Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/NEMO_book.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/NEMO_book.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/NEMO_book.tex	(revision 6436)
@@ -215,6 +215,6 @@
 %\date{\today}
 \date{
-November 2014  \\
-{\small  -- version 3.6 --} \\
+January 2016  \\
+{\small  -- version 3.6 stable --} \\
 ~  \\
 \textit{\small Note du P\^ole de mod\'{e}lisation de l'Institut Pierre-Simon Laplace No 27 }\\
@@ -316,6 +316,6 @@
 \include{./TexFiles/Chapters/Annex_B}			% diffusive operator
 \include{./TexFiles/Chapters/Annex_C}			% Discrete invariants of the eqs.
+\include{./TexFiles/Chapters/Annex_ISO}	                  % Isoneutral diffusion using triads
 \include{./TexFiles/Chapters/Annex_D}			% Coding rules
-\include{./TexFiles/Chapters/Annex_ISO}	                  % Isoneutral diffusion using triads
 %\include{./TexFiles/Chapters/Annex_E}	                  % Notes on some on going staff (no included in the DOC)
 %\include{./TexFiles/Chapters/Annex_Fox-Kemper}   % Notes on Fox-Kemper (no included in the DOC)
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Biblio/Biblio.bib
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Biblio/Biblio.bib	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Biblio/Biblio.bib	(revision 6436)
@@ -149,4 +149,17 @@
   volume = {36},
   pages = {1502--1522}
+}
+
+@ARTICLE{Artale_al_JGR02,
+  author={V. Artale and D. Iudicone and R. Santoleri and V. Rupolo and S. Marullo
+          and F. {D'O}rtenzio},
+  title={Role of surface fluxes in ocean general circulation models using satellite
+          sea surface temperature: Validation of and sensitivity to the forcing
+          frequency of the Mediterranean thermohaline circulation},
+  journal=JGR,
+  year={2002},
+  volume={107},
+  pages={1978-2012},
+  doi = {10.1029/2000JC000452},
 }
 
@@ -276,7 +289,7 @@
   author = {A. Beckmann and H. Goosse},
   title = {A parameterization of ice shelf-ocean interaction for climate models},
-  journal = OM
-  year = {2003}
-  volume = {5}
+  journal = OM,
+  year = {2003},
+  volume = {5},
   pages = {157--170}
 }
@@ -459,4 +472,16 @@
 }
 
+@article{bouffard_Boegman_DAO2013,
+	author = {D. Bouffard and L. Boegman},
+	title = {A diapycnal diffusivity model for stratified environmental flows},
+	volume = {61-62},
+	issn = {03770265},
+	url = {http://dx.doi.org/10.1016/j.dynatmoce.2013.02.002},
+	doi = {10.1016/j.dynatmoce.2013.02.002},
+	journal = DAO,
+	year = {2013},
+	pages = {14--34},
+}
+
 @ARTICLE{Bougeault1989,
   author = {P. Bougeault and P. Lacarrere},
@@ -489,4 +514,27 @@
   volume = {28},  number = {8},
   pages = {1603--1606}
+}
+
+@article{Brankart_OM2013,
+author = "J.-M. Brankart",
+title = "Impact of uncertainties in the horizontal density gradient upon low resolution global ocean modelling ",
+journal = OM,
+year = "2013",
+volume = "66", pages = "64--76",
+issn = "1463-5003",
+doi = "http://dx.doi.org/10.1016/j.ocemod.2013.02.004",
+url = "http://www.sciencedirect.com/science/article/pii/S1463500313000309",
+}
+
+@Article{Brankart_al_GMD2015,
+AUTHOR = {Brankart, J.-M. and Candille, G. and Garnier, F. and Calone, C. and Melet, A. and Bouttier, P.-A. and Brasseur, P. and Verron, J.},
+TITLE = {A generic approach to explicit simulation of uncertainty in the NEMO ocean model},
+JOURNAL = {Geoscientific Model Development},
+VOLUME = {8},
+YEAR = {2015},
+NUMBER = {5},
+PAGES = {1285--1297},
+URL = {http://www.geosci-model-dev.net/8/1285/2015/},
+DOI = {10.5194/gmd-8-1285-2015}
 }
 
@@ -753,4 +801,16 @@
 }
 
+@article{de_lavergne_JPO2016_efficiency,
+	title = {The impact of a variable mixing efficiency on the abyssal overturning},
+	issn = {0022-3670},
+	url = {http://dx.doi.org//10.1175/JPO-D-14-0259.1},
+	doi = {10.1175/JPO-D-14-0259.1},
+	abstract = {In studies of ocean mixing, it is generally assumed that small-scale turbulent overturns lose 15-20 \% of their energy in eroding the background stratification. Accumulating evidence that this energy fraction, or mixing efficiency Rf, significantly varies depending on flow properties challenges this assumption, however. Here, we examine the implications of a varying mixing efficiency for ocean energetics and deep water mass transformation. Combining current parameterizations of internal wave-driven mixing with a recent model expressing Rf as a function of a turbulence intensity parameter Reb = εν/νN2, we show that accounting for reduced mixing efficiencies in regions of weak stratification or energetic turbulence (high Reb) strongly limits the ability of breaking internal waves to supply oceanic potential energy and drive abyssal upwelling. Moving from a fixed Rf = 1/6 to a variable efficiency Rf(Reb) causes Antarctic Bottom Water upwelling induced by locally-dissipating internal tides and lee waves to fall from 9 to 4 Sv, and the corresponding potential energy source to plunge from 97 to 44 GW. When adding the contribution of remotely-dissipating internal tides under idealized distributions of energy dissipation, the total rate of Antarctic Bottom Water upwelling is reduced by about a factor of 2, reaching 5-15 Sv compared to 10-33 Sv for a fixed efficiency. Our results suggest that distributed mixing, overflow-related boundary processes and geothermal heating are more effective in consuming abyssal waters than topographically-enhanced mixing by breaking internal waves. Our calculations also point to the importance of accurately constraining Rf(Reb) and including the effect in ocean models.},
+	journal = {Journal of Physical Oceanography},
+	author = {C. de Lavergne and G. Madec and J. Le Sommer and A. J. G. Nurser and A. C. Naveira Garabato },
+	year = {2016},
+	volume = {46},  pages = {663-–681}
+}
+
 @ARTICLE{Delecluse_Madec_Bk00,
   author = {P. Delecluse and G. Madec},
@@ -763,4 +823,12 @@
 }
 
+@PHDTHESIS{Demange_PhD2014,
+  author = {J. Demange},
+  title = {Sch\'{e}́mas num\'{e}́riques d'advection et de propagation d’ondes de gravit\'{e}́ 
+           dans les mod\`{e}les de circulation oc\'{e}́anique.},
+  school = {Doctorat es Applied Mathematiques, Grenoble University, France},
+  year = {2014},
+  pages = {138pp}
+}
 
 @ARTICLE{Dobricic_al_OS07,
@@ -983,5 +1051,5 @@
   author = {M. Farge},
   title = {Dynamique non lineaire des ondes et des tourbillons dans les equations de Saint Venant},
-  school = {Doctorat es Mathematiques, Paris VI University},
+  school = {Doctorat es Mathematiques, Paris VI University, France},
   year = {1987},
   pages = {401pp}
@@ -1059,4 +1127,16 @@
   volume = {20},  number = {1},
   pages = {150--155},
+}
+
+@Article{Gentemann_al_JGR09,
+  author = 	 {C. L. Gentemann  and P. J. Minnett and B. Ward},
+  title =        {Profiles of Ocean Surface heating ({POSH}): A new model 
+                  of upper ocean diurnal warming},
+  journal = 	 JGR,
+  year = 	 {2009},
+  Volume = 	 {114},
+  Pages = 	 {C07017},
+  doi = 	 {10.1029/2008JC004825},
+  OPTannote = 	 {}
 }
 
@@ -1104,4 +1184,18 @@
 }
 
+@article{goff_JGR2010,
+	author = {J. A. Goff},
+	title = {Global prediction of abyssal hill root-mean-square heights from small-scale altimetric gravity variability},
+	issn = {2156-2202},
+	url = {http://dx.doi.org/10.1029/2010JB007867},
+	doi = {10.1029/2010JB007867},
+	abstract = {Abyssal hills, which are pervasive landforms on the seafloor of the Earth's oceans, represent a potential tectonic record of the history of mid-ocean ridge spreading. However, the most detailed global maps of the seafloor, derived from the satellite altimetry-based gravity field, cannot be used to deterministically characterize such small-scale ({\textless}10 km) morphology. Nevertheless, the small-scale variability of the gravity field can be related to the statistical properties of abyssal hill morphology using the upward continuation formulation. In this paper, I construct a global prediction of abyssal hill root-mean-square (rms) heights from the small-scale variability of the altimetric gravity field. The abyssal hill-related component of the gravity field is derived by first masking distinct features, such as seamounts, mid-ocean ridges, and continental margins, and then applying a newly designed adaptive directional filter algorithm to remove fracture zone/discontinuity fabric. A noise field is derived empirically by correlating the rms variability of the small-scale gravity field to the altimetric noise field in regions of very low relief, and the noise variance is subtracted from the small-scale gravity variance. Suites of synthetically derived, abyssal hill formed gravity fields are generated as a function of water depth, basement rms heights, and sediment thickness and used to predict abyssal hill seafloor rms heights from corrected small-scale gravity rms height. The resulting global prediction of abyssal hill rms heights is validated qualitatively by comparing against expected variations in abyssal hill morphology and quantitatively by comparing against actual measurements of rms heights. Although there is scatter, the prediction appears unbiased.},
+	volume = {115},
+	number = {B12},
+	journal = {Journal of Geophysical Research: Solid Earth},
+	year = {2010},
+	pages = {B12104},
+}
+
 @ARTICLE{Goosse_al_JGR99,
   author = {H. Goosse and E. Deleersnijder and T. Fichefet and M. England},
@@ -1122,4 +1216,14 @@
   doi = {10.1029/2006GL028210},
   url = {http://dx.doi.org/10.1029/2006GL028210}
+}
+
+@ARTICLE{Graham_McDougall_JPO13,
+  author = {F.S. Graham and T.J. McDougall},
+  title = {Quantifying the nonconservative production of conservative temperature, potential temperature, and entropy},
+  journal = JPO,
+  year = {2013},
+  volume = {43},
+  pages = {838--862},
+  url ={http://dx.doi.org/10.1175/JPO-D-11-0188.1}
 }
 
@@ -1197,4 +1301,14 @@
 }
 
+@ARTICLE{Griffies_Hallberg_MWR00,
+  author = {S.M. Griffies and R.H. Hallberg},
+  title = {Biharmonic friction with a Smagorinsky-like viscosity for use in large-scale eddy-permitting ocean models},
+  journal = MWR,
+  year = {2000},
+  volume = {128},  
+  pages = {2935–-2946},
+ url = {http://dx.doi.org/10.1175/1520-0493(2000)128}
+}
+
 @ARTICLE{Guilyardi_al_JC04,
   author = {E. Guilyardi and S. Gualdi and J. M. Slingo and A. Navarra and P. Delecluse 
@@ -1347,4 +1461,13 @@
 }
 
+@ARTICLE{Holland1999, 
+  author = {D. Holland and A. Jenkins},
+  title = {Modeling Thermodynamic Ice-Ocean Interactions at the Base of an Ice Shelf},
+  journal = JPO,
+  year = {1999},
+  volume = {29},  
+  pages = {1787--1800},
+}
+
 @ARTICLE{HollowayOM86,
   author = {Greg Holloway},
@@ -1430,4 +1553,21 @@
 }
 
+@TechReport{Hunter2006,
+  Title                    = {Specification for Test Models of Ice Shelf Cavities},
+  Author                   = {J. R. Hunter},
+  Institution              = {Antarctic Climate \& Ecosystems Cooperative Research Centre Private Bag 80, Hobart, Tasmania 7001},
+  Year                     = {2006},
+}
+
+@TECHREPORT{TEOS10,
+  author = {IOC and SCOR and IAPSO},
+  title = {The international thermodynamic equation of seawater - 2010: Calculation and use of thermodynamic properties},
+  institution = {Intergovernmental Oceanographic Commission},
+  publisher = {Manuals and Guides No. 56, UNESCO (English)},
+  year = {2010},
+  pages = {196pp},
+  url = {http://www.teos-10.org/pubs/TEOS-10_Manual.pdf}
+}
+
 @ARTICLE{Iudicone_al_JPO08b,
   author = {D. Iudicone and G. Madec and B. Blanke and S. Speich},
@@ -1486,4 +1626,17 @@
 }
 
+@article{Jackson_Rehmann_JPO2014,
+	author = {P. R. Jackson and C. R. Rehmann},
+	title = {Experiments on differential scalar mixing in turbulence in a sheared, stratified flow},
+	journal = JPO,
+	volume = {44},
+	issn = {0022-3670},
+	url = {http://dx.doi.org/10.1175/JPO-D-14-0027.1},
+	doi = {10.1175/JPO-D-14-0027.1},
+	number = {10},
+	year = {2014},
+	pages = {2661--2680},
+}
+
 @ARTICLE{Jayne_St_Laurent_GRL01,
   author = {S.R. Jayne and L.C. {St. Laurent}},
@@ -1491,4 +1644,31 @@
   journal = GRL,
   pages = {811--814}
+}
+
+@ARTICLE{Jenkins1991,
+  author = {A. Jenkins},
+  title = {A one-dimensional model of ice shelf-ocean interaction},
+  journal = JGR,
+  year = {1991},
+  volume = {96},  number = {C11},
+  pages = {2298--2312}
+}
+
+@ARTICLE{Jenkins2001,
+  author = {A. Jenkins},
+  title = {The Role of Meltwater Advection in the Formulation of Conservative Boundary Conditions at an Ice-Ocean Interface},
+  journal = JPO,
+  year = {2001},
+  volume = {31},
+  pages = {285--296}
+}
+
+@ARTICLE{Jenkins2010,
+  author = {A. Jenkins},
+  title = {observation and parameterization of ablation at the base of Ronne Ice Shelf, Antarctica},
+  journal = JPO,
+  year = {2010},
+  volume = {40},  number = {10},
+  pages = {2298--2312}
 }
 
@@ -1643,4 +1823,28 @@
 }
 
+@article{Lemarie_OM2012,
+author = "F. Lemari\'{e} and L. Debreu and A.F. Shchepetkin and J.C. McWilliams",
+title = "On the stability and accuracy of the harmonic and biharmonic isoneutral mixing operators in ocean models ",
+journal = OM,
+year = "2012",
+volume = "52–53", pages = "9--35",
+issn = "1463-5003",
+doi = "http://dx.doi.org/10.1016/j.ocemod.2012.04.007",
+url = "http://www.sciencedirect.com/science/article/pii/S1463500312000674",
+}
+
+
+@ARTICLE{Lemarie_OM2015,
+  author = {F. Lemari\'{e} and L. Debreu and J. Demange and  G. Madec and J.M. Molines and M. Honnorat},
+  title = {Stability Constraints for Oceanic Numerical Models: 
+           Implications for the Formulation of time and space Discretizations},
+  journal = OM,
+  year = {2015},
+  volume = {92}, 
+  pages = {124--148},
+  doi = {10.1016/j.ocemod.2015.06.006},
+  url = {http://dx.doi.org/10.1016/j.ocemod.2015.06.006}
+}
+
 @ARTICLE{Lermusiaux2001,
   author = {P. F. J. Lermusiaux},
@@ -1655,5 +1859,5 @@
   author = {M. L\'{e}vy},
   title = {Mod\'{e}lisation des processus biog\'{e}ochimiques en M\'{e}diterran\'{e}e
-	nord-occidentale. Cycle saisonnier et variabilit\'{e} m\'{e}so\'{e}chelle},
+	        nord-occidentale. Cycle saisonnier et variabilit\'{e} m\'{e}so\'{e}chelle},
   school = {Universit\'{e} Pierre et Marie Curie, Paris, France, 207pp},
   year = {1996}
@@ -1783,15 +1987,25 @@
   year = {2009},
   volume = {30},  number = {2-3},
-  pages = {88-94},
+  pages = {88--94},
   doi = {10.1016/j.ocemod.2009.06.006},
-  url = {http://dx.doi.org/}
-}
-
-@ARTICLE{Leclair_Madec_OM10s,
+  url = {http://dx.doi.org/10.1016/j.ocemod.2009.06.006}
+}
+
+@ARTICLE{Leclair_Madec_OM11,
   author = {M. Leclair and G. Madec},
   title = {$\tilde{z}$-coordinate, an Arbitrary Lagrangian-Eulerian coordinate separating high and low frequency},
   journal = OM,
-  year = {2010},
-  pages = {submitted},
+  year = {2011},
+  volume = {37},  pages = {139--152}, 
+  doi = {10.1016/j.ocemod.2011.02.001},
+  url = {http://dx.doi.org/10.1016/j.ocemod.2011.02.001}
+}
+
+@ARTICLE{Lele_JCP1992,
+  author = {S.K. Lele},
+  title = {Compact finite difference schemes with spectral-like resolution},
+  journal = JCP,
+  year = {1992},
+  volume = {103}, pages = {16--42}
 }
 
@@ -1803,6 +2017,5 @@
   journal = JC,
   year = {2003},
-  volume = {16},  number = {20},
-  pages = {3330--3343}
+  volume = {16},  number = {20}, pages = {3330--3343}
 }
 
@@ -1900,4 +2113,12 @@
 }
 
+@ARTICLE{Losch2008,
+  author = {M. Losch},
+  title = {Modeling ice shelf cavities in a z coordinate ocean general circulation model},
+  journal = JGR,
+  year = {2008},
+  volume = {113},  number = {C13},
+}
+
 @TECHREPORT{Lott1989,
   author = {F. Lott and G. Madec},
@@ -2074,17 +2295,4 @@
   volume = {3},
   pages = {1--20}
-}
-
-
-@article{Martin_Adcroft_OM10,
-author = {T. Martin and A. Adcroft},
-title = {Parameterizing the fresh-water flux from land ice to ocean with interactive icebergs in a coupled climate model},
-journal = OM,
-year = {2010},
-volume = {34}, number = {3--4},
-pages = {111--124},
-issn = {1463-5003},
-doi = {10.1016/j.ocemod.2010.05.001},
-url = {http://dx.doi.org/10.1016/j.ocemod.2010.05.001}
 }
 
@@ -2100,4 +2308,28 @@
   doi = {10.1016/j.ocemod.2007.07.005},
   url = {http://dx.doi.org/10.1016/j.ocemod.2007.07.005}
+}
+
+@Article{Marsh_GMD2015,
+AUTHOR = {R. Marsh and V. O. Ivchenko and N. Skliris and S. Alderson and G. R. Bigg and G. Madec and A. T. Blaker and Y. Aksenov and B. Sinha and A. C. Coward and J. Le Sommer and N. Merino and V. B. Zalesny},
+TITLE = {NEMO-ICB (v1.0): interactive icebergs in the NEMO ocean model globally configured at eddy-permitting resolution},
+JOURNAL = {Geoscientific Model Development},
+VOLUME = {8},
+YEAR = {2015},
+NUMBER = {5},
+PAGES = {1547--1562},
+url = {HTTP://www.geosci-model-dev.net/8/1547/2015/},
+DOI = {10.5194/gmd-8-1547-2015}
+}
+
+@article{Martin_Adcroft_OM10,
+author = {T. Martin and A. Adcroft},
+title = {Parameterizing the fresh-water flux from land ice to ocean with interactive icebergs in a coupled climate model},
+journal = OM,
+year = {2010},
+volume = {34}, number = {3--4},
+pages = {111--124},
+issn = {1463-5003},
+doi = {10.1016/j.ocemod.2010.05.001},
+url = {http://dx.doi.org/10.1016/j.ocemod.2010.05.001}
 }
 
@@ -2249,4 +2481,15 @@
 }
 
+
+@ARTICLE{Morel_Berthon_LO89,
+  author = {A. Morel and J.-F. Berthon},
+  title = {Surface pigments, algal biomass profiles, and potential production of the euphotic layer: 
+           Relationships reinvestigated in view of remote-sensing applications},
+  journal = {Limnol. Oceanogr.},
+  year = {1989},
+  volume = {34(8)},
+  pages = {1545--1562}
+}
+
 @ARTICLE{Morel_Maritorena_JGR01,
   author = {A. Morel and S. Maritorena},
@@ -2297,4 +2540,5 @@
   title = {Estimates of the local rate of vertical diﬀusion from dissipation measurements},
   journal = JPO,
+  year = {1980},
   volume = {10},
   pages = {83--89}
@@ -2470,4 +2714,16 @@
 }
 
+@Article{Rodgers_2014,
+AUTHOR = {Rodgers, K. B. and Aumont, O. and Mikaloff Fletcher, S. E. and Plancherel, Y. and Bopp, L. and de Boyer Mont\'egut, C. and Iudicone, D. and Keeling, R. F. and Madec, G. and Wanninkhof, R.},
+TITLE = {Strong sensitivity of Southern Ocean carbon uptake and nutrient cycling to wind stirring},
+JOURNAL = {Biogeosciences},
+VOLUME = {11},
+YEAR = {2014},
+NUMBER = {15},
+PAGES = {4077--4098},
+URL = {HTTP://www.biogeosciences.net/11/4077/2014/},
+DOI = {10.5194/bg-11-4077-2014}
+}
+
 @ARTICLE{Rodi_1987,
   author = {W. Rodi},
@@ -2486,4 +2742,27 @@
   year = {1986},
   editor = {J.J. O'Brien}
+}
+
+@article{Roquet_OM2015,
+author = "F. Roquet and G. Madec and T.J. McDougall and P.M. Barker",
+title = "Accurate polynomial expressions for the density and specific volume of seawater using the TEOS-10 standard ",
+journal = OM,
+volume = "90",
+pages = "29--43",
+year = "2015",
+issn = "1463-5003",
+doi = "10.1016/j.ocemod.2015.04.002",
+url = "http://dx.doi.org/10.1016/j.ocemod.2015.04.002"
+}
+
+@article{Roquet_JPO2015,
+author = "F. Roquet and G. Madec and L. Brodeau and J. Nycander",
+title = "Defining a Simplified Yet Realistic Equation of State for Seawater",
+journal = JPO,
+volume = "45",
+pages = "2564--2579",
+year = "2015",
+doi = "10.1175/JPO-D-15-0080.1",
+url = "http://dx.doi.org/10.1175/JPO-D-15-0080.1"
 }
 
@@ -2498,4 +2777,15 @@
 }
 
+@ARTICLE{Rousset_GMD2015,
+  author = {C. Rousset and M. Vancoppenolle and G. Madec and T. Fichefet and S. Flavoni 
+            and A. Barth\'{e}lemy and R. Benshila and J. Chanut and C. L\'{e}vy and S. Masson and F. Vivier },
+  title  = {The Louvain-La-Neuve sea-ice model LIM3.6: Global and regional capabilities},
+  journal= {Geoscientific Model Development},
+  year = {2015},
+  volume = {8}, pages={2991--3005},
+  doi = {10.5194/gmd-8-2991-2015},
+  url = {http://dx.doi.org/10.5194/gmd-8-2991-2015}
+}
+
 @ARTICLE{Sadourny1975,
   author = {R. Sadourny},
@@ -2514,4 +2804,14 @@
   volume = {87},
   pages = {394--409}
+}
+
+@ARTICLE{Saunders_JAS82,
+  author={P. M. Saunders},
+  title={{The Temperature at the Ocean-air Interface}},
+  journal=JAS,
+  year={1967},
+  volume={24},
+  pages={269-273},
+  doi = {10.1175/1520-0469(1967)024<0269:TTATOA>2.0.CO;2},
 }
 
@@ -2570,4 +2870,13 @@
 }
 
+@INBOOK{Smagorinsky_93,
+  author = {Smagorinsky, J.},
+  chapter = {Some historical remarks on the use of non-linear viscosities},
+  title = {Large Eddy Simulation of Complex Engineering and Geophysical Flows},
+  pages = {3--36},
+  year = {1993},
+  publisher = {Cambridge University Press, B. Galperin and S. A. Orszag (eds.)},
+}
+
 @ARTICLE{Song_Haidvogel_JCP94,
   author = {Y. Song and D. Haidvogel},
@@ -2688,4 +2997,15 @@
   volume = {359},
   pages = {123--129}
+}
+
+@ARTICLE{Takaya_al_JGR10,
+  author = {Y. Takaya and J-R. Bidlot and A. C. M. Beljaars and 
+                  P. A. E. M. Janssen},
+  title = {Refinements to a prognostic scheme of sea surface skin temperature},
+  journal = JGR,
+  year   = 	 {2010},
+  Volume = 	 {115},
+  Pages  = 	 {C06009},
+  doi    = {10.1029/2009JC005985},
 }
 
@@ -2793,4 +3113,14 @@
 }
 
+@ARTICLE{Tu_Tsuang_GRL05,
+  title={{Cool-skin simulation by a one-column ocean model}},
+  author={{C-Y}. Tu  and {B-J}. Tsuang},
+  journal=GRL,
+  year={2005},
+  volume={32},
+  pages={L22602},
+  doi = {10.1029/2005GL024252},
+}
+
 @ARTICLE{Umlauf_Burchard_JMS03,
   author = {L. Umlauf and H. Burchard},
@@ -2842,4 +3172,13 @@
   volume = {27},
   pages = {54--69}
+}
+
+@book{Vallis06,
+author = {Vallis, G. K.},
+title = {Atmospheric and Oceanic Fluid Dynamics},
+publisher = {Cambridge University Press},
+address = {Cambridge, U.K.},
+year = {2006},
+pages = {745},
 }
 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Abstracts_Foreword.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Abstracts_Foreword.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Abstracts_Foreword.tex	(revision 6436)
@@ -13,13 +13,13 @@
 be a flexible tool for studying the ocean and its interactions with the others components of 
 the earth climate system over a wide range of space and time scales. 
-Prognostic variables are the three-dimensional velocity field, a linear 
-or non-linear sea surface height, the temperature and the salinity. In the horizontal direction, 
-the model uses a curvilinear orthogonal grid and in the vertical direction, a full or partial step 
-$z$-coordinate, or $s$-coordinate, or a mixture of the two. The distribution of variables is a 
-three-dimensional Arakawa C-type grid. Various physical choices are available to describe 
-ocean physics, including TKE, GLS and KPP vertical physics. Within NEMO, the ocean is 
-interfaced with a sea-ice model (LIM v2 and v3), passive tracer and biogeochemical models (TOP) 
-and, via the OASIS coupler, with several atmospheric general circulation models. It also 
-support two-way grid embedding via the AGRIF software.
+Prognostic variables are the three-dimensional velocity field, a non-linear sea surface height, 
+the \textit{Conservative} Temperature and the \textit{Absolute} Salinity. 
+In the horizontal direction, the model uses a curvilinear orthogonal grid and in the vertical direction, 
+a full or partial step $z$-coordinate, or $s$-coordinate, or a mixture of the two. 
+The distribution of variables is a three-dimensional Arakawa C-type grid. 
+Various physical choices are available to describe ocean physics, including TKE, and GLS vertical physics. 
+Within NEMO, the ocean is interfaced with a sea-ice model (LIM or CICE), passive tracer and 
+biogeochemical models (TOP) and, via the OASIS coupler, with several atmospheric general circulation models. 
+It also support two-way grid embedding via the AGRIF software.
 
 % ================================================================
@@ -31,13 +31,13 @@
 interactions avec les autres composantes du syst\`{e}me climatique terrestre. 
 Les variables pronostiques sont le champ tridimensionnel de vitesse, une hauteur de la mer 
-lin\'{e}aire ou non, la temperature et la salinit\'{e}. 
+lin\'{e}aire, la Temp\'{e}rature Conservative et la Salinit\'{e} Absolue. 
 La distribution des variables se fait sur une grille C d'Arakawa tridimensionnelle utilisant une 
 coordonn\'{e}e verticale $z$ \`{a} niveaux entiers ou partiels, ou une coordonn\'{e}e s, ou encore 
 une combinaison des deux. Diff\'{e}rents choix sont propos\'{e}s pour d\'{e}crire la physique 
-oc\'{e}anique, incluant notamment des physiques verticales TKE, GLS et KPP. A travers l'infrastructure 
-NEMO, l'oc\'{e}an est interfac\'{e} avec des mod\`{e}les de glace de mer, de biog\'{e}ochimie 
-et de traceurs passifs, et, via le coupleur OASIS, \`{a} plusieurs mod\`{e}les de circulation 
-g\'{e}n\'{e}rale atmosph\'{e}rique. Il supporte \'{e}galement l'embo\^{i}tement interactif de 
-maillages via le logiciel AGRIF.
+oc\'{e}anique, incluant notamment des physiques verticales TKE et GLS. A travers l'infrastructure 
+NEMO, l'oc\'{e}an est interfac\'{e} avec des mod\`{e}les de glace de mer (LIM ou CICE), 
+de biog\'{e}ochimie marine et de traceurs passifs, et, via le coupleur OASIS, \`{a} plusieurs 
+mod\`{e}les de circulation g\'{e}n\'{e}rale atmosph\'{e}rique. 
+Il supporte \'{e}galement l'embo\^{i}tement interactif de maillages via le logiciel AGRIF.
 } 
 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Annex_C.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Annex_C.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Annex_C.tex	(revision 6436)
@@ -410,5 +410,5 @@
 \end{aligned}   } \right.
 \end{equation} 
-where the indices $i_p$ and $k_p$ take the following value: 
+where the indices $i_p$ and $j_p$ take the following value: 
 $i_p = -1/2$ or $1/2$ and $j_p = -1/2$ or $1/2$,
 and the vorticity triads, ${^i_j}\mathbb{Q}^{i_p}_{j_p}$, defined at $T$-point, are given by: 
@@ -1103,5 +1103,5 @@
 The discrete formulation of the horizontal diffusion of momentum ensures the 
 conservation of potential vorticity and the horizontal divergence, and the 
-dissipation of the square of these quantities (i.e. enstrophy and the 
+dissipation of the square of these quantities ($i.e.$ enstrophy and the 
 variance of the horizontal divergence) as well as the dissipation of the 
 horizontal kinetic energy. In particular, when the eddy coefficients are 
@@ -1127,26 +1127,17 @@
 &\int \limits_D \frac{1} {e_3 } \textbf{k} \cdot \nabla \times 
 	\Bigl[    \nabla_h  \left( A^{\,lm}\;\chi  \right)
-	          - \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)    \Bigr]\;dv  = 0
-\end{flalign*}
+	        - \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)    \Bigr]\;dv   \\ 
+%\end{flalign*}
 %%%%%%%%%%  recheck here....  (gm)
-\begin{flalign*}
-= \int \limits_D  -\frac{1} {e_3 } \textbf{k} \cdot \nabla \times 
-	\Bigl[ \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)  \Bigr]\;dv &&& \\ 
-\end{flalign*}
-\begin{flalign*}
+%\begin{flalign*}
+=& \int \limits_D  -\frac{1} {e_3 } \textbf{k} \cdot \nabla \times 
+	\Bigl[ \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)  \Bigr]\;dv  \\ 
+%\end{flalign*}
+%\begin{flalign*}
 \equiv& \sum\limits_{i,j}
 	\left\{
-	\delta_{i+1/2} 
-	\left[ 
-	\frac {e_{2v}} {e_{1v}\,e_{3v}}  \delta_i
-		\left[ A_f^{\,lm} e_{3f} \zeta  \right]
-	 \right]
- 	+ \delta_{j+1/2} 
-	\left[ 
-	\frac {e_{1u}} {e_{2u}\,e_{3u}} \delta_j 
-		\left[ A_f^{\,lm} e_{3f} \zeta  \right]
-	\right]
-	\right\} 
-	&& \\ 
+	  \delta_{i+1/2} \left[  \frac {e_{2v}} {e_{1v}\,e_{3v}}  \delta_i \left[ A_f^{\,lm} e_{3f} \zeta  \right]  \right]
+ 	+ \delta_{j+1/2} \left[  \frac {e_{1u}} {e_{2u}\,e_{3u}}  \delta_j \left[ A_f^{\,lm} e_{3f} \zeta  \right]  \right]
+	\right\} 	 \\ 
 %
 \intertext{Using \eqref{DOM_di_adj}, it follows:}
@@ -1154,10 +1145,8 @@
 \equiv& \sum\limits_{i,j,k} 
 	-\,\left\{
-	   \frac{e_{2v}} {e_{1v}\,e_{3v}}  \delta_i
-		\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_i \left[ 1\right]
-	+ \frac{e_{1u}} {e_{2u}\,e_{3u}} \delta_j 
-		\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_j \left[ 1\right]
+	   \frac{e_{2v}} {e_{1v}\,e_{3v}}  \delta_i	\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_i \left[ 1\right]
+	 + \frac{e_{1u}} {e_{2u}\,e_{3u}}  \delta_j 	\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_j \left[ 1\right]
 	\right\} \quad \equiv 0 
-	&& \\ 
+	 \\ 
 \end{flalign*}
 
@@ -1167,5 +1156,4 @@
 \subsection{Dissipation of Horizontal Kinetic Energy}
 \label{Apdx_C.3.2}
-
 
 The lateral momentum diffusion term dissipates the horizontal kinetic energy:
@@ -1221,5 +1209,4 @@
 \label{Apdx_C.3.3}
 
-
 The lateral momentum diffusion term dissipates the enstrophy when the eddy 
 coefficients are horizontally uniform:
@@ -1228,7 +1215,7 @@
 	\left[   \nabla_h \left( A^{\,lm}\;\chi  \right)
 	       - \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)   \right]\;dv &&&\\
-&= A^{\,lm} \int \limits_D \zeta \textbf{k} \cdot \nabla \times 
+&\quad = A^{\,lm} \int \limits_D \zeta \textbf{k} \cdot \nabla \times 
  	\left[    \nabla_h \times \left( \zeta \; \textbf{k} \right)   \right]\;dv &&&\\
-&\equiv A^{\,lm} \sum\limits_{i,j,k}  \zeta \;e_{3f} 
+&\quad \equiv A^{\,lm} \sum\limits_{i,j,k}  \zeta \;e_{3f} 
 	\left\{     \delta_{i+1/2} \left[  \frac{e_{2v}} {e_{1v}\,e_{3v}} \delta_i \left[ e_{3f} \zeta  \right]   \right]
 	          + \delta_{j+1/2} \left[  \frac{e_{1u}} {e_{2u}\,e_{3u}} \delta_j \left[ e_{3f} \zeta  \right]   \right]      \right\}   &&&\\ 
@@ -1236,8 +1223,7 @@
 \intertext{Using \eqref{DOM_di_adj}, it follows:}
 %
-&\equiv  - A^{\,lm} \sum\limits_{i,j,k} 
+&\quad \equiv  - A^{\,lm} \sum\limits_{i,j,k} 
 	\left\{    \left(  \frac{1} {e_{1v}\,e_{3v}}  \delta_i \left[ e_{3f} \zeta  \right]  \right)^2   b_v
-	         + \left(  \frac{1} {e_{2u}\,e_{3u}}  \delta_j \left[ e_{3f} \zeta  \right] \right)^2   b_u  \right\}      &&&\\
-& \leq \;0       &&&\\ 
+	         + \left(  \frac{1} {e_{2u}\,e_{3u}}  \delta_j \left[ e_{3f} \zeta  \right] \right)^2   b_u  \right\}  \quad \leq \;0    &&&\\
 \end{flalign*}
 
@@ -1250,16 +1236,16 @@
 When the horizontal divergence of the horizontal diffusion of momentum 
 (discrete sense) is taken, the term associated with the vertical curl of the 
-vorticity is zero locally, due to (!!! II.1.8  !!!!!). The resulting term conserves the 
-$\chi$ and dissipates $\chi^2$ when the eddy coefficients are 
-horizontally uniform.
+vorticity is zero locally, due to \eqref{Eq_DOM_div_curl}. 
+The resulting term conserves the $\chi$ and dissipates $\chi^2$ 
+when the eddy coefficients are horizontally uniform.
 \begin{flalign*}
 & \int\limits_D  \nabla_h \cdot 
 	\Bigl[     \nabla_h \left( A^{\,lm}\;\chi \right)
 	          - \nabla_h \times \left( A^{\,lm}\;\zeta \;\textbf{k} \right)    \Bigr]  dv
-= \int\limits_D  \nabla_h \cdot \nabla_h \left( A^{\,lm}\;\chi  \right)   dv   &&&\\
+= \int\limits_D  \nabla_h \cdot \nabla_h \left( A^{\,lm}\;\chi  \right)   dv   \\
 %
 &\equiv \sum\limits_{i,j,k} 
 	\left\{   \delta_i \left[ A_u^{\,lm} \frac{e_{2u}\,e_{3u}} {e_{1u}}  \delta_{i+1/2} \left[ \chi \right]  \right]
-	        + \delta_j \left[ A_v^{\,lm} \frac{e_{1v}\,e_{3v}} {e_{2v}}  \delta_{j+1/2} \left[ \chi \right]  \right]    \right\}    &&&\\ 
+	        + \delta_j \left[ A_v^{\,lm} \frac{e_{1v}\,e_{3v}} {e_{2v}}  \delta_{j+1/2} \left[ \chi \right]  \right]    \right\}    \\ 
 %
 \intertext{Using \eqref{DOM_di_adj}, it follows:}
@@ -1267,6 +1253,6 @@
 &\equiv \sum\limits_{i,j,k} 
 	- \left\{   \frac{e_{2u}\,e_{3u}} {e_{1u}}  A_u^{\,lm} \delta_{i+1/2} \left[ \chi \right] \delta_{i+1/2} \left[ 1 \right] 
-	          + \frac{e_{1v}\,e_{3v}}  {e_{2v}}  A_v^{\,lm} \delta_{j+1/2} \left[ \chi \right] \delta_{j+1/2} \left[ 1 \right]    \right\} 
-	\qquad \equiv 0     &&& \\ 
+	          + \frac{e_{1v}\,e_{3v}} {e_{2v}}  A_v^{\,lm} \delta_{j+1/2} \left[ \chi \right] \delta_{j+1/2} \left[ 1 \right]    \right\} 
+	\quad \equiv 0      \\ 
 \end{flalign*}
 
@@ -1281,5 +1267,5 @@
 	\left[    \nabla_h              \left( A^{\,lm}\;\chi                    \right)
 	        - \nabla_h   \times  \left( A^{\,lm}\;\zeta \;\textbf{k} \right)    \right]\;  dv
- = A^{\,lm}   \int\limits_D \chi \;\nabla_h \cdot \nabla_h \left( \chi \right)\;  dv    &&&\\ 
+ = A^{\,lm}   \int\limits_D \chi \;\nabla_h \cdot \nabla_h \left( \chi \right)\;  dv    \\ 
 %
 &\equiv A^{\,lm}  \sum\limits_{i,j,k}  \frac{1} {e_{1t}\,e_{2t}\,e_{3t}}  \chi 
@@ -1287,5 +1273,5 @@
 	   \delta_i  \left[   \frac{e_{2u}\,e_{3u}} {e_{1u}}  \delta_{i+1/2} \left[ \chi \right]   \right]
 	+ \delta_j  \left[   \frac{e_{1v}\,e_{3v}} {e_{2v}}   \delta_{j+1/2} \left[ \chi \right]   \right]
-	\right\} \;   e_{1t}\,e_{2t}\,e_{3t}    &&&\\ 
+	\right\} \;   e_{1t}\,e_{2t}\,e_{3t}    \\ 
 %
 \intertext{Using \eqref{DOM_di_adj}, it turns out to be:}
@@ -1293,7 +1279,6 @@
 &\equiv - A^{\,lm} \sum\limits_{i,j,k}
 	\left\{    \left(  \frac{1} {e_{1u}}  \delta_{i+1/2}  \left[ \chi \right]  \right)^2  b_u
-                 + \left(  \frac{1} {e_{2v}}  \delta_{j+1/2}  \left[ \chi \right]  \right)^2  b_v    \right\} \;    &&&\\
-%
-&\leq 0              &&&\\
+            + \left(  \frac{1} {e_{2v}}  \delta_{j+1/2}  \left[ \chi \right]  \right)^2  b_v    \right\}    
+\quad \leq 0             \\
 \end{flalign*}
 
@@ -1303,5 +1288,4 @@
 \section{Conservation Properties on Vertical Momentum Physics}
 \label{Apdx_C_4}
-
 
 As for the lateral momentum physics, the continuous form of the vertical diffusion 
@@ -1319,6 +1303,6 @@
 	\left(   \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)\; dv    \quad &\leq 0     \\
 \end{align*}
+
 The first property is obvious. The second results from:
-
 \begin{flalign*}
 \int\limits_D 
@@ -1359,4 +1343,5 @@
 	e_{1f}\,e_{2f}\,e_{3f} \; \equiv 0   && \\
 \end{flalign*}
+
 If the vertical diffusion coefficient is uniform over the whole domain, the 
 enstrophy is dissipated, $i.e.$
@@ -1366,6 +1351,6 @@
 		\left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)   \right)\; dv = 0   &&&\\
 \end{flalign*}
+
 This property is only satisfied in $z$-coordinates:
-
 \begin{flalign*}
 \int\limits_D \zeta \, \textbf{k} \cdot \nabla \times 
@@ -1477,10 +1462,8 @@
 
 The numerical schemes used for tracer subgridscale physics are written such 
-that the heat and salt contents are conserved (equations in flux form, second 
-order centered finite differences). Since a flux form is used to compute the 
-temperature and salinity, the quadratic form of these quantities (i.e. their variance) 
-globally tends to diminish. As for the advection term, there is generally no strict 
-conservation of mass, even if in practice the mass is conserved to a very high 
-accuracy. 
+that the heat and salt contents are conserved (equations in flux form). 
+Since a flux form is used to compute the temperature and salinity, 
+the quadratic form of these quantities ($i.e.$ their variance) globally tends to diminish. 
+As for the advection term, there is conservation of mass only if the Equation Of Seawater is linear. 
 
 % -------------------------------------------------------------------------------------------------------------
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Annex_D.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Annex_D.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Annex_D.tex	(revision 6436)
@@ -120,5 +120,5 @@
 \hline
 public  \par or  \par module variable& 
-\textbf{m n} \par \textit{but not} \par \textbf{nn\_}& 
+\textbf{m n} \par \textit{but not} \par \textbf{nn\_ np\_}& 
 \textbf{a b e f g h o q r} \par \textbf{t} \textit{to} \textbf{x} \par but not \par \textbf{fs rn\_}& 
 \textbf{l} \par \textit{but not} \par \textbf{lp ld} \par \textbf{ ll ln\_}& 
@@ -156,5 +156,5 @@
 \hline
 parameter& 
-\textbf{jp}& 
+\textbf{jp np\_}& 
 \textbf{pp}& 
 \textbf{lp}& 
@@ -190,4 +190,8 @@
 %--------------------------------------------------------------------------------------------------------------
 
+N.B.   Parameter here, in not only parameter in the \textsc{Fortran} acceptation, it is also used for code variables 
+that are read in namelist and should never been modified during a simulation. 
+It is the case, for example, for the size of a domain (jpi,jpj,jpk).
+
 \newpage
 % ================================================================
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_DIA.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_DIA.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_DIA.tex	(revision 6436)
@@ -2,10 +2,10 @@
 % Chapter I/O & Diagnostics
 % ================================================================
-\chapter{Ouput and Diagnostics (IOM, DIA, TRD, FLO)}
+\chapter{Output and Diagnostics (IOM, DIA, TRD, FLO)}
 \label{DIA}
 \minitoc
 
 \newpage
-$\ $\newline    % force a new ligne
+$\ $\newline    % force a new line
 
 % ================================================================
@@ -48,5 +48,7 @@
 
 
-Since version 3.2, iomput is the NEMO output interface of choice. It has been designed to be simple to use, flexible and efficient. The two main purposes of iomput are: 
+Since version 3.2, iomput is the NEMO output interface of choice. 
+It has been designed to be simple to use, flexible and efficient. 
+The two main purposes of iomput are: 
 \begin{enumerate}
 \item The complete and flexible control of the output files through external XML files adapted by the user from standard templates. 
@@ -1116,6 +1118,5 @@
 % -------------------------------------------------------------------------------------------------------------
 \section[Tracer/Dynamics Trends (TRD)]
-                  {Tracer/Dynamics Trends  (\key{trdtra}, \key{trddyn},    \\ 
-                                                             \key{trddvor}, \key{trdmld})}
+                  {Tracer/Dynamics Trends  (\ngn{namtrd})}
 \label{DIA_trd}
 
@@ -1124,40 +1125,33 @@
 %-------------------------------------------------------------------------------------------------------------
 
-When \key{trddyn} and/or \key{trddyn} CPP variables are defined, each 
-trend of the dynamics and/or temperature and salinity time evolution equations 
-is stored in three-dimensional arrays just after their computation ($i.e.$ at the end 
-of each $dyn\cdots.F90$ and/or $tra\cdots.F90$ routines). Options are defined by
-\ngn{namtrd} namelist variables. These trends are then 
-used in \mdl{trdmod} (see TRD directory) every \textit{nn\_trd } time-steps.
-
-What is done depends on the CPP keys defined:
+Each trend of the dynamics and/or temperature and salinity time evolution equations 
+can be send to \mdl{trddyn} and/or \mdl{trdtra} modules (see TRD directory) just after their computation 
+($i.e.$ at the end of each $dyn\cdots.F90$ and/or $tra\cdots.F90$ routines). 
+This capability is controlled by options offered in \ngn{namtrd} namelist. 
+Note that the output are done with xIOS, and therefore the \key{IOM} is required.
+
+What is done depends on the \ngn{namtrd} logical set to \textit{true}:
 \begin{description}
-\item[\key{trddyn}, \key{trdtra}] : a check of the basin averaged properties of the momentum 
-and/or tracer equations is performed ; 
-\item[\key{trdvor}] : a vertical summation of the moment tendencies is performed, 
-then the curl is computed to obtain the barotropic vorticity tendencies which are output ;
-\item[\key{trdmld}] : output of the tracer tendencies averaged vertically  
-either over the mixed layer (\np{nn\_ctls}=0), 
-or       over a fixed number of model levels (\np{nn\_ctls}$>$1 provides the number of level), 
-or       over a spatially varying but temporally fixed number of levels (typically the base 
-of the winter mixed layer) read in \ifile{ctlsurf\_idx} (\np{nn\_ctls}=1) ;
+\item[\np{ln\_glo\_trd}] : at each \np{nn\_trd} time-step a check of the basin averaged properties 
+of the momentum and tracer equations is performed. This also includes a check of $T^2$, $S^2$, 
+$\tfrac{1}{2} (u^2+v2)$, and potential energy time evolution equations properties ; 
+\item[\np{ln\_dyn\_trd}] : each 3D trend of the evolution of the two momentum components is output ; 
+\item[\np{ln\_dyn\_mxl}] : each 3D trend of the evolution of the two momentum components averaged 
+                           over the mixed layer is output  ; 
+\item[\np{ln\_vor\_trd}] : a vertical summation of the moment tendencies is performed, 
+                           then the curl is computed to obtain the barotropic vorticity tendencies which are output ;
+\item[\np{ln\_KE\_trd}]  : each 3D trend of the Kinetic Energy equation is output ;
+\item[\np{ln\_tra\_trd}] : each 3D trend of the evolution of temperature and salinity is output ;
+\item[\np{ln\_tra\_mxl}] : each 2D trend of the evolution of temperature and salinity averaged 
+                           over the mixed layer is output ;
 \end{description}
-
-The units in the output file can be changed using the \np{nn\_ucf} namelist parameter. 
-For example, in case of salinity tendency the units are given by PSU/s/\np{nn\_ucf}.
-Setting \np{nn\_ucf}=86400 ($i.e.$ the number of second in a day) provides the tendencies in PSU/d.
-
-When \key{trdmld} is defined, two time averaging procedure are proposed.
-Setting \np{ln\_trdmld\_instant} to \textit{true}, a simple time averaging is performed, 
-so that the resulting tendency is the contribution to the change of a quantity between 
-the two instantaneous values taken at the extremities of the time averaging period.
-Setting \np{ln\_trdmld\_instant} to \textit{false}, a double time averaging is performed, 
-so that the resulting tendency is the contribution to the change of a quantity between 
-two \textit{time mean} values. The later option requires the use of an extra file, \ifile{restart\_mld}  
-(\np{ln\_trdmld\_restart}=true), to restart a run.
-
 
 Note that the mixed layer tendency diagnostic can also be used on biogeochemical models 
 via the \key{trdtrc} and \key{trdmld\_trc} CPP keys.
+
+\textbf{Note that} in the current version (v3.6), many changes has been introduced but not fully tested. 
+In particular, options associated with \np{ln\_dyn\_mxl}, \np{ln\_vor\_trd}, and \np{ln\_tra\_mxl} 
+are not working, and none of the option have been tested with variable volume ($i.e.$ \key{vvl} defined).
+
 
 % -------------------------------------------------------------------------------------------------------------
@@ -1280,28 +1274,26 @@
 \label{DIA_diag_harm}
 
-A module is available to compute the amplitude and phase for tidal waves. 
-This diagnostic is actived with \key{diaharm}.
-
 %------------------------------------------namdia_harm----------------------------------------------------
 \namdisplay{namdia_harm}
 %----------------------------------------------------------------------------------------------------------
 
-Concerning the on-line Harmonic analysis, some parameters are available in namelist
-\ngn{namdia\_harm} :
-
-- \texttt{nit000\_han} is the first time step used for harmonic analysis
-
-- \texttt{nitend\_han} is the last time step used for harmonic analysis
-
-- \texttt{nstep\_han} is the time step frequency for harmonic analysis
-
-- \texttt{nb\_ana} is the number of harmonics to analyse
-
-- \texttt{tname} is an array with names of tidal constituents to analyse
-
-\texttt{nit000\_han} and \texttt{nitend\_han} must be between \texttt{nit000} and \texttt{nitend} of the simulation.
+A module is available to compute the amplitude and phase of tidal waves. 
+This on-line Harmonic analysis is actived with \key{diaharm}.
+Some parameters are available in namelist \ngn{namdia\_harm} :
+
+- \np{nit000\_han} is the first time step used for harmonic analysis
+
+- \np{nitend\_han} is the last time step used for harmonic analysis
+
+- \np{nstep\_han} is the time step frequency for harmonic analysis
+
+- \np{nb\_ana} is the number of harmonics to analyse
+
+- \np{tname} is an array with names of tidal constituents to analyse
+
+\np{nit000\_han} and \np{nitend\_han} must be between \np{nit000} and \np{nitend} of the simulation.
 The restart capability is not implemented.
 
-The Harmonic analysis solve this equation:
+The Harmonic analysis solve the following equation:
 \begin{equation}
 h_{i} - A_{0} + \sum^{nb\_ana}_{j=1}[A_{j}cos(\nu_{j}t_{j}-\phi_{j})] = e_{i}
@@ -1324,6 +1316,6 @@
 \label{DIA_diag_dct}
 
-A module is available to compute the transport of volume, heat and salt through sections. This diagnostic
-is actived with \key{diadct}.
+A module is available to compute the transport of volume, heat and salt through sections. 
+This diagnostic is actived with \key{diadct}.
 
 Each section is defined by the coordinates of its 2 extremities. The pathways between them are contructed
@@ -1347,9 +1339,9 @@
 %-------------------------------------------------------------------------------------------------------------
 
-\texttt{nn\_dct}: frequency of instantaneous transports computing
-
-\texttt{nn\_dctwri}: frequency of writing ( mean of instantaneous transports )
-
-\texttt{nn\_debug}: debugging of the section
+\np{nn\_dct}: frequency of instantaneous transports computing
+
+\np{nn\_dctwri}: frequency of writing ( mean of instantaneous transports )
+
+\np{nn\_debug}: debugging of the section
 
 \subsubsection{ To create a binary file containing the pathway of each section }
@@ -1482,5 +1474,5 @@
 the \key{diahth} CPP key: 
 
-- the mixed layer depth (based on a density criterion, \citet{de_Boyer_Montegut_al_JGR04}) (\mdl{diahth})
+- the mixed layer depth (based on a density criterion \citep{de_Boyer_Montegut_al_JGR04}) (\mdl{diahth})
 
 - the turbocline depth (based on a turbulent mixing coefficient criterion) (\mdl{diahth})
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_DOM.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_DOM.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_DOM.tex	(revision 6436)
@@ -1,4 +1,4 @@
 % ================================================================
-% Chapter 2 � Space and Time Domain (DOM)
+% Chapter 2 ——— Space and Time Domain (DOM)
 % ================================================================
 \chapter{Space Domain (DOM) }
@@ -138,5 +138,5 @@
 and $f$-points, and its divergence defined at $t$-points:
 \begin{eqnarray}  \label{Eq_DOM_curl}
- \nabla \times {\rm {\bf A}}\equiv &
+ \nabla \times {\rm{\bf A}}\equiv &
       \frac{1}{e_{2v}\,e_{3vw} } \ \left( \delta_{j +1/2} \left[e_{3w}\,a_3 \right] -\delta_{k+1/2} \left[e_{2v} \,a_2 \right] \right)  &\ \mathbf{i} \\ 
  +& \frac{1}{e_{2u}\,e_{3uw}} \ \left( \delta_{k+1/2} \left[e_{1u}\,a_1  \right] -\delta_{i +1/2} \left[e_{3w}\,a_3 \right] \right)  &\ \mathbf{j} \\
@@ -183,6 +183,6 @@
 Let $a$ and $b$ be two fields defined on the mesh, with value zero inside 
 continental area. Using integration by parts it can be shown that the differencing 
-operators ($\delta_i$, $\delta_j$ and $\delta_k$) are anti-symmetric linear 
-operators, and further that the averaging operators $\overline{\,\cdot\,}^{\,i}$, 
+operators ($\delta_i$, $\delta_j$ and $\delta_k$) are skew-symmetric linear operators, 
+and further that the averaging operators $\overline{\,\cdot\,}^{\,i}$, 
 $\overline{\,\cdot\,}^{\,k}$ and $\overline{\,\cdot\,}^{\,k}$) are symmetric linear 
 operators, $i.e.$
@@ -364,5 +364,5 @@
 For both grids here,  the same $w$-point depth has been chosen but in (a) the 
 $t$-points are set half way between $w$-points while in (b) they are defined from 
-an analytical function: $z(k)=5\,(i-1/2)^3 - 45\,(i-1/2)^2 + 140\,(i-1/2) - 150$. 
+an analytical function: $z(k)=5\,(k-1/2)^3 - 45\,(k-1/2)^2 + 140\,(k-1/2) - 150$. 
 Note the resulting difference between the value of the grid-size $\Delta_k$ and 
 those of the scale factor $e_k$. }
@@ -425,5 +425,5 @@
 
 The choice of the grid must be consistent with the boundary conditions specified 
-by the parameter \np{jperio} (see {\S\ref{LBC}).
+by \np{jperio}, a parameter found in \ngn{namcfg} namelist (see {\S\ref{LBC}).
 
 % -------------------------------------------------------------------------------------------------------------
@@ -481,5 +481,5 @@
 %>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
-The choice of a vertical coordinate, even if it is made through a namelist parameter, 
+The choice of a vertical coordinate, even if it is made through \ngn{namzgr} namelist parameters, 
 must be done once of all at the beginning of an experiment. It is not intended as an 
 option which can be enabled or disabled in the middle of an experiment. Three main 
@@ -494,9 +494,10 @@
 bathymetry or $s$-coordinate (hybrid and partial step coordinates have not 
 yet been tested in NEMO v2.3). If using $z$-coordinate with partial step bathymetry
-(\np{ln\_zps}~=~true), ocean cavity beneath ice shelves can be open (\np{ln\_isfcav}~=~true).
+(\np{ln\_zps}~=~true), ocean cavity beneath ice shelves can be open (\np{ln\_isfcav}~=~true) 
+and partial step are also applied at the ocean/ice shelf interface. 
 
 Contrary to the horizontal grid, the vertical grid is computed in the code and no 
 provision is made for reading it from a file. The only input file is the bathymetry 
-(in meters) (\ifile{bathy\_meter}) 
+(in meters) (\ifile{bathy\_meter}). 
 \footnote{N.B. in full step $z$-coordinate, a \ifile{bathy\_level} file can replace the 
 \ifile{bathy\_meter} file, so that the computation of the number of wet ocean point 
@@ -540,5 +541,5 @@
 
 Three options are possible for defining the bathymetry, according to the 
-namelist variable \np{nn\_bathy}: 
+namelist variable \np{nn\_bathy} (found in \ngn{namdom} namelist): 
 \begin{description}
 \item[\np{nn\_bathy} = 0] a flat-bottom domain is defined. The total depth $z_w (jpk)$ 
@@ -548,10 +549,14 @@
 domain width at the central latitude. This is meant for the "EEL-R5" configuration, 
 a periodic or open boundary channel with a seamount. 
-\item[\np{nn\_bathy} = 1] read a bathymetry. The \ifile{bathy\_meter} file (Netcdf format) 
-provides the ocean depth (positive, in meters) at each grid point of the model grid. 
-The bathymetry is usually built by interpolating a standard bathymetry product 
+\item[\np{nn\_bathy} = 1] read a bathymetry and ice shelf draft (if needed).
+ The \ifile{bathy\_meter} file (Netcdf format) provides the ocean depth (positive, in meters)
+ at each grid point of the model grid. The bathymetry is usually built by interpolating a standard bathymetry product 
 ($e.g.$ ETOPO2) onto the horizontal ocean mesh. Defining the bathymetry also 
 defines the coastline: where the bathymetry is zero, no model levels are defined 
 (all levels are masked).
+
+The \ifile{isfdraft\_meter} file (Netcdf format) provides the ice shelf draft (positive, in meters)
+ at each grid point of the model grid. This file is only needed if \np{ln\_isfcav}~=~true. 
+Defining the ice shelf draft will also define the ice shelf edge and the grounding line position.
 \end{description}
 
@@ -610,4 +615,16 @@
 (Fig.~\ref{Fig_zgr}).
 
+If the ice shelf cavities are opened (\np{ln\_isfcav}=~true~}), the definition of $z_0$ is the same. 
+However, definition of $e_3^0$ at $t$- and $w$-points is respectively changed to:
+\begin{equation} \label{DOM_zgr_ana}
+\begin{split}
+ e_3^T(k) &= z_W (k+1) - z_W (k)   \\
+ e_3^W(k) &= z_T (k)   - z_T (k-1) \\
+\end{split}
+\end{equation}
+This formulation decrease the self-generated circulation into the ice shelf cavity 
+(which can, in extreme case, leads to blow up).\\
+
+ 
 The most used vertical grid for ORCA2 has $10~m$ ($500~m)$ resolution in the 
 surface (bottom) layers and a depth which varies from 0 at the sea surface to a 
@@ -721,5 +738,5 @@
 usually 10\%, of the default thickness $e_{3t}(jk)$).
 
- \colorbox{yellow}{Add a figure here of pstep especially at last ocean level }
+\gmcomment{ \colorbox{yellow}{Add a figure here of pstep especially at last ocean level }  }
 
 % -------------------------------------------------------------------------------------------------------------
@@ -860,23 +877,35 @@
 gives the number of ocean levels ($i.e.$ those that are not masked) at each 
 $t$-point. mbathy is computed from the meter bathymetry using the definiton of 
-gdept as the number of $t$-points which gdept $\leq$ bathy. 
+gdept as the number of $t$-points which gdept $\leq$ bathy.
 
 Modifications of the model bathymetry are performed in the \textit{bat\_ctl} 
 routine (see \mdl{domzgr} module) after mbathy is computed. Isolated grid points 
-that do not communicate with another ocean point at the same level are eliminated.
+that do not communicate with another ocean point at the same level are eliminated.\\
+
+As for the representation of bathymetry, a 2D integer array, misfdep, is created. 
+misfdep defines the level of the first wet $t$-point. All the cells between $k=1$ and $misfdep(i,j)-1$ are masked. 
+By default, misfdep(:,:)=1 and no cells are masked.
+
+In case of ice shelf cavities (\np{ln\_isfcav}~=~true), modifications of the model bathymetry and ice shelf draft in 
+the cavities are performed through the \textit{zgr\_isf} routine. The compatibility between ice shelf draft and bathymetry is checked: 
+if only one cell on the water column is opened at $t$-, $u$- or $v$-points, the bathymetry or the ice shelf draft is dug to have a 2-level water column 
+(i.e. two unmasked levels). If the incompatibility is too strong (i.e. need to dig more than one cell), the entire water column is masked.\\ 
 
 From the \textit{mbathy} array, the mask fields are defined as follows:
 \begin{align*}
-tmask(i,j,k) &= \begin{cases}   \; 1&   \text{ if $k\leq mbathy(i,j)$  }    \\
-                                                \; 0&   \text{ if $k\leq mbathy(i,j)$  }    \end{cases}     \\
+tmask(i,j,k) &= \begin{cases}   \; 0&   \text{ if $k < misfdep(i,j) $ } \\
+                                \; 1&   \text{ if $misfdep(i,j) \leq k\leq mbathy(i,j)$  }    \\
+                                \; 0&   \text{ if $k > mbathy(i,j)$  }    \end{cases}     \\
 umask(i,j,k) &=         \; tmask(i,j,k) \ * \ tmask(i+1,j,k)	\\
 vmask(i,j,k) &=         \; tmask(i,j,k) \ * \ tmask(i,j+1,k)	\\
 fmask(i,j,k) &=         \; tmask(i,j,k) \ * \ tmask(i+1,j,k)	\\
-                   & \ \ \, * tmask(i,j,k) \ * \ tmask(i+1,j,k)
+                   & \ \ \, * tmask(i,j,k) \ * \ tmask(i+1,j,k) \\
+wmask(i,j,k) &=         \; tmask(i,j,k) \ * \ tmask(i,j,k-1) \text{ with } wmask(i,j,1) = tmask(i,j,1) 
 \end{align*}
 
-Note that \textit{wmask} is not defined as it is exactly equal to \textit{tmask} with 
-the numerical indexing used (\S~\ref{DOM_Num_Index}). Moreover, the 
-specification of closed lateral boundaries requires that at least the first and last 
+Note, wmask is now defined. It allows, in case of ice shelves, 
+to deal with the top boundary (ice shelf/ocean interface) exactly in the same way as for the bottom boundary. 
+
+The specification of closed lateral boundaries requires that at least the first and last 
 rows and columns of the \textit{mbathy} array are set to zero. In the particular 
 case of an east-west cyclical boundary condition, \textit{mbathy} has its last 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_DYN.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_DYN.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_DYN.tex	(revision 6436)
@@ -1,10 +1,8 @@
 % ================================================================
-% Chapter � Ocean Dynamics (DYN)
+% Chapter ——— Ocean Dynamics (DYN)
 % ================================================================
 \chapter{Ocean Dynamics (DYN)}
 \label{DYN}
 \minitoc
-
-% add a figure for  dynvor ens, ene latices
 
 %\vspace{2.cm}
@@ -165,11 +163,10 @@
 %-------------------------------------------------------------------------------------------------------------
 
-The vector invariant form of the momentum equations is the one most 
-often used in applications of the \NEMO ocean model. The flux form option 
-(see next section) has been present since version $2$. Options are defined
-through the \ngn{namdyn\_adv} namelist variables
-Coriolis and momentum advection terms are evaluated using a leapfrog 
-scheme, $i.e.$ the velocity appearing in these expressions is centred in 
-time (\textit{now} velocity). 
+The vector invariant form of the momentum equations (\np{ln\_dynhpg\_vec}~=~true) is the one most 
+often used in applications of the \NEMO ocean model. The flux form option (\np{ln\_dynhpg\_vec}~=false)
+(see next section) has been present since version $2$. 
+Options are defined through the \ngn{namdyn\_adv} namelist variables.
+Coriolis and momentum advection terms are evaluated using a leapfrog scheme, 
+$i.e.$ the velocity appearing in these expressions is centred in time (\textit{now} velocity). 
 At the lateral boundaries either free slip, no slip or partial slip boundary 
 conditions are applied following Chap.\ref{LBC}.
@@ -303,10 +300,13 @@
 %>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
-Note that a key point in \eqref{Eq_een_e3f} is that the averaging in the \textbf{i}- and 
-\textbf{j}- directions uses the masked vertical scale factor but is always divided by 
-$4$, not by the sum of the masks at the four $T$-points. This preserves the continuity of 
-$e_{3f}$ when one or more of the neighbouring $e_{3t}$ tends to zero and 
-extends by continuity the value of $e_{3f}$ into the land areas. This feature is essential for 
-the $z$-coordinate with partial steps.
+A key point in \eqref{Eq_een_e3f} is how the averaging in the \textbf{i}- and \textbf{j}- directions is made. 
+It uses the sum of masked t-point vertical scale factor divided either 
+by the sum of the four t-point masks (\np{ln\_dynvor\_een\_old}~=~false), 
+or  just by $4$ (\np{ln\_dynvor\_een\_old}~=~true).
+The latter case preserves the continuity of $e_{3f}$ when one or more of the neighbouring $e_{3t}$ 
+tends to zero and extends by continuity the value of $e_{3f}$ into the land areas. 
+This case introduces a sub-grid-scale topography at f-points (with a systematic reduction of $e_{3f}$ 
+when a model level intercept the bathymetry) that tends to reinforce the topostrophy of the flow 
+($i.e.$ the tendency of the flow to follow the isobaths) \citep{Penduff_al_OS07}. 
 
 Next, the vorticity triads, $ {^i_j}\mathbb{Q}^{i_p}_{j_p}$ can be defined at a $T$-point as 
@@ -374,4 +374,11 @@
 \end{aligned}         \right.
 \end{equation} 
+When \np{ln\_dynzad\_zts}~=~\textit{true}, a split-explicit time stepping with 5 sub-timesteps is used 
+on the vertical advection term.
+This option can be useful when the value of the timestep is limited by vertical advection \citep{Lemarie_OM2015}. 
+Note that in this case, a similar split-explicit time stepping should be used on 
+vertical advection of tracer to ensure a better stability, 
+an option which is only available with a TVD scheme (see \np{ln\_traadv\_tvd\_zts} in \S\ref{TRA_adv_tvd}).
+
 
 % ================================================================
@@ -491,5 +498,6 @@
 those in the centred second order method. As the scheme already includes 
 a diffusion component, it can be used without explicit  lateral diffusion on momentum 
-($i.e.$ \np{ln\_dynldf\_lap}=\np{ln\_dynldf\_bilap}=false), and it is recommended to do so.
+($i.e.$ setting both \np{ln\_dynldf\_lap} and \np{ln\_dynldf\_bilap} to \textit{false}), 
+and it is recommended to do so.
 
 The UBS scheme is not used in all directions. In the vertical, the centred $2^{nd}$ 
@@ -629,7 +637,4 @@
 ($e_{3w}$).
  
-$\bullet$ Traditional coding with adaptation for ice shelf cavities (\np{ln\_dynhpg\_isf}=true).
-This scheme need the activation of ice shelf cavities (\np{ln\_isfcav}=true).
-
 $\bullet$ Pressure Jacobian scheme (prj) (a research paper in preparation) (\np{ln\_dynhpg\_prj}=true)
 
@@ -646,4 +651,20 @@
 pressure Jacobian method is used to solve the horizontal pressure gradient. This method can provide
 a more accurate calculation of the horizontal pressure gradient than the standard scheme.
+
+\subsection{Ice shelf cavity}
+\label{DYN_hpg_isf}
+Beneath an ice shelf, the total pressure gradient is the sum of the pressure gradient due to the ice shelf load and
+ the pressure gradient due to the ocean load. If cavities are present (\np{ln\_isfcav}~=~true) these two terms can be
+ calculated by setting \np{ln\_dynhpg\_isf}~=~true. No other scheme is working with ice shelves.\\
+
+$\bullet$ The main hypothesis to compute the ice shelf load is that the ice shelf is in isostatic equilibrium.
+ The top pressure is computed integrating a reference density profile (prescribed as density of a water at 34.4 
+PSU and -1.9$\degres C$) from the sea surface to the ice shelf base, which corresponds to the load of the water
+column in which the ice shelf is floatting. This top pressure is constant over time. A detailed description of 
+this method is described in \citet{Losch2008}.\\
+
+$\bullet$ The ocean load is computed using the expression \eqref{Eq_dynhpg_sco} described in \ref{DYN_hpg_sco}. 
+A treatment of the top and bottom partial cells similar to the one described in \ref{DYN_hpg_zps} is done 
+to reduce the residual circulation generated by the top partial cell. 
 
 %--------------------------------------------------------------------------------------------------------------
@@ -718,9 +739,17 @@
 $\ $\newline      %force an empty line
 
-%%%
 Options are defined through the \ngn{namdyn\_spg} namelist variables.
-The surface pressure gradient term is related to the representation of the free surface (\S\ref{PE_hor_pg}). The main distinction is between the fixed volume case (linear free surface) and the variable volume case (nonlinear free surface, \key{vvl} is defined). In the linear free surface case (\S\ref{PE_free_surface}) the vertical scale factors $e_{3}$ are fixed in time, while they are time-dependent in the nonlinear case (\S\ref{PE_free_surface}). With both linear and nonlinear free surface, external gravity waves are allowed in the equations, which imposes a very small time step when an explicit time stepping is used. Two methods are proposed to allow a longer time step for the three-dimensional equations: the filtered free surface, which is a modification of the continuous equations (see \eqref{Eq_PE_flt}), and the split-explicit free surface described below. The extra term introduced in the filtered method is calculated implicitly, so that the update of the next velocities is done in module \mdl{dynspg\_flt} and not in \mdl{dynnxt}.
-
-%%%
+The surface pressure gradient term is related to the representation of the free surface (\S\ref{PE_hor_pg}). 
+The main distinction is between the fixed volume case (linear free surface) and the variable volume case 
+(nonlinear free surface, \key{vvl} is defined). In the linear free surface case (\S\ref{PE_free_surface}) 
+the vertical scale factors $e_{3}$ are fixed in time, while they are time-dependent in the nonlinear case 
+(\S\ref{PE_free_surface}). 
+With both linear and nonlinear free surface, external gravity waves are allowed in the equations, 
+which imposes a very small time step when an explicit time stepping is used. 
+Two methods are proposed to allow a longer time step for the three-dimensional equations: 
+the filtered free surface, which is a modification of the continuous equations (see \eqref{Eq_PE_flt}), 
+and the split-explicit free surface described below. 
+The extra term introduced in the filtered method is calculated implicitly, 
+so that the update of the next velocities is done in module \mdl{dynspg\_flt} and not in \mdl{dynnxt}.
 
 
@@ -736,5 +765,4 @@
 implicitly, so that a solver is used to compute it. As a consequence the update of the $next$ 
 velocities is done in module \mdl{dynspg\_flt} and not in \mdl{dynnxt}.
-
 
 
@@ -779,5 +807,6 @@
 $\rdt_e = \rdt / nn\_baro$. This parameter can be optionally defined automatically (\np{ln\_bt\_nn\_auto}=true) 
 considering that the stability of the barotropic system is essentially controled by external waves propagation. 
-Maximum allowed Courant number is in that case time independent, and easily computed online from the input bathymetry.
+Maximum Courant number is in that case time independent, and easily computed online from the input bathymetry.
+Therefore, $\rdt_e$ is adjusted so that the Maximum allowed Courant number is smaller than \np{rn\_bt\_cmax}.
 
 %%%
@@ -802,5 +831,5 @@
 Schematic of the split-explicit time stepping scheme for the external 
 and internal modes. Time increases to the right. In this particular exemple, 
-a boxcar averaging window over $nn\_baro$ barotropic time steps is used ($nn\_bt\_filt=1$) and $nn\_baro=5$.
+a boxcar averaging window over $nn\_baro$ barotropic time steps is used ($nn\_bt\_flt=1$) and $nn\_baro=5$.
 Internal mode time steps (which are also the model time steps) are denoted 
 by $t-\rdt$, $t$ and $t+\rdt$. Variables with $k$ superscript refer to instantaneous barotropic variables, 
@@ -808,7 +837,7 @@
 The former are used to obtain time filtered quantities at $t+\rdt$ while the latter are used to obtain time averaged 
 transports to advect tracers.
-a) Forward time integration: \np{ln\_bt\_fw}=true, \np{ln\_bt\_ave}=true. 
-b) Centred time integration: \np{ln\_bt\_fw}=false, \np{ln\_bt\_ave}=true. 
-c) Forward time integration with no time filtering (POM-like scheme): \np{ln\_bt\_fw}=true, \np{ln\_bt\_ave}=false. }
+a) Forward time integration: \np{ln\_bt\_fw}=true, \np{ln\_bt\_av}=true. 
+b) Centred time integration: \np{ln\_bt\_fw}=false, \np{ln\_bt\_av}=true. 
+c) Forward time integration with no time filtering (POM-like scheme): \np{ln\_bt\_fw}=true, \np{ln\_bt\_av}=false. }
 \end{center}    \end{figure}
 %>   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >
@@ -816,5 +845,5 @@
 In the default case (\np{ln\_bt\_fw}=true), the external mode is integrated 
 between \textit{now} and  \textit{after} baroclinic time-steps (Fig.~\ref{Fig_DYN_dynspg_ts}a). To avoid aliasing of fast barotropic motions into three dimensional equations, time filtering is eventually applied on barotropic 
-quantities (\np{ln\_bt\_ave}=true). In that case, the integration is extended slightly beyond  \textit{after} time step to provide time filtered quantities. 
+quantities (\np{ln\_bt\_av}=true). In that case, the integration is extended slightly beyond  \textit{after} time step to provide time filtered quantities. 
 These are used for the subsequent initialization of the barotropic mode in the following baroclinic step. 
 Since external mode equations written at baroclinic time steps finally follow a forward time stepping scheme, 
@@ -837,5 +866,5 @@
 %%%
 
-One can eventually choose to feedback instantaneous values by not using any time filter (\np{ln\_bt\_ave}=false). 
+One can eventually choose to feedback instantaneous values by not using any time filter (\np{ln\_bt\_av}=false). 
 In that case, external mode equations are continuous in time, ie they are not re-initialized when starting a new 
 sub-stepping sequence. This is the method used so far in the POM model, the stability being maintained by refreshing at (almost) 
@@ -1158,12 +1187,19 @@
 
 Besides the surface and bottom stresses (see the above section) which are 
-introduced as boundary conditions on the vertical mixing, two other forcings 
-enter the dynamical equations. 
-
-One is the effect of atmospheric pressure on the ocean dynamics.
-Another forcing term is the tidal potential.
-Both of which will be introduced into the reference version soon. 
-
-\gmcomment{atmospheric pressure is there!!!!    include its description }
+introduced as boundary conditions on the vertical mixing, three other forcings 
+may enter the dynamical equations by affecting the surface pressure gradient. 
+
+(1) When \np{ln\_apr\_dyn}~=~true (see \S\ref{SBC_apr}), the atmospheric pressure is taken 
+into account when computing the surface pressure gradient.
+
+(2) When \np{ln\_tide\_pot}~=~true and \key{tide} is defined (see \S\ref{SBC_tide}), 
+the tidal potential is taken into account when computing the surface pressure gradient.
+
+(3) When \np{nn\_ice\_embd}~=~2 and LIM or CICE is used ($i.e.$ when the sea-ice is embedded in the ocean), 
+the snow-ice mass is taken into account when computing the surface pressure gradient.
+
+
+\gmcomment{ missing : the lateral boundary condition !!!   another external forcing
+ }
 
 % ================================================================
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_LBC.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_LBC.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_LBC.tex	(revision 6436)
@@ -1,4 +1,4 @@
 % ================================================================
-% Chapter � Lateral Boundary Condition (LBC) 
+% Chapter — Lateral Boundary Condition (LBC) 
 % ================================================================
 \chapter{Lateral Boundary Condition (LBC) }
@@ -204,10 +204,11 @@
 %        North fold (\textit{jperio = 3 }to $6)$ 
 % -------------------------------------------------------------------------------------------------------------
-\subsection{North-fold (\textit{jperio = 3 }to $6)$ }
+\subsection{North-fold (\textit{jperio = 3 }to $6$) }
 \label{LBC_north_fold}
 
 The north fold boundary condition has been introduced in order to handle the north 
-boundary of a three-polar ORCA grid. Such a grid has two poles in the northern hemisphere. 
-\colorbox{yellow}{to be completed...}
+boundary of a three-polar ORCA grid. Such a grid has two poles in the northern hemisphere 
+(Fig.\ref{Fig_MISC_ORCA_msh}, and thus requires a specific treatment illustrated in Fig.\ref{Fig_North_Fold_T}. 
+Further information can be found in \mdl{lbcnfd} module which applies the north fold boundary condition.
 
 %>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -250,10 +251,9 @@
 ocean model. Second order finite difference schemes lead to local discrete 
 operators that depend at the very most on one neighbouring point. The only 
-non-local computations concern the vertical physics (implicit diffusion, 1.5 
+non-local computations concern the vertical physics (implicit diffusion, 
 turbulent closure scheme, ...) (delocalization over the whole water column), 
 and the solving of the elliptic equation associated with the surface pressure 
 gradient computation (delocalization over the whole horizontal domain). 
 Therefore, a pencil strategy is used for the data sub-structuration 
-\gmcomment{no idea what this means!}
 : the 3D initial domain is laid out on local processor 
 memories following a 2D horizontal topological splitting. Each sub-domain 
@@ -264,16 +264,14 @@
 phase starts: each processor sends to its neighbouring processors the update 
 values of the points corresponding to the interior overlapping area to its 
-neighbouring sub-domain (i.e. the innermost of the two overlapping rows). 
-The communication is done through message passing. Usually the parallel virtual 
-language, PVM, is used as it is a standard language available on  nearly  all 
-MPP computers. More specific languages (i.e. computer dependant languages) 
-can be easily used to speed up the communication, such as SHEM on a T3E 
-computer. The data exchanges between processors are required at the very 
+neighbouring sub-domain ($i.e.$ the innermost of the two overlapping rows). 
+The communication is done through the Message Passing Interface (MPI). 
+The data exchanges between processors are required at the very 
 place where lateral domain boundary conditions are set in the mono-domain 
-computation (\S III.10-c): the lbc\_lnk routine which manages such conditions 
-is substituted by mpplnk.F or mpplnk2.F routine when running on an MPP 
-computer (\key{mpp\_mpi} defined). It has to be pointed out that when using 
-the MPP version of the model, the east-west cyclic boundary condition is done 
-implicitly, whilst the south-symmetric boundary condition option is not available.
+computation : the \rou{lbc\_lnk} routine (found in \mdl{lbclnk} module) 
+which manages such conditions is interfaced with routines found in \mdl{lib\_mpp} module 
+when running on an MPP computer ($i.e.$ when \key{mpp\_mpi} defined). 
+It has to be pointed out that when using the MPP version of the model, 
+the east-west cyclic boundary condition is done implicitly, 
+whilst the south-symmetric boundary condition option is not available.
 
 %>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -285,12 +283,10 @@
 %>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
-In the standard version of the OPA model, the splitting is regular and arithmetic.
- the i-axis is divided by \jp{jpni} and the j-axis by \jp{jpnj} for a number of processors 
- \jp{jpnij} most often equal to $jpni \times jpnj$ (model parameters set in 
- \mdl{par\_oce}). Each processor is independent and without message passing 
- or synchronous process 
- \gmcomment{how does a synchronous process relate to this?}, 
- programs run alone and access just its own local memory. For this reason, the 
- main model dimensions are now the local dimensions of the subdomain (pencil) 
+In the standard version of \NEMO, the splitting is regular and arithmetic.
+The i-axis is divided by \jp{jpni} and the j-axis by \jp{jpnj} for a number of processors 
+\jp{jpnij} most often equal to $jpni \times jpnj$ (parameters set in 
+ \ngn{nammpp} namelist). Each processor is independent and without message passing 
+ or synchronous process, programs run alone and access just its own local memory. 
+ For this reason, the main model dimensions are now the local dimensions of the subdomain (pencil) 
  that are named \jp{jpi}, \jp{jpj}, \jp{jpk}. These dimensions include the internal 
  domain and the overlapping rows. The number of rows to exchange (known as 
@@ -304,12 +300,8 @@
 where \jp{jpni}, \jp{jpnj} are the number of processors following the i- and j-axis.
 
-\colorbox{yellow}{Figure IV.3: example of a domain splitting with 9 processors and 
-no east-west cyclic boundary conditions.}
-
-One also defines variables nldi and nlei which correspond to the internal 
-domain bounds, and the variables nimpp and njmpp which are the position 
-of the (1,1) grid-point in the global domain. An element of $T_{l}$, a local array 
-(subdomain) corresponds to an element of $T_{g}$, a global array 
-(whole domain) by the relationship: 
+One also defines variables nldi and nlei which correspond to the internal domain bounds, 
+and the variables nimpp and njmpp which are the position of the (1,1) grid-point in the global domain. 
+An element of $T_{l}$, a local array (subdomain) corresponds to an element of $T_{g}$, 
+a global array (whole domain) by the relationship: 
 \begin{equation} \label{Eq_lbc_nimpp}
 T_{g} (i+nimpp-1,j+njmpp-1,k) = T_{l} (i,j,k),
@@ -320,6 +312,5 @@
 nproc. In the standard version, a processor has no more than four neighbouring 
 processors named nono (for north), noea (east), noso (south) and nowe (west) 
-and two variables, nbondi and nbondj, indicate the relative position of the processor 
-\colorbox{yellow}{(see Fig.IV.3)}:
+and two variables, nbondi and nbondj, indicate the relative position of the processor :
 \begin{itemize}
 \item 		nbondi = -1 	an east neighbour, no west processor,
@@ -332,6 +323,4 @@
 processor on its overlapping row, and sends the data issued from internal 
 domain corresponding to the overlapping row of the other processor.
-		 
-\colorbox{yellow}{Figure IV.4: pencil splitting with the additional outer halos }
 
 
@@ -343,27 +332,20 @@
 global ocean where more than 50 \% of points are land points. For this reason, a 
 pre-processing tool can be used to choose the mpp domain decomposition with a 
-maximum number of only land points processors, which can then be eliminated. 
-(For example, the mpp\_optimiz tools, available from the DRAKKAR web site.) 
+maximum number of only land points processors, which can then be eliminated (Fig. \ref{Fig_mppini2})
+(For example, the mpp\_optimiz tools, available from the DRAKKAR web site). 
 This optimisation is dependent on the specific bathymetry employed. The user 
 then chooses optimal parameters \jp{jpni}, \jp{jpnj} and \jp{jpnij} with 
 $jpnij < jpni \times jpnj$, leading to the elimination of $jpni \times jpnj - jpnij$ 
-land processors. When those parameters are specified in module \mdl{par\_oce}, 
+land processors. When those parameters are specified in \ngn{nammpp} namelist, 
 the algorithm in the \rou{inimpp2} routine sets each processor's parameters (nbound, 
 nono, noea,...) so that the land-only processors are not taken into account. 
 
-\colorbox{yellow}{Note that the inimpp2 routine is general so that the original inimpp 
+\gmcomment{Note that the inimpp2 routine is general so that the original inimpp 
 routine should be suppressed from the code.}
 
 When land processors are eliminated, the value corresponding to these locations in 
-the model output files is zero. Note that this is a problem for a mesh output file written 
-by such a model configuration, because model users often divide by the scale factors 
-($e1t$, $e2t$, etc) and do not expect the grid size to be zero, even on land. It may be 
-best not to eliminate land processors when running the model especially to write the 
-mesh files as outputs (when \np{nn\_msh} namelist parameter differs from 0).
-%%
-\gmcomment{Steven : dont understand this, no land processor means no output file 
-covering this part of globe; its only when files are stitched together into one that you 
-can leave a hole}
-%%
+the model output files is undefined. Note that this is a problem for the meshmask file 
+which requires to be defined over the whole domain. Therefore, user should not eliminate 
+land processors when creating a meshmask file ($i.e.$ when setting a non-zero value to \np{nn\_msh}).
 
 %>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -380,360 +362,4 @@
 %>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
-
-% ================================================================
-% Open Boundary Conditions 
-% ================================================================
-\section{Open Boundary Conditions (\key{obc}) (OBC)}
-\label{LBC_obc}
-%-----------------------------------------nam_obc  -------------------------------------------
-%-    nobc_dta    =    0     !  = 0 the obc data are equal to the initial state
-%-                           !  = 1 the obc data are read in 'obc   .dta' files
-%-    rn_dpein      =    1.    !  ???
-%-    rn_dpwin      =    1.    !  ???
-%-    rn_dpnin      =   30.    !  ???
-%-    rn_dpsin      =    1.    !  ???
-%-    rn_dpeob      = 1500.    !  time relaxation (days) for the east  open boundary
-%-    rn_dpwob      =   15.    !    "        "           for the west  open boundary
-%-    rn_dpnob      =  150.    !    "        "           for the north open boundary
-%-    rn_dpsob      =   15.    !    "        "           for the south open boundary
-%-    ln_obc_clim = .true.   !  climatological obc data files (default T)
-%-    ln_vol_cst  = .true.   !  total volume conserved
-\namdisplay{namobc} 
-
-It is often necessary to implement a model configuration limited to an oceanic 
-region or a basin, which communicates with the rest of the global ocean through 
-''open boundaries''. As stated by \citet{Roed1986}, an open boundary is a 
-computational border where the aim of the calculations is to allow the perturbations 
-generated inside the computational domain to leave it without deterioration of the 
-inner model solution. However, an open boundary also has to let information from 
-the outer ocean enter the model and should support inflow and outflow conditions. 
-
-The open boundary package OBC is the first open boundary option developed in 
-NEMO (originally in OPA8.2). It allows the user to 
-\begin{itemize}
-\item tell the model that a boundary is ''open'' and not closed by a wall, for example 
-by modifying the calculation of the divergence of velocity there;
-\item impose values of tracers and velocities at that boundary (values which may 
-be taken from a climatology): this is the``fixed OBC'' option. 
-\item calculate boundary values by a sophisticated algorithm combining radiation 
-and relaxation (``radiative OBC'' option)
-\end{itemize}
-
-Options are defined through the \ngn{namobc} namelist variables.
-The package resides in the OBC directory. It is described here in four parts: the 
-boundary geometry (parameters to be set in \mdl{obc\_par}), the forcing data at 
-the boundaries (module \mdl{obcdta}),  the radiation algorithm involving the 
-namelist and module \mdl{obcrad}, and a brief presentation of boundary update 
-and restart files.
-
-%----------------------------------------------
-\subsection{Boundary geometry}
-\label{OBC_geom}
-%
-First one has to realize that open boundaries may not necessarily be located 
-at the extremities of the computational domain. They may exist in the middle 
-of the domain, for example at Gibraltar Straits if one wants to avoid including 
-the Mediterranean in an Atlantic domain. This flexibility has been found necessary 
-for the CLIPPER project \citep{Treguier_al_JGR01}. Because of the complexity of the 
-geometry of ocean basins, it may even be necessary to have more than one 
-''west'' open boundary, more than one ''north'', etc. This is not possible with 
-the OBC option: only one open boundary of each kind, west, east, south and 
-north is allowed; these names refer to the grid geometry (not to the direction 
-of the geographical ''west'', ''east'', etc).
-
-The open boundary geometry is set by a series of parameters in the module 
-\mdl{obc\_par}. For an eastern open boundary, parameters are \jp{lp\_obc\_east} 
-(true if an east open boundary exists), \jp{jpieob} the $i$-index along which 
-the eastern open boundary (eob) is located, \jp{jpjed} the $j$-index at which 
-it starts, and \jp{jpjef} the $j$-index where it ends (note $d$ is for ''d\'{e}but'' 
-and $f$ for ''fin'' in French). Similar parameters exist for the west, south and 
-north cases (Table~\ref{Tab_obc_param}).
-
-
-%--------------------------------------------------TABLE--------------------------------------------------
-\begin{table}[htbp]     \begin{center}    \begin{tabular}{|l|c|c|c|}
-\hline
-Boundary and  & Constant index  & Starting index (d\'{e}but) & Ending index (fin) \\
-Logical flag  &                 &                            &                     \\
-\hline
-West          & \jp{jpiwob} $>= 2$         &  \jp{jpjwd}$>= 2$          &  \jp{jpjwf}<= \np{jpjglo}-1 \\
-lp\_obc\_west & $i$-index of a $u$ point   & $j$ of a $T$ point   &$j$ of a $T$ point \\
-\hline
-East            & \jp{jpieob}$<=$\np{jpiglo}-2&\jp{jpjed} $>= 2$         & \jp{jpjef}$<=$ \np{jpjglo}-1 \\
- lp\_obc\_east  & $i$-index of a $u$ point    & $j$ of a $T$ point & $j$ of a $T$ point \\
-\hline
-South           & \jp{jpjsob} $>= 2$         & \jp{jpisd} $>= 2$          & \jp{jpisf}$<=$\np{jpiglo}-1 \\
-lp\_obc\_south  & $j$-index of a $v$ point   & $i$ of a $T$ point   & $i$ of a $T$ point \\
-\hline
-North           & \jp{jpjnob} $<=$ \np{jpjglo}-2& \jp{jpind} $>= 2$        & \jp{jpinf}$<=$\np{jpiglo}-1 \\
-lp\_obc\_north  & $j$-index of a $v$ point      & $i$  of a $T$ point & $i$ of a $T$ point \\
-\hline
-\end{tabular}    \end{center}
-\caption{     \label{Tab_obc_param}
-Names of different indices relating to the open boundaries. In the case 
-of a completely open ocean domain with four ocean boundaries, the parameters 
-take exactly the values indicated.}
-\end{table}
-%------------------------------------------------------------------------------------------------------------
-
-The open boundaries must be along coordinate lines. On the C-grid, the boundary 
-itself is along a line of normal velocity points: $v$ points for a zonal open boundary 
-(the south or north one), and $u$ points for a meridional open boundary (the west 
-or east one). Another constraint is that there still must be a row of masked points 
-all around the domain, as if the domain were a closed basin (unless periodic conditions 
-are used together with open boundary conditions). Therefore, an open boundary 
-cannot be located at the first/last index, namely, 1, \jp{jpiglo} or \jp{jpjglo}. Also, 
-the open boundary algorithm involves calculating the normal velocity points situated 
-just on the boundary, as well as the tangential velocity and temperature and salinity 
-just outside the boundary. This means that for a west/south boundary, normal 
-velocities and temperature are calculated at the same index \jp{jpiwob} and 
-\jp{jpjsob}, respectively. For an east/north boundary, the normal velocity is 
-calculated at index \jp{jpieob} and \jp{jpjnob}, but the ``outside'' temperature is 
-at index \jp{jpieob}+1 and \jp{jpjnob}+1. This means that \jp{jpieob}, \jp{jpjnob} 
-cannot be bigger than \jp{jpiglo}-2, \jp{jpjglo}-2. 
-
-
-The starting and ending indices are to be thought of as $T$ point indices: in many 
-cases they indicate the first land $T$-point, at the extremity of an open boundary 
-(the coast line follows the $f$ grid points, see Fig.~\ref{Fig_obc_north} for an example 
-of a northern open boundary). All indices are relative to the global domain. In the 
-free surface case it is possible to have ``ocean corners'', that is, an open boundary 
-starting and ending in the ocean.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]     \begin{center}
-\includegraphics[width=0.70\textwidth]{./TexFiles/Figures/Fig_obc_north.pdf}
-\caption{    \label{Fig_obc_north}
-Localization of the North open boundary points.}
-\end{center}     \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-Although not compulsory, it is highly recommended that the bathymetry in the 
-vicinity of an open boundary follows the following rule: in the direction perpendicular 
-to the open line, the water depth should be constant for 4 grid points. This is in 
-order to ensure that the radiation condition, which involves model variables next 
-to the boundary, is calculated in a consistent way. On Fig.\ref{Fig_obc_north} we 
-indicate by an $=$ symbol, the points which should have the same depth. It means 
-that at the 4 points near the boundary, the bathymetry is cylindrical \gmcomment{not sure 
-why cylindrical}. The line behind the open $T$-line must be 0 in the bathymetry file 
-(as shown on Fig.\ref{Fig_obc_north} for example).
-
-%----------------------------------------------
-\subsection{Boundary data}
-\label{OBC_data}
-
-It is necessary to provide information at the boundaries. The simplest case is 
-when this information does not change in time and is equal to the initial conditions 
-(namelist variable \np{nn\_obcdta}=0). This is the case for the standard configuration 
-EEL5 with open boundaries. When (\np{nn\_obcdta}=1), open boundary information 
-is read from netcdf files. For convenience the input files are supposed to be similar 
-to the ''history'' NEMO output files, for dimension names and variable names. 
-Open boundary arrays must be dimensioned according to the parameters of table~
-\ref{Tab_obc_param}: for example, at the western boundary, arrays have a 
-dimension of \jp{jpwf}-\jp{jpwd}+1 in the horizontal and \jp{jpk} in the vertical. 
-
-When ocean observations are used to generate the boundary data (a hydrographic 
-section for example, as in \citet{Treguier_al_JGR01}) it happens often that only the velocity 
-normal to the boundary is known, which is the reason why the initial OBC code 
-assumes that only $T$, $S$, and the normal velocity ($u$ or $v$) needs to be 
-specified. As more and more global model solutions and ocean analysis products 
-become available, it will be possible to provide information about all the variables 
-(including the tangential velocity) so that the specification of four variables at each 
-boundaries will become standard. For the sea surface height, one must distinguish 
-between the filtered free surface case and the time-splitting or explicit treatment of 
-the free surface.
- In the first case, it is assumed that the user does not wish to represent high 
- frequency motions such as tides. The boundary condition is thus one of zero 
- normal gradient of sea surface height at the open boundaries, following \citet{Marchesiello2001}. 
-No information other than the total velocity needs to be provided at the open 
-boundaries in that case. In the other two cases (time splitting or explicit free surface), 
-the user must provide barotropic information (sea surface height and barotropic 
-velocities) and the use of the Flather algorithm for barotropic variables is 
-recommanded. However, this algorithm has not yet been fully tested and bugs 
-remain in NEMO v2.3. Users should read the code carefully before using it. Finally, 
-in the case of the rigid lid approximation the barotropic streamfunction must be 
-provided, as documented in \citet{Treguier_al_JGR01}). This option is no longer 
-recommended but remains in NEMO V2.3.
-
-One frequently encountered case is when an open boundary domain is constructed 
-from a global or larger scale NEMO configuration. Assuming the domain corresponds 
-to indices $ib:ie$, $jb:je$ of the global domain, the bathymetry and forcing of the 
-small domain can be created by using the following netcdf utility on the global files: 
-ncks -F $-d\;x,ib,ie$ $-d\;y,jb,je$ (part of the nco series of utilities, 
-see their \href{http://nco.sourceforge.net}{website}). 
-The open boundary files can be constructed using ncks 
-commands, following table~\ref{Tab_obc_ind}. 
-
-%--------------------------------------------------TABLE--------------------------------------------------
-\begin{table}[htbp]     \begin{center}      \begin{tabular}{|l|c|c|c|c|c|}
-\hline
-OBC  & Variable   & file name      & Index  & Start  & end  \\
-West &  T,S       &   obcwest\_TS.nc &  $ib$+1     &   $jb$+1 &  $je-1$  \\
-     &    U       &   obcwest\_U.nc  &  $ib$+1     &   $jb$+1 &  $je-1$  \\ 
-     &    V       &   obcwest\_V.nc  &  $ib$+1     &   $jb$+1 &  $je-1$  \\       
-\hline
-East &  T,S       &   obceast\_TS.nc &  $ie$-1     &   $jb$+1 &  $je-1$  \\
-     &    U       &   obceast\_U.nc  &  $ie$-2     &   $jb$+1 &  $je-1$  \\ 
-     &    V       &   obceast\_V.nc  &  $ie$-1     &   $jb$+1 &  $je-1$  \\       
-\hline         
-South &  T,S      &   obcsouth\_TS.nc &  $jb$+1     &  $ib$+1 &  $ie-1$  \\
-      &    U      &   obcsouth\_U.nc  &  $jb$+1     &  $ib$+1 &  $ie-1$  \\ 
-      &    V      &   obcsouth\_V.nc  &  $jb$+1     &  $ib$+1 &  $ie-1$  \\    
-\hline
-North &  T,S      &   obcnorth\_TS.nc &  $je$-1     &  $ib$+1 &  $ie-1$  \\
-      &    U      &   obcnorth\_U.nc  &  $je$-1     &  $ib$+1 &  $ie-1$  \\ 
-      &    V      &   obcnorth\_V.nc  &  $je$-2     &  $ib$+1 &  $ie-1$  \\  
-\hline
-\end{tabular}     \end{center}
-\caption{    \label{Tab_obc_ind}
-Requirements for creating open boundary files from a global configuration, 
-appropriate for the subdomain of indices $ib:ie$, $jb:je$. ``Index'' designates the 
-$i$ or $j$ index along which the $u$ of $v$ boundary point is situated in the global 
-configuration, starting and ending with the $j$ or $i$ indices indicated. 
-For example, to generate file obcnorth\_V.nc, use the command ncks 
-$-F$ $-d\;y,je-2$  $-d\;x,ib+1,ie-1$ } 
-\end{table}
-%-----------------------------------------------------------------------------------------------------------
-
-It is assumed that the open boundary files contain the variables for the period of 
-the model integration. If the boundary files contain one time frame, the boundary 
-data is held fixed in time. If the files contain 12 values, it is assumed that the input 
-is a climatology for a repeated annual cycle (corresponding to the case \np{ln\_obc\_clim} 
-=true). The case of an arbitrary number of time frames is not yet implemented 
-correctly; the user is required to write his own code in the module \mdl{obc\_dta} 
-to deal with this situation. 
-
-\subsection{Radiation algorithm}
-\label{OBC_rad}
-
-The art of open boundary management consists in applying a constraint strong 
-enough that the inner domain "feels" the rest of the ocean, but weak enough
-that perturbations are allowed to leave the domain with minimum false reflections 
-of energy. The constraints are specified separately at each boundary as time 
-scales for ''inflow'' and ''outflow'' as defined below. The time scales are set (in days) 
-by namelist parameters such as \np{rn\_dpein}, \np{rn\_dpeob} for the eastern open 
-boundary for example. When both time scales are zero for a given boundary 
-($e.g.$ for the western boundary, \jp{lp\_obc\_west}=true, \np{rn\_dpwob}=0 and 
-\np{rn\_dpwin}=0) this means that the boundary in question is a ''fixed '' boundary 
-where the solution is set exactly by the boundary data. This is not recommended, 
-except in combination with increased viscosity in a ''sponge'' layer next to the 
-boundary in order to avoid spurious reflections.  
-
-
-The radiation\/relaxation \gmcomment{the / doesnt seem to appear in the output} 
-algorithm is applied when either relaxation time (for ''inflow'' or ''outflow'') is 
-non-zero. It has been developed and tested in the SPEM model and its 
-successor ROMS \citep{Barnier1996, Marchesiello2001}, which is an 
-$s$-coordinate model on an Arakawa C-grid. Although the algorithm has 
-been numerically successful in the CLIPPER Atlantic models, the physics 
-do not work as expected \citep{Treguier_al_JGR01}. Users are invited to consider 
-open boundary conditions (OBC hereafter) with some scepticism 
-\citep{Durran2001, Blayo2005}.
-
-The first part of the algorithm calculates a phase velocity to determine 
-whether perturbations tend to propagate toward, or away from, the 
-boundary. Let us consider a model variable $\phi$. 
-The phase velocities ($C_{\phi x}$,$C_{\phi y}$) for the variable $\phi$, 
-in the directions normal and tangential to the boundary are
-\begin{equation} \label{Eq_obc_cphi}
-C_{\phi x} = \frac{ -\phi_{t} }{ ( \phi_{x}^{2} + \phi_{y}^{2}) } \phi_{x} 
-\;\;\;\;\; \;\;\; 
-C_{\phi y} = \frac{ -\phi_{t} }{ ( \phi_{x}^{2} + \phi_{y}^{2}) } \phi_{y}. 
-\end{equation}
-Following \citet{Treguier_al_JGR01} and \citet{Marchesiello2001} we retain only 
-the normal component of the velocity, $C_{\phi x}$, setting $C_{\phi y} =0$ 
-(but unlike the original Orlanski radiation algorithm we retain $\phi_{y}$ in 
-the expression for $C_{\phi x}$).  
-
-The discrete form of (\ref{Eq_obc_cphi}), described by \citet{Barnier1998},
-takes into account the two rows of grid points situated inside the domain 
-next to the boundary, and the three previous time steps ($n$, $n-1$,
-and $n-2$). The same equation can then be discretized at the boundary at
-time steps $n-1$, $n$ and $n+1$ \gmcomment{since the original was three time-level} 
-in order to extrapolate for the new boundary value $\phi^{n+1}$. 
-
-In the open boundary algorithm as implemented in NEMO v2.3, the new boundary 
-values are updated differently depending on the sign of $C_{\phi x}$. Let us take 
-an eastern boundary as an example. The solution for variable $\phi$ at the 
-boundary is given by a generalized wave equation with phase velocity $C_{\phi}$, 
-with the addition of a relaxation term, as:
-\begin{eqnarray}
-\phi_{t} &  =  & -C_{\phi x} \phi_{x} + \frac{1}{\tau_{o}} (\phi_{c}-\phi) 
-                        \;\;\; \;\;\; \;\;\; (C_{\phi x} > 0), \label{Eq_obc_rado} \\
-\phi_{t} &  =  & \frac{1}{\tau_{i}} (\phi_{c}-\phi) 
-\;\;\; \;\;\; \;\;\;\;\;\; (C_{\phi x} < 0), \label{Eq_obc_radi}
-\end{eqnarray}
-where $\phi_{c}$ is the estimate of $\phi$ at the boundary, provided as boundary 
-data. Note that in (\ref{Eq_obc_rado}), $C_{\phi x}$ is bounded by the ratio 
-$\delta x/\delta t$ for stability reasons. When $C_{\phi x}$ is eastward (outward 
-propagation), the radiation condition (\ref{Eq_obc_rado}) is used. 
-When  $C_{\phi x}$ is westward (inward propagation), (\ref{Eq_obc_radi}) is 
-used with a strong relaxation to climatology (usually $\tau_{i}=\np{rn\_dpein}=$1~day).
-Equation (\ref{Eq_obc_radi}) is solved with a Euler time-stepping scheme. As a 
-consequence, setting $\tau_{i}$ smaller than, or equal to the time step is equivalent 
-to a fixed boundary condition. A time scale of one day is usually a good compromise 
-which guarantees that the inflow conditions remain close to climatology while ensuring 
-numerical stability. 
-
-In  the case of a western boundary located in the Eastern Atlantic, \citet{Penduff_al_JGR00} 
-have been able to implement the radiation algorithm without any boundary data, 
-using persistence from the previous time step instead. This solution has not worked 
-in other cases \citep{Treguier_al_JGR01}, so that the use of boundary data is recommended. 
-Even in the outflow condition (\ref{Eq_obc_rado}), we have found it desirable to 
-maintain a weak relaxation to climatology. The time step is usually chosen so as to 
-be larger than typical turbulent scales (of order 1000~days \gmcomment{or maybe seconds?}).
-
-The radiation condition is applied to the model variables: temperature, salinity, 
-tangential and normal velocities. For normal and tangential velocities, $u$ and $v$, 
-radiation is applied with phase velocities calculated from $u$ and $v$ respectively.  
-For the radiation of tracers, we use the phase velocity calculated from the tangential 
-velocity in order to avoid calculating too many independent radiation velocities and 
-because tangential velocities and tracers have the same position along the boundary 
-on a C-grid.  
-
-\subsection{Domain decomposition (\key{mpp\_mpi})}
-\label{OBC_mpp}
-When \key{mpp\_mpi} is active in the code, the computational domain is divided 
-into rectangles that are attributed each to a different processor. The open boundary 
-code is ``mpp-compatible'' up to a certain point. The radiation algorithm will not 
-work if there is an mpp subdomain boundary parallel to the open boundary at the 
-index of the boundary, or the grid point after (outside), or three grid points before 
-(inside). On the other hand, there is no problem if an mpp subdomain boundary 
-cuts the open boundary perpendicularly. These geometrical limitations must be 
-checked for by the user (there is no safeguard in the code).  
-The general principle for the open boundary mpp code is that loops over the open 
-boundaries {not sure what this means} are performed on local indices (nie0, 
-nie1, nje0, nje1 for an eastern boundary for instance) that are initialized in module 
-\mdl{obc\_ini}. Those indices have relevant values on the processors that contain 
-a segment of an open boundary. For processors that do not include an open 
-boundary segment, the indices are such that the calculations within the loops are 
-not performed.
-\gmcomment{I dont understand most of the last few sentences}
- 
-Arrays of climatological data that are read from files are seen by all processors 
-and have the same dimensions for all (for instance, for the eastern boundary, 
-uedta(jpjglo,jpk,2)). On the other hand, the arrays for the calculation of radiation 
-are local to each processor (uebnd(jpj,jpk,3,3) for instance).  This allowed the 
-CLIPPER model for example, to save on memory where the eastern boundary 
-crossed 8 processors so that \jp{jpj} was much smaller than (\jp{jpjef}-\jp{jpjed}+1). 
-
-\subsection{Volume conservation}
-\label{OBC_vol}
-
-It is necessary to control the volume inside a domain when using open boundaries. 
-With fixed boundaries, it is enough to ensure that the total inflow/outflow has 
-reasonable values (either zero or a value compatible with an observed volume 
-balance). When using radiative boundary conditions it is necessary to have a 
-volume constraint because each open boundary works independently from the 
-others. The methodology used to control this volume is identical to the one 
-coded in the ROMS model \citep{Marchesiello2001}.
-
-
-%---------------------------------------- EXTRAS
-\colorbox{yellow}{Explain obc\_vol{\ldots}}
-
-\colorbox{yellow}{OBC algorithm for update, OBC restart, list of routines where obc key appears{\ldots}}
-
-\colorbox{yellow}{OBC rigid lid? {\ldots}}
 
 % ====================================================================
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_LDF.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_LDF.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_LDF.tex	(revision 6436)
@@ -1,5 +1,5 @@
 
 % ================================================================
-% Chapter � Lateral Ocean Physics (LDF)
+% Chapter ———  Lateral Ocean Physics (LDF)
 % ================================================================
 \chapter{Lateral Ocean Physics (LDF)}
@@ -68,5 +68,5 @@
 When none of the \textbf{key\_dynldf\_...} and \textbf{key\_traldf\_...} keys are 
 defined, a constant value is used over the whole ocean for momentum and 
-tracers, which is specified through the \np{rn\_ahm0} and \np{rn\_aht0} namelist 
+tracers, which is specified through the \np{rn\_ahm\_0\_lap} and \np{rn\_aht\_0} namelist 
 parameters.
 
@@ -77,5 +77,5 @@
 mixing coefficients will require 3D arrays. In the 1D option, a hyperbolic variation 
 of the lateral mixing coefficient is introduced in which the surface value is 
-\np{rn\_aht0} (\np{rn\_ahm0}), the bottom value is 1/4 of the surface value, 
+\np{rn\_aht\_0} (\np{rn\_ahm\_0\_lap}), the bottom value is 1/4 of the surface value, 
 and the transition takes place around z=300~m with a width of 300~m 
 ($i.e.$ both the depth and the width of the inflection point are set to 300~m). 
@@ -93,5 +93,5 @@
 \end{equation}
 where $e_{max}$ is the maximum of $e_1$ and $e_2$ taken over the whole masked 
-ocean domain, and $A_o^l$ is the \np{rn\_ahm0} (momentum) or \np{rn\_aht0} (tracer) 
+ocean domain, and $A_o^l$ is the \np{rn\_ahm\_0\_lap} (momentum) or \np{rn\_aht\_0} (tracer) 
 namelist parameter. This variation is intended to reflect the lesser need for subgrid 
 scale eddy mixing where the grid size is smaller in the domain. It was introduced in 
@@ -105,6 +105,6 @@
 Other formulations can be introduced by the user for a given configuration. 
 For example, in the ORCA2 global ocean model (see Configurations), the laplacian 
-viscosity operator uses \np{rn\_ahm0}~= 4.10$^4$ m$^2$/s poleward of 20$^{\circ}$ 
-north and south and decreases linearly to \np{rn\_aht0}~= 2.10$^3$ m$^2$/s 
+viscosity operator uses \np{rn\_ahm\_0\_lap}~= 4.10$^4$ m$^2$/s poleward of 20$^{\circ}$ 
+north and south and decreases linearly to \np{rn\_aht\_0}~= 2.10$^3$ m$^2$/s 
 at the equator \citep{Madec_al_JPO96, Delecluse_Madec_Bk00}. This modification 
 can be found in routine \rou{ldf\_dyn\_c2d\_orca} defined in \mdl{ldfdyn\_c2d}. 
@@ -120,11 +120,94 @@
 \subsubsection{Space and Time Varying Mixing Coefficients}
 
-There is no default specification of space and time varying mixing coefficient. 
-The only case available is specific to the ORCA2 and ORCA05 global ocean 
-configurations. It provides only a tracer 
-mixing coefficient for eddy induced velocity (ORCA2) or both iso-neutral and 
-eddy induced velocity (ORCA05) that depends on the local growth rate of 
-baroclinic instability. This specification is actually used when an ORCA key 
+There are no default specifications of space and time varying mixing coefficient.  One
+available case is specific to the ORCA2 and ORCA05 global ocean configurations. It
+provides only a tracer mixing coefficient for eddy induced velocity (ORCA2) or both
+iso-neutral and eddy induced velocity (ORCA05) that depends on the local growth rate of
+baroclinic instability. This specification is actually used when an ORCA key
 and both \key{traldf\_eiv} and \key{traldf\_c2d} are defined.
+
+\subsubsection{Smagorinsky viscosity (\key{dynldf\_c3d} and \key{dynldf\_smag})}
+
+The \key{dynldf\_smag} key activates a 3D, time-varying viscosity that depends on the
+resolved motions. Following \citep{Smagorinsky_93} the viscosity coefficient is set
+proportional to a local deformation rate based on the horizontal shear and tension,
+namely:
+
+\begin{equation}
+A_{m_{Smag}} = \left(\frac{{\sf CM_{Smag}}}{\pi}\right)^2L^2\vert{D}\vert
+\end{equation}
+
+\noindent where the deformation rate $\vert{D}\vert$ is given by 
+
+\begin{equation}
+\vert{D}\vert=\sqrt{\left({\frac{\partial{u}} {\partial{x}}}
+                         -{\frac{\partial{v}} {\partial{y}}}\right)^2
+                 +  \left({\frac{\partial{u}} {\partial{y}}}
+                         +{\frac{\partial{v}} {\partial{x}}}\right)^2} 
+\end{equation}
+
+\noindent and $L$ is the local gridscale given by:
+
+\begin{equation}
+L^2 = \frac{2{e_1}^2 {e_2}^2}{\left ( {e_1}^2 + {e_2}^2 \right )}
+\end{equation}
+
+\citep{Griffies_Hallberg_MWR00} suggest values in the range 2.2 to 4.0 of the coefficient
+$\sf CM_{Smag}$ for oceanic flows. This value is set via the \np{rn\_cmsmag\_1} namelist
+parameter. An additional parameter: \np{rn\_cmsh} is included in NEMO for experimenting
+with the contribution of the shear term. A value of 1.0 (the default) calculates the
+deformation rate as above; a value of 0.0 will discard the shear term entirely.
+
+For numerical stability, the calculated viscosity is bounded according to the following:
+
+\begin{equation}
+{\rm MIN}\left ({ L^2\over {8\Delta{t}}}, rn\_ahm\_m\_lap\right ) \geq A_{m_{Smag}} 
+                                                                  \geq rn\_ahm\_0\_lap
+\end{equation}
+
+\noindent with both parameters for the upper and lower bounds being provided via the
+indicated namelist parameters.
+
+\bigskip When $ln\_dynldf\_bilap = .true.$, a biharmonic version of the Smagorinsky
+viscosity is also available which sets a coefficient for the biharmonic viscosity as:
+
+\begin{equation}
+B_{m_{Smag}} = - \left(\frac{{\sf CM_{bSmag}}}{\pi}\right)^2 {L^4\over 8}\vert{D}\vert
+\end{equation}
+
+\noindent which is bounded according to:
+
+\begin{equation}
+{\rm MAX}\left (-{ L^4\over {64\Delta{t}}}, rn\_ahm\_m\_blp\right ) \leq B_{m_{Smag}} 
+                                                                    \leq rn\_ahm\_0\_blp
+\end{equation}
+
+\noindent Note the reversal of the inequalities here because NEMO requires the biharmonic
+coefficients as negative numbers. $\sf CM_{bSmag}$ is set via the \np{rn\_cmsmag\_2}
+namelist parameter and the bounding values have corresponding entries in the namelist too.
+
+\bigskip The current implementation in NEMO also allows for 3D, time-varying diffusivities
+to be set using the Smagorinsky approach. Users should note that this option is not
+recommended for many applications since diffusivities will tend to be largest near
+boundaries (where shears are greatest) leading to spurious upwellings
+(\citep{Griffies_Bk04}, chapter 18.3.4). Nevertheless the option is there for those
+wishing to experiment. This choice requires both \key{traldf\_c3d} and \key{traldf\_smag}
+and uses the \np{rn\_chsmag} (${\sf CH_{Smag}}$), \np{rn\_smsh} and \np{rn\_aht\_m}
+namelist parameters in an analogous way to \np{rn\_cmsmag\_1}, \np{rn\_cmsh} and
+\np{rn\_ahm\_m\_lap} (see above) to set the diffusion coefficient:
+
+\begin{equation}
+A_{h_{Smag}} = \left(\frac{{\sf CH_{Smag}}}{\pi}\right)^2L^2\vert{D}\vert
+\end{equation}
+
+ 
+For numerical stability, the calculated diffusivity is bounded according to the following:
+
+\begin{equation}
+{\rm MIN}\left ({ L^2\over {8\Delta{t}}}, rn\_aht\_m\right ) \geq A_{h_{Smag}} 
+                                                             \geq rn\_aht\_0
+\end{equation}
+
+
 
 $\ $\newline    % force a new ligne
@@ -144,5 +227,5 @@
 (3) for isopycnal diffusion on momentum or tracers, an additional purely 
 horizontal background diffusion with uniform coefficient can be added by 
-setting a non zero value of \np{rn\_ahmb0} or \np{rn\_ahtb0}, a background horizontal 
+setting a non zero value of \np{rn\_ahmb\_0} or \np{rn\_ahtb\_0}, a background horizontal 
 eddy viscosity or diffusivity coefficient (namelist parameters whose default 
 values are $0$). However, the technique used to compute the isopycnal 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_MISC.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_MISC.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_MISC.tex	(revision 6436)
@@ -34,12 +34,6 @@
 has been made to set them in a generic way. However, examples of how 
 they can be set up is given in the ORCA 2\deg and 0.5\deg configurations. For example, 
-for details of implementation in ORCA2, search:
-\vspace{-10pt}  
-\begin{alltt}  
-\tiny    
-\begin{verbatim}
-IF( cp_cfg == "orca" .AND. jp_cfg == 2 )
-\end{verbatim}  
-\end{alltt}
+for details of implementation in ORCA2, search: 
+\texttt{ IF( cp\_cfg == "orca" .AND. jp\_cfg == 2 ) }
 
 % -------------------------------------------------------------------------------------------------------------
@@ -89,6 +83,6 @@
 %--------------------------------------------------------------------------------------------------------------
 
-\colorbox{yellow}{Add a short description of CLA staff here or in lateral boundary condition chapter?}
 Options are defined through the  \ngn{namcla} namelist variables.
+This option is an obsolescent feature that will be removed in version 3.7 and followings. 
 
 %The problem is resolved here by allowing the mixing of tracers and mass/volume between non-adjacent water columns at nominated regions within the model. Momentum is not mixed. The scheme conserves total tracer content, and total volume (the latter in $z*$- or $s*$-coordinate), and maintains compatibility between the tracer and mass/volume budgets.  
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_Model_Basics.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_Model_Basics.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_Model_Basics.tex	(revision 6436)
@@ -247,75 +247,15 @@
 sufficient to solve a linearized version of (\ref{Eq_PE_ssh}), which still allows 
 to take into account freshwater fluxes applied at the ocean surface \citep{Roullet_Madec_JGR00}.
+Nevertheless, with the linearization, an exact conservation of heat and salt contents is lost.
 
 The filtering of EGWs in models with a free surface is usually a matter of discretisation 
-of the temporal derivatives, using the time splitting method \citep{Killworth_al_JPO91, Zhang_Endoh_JGR92} 
-or the implicit scheme \citep{Dukowicz1994}. In \NEMO, we use a slightly different approach 
-developed by \citet{Roullet_Madec_JGR00}: the damping of EGWs is ensured by introducing an 
-additional force in the momentum equation. \eqref{Eq_PE_dyn} becomes: 
-\begin{equation} \label{Eq_PE_flt}
-\frac{\partial {\rm {\bf U}}_h }{\partial t}= {\rm {\bf M}}
-- g \nabla \left( \tilde{\rho} \ \eta \right) 
-- g \ T_c \nabla \left( \widetilde{\rho} \ \partial_t \eta \right) 
-\end{equation}
-where $T_c$, is a parameter with dimensions of time which characterizes the force, 
-$\widetilde{\rho} = \rho / \rho_o$ is the dimensionless density, and $\rm {\bf M}$ 
-represents the collected contributions of the Coriolis, hydrostatic pressure gradient, 
-non-linear and viscous terms in \eqref{Eq_PE_dyn}.
-
-The new force can be interpreted as a diffusion of vertically integrated volume flux divergence. 
-The time evolution of $D$ is thus governed by a balance of two terms, $-g$ \textbf{A} $\eta$ 
-and $g \, T_c \,$ \textbf{A} $D$, associated with a propagative regime and a diffusive regime 
-in the temporal spectrum, respectively. In the diffusive regime, the EGWs no longer propagate, 
-$i.e.$ they are stationary and damped. The diffusion regime applies to the modes shorter than 
-$T_c$. For longer ones, the diffusion term vanishes. Hence, the temporally unresolved EGWs 
-can be damped by choosing $T_c > \rdt$. \citet{Roullet_Madec_JGR00} demonstrate that 
-(\ref{Eq_PE_flt}) can be integrated with a leap frog scheme except the additional term which 
-has to be computed implicitly. This is not surprising since the use of a large time step has a 
-necessarily numerical cost. Two gains arise in comparison with the previous formulations. 
-Firstly, the damping of EGWs can be quantified through the magnitude of the additional term. 
-Secondly, the numerical scheme does not need any tuning. Numerical stability is ensured as 
-soon as $T_c > \rdt$.
-
-When the variations of free surface elevation are small compared to the thickness of the first 
-model layer, the free surface equation (\ref{Eq_PE_ssh}) can be linearized. As emphasized 
-by \citet{Roullet_Madec_JGR00} the linearization of (\ref{Eq_PE_ssh}) has consequences on the 
-conservation of salt in the model. With the nonlinear free surface equation, the time evolution 
-of the total salt content is 
-\begin{equation} \label{Eq_PE_salt_content}
-    \frac{\partial }{\partial t}\int\limits_{D\eta } {S\;dv} 
-                        =\int\limits_S {S\;(-\frac{\partial \eta }{\partial t}-D+P-E)\;ds}
-\end{equation}
-where $S$ is the salinity, and the total salt is integrated over the whole ocean volume 
-$D_\eta$ bounded by the time-dependent free surface. The right hand side (which is an 
-integral over the free surface) vanishes when the nonlinear equation (\ref{Eq_PE_ssh}) 
-is satisfied, so that the salt is perfectly conserved. When the free surface equation is 
-linearized, \citet{Roullet_Madec_JGR00} show that the total salt content integrated in the fixed 
-volume $D$ (bounded by the surface $z=0$) is no longer conserved:
-\begin{equation} \label{Eq_PE_salt_content_linear}
-         \frac{\partial }{\partial t}\int\limits_D {S\;dv} 
-         		= - \int\limits_S {S\;\frac{\partial \eta }{\partial t}ds} 
-\end{equation}
-
-The right hand side of (\ref{Eq_PE_salt_content_linear}) is small in equilibrium solutions 
-\citep{Roullet_Madec_JGR00}. It can be significant when the freshwater forcing is not balanced and 
-the globally averaged free surface is drifting. An increase in sea surface height \textit{$\eta $} 
-results in a decrease of the salinity in the fixed volume $D$. Even in that case though, 
-the total salt integrated in the variable volume $D_{\eta}$ varies much less, since 
-(\ref{Eq_PE_salt_content_linear}) can be rewritten as 
-\begin{equation} \label{Eq_PE_salt_content_corrected}
-\frac{\partial }{\partial t}\int\limits_{D\eta } {S\;dv} 
-=\frac{\partial}{\partial t} \left[ \;{\int\limits_D {S\;dv} +\int\limits_S {S\eta \;ds} } \right]
-=\int\limits_S {\eta \;\frac{\partial S}{\partial t}ds}
-\end{equation}
-
-Although the total salt content is not exactly conserved with the linearized free surface, 
-its variations are driven by correlations of the time variation of surface salinity with the 
-sea surface height, which is a negligible term. This situation contrasts with the case of 
-the rigid lid approximation in which case freshwater forcing is represented by a virtual 
-salt flux, leading to a spurious source of salt at the ocean surface 
-\citep{Huang_JPO93, Roullet_Madec_JGR00}.
-
-\newpage
-$\ $\newline    % force a new ligne
+of the temporal derivatives, using a split-explicit method \citep{Killworth_al_JPO91, Zhang_Endoh_JGR92} 
+or the implicit scheme \citep{Dukowicz1994} or the addition of a filtering force in the momentum equation 
+\citep{Roullet_Madec_JGR00}. With the present release, \NEMO offers the choice between 
+an explicit free surface (see \S\ref{DYN_spg_exp}) or a split-explicit scheme strongly 
+inspired the one proposed by \citet{Shchepetkin_McWilliams_OM05} (see \S\ref{DYN_spg_ts}).
+
+%\newpage
+%$\ $\newline    % force a new line
 
 % ================================================================
@@ -773,10 +713,10 @@
 \end{equation}
 
-The equations solved by the ocean model \eqref{Eq_PE} in $s-$coordinate can be written as follows:
+The equations solved by the ocean model \eqref{Eq_PE} in $s-$coordinate can be written as follows (see Appendix~\ref{Apdx_A_momentum}):
 
  \vspace{0.5cm}
-* momentum equation:
+$\bullet$ Vector invariant form of the momentum equation :
 \begin{multline} \label{Eq_PE_sco_u}
-\frac{1}{e_3} \frac{\partial \left(  e_3\,u  \right) }{\partial t}=
+\frac{\partial  u   }{\partial t}=
 	+   \left( {\zeta +f} \right)\,v                                    
 	-   \frac{1}{2\,e_1} \frac{\partial}{\partial i} \left(  u^2+v^2   \right) 
@@ -787,5 +727,5 @@
 \end{multline}
 \begin{multline} \label{Eq_PE_sco_v}
-\frac{1}{e_3} \frac{\partial \left(  e_3\,v  \right) }{\partial t}=
+\frac{\partial v }{\partial t}=
 	-   \left( {\zeta +f} \right)\,u   
 	-   \frac{1}{2\,e_2 }\frac{\partial }{\partial j}\left(  u^2+v^2  \right)     	
@@ -795,9 +735,38 @@
 	+  D_v^{\vect{U}}  +   F_v^{\vect{U}} \quad
 \end{multline}
+
+ \vspace{0.5cm}
+$\bullet$ Vector invariant form of the momentum equation :
+\begin{multline} \label{Eq_PE_sco_u}
+\frac{1}{e_3} \frac{\partial \left(  e_3\,u  \right) }{\partial t}=
+   +   \left( { f + \frac{1}{e_1 \; e_2 }
+					\left( 	 v \frac{\partial e_2}{\partial i}
+						-u \frac{\partial e_1}{\partial j} 	\right)} 	\right) \, v    \\
+   - \frac{1}{e_1 \; e_2 \; e_3 } 	\left( 
+					\frac{\partial \left( {e_2 \, e_3 \, u\,u} \right)}{\partial i}
+		+			\frac{\partial \left( {e_1 \, e_3 \, v\,u} \right)}{\partial j}	\right)
+   - \frac{1}{e_3 }\frac{\partial \left( { \omega\,u} \right)}{\partial k}    \\
+	- \frac{1}{e_1} \frac{\partial}{\partial i} \left( \frac{p_s + p_h}{\rho _o}    \right)    
+	+  g\frac{\rho }{\rho _o}\sigma _1 
+	+   D_u^{\vect{U}}  +   F_u^{\vect{U}} \quad
+\end{multline}
+\begin{multline} \label{Eq_PE_sco_v}
+\frac{1}{e_3} \frac{\partial \left(  e_3\,v  \right) }{\partial t}=
+   -   \left( { f + \frac{1}{e_1 \; e_2}
+					\left( 	 v \frac{\partial e_2}{\partial i}
+						-u \frac{\partial e_1}{\partial j} 	\right)} 	\right) \, u   \\
+   - \frac{1}{e_1 \; e_2 \; e_3 } 	\left( 
+					\frac{\partial \left( {e_2 \; e_3  \,u\,v} \right)}{\partial i}
+		+			\frac{\partial \left( {e_1 \; e_3  \,v\,v} \right)}{\partial j}	\right)
+                 - \frac{1}{e_3 } \frac{\partial \left( { \omega\,v} \right)}{\partial k}    \\
+	-   \frac{1}{e_2 }\frac{\partial }{\partial j}\left( \frac{p_s+p_h }{\rho _o}  \right) 
+	 +  g\frac{\rho }{\rho _o }\sigma _2   
+	+  D_v^{\vect{U}}  +   F_v^{\vect{U}} \quad
+\end{multline}
+
 where the relative vorticity, \textit{$\zeta $}, the surface pressure gradient, and the hydrostatic 
 pressure have the same expressions as in $z$-coordinates although they do not represent 
 exactly the same quantities. $\omega$ is provided by the continuity equation 
 (see Appendix~\ref{Apdx_A}):
-
 \begin{equation} \label{Eq_PE_sco_continuity}
 \frac{\partial e_3}{\partial t} + e_3 \; \chi + \frac{\partial \omega }{\partial s} = 0   
@@ -809,5 +778,5 @@
 
  \vspace{0.5cm}
-* tracer equations:
+$\bullet$ tracer equations:
 \begin{multline} \label{Eq_PE_sco_t}
 \frac{1}{e_3} \frac{\partial \left(  e_3\,T  \right) }{\partial t}=
@@ -1023,6 +992,8 @@
 \label{PE_zco_tilde}
 
-The $\tilde{z}$-coordinate has been developed by \citet{Leclair_Madec_OM10s}.
-It is not available in the current version of \NEMO.
+The $\tilde{z}$-coordinate has been developed by \citet{Leclair_Madec_OM11}.
+It is available in \NEMO since the version 3.4. Nevertheless, it is currently not robust enough 
+to be used in all possible configurations. Its use is therefore not recommended.
+
 
 \newpage 
@@ -1157,7 +1128,7 @@
 operator acting along $s-$surfaces (see \S\ref{LDF}).
 
-\subsubsection{Lateral second order tracer diffusive operator}
-
-The lateral second order tracer diffusive operator is defined by (see Appendix~\ref{Apdx_B}):
+\subsubsection{Lateral Laplacian tracer diffusive operator}
+
+The lateral Laplacian tracer diffusive operator is defined by (see Appendix~\ref{Apdx_B}):
 \begin{equation} \label{Eq_PE_iso_tensor}
 D^{lT}=\nabla {\rm {\bf .}}\left( {A^{lT}\;\Re \;\nabla T} \right) \qquad 
@@ -1180,8 +1151,10 @@
 ocean (see Appendix~\ref{Apdx_B}).
 
+For \textit{iso-level} diffusion, $r_1$ and $r_2 $ are zero. $\Re $ reduces to the identity 
+in the horizontal direction, no rotation is applied. 
+
 For \textit{geopotential} diffusion, $r_1$ and $r_2 $ are the slopes between the 
-geopotential and computational surfaces: in $z$-coordinates they are zero 
-($r_1 = r_2 = 0$) while in $s$-coordinate (including $\textit{z*}$ case) they are 
-equal to $\sigma _1$ and $\sigma _2$, respectively (see \eqref{Eq_PE_sco_slope} ).
+geopotential and computational surfaces: they are equal to $\sigma _1$ and $\sigma _2$, 
+respectively (see \eqref{Eq_PE_sco_slope} ).
 
 For \textit{isoneutral} diffusion $r_1$ and $r_2$ are the slopes between the isoneutral 
@@ -1231,19 +1204,17 @@
 to zero in the vicinity of the boundaries. The latter strategy is used in \NEMO (cf. Chap.~\ref{LDF}).
 
-\subsubsection{Lateral fourth order tracer diffusive operator}
-
-The lateral fourth order tracer diffusive operator is defined by:
+\subsubsection{Lateral bilaplacian tracer diffusive operator}
+
+The lateral bilaplacian tracer diffusive operator is defined by:
 \begin{equation} \label{Eq_PE_bilapT}
 D^{lT}=\Delta \left( {A^{lT}\;\Delta T} \right) 
 \qquad \text{where} \  D^{lT}=\Delta \left( {A^{lT}\;\Delta T} \right)
  \end{equation}
-
 It is the second order operator given by \eqref{Eq_PE_iso_tensor} applied twice with 
 the eddy diffusion coefficient correctly placed. 
 
-
-\subsubsection{Lateral second order momentum diffusive operator}
-
-The second order momentum diffusive operator along $z$- or $s$-surfaces is found by 
+\subsubsection{Lateral Laplacian momentum diffusive operator}
+
+The Laplacian momentum diffusive operator along $z$- or $s$-surfaces is found by 
 applying \eqref{Eq_PE_lap_vector} to the horizontal velocity vector (see Appendix~\ref{Apdx_B}):
 \begin{equation} \label{Eq_PE_lapU}
@@ -1279,5 +1250,5 @@
 of the Equator in a geographical coordinate system \citep{Lengaigne_al_JGR03}.
 
-\subsubsection{lateral fourth order momentum diffusive operator}
+\subsubsection{lateral bilaplacian momentum diffusive operator}
 
 As for tracers, the fourth order momentum diffusive operator along $z$ or $s$-surfaces 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_Model_Basics_zstar.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_Model_Basics_zstar.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_Model_Basics_zstar.tex	(revision 6436)
@@ -1,4 +1,4 @@
 % ================================================================
-% Chapter 1 � Model Basics
+% Chapter 1 ——— Model Basics
 % ================================================================
 % ================================================================
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_SBC.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_SBC.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_SBC.tex	(revision 6436)
@@ -1,4 +1,4 @@
 % ================================================================
-% Chapter � Surface Boundary Condition (SBC, ISF, ICB) 
+% Chapter —— Surface Boundary Condition (SBC, ISF, ICB) 
 % ================================================================
 \chapter{Surface Boundary Condition (SBC, ISF, ICB) }
@@ -17,5 +17,6 @@
 	\item the two components of the surface ocean stress $\left( {\tau _u \;,\;\tau _v} \right)$
 	\item the incoming solar and non solar heat fluxes $\left( {Q_{ns} \;,\;Q_{sr} } \right)$
-	\item the surface freshwater budget $\left( {\textit{emp},\;\textit{emp}_S } \right)$
+	\item the surface freshwater budget $\left( {\textit{emp}} \right)$
+	\item the surface salt flux associated with freezing/melting of seawater $\left( {\textit{sfx}} \right)$
 \end{itemize}
 plus an optional field:
@@ -27,14 +28,13 @@
 are controlled by namelist \ngn{namsbc} variables: an analytical formulation (\np{ln\_ana}~=~true), 
 a flux formulation (\np{ln\_flx}~=~true), a bulk formulae formulation (CORE 
-(\np{ln\_core}~=~true), CLIO (\np{ln\_clio}~=~true) or MFS
+(\np{ln\_blk\_core}~=~true), CLIO (\np{ln\_blk\_clio}~=~true) or MFS
 \footnote { Note that MFS bulk formulae compute fluxes only for the ocean component}
-(\np{ln\_mfs}~=~true) bulk formulae) and a coupled 
-formulation (exchanges with a atmospheric model via the OASIS coupler) 
-(\np{ln\_cpl}~=~true). When used, the atmospheric pressure forces both 
-ocean and ice dynamics (\np{ln\_apr\_dyn}~=~true).
-The frequency at which the six or seven fields have to be updated is the \np{nn\_fsbc} 
-namelist parameter. 
+(\np{ln\_blk\_mfs}~=~true) bulk formulae) and a coupled or mixed forced/coupled formulation 
+(exchanges with a atmospheric model via the OASIS coupler) (\np{ln\_cpl} or \np{ln\_mixcpl}~=~true). 
+When used ($i.e.$ \np{ln\_apr\_dyn}~=~true), the atmospheric pressure forces both ocean and ice dynamics.
+
+The frequency at which the forcing fields have to be updated is given by the \np{nn\_fsbc} namelist parameter. 
 When the fields are supplied from data files (flux and bulk formulations), the input fields 
-need not be supplied on the model grid.  Instead a file of coordinates and weights can 
+need not be supplied on the model grid. Instead a file of coordinates and weights can 
 be supplied which maps the data from the supplied grid to the model points 
 (so called "Interpolation on the Fly", see \S\ref{SBC_iof}).
@@ -42,17 +42,20 @@
 can be masked to avoid spurious results in proximity of the coasts  as large sea-land gradients characterize
 most of the atmospheric variables.
+
 In addition, the resulting fields can be further modified using several namelist options. 
-These options control  the rotation of vector components supplied relative to an east-north 
-coordinate system onto the local grid directions in the model; the addition of a surface 
-restoring term to observed SST and/or SSS (\np{ln\_ssr}~=~true); the modification of fluxes 
-below ice-covered areas (using observed ice-cover or a sea-ice model) 
-(\np{nn\_ice}~=~0,1, 2 or 3); the addition of river runoffs as surface freshwater 
-fluxes or lateral inflow (\np{ln\_rnf}~=~true); the addition of isf melting as lateral inflow (parameterisation) 
-(\np{nn\_isf}~=~2 or 3 and \np{ln\_isfcav}~=~false) or as surface flux at the land-ice ocean interface
-(\np{nn\_isf}~=~1 or 4 and \np{ln\_isfcav}~=~true); 
-the addition of a freshwater flux adjustment in order to avoid a mean sea-level drift (\np{nn\_fwb}~=~0,~1~or~2); the 
-transformation of the solar radiation (if provided as daily mean) into a diurnal 
-cycle (\np{ln\_dm2dc}~=~true); and a neutral drag coefficient can be read from an external wave 
-model (\np{ln\_cdgw}~=~true). The latter option is possible only in case core or mfs bulk formulas are selected.
+These options control 
+\begin{itemize}
+\item the rotation of vector components supplied relative to an east-north 
+coordinate system onto the local grid directions in the model ; 
+\item the addition of a surface restoring term to observed SST and/or SSS (\np{ln\_ssr}~=~true) ; 
+\item the modification of fluxes below ice-covered areas (using observed ice-cover or a sea-ice model) (\np{nn\_ice}~=~0,1, 2 or 3) ; 
+\item the addition of river runoffs as surface freshwater fluxes or lateral inflow (\np{ln\_rnf}~=~true) ; 
+\item the addition of isf melting as lateral inflow (parameterisation) (\np{nn\_isf}~=~2 or 3 and \np{ln\_isfcav}~=~false) 
+or as fluxes applied at the land-ice ocean interface (\np{nn\_isf}~=~1 or 4 and \np{ln\_isfcav}~=~true) ; 
+\item the addition of a freshwater flux adjustment in order to avoid a mean sea-level drift (\np{nn\_fwb}~=~0,~1~or~2) ; 
+\item the transformation of the solar radiation (if provided as daily mean) into a diurnal cycle (\np{ln\_dm2dc}~=~true) ; 
+and a neutral drag coefficient can be read from an external wave model (\np{ln\_cdgw}~=~true). 
+\end{itemize}
+The latter option is possible only in case core or mfs bulk formulas are selected.
 
 In this chapter, we first discuss where the surface boundary condition appears in the
@@ -73,69 +76,31 @@
 
 The surface ocean stress is the stress exerted by the wind and the sea-ice 
-on the ocean. The two components of stress are assumed to be interpolated 
-onto the ocean mesh, $i.e.$ resolved onto the model (\textbf{i},\textbf{j}) direction 
-at $u$- and $v$-points They are applied as a surface boundary condition of the 
-computation of the momentum vertical mixing trend (\mdl{dynzdf} module) :
-\begin{equation} \label{Eq_sbc_dynzdf}
-\left.{\left( {\frac{A^{vm} }{e_3 }\ \frac{\partial \textbf{U}_h}{\partial k}} \right)} \right|_{z=1}
-	 = \frac{1}{\rho _o} \binom{\tau _u}{\tau _v }
-\end{equation}
-where $(\tau _u ,\;\tau _v )=(utau,vtau)$ are the two components of the wind 
-stress vector in the $(\textbf{i},\textbf{j})$ coordinate system.
+on the ocean. It is applied in \mdl{dynzdf} module as a surface boundary condition of the 
+computation of the momentum vertical mixing trend (see \eqref{Eq_dynzdf_sbc} in \S\ref{DYN_zdf}).
+As such, it has to be provided as a 2D vector interpolated 
+onto the horizontal velocity ocean mesh, $i.e.$ resolved onto the model 
+(\textbf{i},\textbf{j}) direction at $u$- and $v$-points.
 
 The surface heat flux is decomposed into two parts, a non solar and a solar heat 
 flux, $Q_{ns}$ and $Q_{sr}$, respectively. The former is the non penetrative part 
-of the heat flux ($i.e.$ the sum of sensible, latent and long wave heat fluxes). 
-It is applied as a surface boundary condition trend of the first level temperature 
-time evolution equation (\mdl{trasbc} module). 
-\begin{equation} \label{Eq_sbc_trasbc_q}
-\frac{\partial T}{\partial t}\equiv \cdots \;+\;\left. {\frac{Q_{ns} }{\rho 
-_o \;C_p \;e_{3t} }} \right|_{k=1} \quad
-\end{equation}
-$Q_{sr}$ is the penetrative part of the heat flux. It is applied as a 3D 
-trends of the temperature equation (\mdl{traqsr} module) when \np{ln\_traqsr}=True.
-
-\begin{equation} \label{Eq_sbc_traqsr}
-\frac{\partial T}{\partial t}\equiv \cdots \;+\frac{Q_{sr} }{\rho_o C_p \,e_{3t} }\delta _k \left[ {I_w } \right]
-\end{equation}
-where $I_w$ is a non-dimensional function that describes the way the light 
-penetrates inside the water column. It is generally a sum of decreasing 
-exponentials (see \S\ref{TRA_qsr}).
-
-The surface freshwater budget is provided by fields: \textit{emp} and $\textit{emp}_S$ which 
-may or may not be identical. Indeed, a surface freshwater flux has two effects: 
-it changes the volume of the ocean and it changes the surface concentration of 
-salt (and other tracers). Therefore it appears in the sea surface height as a volume 
-flux, \textit{emp} (\textit{dynspg\_xxx} modules), and in the salinity time evolution equations 
-as a concentration/dilution effect, 
-$\textit{emp}_{S}$ (\mdl{trasbc} module). 
-\begin{equation} \label{Eq_trasbc_emp}
-\begin{aligned}
-&\frac{\partial \eta }{\partial t}\equiv \cdots \;+\;\textit{emp}\quad  \\ 
-\\
- &\frac{\partial S}{\partial t}\equiv \cdots \;+\left. {\frac{\textit{emp}_S \;S}{e_{3t} }} \right|_{k=1} \\ 
- \end{aligned}
-\end{equation} 
-
-In the real ocean, $\textit{emp}=\textit{emp}_S$ and the ocean salt content is conserved, 
-but it exist several numerical reasons why this equality should be broken. 
-For example, when the ocean is coupled to a sea-ice model, the water exchanged between 
-ice and ocean is slightly salty (mean sea-ice salinity is $\sim $\textit{4 psu}). In this case, 
-$\textit{emp}_{S}$ take into account both concentration/dilution effect associated with 
-freezing/melting and the salt flux between ice and ocean, while \textit{emp} is 
-only the volume flux. In addition, in the current version of \NEMO, the sea-ice is 
-assumed to be above the ocean (the so-called levitating sea-ice). Freezing/melting does 
-not change the ocean volume (no impact on \textit{emp}) but it modifies the SSS.
-%gm  \colorbox{yellow}{(see {\S} on LIM sea-ice model)}.
-
-Note that SST can also be modified by a freshwater flux. Precipitation (in 
-particular solid precipitation) may have a temperature significantly different from 
-the SST. Due to the lack of information about the temperature of 
-precipitation, we assume it is equal to the SST. Therefore, no 
-concentration/dilution term appears in the temperature equation. It has to 
-be emphasised that this absence does not mean that there is no heat flux 
-associated with precipitation! Precipitation can change the ocean volume and thus the
-ocean heat content. It is therefore associated with a heat flux (not yet  
-diagnosed in the model) \citep{Roullet_Madec_JGR00}).
+of the heat flux ($i.e.$ the sum of sensible, latent and long wave heat fluxes 
+plus the heat content of the mass exchange with the atmosphere and sea-ice). 
+It is applied in \mdl{trasbc} module as a surface boundary condition trend of 
+the first level temperature time evolution equation (see \eqref{Eq_tra_sbc} 
+and \eqref{Eq_tra_sbc_lin} in \S\ref{TRA_sbc}). 
+The latter is the penetrative part of the heat flux. It is applied as a 3D 
+trends of the temperature equation (\mdl{traqsr} module) when \np{ln\_traqsr}=\textit{true}.
+The way the light penetrates inside the water column is generally a sum of decreasing 
+exponentials (see \S\ref{TRA_qsr}). 
+
+The surface freshwater budget is provided by the \textit{emp} field.
+It represents the mass flux exchanged with the atmosphere (evaporation minus precipitation) 
+and possibly with the sea-ice and ice shelves (freezing minus melting of ice). 
+It affects both the ocean in two different ways: 
+$(i)$   it changes the volume of the ocean and therefore appears in the sea surface height 
+equation as a volume flux, and 
+$(ii)$  it changes the surface temperature and salinity through the heat and salt contents 
+of the mass exchanged with the atmosphere, the sea-ice and the ice shelves. 
+
 
 %\colorbox{yellow}{Miss: }
@@ -152,15 +117,20 @@
 %Sbcmod manage the ``providing'' (fourniture) to the ocean the 7 fields
 %
-%Fluxes update only each nf{\_}sbc time step (namsbc) explain relation 
-%between nf{\_}sbc and nf{\_}ice, do we define nf{\_}blk??? ? only one 
-%nf{\_}sbc
+%Fluxes update only each nn{\_}fsbc time step (namsbc) explain relation 
+%between nn{\_}fsbc and nf{\_}ice, do we define nf{\_}blk??? ? only one 
+%nn{\_}fsbc
 %
 %Explain here all the namlist namsbc variable{\ldots}.
+% 
+% explain : use or not of surface currents
 %
 %\colorbox{yellow}{End Miss }
 
-The ocean model provides the surface currents, temperature and salinity 
-averaged over \np{nf\_sbc} time-step (\ref{Tab_ssm}).The computation of the 
-mean is done in \mdl{sbcmod} module.
+The ocean model provides, at each time step, to the surface module (\mdl{sbcmod}) 
+the surface currents, temperature and salinity.  
+These variables are averaged over \np{nn\_fsbc} time-step (\ref{Tab_ssm}), 
+and it is these averaged fields which are used to computes the surface fluxes 
+at a frequency of \np{nn\_fsbc} time-step.
+
 
 %-------------------------------------------------TABLE---------------------------------------------------
@@ -175,5 +145,5 @@
 \caption{  \label{Tab_ssm}   
 Ocean variables provided by the ocean to the surface module (SBC). 
-The variable are averaged over nf{\_}sbc time step, $i.e.$ the frequency of 
+The variable are averaged over nn{\_}fsbc time step, $i.e.$ the frequency of 
 computation of surface fluxes.}
 \end{center}   \end{table}
@@ -459,15 +429,19 @@
 %--------------------------------------------------------------------------------------------------------------
 
-In some circumstances it may be useful to avoid calculating the 3D temperature, salinity and velocity fields and simply read them in from  a previous run.  
-Options are defined through the  \ngn{namsbc\_sas} namelist variables.
+In some circumstances it may be useful to avoid calculating the 3D temperature, salinity and velocity fields 
+and simply read them in from a previous run or receive them from OASIS.  
 For example:
 
-\begin{enumerate}
-\item  Multiple runs of the model are required in code development to see the affect of different algorithms in
+\begin{itemize}
+\item  Multiple runs of the model are required in code development to see the effect of different algorithms in
        the bulk formulae.
 \item  The effect of different parameter sets in the ice model is to be examined.
-\end{enumerate}
+\item  Development of sea-ice algorithms or parameterizations.
+\item  spinup of the iceberg floats
+\item  ocean/sea-ice simulation with both media running in parallel (\np{ln\_mixcpl}~=~\textit{true})
+\end{itemize}
 
 The StandAlone Surface scheme provides this utility.
+Its options are defined through the \ngn{namsbc\_sas} namelist variables.
 A new copy of the model has to be compiled with a configuration based on ORCA2\_SAS\_LIM.
 However no namelist parameters need be changed from the settings of the previous run (except perhaps nn{\_}date0)
@@ -475,39 +449,33 @@
 Routines replaced are:
 
-\begin{enumerate}
-\item  \mdl{nemogcm}
-
-       This routine initialises the rest of the model and repeatedly calls the stp time stepping routine (step.F90)
+\begin{itemize}
+\item \mdl{nemogcm} : This routine initialises the rest of the model and repeatedly calls the stp time stepping routine (step.F90)
        Since the ocean state is not calculated all associated initialisations have been removed.
-\item  \mdl{step}
-
-       The main time stepping routine now only needs to call the sbc routine (and a few utility functions).
-\item  \mdl{sbcmod}
-
-       This has been cut down and now only calculates surface forcing and the ice model required.  New surface modules
+\item  \mdl{step} : The main time stepping routine now only needs to call the sbc routine (and a few utility functions).
+\item  \mdl{sbcmod} : This has been cut down and now only calculates surface forcing and the ice model required.  New surface modules
        that can function when only the surface level of the ocean state is defined can also be added (e.g. icebergs).
-\item  \mdl{daymod}
-
-       No ocean restarts are read or written (though the ice model restarts are retained), so calls to restart functions
+\item  \mdl{daymod} : No ocean restarts are read or written (though the ice model restarts are retained), so calls to restart functions
        have been removed.  This also means that the calendar cannot be controlled by time in a restart file, so the user
        must make sure that nn{\_}date0 in the model namelist is correct for his or her purposes.
-\item  \mdl{stpctl}
-
-       Since there is no free surface solver, references to it have been removed from \rou{stp\_ctl} module.
-\item  \mdl{diawri}
-
-       All 3D data have been removed from the output.  The surface temperature, salinity and velocity components (which
+\item  \mdl{stpctl} : Since there is no free surface solver, references to it have been removed from \rou{stp\_ctl} module.
+\item  \mdl{diawri} : All 3D data have been removed from the output.  The surface temperature, salinity and velocity components (which
        have been read in) are written along with relevant forcing and ice data.
-\end{enumerate}
+\end{itemize}
 
 One new routine has been added:
 
-\begin{enumerate}
-\item  \mdl{sbcsas}
-       This module initialises the input files needed for reading temperature, salinity and velocity arrays at the surface.
+\begin{itemize}
+\item  \mdl{sbcsas} : This module initialises the input files needed for reading temperature, salinity and velocity arrays at the surface.
        These filenames are supplied in namelist namsbc{\_}sas.  Unfortunately because of limitations with the \mdl{iom} module,
        the full 3D fields from the mean files have to be read in and interpolated in time, before using just the top level.
        Since fldread is used to read in the data, Interpolation on the Fly may be used to change input data resolution.
-\end{enumerate}
+\end{itemize}
+
+
+% Missing the description of the 2 following variables:
+%   ln_3d_uve   = .true.    !  specify whether we are supplying a 3D u,v and e3 field
+%   ln_read_frq = .false.    !  specify whether we must read frq or not
+
+
 
 % ================================================================
@@ -590,5 +558,5 @@
 reanalysis and satellite data. They use an inertial dissipative method to compute 
 the turbulent transfer coefficients (momentum, sensible heat and evaporation) 
-from the 10 metre wind speed, air temperature and specific humidity.
+from the 10 meters wind speed, air temperature and specific humidity.
 This \citet{Large_Yeager_Rep04} dataset is available through the 
 \href{http://nomads.gfdl.noaa.gov/nomads/forms/mom4/CORE.html}{GFDL web site}. 
@@ -625,4 +593,15 @@
 or larger than the one of the input atmospheric fields.
 
+The  \np{sn\_wndi}, \np{sn\_wndj}, \np{sn\_qsr}, \np{sn\_qlw}, \np{sn\_tair},\np{sn\_humi},\np{sn\_prec}, \np{sn\_snow}, \np{sn\_tdif} parameters describe the fields and the way they have to be used (spatial and temporal interpolations). 
+
+\np{cn\_dir} is the directory of location of bulk files
+\np{ln\_taudif} is the flag to specify if we use Hight Frequency (HF) tau information (.true.) or not (.false.)
+\np{rn\_zqt}: is the height of humidity and temperature measurements (m)
+\np{rn\_zu}: is the height of wind measurements (m)
+The multiplicative factors to activate (value is 1) or deactivate (value is 0) : 
+\np{rn\_pfac} for precipitations (total and snow)
+\np{rn\_efac} for evaporation 
+\np{rn\_vfac} for for ice/ocean velocities in the calculation of wind stress  
+
 % -------------------------------------------------------------------------------------------------------------
 %        CLIO Bulk formulea
@@ -720,7 +699,6 @@
 are sent to the atmospheric component.
 
-A generalised coupled interface has been developed. It is currently interfaced with OASIS 3
-(\key{oasis3}) and does not support OASIS 4
-\footnote{The \key{oasis4} exist. It activates portion of the code that are still under development.}. 
+A generalised coupled interface has been developed. 
+It is currently interfaced with OASIS-3-MCT (\key{oasis3}). 
 It has been successfully used to interface \NEMO to most of the European atmospheric 
 GCM (ARPEGE, ECHAM, ECMWF, HadAM, HadGAM, LMDz), 
@@ -787,12 +765,12 @@
 \label{SBC_tide}
 
-A module is available to use the tidal potential forcing and is activated with with \key{tide}.
-
-
-%------------------------------------------nam_tide----------------------------------------------------
+%------------------------------------------nam_tide---------------------------------------
 \namdisplay{nam_tide}
-%-------------------------------------------------------------------------------------------------------------
-
-Concerning the tidal potential, some parameters are available in namelist \ngn{nam\_tide}:
+%-----------------------------------------------------------------------------------------
+
+A module is available to compute the tidal potential and use it in the momentum equation.
+This option is activated when \key{tide} is defined.
+
+Some parameters are available in namelist \ngn{nam\_tide}:
 
 - \np{ln\_tide\_pot} activate the tidal potential forcing
@@ -801,5 +779,4 @@
 
 - \np{clname} is the name of constituent
-
 
 The tide is generated by the forces of gravity ot the Earth-Moon and Earth-Sun sytem;
@@ -895,4 +872,17 @@
 lowest box the river water is being added to (i.e. the total depth that river water is being added to in the model).
 
+%Christian:
+If the depth information is not provide in the NetCDF file, it can be estimate from the runoff input file at the initial time-step, by setting the namelist parameter \np{ln\_rnf\_depth\_ini} to true.
+
+This estimation is a simple linear relation between the runoff and a given depth : 
+\begin{equation} 
+h\_dep  = \frac{rn\_dep\_max} {rn\_rnf\_max}  rnf
+\end{equation}
+where  \np{rn\_dep\_max} is the given maximum depth over which the runoffs is spread, 
+ \np{rn\_rnf\_max} is the maximum value of the runoff climatologie over the global domain
+and rnf is the maximum value in time of the runoff climatology at each grid cell (computed online).
+
+The estimated depth array can be output if needed in a NetCDF file by setting the namelist parameter \np{nn\_rnf\_depth\_file} to 1.
+
 The mass/volume addition due to the river runoff is, at each relevant depth level, added to the horizontal divergence 
 (\textit{hdivn}) in the subroutine \rou{sbc\_rnf\_div} (called from \mdl{divcur}).
@@ -958,9 +948,49 @@
 \namdisplay{namsbc_isf}
 %--------------------------------------------------------------------------------------------------------
-Namelist variable in \ngn{namsbc}, \np{nn\_isf},  control the kind of ice shelf representation used. 
+Namelist variable in \ngn{namsbc}, \np{nn\_isf}, controls the ice shelf representation used (Fig. \ref{Fig_SBC_isf}): 
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{figure}[!h]    \begin{center}
+\includegraphics[width=0.8\textwidth]{./TexFiles/Figures/Fig_SBC_isf.pdf}
+\caption{ \label{Fig_SBC_isf}
+Schematic for all the options available trough \np{nn\_isf}.}
+\end{center}   \end{figure}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
 \begin{description}
+\item[\np{nn\_isf}~=~0]
+The ice shelf routines are not used. The ice shelf melting is not computed or prescribed, the cavity have to be closed. 
+If needed, the ice shelf melting should be added to the runoff or the precipitation file.
+
 \item[\np{nn\_isf}~=~1]
-The ice shelf cavity is represented. The fwf and heat flux are computed. 
-Full description, sensitivity and validation in preparation. 
+The ice shelf cavity is represented. The fwf and heat flux are computed. Two different bulk formula are available:
+	\begin{description}
+	\item[\np{nn\_isfblk}~=~1]
+	The bulk formula used to compute the melt is based the one described in \citet{Hunter2006}.
+        This formulation is based on a balance between the upward ocean heat flux and the latent heat flux at the ice shelf base.
+
+	\item[\np{nn\_isfblk}~=~2] 
+	The bulk formula used to compute the melt is based the one described in \citet{Jenkins1991}.
+        This formulation is based on a 3 equations formulation (a heat flux budget, a salt flux budget and a linearised freezing point temperature equation).
+	\end{description}
+
+For this 2 bulk formulations, there are 3 different ways to compute the exchange coeficient:
+	\begin{description}
+        \item[\np{nn\_gammablk~=~0~}]
+	The salt and heat exchange coefficients are constant and defined by \np{rn\_gammas0} and \np{rn\_gammat0}
+
+	\item[\np{nn\_gammablk~=~1~}]
+	The salt and heat exchange coefficients are velocity dependent and defined as $\np{rn\_gammas0} \times u_{*}$ and $\np{rn\_gammat0} \times u_{*}$
+        where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn\_hisf\_tbl} meters).
+        See \citet{Jenkins2010} for all the details on this formulation.
+	
+	\item[\np{nn\_gammablk~=~2~}]
+	The salt and heat exchange coefficients are velocity and stability dependent and defined as 
+        $\gamma_{T,S} = \frac{u_{*}}{\Gamma_{Turb} + \Gamma^{T,S}_{Mole}}$
+        where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn\_hisf\_tbl} meters), 
+        $\Gamma_{Turb}$ the contribution of the ocean stability and 
+        $\Gamma^{T,S}_{Mole}$ the contribution of the molecular diffusion.
+        See \citet{Holland1999} for all the details on this formulation.
+        \end{description}
 
 \item[\np{nn\_isf}~=~2]
@@ -968,37 +998,56 @@
 The fwf is distributed along the ice shelf edge between the depth of the average grounding line (GL)
 (\np{sn\_depmax\_isf}) and the base of the ice shelf along the calving front (\np{sn\_depmin\_isf}) as in (\np{nn\_isf}~=~3). 
-Furthermore the fwf is computed using the \citet{Beckmann2003} parameterisation of isf melting. 
+Furthermore the fwf and heat flux are computed using the \citet{Beckmann2003} parameterisation of isf melting. 
 The effective melting length (\np{sn\_Leff\_isf}) is read from a file.
 
 \item[\np{nn\_isf}~=~3]
 A simple parameterisation of isf is used. The ice shelf cavity is not represented. 
-The fwf (\np{sn\_rnfisf}) is distributed along the ice shelf edge between the depth of the average grounding line (GL)
-(\np{sn\_depmax\_isf}) and the base of the ice shelf along the calving front (\np{sn\_depmin\_isf}).
-Full description, sensitivity and validation in preparation.
+The fwf (\np{sn\_rnfisf}) is prescribed and distributed along the ice shelf edge between the depth of the average grounding line (GL)
+(\np{sn\_depmax\_isf}) and the base of the ice shelf along the calving front (\np{sn\_depmin\_isf}). 
+The heat flux ($Q_h$) is computed as $Q_h = fwf \times L_f$.
 
 \item[\np{nn\_isf}~=~4]
-The ice shelf cavity is represented. However, the fwf (\np{sn\_fwfisf}) and heat flux (\np{sn\_qisf}) are 
-not computed but specified from file. 
+The ice shelf cavity is opened. However, the fwf is not computed but specified from file \np{sn\_fwfisf}). 
+The heat flux ($Q_h$) is computed as $Q_h = fwf \times L_f$.\\
 \end{description}
 
-\np{nn\_isf}~=~1 and \np{nn\_isf}~=~2 compute a melt rate based on the water masse properties, ocean velocities and depth.
- This flux is thus highly dependent of the model resolution (horizontal and vertical), realism of the water masse onto the shelf ...
-
-\np{nn\_isf}~=~3 and \np{nn\_isf}~=~4 read the melt rate and heat flux from a file. You have total control of the fwf scenario.
-
- This can be usefull if the water masses on the shelf are not realistic or the resolution (horizontal/vertical) are too 
-coarse to have realistic melting or for sensitivity studies where you want to control your input. 
-Full description, sensitivity and validation in preparation. 
-
-There is 2 ways to apply the fwf to NEMO. The first possibility (\np{ln\_divisf}~=~false) applied the fwf
- and heat flux directly on the salinity and temperature tendancy. The second possibility (\np{ln\_divisf}~=~true)
- apply the fwf as for the runoff fwf (see \S\ref{SBC_rnf}). The mass/volume addition due to the ice shelf melting is,
- at each relevant depth level, added to the horizontal divergence (\textit{hdivn}) in the subroutine \rou{sbc\_isf\_div} 
-(called from \mdl{divcur}). 
+
+$\bullet$ \np{nn\_isf}~=~1 and \np{nn\_isf}~=~2 compute a melt rate based on the water mass properties, ocean velocities and depth.
+ This flux is thus highly dependent of the model resolution (horizontal and vertical), realism of the water masses onto the shelf ...\\
+
+$\bullet$ \np{nn\_isf}~=~3 and \np{nn\_isf}~=~4 read the melt rate from a file. You have total control of the fwf forcing.
+This can be usefull if the water masses on the shelf are not realistic or the resolution (horizontal/vertical) are too 
+coarse to have realistic melting or for studies where you need to control your heat and fw input.\\ 
+
+Two namelist parameters control how the heat and fw fluxes are passed to NEMO: \np{rn\_hisf\_tbl} and \np{ln\_divisf}
+\begin{description}
+\item[\np{rn\_hisf\_tbl}] is the top boundary layer thickness as defined in \citet{Losch2008}. 
+This parameter is only used if \np{nn\_isf}~=~1 or \np{nn\_isf}~=~4
+It allows you to control over which depth you want to spread the heat and fw fluxes. 
+
+If \np{rn\_hisf\_tbl} = 0.0, the fluxes are put in the top level whatever is its tickness. 
+
+If \np{rn\_hisf\_tbl} $>$ 0.0, the fluxes are spread over the first \np{rn\_hisf\_tbl} m (ie over one or several cells).
+
+\item[\np{ln\_divisf}] is a flag to apply the fw flux as a volume flux or as a salt flux. 
+
+\np{ln\_divisf}~=~true applies the fwf as a volume flux. This volume flux is implemented with in the same way as for the runoff.
+The fw addition due to the ice shelf melting is, at each relevant depth level, added to the horizontal divergence 
+(\textit{hdivn}) in the subroutine \rou{sbc\_isf\_div}, called from \mdl{divcur}. 
+See the runoff section \ref{SBC_rnf} for all the details about the divergence correction. 
+
+\np{ln\_divisf}~=~false applies the fwf and heat flux directly on the salinity and temperature tendancy.
+
+\item[\np{ln\_conserve}] is a flag for \np{nn\_isf}~=~1. A conservative boundary layer scheme as described in \citet{Jenkins2001} 
+is used if \np{ln\_conserve}=true. It takes into account the fact that the melt water is at freezing T and needs to be warm up to ocean temperature. 
+It is only relevant for \np{ln\_divisf}~=~false. 
+If \np{ln\_divisf}~=~true, \np{ln\_conserve} has to be set to false to avoid a double counting of the contribution. 
+ 
+\end{description}
 %
 % ================================================================
 %        Handling of icebergs
 % ================================================================
-\section{ Handling of icebergs (ICB) }
+\section{Handling of icebergs (ICB)}
 \label{ICB_icebergs}
 %------------------------------------------namberg----------------------------------------------------
@@ -1006,8 +1055,9 @@
 %-------------------------------------------------------------------------------------------------------------
 
-Icebergs are modelled as lagrangian particles in NEMO.
-Their physical behaviour is controlled by equations as described in  \citet{Martin_Adcroft_OM10} ).
-(Note that the authors kindly provided a copy of their code to act as a basis for implementation in NEMO.)
-Icebergs are initially spawned into one of ten classes which have specific mass and thickness as described in the \ngn{namberg} namelist: 
+Icebergs are modelled as lagrangian particles in NEMO \citep{Marsh_GMD2015}.
+Their physical behaviour is controlled by equations as described in \citet{Martin_Adcroft_OM10} ).
+(Note that the authors kindly provided a copy of their code to act as a basis for implementation in NEMO).
+Icebergs are initially spawned into one of ten classes which have specific mass and thickness as described 
+in the \ngn{namberg} namelist: 
 \np{rn\_initial\_mass} and \np{rn\_initial\_thickness}.
 Each class has an associated scaling (\np{rn\_mass\_scaling}), which is an integer representing how many icebergs 
@@ -1193,5 +1243,5 @@
 The presence at the sea surface of an ice covered area modifies all the fluxes 
 transmitted to the ocean. There are several way to handle sea-ice in the system 
-depending on the value of the \np{nn{\_}ice} namelist parameter.  
+depending on the value of the \np{nn\_ice} namelist parameter found in \ngn{namsbc} namelist.  
 \begin{description}
 \item[nn{\_}ice = 0]  there will never be sea-ice in the computational domain. 
@@ -1268,27 +1318,41 @@
 % -------------------------------------------------------------------------------------------------------------
 \subsection   [Neutral drag coefficient from external wave model (\textit{sbcwave})]
-                        {Neutral drag coefficient from external wave model (\mdl{sbcwave})}
+              {Neutral drag coefficient from external wave model (\mdl{sbcwave})}
 \label{SBC_wave}
 %------------------------------------------namwave----------------------------------------------------
 \namdisplay{namsbc_wave}
 %-------------------------------------------------------------------------------------------------------------
-\begin{description}
-
-\item [??] In order to read a neutral drag coeff, from an external data source (i.e. a wave model), the 
-logical variable \np{ln\_cdgw}
- in $namsbc$ namelist must be defined ${.true.}$. 
+
+In order to read a neutral drag coeff, from an external data source ($i.e.$ a wave model), the 
+logical variable \np{ln\_cdgw} in \ngn{namsbc} namelist must be set to \textit{true}. 
 The \mdl{sbcwave} module containing the routine \np{sbc\_wave} reads the
 namelist \ngn{namsbc\_wave} (for external data names, locations, frequency, interpolation and all 
 the miscellanous options allowed by Input Data generic Interface see \S\ref{SBC_input}) 
-and a 2D field of neutral drag coefficient. Then using the routine 
-TURB\_CORE\_1Z or TURB\_CORE\_2Z, and starting from the neutral drag coefficent provided, the drag coefficient is computed according 
-to stable/unstable conditions of the air-sea interface following \citet{Large_Yeager_Rep04}.
-
-\end{description}
+and a 2D field of neutral drag coefficient. 
+Then using the routine TURB\_CORE\_1Z or TURB\_CORE\_2Z, and starting from the neutral drag coefficent provided, 
+the drag coefficient is computed according to stable/unstable conditions of the air-sea interface following \citet{Large_Yeager_Rep04}.
+
 
 % Griffies doc:
-% When running ocean-ice simulations, we are not explicitly representing land processes, such as rivers, catchment areas, snow accumulation, etc. However, to reduce model drift, it is important to balance the hydrological cycle in ocean-ice models. We thus need to prescribe some form of global normalization to the precipitation minus evaporation plus river runoff. The result of the normalization should be a global integrated zero net water input to the ocean-ice system over a chosen time scale. 
-%How often the normalization is done is a matter of choice. In mom4p1, we choose to do so at each model time step, so that there is always a zero net input of water to the ocean-ice system. Others choose to normalize over an annual cycle, in which case the net imbalance over an annual cycle is used to alter the subsequent year�s water budget in an attempt to damp the annual water imbalance. Note that the annual budget approach may be inappropriate with interannually varying precipitation forcing. 
-%When running ocean-ice coupled models, it is incorrect to include the water transport between the ocean and ice models when aiming to balance the hydrological cycle. The reason is that it is the sum of the water in the ocean plus ice that should be balanced when running ocean-ice models, not the water in any one sub-component. As an extreme example to illustrate the issue, consider an ocean-ice model with zero initial sea ice. As the ocean-ice model spins up, there should be a net accumulation of water in the growing sea ice, and thus a net loss of water from the ocean. The total water contained in the ocean plus ice system is constant, but there is an exchange of water between the subcomponents. This exchange should not be part of the normalization used to balance the hydrological cycle in ocean-ice models. 
-
-
+% When running ocean-ice simulations, we are not explicitly representing land processes, 
+% such as rivers, catchment areas, snow accumulation, etc. However, to reduce model drift, 
+% it is important to balance the hydrological cycle in ocean-ice models. 
+% We thus need to prescribe some form of global normalization to the precipitation minus evaporation plus river runoff. 
+% The result of the normalization should be a global integrated zero net water input to the ocean-ice system over 
+% a chosen time scale. 
+%How often the normalization is done is a matter of choice. In mom4p1, we choose to do so at each model time step, 
+% so that there is always a zero net input of water to the ocean-ice system. 
+% Others choose to normalize over an annual cycle, in which case the net imbalance over an annual cycle is used 
+% to alter the subsequent year�s water budget in an attempt to damp the annual water imbalance. 
+% Note that the annual budget approach may be inappropriate with interannually varying precipitation forcing. 
+% When running ocean-ice coupled models, it is incorrect to include the water transport between the ocean 
+% and ice models when aiming to balance the hydrological cycle. 
+% The reason is that it is the sum of the water in the ocean plus ice that should be balanced when running ocean-ice models, 
+% not the water in any one sub-component. As an extreme example to illustrate the issue, 
+% consider an ocean-ice model with zero initial sea ice. As the ocean-ice model spins up, 
+% there should be a net accumulation of water in the growing sea ice, and thus a net loss of water from the ocean. 
+% The total water contained in the ocean plus ice system is constant, but there is an exchange of water between 
+% the subcomponents. This exchange should not be part of the normalization used to balance the hydrological cycle 
+% in ocean-ice models. 
+
+
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_STO.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_STO.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_STO.tex	(revision 6436)
@@ -5,7 +5,154 @@
 \label{STO}
 
+Authors: P.-A. Bouttier
+
 \minitoc
-
 
 \newpage
 $\ $\newline    % force a new line
+
+The stochastic parametrization module aims to explicitly simulate uncertainties in the model. More particularly, \cite{Brankart_OM2013} has shown that, because of the nonlinearity of the seawater equation of state, unresolved scales represent a major source of uncertainties in the computation of the large scale horizontal density gradient (from T/S large scale fields), and that the impact of these uncertainties can be simulated by random processes representing unresolved T/S fluctuations.
+
+The stochastic formulation of the equation of state can be written as:
+\begin{equation}
+ \label{eq:eos_sto}
+  \rho = \frac{1}{2} \sum_{i=1}^m\{ \rho[T+\Delta T_i,S+\Delta S_i,p_o(z)] + \rho[T-\Delta T_i,S-\Delta S_i,p_o(z)] \}
+\end{equation}
+where $p_o(z)$ is the reference pressure depending on the depth and $\Delta T_i$ and $\Delta S_i$ are a set of T/S perturbations defined as the scalar product of the respective local T/S gradients with random walks $\mathbf{\xi}$:
+\begin{equation}
+ \label{eq:sto_pert}
+ \Delta T_i = \mathbf{\xi}_i \cdot \nabla T \qquad \hbox{and} \qquad \Delta S_i = \mathbf{\xi}_i \cdot \nabla S
+\end{equation}
+$\mathbf{\xi}_i$ are produced by a first-order autoregressive processes (AR-1) with a parametrized decorrelation time scale, and horizontal and vertical standard deviations $\sigma_s$. $\mathbf{\xi}$ are uncorrelated over the horizontal and fully correlated along the vertical.
+
+
+\section{Stochastic processes}
+\label{STO_the_details}
+
+The starting point of our implementation of stochastic parameterizations
+in NEMO is to observe that many existing parameterizations are based
+on autoregressive processes, which are used as a basic source of randomness
+to transform a deterministic model into a probabilistic model.
+A generic approach is thus to add one single new module in NEMO,
+generating processes with appropriate statistics
+to simulate each kind of uncertainty in the model
+(see \cite{Brankart_al_GMD2015} for more details).
+
+In practice, at every model grid point, independent Gaussian autoregressive
+processes~$\xi^{(i)},\,i=1,\ldots,m$ are first generated
+using the same basic equation:
+
+\begin{equation}
+\label{eq:autoreg}
+\xi^{(i)}_{k+1} = a^{(i)} \xi^{(i)}_k + b^{(i)} w^{(i)} + c^{(i)}
+\end{equation}
+
+\noindent
+where $k$ is the index of the model timestep; and
+$a^{(i)}$, $b^{(i)}$, $c^{(i)}$ are parameters defining
+the mean ($\mu^{(i)}$) standard deviation ($\sigma^{(i)}$)
+and correlation timescale ($\tau^{(i)}$) of each process:
+
+\begin{itemize}
+\item for order~1 processes, $w^{(i)}$ is a Gaussian white noise,
+with zero mean and standard deviation equal to~1, and the parameters
+$a^{(i)}$, $b^{(i)}$, $c^{(i)}$ are given by:
+
+\begin{equation}
+\label{eq:ord1}
+\left\{
+\begin{array}{l}
+a^{(i)} = \varphi \\
+b^{(i)} = \sigma^{(i)} \sqrt{ 1 - \varphi^2 } 
+ \qquad\qquad\mbox{with}\qquad\qquad
+\varphi = \exp \left( - 1 / \tau^{(i)} \right) \\
+c^{(i)} = \mu^{(i)} \left( 1 - \varphi \right) \\
+\end{array}
+\right.
+\end{equation}
+
+\item for order~$n>1$ processes, $w^{(i)}$ is an order~$n-1$ autoregressive process,
+with zero mean, standard deviation equal to~$\sigma^{(i)}$; correlation timescale
+equal to~$\tau^{(i)}$; and the parameters
+$a^{(i)}$, $b^{(i)}$, $c^{(i)}$ are given by:
+
+\begin{equation}
+\label{eq:ord2}
+\left\{
+\begin{array}{l}
+a^{(i)} = \varphi \\
+b^{(i)} = \frac{n-1}{2(4n-3)} \sqrt{ 1 - \varphi^2 } 
+ \qquad\qquad\mbox{with}\qquad\qquad
+\varphi = \exp \left( - 1 / \tau^{(i)} \right) \\
+c^{(i)} = \mu^{(i)} \left( 1 - \varphi \right) \\
+\end{array}
+\right.
+\end{equation}
+
+\end{itemize}
+
+\noindent
+In this way, higher order processes can be easily generated recursively using the same piece of code implementing Eq.~(\ref{eq:autoreg}), and using succesively processes from order $0$ to~$n-1$ as~$w^{(i)}$.
+The parameters in Eq.~(\ref{eq:ord2}) are computed so that this recursive application
+of Eq.~(\ref{eq:autoreg}) leads to processes with the required standard deviation
+and correlation timescale, with the additional condition that
+the $n-1$ first derivatives of the autocorrelation function
+are equal to zero at~$t=0$, so that the resulting processes
+become smoother and smoother as $n$ is increased.
+
+Overall, this method provides quite a simple and generic way of generating a wide class of stochastic processes. However, this also means that new model parameters are needed to specify each of these stochastic processes. As in any parameterization of lacking physics, a very important issues then to tune these new parameters using either first principles, model simulations, or real-world observations.
+
+\section{Implementation details}
+\label{STO_thech_details}
+The computer code implementing stochastic parametrisations is made of one single FORTRAN module,
+with 3 public routines to be called by the model (in our case, NEMO):
+
+The first routine ({sto\_par}) is a direct implementation of Eq.~(\ref{eq:autoreg}),
+applied at each model grid point (in 2D or 3D),
+and called at each model time step ($k$) to update
+every autoregressive process ($i=1,\ldots,m$).
+This routine also includes a filtering operator, applied to $w^{(i)}$,
+to introduce a spatial correlation between the stochastic processes.
+
+The second routine ({sto\_par\_init})
+is an initialization routine mainly dedicated
+to the computation of parameters $a^{(i)}, b^{(i)}, c^{(i)}$
+for each autoregressive process, as a function of the statistical properties
+required by the model user (mean, standard deviation, time correlation,
+order of the process,\ldots). Parameters for the processes can be specified through the following namelist parameters:
+\begin{alltt}
+\tiny
+\begin{verbatim}
+   nn_sto_eos = 1                ! number of independent random walks 
+   rn_eos_stdxy = 1.4            ! random walk horz. standard deviation (in grid points)
+   rn_eos_stdz  = 0.7            ! random walk vert. standard deviation (in grid points)
+   rn_eos_tcor  = 1440.0         ! random walk time correlation (in timesteps)
+   nn_eos_ord  = 1               ! order of autoregressive processes
+   nn_eos_flt  = 0               ! passes of Laplacian filter
+   rn_eos_lim  = 2.0             ! limitation factor (default = 3.0)
+\end{verbatim}
+\end{alltt}
+This routine also includes the initialization (seeding)
+of the random number generator.
+
+The third routine ({sto\_rst\_write}) writes a ``restart file''
+with the current value of all autoregressive processes
+to allow restarting a simulation from where it has been interrupted.
+This file also contains the current state of the random number generator.
+In case of a restart, this file is then read by the initialization routine
+({sto\_par\_init}), so that the simulation can continue exactly
+as if it was not interrupted.
+Restart capabilities of the module are driven by the following namelist parameters:
+\begin{alltt}
+\tiny
+\begin{verbatim}
+   ln_rststo = .false.           ! start from mean parameter (F) or from restart file (T)
+   ln_rstseed = .true.           ! read seed of RNG from restart file
+   cn_storst_in  = "restart_sto" !  suffix of stochastic parameter restart file (input)
+   cn_storst_out = "restart_sto" !  suffix of stochastic parameter restart file (output)
+\end{verbatim}
+\end{alltt}
+
+In the particular case of the stochastic equation of state, there is also an additional module ({sto\_pts}) implementing Eq~\ref{eq:sto_pert} and specific piece of code in the equation of state implementing Eq~\ref{eq:eos_sto}.
+
+
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_TRA.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_TRA.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_TRA.tex	(revision 6436)
@@ -1,4 +1,4 @@
 % ================================================================
-% Chapter 1 � Ocean Tracers (TRA)
+% Chapter 1 ——— Ocean Tracers (TRA)
 % ================================================================
 \chapter{Ocean Tracers (TRA)}
@@ -36,16 +36,14 @@
 (BBL) parametrisation, and an internal damping (DMP) term. The terms QSR, 
 BBC, BBL and DMP are optional. The external forcings and parameterisations 
-require complex inputs and complex calculations (e.g. bulk formulae, estimation 
+require complex inputs and complex calculations ($e.g.$ bulk formulae, estimation 
 of mixing coefficients) that are carried out in the SBC, LDF and ZDF modules and 
 described in chapters \S\ref{SBC}, \S\ref{LDF} and  \S\ref{ZDF}, respectively. 
-Note that \mdl{tranpc}, the non-penetrative convection module,  although 
-(temporarily) located in the NEMO/OPA/TRA directory, is described with the 
-model vertical physics (ZDF).
-%%%
-\gmcomment{change the position of eosbn2 in the reference code}
-%%%
+Note that \mdl{tranpc}, the non-penetrative convection module, although 
+located in the NEMO/OPA/TRA directory as it directly modifies the tracer fields, 
+is described with the model vertical physics (ZDF) together with other available 
+parameterization of convection.
 
 In the present chapter we also describe the diagnostic equations used to compute 
-the sea-water properties (density, Brunt-Vais\"{a}l\"{a} frequency, specific heat and 
+the sea-water properties (density, Brunt-V\"{a}is\"{a}l\"{a} frequency, specific heat and 
 freezing point with associated modules \mdl{eosbn2} and \mdl{phycst}).
 
@@ -56,6 +54,6 @@
 found in the \textit{trattt} or \textit{trattt\_xxx} module, in the NEMO/OPA/TRA directory.
 
-The user has the option of extracting each tendency term on the rhs of the tracer 
-equation for output (\key{trdtra} is defined), as described in Chap.~\ref{MISC}.
+The user has the option of extracting each tendency term on the RHS of the tracer 
+equation for output (\np{ln\_tra\_trd} or \np{ln\_tra\_mxl}~=~true), as described in Chap.~\ref{DIA}.
 
 $\ $\newline    % force a new ligne
@@ -125,7 +123,7 @@
 \end{description}
 In all cases, this boundary condition retains local conservation of tracer. 
-Global conservation is obtained in both rigid-lid and non-linear free surface 
-cases, but not in the linear free surface case. Nevertheless, in the latter
-case, it is achieved to a good approximation since the non-conservative 
+Global conservation is obtained in non-linear free surface case, 
+but \textit{not} in the linear free surface case. Nevertheless, in the latter case, 
+it is achieved to a good approximation since the non-conservative 
 term is the product of the time derivative of the tracer and the free surface 
 height, two quantities that are not correlated (see \S\ref{PE_free_surface}, 
@@ -133,7 +131,8 @@
 
 The velocity field that appears in (\ref{Eq_tra_adv}) and (\ref{Eq_tra_adv_zco}) 
-is the centred (\textit{now}) \textit{eulerian} ocean velocity (see Chap.~\ref{DYN}). 
-When eddy induced velocity (\textit{eiv}) parameterisation is used it is the \textit{now} 
-\textit{effective} velocity ($i.e.$ the sum of the eulerian and eiv velocities) which is used.
+is the centred (\textit{now}) \textit{effective} ocean velocity, $i.e.$ the \textit{eulerian} velocity
+(see Chap.~\ref{DYN}) plus the eddy induced velocity (\textit{eiv}) 
+and/or the mixed layer eddy induced velocity (\textit{eiv})
+when those parameterisations are used (see Chap.~\ref{LDF}).
 
 The choice of an advection scheme is made in the \textit{\ngn{nam\_traadv}} namelist, by 
@@ -146,8 +145,8 @@
 
 Note that 
-(1) cen2, cen4 and TVD schemes require an explicit diffusion 
+(1) cen2 and TVD schemes require an explicit diffusion 
 operator while the other schemes are diffusive enough so that they do not 
 require additional diffusion ; 
-(2) cen2, cen4, MUSCL2, and UBS are not \textit{positive} schemes
+(2) cen2, MUSCL2, and UBS are not \textit{positive} schemes
 \footnote{negative values can appear in an initially strictly positive tracer field 
 which is advected}
@@ -189,5 +188,5 @@
 temperature is close to the freezing point).
 This combined scheme has been included for specific grid points in the ORCA2 
-and ORCA4 configurations only. This is an obsolescent feature as the recommended 
+configuration only. This is an obsolescent feature as the recommended 
 advection scheme for the ORCA configuration is TVD (see  \S\ref{TRA_adv_tvd}).
 
@@ -196,41 +195,4 @@
 have this order of accuracy. \gmcomment{Note also that ... blah, blah}
 
-% -------------------------------------------------------------------------------------------------------------
-%        4nd order centred scheme  
-% -------------------------------------------------------------------------------------------------------------
-\subsection   [$4^{nd}$ order centred scheme (cen4) (\np{ln\_traadv\_cen4})]
-		     {$4^{nd}$ order centred scheme (cen4) (\np{ln\_traadv\_cen4}=true)}
-\label{TRA_adv_cen4}
-
-In the $4^{th}$ order formulation (to be implemented), tracer values are 
-evaluated at velocity points as a $4^{th}$ order interpolation, and thus depend on 
-the four neighbouring $T$-points. For example, in the $i$-direction:
-\begin{equation} \label{Eq_tra_adv_cen4}
-\tau _u^{cen4} 
-=\overline{   T - \frac{1}{6}\,\delta _i \left[ \delta_{i+1/2}[T] \,\right]   }^{\,i+1/2}
-\end{equation}
-
-Strictly speaking, the cen4 scheme is not a $4^{th}$ order advection scheme 
-but a $4^{th}$ order evaluation of advective fluxes, since the divergence of 
-advective fluxes \eqref{Eq_tra_adv} is kept at $2^{nd}$ order. The phrase ``$4^{th}$ 
-order scheme'' used in oceanographic literature is usually associated 
-with the scheme presented here. Introducing a \textit{true} $4^{th}$ order advection 
-scheme is feasible but, for consistency reasons, it requires changes in the 
-discretisation of the tracer advection together with changes in both the 
-continuity equation and the momentum advection terms.  
-
-A direct consequence of the pseudo-fourth order nature of the scheme is that 
-it is not non-diffusive, i.e. the global variance of a tracer is not preserved using 
-\textit{cen4}. Furthermore, it must be used in conjunction with an explicit 
-diffusion operator to produce a sensible solution. The time-stepping is also 
-performed using a leapfrog scheme in conjunction with an Asselin time-filter, 
-so $T$ in (\ref{Eq_tra_adv_cen4}) is the \textit{now} tracer.
-
-At a $T$-grid cell adjacent to a boundary (coastline, bottom and surface), an 
-additional hypothesis must be made to evaluate $\tau _u^{cen4}$. This 
-hypothesis usually reduces the order of the scheme. Here we choose to set 
-the gradient of $T$ across the boundary to zero. Alternative conditions can be 
-specified, such as a reduction to a second order scheme for these near boundary 
-grid points.
 
 % -------------------------------------------------------------------------------------------------------------
@@ -270,4 +232,12 @@
 used for the diffusive part. 
 
+An additional option has been added controlled by \np{ln\_traadv\_tvd\_zts}. 
+By setting this logical to true, a TVD scheme is used on both horizontal and vertical direction, 
+but on the latter, a split-explicit time stepping is used, with 5 sub-timesteps. 
+This option can be useful when the value of the timestep is limited by vertical advection \citep{Lemarie_OM2015}. 
+Note that in this case, a similar split-explicit time stepping should be used on 
+vertical advection of momentum to ensure a better stability (see \np{ln\_dynzad\_zts} in \S\ref{DYN_zad}).
+
+
 % -------------------------------------------------------------------------------------------------------------
 %        MUSCL scheme  
@@ -296,10 +266,12 @@
 
 For an ocean grid point adjacent to land and where the ocean velocity is 
-directed toward land, two choices are available: an upstream flux 
-(\np{ln\_traadv\_muscl}=true) or a second order flux 
-(\np{ln\_traadv\_muscl2}=true). Note that the latter choice does not ensure 
-the \textit{positive} character of the scheme. Only the former can be used 
-on both active and passive tracers. The two MUSCL schemes are implemented 
-in the \mdl{traadv\_tvd} and \mdl{traadv\_tvd2} modules.
+directed toward land, two choices are available: an upstream flux (\np{ln\_traadv\_muscl}=true) 
+or a second order flux (\np{ln\_traadv\_muscl2}=true). 
+Note that the latter choice does not ensure the \textit{positive} character of the scheme. 
+Only the former can be used on both active and passive tracers. 
+The two MUSCL schemes are implemented in the \mdl{traadv\_tvd} and \mdl{traadv\_tvd2} modules.
+
+Note that when using np{ln\_traadv\_msc\_ups}~=~true in addition to \np{ln\_traadv\_muscl}=true, 
+the MUSCL fluxes are replaced by upstream fluxes in vicinity of river mouths.
 
 % -------------------------------------------------------------------------------------------------------------
@@ -416,18 +388,4 @@
 direction (as for the UBS case) should be implemented to restore this property.
 
-
-% -------------------------------------------------------------------------------------------------------------
-%        PPM scheme  
-% -------------------------------------------------------------------------------------------------------------
-\subsection   [Piecewise Parabolic Method (PPM) (\np{ln\_traadv\_ppm})]
-			{Piecewise Parabolic Method (PPM) (\np{ln\_traadv\_ppm}=true)}
-\label{TRA_adv_ppm}
-
-The Piecewise Parabolic Method (PPM) proposed by Colella and Woodward (1984) 
-\sgacomment{reference?}
-is based on a quadradic piecewise construction. Like the QCK scheme, it is associated 
-with the ULTIMATE QUICKEST limiter \citep{Leonard1991}. It has been implemented 
-in \NEMO by G. Reffray (MERCATOR-ocean) but is not yet offered in the reference 
-version 3.3.
 
 % ================================================================
@@ -464,5 +422,5 @@
 surfaces is given by: 
 \begin{equation} \label{Eq_tra_ldf_lap}
-D_T^{lT} =\frac{1}{b_tT} \left( \;
+D_T^{lT} =\frac{1}{b_t} \left( \;
    \delta _{i}\left[ A_u^{lT} \; \frac{e_{2u}\,e_{3u}}{e_{1u}} \;\delta _{i+1/2} [T] \right] 
 + \delta _{j}\left[ A_v^{lT} \;  \frac{e_{1v}\,e_{3v}}{e_{2v}} \;\delta _{j+1/2} [T] \right]  \;\right)
@@ -661,16 +619,10 @@
 the thickness of the top model layer. 
 
-Due to interactions and mass exchange of water ($F_{mass}$) with other Earth system components ($i.e.$ atmosphere, sea-ice, land),
-the change in the heat and salt content of the surface layer of the ocean is due both 
-to the heat and salt fluxes crossing the sea surface (not linked with $F_{mass}$)
- and to the heat and salt content of the mass exchange.
-\sgacomment{ the following does not apply to the release to which this documentation is 
-attached and so should not be included ....
-In a forthcoming release, these two parts, computed in the surface module (SBC), will be included directly
-in $Q_{ns}$, the surface heat flux and $F_{salt}$, the surface salt flux.
-The specification of these fluxes is further detailed in the SBC chapter (see \S\ref{SBC}). 
-This change will provide a forcing formulation which is the same for any tracer (including temperature and salinity).
- 
-In the current version, the situation is a little bit more complicated. }
+Due to interactions and mass exchange of water ($F_{mass}$) with other Earth system components 
+($i.e.$ atmosphere, sea-ice, land), the change in the heat and salt content of the surface layer 
+of the ocean is due both to the heat and salt fluxes crossing the sea surface (not linked with $F_{mass}$) 
+and to the heat and salt content of the mass exchange. They are both included directly in $Q_{ns}$, 
+the surface heat flux, and $F_{salt}$, the surface salt flux (see \S\ref{SBC} for further details).
+By doing this, the forcing formulation is the same for any tracer (including temperature and salinity).
 
 The surface module (\mdl{sbcmod}, see \S\ref{SBC}) provides the following 
@@ -679,22 +631,37 @@
 $\bullet$ $Q_{ns}$, the non-solar part of the net surface heat flux that crosses the sea surface 
 (i.e. the difference between the total surface heat flux and the fraction of the short wave flux that 
-penetrates into the water column, see \S\ref{TRA_qsr})
-
-$\bullet$ \textit{emp}, the mass flux exchanged with the atmosphere (evaporation minus precipitation)
-
-$\bullet$ $\textit{emp}_S$, an equivalent mass flux taking into account the effect of ice-ocean mass exchange
-
-$\bullet$ \textit{rnf}, the mass flux associated with runoff (see \S\ref{SBC_rnf} for further detail of how it acts on temperature and salinity tendencies)
-
-The $\textit{emp}_S$ field is not simply the budget of evaporation-precipitation+freezing-melting because 
-the sea-ice is not currently embedded in the ocean but levitates above it. There is no mass
-exchanged between the sea-ice and the ocean. Instead we only take into account the salt
-flux associated with the non-zero salinity of sea-ice, and the concentration/dilution effect
-due to the freezing/melting (F/M) process. These two parts of the forcing are then converted into 
-an equivalent mass flux given by $\textit{emp}_S - \textit{emp}$. As a result of this mess, 
-the surface boundary condition on temperature and salinity is applied as follows:
-
-In the nonlinear free surface case (\key{vvl} is defined):
+penetrates into the water column, see \S\ref{TRA_qsr}) plus the heat content associated with 
+of the mass exchange with the atmosphere and lands.
+
+$\bullet$ $\textit{sfx}$, the salt flux resulting from ice-ocean mass exchange (freezing, melting, ridging...)
+
+$\bullet$ \textit{emp}, the mass flux exchanged with the atmosphere (evaporation minus precipitation) 
+ and possibly with the sea-ice and ice-shelves.
+
+$\bullet$ \textit{rnf}, the mass flux associated with runoff 
+(see \S\ref{SBC_rnf} for further detail of how it acts on temperature and salinity tendencies)
+
+$\bullet$ \textit{fwfisf}, the mass flux associated with ice shelf melt, (see \S\ref{SBC_isf} for further details 
+on how the ice shelf melt is computed and applied).\\
+
+In the non-linear free surface case (\key{vvl} is defined), the surface boundary condition 
+on temperature and salinity is applied as follows:
 \begin{equation} \label{Eq_tra_sbc}
+\begin{aligned}
+ &F^T = \frac{ 1 }{\rho _o \;C_p \,\left. e_{3t} \right|_{k=1} }  &\overline{ Q_{ns}       }^t  & \\ 
+& F^S =\frac{ 1 }{\rho _o  \,      \left. e_{3t} \right|_{k=1} }  &\overline{ \textit{sfx} }^t   & \\   
+ \end{aligned}
+\end{equation} 
+where $\overline{x }^t$ means that $x$ is averaged over two consecutive time steps 
+($t-\rdt/2$ and $t+\rdt/2$). Such time averaging prevents the 
+divergence of odd and even time step (see \S\ref{STP}).
+
+In the linear free surface case (\key{vvl} is \textit{not} defined), 
+an additional term has to be added on both temperature and salinity. 
+On temperature, this term remove the heat content associated with mass exchange
+that has been added to $Q_{ns}$. On salinity, this term mimics the concentration/dilution effect that
+would have resulted from a change in the volume of the first level.
+The resulting surface boundary condition is applied as follows:
+\begin{equation} \label{Eq_tra_sbc_lin}
 \begin{aligned}
  &F^T = \frac{ 1 }{\rho _o \;C_p \,\left. e_{3t} \right|_{k=1} }   
@@ -702,50 +669,11 @@
 %
 & F^S =\frac{ 1 }{\rho _o \,\left. e_{3t} \right|_{k=1} } 
-           &\overline{ \left( (\textit{emp}_S - \textit{emp})\;\left. S \right|_{k=1}  \right) }^t   & \\   
+           &\overline{ \left( \;\textit{sfx} - \textit{emp} \;\left. S \right|_{k=1}  \right) }^t   & \\   
  \end{aligned}
 \end{equation} 
-
-In the linear free surface case (\key{vvl} not defined):
-\begin{equation} \label{Eq_tra_sbc_lin}
-\begin{aligned}
- &F^T = \frac{ 1 }{\rho _o \;C_p \,\left. e_{3t} \right|_{k=1} }  &\overline{ Q_{ns} }^t  & \\ 
-%
-& F^S =\frac{ 1 }{\rho _o \,\left. e_{3t} \right|_{k=1} } 
-           &\overline{ \left( \textit{emp}_S\;\left. S \right|_{k=1}  \right) }^t   & \\   
- \end{aligned}
-\end{equation} 
-where $\overline{x }^t$ means that $x$ is averaged over two consecutive time steps 
-($t-\rdt/2$ and $t+\rdt/2$). Such time averaging prevents the 
-divergence of odd and even time step (see \S\ref{STP}).
-
-The two set of equations, \eqref{Eq_tra_sbc} and \eqref{Eq_tra_sbc_lin}, are obtained 
-by assuming that the temperature of precipitation and evaporation are equal to
-the ocean surface temperature and that their salinity is zero. Therefore, the heat content
-of the \textit{emp} budget must be added to the temperature equation in the variable volume case, 
-while it does not appear in the constant volume case. Similarly, the \textit{emp} budget affects 
-the ocean surface salinity in the constant volume case (through the concentration dilution effect)
-while it does not appears explicitly in the variable volume case since salinity change will be
-induced by volume change. In both constant and variable volume cases, surface salinity 
-will change with ice-ocean salt flux and F/M flux (both contained in $\textit{emp}_S - \textit{emp}$) without mass exchanges.
-
-Note that the concentration/dilution effect due to F/M is computed using
-a constant ice salinity as well as a constant ocean salinity. 
-This approximation suppresses the correlation between \textit{SSS} 
-and F/M flux, allowing the ice-ocean salt exchanges to be conservative.
-Indeed, if this approximation is not made, even if the F/M budget is zero 
-on average over the whole ocean domain and over the seasonal cycle, 
-the associated salt flux is not zero, since sea-surface salinity and F/M flux are 
-intrinsically correlated (high \textit{SSS} are found where freezing is 
-strong whilst low \textit{SSS} is usually associated with high melting areas).
-
-Even using this approximation, an exact conservation of heat and salt content 
-is only achieved in the variable volume case. In the constant volume case, 
-there is a small imbalance associated with the product $(\partial_t\eta - \textit{emp}) * \textit{SSS}$.
-Nevertheless, the salt content variation is quite small and will not induce
-a long term drift as there is no physical reason for $(\partial_t\eta - \textit{emp})$ 
-and \textit{SSS} to be correlated \citep{Roullet_Madec_JGR00}. 
-Note that, while quite small, the imbalance in the constant volume case is larger 
+Note that an exact conservation of heat and salt content is only achieved with non-linear free surface. 
+In the linear free surface case, there is a small imbalance. The imbalance is larger 
 than the imbalance associated with the Asselin time filter \citep{Leclair_Madec_OM09}. 
-This is the reason why the modified filter is not applied in the constant volume case.
+This is the reason why the modified filter is not applied in the linear free surface case (see \S\ref{STP}).
 
 % -------------------------------------------------------------------------------------------------------------
@@ -821,11 +749,19 @@
 ($i.e.$ the inverses of the extinction length scales) are tabulated over 61 nonuniform 
 chlorophyll classes ranging from 0.01 to 10 g.Chl/L (see the routine \rou{trc\_oce\_rgb} 
-in \mdl{trc\_oce} module). Three types of chlorophyll can be chosen in the RGB formulation:
-(1) a constant 0.05 g.Chl/L value everywhere (\np{nn\_chdta}=0) ; (2) an observed 
-time varying chlorophyll (\np{nn\_chdta}=1) ; (3) simulated time varying chlorophyll
-by TOP biogeochemical model (\np{ln\_qsr\_bio}=true). In the latter case, the RGB 
-formulation is used to calculate both the phytoplankton light limitation in PISCES 
-or LOBSTER and the oceanic heating rate. 
-
+in \mdl{trc\_oce} module). Four types of chlorophyll can be chosen in the RGB formulation:
+\begin{description} 
+\item[\np{nn\_chdta}=0] 
+a constant 0.05 g.Chl/L value everywhere ; 
+\item[\np{nn\_chdta}=1]  
+an observed time varying chlorophyll deduced from satellite surface ocean color measurement 
+spread uniformly in the vertical direction ; 
+\item[\np{nn\_chdta}=2]  
+same as previous case except that a vertical profile of chlorophyl is used. 
+Following \cite{Morel_Berthon_LO89}, the profile is computed from the local surface chlorophyll value ;
+\item[\np{ln\_qsr\_bio}=true]  
+simulated time varying chlorophyll by TOP biogeochemical model. 
+In this case, the RGB formulation is used to calculate both the phytoplankton 
+light limitation in PISCES or LOBSTER and the oceanic heating rate. 
+\end{description} 
 The trend in \eqref{Eq_tra_qsr} associated with the penetration of the solar radiation 
 is added to the temperature trend, and the surface heat flux is modified in routine \mdl{traqsr}. 
@@ -859,5 +795,5 @@
 \label{TRA_bbc}
 %--------------------------------------------nambbc--------------------------------------------------------
-\namdisplay{namtra_bbc}
+\namdisplay{nambbc}
 %--------------------------------------------------------------------------------------------------------------
 %>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -1103,5 +1039,10 @@
 \subsection[DMP\_TOOLS]{Generating resto.nc using DMP\_TOOLS}
 
-DMP\_TOOLS can be used to generate a netcdf file containing the restoration coefficient $\gamma$. Note that in order to maintain bit comparison with previous NEMO versions DMP\_TOOLS must be compiled and run on the same machine as the NEMO model. A mesh\_mask.nc file for the model configuration is required as an input. This can be generated by carrying out a short model run with the namelist parameter \np{nn\_msh} set to 1. The namelist parameter \np{ln\_tradmp} will also need to be set to .false. for this to work. The \nl{nam\_dmp\_create} namelist in the DMP\_TOOLS directory is used to specify options for the restoration coefficient.
+DMP\_TOOLS can be used to generate a netcdf file containing the restoration coefficient $\gamma$. 
+Note that in order to maintain bit comparison with previous NEMO versions DMP\_TOOLS must be compiled 
+and run on the same machine as the NEMO model. A mesh\_mask.nc file for the model configuration is required as an input. 
+This can be generated by carrying out a short model run with the namelist parameter \np{nn\_msh} set to 1. 
+The namelist parameter \np{ln\_tradmp} will also need to be set to .false. for this to work. 
+The \nl{nam\_dmp\_create} namelist in the DMP\_TOOLS directory is used to specify options for the restoration coefficient.
 
 %--------------------------------------------nam_dmp_create-------------------------------------------------
@@ -1111,7 +1052,23 @@
 \np{cp\_cfg}, \np{cp\_cpz}, \np{jp\_cfg} and \np{jperio} specify the model configuration being used and should be the same as specified in \nl{namcfg}. The variable \nl{lzoom} is used to specify that the damping is being used as in case \textit{a} above to provide boundary conditions to a zoom configuration. In the case of the arctic or antarctic zoom configurations this includes some specific treatment. Otherwise damping is applied to the 6 grid points along the ocean boundaries. The open boundaries are specified by the variables \np{lzoom\_n}, \np{lzoom\_e}, \np{lzoom\_s}, \np{lzoom\_w} in the \nl{nam\_zoom\_dmp} name list.
 
-The remaining switch namelist variables determine the spatial variation of the restoration coefficient in non-zoom configurations. \np{ln\_full\_field} specifies that newtonian damping should be applied to the whole model domain. \np{ln\_med\_red\_seas} specifies grid specific restoration coefficients in the Mediterranean Sea for the ORCA4, ORCA2 and ORCA05 configurations. If \np{ln\_old\_31\_lev\_code} is set then the depth variation of the coeffients will be specified as a function of the model number. This option is included to allow backwards compatability of the ORCA2 reference configurations with previous model versions. \np{ln\_coast} specifies that the restoration coefficient should be reduced near to coastlines. This option only has an effect if \np{ln\_full\_field} is true. \np{ln\_zero\_top\_layer} specifies that the restoration coefficient should be zero in the surface layer. Finally \np{ln\_custom} specifies that the custom module will be called. This module is contained in the file custom.F90 and can be edited by users. For example damping could be applied in a specific region.
-
-The restoration coefficient can be set to zero in equatorial regions by specifying a positive value of \np{nn\_hdmp}. Equatorward of this latitude the restoration coefficient will be zero with a smooth transition to the full values of a 10$^{\circ}$ latitud band. This is often used because of the short adjustment time scale in the equatorial region \citep{Reverdin1991, Fujio1991, Marti_PhD92}. The time scale associated with the damping depends on the depth as a hyperbolic tangent, with \np{rn\_surf} as surface value, \np{rn\_bot} as bottom value and a transition depth of \np{rn\_dep}.  
+The remaining switch namelist variables determine the spatial variation of the restoration coefficient in non-zoom configurations. 
+\np{ln\_full\_field} specifies that newtonian damping should be applied to the whole model domain. 
+\np{ln\_med\_red\_seas} specifies grid specific restoration coefficients in the Mediterranean Sea 
+for the ORCA4, ORCA2 and ORCA05 configurations. 
+If \np{ln\_old\_31\_lev\_code} is set then the depth variation of the coeffients will be specified as 
+a function of the model number. This option is included to allow backwards compatability of the ORCA2 reference 
+configurations with previous model versions. 
+\np{ln\_coast} specifies that the restoration coefficient should be reduced near to coastlines. 
+This option only has an effect if \np{ln\_full\_field} is true. 
+\np{ln\_zero\_top\_layer} specifies that the restoration coefficient should be zero in the surface layer. 
+Finally \np{ln\_custom} specifies that the custom module will be called. 
+This module is contained in the file custom.F90 and can be edited by users. For example damping could be applied in a specific region.
+
+The restoration coefficient can be set to zero in equatorial regions by specifying a positive value of \np{nn\_hdmp}. 
+Equatorward of this latitude the restoration coefficient will be zero with a smooth transition to 
+the full values of a 10$^{\circ}$ latitud band. 
+This is often used because of the short adjustment time scale in the equatorial region 
+\citep{Reverdin1991, Fujio1991, Marti_PhD92}. The time scale associated with the damping depends on the depth as a 
+hyperbolic tangent, with \np{rn\_surf} as surface value, \np{rn\_bot} as bottom value and a transition depth of \np{rn\_dep}.  
 
 % ================================================================
@@ -1167,115 +1124,138 @@
 %        Equation of State
 % -------------------------------------------------------------------------------------------------------------
-\subsection{Equation of State (\np{nn\_eos} = 0, 1 or 2)}
+\subsection{Equation Of Seawater (\np{nn\_eos} = -1, 0, or 1)}
 \label{TRA_eos}
 
-It is necessary to know the equation of state for the ocean very accurately 
-to determine stability properties (especially the Brunt-Vais\"{a}l\"{a} frequency), 
-particularly in the deep ocean. The ocean seawater volumic mass, $\rho$, 
-abusively called density, is a non linear empirical function of \textit{in situ} 
-temperature, salinity and pressure. The reference equation of state is that 
-defined by the Joint Panel on Oceanographic Tables and Standards 
-\citep{UNESCO1983}. It was the standard equation of state used in early 
-releases of OPA. However, even though this computation is fully vectorised, 
-it is quite time consuming ($15$ to $20${\%} of the total CPU time) since 
-it requires the prior computation of the \textit{in situ} temperature from the 
-model \textit{potential} temperature using the \citep{Bryden1973} polynomial 
-for adiabatic lapse rate and a $4^th$ order Runge-Kutta integration scheme. 
-Since OPA6, we have used the \citet{JackMcD1995} equation of state for 
-seawater instead. It allows the computation of the \textit{in situ} ocean density 
-directly as a function of \textit{potential} temperature relative to the surface 
-(an \NEMO variable), the practical salinity (another \NEMO variable) and the 
-pressure (assuming no pressure variation along geopotential surfaces, $i.e.$ 
-the pressure in decibars is approximated by the depth in meters). 
-Both the \citet{UNESCO1983} and \citet{JackMcD1995} equations of state 
-have exactly the same except that the values of the various coefficients have 
-been adjusted by \citet{JackMcD1995} in order to directly use the \textit{potential} 
-temperature instead of the \textit{in situ} one. This reduces the CPU time of the 
-\textit{in situ} density computation to about $3${\%} of the total CPU time, 
-while maintaining a quite accurate equation of state.
-
-In the computer code, a \textit{true} density anomaly, $d_a= \rho / \rho_o - 1$, 
-is computed, with $\rho_o$ a reference volumic mass. Called \textit{rau0} 
-in the code, $\rho_o$ is defined in \mdl{phycst}, and a value of $1,035~Kg/m^3$. 
+The Equation Of Seawater (EOS) is an empirical nonlinear thermodynamic relationship 
+linking seawater density, $\rho$, to a number of state variables, 
+most typically temperature, salinity and pressure. 
+Because density gradients control the pressure gradient force through the hydrostatic balance, 
+the equation of state provides a fundamental bridge between the distribution of active tracers 
+and the fluid dynamics. Nonlinearities of the EOS are of major importance, in particular 
+influencing the circulation through determination of the static stability below the mixed layer, 
+thus controlling rates of exchange between the atmosphere  and the ocean interior \citep{Roquet_JPO2015}. 
+Therefore an accurate EOS based on either the 1980 equation of state (EOS-80, \cite{UNESCO1983}) 
+or TEOS-10 \citep{TEOS10} standards should be used anytime a simulation of the real 
+ocean circulation is attempted \citep{Roquet_JPO2015}. 
+The use of TEOS-10 is highly recommended because 
+\textit{(i)} it is the new official EOS, 
+\textit{(ii)} it is more accurate, being based on an updated database of laboratory measurements, and 
+\textit{(iii)} it uses Conservative Temperature and Absolute Salinity (instead of potential temperature 
+and practical salinity for EOS-980, both variables being more suitable for use as model variables 
+\citep{TEOS10, Graham_McDougall_JPO13}. 
+EOS-80 is an obsolescent feature of the NEMO system, kept only for backward compatibility.
+For process studies, it is often convenient to use an approximation of the EOS. To that purposed, 
+a simplified EOS (S-EOS) inspired by \citet{Vallis06} is also available.
+
+In the computer code, a density anomaly, $d_a= \rho / \rho_o - 1$, 
+is computed, with $\rho_o$ a reference density. Called \textit{rau0} 
+in the code, $\rho_o$ is set in \mdl{phycst} to a value of $1,026~Kg/m^3$. 
 This is a sensible choice for the reference density used in a Boussinesq ocean 
 climate model, as, with the exception of only a small percentage of the ocean, 
-density in the World Ocean varies by no more than 2$\%$ from $1,035~kg/m^3$ 
-\citep{Gill1982}.
-
-Options are defined through the  \ngn{nameos} namelist variables.
-The default option (namelist parameter \np{nn\_eos}=0) is the \citet{JackMcD1995} 
-equation of state. Its use is highly recommended. However, for process studies, 
-it is often convenient to use a linear approximation of the density.
+density in the World Ocean varies by no more than 2$\%$ from that value \citep{Gill1982}.
+
+Options are defined through the  \ngn{nameos} namelist variables, and in particular \np{nn\_eos} 
+which controls the EOS used (=-1 for TEOS10 ; =0 for EOS-80 ; =1 for S-EOS).
+\begin{description}
+
+\item[\np{nn\_eos}$=-1$] the polyTEOS10-bsq equation of seawater \citep{Roquet_OM2015} is used.  
+The accuracy of this approximation is comparable to the TEOS-10 rational function approximation, 
+but it is optimized for a boussinesq fluid and the polynomial expressions have simpler 
+and more computationally efficient expressions for their derived quantities 
+which make them more adapted for use in ocean models. 
+Note that a slightly higher precision polynomial form is now used replacement of the TEOS-10 
+rational function approximation for hydrographic data analysis  \citep{TEOS10}. 
+A key point is that conservative state variables are used: 
+Absolute Salinity (unit: g/kg, notation: $S_A$) and Conservative Temperature (unit: $\degres C$, notation: $\Theta$).
+The pressure in decibars is approximated by the depth in meters. 
+With TEOS10, the specific heat capacity of sea water, $C_p$, is a constant. It is set to 
+$C_p=3991.86795711963~J\,Kg^{-1}\,\degres K^{-1}$, according to \citet{TEOS10}.
+
+Choosing polyTEOS10-bsq implies that the state variables used by the model are 
+$\Theta$ and $S_A$. In particular, the initial state deined by the user have to be given as 
+\textit{Conservative} Temperature and \textit{Absolute} Salinity. 
+In addition, setting \np{ln\_useCT} to \textit{true} convert the Conservative SST to potential SST 
+prior to either computing the air-sea and ice-sea fluxes (forced mode) 
+or sending the SST field to the atmosphere (coupled mode).
+
+\item[\np{nn\_eos}$=0$] the polyEOS80-bsq equation of seawater is used.
+It takes the same polynomial form as the polyTEOS10, but the coefficients have been optimized 
+to accurately fit EOS80 (Roquet, personal comm.). The state variables used in both the EOS80 
+and the ocean model are: 
+the Practical Salinity ((unit: psu, notation: $S_p$)) and Potential Temperature (unit: $\degres C$, notation: $\theta$).
+The pressure in decibars is approximated by the depth in meters.  
+With thsi EOS, the specific heat capacity of sea water, $C_p$, is a function of temperature, 
+salinity and pressure \citep{UNESCO1983}. Nevertheless, a severe assumption is made in order to 
+have a heat content ($C_p T_p$) which is conserved by the model: $C_p$ is set to a constant 
+value, the TEOS10 value. 
+ 
+\item[\np{nn\_eos}$=1$] a simplified EOS (S-EOS) inspired by \citet{Vallis06} is chosen, 
+the coefficients of which has been optimized to fit the behavior of TEOS10 (Roquet, personal comm.) 
+(see also \citet{Roquet_JPO2015}). It provides a simplistic linear representation of both 
+cabbeling and thermobaricity effects which is enough for a proper treatment of the EOS 
+in theoretical studies \citep{Roquet_JPO2015}.
 With such an equation of state there is no longer a distinction between 
-\textit{in situ} and \textit{potential} density and both cabbeling and thermobaric
-effects are removed.
-Two linear formulations are available: a function of $T$ only (\np{nn\_eos}=1) 
-and a function of both $T$ and $S$ (\np{nn\_eos}=2):
-\begin{equation} \label{Eq_tra_eos_linear}
+\textit{conservative} and \textit{potential} temperature, as well as between \textit{absolute} 
+and \textit{practical} salinity.
+S-EOS takes the following expression:
+\begin{equation} \label{Eq_tra_S-EOS}
 \begin{split}
-  d_a(T)       &=  \rho (T)      /  \rho_o   - 1     =  \  0.0285         -  \alpha   \;T     \\ 
-  d_a(T,S)    &=  \rho (T,S)   /  \rho_o   - 1     =  \  \beta \; S       -  \alpha   \;T    
+  d_a(T,S,z)  =  ( & - a_0 \; ( 1 + 0.5 \; \lambda_1 \; T_a + \mu_1 \; z ) * T_a  \\
+                                & + b_0 \; ( 1 - 0.5 \; \lambda_2 \; S_a - \mu_2 \; z ) * S_a  \\
+                                & - \nu \; T_a \; S_a \;  ) \; / \; \rho_o                     \\
+  with \ \  T_a = T-10  \; ;  & \;  S_a = S-35  \; ;\;  \rho_o = 1026~Kg/m^3
 \end{split}
 \end{equation} 
-where $\alpha$ and $\beta$ are the thermal and haline expansion 
-coefficients, and $\rho_o$, the reference volumic mass, $rau0$. 
-($\alpha$ and $\beta$ can be modified through the \np{rn\_alpha} and 
-\np{rn\_beta} namelist variables). Note that when $d_a$ is a function 
-of $T$ only (\np{nn\_eos}=1), the salinity is a passive tracer and can be 
-used as such.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Brunt-Vais\"{a}l\"{a} Frequency
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Brunt-Vais\"{a}l\"{a} Frequency (\np{nn\_eos} = 0, 1 or 2)}
+where the computer name of the coefficients as well as their standard value are given in \ref{Tab_SEOS}.
+In fact, when choosing S-EOS, various approximation of EOS can be specified simply by changing 
+the associated coefficients. 
+Setting to zero the two thermobaric coefficients ($\mu_1$, $\mu_2$) remove thermobaric effect from S-EOS.
+setting to zero the three cabbeling coefficients ($\lambda_1$, $\lambda_2$, $\nu$) remove cabbeling effect from S-EOS.
+Keeping non-zero value to $a_0$ and $b_0$ provide a linear EOS function of T and S.
+
+\end{description}
+
+
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\begin{table}[!tb]
+\begin{center} \begin{tabular}{|p{26pt}|p{72pt}|p{56pt}|p{136pt}|}
+\hline
+coeff.	& computer name   & S-EOS		&  description		                  \\ \hline
+$a_0$       & \np{rn\_a0}     & 1.6550 $10^{-1}$ &  linear thermal expansion coeff. 	\\ \hline
+$b_0$	      & \np{rn\_b0} 	   & 7.6554 $10^{-1}$ &  linear haline  expansion coeff. 	\\ \hline
+$\lambda_1$	& \np{rn\_lambda1}& 5.9520 $10^{-2}$ &  cabbeling coeff. in $T^2$ 	      \\ \hline
+$\lambda_2$	& \np{rn\_lambda2}& 5.4914 $10^{-4}$ &  cabbeling coeff. in $S^2$	 	   \\ \hline
+$\nu$       & \np{rn\_nu}     & 2.4341 $10^{-3}$ &  cabbeling coeff. in $T \, S$ 	   \\ \hline
+$\mu_1$     & \np{rn\_mu1} 	& 1.4970 $10^{-4}$ &  thermobaric coeff. in T    	   \\ \hline
+$\mu_2$     & \np{rn\_mu2} 	& 1.1090 $10^{-5}$ &  thermobaric coeff. in S   	      \\ \hline
+\end{tabular}
+\caption{ \label{Tab_SEOS}
+Standard value of S-EOS coefficients. }
+\end{center}
+\end{table}
+%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+
+% -------------------------------------------------------------------------------------------------------------
+%        Brunt-V\"{a}is\"{a}l\"{a} Frequency
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Brunt-V\"{a}is\"{a}l\"{a} Frequency (\np{nn\_eos} = 0, 1 or 2)}
 \label{TRA_bn2}
 
-An accurate computation of the ocean stability (i.e. of $N$, the brunt-Vais\"{a}l\"{a}
- frequency) is of paramount importance as it is used in several ocean 
- parameterisations (namely TKE, KPP, Richardson number dependent 
- vertical diffusion, enhanced vertical diffusion, non-penetrative convection, 
- iso-neutral diffusion). In particular, one must be aware that $N^2$ has to 
- be computed with an \textit{in situ} reference. The expression for $N^2$ 
- depends on the type of equation of state used (\np{nn\_eos} namelist parameter).
-
-For \np{nn\_eos}=0 (\citet{JackMcD1995} equation of state), the \citet{McDougall1987} 
-polynomial expression is used (with the pressure in decibar approximated by 
-the depth in meters): 
+An accurate computation of the ocean stability (i.e. of $N$, the brunt-V\"{a}is\"{a}l\"{a}
+ frequency) is of paramount importance as determine the ocean stratification and 
+ is used in several ocean parameterisations (namely TKE, GLS, Richardson number dependent 
+ vertical diffusion, enhanced vertical diffusion, non-penetrative convection, tidal mixing 
+ parameterisation, iso-neutral diffusion). In particular, $N^2$ has to be computed at the local pressure 
+ (pressure in decibar being approximated by the depth in meters). The expression for $N^2$ 
+ is given by: 
 \begin{equation} \label{Eq_tra_bn2}
-N^2 = \frac{g}{e_{3w}} \; \beta   \ 
-	   \left(  \alpha / \beta \ \delta_{k+1/2}[T]     - \delta_{k+1/2}[S]   \right) 
-\end{equation} 
-where $\alpha$ and $\beta$ are the thermal and haline expansion coefficients. 
-They are a function of  $\overline{T}^{\,k+1/2},\widetilde{S}=\overline{S}^{\,k+1/2} - 35.$, 
-and  $z_w$, with $T$ the \textit{potential} temperature and $\widetilde{S}$ a salinity anomaly. 
-Note that both $\alpha$ and $\beta$ depend on \textit{potential} 
-temperature and salinity which are averaged at $w$-points prior 
-to the computation instead of being computed at $T$-points and 
-then averaged to $w$-points.
-
-When a linear equation of state is used (\np{nn\_eos}=1 or 2, 
-\eqref{Eq_tra_bn2} reduces to:
-\begin{equation} \label{Eq_tra_bn2_linear}
 N^2 =	\frac{g}{e_{3w}} \left(   \beta \;\delta_{k+1/2}[S] - \alpha \;\delta_{k+1/2}[T]   \right)
 \end{equation} 
-where $\alpha$ and $\beta $ are the constant coefficients used to 
-defined the linear equation of state \eqref{Eq_tra_eos_linear}.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Specific Heat
-% -------------------------------------------------------------------------------------------------------------
-\subsection   	[Specific Heat (\textit{phycst})]
-			{Specific Heat (\mdl{phycst})}
-\label{TRA_adv_ldf}
-
-The specific heat of sea water, $C_p$, is a function of temperature, salinity 
-and pressure \citep{UNESCO1983}. It is only used in the model to convert 
-surface heat fluxes into surface temperature increase and so the pressure 
-dependence is neglected. The dependence on $T$ and $S$ is weak. 
-For example, with $S=35~psu$, $C_p$ increases from $3989$ to $4002$ 
-when $T$ varies from -2~\degres C to 31~\degres C. Therefore, $C_p$ has 
-been chosen as a constant: $C_p=4.10^3~J\,Kg^{-1}\,\degres K^{-1}$. 
-Its value is set in \mdl{phycst} module. 
-
+where $(T,S) = (\Theta, S_A)$ for TEOS10, $= (\theta, S_p)$ for TEOS-80, or $=(T,S)$ for S-EOS, 
+and, $\alpha$ and $\beta$ are the thermal and haline expansion coefficients. 
+The coefficients are a polynomial function of temperature, salinity and depth which expression 
+depends on the chosen EOS. They are computed through \textit{eos\_rab}, a \textsc{Fortran} 
+function that can be found in \mdl{eosbn2}.
 
 % -------------------------------------------------------------------------------------------------------------
@@ -1298,5 +1278,5 @@
 sea water ($i.e.$ referenced to the surface $p=0$), thus the pressure dependent 
 terms in \eqref{Eq_tra_eos_fzp} (last term) have been dropped. The freezing
-point is computed through \textit{tfreez}, a \textsc{Fortran} function that can be found 
+point is computed through \textit{eos\_fzp}, a \textsc{Fortran} function that can be found 
 in \mdl{eosbn2}.  
 
@@ -1308,11 +1288,13 @@
 \label{TRA_zpshde}
 
-\gmcomment{STEVEN: to be consistent with earlier discussion of differencing and averaging operators, I've changed "derivative" to "difference" and "mean" to "average"}
-
-With partial bottom cells (\np{ln\_zps}=true), in general, tracers in horizontally 
+\gmcomment{STEVEN: to be consistent with earlier discussion of differencing and averaging operators, 
+                   I've changed "derivative" to "difference" and "mean" to "average"}
+
+With partial cells (\np{ln\_zps}=true) at bottom and top (\np{ln\_isfcav}=true), in general, tracers in horizontally 
 adjacent cells live at different depths. Horizontal gradients of tracers are needed 
 for horizontal diffusion (\mdl{traldf} module) and for the hydrostatic pressure 
 gradient (\mdl{dynhpg} module) to be active. 
 \gmcomment{STEVEN from gm : question: not sure of  what -to be active- means}
+
 Before taking horizontal gradients between the tracers next to the bottom, a linear 
 interpolation in the vertical is used to approximate the deeper tracer as if it actually 
@@ -1390,2 +1372,14 @@
 \gmcomment{gm :   this last remark has to be done}
 %%%
+
+If under ice shelf seas opened (\np{ln\_isfcav}=true), the partial cell properties 
+at the top are computed in the same way as for the bottom. Some extra variables are, 
+however, computed to reduce the flow generated at the top and bottom if $z*$ coordinates activated.
+The extra variables calculated and used by \S\ref{DYN_hpg_isf} are:
+
+$\bullet$ $\overline{T}_k^{\,i+1/2}$ as described in \eqref{Eq_zps_hde}
+
+$\bullet$ $\delta _{i+1/2} Z_{T_k} = \widetilde {Z}^{\,i}_{T_k}-Z^{\,i}_{T_k}$ to compute 
+the pressure gradient correction term used by \eqref{Eq_dynhpg_sco} in \S\ref{DYN_hpg_isf},
+ with $\widetilde {Z}_{T_k}$ the depth of the point $\widetilde {T}_{k}$ in case of $z^*$ coordinates 
+(this term = 0 in z-coordinates)
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_ZDF.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_ZDF.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Chap_ZDF.tex	(revision 6436)
@@ -33,10 +33,9 @@
 points, respectively (see \S\ref{TRA_zdf} and \S\ref{DYN_zdf}). These 
 coefficients can be assumed to be either constant, or a function of the local 
-Richardson number, or computed from a turbulent closure model (either 
-TKE or KPP formulation). The computation of these coefficients is initialized 
-in the \mdl{zdfini} module and performed in the \mdl{zdfric}, \mdl{zdftke} or 
-\mdl{zdfkpp} modules. The trends due to the vertical momentum and tracer 
-diffusion, including the surface forcing, are computed and added to the 
-general trend in the \mdl{dynzdf} and \mdl{trazdf} modules, respectively. 
+Richardson number, or computed from a turbulent closure model (TKE, GLS or KPP formulation). 
+The computation of these coefficients is initialized in the \mdl{zdfini} module 
+and performed in the \mdl{zdfric}, \mdl{zdftke}, \mdl{zdfgls} or \mdl{zdfkpp} modules. 
+The trends due to the vertical momentum and tracer diffusion, including the surface forcing, 
+are computed and added to the general trend in the \mdl{dynzdf} and \mdl{trazdf} modules, respectively. 
 These trends can be computed using either a forward time stepping scheme 
 (namelist parameter \np{ln\_zdfexp}=true) or a backward time stepping 
@@ -262,9 +261,9 @@
 \end{equation}
 
-At the ocean surface, a non zero length scale is set through the  \np{rn\_lmin0} namelist 
+At the ocean surface, a non zero length scale is set through the  \np{rn\_mxl0} namelist 
 parameter. Usually the surface scale is given by $l_o = \kappa \,z_o$ 
 where $\kappa = 0.4$ is von Karman's constant and $z_o$ the roughness 
 parameter of the surface. Assuming $z_o=0.1$~m \citep{Craig_Banner_JPO94} 
-leads to a 0.04~m, the default value of \np{rn\_lsurf}. In the ocean interior 
+leads to a 0.04~m, the default value of \np{rn\_mxl0}. In the ocean interior 
 a minimum length scale is set to recover the molecular viscosity when $\bar{e}$ 
 reach its minimum value ($1.10^{-6}= C_k\, l_{min} \,\sqrt{\bar{e}_{min}}$ ).
@@ -295,6 +294,6 @@
 As the surface boundary condition on TKE is prescribed through $\bar{e}_o = e_{bb} |\tau| / \rho_o$, 
 with $e_{bb}$ the \np{rn\_ebb} namelist parameter, setting \np{rn\_ebb}~=~67.83 corresponds 
-to $\alpha_{CB} = 100$. further setting  \np{ln\_lsurf} to true applies \eqref{ZDF_Lsbc} 
-as surface boundary condition on length scale, with $\beta$ hard coded to the Stacet's value.
+to $\alpha_{CB} = 100$. Further setting  \np{ln\_mxl0} to true applies \eqref{ZDF_Lsbc} 
+as surface boundary condition on length scale, with $\beta$ hard coded to the Stacey's value.
 Note that a minimal threshold of \np{rn\_emin0}$=10^{-4}~m^2.s^{-2}$ (namelist parameters) 
 is applied on surface $\bar{e}$ value.
@@ -355,9 +354,46 @@
 %--------------------------------------------------------------%
 
-To be add here a description of "penetration of TKE" and the associated namelist parameters
- \np{nn\_etau}, \np{rn\_efr} and \np{nn\_htau}.
+Vertical mixing parameterizations commonly used in ocean general circulation models 
+tend to produce mixed-layer depths that are too shallow during summer months and windy conditions.
+This bias is particularly acute over the Southern Ocean. 
+To overcome this systematic bias, an ad hoc parameterization is introduced into the TKE scheme  \cite{Rodgers_2014}. 
+The parameterization is an empirical one, $i.e.$ not derived from theoretical considerations, 
+but rather is meant to account for observed processes that affect the density structure of 
+the ocean’s planetary boundary layer that are not explicitly captured by default in the TKE scheme 
+($i.e.$ near-inertial oscillations and ocean swells and waves).
+
+When using this parameterization ($i.e.$ when \np{nn\_etau}~=~1), the TKE input to the ocean ($S$) 
+imposed by the winds in the form of near-inertial oscillations, swell and waves is parameterized 
+by \eqref{ZDF_Esbc} the standard TKE surface boundary condition, plus a depth depend one given by:
+\begin{equation}  \label{ZDF_Ehtau}
+S = (1-f_i) \; f_r \; e_s \; e^{-z / h_\tau} 
+\end{equation}
+where 
+$z$ is the depth,  
+$e_s$ is TKE surface boundary condition, 
+$f_r$ is the fraction of the surface TKE that penetrate in the ocean, 
+$h_\tau$ is a vertical mixing length scale that controls exponential shape of the penetration, 
+and $f_i$ is the ice concentration (no penetration if $f_i=1$, that is if the ocean is entirely 
+covered by sea-ice).
+The value of $f_r$, usually a few percents, is specified through \np{rn\_efr} namelist parameter. 
+The vertical mixing length scale, $h_\tau$, can be set as a 10~m uniform value (\np{nn\_etau}~=~0) 
+or a latitude dependent value (varying from 0.5~m at the Equator to a maximum value of 30~m 
+at high latitudes (\np{nn\_etau}~=~1). 
+
+Note that two other option existe, \np{nn\_etau}~=~2, or 3. They correspond to applying 
+\eqref{ZDF_Ehtau} only at the base of the mixed layer, or to using the high frequency part 
+of the stress to evaluate the fraction of TKE that penetrate the ocean. 
+Those two options are obsolescent features introduced for test purposes.
+They will be removed in the next release. 
+
+
 
 % from Burchard et al OM 2008 : 
-% the most critical process not reproduced by statistical turbulence models is the activity of internal waves and their interaction with turbulence. After the Reynolds decomposition, internal waves are in principle included in the RANS equations, but later partially excluded by the hydrostatic assumption and the model resolution. Thus far, the representation of internal wave mixing in ocean models has been relatively crude (e.g. Mellor, 1989; Large et al., 1994; Meier, 2001; Axell, 2002; St. Laurent and Garrett, 2002).
+% the most critical process not reproduced by statistical turbulence models is the activity of 
+% internal waves and their interaction with turbulence. After the Reynolds decomposition, 
+% internal waves are in principle included in the RANS equations, but later partially 
+% excluded by the hydrostatic assumption and the model resolution. 
+% Thus far, the representation of internal wave mixing in ocean models has been relatively crude 
+% (e.g. Mellor, 1989; Large et al., 1994; Meier, 2001; Axell, 2002; St. Laurent and Garrett, 2002).
 
 
@@ -586,5 +622,6 @@
 Options are defined through the  \ngn{namzdf\_kpp} namelist variables.
 
-\colorbox{yellow}{Add a description of KPP here.}
+Note that KPP is an obsolescent feature of the \NEMO system. 
+It will be removed in the next release (v3.7 and followings).
 
 
@@ -636,5 +673,5 @@
 
 Options are defined through the  \ngn{namzdf} namelist variables.
-The non-penetrative convective adjustment is used when \np{ln\_zdfnpc}=true. 
+The non-penetrative convective adjustment is used when \np{ln\_zdfnpc}~=~\textit{true}. 
 It is applied at each \np{nn\_npc} time step and mixes downwards instantaneously 
 the statically unstable portion of the water column, but only until the density 
@@ -644,5 +681,5 @@
 (Fig. \ref{Fig_npc}): starting from the top of the ocean, the first instability is 
 found. Assume in the following that the instability is located between levels 
-$k$ and $k+1$. The potential temperature and salinity in the two levels are 
+$k$ and $k+1$. The temperature and salinity in the two levels are 
 vertically mixed, conserving the heat and salt contents of the water column. 
 The new density is then computed by a linear approximation. If the new 
@@ -664,24 +701,14 @@
 \citep{Madec_al_JPO91, Madec_al_DAO91, Madec_Crepon_Bk91}.
 
-Note that in the current implementation of this algorithm presents several 
-limitations. First, potential density referenced to the sea surface is used to 
-check whether the density profile is stable or not. This is a strong 
-simplification which leads to large errors for realistic ocean simulations. 
-Indeed, many water masses of the world ocean, especially Antarctic Bottom
-Water, are unstable when represented in surface-referenced potential density. 
-The scheme will erroneously mix them up. Second, the mixing of potential 
-density is assumed to be linear. This assures the convergence of the algorithm 
-even when the equation of state is non-linear. Small static instabilities can thus 
-persist due to cabbeling: they will be treated at the next time step. 
-Third, temperature and salinity, and thus density, are mixed, but the 
-corresponding velocity fields remain unchanged. When using a Richardson 
-Number dependent eddy viscosity, the mixing of momentum is done through 
-the vertical diffusion: after a static adjustment, the Richardson Number is zero 
-and thus the eddy viscosity coefficient is at a maximum. When this convective 
-adjustment algorithm is used with constant vertical eddy viscosity, spurious 
-solutions can occur since the vertical momentum diffusion remains small even 
-after a static adjustment. In that case, we recommend the addition of momentum 
-mixing in a manner that mimics the mixing in temperature and salinity 
-\citep{Speich_PhD92, Speich_al_JPO96}.
+The current implementation has been modified in order to deal with any non linear 
+equation of seawater (L. Brodeau, personnal communication). 
+Two main differences have been introduced compared to the original algorithm: 
+$(i)$ the stability is now checked using the Brunt-V\"{a}is\"{a}l\"{a} frequency 
+(not the the difference in potential density) ; 
+$(ii)$ when two levels are found unstable, their thermal and haline expansion coefficients 
+are vertically mixed in the same way their temperature and salinity has been mixed.
+These two modifications allow the algorithm to perform properly and accurately 
+with TEOS10 or EOS-80 without having to recompute the expansion coefficients at each 
+mixing iteration.
 
 % -------------------------------------------------------------------------------------------------------------
@@ -689,5 +716,5 @@
 % -------------------------------------------------------------------------------------------------------------
 \subsection   [Enhanced Vertical Diffusion (\np{ln\_zdfevd})]
-			{Enhanced Vertical Diffusion (\np{ln\_zdfevd}=true)}
+		     	  {Enhanced Vertical Diffusion (\np{ln\_zdfevd}=true)}
 \label{ZDF_evd}
 
@@ -830,5 +857,5 @@
 % Bottom Friction
 % ================================================================
-\section  [Bottom and top Friction (\textit{zdfbfr})]   {Bottom Friction (\mdl{zdfbfr} module)}
+\section  [Bottom and Top Friction (\textit{zdfbfr})]   {Bottom and Top Friction (\mdl{zdfbfr} module)}
 \label{ZDF_bfr}
 
@@ -838,6 +865,8 @@
 
 Options to define the top and bottom friction are defined through the  \ngn{nambfr} namelist variables.
-The top friction is activated only if the ice shelf cavities are opened (\np{ln\_isfcav}~=~true).
-As the friction processes at the top and bottom are the represented similarly, only the bottom friction is described in detail.
+The bottom friction represents the friction generated by the bathymetry. 
+The top friction represents the friction generated by the ice shelf/ocean interface. 
+As the friction processes at the top and bottom are represented similarly, only the bottom friction is described in detail below.\\
+
 
 Both the surface momentum flux (wind stress) and the bottom momentum 
@@ -912,5 +941,5 @@
 $H = 4000$~m, the resulting friction coefficient is $r = 4\;10^{-4}$~m\;s$^{-1}$. 
 This is the default value used in \NEMO. It corresponds to a decay time scale 
-of 115~days. It can be changed by specifying \np{rn\_bfric1} (namelist parameter).
+of 115~days. It can be changed by specifying \np{rn\_bfri1} (namelist parameter).
 
 For the linear friction case the coefficients defined in the general 
@@ -922,5 +951,5 @@
 \end{split}
 \end{equation}
-When \np{nn\_botfr}=1, the value of $r$ used is \np{rn\_bfric1}. 
+When \np{nn\_botfr}=1, the value of $r$ used is \np{rn\_bfri1}. 
 Setting \np{nn\_botfr}=0 is equivalent to setting $r=0$ and leads to a free-slip 
 bottom boundary condition. These values are assigned in \mdl{zdfbfr}. 
@@ -929,5 +958,5 @@
 in the \ifile{bfr\_coef} input NetCDF file. The mask values should vary from 0 to 1. 
 Locations with a non-zero mask value will have the friction coefficient increased 
-by $mask\_value$*\np{rn\_bfrien}*\np{rn\_bfric1}.
+by $mask\_value$*\np{rn\_bfrien}*\np{rn\_bfri1}.
 
 % -------------------------------------------------------------------------------------------------------------
@@ -949,5 +978,5 @@
 $e_b = 2.5\;10^{-3}$m$^2$\;s$^{-2}$, while the FRAM experiment \citep{Killworth1992} 
 uses $C_D = 1.4\;10^{-3}$ and $e_b =2.5\;\;10^{-3}$m$^2$\;s$^{-2}$. 
-The CME choices have been set as default values (\np{rn\_bfric2} and \np{rn\_bfeb2} 
+The CME choices have been set as default values (\np{rn\_bfri2} and \np{rn\_bfeb2} 
 namelist parameters).
 
@@ -964,10 +993,41 @@
 \end{equation}
 
-The coefficients that control the strength of the non-linear bottom friction are 
-initialised as namelist parameters: $C_D$= \np{rn\_bfri2}, and $e_b$ =\np{rn\_bfeb2}. 
-Note for applications which treat tides explicitly a low or even zero value of 
-\np{rn\_bfeb2} is recommended. From v3.2 onwards a local enhancement of $C_D$ 
-is possible via an externally defined 2D mask array (\np{ln\_bfr2d}=true). 
-See previous section for details.
+The coefficients that control the strength of the non-linear bottom friction are
+initialised as namelist parameters: $C_D$= \np{rn\_bfri2}, and $e_b$ =\np{rn\_bfeb2}.
+Note for applications which treat tides explicitly a low or even zero value of
+\np{rn\_bfeb2} is recommended. From v3.2 onwards a local enhancement of $C_D$ is possible
+via an externally defined 2D mask array (\np{ln\_bfr2d}=true).  This works in the same way
+as for the linear bottom friction case with non-zero masked locations increased by
+$mask\_value$*\np{rn\_bfrien}*\np{rn\_bfri2}.
+
+% -------------------------------------------------------------------------------------------------------------
+%       Bottom Friction Log-layer
+% -------------------------------------------------------------------------------------------------------------
+\subsection{Log-layer Bottom Friction enhancement (\np{nn\_botfr} = 2, \np{ln\_loglayer} = .true.)}
+\label{ZDF_bfr_loglayer}
+
+In the non-linear bottom friction case, the drag coefficient, $C_D$, can be optionally
+enhanced using a "law of the wall" scaling. If  \np{ln\_loglayer} = .true., $C_D$ is no
+longer constant but is related to the thickness of the last wet layer in each column by:
+
+\begin{equation}
+C_D = \left ( {\kappa \over {\rm log}\left ( 0.5e_{3t}/rn\_bfrz0 \right ) } \right )^2
+\end{equation}
+
+\noindent where $\kappa$ is the von-Karman constant and \np{rn\_bfrz0} is a roughness
+length provided via the namelist.
+
+For stability, the drag coefficient is bounded such that it is kept greater or equal to
+the base \np{rn\_bfri2} value and it is not allowed to exceed the value of an additional
+namelist parameter: \np{rn\_bfri2\_max}, i.e.:
+
+\begin{equation}
+rn\_bfri2 \leq C_D \leq rn\_bfri2\_max
+\end{equation}
+
+\noindent Note also that a log-layer enhancement can also be applied to the top boundary
+friction if under ice-shelf cavities are in use (\np{ln\_isfcav}=.true.).  In this case, the
+relevant namelist parameters are \np{rn\_tfrz0}, \np{rn\_tfri2}
+and \np{rn\_tfri2\_max}.
 
 % -------------------------------------------------------------------------------------------------------------
@@ -1253,2 +1313,58 @@
 
 % ================================================================
+% Internal wave-driven mixing
+% ================================================================
+\section{Internal wave-driven mixing (\key{zdftmx\_new})}
+\label{ZDF_tmx_new}
+
+%--------------------------------------------namzdf_tmx_new------------------------------------------
+\namdisplay{namzdf_tmx_new}
+%--------------------------------------------------------------------------------------------------------------
+
+The parameterization of mixing induced by breaking internal waves is a generalization 
+of the approach originally proposed by \citet{St_Laurent_al_GRL02}. 
+A three-dimensional field of internal wave energy dissipation $\epsilon(x,y,z)$ is first constructed, 
+and the resulting diffusivity is obtained as 
+\begin{equation} \label{Eq_Kwave}
+A^{vT}_{wave} =  R_f \,\frac{ \epsilon }{ \rho \, N^2 }
+\end{equation}
+where $R_f$ is the mixing efficiency and $\epsilon$ is a specified three dimensional distribution 
+of the energy available for mixing. If the \np{ln\_mevar} namelist parameter is set to false, 
+the mixing efficiency is taken as constant and equal to 1/6 \citep{Osborn_JPO80}. 
+In the opposite (recommended) case, $R_f$ is instead a function of the turbulence intensity parameter 
+$Re_b = \frac{ \epsilon}{\nu \, N^2}$, with $\nu$ the molecular viscosity of seawater, 
+following the model of \cite{Bouffard_Boegman_DAO2013} 
+and the implementation of \cite{de_lavergne_JPO2016_efficiency}.
+Note that $A^{vT}_{wave}$ is bounded by $10^{-2}\,m^2/s$, a limit that is often reached when the mixing efficiency is constant.
+
+In addition to the mixing efficiency, the ratio of salt to heat diffusivities can chosen to vary 
+as a function of $Re_b$ by setting the \np{ln\_tsdiff} parameter to true, a recommended choice). 
+This parameterization of differential mixing, due to \cite{Jackson_Rehmann_JPO2014}, 
+is implemented as in \cite{de_lavergne_JPO2016_efficiency}.
+
+The three-dimensional distribution of the energy available for mixing, $\epsilon(i,j,k)$, is constructed 
+from three static maps of column-integrated internal wave energy dissipation, $E_{cri}(i,j)$, 
+$E_{pyc}(i,j)$, and $E_{bot}(i,j)$, combined to three corresponding vertical structures 
+(de Lavergne et al., in prep):
+\begin{align*}
+F_{cri}(i,j,k) &\propto e^{-h_{ab} / h_{cri} }\\
+F_{pyc}(i,j,k) &\propto N^{n\_p}\\
+F_{bot}(i,j,k) &\propto N^2 \, e^{- h_{wkb} / h_{bot} }
+\end{align*} 
+In the above formula, $h_{ab}$ denotes the height above bottom, 
+$h_{wkb}$ denotes the WKB-stretched height above bottom, defined by
+\begin{equation*}
+h_{wkb} = H \, \frac{ \int_{-H}^{z} N \, dz' } { \int_{-H}^{\eta} N \, dz'  } \; ,
+\end{equation*}
+The $n_p$ parameter (given by \np{nn\_zpyc} in \ngn{namzdf\_tmx\_new} namelist)  controls the stratification-dependence of the pycnocline-intensified dissipation. 
+It can take values of 1 (recommended) or 2.
+Finally, the vertical structures $F_{cri}$ and $F_{bot}$ require the specification of 
+the decay scales $h_{cri}(i,j)$ and $h_{bot}(i,j)$, which are defined by two additional input maps. 
+$h_{cri}$ is related to the large-scale topography of the ocean (etopo2) 
+and $h_{bot}$ is a function of the energy flux $E_{bot}$, the characteristic horizontal scale of 
+the abyssal hill topography \citep{Goff_JGR2010} and the latitude.
+
+% ================================================================
+
+
+
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Introduction.tex
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Introduction.tex	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Chapters/Introduction.tex	(revision 6436)
@@ -24,11 +24,10 @@
 release 8.2, described in \citet{Madec1998}. This model has been used for a wide 
 range of applications, both regional or global, as a forced ocean model and as a 
-model coupled with the atmosphere. A complete list of references is found on the 
-\NEMO web site. 
+model coupled with the sea-ice and/or the atmosphere.  
 
 This manual is organised in as follows. Chapter~\ref{PE} presents the model basics, 
 $i.e.$ the equations and their assumptions, the vertical coordinates used, and the 
 subgrid scale physics. This part deals with the continuous equations of the model 
-(primitive equations, with potential temperature, salinity and an equation of state). 
+(primitive equations, with temperature, salinity and an equation of seawater). 
 The equations are written in a curvilinear coordinate system, with a choice of vertical 
 coordinates ($z$ or $s$, with the rescaled height coordinate formulation \textit{z*}, or  
@@ -79,9 +78,10 @@
 space and time variable coefficient \citet{Treguier1997}. The model has vertical harmonic 
 viscosity and diffusion with a space and time variable coefficient, with options to compute 
-the coefficients with \citet{Blanke1993}, \citet{Large_al_RG94}, \citet{Pacanowski_Philander_JPO81}, 
+the coefficients with \citet{Blanke1993}, \citet{Pacanowski_Philander_JPO81}, 
 or \citet{Umlauf_Burchard_JMS03} mixing schemes.
  \vspace{1cm}
  
- 
+%%gm    To be put somewhere else ....
+
 \noindent CPP keys and namelists are used for inputs to the code.  \newline
 
@@ -112,4 +112,5 @@
  \vspace{1cm}
 
+%%gm  end
 
 Model outputs management and specific online diagnostics are described in chapters~\ref{DIA}.
@@ -227,5 +228,5 @@
 \item a deep re-writting and simplification of the off-line tracer component (OFF\_SRC) ; 
 \item the merge of passive and active advection and diffusion modules ;
-\item  Use of the Flexible Configuration Manager (FCM) to build configurations, generate the Makefile and produce the executable ;
+\item Use of the Flexible Configuration Manager (FCM) to build configurations, generate the Makefile and produce the executable ;
 \item Linear-tangent and Adjoint component (TAM) added, phased with v3.0
 \end{enumerate}
@@ -249,2 +250,42 @@
 
 
+ \vspace{1cm}
+$\bullet$ The main modifications from NEMO/OPA v3.4 and  v3.6 are :\\
+\begin{enumerate}
+\item I/O management: NEMO in now interfaced with XIOS, a Input/Output server having a versatile xml user interface, and 
+allowing I/O to be performed on dedicated processors thus improving scalability and performance on massively parallel platforms. 
+\item ICB module \citep{Marsh_GMD2015}: icebergs as lagrangian floats ; 
+\item SAS: Stand Alone Surface module allowing testing of forcing set with bulk formulae, to run sea-ice models without ocean, to run ICB icebergs module alone, and to test AGRIF with sea-ice
+\item ISF : Under ice-selves cavities (parametrisation and/or explicit representation)
+\item Coupled interface for next IPCC requirements (multi category sea-ice, calving and iceberg module)
+\item Ocean and ice allowed to be explicitly coupled through OASIS, using StandAlone Surface module)
+\item On line coarsening of ocean I/O
+\item Major evolution of LIM3 sea-ice model \citep{Rousset_GMD2015}
+\item Open boundaries: completion of BDY/OBC merge : BDY is now the only Open boundary module available
+\item re-visit of the specification of heat/salt(tracers)/mass fluxes ;
+\item levitating or fully embedded sea-ice (for LIM and CICE) ;
+\item a new parameterization of mixing induced by breaking internal waves (de Lavergne et al. in prep.)
+And also:
+\item update of AGRIF package and AGRIF compatibility with LIM2 sea-ice model ;
+\item A new vertical sigma coordinate stretching function \citep{Siddorn_Furner_OM12} ;
+\item Smagorinsky eddy coefficients: the \cite{Griffies_Hallberg_MWR00} Smagorinsky type diffusivity/viscosity for lateral mixing has been introduced ;
+\item Standard Fox Kemper parametrisation
+\item Analytical tropical cyclones taken in account using track and magnitude observations (Vincent et al. JGR 2012a,b) ;
+\item OBS: observation operators improved and now available in Standalone mode ;
+\item Log layer option for bottom friction
+\item Faster split-explicit time stepping ; 
+\item Z-tilde ALE coordinates \citep{Leclair_Madec_OM11} ; 
+\item implicit bottom friction ;
+\item Runoff improved and SBC with BGC
+\item MPP assessment and optimisation
+\item First steps of wave coupling
+
+Features becoming obsolete: LIM2 (replaced by LIM3 monocategory) ; IOIPSL (replaced by XIOS) ; 
+
+Features that has been removed : LOBSTER (now included in PISCES) ; OBC, replaced by BDY ;   
+
+
+
+\end{enumerate}
+
+
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_asminc
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_asminc	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_asminc	(revision 6436)
@@ -0,0 +1,18 @@
+!-----------------------------------------------------------------------
+&nam_asminc   !   assimilation increments                               ('key_asminc')
+!-----------------------------------------------------------------------
+    ln_bkgwri = .false.    !  Logical switch for writing out background state
+    ln_trainc = .false.    !  Logical switch for applying tracer increments
+    ln_dyninc = .false.    !  Logical switch for applying velocity increments
+    ln_sshinc = .false.    !  Logical switch for applying SSH increments
+    ln_asmdin = .false.    !  Logical switch for Direct Initialization (DI)
+    ln_asmiau = .false.    !  Logical switch for Incremental Analysis Updating (IAU)
+    nitbkg    = 0          !  Timestep of background in [0,nitend-nit000-1]
+    nitdin    = 0          !  Timestep of background for DI in [0,nitend-nit000-1]
+    nitiaustr = 1          !  Timestep of start of IAU interval in [0,nitend-nit000-1]
+    nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
+    niaufn    = 0          !  Type of IAU weighting function
+    ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
+    salfixmin = -9999      !  Minimum salinity after applying the increments
+    nn_divdmp = 0          !  Number of iterations of divergence damping operator
+/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_diaharm
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_diaharm	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_diaharm	(revision 6436)
@@ -0,0 +1,9 @@
+!-----------------------------------------------------------------------
+&nam_diaharm   !   Harmonic analysis of tidal constituents ('key_diaharm')
+!-----------------------------------------------------------------------
+    nit000_han = 1         ! First time step used for harmonic analysis
+    nitend_han = 75        ! Last time step used for harmonic analysis
+    nstep_han  = 15        ! Time step frequency for harmonic analysis
+    tname(1)   = 'M2'      ! Name of tidal constituents
+    tname(2)   = 'K1'
+/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_tide
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_tide	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_tide	(revision 6436)
@@ -3,14 +3,6 @@
 !-----------------------------------------------------------------------
    ln_tide_pot   = .true.   !  use tidal potential forcing
-   clname(1)     =   'M2'   !  name of constituent
-   clname(2)     =   'S2'
-   clname(3)     =   'N2'
-   clname(4)     =   'K1'
-   clname(5)     =   'O1'
-   clname(6)     =   'Q1'
-   clname(7)     =   'M4'
-   clname(8)     =   'K2'
-   clname(9)     =   'P1'
-   clname(10)    =   'Mf'
-   clname(11)    =   'Mm'
+   ln_tide_ramp  = .false.  !
+   rdttideramp   =    0.    !
+   clname(1)     = 'DUMMY'  !  name of constituent - all tidal components must be set in namelist_cfg
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_vvl
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_vvl	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nam_vvl	(revision 6436)
@@ -0,0 +1,14 @@
+!-----------------------------------------------------------------------
+&nam_vvl    !   vertical coordinate options
+!-----------------------------------------------------------------------
+   ln_vvl_zstar  = .true.           !  zstar vertical coordinate
+   ln_vvl_ztilde = .false.          !  ztilde vertical coordinate: only high frequency variations
+   ln_vvl_layer  = .false.          !  full layer vertical coordinate
+   ln_vvl_ztilde_as_zstar = .false. !  ztilde vertical coordinate emulating zstar
+   ln_vvl_zstar_at_eqtor = .false.  !  ztilde near the equator
+   rn_ahe3       = 0.0e0            !  thickness diffusion coefficient
+   rn_rst_e3t    = 30.e0            !  ztilde to zstar restoration timescale [days]
+   rn_lf_cutoff  = 5.0e0            !  cutoff frequency for low-pass filter  [days]
+   rn_zdef_max   = 0.9e0            !  maximum fractional e3t deformation
+   ln_vvl_dbg    = .true.           !  debug prints    (T/F)
+/
Index: anches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namasm
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namasm	(revision 6435)
+++ 	(revision )
@@ -1,18 +1,0 @@
-!-----------------------------------------------------------------------
-&nam_asminc   !   assimilation increments                               ('key_asminc')
-!-----------------------------------------------------------------------
-    ln_bkgwri = .false.    !  Logical switch for writing out background state
-    ln_trainc = .false.    !  Logical switch for applying tracer increments
-    ln_dyninc = .false.    !  Logical switch for applying velocity increments
-    ln_sshinc = .false.    !  Logical switch for applying SSH increments
-    ln_asmdin = .false.    !  Logical switch for Direct Initialization (DI)
-    ln_asmiau = .false.    !  Logical switch for Incremental Analysis Updating (IAU)
-    nitbkg    = 0          !  Timestep of background in [0,nitend-nit000-1]
-    nitdin    = 0          !  Timestep of background for DI in [0,nitend-nit000-1]
-    nitiaustr = 1          !  Timestep of start of IAU interval in [0,nitend-nit000-1]
-    nitiaufin = 15         !  Timestep of end of IAU interval in [0,nitend-nit000-1]
-    niaufn    = 0          !  Type of IAU weighting function
-    ln_salfix = .false.    !  Logical switch for ensuring that the sa > salfixmin
-    salfixmin = -9999      !  Minimum salinity after applying the increments
-    nn_divdmp = 0          !  Number of iterations of divergence damping operator
-/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambbc
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambbc	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambbc	(revision 6436)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+!              !                              !  (if <0  months)  !  
+!              !  file name      ! frequency (hours) ! variable   ! time interp.   !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                 !  (if <0  months)  !   name     !   (logical)    !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_qgh      ='geothermal_heating.nc',  -12.  , 'heatflow'      ,   .false.      , .true.  , 'yearly'  , ''       , ''       , ''
+   !
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_trabbc   = .true.    !  Apply a geothermal heating at the ocean bottom
+   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux
+                           !     = 1 constant flux
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2)
+   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
+
+/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy	(revision 6436)
@@ -2,22 +2,34 @@
 &nambdy        !  unstructured open boundaries                          ("key_bdy")
 !-----------------------------------------------------------------------
-    nb_bdy = 1                            !  number of open boundary sets
-    ln_coords_file = .true.               !  =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.)
-    nn_dyn2d      =  2                    !  boundary conditions for barotropic fields
-    nn_dyn2d_dta  =  3                    !  = 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
-    nn_dyn3d      =  0                    !  boundary conditions for baroclinic velocities
-    nn_dyn3d_dta  =  0                    !  = 0, bdy data are equal to the initial state
-                           !  = 1, bdy data are read in 'bdydata   .nc' files
-    nn_tra        =  1                    !  boundary conditions for T and S
-    nn_tra_dta    =  1                    !  = 0, bdy data are equal to the initial state
-                           !  = 1, bdy data are read in 'bdydata   .nc' files
-    nn_rimwidth  = 10                      !  width of the relaxation zone
-    ln_vol     = .false.                  !  total volume correction (see nn_volctl parameter)
-    nn_volctl  = 1                        !  = 0, the total water flux across open boundaries is zero
+    nb_bdy = 2                               !  number of open boundary sets       
+    ln_coords_file = .true.,.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       = 'none','none'           !
+    nn_dyn2d      =  2, 0                    !  boundary conditions for barotropic fields
+    nn_dyn2d_dta  =  3, 0                    !  = 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',' none'          !
+    nn_dyn3d      =  0, 0                    !  boundary conditions for baroclinic velocities
+    nn_dyn3d_dta  =  0, 0                    !  = 0, bdy data are equal to the initial state
+                                             !  = 1, bdy data are read in 'bdydata   .nc' files
+    cn_tra        =  'none', 'none'          !
+    nn_tra_dta    =  1, 1                    !  = 0, bdy data are equal to the initial state
+                                             !  = 1, bdy data are read in 'bdydata   .nc' files
+    cn_ice_lim      =  'none','none'         !
+    nn_ice_lim_dta  =  0, 0                  !  = 0, bdy data are equal to the initial state
+                                             !  = 1, bdy data are read in 'bdydata   .nc' files
+    rn_ice_tem      = 270., 270.             !  lim3 only: arbitrary temperature of incoming sea ice
+    rn_ice_sal      = 10.,  10.              !  lim3 only:      --   salinity           --
+    rn_ice_age      = 30., 30.               !  lim3 only:      --   age                --
+    ln_tra_dmp    = .false.,.false.          !  open boudaries conditions for tracers
+    ln_dyn3d_dmp  = .false.,.false.          !  open boundary condition for baroclinic velocities
+    rn_time_dmp   =  1., 1.                  ! Damping time scale in days
+    rn_time_dmp_out =  1., 1.                ! Outflow damping time scale
+    nn_rimwidth  = 10, 5                     !  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
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy_dta
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy_dta	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy_dta	(revision 6436)
@@ -2,13 +2,21 @@
 &nambdy_dta      !  open boundaries - external data           ("key_bdy")
 !-----------------------------------------------------------------------
-!              !   file name    ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-!              !                !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
-   bn_ssh =     'amm12_bdyT_u2d' ,         24        , 'sossheig' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''    , ''
-   bn_u2d =     'amm12_bdyU_u2d' ,         24        , 'vobtcrtx' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''    , ''
-   bn_v2d =     'amm12_bdyV_u2d' ,         24        , 'vobtcrty' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''    , ''
-   bn_u3d  =    'amm12_bdyU_u3d' ,         24        , 'vozocrtx' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''    , ''
-   bn_v3d  =    'amm12_bdyV_u3d' ,         24        , 'vomecrty' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''    , ''
-   bn_tem  =    'amm12_bdyT_tra' ,         24        , 'votemper' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''    , ''
-   bn_sal  =    'amm12_bdyT_tra' ,         24        , 'vosaline' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''    , ''
+!              !  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 =     'amm12_bdyT_u2d' ,         24        , 'sossheig' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+   bn_u2d =     'amm12_bdyU_u2d' ,         24        , 'vobtcrtx' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+   bn_v2d =     'amm12_bdyV_u2d' ,         24        , 'vobtcrty' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+   bn_u3d  =    'amm12_bdyU_u3d' ,         24        , 'vozocrtx' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+   bn_v3d  =    'amm12_bdyV_u3d' ,         24        , 'vomecrty' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+   bn_tem  =    'amm12_bdyT_tra' ,         24        , 'votemper' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+   bn_sal  =    'amm12_bdyT_tra' ,         24        , 'vosaline' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+! for lim2
+!   bn_frld  =    'amm12_bdyT_ice' ,         24        , 'ileadfra' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+!   bn_hicif =    'amm12_bdyT_ice' ,         24        , 'iicethic' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+!   bn_hsnif =    'amm12_bdyT_ice' ,         24        , 'isnowthi' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+! for lim3
+!   bn_a_i  =    'amm12_bdyT_ice' ,         24        , 'ileadfra' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+!   bn_ht_i =    'amm12_bdyT_ice' ,         24        , 'iicethic' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
+!   bn_ht_s =    'amm12_bdyT_ice' ,         24        , 'isnowthi' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''     , ''
    cn_dir  =    'bdydta/'
    ln_full_vel = .false.
Index: anches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy_dta2
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy_dta2	(revision 6435)
+++ 	(revision )
@@ -1,10 +1,0 @@
-!-----------------------------------------------------------------------
-&nambdy_dta      !  open boundaries - external data           ("key_bdy")
-!-----------------------------------------------------------------------
-!              !   file name    ! frequency (hours) !  variable  ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-!              !                !  (if <0  months)  !    name    !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
-   bn_tem  =    'amm12_bdyT_clim' ,         -1        , 'votemper' ,     .true.     , .true. ,  'daily'  ,    ''    ,   ''    , ''
-   bn_sal  =    'amm12_bdyT_clim' ,         -1        , 'vosaline' ,     .true.     , .true. ,  'daily'  ,    ''    ,   ''    , ''
-   cn_dir  =    'bdydta/'
-   ln_full_vel = .false.
-/
Index: anches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy_index
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nambdy_index	(revision 6435)
+++ 	(revision )
@@ -1,17 +1,0 @@
-!-----------------------------------------------------------------------
-&nambdy_index    !  open boundaries - definition           ("key_bdy")
-!-----------------------------------------------------------------------
-    nbdysege = 0
-    nbdysegw = 1
-    jpiwob = 2
-    jpjwdt = 2
-    jpjwft = 191
-    nbdysegn = 1
-    jpjnob = 191
-    jpindt = 2
-    jpinft = 146
-    nbdysegs = 1
-    jpjsob = 2
-    jpisdt = 2
-    jpisft = 43
-/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namberg
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namberg	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namberg	(revision 6436)
@@ -9,8 +9,8 @@
                                                       ! Initial mass required for an iceberg of each class
       rn_initial_mass          = 8.8e7, 4.1e8, 3.3e9, 1.8e10, 3.8e10, 7.5e10, 1.2e11, 2.2e11, 3.9e11, 7.4e11
-                                                      ! Proportion of calving mass to apportion to each class  
+                                                      ! Proportion of calving mass to apportion to each class
       rn_distribution          = 0.24, 0.12, 0.15, 0.18, 0.12, 0.07, 0.03, 0.03, 0.03, 0.02
                                                       ! Ratio between effective and real iceberg mass (non-dim)
-                                                      ! i.e. number of icebergs represented at a point         
+                                                      ! i.e. number of icebergs represented at a point
       rn_mass_scaling          = 2000, 200, 50, 20, 10, 5, 2, 1, 1, 1
                                                       ! thickness of newly calved bergs (m)
@@ -21,14 +21,14 @@
       rn_bits_erosion_fraction = 0.                   ! Fraction of erosion melt flux to divert to bergy bits
       rn_sicn_shift            = 0.                   ! Shift of sea-ice concn in erosion flux (0<sicn_shift<1)
-      ln_passive_mode          = .false.              ! iceberg - ocean decoupling   
+      ln_passive_mode          = .false.              ! iceberg - ocean decoupling
       nn_test_icebergs         =  10                  ! Create test icebergs of this class (-1 = no)
                                                       ! Put a test iceberg at each gridpoint in box (lon1,lon2,lat1,lat2)
       rn_test_box              = 108.0,  116.0, -66.0, -58.0
-      rn_speed_limit           = 0.                   ! CFL speed limit for a berg   
+      rn_speed_limit           = 0.                   ! CFL speed limit for a berg
 
-               ! filename ! freq (hours) ! variable ! time interp. ! clim  !'yearly' or ! weights  ! rotation ! land/sea mask !
-               !          ! (<0  months) !   name   !  (logical)   ! (T/F) ! 'monthly'  ! filename ! pairing  ! filename      !
-      sn_icb =  'calving' ,     -1       , 'calvingmask',  .true.      , .true., 'yearly'   , ' '      , ' '  , ''
-   
-      cn_dir = './' 
+!              ! file name ! frequency (hours) !   variable   ! time interp.   !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !           !  (if <0  months)  !     name     !   (logical)    !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+      sn_icb =  'calving' ,       -1           , 'calvingmask',  .true.        , .true.  , 'yearly'  , ''       , ''       , ''
+
+      cn_dir = './'
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namc1d
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namc1d	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namc1d	(revision 6436)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&namc1d        !   1D configuration options                             ("key_c1d")
+!-----------------------------------------------------------------------
+   rn_lat1d    =      50   !  Column latitude (default at PAPA station)
+   rn_lon1d    =    -145   !  Column longitude (default at PAPA station)
+   ln_c1d_locpt=  .true.   ! Localization of 1D config in a grid (T) or independant point (F)
+/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namc1d_dyndmp
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namc1d_dyndmp	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namc1d_dyndmp	(revision 6436)
@@ -0,0 +1,5 @@
+!-----------------------------------------------------------------------
+&namc1d_dyndmp !   U & V newtonian damping                              ("key_c1d")
+!-----------------------------------------------------------------------
+   ln_dyndmp   =  .false.  !  add a damping term (T) or not (F)
+/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namc1d_uvd
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namc1d_uvd	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namc1d_uvd	(revision 6436)
@@ -0,0 +1,12 @@
+!-----------------------------------------------------------------------
+&namc1d_uvd    !   data: U & V currents                                 ("key_c1d")
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_ucur     = 'ucurrent'  ,         -1        ,'u_current',   .false.    , .true. , 'monthly' ,  ''      ,  'Ume'   , ''
+   sn_vcur     = 'vcurrent'  ,         -1        ,'v_current',   .false.    , .true. , 'monthly' ,  ''      ,  'Vme'   , ''
+!
+   cn_dir        = './'    !  root directory for the location of the files
+   ln_uvd_init   = .false. !  Initialisation of ocean U & V with U & V input data (T) or not (F)
+   ln_uvd_dyndmp = .false. !  damping of ocean U & V toward U & V input data (T) or not (F)
+/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namcfg
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namcfg	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namcfg	(revision 6436)
@@ -0,0 +1,22 @@
+!-----------------------------------------------------------------------
+&namcfg     !   parameters of the configuration
+!-----------------------------------------------------------------------
+   cp_cfg      =  "default"            !  name of the configuration
+   cp_cfz      =  "no zoom"            !  name of the zoom of configuration
+   jp_cfg      =       0               !  resolution of the configuration
+   jpidta      =      10               !  1st lateral dimension ( >= jpi )
+   jpjdta      =      12               !  2nd    "         "    ( >= jpj )
+   jpkdta      =      31               !  number of levels      ( >= jpk )
+   jpiglo      =      10               !  1st dimension of global domain --> i =jpidta
+   jpjglo      =      12               !  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)
+                                       !  = 0 closed                 ;   = 1 cyclic East-West
+                                       !  = 2 equatorial symmetric   ;   = 3 North fold T-point pivot
+                                       !  = 4 cyclic East-West AND North fold T-point pivot
+                                       !  = 5 North fold F-point pivot
+                                       !  = 6 cyclic East-West AND North fold F-point pivot
+   ln_use_jattr = .false.              !  use (T) the file attribute: open_ocean_jstart, if present
+                                       !  in netcdf input files, as the start j-row for reading
+/
Index: anches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namcfg_orca1
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namcfg_orca1	(revision 6435)
+++ 	(revision )
@@ -1,12 +1,0 @@
-!-----------------------------------------------------------------------
-&namcfg        !   parameters of the configuration
-!-----------------------------------------------------------------------
-   cp_cfg      =  "orca"               !  name of the configuration
-   jp_cfg      =       1               !  resolution of the configuration
-   jpidta      =     362               !  1st lateral dimension ( >= jpi )
-   jpjdta      =     292               !  2nd    "         "    ( >= jpj )
-   jpkdta      =      75               !  number of levels      ( >= jpk )
-   jpiglo      =     362               !  1st dimension of global domain --> i =jpidta
-   jpjglo      =     292               !  2nd    -                  -    --> j  =jpjdta
-   jperio      =       6               !  lateral cond. type (between 0 and 6)
-   ln_use_jattr = .true.               !  use (T) the file attribute: open_ocean_jstart if present
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namcrs
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namcrs	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namcrs	(revision 6436)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+&namcrs        !   Grid coarsening for dynamics output and/or
+               !   passive tracer coarsened online simulations
+!-----------------------------------------------------------------------
+   nn_factx    = 3         !  Reduction factor of x-direction
+   nn_facty    = 3         !  Reduction factor of y-direction
+   nn_binref   = 0         !  Bin centering preference: NORTH or EQUAT
+                           !  0, coarse grid is binned with preferential treatment of the north fold
+                           !  1, coarse grid is binned with centering at the equator
+                           !    Symmetry with nn_facty being odd-numbered. Asymmetry with even-numbered nn_facty.
+   nn_msh_crs  = 1         !  create (=1) a mesh file or not (=0)
+   nn_crs_kz   = 0         ! 0, MEAN of volume boxes
+                           ! 1, MAX of boxes
+                           ! 2, MIN of boxes
+   ln_crs_wn   = .true.    ! wn coarsened (T) or computed using horizontal divergence ( F )
+/
Index: anches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdia_harm
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdia_harm	(revision 6435)
+++ 	(revision )
@@ -1,9 +1,0 @@
-!-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents ('key_diaharm')
-!-----------------------------------------------------------------------
-    nit000_han = 1         ! First time step used for harmonic analysis
-    nitend_han = 75        ! Last time step used for harmonic analysis
-    nstep_han  = 15        ! Time step frequency for harmonic analysis
-    tname(1)   = 'M2'      ! Name of tidal constituents
-    tname(2)   = 'K1'
-/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdom
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdom	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdom	(revision 6436)
@@ -3,6 +3,7 @@
 !-----------------------------------------------------------------------
    nn_bathy    =    1      !  compute (=0) or read (=1) the bathymetry file
-   nn_closea    =   0      !  remove (=0) or keep (=1) closed seas and lakes (ORCA)
-   nn_msh      =    0      !  create (=1) a mesh file or not (=0)
+   rn_bathy    =    0.     !  value of the bathymetry. if (=0) bottom flat at jpkm1
+   nn_closea   =    0      !  remove (=0) or keep (=1) closed seas and lakes (ORCA)
+   nn_msh      =    1      !  create (=1) a mesh file or not (=0)
    rn_hmin     =   -3.     !  min depth of the ocean (>0) or min number of ocean level (<0)
    rn_e3zps_min=   20.     !  partial step thickness is set larger than the minimum of
@@ -16,4 +17,5 @@
    rn_rdtmax   = 28800.          !  maximum time step on tracers (used if nn_acc=1)
    rn_rdth     =  800.           !  depth variation of tracer time step  (used if nn_acc=1)
+   ln_crs      = .false.      !  Logical switch for coarsening module
    jphgr_msh   =       0               !  type of horizontal mesh
                                        !  = 0 curvilinear coordinate on the sphere read in coordinate.nc
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdyn_adv
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdyn_adv	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdyn_adv	(revision 6436)
@@ -2,6 +2,8 @@
 &namdyn_adv    !   formulation of the momentum advection
 !-----------------------------------------------------------------------
-   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)  
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)
+   nn_dynkeg     = 0       ! scheme for grad(KE): =0   C2  ;  =1   Hollingsworth correction
    ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
-   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme 
-/  
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme
+   ln_dynzad_zts = .false. !  Use (T) sub timestepping for vertical momentum advection
+/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdyn_hpg
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdyn_hpg	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdyn_hpg	(revision 6436)
@@ -5,5 +5,5 @@
    ln_hpg_zps  = .true.    !  z-coordinate - partial steps (interpolation)
    ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
-   ln_hpg_isf  = .false.   !  s-coordinate (sco ) adapted to ice shelf cavity
+   ln_hpg_isf  = .false.   !  s-coordinate (sco ) adapted to isf
    ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
    ln_hpg_prj  = .false.   !  s-coordinate (Pressure Jacobian scheme)
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdyn_vor
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdyn_vor	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namdyn_vor	(revision 6436)
@@ -6,3 +6,4 @@
    ln_dynvor_mix = .false. !  mixed scheme
    ln_dynvor_een = .true.  !  energy & enstrophy scheme
+   ln_dynvor_een_old = .false.  !  energy & enstrophy scheme - original formulation
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nameos
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nameos	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nameos	(revision 6436)
@@ -2,9 +2,18 @@
 &nameos        !   ocean physical parameters
 !-----------------------------------------------------------------------
-   nn_eos      =   0       !  type of equation of state and Brunt-Vaisala frequency
-                           !     = 0, UNESCO (formulation of Jackett and McDougall (1994) and of McDougall (1987) )
-                           !     = 1, linear: rho(T)   = rau0 * ( 1.028 - ralpha * T )
-                           !     = 2, linear: rho(T,S) = rau0 * ( rbeta * S - ralpha * T )
-   rn_alpha    =   2.0e-4  !  thermal expension coefficient (nn_eos= 1 or 2)
-   rn_beta     =   7.7e-4  !  saline  expension coefficient (nn_eos= 2)
+   nn_eos      =  -1     !  type of equation of state and Brunt-Vaisala frequency
+                                 !  =-1, TEOS-10
+                                 !  = 0, EOS-80
+                                 !  = 1, S-EOS   (simplified eos)
+   ln_useCT    = .true.  ! 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)
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namhsb
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namhsb	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namhsb	(revision 6436)
@@ -1,4 +1,4 @@
 !-----------------------------------------------------------------------
-&namhsb       !  Heat and salt budgets 
+&namhsb       !  Heat and salt budgets
 !-----------------------------------------------------------------------
    ln_diahsb  = .false.    !  check the heat and salt budgets (T) or not (F)
Index: anches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nammpp_dyndist
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/nammpp_dyndist	(revision 6435)
+++ 	(revision )
@@ -1,7 +1,0 @@
-!-----------------------------------------------------------------------
-&nammpp_dyndist !   Massively Parallel Distribution for AGRIF zoom      ("key_agrif" && "key_mpp_dyndist")
-!-----------------------------------------------------------------------
-   jpni        =    1      !  jpni   number of processors following i
-   jpnj        =    1      !  jpnj   number of processors following j
-   jpnij       =    1      !  jpnij  number of local domains
-/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namobs
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namobs	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namobs	(revision 6436)
@@ -5,58 +5,52 @@
    ln_s3d     = .false.    ! Logical switch for S profile observations
    ln_ena     = .false.    ! Logical switch for ENACT insitu data set
-   !                       !     ln_cor                  Logical switch for Coriolis insitu data set
+   ln_cor     = .false.    ! Logical switch for Coriolis insitu data set
    ln_profb   = .false.    ! Logical switch for feedback insitu data set
    ln_sla     = .false.    ! Logical switch for SLA observations
-
    ln_sladt   = .false.    ! Logical switch for AVISO SLA data
-
    ln_slafb   = .false.    ! Logical switch for feedback SLA data
-                           !     ln_ssh                  Logical switch for SSH observations
-
-   ln_sst     = .true.     ! Logical switch for SST observations
-   ln_reysst  = .true.     !     ln_reysst               Logical switch for Reynolds observations
-   ln_ghrsst  = .false.    !     ln_ghrsst               Logical switch for GHRSST observations      
-
+   ln_ssh     = .false.    ! Logical switch for SSH observations
+   ln_sst     = .false.    ! Logical switch for SST observations
+   ln_reysst  = .false.    ! Logical switch for Reynolds observations
+   ln_ghrsst  = .false.    ! Logical switch for GHRSST observations
    ln_sstfb   = .false.    ! Logical switch for feedback SST data
-                           !     ln_sss                  Logical switch for SSS observations
-                           !     ln_seaice               Logical switch for Sea Ice observations
-                           !     ln_vel3d                Logical switch for velocity observations
-                           !     ln_velavcur             Logical switch for velocity daily av. cur.
-                           !     ln_velhrcur             Logical switch for velocity high freq. cur.
-                           !     ln_velavadcp            Logical switch for velocity daily av. ADCP
-                           !     ln_velhradcp            Logical switch for velocity high freq. ADCP
-                           !     ln_velfb                Logical switch for feedback velocity data
-                           !     ln_grid_global          Global distribtion of observations
-                           !     ln_grid_search_lookup   Logical switch for obs grid search w/lookup table
-                           !     grid_search_file        Grid search lookup file header
-                           !     enactfiles              ENACT input observation file names
-                           !     coriofiles              Coriolis input observation file name
-   !                       ! profbfiles: Profile feedback input observation file name
-   profbfiles = 'profiles_01.nc'
-                           !     ln_profb_enatim         Enact feedback input time setting switch
-                           !     slafilesact             Active SLA input observation file name
-                           !     slafilespas             Passive SLA input observation file name
-   !                       ! slafbfiles: Feedback SLA input observation file name
-   slafbfiles = 'sla_01.nc'
-                           !     sstfiles                GHRSST input observation file name
-   !                       ! sstfbfiles: Feedback SST input observation file name
-   sstfbfiles = 'sst_01.nc' 'sst_02.nc' 'sst_03.nc' 'sst_04.nc' 'sst_05.nc'
-                           !     seaicefiles             Sea Ice input observation file name
-                           !     velavcurfiles           Vel. cur. daily av. input file name
-                           !     velhvcurfiles           Vel. cur. high freq. input file name
-                           !     velavadcpfiles          Vel. ADCP daily av. input file name
-                           !     velhvadcpfiles          Vel. ADCP high freq. input file name
-                           !     velfbfiles              Vel. feedback input observation file name
-                           !     dobsini                 Initial date in window YYYYMMDD.HHMMSS
-                           !     dobsend                 Final date in window YYYYMMDD.HHMMSS
-                           !     n1dint                  Type of vertical interpolation method
-                           !     n2dint                  Type of horizontal interpolation method
-                           !     ln_nea                  Rejection of observations near land switch
-   nmsshc     = 0          ! MSSH correction scheme
-                           !     mdtcorr                 MDT  correction
-                           !     mdtcutoff               MDT cutoff for computed correction
+   ln_sss     = .false.    ! Logical switch for SSS observations
+   ln_seaice  = .false.    ! Logical switch for Sea Ice observations
+   ln_vel3d   = .false.    ! Logical switch for velocity observations
+   ln_velavcur= .false     ! Logical switch for velocity daily av. cur.
+   ln_velhrcur= .false     ! Logical switch for velocity high freq. cur.
+   ln_velavadcp = .false.  ! Logical switch for velocity daily av. ADCP
+   ln_velhradcp = .false.  ! Logical switch for velocity high freq. ADCP
+   ln_velfb   = .false.    ! Logical switch for feedback velocity data
+   ln_grid_global = .false. ! Global distribtion of observations
+   ln_grid_search_lookup = .false. !  Logical switch for obs grid search w/lookup table
+   grid_search_file = 'grid_search'  !  Grid search lookup file header
+! All of the *files* variables below are arrays. Use namelist_cfg to add more files
+   enactfiles = 'enact.nc' !  ENACT input observation file names (specify full array in namelist_cfg)
+   coriofiles = 'corio.nc' !  Coriolis input observation file name
+   profbfiles = 'profiles_01.nc' ! Profile feedback input observation file name
+   ln_profb_enatim = .false !        Enact feedback input time setting switch
+   slafilesact = 'sla_act.nc' !  Active SLA input observation file names
+   slafilespas = 'sla_pass.nc' ! Passive SLA input observation file names
+   slafbfiles = 'sla_01.nc' ! slafbfiles: Feedback SLA input observation file names
+   sstfiles = 'ghrsst.nc'   ! GHRSST input observation file names
+   sstfbfiles = 'sst_01.nc' ! Feedback SST input observation file names
+   seaicefiles = 'seaice_01.nc' ! Sea Ice input observation file names
+   velavcurfiles = 'velavcurfile.nc'  ! Vel. cur. daily av. input file name
+   velhrcurfiles = 'velhrcurfile.nc'  ! Vel. cur. high freq. input file name
+   velavadcpfiles = 'velavadcpfile.nc' ! Vel. ADCP daily av. input file name
+   velhradcpfiles = 'velhradcpfile.nc' ! Vel. ADCP high freq. input file name
+   velfbfiles = 'velfbfile.nc' ! Vel. feedback input observation file name
+   dobsini = 20000101.000000  !  Initial date in window YYYYMMDD.HHMMSS
+   dobsend = 20010101.000000  !  Final date in window YYYYMMDD.HHMMSS
+   n1dint = 0  !               Type of vertical interpolation method
+   n2dint = 0  !               Type of horizontal interpolation method
+   ln_nea = .false.   !        Rejection of observations near land switch
+   nmsshc     = 0     !        MSSH correction scheme
+   mdtcorr = 1.61     !        MDT  correction
+   mdtcutoff = 65.0   !        MDT cutoff for computed correction
    ln_altbias = .false.    ! Logical switch for alt bias
    ln_ignmis  = .true.     ! Logical switch for ignoring missing files
-                           !     endailyavtypes   ENACT daily average types
+   endailyavtypes = 820    ! ENACT daily average types - array (use namelist_cfg to set more values)
    ln_grid_global = .true.
    ln_grid_search_lookup = .false.
Index: anches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namobs_example
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namobs_example	(revision 6435)
+++ 	(revision )
@@ -1,63 +1,0 @@
-!-----------------------------------------------------------------------
-!       namobs    observation usage switch
-!-----------------------------------------------------------------------
-!
-!  ln_t3d                  Logical switch for T profile observations         
-!  ln_s3d                  Logical switch for S profile observations          
-!  ln_ena                  Logical switch for ENACT insitu data set           
-!  ln_cor                  Logical switch for Coriolis insitu data set       
-!  ln_profb                Logical switch for feedback insitu data set     
-!  ln_sla                  Logical switch for SLA observations               
-!  ln_sladt                Logical switch for AVISO SLA data              
-!  ln_slafb                Logical switch for feedback SLA data            
-!  ln_ssh                  Logical switch for SSH observations              
-!  ln_sst                  Logical switch for SST observations              
-!  ln_reysst               Logical switch for Reynolds observations       
-!  ln_ghrsst               Logical switch for GHRSST observations          
-!  ln_sstfb                Logical switch for feedback SST data          
-!  ln_sss                  Logical switch for SSS observations              
-!  ln_seaice               Logical switch for Sea Ice observations        
-!  ln_vel3d                Logical switch for velocity observations         
-!  ln_velavcur             Logical switch for velocity daily av. cur.    
-!  ln_velhrcur             Logical switch for velocity high freq. cur.   
-!  ln_velavadcp            Logical switch for velocity daily av. ADCP  
-!  ln_velhradcp            Logical switch for velocity high freq. ADCP
-!  ln_velfb                Logical switch for feedback velocity data       
-!  ln_grid_global          Global distribtion of observations         
-!  ln_grid_search_lookup   Logical switch for obs grid search w/lookup table  
-!  grid_search_file        Grid search lookup file header 
-!  enactfiles              ENACT input observation file names 
-!  coriofiles              Coriolis input observation file name  
-!  profbfiles              Profile feedback input observation file name 
-!  ln_profb_enatim         Enact feedback input time setting switch    
-!  slafilesact             Active SLA input observation file name
-!  slafilespas             Passive SLA input observation file name 
-!  slafbfiles              Feedback SLA input observation file name 
-!  sstfiles                GHRSST input observation file name       
-!  sstfbfiles              Feedback SST input observation file name 
-!  seaicefiles             Sea Ice input observation file name 
-!  velavcurfiles           Vel. cur. daily av. input file name  
-!  velhvcurfiles           Vel. cur. high freq. input file name  
-!  velavadcpfiles          Vel. ADCP daily av. input file name    
-!  velhvadcpfiles          Vel. ADCP high freq. input file name 
-!  velfbfiles              Vel. feedback input observation file name 
-!  dobsini                 Initial date in window YYYYMMDD.HHMMSS       
-!  dobsend                 Final date in window YYYYMMDD.HHMMSS         
-!  n1dint                  Type of vertical interpolation method        
-!  n2dint                  Type of horizontal interpolation method       
-!  ln_nea                  Rejection of observations near land switch    
-!  nmsshc                  MSSH correction scheme                         
-!  mdtcorr                 MDT  correction                               
-!  mdtcutoff               MDT cutoff for computed correction          
-!  ln_altbias              Logical switch for alt bias                
-!  ln_ignmis               Logical switch for ignoring missing files   
-!  endailyavtypes          ENACT daily average types                    
- &namobs
-   ln_t3d = .true.
-   ln_s3d = .true.
-   ln_ena = .true.
-   enactfiles = 'enact.1.nc'
-   ln_grid_global = .true.
-   ln_grid_search_lookup = .true.
-   ln_ignmis = .true.  
-/ 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namptr
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namptr	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namptr	(revision 6436)
@@ -3,9 +3,4 @@
 !-----------------------------------------------------------------------
    ln_diaptr  = .false.    !  Poleward heat and salt transport (T) or not (F)
-   ln_diaznl  = .true.     !  Add zonal means and meridional stream functions
-   ln_subbas  = .true.     !  Atlantic/Pacific/Indian basins computation (T) or not
-                           !  (orca configuration only, need input basins mask file named "subbasins.nc"
-   ln_ptrcomp = .true.     !  Add decomposition : overturning
-   nn_fptr    =  1         !  Frequency of ptr computation [time step]
-   nn_fwri    =  15        !  Frequency of ptr outputs [time step]
+   ln_subbas  = .false.     !  Atlantic/Pacific/Indian basins computation (T) or not
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namrun
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namrun	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namrun	(revision 6436)
@@ -9,15 +9,21 @@
    nn_leapy    =       0   !  Leap year calendar (1) or not (0)
    ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
-   nn_rstctl   =       0   !  restart control => activated only if ln_rstart = T
+   nn_euler    =       1   !  = 0 : start with forward time step if ln_rstart=T
+   nn_rstctl   =       0   !  restart control ==> activated only if ln_rstart=T
                            !    = 0 nn_date0 read in namelist ; nn_it000 : read in namelist
                            !    = 1 nn_date0 read in namelist ; nn_it000 : check consistancy between namelist and restart
                            !    = 2 nn_date0 read in restart  ; nn_it000 : check consistancy between namelist and restart
    cn_ocerst_in  = "restart"   !  suffix of ocean restart name (input)
+   cn_ocerst_indir = "."       !  directory from which to read input ocean restarts
    cn_ocerst_out = "restart"   !  suffix of ocean restart name (output)
+   cn_ocerst_outdir = "."      !  directory in which to write output ocean restarts
    nn_istate   =       0   !  output the initial state (1) or not (0)
+   ln_rst_list = .false.   !  output restarts at list of times using nn_stocklist (T) or at set frequency with nn_stock (F)
    nn_stock    =    5475   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_stocklist = 0,0,0,0,0,0,0,0,0,0 ! List of timesteps when a restart file is to be written
    nn_write    =    5475   !  frequency of write in the output file   (modulo referenced to nn_it000)
    ln_dimgnnn  = .false.   !  DIMG file format: 1 file for all processors (F) or by processor (T)
    ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   ln_cfmeta   = .false.   !  output additional data to netCDF files required for compliance with the CF metadata standard
    ln_clobber  = .false.   !  clobber (overwrite) an existing file
    nn_chunksz  =       0   !  chunksize (bytes) for NetCDF file (works only with iom_nf90 routines)
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc	(revision 6436)
@@ -9,14 +9,19 @@
    ln_blk_core = .true.    !  CORE bulk formulation                     (T => fill namsbc_core)
    ln_blk_mfs  = .false.   !  MFS bulk formulation                      (T => fill namsbc_mfs )
-   ln_cpl      = .false.   !  Coupled formulation                       (T => fill namsbc_cpl )
+   ln_cpl      = .false.   !  atmosphere coupled   formulation          ( requires key_oasis3 )
+   ln_mixcpl   = .false.   !  forced-coupled mixed formulation          ( requires key_oasis3 )
+   nn_components = 0       !  configuration of the opa-sas OASIS coupling
+                           !  =0 no opa-sas OASIS coupling: default single executable configuration
+                           !  =1 opa-sas OASIS coupling: multi executable configuration, OPA component
+                           !  =2 opa-sas OASIS coupling: multi executable configuration, SAS component 
    ln_apr_dyn  = .false.   !  Patm gradient added in ocean & ice Eqs.   (T => fill namsbc_apr )
    nn_ice      = 2         !  =0 no ice boundary condition   ,
                            !  =1 use observed ice-cover      ,
-                           !  =2 ice-model used                         ("key_lim3" or "key_lim2)
-   nn_ice_embd = 0         !  =0 levitating ice (no mass exchange, concentration/dilution effect)
+                           !  =2 ice-model used                         ("key_lim3" or "key_lim2")
+   nn_ice_embd = 1         !  =0 levitating ice (no mass exchange, concentration/dilution effect)
                            !  =1 levitating ice with mass and salt exchange but no presure effect
                            !  =2 embedded sea-ice (full salt and mass exchanges and pressure)
    ln_dm2dc    = .false.   !  daily mean to diurnal cycle on short wave
-   ln_rnf      = .true.    !  runoffs                                   (T => fill namsbc_rnf)
+   ln_rnf      = .true.    !  runoffs                                   (T   => fill namsbc_rnf)
    nn_isf      = 0         !  ice shelf melting/freezing                (/=0 => fill namsbc_isf)
                            !  0 =no isf                  1 = presence of ISF
@@ -25,13 +30,16 @@
                            !  option 1 and 4 need ln_isfcav = .true. (domzgr)
    ln_ssr      = .true.    !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
-   nn_fwb      = 3         !  FreshWater Budget: =0 unchecked
+   nn_fwb      = 2         !  FreshWater Budget: =0 unchecked
                            !     =1 global mean of e-p-r set to zero at each time step
                            !     =2 annual global mean of e-p-r set to zero
-                           !     =3 global emp set to zero and spread out over erp area
    ln_wave = .false.       !  Activate coupling with wave (either Stokes Drift or Drag coefficient, or both)  (T => fill namsbc_wave)
    ln_cdgw = .false.       !  Neutral drag coefficient read from wave model (T => fill namsbc_wave)
    ln_sdw  = .false.       !  Computation of 3D stokes drift                (T => fill namsbc_wave)
-   nn_lsm  = 0             !  =0   land/sea mask for input fields is not applied (the field land/sea mask filename
-                           !       is left empty in namelist)  ,
-                           !  =1:n number of iterations of land/sea mask application for input fields
+   nn_lsm  = 0             !  =0 land/sea mask for input fields is not applied (keep empty land/sea mask filename field) ,
+                           !  =1:n number of iterations of land/sea mask application for input fields (fill land/sea mask filename field)
+   nn_limflx = -1          !  LIM3 Multi-category heat flux formulation (use -1 if LIM3 is not used)
+                           !  =-1  Use per-category fluxes, bypass redistributor, forced mode only, not yet implemented coupled
+                           !  = 0  Average per-category fluxes (forced and coupled mode)
+                           !  = 1  Average and redistribute per-category fluxes, forced mode only, not yet implemented coupled
+                           !  = 2  Redistribute a single flux over categories (coupled mode only)
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_alb
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_alb	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_alb	(revision 6436)
@@ -2,8 +2,10 @@
 &namsbc_alb    !   albedo parameters
 !-----------------------------------------------------------------------
-   rn_cloud    =    0.06   !  cloud correction to snow and ice albedo
-   rn_albice   =    0.53   !  albedo of melting ice in the arctic and antarctic
-   rn_alphd    =    0.80   !  coefficients for linear interpolation used to
-   rn_alphc    =    0.65   !  compute albedo between two extremes values
-   rn_alphdi   =    0.72   !  (Pyane, 1972)
+   nn_ice_alb  =    0   !  parameterization of ice/snow albedo
+                        !     0: Shine & Henderson-Sellers (JGR 1985)
+                        !     1: "home made" based on Brandt et al. (J. Climate 2005)
+                        !                         and Grenfell & Perovich (JGR 2004)
+   rn_albice   =  0.53  !  albedo of bare puddled ice (values from 0.49 to 0.58)
+                        !     0.53 (default) => if nn_ice_alb=0
+                        !     0.50 (default) => if nn_ice_alb=1
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_apr
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_apr	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_apr	(revision 6436)
@@ -2,10 +2,10 @@
 &namsbc_apr    !   Atmospheric pressure used as ocean forcing or in bulk
 !-----------------------------------------------------------------------
-!              ! file name ! frequency (hours) ! variable ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-!              !           !  (if <0  months)  !   name   !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_apr      = 'patm'    ,         -1        ,'somslpre',    .true.      , .true.  , 'yearly'  ,  ''      ,   ''     , ''
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_apr      = 'patm'      ,         -1        ,'somslpre',    .true.     , .true. , 'yearly'  ,  ''      ,   ''     , ''
 
    cn_dir      = './'       !  root directory for the location of the bulk files
-   rn_pref     = 101000._wp !  reference atmospheric pressure   [N/m2]/
+   rn_pref     = 101000.    !  reference atmospheric pressure   [N/m2]/
    ln_ref_apr  = .false.    !  ref. pressure: global mean Patm (T) or a constant (F)
    ln_apr_obc  = .false.    !  inverse barometer added to OBC ssh data
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_core
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_core	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_core	(revision 6436)
@@ -2,19 +2,23 @@
 &namsbc_core   !   namsbc_core  CORE bulk formulae
 !-----------------------------------------------------------------------
-!              !  file name                    ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-!              !                               !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  !  filename     !
-   sn_wndi     = 'u_10.15JUNE2009_orca2'       ,         6         , 'U_10_MOD',   .false.    , .true. , 'yearly'  , ''       , 'Uwnd'   , ''
-   sn_wndj     = 'v_10.15JUNE2009_orca2'       ,         6         , 'V_10_MOD',   .false.    , .true. , 'yearly'  , ''       , 'Vwnd'   , ''
-   sn_qsr      = 'ncar_rad.15JUNE2009_orca2'   ,        24         , 'SWDN_MOD',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_qlw      = 'ncar_rad.15JUNE2009_orca2'   ,        24         , 'LWDN_MOD',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_tair     = 't_10.15JUNE2009_orca2'       ,         6         , 'T_10_MOD',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_humi     = 'q_10.15JUNE2009_orca2'       ,         6         , 'Q_10_MOD',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_prec     = 'ncar_precip.15JUNE2009_orca2',        -1         , 'PRC_MOD1',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_snow     = 'ncar_precip.15JUNE2009_orca2',        -1         , 'SNOW'    ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_tdif     = 'taudif_core'                 ,        24         , 'taudif'  ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-!
+!              !  file name                    ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights                               ! rotation ! land/sea mask !
+!              !                               !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename                              ! pairing  ! filename      !
+   sn_wndi     = 'u_10.15JUNE2009_fill'        ,         6         , 'U_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'   , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'        ,         6         , 'V_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'   , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'    ,        24         , 'SWDN_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'    ,        24         , 'LWDN_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'        ,         6         , 'T_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'        ,         6         , 'Q_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill' ,        -1         , 'PRC_MOD1',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill' ,        -1         , 'SNOW'    ,   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_tdif     = 'taudif_core'                 ,        24         , 'taudif'  ,   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+
    cn_dir      = './'      !  root directory for the location of the bulk files
-   ln_2m       = .false.   !  air temperature and humidity referenced at 2m (T) instead 10m (F)
    ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data
+   rn_zqt      = 10.        !  Air temperature and humidity reference height (m)
+   rn_zu       = 10.        !  Wind vector reference height (m)
    rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
+   rn_efac     = 1.        !  multiplicative factor for evaporation (0. or 1.)
+   rn_vfac     = 0.        !  multiplicative factor for ocean/ice velocity
+                           !  in the calculation of the wind stress (0.=absolute winds or 1.=relative winds)
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_cpl
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_cpl	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_cpl	(revision 6436)
@@ -1,23 +1,27 @@
 !-----------------------------------------------------------------------
-&namsbc_cpl    !   coupled ocean/atmosphere model                       ("key_coupled")
+&namsbc_cpl    !   coupled ocean/atmosphere model                       ("key_oasis3")
 !-----------------------------------------------------------------------
 !                    !     description       !  multiple  !    vector   !      vector          ! vector !
 !                    !                       ! categories !  reference  !    orientation       ! grids  !
 ! send
-sn_snd_temp   =       'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''
-sn_snd_alb    =       'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''
-sn_snd_thick  =       'none'                 ,    'no'   ,     ''      ,         ''           ,   ''
-sn_snd_crt    =       'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'
-sn_snd_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_temp   =       'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_alb    =       'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_thick  =       'none'                 ,    'no'   ,     ''      ,         ''           ,   ''
+   sn_snd_crt    =       'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'
+   sn_snd_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
 ! receive
-sn_rcv_w10m   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
-sn_rcv_taumod =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
-sn_rcv_tau    =       'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'
-sn_rcv_dqnsdt =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
-sn_rcv_qsr    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
-sn_rcv_qns    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
-sn_rcv_emp    =       'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''
-sn_rcv_rnf    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
-sn_rcv_cal    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
-sn_rcv_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_w10m   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_taumod =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_tau    =       'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'
+   sn_rcv_dqnsdt =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_qsr    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_qns    =       'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_emp    =       'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_rnf    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_cal    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_co2    =       'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+!
+   nn_cplmodel   =     1     !  Maximum number of models to/from which NEMO is potentialy sending/receiving data
+   ln_usecplmask = .false.   !  use a coupling mask file to merge data received from several models
+                             !   -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel)
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_mfs
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_mfs	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_mfs	(revision 6436)
@@ -2,13 +2,14 @@
 &namsbc_mfs   !   namsbc_mfs  MFS bulk formulae
 !-----------------------------------------------------------------------
-!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_wndi     =   'ecmwf'   ,        6          , 'u10'     ,    .true.    , .false. , 'daily'  ,'bicubic.nc' , ''    , ''
-   sn_wndj     =   'ecmwf'   ,        6          , 'v10'     ,    .true.    , .false. , 'daily'  ,'bicubic.nc' , ''    , ''
-   sn_clc      =   'ecmwf'   ,        6          , 'clc'     ,    .true.    , .false. , 'daily'  ,'bilinear.nc', ''    , ''
-   sn_msl      =   'ecmwf'   ,        6          , 'msl'     ,    .true.    , .false. , 'daily'  ,'bicubic.nc' , ''    , ''
-   sn_tair     =   'ecmwf'   ,        6          , 't2'      ,    .true.    , .false. , 'daily'  ,'bicubic.nc' , ''    , ''
-   sn_rhm      =   'ecmwf'   ,        6          , 'rh'      ,    .true.    , .false. , 'daily'  ,'bilinear.nc', ''    , ''
-   sn_prec     =   'precip'  ,        6          , 'precip'  ,    .true.    , .false. , 'daily'  ,'bicubic'    , ''    , ''
-   cn_dir      =   './'      !  root directory for the location of the bulk files
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights     ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename    ! pairing  ! filename      !
+   sn_wndi     =   'ecmwf'   ,        6          , 'u10'     ,    .true.    , .false. , 'daily'  ,'bicubic.nc' , ''       , ''
+   sn_wndj     =   'ecmwf'   ,        6          , 'v10'     ,    .true.    , .false. , 'daily'  ,'bicubic.nc' , ''       , ''
+   sn_clc      =   'ecmwf'   ,        6          , 'clc'     ,    .true.    , .false. , 'daily'  ,'bilinear.nc', ''       , ''
+   sn_msl      =   'ecmwf'   ,        6          , 'msl'     ,    .true.    , .false. , 'daily'  ,'bicubic.nc' , ''       , ''
+   sn_tair     =   'ecmwf'   ,        6          , 't2'      ,    .true.    , .false. , 'daily'  ,'bicubic.nc' , ''       , ''
+   sn_rhm      =   'ecmwf'   ,        6          , 'rh'      ,    .true.    , .false. , 'daily'  ,'bilinear.nc', ''       , ''
+   sn_prec     =   'ecmwf'   ,        6          , 'precip'  ,    .true.    , .true.  , 'daily'  ,'bicubic.nc' , ''       , ''
+
+   cn_dir      = './ECMWF/'      !  root directory for the location of the bulk files
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_rnf
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_rnf	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_rnf	(revision 6436)
@@ -2,14 +2,13 @@
 &namsbc_rnf    !   runoffs namelist surface boundary condition
 !-----------------------------------------------------------------------
-!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_rnf      = 'runoff_core_monthly',    -1    , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_cnf      = 'runoff_core_monthly',     0    , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_s_rnf    = 'runoffs'            ,    24    , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_t_rnf    = 'runoffs'            ,    24    , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_dep_rnf  = 'runoffs'            ,     0    , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+!              !  file name           ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                      !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_rnf      = 'runoff_core_monthly',        -1         , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_cnf      = 'runoff_core_monthly',         0         , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_s_rnf    = 'runoffs'            ,        24         , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_t_rnf    = 'runoffs'            ,        24         , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_dep_rnf  = 'runoffs'            ,         0         , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
 
    cn_dir       = './'      !  root directory for the location of the runoff files
-   ln_rnf_emp   = .false.   !  runoffs included into precipitation field (T) or into a file (F)
    ln_rnf_mouth = .true.    !  specific treatment at rivers mouths
    rn_hrnf      =  15.e0    !  depth over which enhanced vertical mixing is used
@@ -19,3 +18,7 @@
    ln_rnf_tem   = .false.   !  read in temperature information for runoff
    ln_rnf_sal   = .false.   !  read in salinity information for runoff
+   ln_rnf_depth_ini = .false.  ! compute depth at initialisation from runoff file
+   rn_rnf_max   = 5.735e-4  !  max value of the runoff climatologie over global domain ( ln_rnf_depth_ini = .true )
+   rn_dep_max   = 150.      !  depth over which runoffs is spread ( ln_rnf_depth_ini = .true )
+   nn_rnf_depth_file = 0    !  create (=1) a runoff depth file or not (=0)
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_sas
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_sas	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_sas	(revision 6436)
@@ -4,11 +4,14 @@
 !              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_usp      = 'sas_grid_U' ,    120    , 'vozocrtx' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
-   sn_vsp      = 'sas_grid_V' ,    120    , 'vomecrty' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
-   sn_tem      = 'sas_grid_T' ,    120    , 'sosstsst' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
-   sn_sal      = 'sas_grid_T' ,    120    , 'sosaline' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
-   sn_ssh      = 'sas_grid_T' ,    120    , 'sossheig' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
+   sn_usp      = 'sas_grid_U' ,    120           , 'vozocrtx' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
+   sn_vsp      = 'sas_grid_V' ,    120           , 'vomecrty' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
+   sn_tem      = 'sas_grid_T' ,    120           , 'sosstsst' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
+   sn_sal      = 'sas_grid_T' ,    120           , 'sosaline' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
+   sn_ssh      = 'sas_grid_T' ,    120           , 'sossheig' ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
+   sn_e3t      = 'sas_grid_T' ,    120           , 'e3t_m'    ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
+   sn_frq      = 'sas_grid_T' ,    120           , 'frq_m'    ,  .true.    , .true. ,   'yearly'  , ''       , ''             , ''
 
-   ln_3d_uv    = .true.    !  specify whether we are supplying a 3D u,v field
+   ln_3d_uve   = .true.    !  specify whether we are supplying a 3D u,v and e3 field
+   ln_read_frq = .false.    !  specify whether we must read frq or not
    cn_dir      = './'      !  root directory for the location of the bulk files are
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_wave
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_wave	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsbc_wave	(revision 6436)
@@ -2,10 +2,10 @@
 &namsbc_wave   ! External fields from wave model
 !-----------------------------------------------------------------------
-!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_cdg      =  'cdg_wave' ,        1          , 'drag_coeff' , .true.    , .false. , 'daily'  , ''       , ''       , ''
-   sn_usd      =  'sdw_wave' ,        1          , 'u_sd2d'     , .true.   , .false. , 'daily'  ,''         , ''       , ''
-   sn_vsd      =  'sdw_wave' ,        1          , 'v_sd2d'     , .true.   , .false. , 'daily'  ,''         , ''       , ''
-   sn_wn       =  'sdw_wave' ,        1          , 'wave_num'   , .true.   , .false. , 'daily'  ,''         , ''       , ''
+!              !  file name  ! frequency (hours) ! variable     ! time interp. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name       !   (logical)  !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_cdg      =  'cdg_wave' ,        1          , 'drag_coeff' ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_usd      =  'sdw_wave' ,        1          , 'u_sd2d'     ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_vsd      =  'sdw_wave' ,        1          , 'v_sd2d'     ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_wn       =  'sdw_wave' ,        1          , 'wave_num'   ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
 !
    cn_dir_cdg  = './'  !  root directory for the location of drag coefficient files
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsto
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsto	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namsto	(revision 6436)
@@ -0,0 +1,17 @@
+!-----------------------------------------------------------------------
+&namsto       ! Stochastic parametrization of EOS
+!-----------------------------------------------------------------------
+   ln_rststo = .false.           ! start from mean parameter (F) or from restart file (T)
+   ln_rstseed = .true.           ! read seed of RNG from restart file
+   cn_storst_in  = "restart_sto" !  suffix of stochastic parameter restart file (input)
+   cn_storst_out = "restart_sto" !  suffix of stochastic parameter restart file (output)
+
+   ln_sto_eos = .false.          ! stochastic equation of state
+   nn_sto_eos = 1                ! number of independent random walks
+   rn_eos_stdxy = 1.4            ! random walk horz. standard deviation (in grid points)
+   rn_eos_stdz  = 0.7            ! random walk vert. standard deviation (in grid points)
+   rn_eos_tcor  = 1440.0         ! random walk time correlation (in timesteps)
+   nn_eos_ord  = 1               ! order of autoregressive processes
+   nn_eos_flt  = 0               ! passes of Laplacian filter
+   rn_eos_lim  = 2.0             ! limitation factor (default = 3.0)
+/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_adv
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_adv	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_adv	(revision 6436)
@@ -2,10 +2,11 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
-   ln_traadv_cen2   =  .false.  !  2nd order centered scheme
-   ln_traadv_tvd    =  .true.   !  TVD scheme
-   ln_traadv_muscl  =  .false.  !  MUSCL scheme
-   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries
-   ln_traadv_ubs    =  .false.  !  UBS scheme
-   ln_traadv_qck    =  .false.  !  QUICKEST scheme
-   ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl
+   ln_traadv_cen2   =  .false.   !  2nd order centered scheme
+   ln_traadv_tvd    =  .true.    !  TVD scheme
+   ln_traadv_muscl  =  .false.   !  MUSCL scheme
+   ln_traadv_muscl2 =  .false.   !  MUSCL2 scheme + cen2 at boundaries
+   ln_traadv_ubs    =  .false.   !  UBS scheme
+   ln_traadv_qck    =  .false.   !  QUICKEST scheme
+   ln_traadv_msc_ups=  .false.   !  use upstream scheme within muscl
+   ln_traadv_tvd_zts=  .false.  !  TVD scheme with sub-timestepping of vertical tracer advection
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_adv_mle
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_adv_mle	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_adv_mle	(revision 6436)
@@ -0,0 +1,13 @@
+!-----------------------------------------------------------------------
+&namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+   ln_mle    = .true.      ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+   rn_ce     = 0.06        ! magnitude of the MLE (typical value: 0.06 to 0.08)
+   nn_mle    = 1           ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   rn_lf     = 5.e+3       ! typical scale of mixed layer front (meters)                      (case rn_mle=0)
+   rn_time   = 172800.     ! time scale for mixing momentum across the mixed layer (seconds)  (case rn_mle=0)
+   rn_lat    = 20.         ! reference latitude (degrees) of MLE coef.                        (case rn_mle=1)
+   nn_mld_uv = 0           ! space interpolation of MLD at u- & v-pts (0=min,1=averaged,2=max)
+   nn_conv   = 0           ! =1 no MLE in case of convection ; =0 always MLE
+   rn_rho_c_mle  = 0.01    ! delta rho criterion used to calculate MLD for FK
+/
Index: anches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_bbc
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_bbc	(revision 6435)
+++ 	(revision )
@@ -1,9 +1,0 @@
-!-----------------------------------------------------------------------
-&nambbc        !   bottom temperature boundary condition
-!-----------------------------------------------------------------------
-   ln_trabbc   = .true.    !  Apply a geothermal heating at the ocean bottom
-   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux
-                           !     = 1 constant flux
-                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2)
-   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
-/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_dmp
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_dmp	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_dmp	(revision 6436)
@@ -2,9 +2,8 @@
 &namtra_dmp    !   tracer: T & S newtonian damping
 !-----------------------------------------------------------------------
-   ln_tradmp   =  .true.     !  add a damping termn (T) or not (F)
-   nn_zdmp     =    0        !  vertical   shape =0    damping throughout the water column
-                             !                   =1 no damping in the mixing layer (kz  criteria)
-                             !                   =2 no damping in the mixed  layer (rho crieria)
-   cn_resto    = 'resto.nc'  ! Name of file containing restoration coefficient field (use dmp_tools to create this)
-
+   ln_tradmp   =  .true.   !  add a damping termn (T) or not (F)
+   nn_zdmp     =    0      !  vertical   shape =0    damping throughout the water column
+                           !                   =1 no damping in the mixing layer (kz  criteria)
+                           !                   =2 no damping in the mixed  layer (rho crieria)
+   cn_resto    = 'resto.nc' ! Name of file containing restoration coefficient field (use dmp_tools to create this)
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_qsr
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_qsr	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtra_qsr	(revision 6436)
@@ -11,7 +11,8 @@
    ln_qsr_2bd  = .false.   !  2 bands              light penetration
    ln_qsr_bio  = .false.   !  bio-model light penetration
-   nn_chldta   =      1    !  RGB : Chl data (=1) or cst value (=0)
+   nn_chldta   =      1    !  RGB : 2D Chl data (=1), 3D Chl data (=2) or cst value (=0)
    rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
    rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
    rn_si1      =   23.0    !  2 bands: longest depth of extinction
+   ln_qsr_ice  = .true.    !  light penetration for ice-model LIM3
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtrd
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtrd	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtrd	(revision 6436)
@@ -1,12 +1,14 @@
 !-----------------------------------------------------------------------
-&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")
+&namtrd        !   diagnostics on dynamics and/or tracer trends
+!              !       and/or mixed-layer trends and/or barotropic vorticity
 !-----------------------------------------------------------------------
-   nn_trd      = 365       !  time step frequency dynamics and tracers trends
-   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
-   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
-   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
-   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
-   ln_trdmld_restart = .false.         !  restart for ML diagnostics
-   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+   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)
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtsd
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtsd	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namtsd	(revision 6436)
@@ -2,8 +2,9 @@
 &namtsd    !   data : Temperature  & Salinity
 !-----------------------------------------------------------------------
-!          ! file name ! frequency (hours)         ! variable     ! time interp. ! clim  !'yearly' or ! weights  ! rotation ! land/sea mask !
-!          !           !  (if <0  months)          !   name       !  (logical)   ! (T/F) ! 'monthly'  ! filename ! pairing  ! filename      !
-   sn_tem  = 'data_1m_potential_temperature_nomask', -1,'votemper',  .true.      , .true., 'yearly'   , ' '      , ' '      , ''
-   sn_sal  = 'data_1m_salinity_nomask'             , -1,'vosaline',  .true.      , .true., 'yearly'   , ''       , ' '      , ''
+!-----------------------------------------------------------------------
+!          !  file name                            ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!          !                                       !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_tem  = 'data_1m_potential_temperature_nomask',         -1        ,'votemper' ,    .true.    , .true. , 'yearly'   , ''       ,   ''    ,    ''
+   sn_sal  = 'data_1m_salinity_nomask'             ,         -1        ,'vosaline' ,    .true.    , .true. , 'yearly'   , ''       ,   ''    ,    ''
    !
    cn_dir        = './'     !  root directory for the location of the runoff files
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namzdf_gls
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namzdf_gls	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namzdf_gls	(revision 6436)
@@ -2,17 +2,17 @@
 &namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
 !-----------------------------------------------------------------------
-   rn_emin       = 1.e-6   !  minimum value of e   [m2/s2]
+   rn_emin       = 1.e-7   !  minimum value of e   [m2/s2]
    rn_epsmin     = 1.e-12  !  minimum value of eps [m2/s3]
    ln_length_lim = .true.  !  limit on the dissipation rate under stable stratification (Galperin et al., 1988)
-   rn_clim_galp  = 0.53    !  galperin limit
-   ln_crban      = .true.  !  Use Craig & Banner (1994) surface wave mixing parametrisation
+   rn_clim_galp  = 0.267   !  galperin limit
    ln_sigpsi     = .true.  !  Activate or not Burchard 2001 mods on psi schmidt number in the wb case
    rn_crban      = 100.    !  Craig and Banner 1994 constant for wb tke flux
    rn_charn      = 70000.  !  Charnock constant for wb induced roughness length
-   nn_tkebc_surf =   1     !  surface tke condition (0/1/2=Dir/Neum/Dir Mellor-Blumberg)
-   nn_tkebc_bot  =   1     !  bottom tke condition (0/1=Dir/Neum)
-   nn_psibc_surf =   1     !  surface psi condition (0/1/2=Dir/Neum/Dir Mellor-Blumberg)
-   nn_psibc_bot  =   1     !  bottom psi condition (0/1=Dir/Neum)
-   nn_stab_func  =   2     !  stability function (0=Galp, 1= KC94, 2=CanutoA, 3=CanutoB)
-   nn_clos       =   1     !  predefined closure type (0=MY82, 1=k-eps, 2=k-w, 3=Gen)
+   rn_hsro       =  0.02   !  Minimum surface roughness
+   rn_frac_hs    =   1.3   !  Fraction of wave height as roughness (if nn_z0_met=2)
+   nn_z0_met     =     2   !  Method for surface roughness computation (0/1/2)
+   nn_bc_surf    =     1   !  surface condition (0/1=Dir/Neum)
+   nn_bc_bot     =     1   !  bottom condition (0/1=Dir/Neum)
+   nn_stab_func  =     2   !  stability function (0=Galp, 1= KC94, 2=CanutoA, 3=CanutoB)
+   nn_clos       =     1   !  predefined closure type (0=MY82, 1=k-eps, 2=k-w, 3=Gen)
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namzdf_tke
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namzdf_tke	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namzdf_tke	(revision 6436)
@@ -21,5 +21,5 @@
                            !        = 1 add a tke source below the ML
                            !        = 2 add a tke source just at the base of the ML
-                           !        = 3 as = 1 applied on HF part of the stress    ("key_coupled")
+                           !        = 3 as = 1 applied on HF part of the stress    ("key_oasis3")
    rn_efr      =   0.05    !  fraction of surface tke value which penetrates below the ML (nn_etau=1 or 2)
    nn_htau     =   1       !  type of exponential decrease of tke penetration below the ML
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namzgr_sco
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namzgr_sco	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/Namelist/namzgr_sco	(revision 6436)
@@ -13,5 +13,5 @@
                         !!!!!!!  SH94 stretching coefficients  (ln_s_sh94 = .true.)
    rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
-   rn_bb       =    0.8    !  stretching with SH94 s-sigma   
+   rn_bb       =    0.8    !  stretching with SH94 s-sigma
                         !!!!!!!  SF12 stretching coefficient  (ln_s_sf12 = .true.)
    rn_alpha    =    4.4    !  stretching with SF12 s-sigma
@@ -22,4 +22,4 @@
    rn_zb_b     =   -0.2    !  offset for calculating Zb
                         !!!!!!!! Other stretching (not SH94 or SF12) [also uses rn_theta above]
-   rn_thetb    =    1.0    !  bottom control parameter  (0<=thetb<= 1) 
+   rn_thetb    =    1.0    !  bottom control parameter  (0<=thetb<= 1)
 /
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/namcfg_orca1
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/namcfg_orca1	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/namcfg_orca1	(revision 6436)
@@ -0,0 +1,12 @@
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration
+!-----------------------------------------------------------------------
+   cp_cfg      =  "orca"               !  name of the configuration
+   jp_cfg      =       1               !  resolution of the configuration
+   jpidta      =     362               !  1st lateral dimension ( >= jpi )
+   jpjdta      =     292               !  2nd    "         "    ( >= jpj )
+   jpkdta      =      75               !  number of levels      ( >= jpk )
+   jpiglo      =     362               !  1st dimension of global domain --> i =jpidta
+   jpjglo      =     292               !  2nd    -                  -    --> j  =jpjdta
+   jperio      =       6               !  lateral cond. type (between 0 and 6)
+   ln_use_jattr = .true.               !  use (T) the file attribute: open_ocean_jstart if present
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/namelist_split.sh
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/namelist_split.sh	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/DOC/TexFiles/namelist_split.sh	(revision 6436)
@@ -0,0 +1,247 @@
+#! /bin/sh
+#
+#       usage for NEMO doc to create an update of the Namelist directory :
+# 1- delete the existing directory (You can also choose to save it somewhere) 
+#    rm -rf Namelist
+# 2- create the updated Namelist directory from the SHARED/namelist_ref :
+#    ./namelist_split.sh -i ../../NEMOGCM/CONFIG/SHARED/namelist_ref -o Namelist
+#
+# .. _namelist_split.sh:
+#
+# =================
+# namelist_split.sh
+# =================
+#
+# ----------------
+# split a namelist
+# ----------------
+#
+# SYNOPSIS
+# ========
+#
+# .. code-block:: bash
+#
+#    namelist_split.sh -i namelist -o dirout [-n]
+#
+# DESCRIPTION
+# ===========
+#
+# Split a namelist file (NEMO convention syntax) given in parameter
+# into files in a given output directory.
+#
+# .. option:: -i <input file (namelist)>
+# .. option:: -o <output directory>
+# .. option:: -n <numbered output files>
+#
+# Each file of the output directory is named after the *block* it contains.
+#
+# We assume here that the input file is written with this pattern of block:
+#
+# .. parsed-literal::
+#
+#    !---------------
+#    &nameblock
+#    !---------------
+#    var1 = val1
+#    ...
+#    varn = valn
+#    /
+#
+# If ``-n`` option is used, files in the directory output are named after
+# the number of the block it contains and the name of this block. This might
+# be useful to recombine blocks in the same order.
+#
+# EXAMPLES
+# ========
+#
+# To split the namelist NEMO ORCA2_LIM experiment 00 if you are in NEMO
+# working space :
+#
+# .. code-block:: bash
+#
+#    namelist_split.sh -i CONFIG/ORCA2_LIM/EXP00/namelist -o /tmp/EXP00_namelist_split/
+#
+# To split the namelist under data directory with numbered files:
+#
+# .. code-block:: bash
+#
+#    namelist_split.sh -i ./data/namelist -o /tmp/EXP00_namelist_split/ -n
+#
+# Check can be made by concatenation of files in output directory if ``-n``
+# option have been used and comparison with original file :
+#
+# .. code-block:: bash
+#
+#    cat /tmp/EXP00_namelist_split/b???_* > /tmp/EXP00_namelist_rebuild
+#    sdiff -w80 ./data/namelist /tmp/EXP00_namelist_rebuild
+#
+# Output contains lines which are before the first block, after the last
+# block and lines between blocks.
+#
+# EVOLUTIONS
+# ==========
+#
+# $Id$
+#
+# - fplod 2008-08-11T08:56:44Z aedon.locean-ipsl.upmc.fr (Darwin)
+#
+#   * commentaires dans ce fichier en reStructuredText
+#     cf. reStructuredText_ and Docutils_
+#
+# .. _reStructuredText: http://docutils.sourceforge.net/rst.html
+# .. _Docutils: http://docutils.sourceforge.net/
+#
+# - fplod 2008-07-22T12:41:04Z aedon.locean-ipsl.upmc.fr (Darwin)
+#
+#   * creation with test on
+#     http://forge.ipsl.jussieu.fr/nemo/browser/trunk/CONFIG/ORCA2_LIM/EXP00/namelist revision 1151
+#-
+#
+system=$(uname)
+case "${system}" in
+    AIX|IRIX64)
+        echo " www : no specific posix checking"
+    ;;
+    *)
+        set -o posix
+    ;;
+esac
+unset system
+#
+command=$(basename ${0})
+log_date=$(date -u +"%Y%m%dT%H%M%SZ")
+#
+usage=" Usage : ${command} -i namelist -o dirout [-n]"
+#
+# default
+blocknum=0
+#
+minargcount=4
+if [ ${#} -lt ${minargcount} ]
+then
+    echo "eee : not enough arguments"
+    echo "${usage}"
+    exit 1
+fi
+#
+while [ ${#} -gt 0 ]
+do
+    case ${1} in
+        -i)
+            filein=${2}
+            shift
+        ;;
+        -o)
+            dirout=${2}
+            shift
+        ;;
+        -h)
+            echo "${usage}"
+            exit 0
+        ;;
+        -n)
+            blocknum=1
+        ;;
+        *)
+            # anything else
+            echo "eee : unknown option ${1}"
+            echo "eee : ${usage}"
+            exit 1
+        ;;
+    esac
+    # next flag
+    shift
+done
+unset usage
+#
+set -u
+#
+# check for filein
+if [ ! -r ${filein} ]
+then
+    echo "eee : ${filein} not accessible"
+    exit 1
+fi
+#
+# check for dirout
+# the idea is to prevent unwanted overwrite
+if [ -d ${dirout} ]
+then
+    echo "eee : ${dirout} already exist"
+    exit 1
+else
+    mkdir -p ${dirout}
+    if [ ${?} -ne 0 ]
+    then
+        echo "eee : cannot create ${dirout}"
+        exit 1
+    fi
+fi
+#
+# loop on each line of ${filein} ie the namelist to be split
+fileout=/dev/null
+begin=0
+if [ ${blocknum} -eq 1 ]
+then
+    iblock=0
+fi
+nbline=$(wc -l ${filein} | awk '{print $1}')
+il=1
+while [ ${il} -le ${nbline} ]
+do
+    line=$(sed -ne "${il},${il}p" ${filein})
+    # if current line start with "&", we can establish the name of output file
+    echo ${line} | grep -q "^&"
+    if [ ${?} -eq 0 ]
+    then
+        begin=1
+        # the form of this line is "&block   !"
+        block=${line#&}
+        block=${block%% *}
+        echo "iii : detection of the beginning of ${block}"
+        if [ ${blocknum} -eq 1 ]
+        then
+            iblock=$(( ${iblock} + 1))
+            fileout=${dirout}/b$(echo ${iblock} | awk '{printf "%3.3d", $1}')_${block}
+        else
+            fileout="${dirout}/${block}"
+        fi
+        # check for ${fileout}
+        if [ -f ${fileout} ]
+        then
+            echo "eee : ${fileout} already exists"
+            exit 1
+        fi
+        # write the previous line and the current line
+        echo "${memoline}" > ${fileout}
+        echo "${line}" >> ${fileout}
+    fi
+    # if current line contains "/" there will be no more lines to put in fileout
+    echo ${line} | grep -q "^/$"
+    if [ ${?} -eq 0 ]
+    then
+        echo "iii : detection of the end of ${block}"
+        echo "${line}" >> ${fileout}
+        fileout="/dev/null"
+    fi
+    # if current line is between "&" and "/", it should be written in fileout
+    # if current line is before the first &, it won't be written
+    if [ "${fileout}" != "/dev/null" ]
+    then
+        if [ ${begin} -eq 0 ]
+        then
+            echo "${line}" >> ${fileout}
+        fi
+    fi
+    # keep memory of this current line to use it if the next one is the
+    # beginning of a block
+    memoline=${line}
+    begin=0
+    # next line
+    il=$(( ${il} + 1 ))
+done
+#
+echo "iii : ${filein} is split in ${dirout}"
+#
+# end
+exit 0
Index: anches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/ARCH/CMCC/arch-PW6_calypso.fcm
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/ARCH/CMCC/arch-PW6_calypso.fcm	(revision 6435)
+++ 	(revision )
@@ -1,34 +1,0 @@
-# vargas IBM POWER6 at french IDRIS, http://www.idris.fr/su/Scalaire/vargas/hw-vargas.html
-# NCDF_INC    netcdf include file
-# NCDF_LIB    netcdf library
-# 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 in a
-# FPPFLAGS    pre-processing flags
-# AR          assembler
-# ARFLAGS     assembler flags
-# MK          make  
-# USER_INC    additional include files for the compiler,  e.g. -I<include dir> 
-# USER_LIB    additional libraries to pass to the linker, e.g. -l<library>
-# CC          C compiler used to compile conv for AGRIF
-# CFLAGS      compiler flags used with CC
-
-
-%NCDF_INC            -I/usr/local/netcdf-3.6.3/include
-%NCDF_LIB            -L/usr/local/netcdf-3.6.3/lib -lnetcdf
-%CPP                 cpp
-%FC                  mpxlf90_r
-%FCFLAGS             -O3 -qsuffix=f=f90  -qstrict -qalias=intptr -qsuppress=1501-245 -qarch=pwr6 -q64 -qrealsize=8 -qtune=pwr6 -qextname -qlargepage -qmaxmem=-1
-%FFLAGS              -O3 -qsuffix=f=f90  -qstrict -qalias=intptr -qsuppress=1501-245 -qarch=pwr6 -q64 -qrealsize=8 -qtune=pwr6 -qextname -qlargepage -qmaxmem=-1
-%LD                  mpxlf90_r
-%LDFLAGS             -bloadmap:LinkerErrorMap 
-%FPPFLAGS            -P -C
-%AR                  ar  
-%ARFLAGS             rs
-%MK                  gmake 
-%USER_INC            %NCDF_INC
-%USER_LIB            %NCDF_LIB 
-%CC                  xlc
-%CFLAGS              -O -qcpluscmt
Index: anches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/ARCH/CMCC/arch-PW6_calypso_debug.fcm
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/ARCH/CMCC/arch-PW6_calypso_debug.fcm	(revision 6435)
+++ 	(revision )
@@ -1,34 +1,0 @@
-# vargas IBM POWER6 at french IDRIS, http://www.idris.fr/su/Scalaire/vargas/hw-vargas.html
-# NCDF_INC    netcdf include file
-# NCDF_LIB    netcdf library
-# 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 in a
-# FPPFLAGS    pre-processing flags
-# AR          assembler
-# ARFLAGS     assembler flags
-# MK          make  
-# USER_INC    additional include files for the compiler,  e.g. -I<include dir> 
-# USER_LIB    additional libraries to pass to the linker, e.g. -l<library>
-# CC          C compiler used to compile conv for AGRIF
-# CFLAGS      compiler flags used with CC
-
-
-%NCDF_INC            -I/usr/local/netcdf-3.6.3/include
-%NCDF_LIB            -L/usr/local/netcdf-3.6.3/lib -lnetcdf
-%CPP                 cpp
-%FC                  mpxlf90_r
-%FCFLAGS             -g -qsuffix=f=f90  -qstrict -qalias=intptr -qsuppress=1501-245 -qarch=pwr6 -q64 -qrealsize=8 -qtune=pwr6 -qextname -qlargepage -qmaxmem=-1
-%FFLAGS              -g -qsuffix=f=f90  -qstrict -qalias=intptr -qsuppress=1501-245 -qarch=pwr6 -q64 -qrealsize=8 -qtune=pwr6 -qextname -qlargepage -qmaxmem=-1
-%LD                  mpxlf90_r
-%LDFLAGS             -bloadmap:LinkerErrorMap 
-%FPPFLAGS            -P -C
-%AR                  ar  
-%ARFLAGS             rs
-%MK                  gmake 
-%USER_INC            %NCDF_INC
-%USER_LIB            %NCDF_LIB 
-%CC                  xlc
-%CFLAGS              -O -qcpluscmt
Index: anches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/ARCH/CMCC/arch-PW6_calypso_tools.fcm
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/ARCH/CMCC/arch-PW6_calypso_tools.fcm	(revision 6435)
+++ 	(revision )
@@ -1,34 +1,0 @@
-# vargas IBM POWER6 at french IDRIS, http://www.idris.fr/su/Scalaire/vargas/hw-vargas.html
-# NCDF_INC    netcdf include file
-# NCDF_LIB    netcdf library
-# 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 in a
-# FPPFLAGS    pre-processing flags
-# AR          assembler
-# ARFLAGS     assembler flags
-# MK          make  
-# USER_INC    additional include files for the compiler,  e.g. -I<include dir> 
-# USER_LIB    additional libraries to pass to the linker, e.g. -l<library>
-# CC          C compiler used to compile conv for AGRIF
-# CFLAGS      compiler flags used with CC
-
-
-%NCDF_INC            -I/usr/local/netcdf-3.6.3/include
-%NCDF_LIB            -L/usr/local/netcdf-3.6.3/lib -lnetcdf
-%CPP                 cpp
-%FC                  xlf90
-%FCFLAGS             -O3 -qsuffix=f=f90  -qstrict -qsuppress=1501-245 -qarch=pwr6 -q64 -qrealsize=8 -qtune=pwr6 -qextname -qlargepage -qmaxmem=-1
-%FFLAGS              -O3 -qsuffix=f=f90  -qstrict -qsuppress=1501-245 -qarch=pwr6 -q64 -qrealsize=8 -qtune=pwr6 -qextname -qlargepage -qmaxmem=-1
-%LD                  xlf90
-%LDFLAGS             -bloadmap:LinkerErrorMap 
-%FPPFLAGS            -P -C
-%AR                  ar  
-%ARFLAGS             rs
-%MK                  gmake 
-%USER_INC            %NCDF_INC
-%USER_LIB            %NCDF_LIB 
-%CC                  xlc
-%CFLAGS              -O -qcpluscmt
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/ARCH/CMCC/arch-ifort_athena_xios.fcm
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/ARCH/CMCC/arch-ifort_athena_xios.fcm	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/ARCH/CMCC/arch-ifort_athena_xios.fcm	(revision 6436)
@@ -34,10 +34,10 @@
 
 # required modules
-# module load  INTEL/intel_xe_2013 NETCDF/netcdf-4.3_parallel_shared NETCDF/parallel-netcdf-1.3.1 HDF5/hdf5-1.8.11_parallel_shared
+# module load  INTEL/intel_xe_2013 NETCDF/netcdf-4.3_parallel NETCDF/parallel-netcdf-1.3.1 HDF5/hdf5-1.8.11_parallel
 
 # Environment variables set by user. Others should automatically define when loading modules.
 #export XIOS=/users/home/models/nemo/xios
-#export HDF5=/users/home/opt/hdf5/hdf5-1.8.11_parallel_shared
-#export NETCDF=/users/home/opt/netcdf/netcdf-4.3_parallel_shared
+#export HDF5=/users/home/opt/hdf5/hdf5-1.8.11_parallel
+#export NETCDF=/users/home/opt/netcdf/netcdf-4.3_parallel
 
 %NCDF_INC            -I${NETCDF}/include 
@@ -49,9 +49,9 @@
 %CPP                 cpp
 %FC                  mpiifort
-%FCFLAGS             -r8 -O3 -xHost -fp-model source -traceback ${CFLAGS} 
+%FCFLAGS             -r8 -O3 -xHost -fp-model source -traceback
 %FFLAGS              %FCFLAGS
 %LD                  mpiifort
 %FPPFLAGS            -P -C -traditional
-%LDFLAGS             -lstdc++ -lz -lgpfs -lcurl  ${LDFLAGS}
+%LDFLAGS             -lstdc++ -lz -lgpfs -lcurl
 %AR                  ar 
 %ARFLAGS             -r
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/CONFIG/SHARED/field_def.xml
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 6436)
@@ -174,4 +174,5 @@
       <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="emp_oce"      long_name="Evap minus Precip over ocean"         standard_name="evap_minus_precip_over_sea_water"                                     unit="kg/m2/s"   />
          <field id="emp_ice"      long_name="Evap minus Precip over ice"           standard_name="evap_minus_precip_over_sea_ice"                                       unit="kg/m2/s"   />
@@ -315,4 +316,5 @@
          <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="sfxsub"       long_name="salt flux from sublimation"                                   unit="1e-3*kg/m2/day" />
          <field id="sfx"          long_name="salt flux total"                                              unit="1e-3*kg/m2/day" />
 
@@ -448,10 +450,11 @@
         <field id="woce_eiv"     long_name="EIV ocean vertical velocity"   standard_name="bolus_upward_sea_water_velocity"   unit="m/s" />
 
-        <!-- woce_eiv: available with key_trabbl_adv -->
         <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 -->
@@ -542,4 +545,5 @@
          <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="ibgsfxsub"    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"          />
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/CONFIG/cfg.txt
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/CONFIG/cfg.txt	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/CONFIG/cfg.txt	(revision 6436)
@@ -6,7 +6,7 @@
 GYRE_BFM OPA_SRC TOP_SRC
 AMM12 OPA_SRC
+ORCA2_OFF_PISCES OPA_SRC OFF_SRC TOP_SRC
 ORCA2_LIM_PISCES OPA_SRC LIM_SRC_2 NST_SRC TOP_SRC
+ORCA2_LIM3 OPA_SRC LIM_SRC_3 NST_SRC
 GYRE OPA_SRC
-ORCA2_LIM3 OPA_SRC LIM_SRC_3 NST_SRC
 ORCA2_LIM OPA_SRC LIM_SRC_2 NST_SRC
-ORCA2_OFF_PISCES OPA_SRC OFF_SRC TOP_SRC
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilAgrif.c
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilAgrif.c	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilAgrif.c	(revision 6436)
@@ -274,7 +274,10 @@
      }
      if ( parcours && parcours->o_val != 0 )
-        fprintf(fileout,"\n      use Agrif_Util\n");
-     else
-        fprintf(fileout,"\n      use Agrif_Types, only : Agrif_tabvars\n");
+       {
+        if( strcasecmp(subroutinename,"Agrif_InvLoc") )	 
+       fprintf(fileout,"\n      USE Agrif_Util \n");
+       else fprintf(fileout,"\n      USE Agrif_Types \n");
+
+       }
   }
 }
@@ -286,22 +289,23 @@
     int out;
 
-    if ( firstpass == 0 )
-    {
-        parcours = List_NameOfModuleUsed;
-        out = 0 ;
-        while ( parcours && out == 0 )
-        {
-            if ( !strcasecmp(parcours->u_usemodule, "Agrif_Util")   &&
-                 !strcasecmp(parcours->u_modulename, curmodulename) &&
-                 !strcasecmp(parcours->u_cursubroutine, subroutinename) )
-                out = 1;
-            else
-                parcours = parcours->suiv;
-        }
-        if ( out == 0 )
-        {
-            fprintf(fileout,"\n      use Agrif_Util\n");
-        }
-    }
+  if ( firstpass == 0 )
+  {
+     parcours = List_NameOfModuleUsed;
+     out = 0 ;
+     while ( parcours && out == 0 )
+     {
+        if ( !strcasecmp(parcours->u_usemodule,"Agrif_Util")     &&
+             !strcasecmp(parcours->u_modulename,curmodulename)   &&
+             !strcasecmp(parcours->u_cursubroutine,subroutinename)
+            ) out = 1;
+        else parcours = parcours->suiv;
+     }
+     if ( out == 0 )
+     {
+       if( strcasecmp(subroutinename,"Agrif_InitWorkspace") )	 
+       fprintf(fileout,"\n      USE Agrif_Util \n");
+       else fprintf(fileout,"\n      USE Agrif_Types \n");
+     }
+  }
 }
 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/ice.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 6436)
@@ -253,20 +253,20 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   fhld        !: heat flux from the lead used for bottom melting
 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_snw    !: snow-ocean mass exchange over 1 time step [kg/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_spr    !: snow precipitation on ice over 1 time step [kg/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_sub    !: snow sublimation over 1 time step [kg/m2]
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_ice    !: ice-ocean mass exchange over 1 time step [kg/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_sni    !: snow ice growth component of wfx_ice [kg/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_opw    !: lateral ice growth component of wfx_ice [kg/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_bog    !: bottom ice growth component of wfx_ice [kg/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_dyn    !: dynamical ice growth component of wfx_ice [kg/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_bom    !: bottom melt component of wfx_ice [kg/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_sum    !: surface melt component of wfx_ice [kg/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_res    !: residual component of wfx_ice [kg/m2]
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   afx_tot     !: ice concentration tendency (total) [s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_snw    !: snow-ocean mass exchange   [kg.m-2.s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_spr    !: snow precipitation on ice  [kg.m-2.s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_sub    !: snow/ice sublimation       [kg.m-2.s-1]
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_ice    !: ice-ocean mass exchange                   [kg.m-2.s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_sni    !: snow ice growth component of wfx_ice      [kg.m-2.s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_opw    !: lateral ice growth component of wfx_ice   [kg.m-2.s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_bog    !: bottom ice growth component of wfx_ice    [kg.m-2.s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_dyn    !: dynamical ice growth component of wfx_ice [kg.m-2.s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_bom    !: bottom melt component of wfx_ice          [kg.m-2.s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_sum    !: surface melt component of wfx_ice         [kg.m-2.s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_res    !: residual component of wfx_ice             [kg.m-2.s-1]
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   afx_tot     !: ice concentration tendency (total)          [s-1]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   afx_thd     !: ice concentration tendency (thermodynamics) [s-1]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   afx_dyn     !: ice concentration tendency (dynamics) [s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   afx_dyn     !: ice concentration tendency (dynamics)       [s-1]
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sfx_bog     !: salt flux due to ice growth/melt                      [PSU/m2/s]
@@ -279,24 +279,27 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sfx_res     !: residual salt flux due to correction of ice thickness [PSU/m2/s]
 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_bog     !: total heat flux causing bottom ice growth 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_bom     !: total heat flux causing bottom ice melt 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_sum     !: total heat flux causing surface ice melt 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_opw     !: total heat flux causing open water ice formation
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_dif     !: total heat flux causing Temp change in the ice 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_snw     !: heat flux for snow melt 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_err     !: heat flux error after heat diffusion 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_err_dif !: heat flux remaining due to change in non-solar flux
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_err_rem !: heat flux error after heat remapping 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_in      !: heat flux available for thermo transformations 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_out     !: heat flux remaining at the end of thermo transformations 
-
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sfx_sub     !: salt flux due to ice sublimation
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_bog     !: total heat flux causing bottom ice growth        [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_bom     !: total heat flux causing bottom ice melt          [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_sum     !: total heat flux causing surface ice melt         [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_opw     !: total heat flux causing open water ice formation [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_dif     !: total heat flux causing Temp change in the ice   [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_snw     !: heat flux for snow melt                          [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_err     !: heat flux error after heat diffusion             [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_err_dif !: heat flux remaining due to change in non-solar flux [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_err_rem !: heat flux error after heat remapping             [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_in      !: heat flux available for thermo transformations   [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_out     !: heat flux remaining at the end of thermo transformations  [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_err_sub !: mass flux error after sublimation [kg.m-2.s-1]
+   
    ! heat flux associated with ice-atmosphere mass exchange
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_sub     !: heat flux for sublimation 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_spr     !: heat flux of the snow precipitation 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_sub     !: heat flux for sublimation  [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_spr     !: heat flux of the snow precipitation  [W.m-2]
 
    ! heat flux associated with ice-ocean mass exchange
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_thd     !: ice-ocean heat flux from thermo processes (limthd_dh) 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_dyn     !: ice-ocean heat flux from mecanical processes (limitd_me) 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_res     !: residual heat flux due to correction of ice thickness
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_thd     !: ice-ocean heat flux from thermo processes (limthd_dh)  [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_dyn     !: ice-ocean heat flux from mecanical processes (limitd_me)  [W.m-2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hfx_res     !: residual heat flux due to correction of ice thickness [W.m-2]
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ftr_ice   !: transmitted solar radiation under ice
@@ -441,8 +444,8 @@
          &      fhtur  (jpi,jpj) , ftr_ice(jpi,jpj,jpl), qlead  (jpi,jpj) ,                     &
          &      rn_amax_2d(jpi,jpj),                                                            &
-         &      sfx_res(jpi,jpj) , sfx_bri(jpi,jpj) , sfx_dyn(jpi,jpj) ,                        &
+         &      sfx_res(jpi,jpj) , sfx_bri(jpi,jpj) , sfx_dyn(jpi,jpj) , sfx_sub(jpi,jpj) ,                       &
          &      sfx_bog(jpi,jpj) , sfx_bom(jpi,jpj) , sfx_sum(jpi,jpj) , sfx_sni(jpi,jpj) , sfx_opw(jpi,jpj) ,    &
          &      hfx_res(jpi,jpj) , hfx_snw(jpi,jpj) , hfx_sub(jpi,jpj) , hfx_err(jpi,jpj) ,     & 
-         &      hfx_err_dif(jpi,jpj) , hfx_err_rem(jpi,jpj) ,                                   &
+         &      hfx_err_dif(jpi,jpj) , hfx_err_rem(jpi,jpj) , wfx_err_sub(jpi,jpj) ,       &
          &      hfx_in (jpi,jpj) , hfx_out(jpi,jpj) , fhld(jpi,jpj) ,                           &
          &      hfx_sum(jpi,jpj) , hfx_bom(jpi,jpj) , hfx_bog(jpi,jpj) , hfx_dif(jpi,jpj) , hfx_opw(jpi,jpj) ,    &
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limcons.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limcons.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limcons.F90	(revision 6436)
@@ -24,5 +24,6 @@
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
    USE sbc_oce , ONLY : sfx  ! Surface boundary condition: ocean fields
-
+   USE sbc_ice , ONLY : qevap_ice
+   
    IMPLICIT NONE
    PRIVATE
@@ -184,5 +185,5 @@
          ! salt flux
          zfs_b  = glob_sum(  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
-            &                  sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:)                                  &
+            &                  sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:) + sfx_sub(:,:)                   &
             &                ) *  e12t(:,:) * tmask(:,:,1) * zconv )
 
@@ -209,5 +210,5 @@
          ! salt flux
          zfs  = glob_sum(  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
-            &                sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:)                                  & 
+            &                sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:) + sfx_sub(:,:)                   & 
             &              ) * e12t(:,:) * tmask(:,:,1) * zconv ) - zfs_b
 
@@ -287,5 +288,6 @@
 #if ! defined key_bdy
       ! heat flux
-      zhfx  = glob_sum( ( hfx_in - hfx_out - diag_heat - diag_trp_ei - diag_trp_es - hfx_sub ) * e12t * tmask(:,:,1) * zconv ) 
+      zhfx  = glob_sum( ( hfx_in - hfx_out - diag_heat - diag_trp_ei - diag_trp_es - SUM( qevap_ice * a_i_b, dim=3 ) )  &
+         &              * e12t * tmask(:,:,1) * zconv ) 
       ! salt flux
       zsfx  = glob_sum( ( sfx + diag_smvi ) * e12t * tmask(:,:,1) * zconv ) * rday
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limdiahsb.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limdiahsb.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limdiahsb.F90	(revision 6436)
@@ -56,5 +56,5 @@
       real(wp)   ::   zbg_ivo, zbg_svo, zbg_are, zbg_sal ,zbg_tem ,zbg_ihc ,zbg_shc
       real(wp)   ::   zbg_sfx, zbg_sfx_bri, zbg_sfx_bog, zbg_sfx_bom, zbg_sfx_sum, zbg_sfx_sni,   &
-      &               zbg_sfx_opw, zbg_sfx_res, zbg_sfx_dyn 
+      &               zbg_sfx_opw, zbg_sfx_res, zbg_sfx_dyn, zbg_sfx_sub 
       real(wp)   ::   zbg_vfx, zbg_vfx_bog, zbg_vfx_opw, zbg_vfx_sni, zbg_vfx_dyn
       real(wp)   ::   zbg_vfx_bom, zbg_vfx_sum, zbg_vfx_res, zbg_vfx_spr, zbg_vfx_snw, zbg_vfx_sub  
@@ -111,4 +111,5 @@
       zbg_sfx_bom = ztmp * glob_sum( sfx_bom(:,:) * e12t(:,:) * tmask(:,:,1) )
       zbg_sfx_sum = ztmp * glob_sum( sfx_sum(:,:) * e12t(:,:) * tmask(:,:,1) )
+      zbg_sfx_sub = ztmp * glob_sum( sfx_sub(:,:) * e12t(:,:) * tmask(:,:,1) )
 
       ! Heat budget
@@ -189,4 +190,5 @@
       CALL iom_put( 'ibgsfxbom' , zbg_sfx_bom                              )   ! salt flux bottom melt       -
       CALL iom_put( 'ibgsfxsum' , zbg_sfx_sum                              )   ! salt flux surface melt      -
+      CALL iom_put( 'ibgsfxsub' , zbg_sfx_sub                              )   ! salt flux sublimation      -
 
       CALL iom_put( 'ibghfxdhc' , zbg_hfx_dhc                              )   ! Heat content variation in snow and ice [W]
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 6436)
@@ -45,26 +45,17 @@
    REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   asum     ! sum of total ice and open water area
    REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   aksum    ! ratio of area removed to area ridged
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   athorn   ! participation function; fraction of ridging/
-   !                                                     ! closing associated w/ category n
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   athorn   ! participation function; fraction of ridging/closing associated w/ category n
    REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   hrmin    ! minimum ridge thickness
    REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   hrmax    ! maximum ridge thickness
    REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   hraft    ! thickness of rafted ice
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   krdg     ! mean ridge thickness/thickness of ridging ice 
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   krdg     ! thickness of ridging ice / mean ridge thickness
    REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   aridge   ! participating ice ridging
    REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   araft    ! participating ice rafting
 
    REAL(wp), PARAMETER ::   krdgmin = 1.1_wp    ! min ridge thickness multiplier
-   REAL(wp), PARAMETER ::   kraft   = 2.0_wp    ! rafting multipliyer
-   REAL(wp), PARAMETER ::   kamax   = 1.0_wp    ! max of ice area authorized (clem: scheme is not stable if kamax <= 0.99)
+   REAL(wp), PARAMETER ::   kraft   = 0.5_wp    ! rafting multipliyer
 
    REAL(wp) ::   Cp                             ! 
    !
-   !-----------------------------------------------------------------------
-   ! Ridging diagnostic arrays for history files
-   !-----------------------------------------------------------------------
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   dardg1dt   ! rate of fractional area loss by ridging ice (1/s)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   dardg2dt   ! rate of fractional area gain by new ridges (1/s)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   dvirdgdt   ! rate of ice volume ridged (m/s)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   opening    ! rate of opening due to divergence/shear (1/s)
    !
    !!----------------------------------------------------------------------
@@ -83,11 +74,6 @@
          &      asum (jpi,jpj)     , athorn(jpi,jpj,0:jpl)                    ,     &
          &      aksum(jpi,jpj)                                                ,     &
-         !
          &      hrmin(jpi,jpj,jpl) , hraft(jpi,jpj,jpl) , aridge(jpi,jpj,jpl) ,     &
-         &      hrmax(jpi,jpj,jpl) , krdg (jpi,jpj,jpl) , araft (jpi,jpj,jpl) ,     &
-         !
-         !* Ridging diagnostic arrays for history files
-         &      dardg1dt(jpi,jpj)  , dardg2dt(jpi,jpj)                        ,     & 
-         &      dvirdgdt(jpi,jpj)  , opening(jpi,jpj)                         , STAT=lim_itd_me_alloc )
+         &      hrmax(jpi,jpj,jpl) , krdg (jpi,jpj,jpl) , araft (jpi,jpj,jpl) , STAT=lim_itd_me_alloc )
          !
       IF( lim_itd_me_alloc /= 0 )   CALL ctl_warn( 'lim_itd_me_alloc: failed to allocate arrays' )
@@ -132,7 +118,4 @@
       REAL(wp), POINTER, DIMENSION(:,:)   ::   opning          ! rate of opening due to divergence/shear
       REAL(wp), POINTER, DIMENSION(:,:)   ::   closing_gross   ! rate at which area removed, not counting area of new ridges
-      REAL(wp), POINTER, DIMENSION(:,:)   ::   msnow_mlt       ! mass of snow added to ocean (kg m-2)
-      REAL(wp), POINTER, DIMENSION(:,:)   ::   esnow_mlt       ! energy needed to melt snow in ocean (J m-2)
-      REAL(wp), POINTER, DIMENSION(:,:)   ::   vt_i_init, vt_i_final  !  ice volume summed over categories
       !
       INTEGER, PARAMETER ::   nitermax = 20    
@@ -142,5 +125,5 @@
       IF( nn_timing == 1 )  CALL timing_start('limitd_me')
 
-      CALL wrk_alloc( jpi,jpj, closing_net, divu_adv, opning, closing_gross, msnow_mlt, esnow_mlt, vt_i_init, vt_i_final )
+      CALL wrk_alloc( jpi,jpj, closing_net, divu_adv, opning, closing_gross )
 
       IF(ln_ctl) THEN
@@ -154,7 +137,4 @@
       IF( ln_limdiahsb ) CALL lim_cons_hsm(0, 'limitd_me', zvi_b, zsmv_b, zei_b, zfw_b, zfs_b, zft_b)
 
-      CALL lim_var_zapsmall
-      CALL lim_var_glo2eqv            ! equivalent variables, requested for rafting
-
       !-----------------------------------------------------------------------------!
       ! 1) Thickness categories boundaries, ice / o.w. concentrations, init_ons
@@ -164,14 +144,7 @@
       CALL lim_itd_me_ridgeprep                                    ! prepare ridging
       !
-      IF( con_i)   CALL lim_column_sum( jpl, v_i, vt_i_init )      ! conservation check
 
       DO jj = 1, jpj                                     ! Initialize arrays.
          DO ji = 1, jpi
-            msnow_mlt(ji,jj) = 0._wp
-            esnow_mlt(ji,jj) = 0._wp
-            dardg1dt (ji,jj) = 0._wp
-            dardg2dt (ji,jj) = 0._wp
-            dvirdgdt (ji,jj) = 0._wp
-            opening  (ji,jj) = 0._wp
 
             !-----------------------------------------------------------------------------!
@@ -204,6 +177,6 @@
             ! If divu_adv < 0, make sure the closing rate is large enough
             ! to give asum = 1.0 after ridging.
-
-            divu_adv(ji,jj) = ( kamax - asum(ji,jj) ) * r1_rdtice  ! asum found in ridgeprep
+            
+            divu_adv(ji,jj) = ( 1._wp - asum(ji,jj) ) * r1_rdtice  ! asum found in ridgeprep
 
             IF( divu_adv(ji,jj) < 0._wp )   closing_net(ji,jj) = MAX( closing_net(ji,jj), -divu_adv(ji,jj) )
@@ -224,25 +197,25 @@
       DO WHILE ( iterate_ridging > 0 .AND. niter < nitermax )
 
+         ! 3.2 closing_gross
+         !-----------------------------------------------------------------------------!
+         ! Based on the ITD of ridging and ridged ice, convert the net
+         !  closing rate to a gross closing rate.  
+         ! NOTE: 0 < aksum <= 1
+         closing_gross(:,:) = closing_net(:,:) / aksum(:,:)
+
+         ! correction to closing rate and opening if closing rate is excessive
+         !---------------------------------------------------------------------
+         ! Reduce the closing rate if more than 100% of the open water 
+         ! would be removed.  Reduce the opening rate proportionately.
          DO jj = 1, jpj
             DO ji = 1, jpi
-
-               ! 3.2 closing_gross
-               !-----------------------------------------------------------------------------!
-               ! Based on the ITD of ridging and ridged ice, convert the net
-               !  closing rate to a gross closing rate.  
-               ! NOTE: 0 < aksum <= 1
-               closing_gross(ji,jj) = closing_net(ji,jj) / aksum(ji,jj)
-
-               ! correction to closing rate and opening if closing rate is excessive
-               !---------------------------------------------------------------------
-               ! Reduce the closing rate if more than 100% of the open water 
-               ! would be removed.  Reduce the opening rate proportionately.
-               za   = athorn(ji,jj,0) * closing_gross(ji,jj) * rdt_ice
-               IF( za > epsi20 ) THEN
-                  zfac = MIN( 1._wp, ato_i(ji,jj) / za )
-                  closing_gross(ji,jj) = closing_gross(ji,jj) * zfac
-                  opning       (ji,jj) = opning       (ji,jj) * zfac
+               za   = ( opning(ji,jj) - athorn(ji,jj,0) * closing_gross(ji,jj) ) * rdt_ice
+               IF( za < 0._wp .AND. za > - ato_i(ji,jj) ) THEN  ! would lead to negative ato_i
+                  zfac = - ato_i(ji,jj) / za
+                  opning(ji,jj) = athorn(ji,jj,0) * closing_gross(ji,jj) - ato_i(ji,jj) * r1_rdtice 
+               ELSEIF( za > 0._wp .AND. za > ( asum(ji,jj) - ato_i(ji,jj) ) ) THEN  ! would lead to ato_i > asum
+                  zfac = ( asum(ji,jj) - ato_i(ji,jj) ) / za
+                  opning(ji,jj) = athorn(ji,jj,0) * closing_gross(ji,jj) + ( asum(ji,jj) - ato_i(ji,jj) ) * r1_rdtice 
                ENDIF
-
             END DO
          END DO
@@ -256,8 +229,7 @@
                DO ji = 1, jpi
                   za = athorn(ji,jj,jl) * closing_gross(ji,jj) * rdt_ice
-                  IF( za  >  epsi20 ) THEN
-                     zfac = MIN( 1._wp, a_i(ji,jj,jl) / za )
+                  IF( za  >  a_i(ji,jj,jl) ) THEN
+                     zfac = a_i(ji,jj,jl) / za
                      closing_gross(ji,jj) = closing_gross(ji,jj) * zfac
-                     opning       (ji,jj) = opning       (ji,jj) * zfac
                   ENDIF
                END DO
@@ -268,13 +240,11 @@
          !-----------------------------------------------------------------------------!
 
-         CALL lim_itd_me_ridgeshift( opning, closing_gross, msnow_mlt, esnow_mlt )
-
+         CALL lim_itd_me_ridgeshift( opning, closing_gross )
+
+         
          ! 3.4 Compute total area of ice plus open water after ridging.
          !-----------------------------------------------------------------------------!
          ! This is in general not equal to one because of divergence during transport
-         asum(:,:) = ato_i(:,:)
-         DO jl = 1, jpl
-            asum(:,:) = asum(:,:) + a_i(:,:,jl)
-         END DO
+         asum(:,:) = ato_i(:,:) + SUM( a_i, dim=3 )
 
          ! 3.5 Do we keep on iterating ???
@@ -284,13 +254,12 @@
 
          iterate_ridging = 0
-
          DO jj = 1, jpj
             DO ji = 1, jpi
-               IF (ABS(asum(ji,jj) - kamax ) < epsi10) THEN
+               IF( ABS( asum(ji,jj) - 1._wp ) < epsi10 ) THEN
                   closing_net(ji,jj) = 0._wp
                   opning     (ji,jj) = 0._wp
                ELSE
                   iterate_ridging    = 1
-                  divu_adv   (ji,jj) = ( kamax - asum(ji,jj) ) * r1_rdtice
+                  divu_adv   (ji,jj) = ( 1._wp - asum(ji,jj) ) * r1_rdtice
                   closing_net(ji,jj) = MAX( 0._wp, -divu_adv(ji,jj) )
                   opning     (ji,jj) = MAX( 0._wp,  divu_adv(ji,jj) )
@@ -309,60 +278,12 @@
 
          IF( iterate_ridging == 1 ) THEN
+            CALL lim_itd_me_ridgeprep
             IF( niter  >  nitermax ) THEN
                WRITE(numout,*) ' ALERTE : non-converging ridging scheme '
                WRITE(numout,*) ' niter, iterate_ridging ', niter, iterate_ridging
             ENDIF
-            CALL lim_itd_me_ridgeprep
          ENDIF
 
       END DO !! on the do while over iter
-
-      !-----------------------------------------------------------------------------!
-      ! 4) Ridging diagnostics
-      !-----------------------------------------------------------------------------!
-      ! Convert ridging rate diagnostics to correct units.
-      ! Update fresh water and heat fluxes due to snow melt.
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-
-            dardg1dt(ji,jj) = dardg1dt(ji,jj) * r1_rdtice
-            dardg2dt(ji,jj) = dardg2dt(ji,jj) * r1_rdtice
-            dvirdgdt(ji,jj) = dvirdgdt(ji,jj) * r1_rdtice
-            opening (ji,jj) = opening (ji,jj) * r1_rdtice
-
-            !-----------------------------------------------------------------------------!
-            ! 5) Heat, salt and freshwater fluxes
-            !-----------------------------------------------------------------------------!
-            wfx_snw(ji,jj) = wfx_snw(ji,jj) + msnow_mlt(ji,jj) * r1_rdtice     ! fresh water source for ocean
-            hfx_dyn(ji,jj) = hfx_dyn(ji,jj) + esnow_mlt(ji,jj) * r1_rdtice     ! heat sink for ocean (<0, W.m-2)
-
-         END DO
-      END DO
-
-      ! Check if there is a ridging error
-      IF( lwp ) THEN
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               IF( ABS( asum(ji,jj) - kamax)  >  epsi10 ) THEN   ! there is a bug
-                  WRITE(numout,*) ' '
-                  WRITE(numout,*) ' ALERTE : Ridging error: total area = ', asum(ji,jj)
-                  WRITE(numout,*) ' limitd_me '
-                  WRITE(numout,*) ' POINT : ', ji, jj
-                  WRITE(numout,*) ' jpl, a_i, athorn '
-                  WRITE(numout,*) 0, ato_i(ji,jj), athorn(ji,jj,0)
-                  DO jl = 1, jpl
-                     WRITE(numout,*) jl, a_i(ji,jj,jl), athorn(ji,jj,jl)
-                  END DO
-               ENDIF
-            END DO
-         END DO
-      END IF
-
-      ! Conservation check
-      IF ( con_i ) THEN
-         CALL lim_column_sum (jpl,   v_i, vt_i_final)
-         fieldid = ' v_i : limitd_me '
-         CALL lim_cons_check (vt_i_init, vt_i_final, 1.0e-6, fieldid) 
-      ENDIF
 
       CALL lim_var_agg( 1 ) 
@@ -410,9 +331,441 @@
       ENDIF  ! ln_limdyn=.true.
       !
-      CALL wrk_dealloc( jpi, jpj, closing_net, divu_adv, opning, closing_gross, msnow_mlt, esnow_mlt, vt_i_init, vt_i_final )
+      CALL wrk_dealloc( jpi, jpj, closing_net, divu_adv, opning, closing_gross )
       !
       IF( nn_timing == 1 )  CALL timing_stop('limitd_me')
    END SUBROUTINE lim_itd_me
 
+   SUBROUTINE lim_itd_me_ridgeprep
+      !!---------------------------------------------------------------------!
+      !!                ***  ROUTINE lim_itd_me_ridgeprep ***
+      !!
+      !! ** Purpose :   preparation for ridging and strength calculations
+      !!
+      !! ** Method  :   Compute the thickness distribution of the ice and open water 
+      !!              participating in ridging and of the resulting ridges.
+      !!---------------------------------------------------------------------!
+      INTEGER ::   ji,jj, jl    ! dummy loop indices
+      REAL(wp) ::   Gstari, astari, hrmean, zdummy   ! local scalar
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   Gsum      ! Gsum(n) = sum of areas in categories 0 to n
+      !------------------------------------------------------------------------------!
+
+      CALL wrk_alloc( jpi,jpj,jpl+2, Gsum, kkstart = -1 )
+
+      Gstari     = 1.0/rn_gstar    
+      astari     = 1.0/rn_astar    
+      aksum(:,:)    = 0.0
+      athorn(:,:,:) = 0.0
+      aridge(:,:,:) = 0.0
+      araft (:,:,:) = 0.0
+
+      ! Zero out categories with very small areas
+      CALL lim_var_zapsmall
+
+      ! Ice thickness needed for rafting
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               rswitch = MAX( 0._wp , SIGN( 1._wp, a_i(ji,jj,jl) - epsi20 ) )
+               ht_i(ji,jj,jl) = v_i (ji,jj,jl) / MAX( a_i(ji,jj,jl) , epsi20 ) * rswitch
+            END DO
+         END DO
+      END DO
+
+      !------------------------------------------------------------------------------!
+      ! 1) Participation function 
+      !------------------------------------------------------------------------------!
+
+      ! Compute total area of ice plus open water.
+      ! This is in general not equal to one because of divergence during transport
+      asum(:,:) = ato_i(:,:) + SUM( a_i, dim=3 )
+
+      ! Compute cumulative thickness distribution function
+      ! Compute the cumulative thickness distribution function Gsum,
+      ! where Gsum(n) is the fractional area in categories 0 to n.
+      ! initial value (in h = 0) equals open water area
+      Gsum(:,:,-1) = 0._wp
+      Gsum(:,:,0 ) = ato_i(:,:)
+      ! for each value of h, you have to add ice concentration then
+      DO jl = 1, jpl
+         Gsum(:,:,jl) = Gsum(:,:,jl-1) + a_i(:,:,jl)
+      END DO
+
+      ! Normalize the cumulative distribution to 1
+      DO jl = 0, jpl
+         Gsum(:,:,jl) = Gsum(:,:,jl) / asum(:,:)
+      END DO
+
+      ! 1.3 Compute participation function a(h) = b(h).g(h) (athorn)
+      !--------------------------------------------------------------------------------------------------
+      ! Compute the participation function athorn; this is analogous to
+      ! a(h) = b(h)g(h) as defined in Thorndike et al. (1975).
+      ! area lost from category n due to ridging/closing
+      ! athorn(n)   = total area lost due to ridging/closing
+      ! assume b(h) = (2/Gstar) * (1 - G(h)/Gstar). 
+      !
+      ! The expressions for athorn are found by integrating b(h)g(h) between
+      ! the category boundaries.
+      ! athorn is always >= 0 and SUM(athorn(0:jpl))=1
+      !-----------------------------------------------------------------
+
+      IF( nn_partfun == 0 ) THEN       !--- Linear formulation (Thorndike et al., 1975)
+         DO jl = 0, jpl    
+            DO jj = 1, jpj 
+               DO ji = 1, jpi
+                  IF    ( Gsum(ji,jj,jl)   < rn_gstar ) THEN
+                     athorn(ji,jj,jl) = Gstari * ( Gsum(ji,jj,jl) - Gsum(ji,jj,jl-1) ) * &
+                        &                        ( 2._wp - ( Gsum(ji,jj,jl-1) + Gsum(ji,jj,jl) ) * Gstari )
+                  ELSEIF( Gsum(ji,jj,jl-1) < rn_gstar ) THEN
+                     athorn(ji,jj,jl) = Gstari * ( rn_gstar       - Gsum(ji,jj,jl-1) ) *  &
+                        &                        ( 2._wp - ( Gsum(ji,jj,jl-1) + rn_gstar       ) * Gstari )
+                  ELSE
+                     athorn(ji,jj,jl) = 0._wp
+                  ENDIF
+               END DO
+            END DO
+         END DO
+
+      ELSE                             !--- Exponential, more stable formulation (Lipscomb et al, 2007)
+         !                        
+         zdummy = 1._wp / ( 1._wp - EXP(-astari) )        ! precompute exponential terms using Gsum as a work array
+         DO jl = -1, jpl
+            Gsum(:,:,jl) = EXP( -Gsum(:,:,jl) * astari ) * zdummy
+         END DO
+         DO jl = 0, jpl
+             athorn(:,:,jl) = Gsum(:,:,jl-1) - Gsum(:,:,jl)
+         END DO
+         !
+      ENDIF
+
+      IF( ln_rafting ) THEN      ! Ridging and rafting ice participation functions
+         !
+         DO jl = 1, jpl
+            DO jj = 1, jpj 
+               DO ji = 1, jpi
+                  zdummy           = TANH ( rn_craft * ( ht_i(ji,jj,jl) - rn_hraft ) )
+                  aridge(ji,jj,jl) = ( 1._wp + zdummy ) * 0.5_wp * athorn(ji,jj,jl)
+                  araft (ji,jj,jl) = ( 1._wp - zdummy ) * 0.5_wp * athorn(ji,jj,jl)
+               END DO
+            END DO
+         END DO
+
+      ELSE
+         !
+         DO jl = 1, jpl
+            aridge(:,:,jl) = athorn(:,:,jl)
+         END DO
+         !
+      ENDIF
+
+      !-----------------------------------------------------------------
+      ! 2) Transfer function
+      !-----------------------------------------------------------------
+      ! Compute max and min ridged ice thickness for each ridging category.
+      ! Assume ridged ice is uniformly distributed between hrmin and hrmax.
+      ! 
+      ! This parameterization is a modified version of Hibler (1980).
+      ! The mean ridging thickness, hrmean, is proportional to hi^(0.5)
+      !  and for very thick ridging ice must be >= krdgmin*hi
+      !
+      ! The minimum ridging thickness, hrmin, is equal to 2*hi 
+      !  (i.e., rafting) and for very thick ridging ice is
+      !  constrained by hrmin <= (hrmean + hi)/2.
+      ! 
+      ! The maximum ridging thickness, hrmax, is determined by
+      !  hrmean and hrmin.
+      !
+      ! These modifications have the effect of reducing the ice strength
+      ! (relative to the Hibler formulation) when very thick ice is
+      ! ridging.
+      !
+      ! aksum = net area removed/ total area removed
+      ! where total area removed = area of ice that ridges
+      !         net area removed = total area removed - area of new ridges
+      !-----------------------------------------------------------------
+
+      aksum(:,:) = athorn(:,:,0)
+      ! Transfer function
+      DO jl = 1, jpl !all categories have a specific transfer function
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               
+               IF( athorn(ji,jj,jl) > 0._wp ) THEN
+                  hrmean          = MAX( SQRT( rn_hstar * ht_i(ji,jj,jl) ), ht_i(ji,jj,jl) * krdgmin )
+                  hrmin(ji,jj,jl) = MIN( 2._wp * ht_i(ji,jj,jl), 0.5_wp * ( hrmean + ht_i(ji,jj,jl) ) )
+                  hrmax(ji,jj,jl) = 2._wp * hrmean - hrmin(ji,jj,jl)
+                  hraft(ji,jj,jl) = ht_i(ji,jj,jl) / kraft
+                  krdg(ji,jj,jl)  = ht_i(ji,jj,jl) / MAX( hrmean, epsi20 )
+
+                  ! Normalization factor : aksum, ensures mass conservation
+                  aksum(ji,jj) = aksum(ji,jj) + aridge(ji,jj,jl) * ( 1._wp - krdg(ji,jj,jl) )    &
+                     &                        + araft (ji,jj,jl) * ( 1._wp - kraft          )
+
+               ELSE
+                  hrmin(ji,jj,jl)  = 0._wp 
+                  hrmax(ji,jj,jl)  = 0._wp 
+                  hraft(ji,jj,jl)  = 0._wp 
+                  krdg (ji,jj,jl)  = 1._wp
+               ENDIF
+
+            END DO
+         END DO
+      END DO
+      !
+      CALL wrk_dealloc( jpi,jpj,jpl+2, Gsum, kkstart = -1 )
+      !
+   END SUBROUTINE lim_itd_me_ridgeprep
+
+
+   SUBROUTINE lim_itd_me_ridgeshift( opning, closing_gross )
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE lim_itd_me_icestrength ***
+      !!
+      !! ** Purpose :   shift ridging ice among thickness categories of ice thickness
+      !!
+      !! ** Method  :   Remove area, volume, and energy from each ridging category
+      !!              and add to thicker ice categories.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   opning         ! rate of opening due to divergence/shear
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   closing_gross  ! rate at which area removed, excluding area of new ridges
+      !
+      CHARACTER (len=80) ::   fieldid   ! field identifier
+      !
+      INTEGER ::   ji, jj, jl, jl1, jl2, jk   ! dummy loop indices
+      INTEGER ::   ij                ! horizontal index, combines i and j loops
+      INTEGER ::   icells            ! number of cells with a_i > puny
+      REAL(wp) ::   hL, hR, farea    ! left and right limits of integration
+
+      INTEGER , POINTER, DIMENSION(:) ::   indxi, indxj   ! compressed indices
+      REAL(wp), POINTER, DIMENSION(:) ::   zswitch, fvol   ! new ridge volume going to n2
+
+      REAL(wp), POINTER, DIMENSION(:) ::   afrac            ! fraction of category area ridged 
+      REAL(wp), POINTER, DIMENSION(:) ::   ardg1 , ardg2    ! area of ice ridged & new ridges
+      REAL(wp), POINTER, DIMENSION(:) ::   vsrdg , esrdg    ! snow volume & energy of ridging ice
+      REAL(wp), POINTER, DIMENSION(:) ::   dhr   , dhr2     ! hrmax - hrmin  &  hrmax^2 - hrmin^2
+
+      REAL(wp), POINTER, DIMENSION(:) ::   vrdg1   ! volume of ice ridged
+      REAL(wp), POINTER, DIMENSION(:) ::   vrdg2   ! volume of new ridges
+      REAL(wp), POINTER, DIMENSION(:) ::   vsw     ! volume of seawater trapped into ridges
+      REAL(wp), POINTER, DIMENSION(:) ::   srdg1   ! sal*volume of ice ridged
+      REAL(wp), POINTER, DIMENSION(:) ::   srdg2   ! sal*volume of new ridges
+      REAL(wp), POINTER, DIMENSION(:) ::   smsw    ! sal*volume of water trapped into ridges
+      REAL(wp), POINTER, DIMENSION(:) ::   oirdg1, oirdg2   ! ice age of ice ridged
+
+      REAL(wp), POINTER, DIMENSION(:) ::   afrft            ! fraction of category area rafted
+      REAL(wp), POINTER, DIMENSION(:) ::   arft1 , arft2    ! area of ice rafted and new rafted zone
+      REAL(wp), POINTER, DIMENSION(:) ::   virft , vsrft    ! ice & snow volume of rafting ice
+      REAL(wp), POINTER, DIMENSION(:) ::   esrft , smrft    ! snow energy & salinity of rafting ice
+      REAL(wp), POINTER, DIMENSION(:) ::   oirft1, oirft2   ! ice age of ice rafted
+
+      REAL(wp), POINTER, DIMENSION(:,:) ::   eirft      ! ice energy of rafting ice
+      REAL(wp), POINTER, DIMENSION(:,:) ::   erdg1      ! enth*volume of ice ridged
+      REAL(wp), POINTER, DIMENSION(:,:) ::   erdg2      ! enth*volume of new ridges
+      REAL(wp), POINTER, DIMENSION(:,:) ::   ersw       ! enth of water trapped into ridges
+      !!----------------------------------------------------------------------
+
+      CALL wrk_alloc( jpij,        indxi, indxj )
+      CALL wrk_alloc( jpij,        zswitch, fvol )
+      CALL wrk_alloc( jpij,        afrac, ardg1, ardg2, vsrdg, esrdg, dhr, dhr2 )
+      CALL wrk_alloc( jpij,        vrdg1, vrdg2, vsw  , srdg1, srdg2, smsw, oirdg1, oirdg2 )
+      CALL wrk_alloc( jpij,        afrft, arft1, arft2, virft, vsrft, esrft, smrft, oirft1, oirft2 )
+      CALL wrk_alloc( jpij,nlay_i, eirft, erdg1, erdg2, ersw )
+
+      !-------------------------------------------------------------------------------
+      ! 1) Compute change in open water area due to closing and opening.
+      !-------------------------------------------------------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ato_i(ji,jj) = MAX( 0._wp, ato_i(ji,jj) +  &
+               &                     ( opning(ji,jj) - athorn(ji,jj,0) * closing_gross(ji,jj) ) * rdt_ice )
+         END DO
+      END DO
+
+      !-----------------------------------------------------------------
+      ! 3) Pump everything from ice which is being ridged / rafted
+      !-----------------------------------------------------------------
+      ! Compute the area, volume, and energy of ice ridging in each
+      ! category, along with the area of the resulting ridge.
+
+      DO jl1 = 1, jpl !jl1 describes the ridging category
+
+         !------------------------------------------------
+         ! 3.1) Identify grid cells with nonzero ridging
+         !------------------------------------------------
+         icells = 0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( athorn(ji,jj,jl1) > 0._wp .AND. closing_gross(ji,jj) > 0._wp ) THEN
+                  icells = icells + 1
+                  indxi(icells) = ji
+                  indxj(icells) = jj
+               ENDIF
+            END DO
+         END DO
+
+         DO ij = 1, icells
+            ji = indxi(ij) ; jj = indxj(ij)
+
+            !--------------------------------------------------------------------
+            ! 3.2) Compute area of ridging ice (ardg1) and of new ridge (ardg2)
+            !--------------------------------------------------------------------
+            ardg1(ij) = aridge(ji,jj,jl1) * closing_gross(ji,jj) * rdt_ice
+            arft1(ij) = araft (ji,jj,jl1) * closing_gross(ji,jj) * rdt_ice
+
+            !---------------------------------------------------------------
+            ! 3.3) Compute ridging /rafting fractions, make sure afrac <=1 
+            !---------------------------------------------------------------
+            afrac(ij) = ardg1(ij) / a_i(ji,jj,jl1) !ridging
+            afrft(ij) = arft1(ij) / a_i(ji,jj,jl1) !rafting
+            ardg2(ij) = ardg1(ij) * krdg(ji,jj,jl1)
+            arft2(ij) = arft1(ij) * kraft
+
+            !--------------------------------------------------------------------------
+            ! 3.4) Subtract area, volume, and energy from ridging 
+            !     / rafting category n1.
+            !--------------------------------------------------------------------------
+            vrdg1(ij) = v_i(ji,jj,jl1) * afrac(ij)
+            vrdg2(ij) = vrdg1(ij) * ( 1. + rn_por_rdg )
+            vsw  (ij) = vrdg1(ij) * rn_por_rdg
+
+            vsrdg (ij) = v_s  (ji,jj,  jl1) * afrac(ij)
+            esrdg (ij) = e_s  (ji,jj,1,jl1) * afrac(ij)
+            srdg1 (ij) = smv_i(ji,jj,  jl1) * afrac(ij)
+            oirdg1(ij) = oa_i (ji,jj,  jl1) * afrac(ij)
+            oirdg2(ij) = oa_i (ji,jj,  jl1) * afrac(ij) * krdg(ji,jj,jl1) 
+
+            ! rafting volumes, heat contents ...
+            virft (ij) = v_i  (ji,jj,  jl1) * afrft(ij)
+            vsrft (ij) = v_s  (ji,jj,  jl1) * afrft(ij)
+            esrft (ij) = e_s  (ji,jj,1,jl1) * afrft(ij)
+            smrft (ij) = smv_i(ji,jj,  jl1) * afrft(ij) 
+            oirft1(ij) = oa_i (ji,jj,  jl1) * afrft(ij) 
+            oirft2(ij) = oa_i (ji,jj,  jl1) * afrft(ij) * kraft 
+
+            !-----------------------------------------------------------------
+            ! 3.5) Compute properties of new ridges
+            !-----------------------------------------------------------------
+            smsw(ij)  = vsw(ij) * sss_m(ji,jj)                   ! salt content of seawater frozen in voids
+            srdg2(ij) = srdg1(ij) + smsw(ij)                     ! salt content of new ridge
+            
+            sfx_dyn(ji,jj) = sfx_dyn(ji,jj) - smsw(ij) * rhoic * r1_rdtice
+            wfx_dyn(ji,jj) = wfx_dyn(ji,jj) - vsw (ij) * rhoic * r1_rdtice   ! increase in ice volume due to seawater frozen in voids
+            
+            !------------------------------------------            
+            ! 3.7 Put the snow somewhere in the ocean
+            !------------------------------------------            
+            !  Place part of the snow lost by ridging into the ocean. 
+            !  Note that esrdg > 0; the ocean must cool to melt snow.
+            !  If the ocean temp = Tf already, new ice must grow.
+            !  During the next time step, thermo_rates will determine whether
+            !  the ocean cools or new ice grows.
+            wfx_snw(ji,jj) = wfx_snw(ji,jj) + ( rhosn * vsrdg(ij) * ( 1._wp - rn_fsnowrdg )   & 
+               &                              + rhosn * vsrft(ij) * ( 1._wp - rn_fsnowrft ) ) * r1_rdtice  ! fresh water source for ocean
+
+            hfx_dyn(ji,jj) = hfx_dyn(ji,jj) + ( - esrdg(ij) * ( 1._wp - rn_fsnowrdg )         & 
+               &                                - esrft(ij) * ( 1._wp - rn_fsnowrft ) ) * r1_rdtice        ! heat sink for ocean (<0, W.m-2)
+
+            !-----------------------------------------------------------------
+            ! 3.8 Compute quantities used to apportion ice among categories
+            ! in the n2 loop below
+            !-----------------------------------------------------------------
+            dhr (ij) = 1._wp / ( hrmax(ji,jj,jl1)                    - hrmin(ji,jj,jl1)                    )
+            dhr2(ij) = 1._wp / ( hrmax(ji,jj,jl1) * hrmax(ji,jj,jl1) - hrmin(ji,jj,jl1) * hrmin(ji,jj,jl1) )
+
+
+            ! update jl1 (removing ridged/rafted area)
+            a_i  (ji,jj,  jl1) = a_i  (ji,jj,  jl1) - ardg1 (ij) - arft1 (ij)
+            v_i  (ji,jj,  jl1) = v_i  (ji,jj,  jl1) - vrdg1 (ij) - virft (ij)
+            v_s  (ji,jj,  jl1) = v_s  (ji,jj,  jl1) - vsrdg (ij) - vsrft (ij)
+            e_s  (ji,jj,1,jl1) = e_s  (ji,jj,1,jl1) - esrdg (ij) - esrft (ij)
+            smv_i(ji,jj,  jl1) = smv_i(ji,jj,  jl1) - srdg1 (ij) - smrft (ij)
+            oa_i (ji,jj,  jl1) = oa_i (ji,jj,  jl1) - oirdg1(ij) - oirft1(ij)
+
+         END DO
+
+         !--------------------------------------------------------------------
+         ! 3.9 Compute ridging ice enthalpy, remove it from ridging ice and
+         !      compute ridged ice enthalpy 
+         !--------------------------------------------------------------------
+         DO jk = 1, nlay_i
+            DO ij = 1, icells
+               ji = indxi(ij) ; jj = indxj(ij)
+               ! heat content of ridged ice
+               erdg1(ij,jk) = e_i(ji,jj,jk,jl1) * afrac(ij) 
+               eirft(ij,jk) = e_i(ji,jj,jk,jl1) * afrft(ij)               
+               
+               ! enthalpy of the trapped seawater (J/m2, >0)
+               ! clem: if sst>0, then ersw <0 (is that possible?)
+               ersw(ij,jk)  = - rhoic * vsw(ij) * rcp * sst_m(ji,jj) * r1_nlay_i
+
+               ! heat flux to the ocean
+               hfx_dyn(ji,jj) = hfx_dyn(ji,jj) + ersw(ij,jk) * r1_rdtice  ! > 0 [W.m-2] ocean->ice flux 
+
+               ! it is added to sea ice because the sign convention is the opposite of the sign convention for the ocean
+               erdg2(ij,jk) = erdg1(ij,jk) + ersw(ij,jk)
+
+               ! update jl1
+               e_i  (ji,jj,jk,jl1) = e_i(ji,jj,jk,jl1) - erdg1(ij,jk) - eirft(ij,jk)
+
+            END DO
+         END DO
+
+         !-------------------------------------------------------------------------------
+         ! 4) Add area, volume, and energy of new ridge to each category jl2
+         !-------------------------------------------------------------------------------
+         DO jl2  = 1, jpl 
+            ! over categories to which ridged/rafted ice is transferred
+            DO ij = 1, icells
+               ji = indxi(ij) ; jj = indxj(ij)
+
+               ! Compute the fraction of ridged ice area and volume going to thickness category jl2.
+               IF( hrmin(ji,jj,jl1) <= hi_max(jl2) .AND. hrmax(ji,jj,jl1) > hi_max(jl2-1) ) THEN
+                  hL = MAX( hrmin(ji,jj,jl1), hi_max(jl2-1) )
+                  hR = MIN( hrmax(ji,jj,jl1), hi_max(jl2)   )
+                  farea    = ( hR      - hL      ) * dhr(ij) 
+                  fvol(ij) = ( hR * hR - hL * hL ) * dhr2(ij)
+               ELSE
+                  farea    = 0._wp 
+                  fvol(ij) = 0._wp                  
+               ENDIF
+
+               ! Compute the fraction of rafted ice area and volume going to thickness category jl2
+               IF( hraft(ji,jj,jl1) <= hi_max(jl2) .AND. hraft(ji,jj,jl1) >  hi_max(jl2-1) ) THEN
+                  zswitch(ij) = 1._wp
+               ELSE
+                  zswitch(ij) = 0._wp                  
+               ENDIF
+
+               a_i  (ji,jj  ,jl2) = a_i  (ji,jj  ,jl2) + ( ardg2 (ij) * farea    + arft2 (ij) * zswitch(ij) )
+               oa_i (ji,jj  ,jl2) = oa_i (ji,jj  ,jl2) + ( oirdg2(ij) * farea    + oirft2(ij) * zswitch(ij) )
+               v_i  (ji,jj  ,jl2) = v_i  (ji,jj  ,jl2) + ( vrdg2 (ij) * fvol(ij) + virft (ij) * zswitch(ij) )
+               smv_i(ji,jj  ,jl2) = smv_i(ji,jj  ,jl2) + ( srdg2 (ij) * fvol(ij) + smrft (ij) * zswitch(ij) )
+               v_s  (ji,jj  ,jl2) = v_s  (ji,jj  ,jl2) + ( vsrdg (ij) * rn_fsnowrdg * fvol(ij)  +  &
+                  &                                        vsrft (ij) * rn_fsnowrft * zswitch(ij) )
+               e_s  (ji,jj,1,jl2) = e_s  (ji,jj,1,jl2) + ( esrdg (ij) * rn_fsnowrdg * fvol(ij)  +  &
+                  &                                        esrft (ij) * rn_fsnowrft * zswitch(ij) )
+
+            END DO
+
+            ! Transfer ice energy to category jl2 by ridging
+            DO jk = 1, nlay_i
+               DO ij = 1, icells
+                  ji = indxi(ij) ; jj = indxj(ij)
+                  e_i(ji,jj,jk,jl2) = e_i(ji,jj,jk,jl2) + erdg2(ij,jk) * fvol(ij) + eirft(ij,jk) * zswitch(ij)                  
+               END DO
+            END DO
+            !
+         END DO ! jl2
+         
+      END DO ! jl1 (deforming categories)
+
+      !
+      CALL wrk_dealloc( jpij,        indxi, indxj )
+      CALL wrk_dealloc( jpij,        zswitch, fvol )
+      CALL wrk_dealloc( jpij,        afrac, ardg1, ardg2, vsrdg, esrdg, dhr, dhr2 )
+      CALL wrk_dealloc( jpij,        vrdg1, vrdg2, vsw  , srdg1, srdg2, smsw, oirdg1, oirdg2 )
+      CALL wrk_dealloc( jpij,        afrft, arft1, arft2, virft, vsrft, esrft, smrft, oirft1, oirft2 )
+      CALL wrk_dealloc( jpij,nlay_i, eirft, erdg1, erdg2, ersw )
+      !
+   END SUBROUTINE lim_itd_me_ridgeshift
 
    SUBROUTINE lim_itd_me_icestrength( kstrngth )
@@ -434,5 +787,5 @@
       INTEGER             ::   ksmooth     ! smoothing the resistance to deformation
       INTEGER             ::   numts_rm    ! number of time steps for the P smoothing
-      REAL(wp)            ::   zhi, zp, z1_3  ! local scalars
+      REAL(wp)            ::   zp, z1_3    ! local scalars
       REAL(wp), POINTER, DIMENSION(:,:) ::   zworka   ! temporary array used here
       !!----------------------------------------------------------------------
@@ -459,21 +812,22 @@
                DO ji = 1, jpi
                   !
-                  IF( a_i(ji,jj,jl) > epsi10 .AND. athorn(ji,jj,jl) > 0._wp ) THEN
-                     zhi = v_i(ji,jj,jl) / a_i(ji,jj,jl)
+                  IF( athorn(ji,jj,jl) > 0._wp ) THEN
                      !----------------------------
                      ! PE loss from deforming ice
                      !----------------------------
-                     strength(ji,jj) = strength(ji,jj) - athorn(ji,jj,jl) * zhi * zhi
+                     strength(ji,jj) = strength(ji,jj) - athorn(ji,jj,jl) * ht_i(ji,jj,jl) * ht_i(ji,jj,jl)
 
                      !--------------------------
                      ! PE gain from rafting ice
                      !--------------------------
-                     strength(ji,jj) = strength(ji,jj) + 2._wp * araft(ji,jj,jl) * zhi * zhi
+                     strength(ji,jj) = strength(ji,jj) + 2._wp * araft(ji,jj,jl) * ht_i(ji,jj,jl) * ht_i(ji,jj,jl)
 
                      !----------------------------
                      ! PE gain from ridging ice
                      !----------------------------
-                     strength(ji,jj) = strength(ji,jj) + aridge(ji,jj,jl) / krdg(ji,jj,jl)     &
-                        * z1_3 * ( hrmax(ji,jj,jl)**2 + hrmin(ji,jj,jl)**2 +  hrmax(ji,jj,jl) * hrmin(ji,jj,jl) )  
+                     strength(ji,jj) = strength(ji,jj) + aridge(ji,jj,jl) * krdg(ji,jj,jl) * z1_3 *  &
+                        &                              ( hrmax(ji,jj,jl) * hrmax(ji,jj,jl) +         &
+                        &                                hrmin(ji,jj,jl) * hrmin(ji,jj,jl) +         &
+                        &                                hrmax(ji,jj,jl) * hrmin(ji,jj,jl) )  
                         !!(a**3-b**3)/(a-b) = a*a+ab+b*b                      
                   ENDIF
@@ -497,5 +851,4 @@
          !
       ENDIF                     ! kstrngth
-
       !
       !------------------------------------------------------------------------------!
@@ -503,7 +856,5 @@
       !------------------------------------------------------------------------------!
       ! CAN BE REMOVED
-      !
       IF( ln_icestr_bvf ) THEN
-
          DO jj = 1, jpj
             DO ji = 1, jpi
@@ -511,7 +862,5 @@
             END DO
          END DO
-
       ENDIF
-
       !
       !------------------------------------------------------------------------------!
@@ -558,5 +907,4 @@
       IF ( ksmooth == 2 ) THEN
 
-
          CALL lbc_lnk( strength, 'T', 1. )
 
@@ -565,6 +913,6 @@
                IF ( ( asum(ji,jj) - ato_i(ji,jj) ) > 0._wp) THEN 
                   numts_rm = 1 ! number of time steps for the running mean
-                  IF ( strp1(ji,jj) > 0.0 ) numts_rm = numts_rm + 1
-                  IF ( strp2(ji,jj) > 0.0 ) numts_rm = numts_rm + 1
+                  IF ( strp1(ji,jj) > 0._wp ) numts_rm = numts_rm + 1
+                  IF ( strp2(ji,jj) > 0._wp ) numts_rm = numts_rm + 1
                   zp = ( strength(ji,jj) + strp1(ji,jj) + strp2(ji,jj) ) / numts_rm
                   strp2(ji,jj) = strp1(ji,jj)
@@ -583,616 +931,4 @@
       !
    END SUBROUTINE lim_itd_me_icestrength
-
-
-   SUBROUTINE lim_itd_me_ridgeprep
-      !!---------------------------------------------------------------------!
-      !!                ***  ROUTINE lim_itd_me_ridgeprep ***
-      !!
-      !! ** Purpose :   preparation for ridging and strength calculations
-      !!
-      !! ** Method  :   Compute the thickness distribution of the ice and open water 
-      !!              participating in ridging and of the resulting ridges.
-      !!---------------------------------------------------------------------!
-      INTEGER ::   ji,jj, jl    ! dummy loop indices
-      REAL(wp) ::   Gstari, astari, zhi, hrmean, zdummy   ! local scalar
-      REAL(wp), POINTER, DIMENSION(:,:)   ::   zworka    ! temporary array used here
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   Gsum      ! Gsum(n) = sum of areas in categories 0 to n
-      !------------------------------------------------------------------------------!
-
-      CALL wrk_alloc( jpi,jpj, zworka )
-      CALL wrk_alloc( jpi,jpj,jpl+2, Gsum, kkstart = -1 )
-
-      Gstari     = 1.0/rn_gstar    
-      astari     = 1.0/rn_astar    
-      aksum(:,:)    = 0.0
-      athorn(:,:,:) = 0.0
-      aridge(:,:,:) = 0.0
-      araft (:,:,:) = 0.0
-      hrmin(:,:,:)  = 0.0 
-      hrmax(:,:,:)  = 0.0 
-      hraft(:,:,:)  = 0.0 
-      krdg (:,:,:)  = 1.0
-
-      !     ! Zero out categories with very small areas
-      CALL lim_var_zapsmall
-
-      !------------------------------------------------------------------------------!
-      ! 1) Participation function 
-      !------------------------------------------------------------------------------!
-
-      ! Compute total area of ice plus open water.
-      ! This is in general not equal to one because of divergence during transport
-      asum(:,:) = ato_i(:,:)
-      DO jl = 1, jpl
-         asum(:,:) = asum(:,:) + a_i(:,:,jl)
-      END DO
-
-      ! Compute cumulative thickness distribution function
-      ! Compute the cumulative thickness distribution function Gsum,
-      ! where Gsum(n) is the fractional area in categories 0 to n.
-      ! initial value (in h = 0) equals open water area
-
-      Gsum(:,:,-1) = 0._wp
-      Gsum(:,:,0 ) = ato_i(:,:)
-
-      ! for each value of h, you have to add ice concentration then
-      DO jl = 1, jpl
-         Gsum(:,:,jl) = Gsum(:,:,jl-1) + a_i(:,:,jl)
-      END DO
-
-      ! Normalize the cumulative distribution to 1
-      zworka(:,:) = 1._wp / Gsum(:,:,jpl)
-      DO jl = 0, jpl
-         Gsum(:,:,jl) = Gsum(:,:,jl) * zworka(:,:)
-      END DO
-
-      ! 1.3 Compute participation function a(h) = b(h).g(h) (athorn)
-      !--------------------------------------------------------------------------------------------------
-      ! Compute the participation function athorn; this is analogous to
-      ! a(h) = b(h)g(h) as defined in Thorndike et al. (1975).
-      ! area lost from category n due to ridging/closing
-      ! athorn(n)   = total area lost due to ridging/closing
-      ! assume b(h) = (2/Gstar) * (1 - G(h)/Gstar). 
-      !
-      ! The expressions for athorn are found by integrating b(h)g(h) between
-      ! the category boundaries.
-      !-----------------------------------------------------------------
-
-      IF( nn_partfun == 0 ) THEN       !--- Linear formulation (Thorndike et al., 1975)
-         DO jl = 0, jpl    
-            DO jj = 1, jpj 
-               DO ji = 1, jpi
-                  IF( Gsum(ji,jj,jl) < rn_gstar) THEN
-                     athorn(ji,jj,jl) = Gstari * ( Gsum(ji,jj,jl) - Gsum(ji,jj,jl-1) ) * &
-                        &                        ( 2.0 - (Gsum(ji,jj,jl-1) + Gsum(ji,jj,jl) ) * Gstari )
-                  ELSEIF (Gsum(ji,jj,jl-1) < rn_gstar) THEN
-                     athorn(ji,jj,jl) = Gstari * ( rn_gstar - Gsum(ji,jj,jl-1) ) *  &
-                        &                        ( 2.0 - ( Gsum(ji,jj,jl-1) + rn_gstar ) * Gstari )
-                  ELSE
-                     athorn(ji,jj,jl) = 0.0
-                  ENDIF
-               END DO
-            END DO
-         END DO
-
-      ELSE                             !--- Exponential, more stable formulation (Lipscomb et al, 2007)
-         !                        
-         zdummy = 1._wp / ( 1._wp - EXP(-astari) )        ! precompute exponential terms using Gsum as a work array
-         DO jl = -1, jpl
-            Gsum(:,:,jl) = EXP( -Gsum(:,:,jl) * astari ) * zdummy
-         END DO
-         DO jl = 0, jpl
-             athorn(:,:,jl) = Gsum(:,:,jl-1) - Gsum(:,:,jl)
-         END DO
-         !
-      ENDIF
-
-      IF( ln_rafting ) THEN      ! Ridging and rafting ice participation functions
-         !
-         DO jl = 1, jpl
-            DO jj = 1, jpj 
-               DO ji = 1, jpi
-                  IF ( athorn(ji,jj,jl) > 0._wp ) THEN
-!!gm  TANH( -X ) = - TANH( X )  so can be computed only 1 time....
-                     aridge(ji,jj,jl) = ( TANH (  rn_craft * ( ht_i(ji,jj,jl) - rn_hraft ) ) + 1.0 ) * 0.5 * athorn(ji,jj,jl)
-                     araft (ji,jj,jl) = ( TANH ( -rn_craft * ( ht_i(ji,jj,jl) - rn_hraft ) ) + 1.0 ) * 0.5 * athorn(ji,jj,jl)
-                     IF ( araft(ji,jj,jl) < epsi06 )   araft(ji,jj,jl)  = 0._wp
-                     aridge(ji,jj,jl) = MAX( athorn(ji,jj,jl) - araft(ji,jj,jl), 0.0 )
-                  ENDIF
-               END DO
-            END DO
-         END DO
-
-      ELSE
-         !
-         DO jl = 1, jpl
-            aridge(:,:,jl) = athorn(:,:,jl)
-         END DO
-         !
-      ENDIF
-
-      IF( ln_rafting ) THEN
-
-         IF( MAXVAL(aridge + araft - athorn(:,:,1:jpl)) > epsi10 .AND. lwp ) THEN
-            DO jl = 1, jpl
-               DO jj = 1, jpj
-                  DO ji = 1, jpi
-                     IF ( aridge(ji,jj,jl) + araft(ji,jj,jl) - athorn(ji,jj,jl) > epsi10 ) THEN
-                        WRITE(numout,*) ' ALERTE 96 : wrong participation function ... '
-                        WRITE(numout,*) ' ji, jj, jl : ', ji, jj, jl
-                        WRITE(numout,*) ' lat, lon   : ', gphit(ji,jj), glamt(ji,jj)
-                        WRITE(numout,*) ' aridge     : ', aridge(ji,jj,1:jpl)
-                        WRITE(numout,*) ' araft      : ', araft(ji,jj,1:jpl)
-                        WRITE(numout,*) ' athorn     : ', athorn(ji,jj,1:jpl)
-                     ENDIF
-                  END DO
-               END DO
-            END DO
-         ENDIF
-
-      ENDIF
-
-      !-----------------------------------------------------------------
-      ! 2) Transfer function
-      !-----------------------------------------------------------------
-      ! Compute max and min ridged ice thickness for each ridging category.
-      ! Assume ridged ice is uniformly distributed between hrmin and hrmax.
-      ! 
-      ! This parameterization is a modified version of Hibler (1980).
-      ! The mean ridging thickness, hrmean, is proportional to hi^(0.5)
-      !  and for very thick ridging ice must be >= krdgmin*hi
-      !
-      ! The minimum ridging thickness, hrmin, is equal to 2*hi 
-      !  (i.e., rafting) and for very thick ridging ice is
-      !  constrained by hrmin <= (hrmean + hi)/2.
-      ! 
-      ! The maximum ridging thickness, hrmax, is determined by
-      !  hrmean and hrmin.
-      !
-      ! These modifications have the effect of reducing the ice strength
-      ! (relative to the Hibler formulation) when very thick ice is
-      ! ridging.
-      !
-      ! aksum = net area removed/ total area removed
-      ! where total area removed = area of ice that ridges
-      !         net area removed = total area removed - area of new ridges
-      !-----------------------------------------------------------------
-
-      ! Transfer function
-      DO jl = 1, jpl !all categories have a specific transfer function
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-
-               IF (a_i(ji,jj,jl) > epsi10 .AND. athorn(ji,jj,jl) > 0.0 ) THEN
-                  zhi = v_i(ji,jj,jl) / a_i(ji,jj,jl)
-                  hrmean          = MAX(SQRT(rn_hstar*zhi), zhi*krdgmin)
-                  hrmin(ji,jj,jl) = MIN(2.0*zhi, 0.5*(hrmean + zhi))
-                  hrmax(ji,jj,jl) = 2.0*hrmean - hrmin(ji,jj,jl)
-                  hraft(ji,jj,jl) = kraft*zhi
-                  krdg(ji,jj,jl)  = hrmean / zhi
-               ELSE
-                  hraft(ji,jj,jl) = 0.0
-                  hrmin(ji,jj,jl) = 0.0 
-                  hrmax(ji,jj,jl) = 0.0 
-                  krdg (ji,jj,jl) = 1.0
-               ENDIF
-
-            END DO
-         END DO
-      END DO
-
-      ! Normalization factor : aksum, ensures mass conservation
-      aksum(:,:) = athorn(:,:,0)
-      DO jl = 1, jpl 
-         aksum(:,:)    = aksum(:,:) + aridge(:,:,jl) * ( 1._wp - 1._wp / krdg(:,:,jl) )    &
-            &                       + araft (:,:,jl) * ( 1._wp - 1._wp / kraft        )
-      END DO
-      !
-      CALL wrk_dealloc( jpi,jpj, zworka )
-      CALL wrk_dealloc( jpi,jpj,jpl+2, Gsum, kkstart = -1 )
-      !
-   END SUBROUTINE lim_itd_me_ridgeprep
-
-
-   SUBROUTINE lim_itd_me_ridgeshift( opning, closing_gross, msnow_mlt, esnow_mlt )
-      !!----------------------------------------------------------------------
-      !!                ***  ROUTINE lim_itd_me_icestrength ***
-      !!
-      !! ** Purpose :   shift ridging ice among thickness categories of ice thickness
-      !!
-      !! ** Method  :   Remove area, volume, and energy from each ridging category
-      !!              and add to thicker ice categories.
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   opning         ! rate of opening due to divergence/shear
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   closing_gross  ! rate at which area removed, excluding area of new ridges
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   msnow_mlt      ! mass of snow added to ocean (kg m-2)
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   esnow_mlt      ! energy needed to melt snow in ocean (J m-2)
-      !
-      CHARACTER (len=80) ::   fieldid   ! field identifier
-      LOGICAL, PARAMETER ::   l_conservation_check = .true.  ! if true, check conservation (useful for debugging)
-      !
-      INTEGER ::   ji, jj, jl, jl1, jl2, jk   ! dummy loop indices
-      INTEGER ::   ij                ! horizontal index, combines i and j loops
-      INTEGER ::   icells            ! number of cells with aicen > puny
-      REAL(wp) ::   hL, hR, farea, ztmelts    ! left and right limits of integration
-
-      INTEGER , POINTER, DIMENSION(:) ::   indxi, indxj   ! compressed indices
-
-      REAL(wp), POINTER, DIMENSION(:,:) ::   vice_init, vice_final   ! ice volume summed over categories
-      REAL(wp), POINTER, DIMENSION(:,:) ::   eice_init, eice_final   ! ice energy summed over layers
-
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   aicen_init, vicen_init   ! ice  area    & volume before ridging
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   vsnwn_init, esnwn_init   ! snow volume  & energy before ridging
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   smv_i_init, oa_i_init    ! ice salinity & age    before ridging
-
-      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   eicen_init        ! ice energy before ridging
-
-      REAL(wp), POINTER, DIMENSION(:,:) ::   afrac , fvol     ! fraction of category area ridged & new ridge volume going to n2
-      REAL(wp), POINTER, DIMENSION(:,:) ::   ardg1 , ardg2    ! area of ice ridged & new ridges
-      REAL(wp), POINTER, DIMENSION(:,:) ::   vsrdg , esrdg    ! snow volume & energy of ridging ice
-      REAL(wp), POINTER, DIMENSION(:,:) ::   dhr   , dhr2     ! hrmax - hrmin  &  hrmax^2 - hrmin^2
-
-      REAL(wp), POINTER, DIMENSION(:,:) ::   vrdg1   ! volume of ice ridged
-      REAL(wp), POINTER, DIMENSION(:,:) ::   vrdg2   ! volume of new ridges
-      REAL(wp), POINTER, DIMENSION(:,:) ::   vsw     ! volume of seawater trapped into ridges
-      REAL(wp), POINTER, DIMENSION(:,:) ::   srdg1   ! sal*volume of ice ridged
-      REAL(wp), POINTER, DIMENSION(:,:) ::   srdg2   ! sal*volume of new ridges
-      REAL(wp), POINTER, DIMENSION(:,:) ::   smsw    ! sal*volume of water trapped into ridges
-      REAL(wp), POINTER, DIMENSION(:,:) ::   oirdg1, oirdg2   ! ice age of ice ridged
-
-      REAL(wp), POINTER, DIMENSION(:,:) ::   afrft            ! fraction of category area rafted
-      REAL(wp), POINTER, DIMENSION(:,:) ::   arft1 , arft2    ! area of ice rafted and new rafted zone
-      REAL(wp), POINTER, DIMENSION(:,:) ::   virft , vsrft    ! ice & snow volume of rafting ice
-      REAL(wp), POINTER, DIMENSION(:,:) ::   esrft , smrft    ! snow energy & salinity of rafting ice
-      REAL(wp), POINTER, DIMENSION(:,:) ::   oirft1, oirft2   ! ice age of ice rafted
-
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   eirft      ! ice energy of rafting ice
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   erdg1      ! enth*volume of ice ridged
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   erdg2      ! enth*volume of new ridges
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ersw       ! enth of water trapped into ridges
-      !!----------------------------------------------------------------------
-
-      CALL wrk_alloc( (jpi+1)*(jpj+1),       indxi, indxj )
-      CALL wrk_alloc( jpi, jpj,              vice_init, vice_final, eice_init, eice_final )
-      CALL wrk_alloc( jpi, jpj,              afrac, fvol , ardg1, ardg2, vsrdg, esrdg, dhr, dhr2 )
-      CALL wrk_alloc( jpi, jpj,              vrdg1, vrdg2, vsw  , srdg1, srdg2, smsw, oirdg1, oirdg2 )
-      CALL wrk_alloc( jpi, jpj,              afrft, arft1, arft2, virft, vsrft, esrft, smrft, oirft1, oirft2 )
-      CALL wrk_alloc( jpi, jpj, jpl,         aicen_init, vicen_init, vsnwn_init, esnwn_init, smv_i_init, oa_i_init )
-      CALL wrk_alloc( jpi, jpj, nlay_i,      eirft, erdg1, erdg2, ersw )
-      CALL wrk_alloc( jpi, jpj, nlay_i, jpl, eicen_init )
-
-      ! Conservation check
-      eice_init(:,:) = 0._wp
-
-      IF( con_i ) THEN
-         CALL lim_column_sum        (jpl,    v_i,       vice_init )
-         CALL lim_column_sum_energy (jpl, nlay_i,  e_i, eice_init )
-         DO ji = mi0(iiceprt), mi1(iiceprt)
-            DO jj = mj0(jiceprt), mj1(jiceprt)
-               WRITE(numout,*) ' vice_init  : ', vice_init(ji,jj)
-               WRITE(numout,*) ' eice_init  : ', eice_init(ji,jj)
-            END DO
-         END DO
-      ENDIF
-
-      !-------------------------------------------------------------------------------
-      ! 1) Compute change in open water area due to closing and opening.
-      !-------------------------------------------------------------------------------
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            ato_i(ji,jj) = ato_i(ji,jj) - athorn(ji,jj,0) * closing_gross(ji,jj) * rdt_ice        &
-               &                        + opning(ji,jj)                          * rdt_ice
-            IF    ( ato_i(ji,jj) < -epsi10 ) THEN    ! there is a bug
-               IF(lwp)   WRITE(numout,*) 'Ridging error: ato_i < 0 -- ato_i : ',ato_i(ji,jj)
-            ELSEIF( ato_i(ji,jj) < 0._wp   ) THEN    ! roundoff error
-               ato_i(ji,jj) = 0._wp
-            ENDIF
-         END DO
-      END DO
-
-      !-----------------------------------------------------------------
-      ! 2) Save initial state variables
-      !-----------------------------------------------------------------
-      aicen_init(:,:,:)   = a_i  (:,:,:)
-      vicen_init(:,:,:)   = v_i  (:,:,:)
-      vsnwn_init(:,:,:)   = v_s  (:,:,:)
-      smv_i_init(:,:,:)   = smv_i(:,:,:)
-      esnwn_init(:,:,:)   = e_s  (:,:,1,:)
-      eicen_init(:,:,:,:) = e_i  (:,:,:,:)
-      oa_i_init (:,:,:)   = oa_i (:,:,:)
-
-      !
-      !-----------------------------------------------------------------
-      ! 3) Pump everything from ice which is being ridged / rafted
-      !-----------------------------------------------------------------
-      ! Compute the area, volume, and energy of ice ridging in each
-      ! category, along with the area of the resulting ridge.
-
-      DO jl1 = 1, jpl !jl1 describes the ridging category
-
-         !------------------------------------------------
-         ! 3.1) Identify grid cells with nonzero ridging
-         !------------------------------------------------
-
-         icells = 0
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               IF( aicen_init(ji,jj,jl1) > epsi10 .AND. athorn(ji,jj,jl1) > 0._wp  &
-                  &   .AND. closing_gross(ji,jj) > 0._wp ) THEN
-                  icells = icells + 1
-                  indxi(icells) = ji
-                  indxj(icells) = jj
-               ENDIF
-            END DO
-         END DO
-
-         DO ij = 1, icells
-            ji = indxi(ij)
-            jj = indxj(ij)
-
-            !--------------------------------------------------------------------
-            ! 3.2) Compute area of ridging ice (ardg1) and of new ridge (ardg2)
-            !--------------------------------------------------------------------
-
-            ardg1(ji,jj) = aridge(ji,jj,jl1)*closing_gross(ji,jj)*rdt_ice
-            arft1(ji,jj) = araft (ji,jj,jl1)*closing_gross(ji,jj)*rdt_ice
-            ardg2(ji,jj) = ardg1(ji,jj) / krdg(ji,jj,jl1)
-            arft2(ji,jj) = arft1(ji,jj) / kraft
-
-            !---------------------------------------------------------------
-            ! 3.3) Compute ridging /rafting fractions, make sure afrac <=1 
-            !---------------------------------------------------------------
-
-            afrac(ji,jj) = ardg1(ji,jj) / aicen_init(ji,jj,jl1) !ridging
-            afrft(ji,jj) = arft1(ji,jj) / aicen_init(ji,jj,jl1) !rafting
-
-            IF( afrac(ji,jj) > kamax + epsi10 ) THEN  ! there is a bug
-               IF(lwp)   WRITE(numout,*) ' ardg > a_i -- ardg, aicen_init : ', ardg1(ji,jj), aicen_init(ji,jj,jl1)
-            ELSEIF( afrac(ji,jj) > kamax ) THEN       ! roundoff error
-               afrac(ji,jj) = kamax
-            ENDIF
-
-            IF( afrft(ji,jj) > kamax + epsi10 ) THEN ! there is a bug
-               IF(lwp)   WRITE(numout,*) ' arft > a_i -- arft, aicen_init : ', arft1(ji,jj), aicen_init(ji,jj,jl1) 
-            ELSEIF( afrft(ji,jj) > kamax) THEN       ! roundoff error
-               afrft(ji,jj) = kamax
-            ENDIF
-
-            !--------------------------------------------------------------------------
-            ! 3.4) Subtract area, volume, and energy from ridging 
-            !     / rafting category n1.
-            !--------------------------------------------------------------------------
-            vrdg1(ji,jj) = vicen_init(ji,jj,jl1) * afrac(ji,jj)
-            vrdg2(ji,jj) = vrdg1(ji,jj) * ( 1. + rn_por_rdg )
-            vsw  (ji,jj) = vrdg1(ji,jj) * rn_por_rdg
-
-            vsrdg (ji,jj) = vsnwn_init(ji,jj,jl1) * afrac(ji,jj)
-            esrdg (ji,jj) = esnwn_init(ji,jj,jl1) * afrac(ji,jj)
-            srdg1 (ji,jj) = smv_i_init(ji,jj,jl1) * afrac(ji,jj)
-            oirdg1(ji,jj) = oa_i_init (ji,jj,jl1) * afrac(ji,jj)
-            oirdg2(ji,jj) = oa_i_init (ji,jj,jl1) * afrac(ji,jj) / krdg(ji,jj,jl1) 
-
-            ! rafting volumes, heat contents ...
-            virft (ji,jj) = vicen_init(ji,jj,jl1) * afrft(ji,jj)
-            vsrft (ji,jj) = vsnwn_init(ji,jj,jl1) * afrft(ji,jj)
-            esrft (ji,jj) = esnwn_init(ji,jj,jl1) * afrft(ji,jj)
-            smrft (ji,jj) = smv_i_init(ji,jj,jl1) * afrft(ji,jj) 
-            oirft1(ji,jj) = oa_i_init (ji,jj,jl1) * afrft(ji,jj) 
-            oirft2(ji,jj) = oa_i_init (ji,jj,jl1) * afrft(ji,jj) / kraft 
-
-            ! substract everything
-            a_i(ji,jj,jl1)   = a_i(ji,jj,jl1)   - ardg1 (ji,jj) - arft1 (ji,jj)
-            v_i(ji,jj,jl1)   = v_i(ji,jj,jl1)   - vrdg1 (ji,jj) - virft (ji,jj)
-            v_s(ji,jj,jl1)   = v_s(ji,jj,jl1)   - vsrdg (ji,jj) - vsrft (ji,jj)
-            e_s(ji,jj,1,jl1) = e_s(ji,jj,1,jl1) - esrdg (ji,jj) - esrft (ji,jj)
-            smv_i(ji,jj,jl1) = smv_i(ji,jj,jl1) - srdg1 (ji,jj) - smrft (ji,jj)
-            oa_i(ji,jj,jl1)  = oa_i(ji,jj,jl1)  - oirdg1(ji,jj) - oirft1(ji,jj)
-
-            !-----------------------------------------------------------------
-            ! 3.5) Compute properties of new ridges
-            !-----------------------------------------------------------------
-            !---------
-            ! Salinity
-            !---------
-            smsw(ji,jj)  = vsw(ji,jj) * sss_m(ji,jj)                      ! salt content of seawater frozen in voids !! MV HC2014
-            srdg2(ji,jj) = srdg1(ji,jj) + smsw(ji,jj)                     ! salt content of new ridge
-
-            !srdg2(ji,jj) = MIN( rn_simax * vrdg2(ji,jj) , zsrdg2 )         ! impose a maximum salinity
-            
-            sfx_dyn(ji,jj) = sfx_dyn(ji,jj) - smsw(ji,jj) * rhoic * r1_rdtice
-            wfx_dyn(ji,jj) = wfx_dyn(ji,jj) - vsw (ji,jj) * rhoic * r1_rdtice   ! increase in ice volume du to seawater frozen in voids             
-
-            !------------------------------------            
-            ! 3.6 Increment ridging diagnostics
-            !------------------------------------            
-
-            !        jl1 looping 1-jpl
-            !           ij looping 1-icells
-
-            dardg1dt   (ji,jj) = dardg1dt(ji,jj) + ardg1(ji,jj) + arft1(ji,jj)
-            dardg2dt   (ji,jj) = dardg2dt(ji,jj) + ardg2(ji,jj) + arft2(ji,jj)
-            opening    (ji,jj) = opening (ji,jj) + opning(ji,jj) * rdt_ice
-
-            IF( con_i )   vice_init(ji,jj) = vice_init(ji,jj) + vrdg2(ji,jj) - vrdg1(ji,jj)
-
-            !------------------------------------------            
-            ! 3.7 Put the snow somewhere in the ocean
-            !------------------------------------------            
-            !  Place part of the snow lost by ridging into the ocean. 
-            !  Note that esnow_mlt < 0; the ocean must cool to melt snow.
-            !  If the ocean temp = Tf already, new ice must grow.
-            !  During the next time step, thermo_rates will determine whether
-            !  the ocean cools or new ice grows.
-            !        jl1 looping 1-jpl
-            !           ij looping 1-icells
-
-            msnow_mlt(ji,jj) = msnow_mlt(ji,jj) + rhosn*vsrdg(ji,jj)*(1.0-rn_fsnowrdg)   &   ! rafting included
-               &                                + rhosn*vsrft(ji,jj)*(1.0-rn_fsnowrft)
-
-            ! in J/m2 (same as e_s)
-            esnow_mlt(ji,jj) = esnow_mlt(ji,jj) - esrdg(ji,jj)*(1.0-rn_fsnowrdg)         &   !rafting included
-               &                                - esrft(ji,jj)*(1.0-rn_fsnowrft)          
-
-            !-----------------------------------------------------------------
-            ! 3.8 Compute quantities used to apportion ice among categories
-            ! in the n2 loop below
-            !-----------------------------------------------------------------
-
-            !        jl1 looping 1-jpl
-            !           ij looping 1-icells
-
-            dhr (ji,jj) = hrmax(ji,jj,jl1) - hrmin(ji,jj,jl1)
-            dhr2(ji,jj) = hrmax(ji,jj,jl1) * hrmax(ji,jj,jl1) - hrmin(ji,jj,jl1) * hrmin(ji,jj,jl1)
-
-         END DO
-
-         !--------------------------------------------------------------------
-         ! 3.9 Compute ridging ice enthalpy, remove it from ridging ice and
-         !      compute ridged ice enthalpy 
-         !--------------------------------------------------------------------
-         DO jk = 1, nlay_i
-            DO ij = 1, icells
-               ji = indxi(ij)
-               jj = indxj(ij)
-               ! heat content of ridged ice
-               erdg1(ji,jj,jk)      = eicen_init(ji,jj,jk,jl1) * afrac(ji,jj) 
-               eirft(ji,jj,jk)      = eicen_init(ji,jj,jk,jl1) * afrft(ji,jj)
-               e_i  (ji,jj,jk,jl1)  = e_i(ji,jj,jk,jl1) - erdg1(ji,jj,jk) - eirft(ji,jj,jk)
-               
-               
-               ! enthalpy of the trapped seawater (J/m2, >0)
-               ! clem: if sst>0, then ersw <0 (is that possible?)
-               ersw(ji,jj,jk)   = - rhoic * vsw(ji,jj) * rcp * sst_m(ji,jj) * r1_nlay_i
-
-               ! heat flux to the ocean
-               hfx_dyn(ji,jj) = hfx_dyn(ji,jj) + ersw(ji,jj,jk) * r1_rdtice  ! > 0 [W.m-2] ocean->ice flux 
-
-               ! it is added to sea ice because the sign convention is the opposite of the sign convention for the ocean
-               erdg2(ji,jj,jk)  = erdg1(ji,jj,jk) + ersw(ji,jj,jk)
-
-            END DO
-         END DO
-
-
-         IF( con_i ) THEN
-            DO jk = 1, nlay_i
-               DO ij = 1, icells
-                  ji = indxi(ij)
-                  jj = indxj(ij)
-                  eice_init(ji,jj) = eice_init(ji,jj) + erdg2(ji,jj,jk) - erdg1(ji,jj,jk)
-               END DO
-            END DO
-         ENDIF
-
-         !-------------------------------------------------------------------------------
-         ! 4) Add area, volume, and energy of new ridge to each category jl2
-         !-------------------------------------------------------------------------------
-         !        jl1 looping 1-jpl
-         DO jl2  = 1, jpl 
-            ! over categories to which ridged ice is transferred
-            DO ij = 1, icells
-               ji = indxi(ij)
-               jj = indxj(ij)
-
-               ! Compute the fraction of ridged ice area and volume going to 
-               ! thickness category jl2.
-               ! Transfer area, volume, and energy accordingly.
-
-               IF( hrmin(ji,jj,jl1) >= hi_max(jl2) .OR. hrmax(ji,jj,jl1) <= hi_max(jl2-1) ) THEN
-                  hL = 0._wp
-                  hR = 0._wp
-               ELSE
-                  hL = MAX( hrmin(ji,jj,jl1), hi_max(jl2-1) )
-                  hR = MIN( hrmax(ji,jj,jl1), hi_max(jl2)   )
-               ENDIF
-
-               ! fraction of ridged ice area and volume going to n2
-               farea = ( hR - hL ) / dhr(ji,jj) 
-               fvol(ji,jj) = ( hR*hR - hL*hL ) / dhr2(ji,jj)
-
-               a_i  (ji,jj  ,jl2) = a_i  (ji,jj  ,jl2) + ardg2 (ji,jj) * farea
-               v_i  (ji,jj  ,jl2) = v_i  (ji,jj  ,jl2) + vrdg2 (ji,jj) * fvol(ji,jj)
-               v_s  (ji,jj  ,jl2) = v_s  (ji,jj  ,jl2) + vsrdg (ji,jj) * fvol(ji,jj) * rn_fsnowrdg
-               e_s  (ji,jj,1,jl2) = e_s  (ji,jj,1,jl2) + esrdg (ji,jj) * fvol(ji,jj) * rn_fsnowrdg
-               smv_i(ji,jj  ,jl2) = smv_i(ji,jj  ,jl2) + srdg2 (ji,jj) * fvol(ji,jj)
-               oa_i (ji,jj  ,jl2) = oa_i (ji,jj  ,jl2) + oirdg2(ji,jj) * farea
-
-            END DO
-
-            ! Transfer ice energy to category jl2 by ridging
-            DO jk = 1, nlay_i
-               DO ij = 1, icells
-                  ji = indxi(ij)
-                  jj = indxj(ij)
-                  e_i(ji,jj,jk,jl2) = e_i(ji,jj,jk,jl2) + fvol(ji,jj) * erdg2(ji,jj,jk)
-               END DO
-            END DO
-            !
-         END DO                 ! jl2 (new ridges)            
-
-         DO jl2 = 1, jpl 
-
-            DO ij = 1, icells
-               ji = indxi(ij)
-               jj = indxj(ij)
-               ! Compute the fraction of rafted ice area and volume going to 
-               ! thickness category jl2, transfer area, volume, and energy accordingly.
-               !
-               IF( hraft(ji,jj,jl1) <= hi_max(jl2) .AND. hraft(ji,jj,jl1) >  hi_max(jl2-1) ) THEN
-                  a_i  (ji,jj  ,jl2) = a_i  (ji,jj  ,jl2) + arft2 (ji,jj)
-                  v_i  (ji,jj  ,jl2) = v_i  (ji,jj  ,jl2) + virft (ji,jj)
-                  v_s  (ji,jj  ,jl2) = v_s  (ji,jj  ,jl2) + vsrft (ji,jj) * rn_fsnowrft
-                  e_s  (ji,jj,1,jl2) = e_s  (ji,jj,1,jl2) + esrft (ji,jj) * rn_fsnowrft
-                  smv_i(ji,jj  ,jl2) = smv_i(ji,jj  ,jl2) + smrft (ji,jj)    
-                  oa_i (ji,jj  ,jl2) = oa_i (ji,jj  ,jl2) + oirft2(ji,jj)
-               ENDIF
-               !
-            END DO
-
-            ! Transfer rafted ice energy to category jl2 
-            DO jk = 1, nlay_i
-               DO ij = 1, icells
-                  ji = indxi(ij)
-                  jj = indxj(ij)
-                  IF( hraft(ji,jj,jl1) <= hi_max(jl2) .AND. hraft(ji,jj,jl1) > hi_max(jl2-1)  ) THEN
-                     e_i(ji,jj,jk,jl2) = e_i(ji,jj,jk,jl2) + eirft(ji,jj,jk)
-                  ENDIF
-               END DO
-            END DO
-
-         END DO
-
-      END DO ! jl1 (deforming categories)
-
-      ! Conservation check
-      IF ( con_i ) THEN
-         CALL lim_column_sum (jpl,   v_i, vice_final)
-         fieldid = ' v_i : limitd_me '
-         CALL lim_cons_check (vice_init, vice_final, 1.0e-6, fieldid) 
-
-         CALL lim_column_sum_energy (jpl, nlay_i,  e_i, eice_final )
-         fieldid = ' e_i : limitd_me '
-         CALL lim_cons_check (eice_init, eice_final, 1.0e-2, fieldid) 
-
-         DO ji = mi0(iiceprt), mi1(iiceprt)
-            DO jj = mj0(jiceprt), mj1(jiceprt)
-               WRITE(numout,*) ' vice_init  : ', vice_init (ji,jj)
-               WRITE(numout,*) ' vice_final : ', vice_final(ji,jj)
-               WRITE(numout,*) ' eice_init  : ', eice_init (ji,jj)
-               WRITE(numout,*) ' eice_final : ', eice_final(ji,jj)
-            END DO
-         END DO
-      ENDIF
-      !
-      CALL wrk_dealloc( (jpi+1)*(jpj+1),        indxi, indxj )
-      CALL wrk_dealloc( jpi, jpj,               vice_init, vice_final, eice_init, eice_final )
-      CALL wrk_dealloc( jpi, jpj,               afrac, fvol , ardg1, ardg2, vsrdg, esrdg, dhr, dhr2 )
-      CALL wrk_dealloc( jpi, jpj,               vrdg1, vrdg2, vsw  , srdg1, srdg2, smsw, oirdg1, oirdg2 )
-      CALL wrk_dealloc( jpi, jpj,               afrft, arft1, arft2, virft, vsrft, esrft, smrft, oirft1, oirft2 )
-      CALL wrk_dealloc( jpi, jpj, jpl,          aicen_init, vicen_init, vsnwn_init, esnwn_init, smv_i_init, oa_i_init )
-      CALL wrk_dealloc( jpi, jpj, nlay_i,       eirft, erdg1, erdg2, ersw )
-      CALL wrk_dealloc( jpi, jpj, nlay_i, jpl,  eicen_init )
-      !
-   END SUBROUTINE lim_itd_me_ridgeshift
 
    SUBROUTINE lim_itd_me_init
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90	(revision 6436)
@@ -125,5 +125,5 @@
       IF( iom_use('emp_ice' ) )  CALL iom_put( "emp_ice"  , emp_ice(:,:) )   ! emp over ice   (taking into account the snow blown away from the ice)
 
-      ! clem 2016: albedo output
+      ! albedo output
       CALL wrk_alloc( jpi,jpj, zalb )    
 
@@ -158,10 +158,11 @@
             hfx_out(ji,jj) = hfx_out(ji,jj) + zqmass + zqsr
 
-            ! Add the residual from heat diffusion equation (W.m-2)
-            !-------------------------------------------------------
-            hfx_out(ji,jj) = hfx_out(ji,jj) + hfx_err_dif(ji,jj)
+            ! Add the residual from heat diffusion equation and sublimation (W.m-2)
+            !----------------------------------------------------------------------
+            hfx_out(ji,jj) = hfx_out(ji,jj) + hfx_err_dif(ji,jj) +   &
+               &           ( hfx_sub(ji,jj) - SUM( qevap_ice(ji,jj,:) * a_i_b(ji,jj,:) ) )
 
             ! New qsr and qns used to compute the oceanic heat flux at the next time step
-            !---------------------------------------------------
+            !----------------------------------------------------------------------------
             qsr(ji,jj) = zqsr                                      
             qns(ji,jj) = hfx_out(ji,jj) - zqsr              
@@ -183,7 +184,6 @@
 
             ! mass flux at the ocean/ice interface
-            fmmflx(ji,jj) = - ( wfx_ice(ji,jj) + wfx_snw(ji,jj) ) * r1_rdtice  ! F/M mass flux save at least for biogeochemical model
-            emp(ji,jj)    = emp_oce(ji,jj) - wfx_ice(ji,jj) - wfx_snw(ji,jj)   ! mass flux + F/M mass flux (always ice/ocean mass exchange)
-            
+            fmmflx(ji,jj) = - ( wfx_ice(ji,jj) + wfx_snw(ji,jj) + wfx_err_sub(ji,jj) )              ! F/M mass flux save at least for biogeochemical model
+            emp(ji,jj)    = emp_oce(ji,jj) - wfx_ice(ji,jj) - wfx_snw(ji,jj) - wfx_err_sub(ji,jj)   ! mass flux + F/M mass flux (always ice/ocean mass exchange)
          END DO
       END DO
@@ -193,5 +193,5 @@
       !------------------------------------------!
       sfx(:,:) = sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) + sfx_opw(:,:)   &
-         &     + sfx_res(:,:) + sfx_dyn(:,:) + sfx_bri(:,:)
+         &     + sfx_res(:,:) + sfx_dyn(:,:) + sfx_bri(:,:) + sfx_sub(:,:)
 
       !-------------------------------------------------------------!
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 6436)
@@ -461,5 +461,5 @@
 
       DO ji = kideb, kiut
-         zdh_mel = MIN( 0._wp, dh_i_surf(ji) + dh_i_bott(ji) + dh_snowice(ji) )
+         zdh_mel = MIN( 0._wp, dh_i_surf(ji) + dh_i_bott(ji) + dh_snowice(ji) + dh_i_sub(ji) )
          IF( zdh_mel < 0._wp .AND. a_i_1d(ji) > 0._wp )  THEN
             zvi          = a_i_1d(ji) * ht_i_1d(ji)
@@ -470,5 +470,5 @@
             zda_mel     = rswitch * a_i_1d(ji) * zdh_mel / ( 2._wp * MAX( zhi_bef, epsi20 ) )
             a_i_1d(ji)  = MAX( epsi20, a_i_1d(ji) + zda_mel ) 
-             ! adjust thickness
+            ! adjust thickness
             ht_i_1d(ji) = zvi / a_i_1d(ji)            
             ht_s_1d(ji) = zvs / a_i_1d(ji)            
@@ -514,4 +514,5 @@
          
          CALL tab_2d_1d( nbpb, qprec_ice_1d(1:nbpb), qprec_ice(:,:) , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d( nbpb, qevap_ice_1d(1:nbpb), qevap_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
          CALL tab_2d_1d( nbpb, qsr_ice_1d (1:nbpb), qsr_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
          CALL tab_2d_1d( nbpb, fr1_i0_1d  (1:nbpb), fr1_i0          , jpi, jpj, npb(1:nbpb) )
@@ -543,5 +544,6 @@
          CALL tab_2d_1d( nbpb, sfx_bri_1d (1:nbpb), sfx_bri         , jpi, jpj, npb(1:nbpb) )
          CALL tab_2d_1d( nbpb, sfx_res_1d (1:nbpb), sfx_res         , jpi, jpj, npb(1:nbpb) )
-         
+         CALL tab_2d_1d( nbpb, sfx_sub_1d (1:nbpb), sfx_sub         , jpi, jpj,npb(1:nbpb) )
+ 
          CALL tab_2d_1d( nbpb, hfx_thd_1d (1:nbpb), hfx_thd         , jpi, jpj, npb(1:nbpb) )
          CALL tab_2d_1d( nbpb, hfx_spr_1d (1:nbpb), hfx_spr         , jpi, jpj, npb(1:nbpb) )
@@ -593,5 +595,6 @@
          CALL tab_1d_2d( nbpb, sfx_res       , npb, sfx_res_1d(1:nbpb)   , jpi, jpj )
          CALL tab_1d_2d( nbpb, sfx_bri       , npb, sfx_bri_1d(1:nbpb)   , jpi, jpj )
-         
+         CALL tab_1d_2d( nbpb, sfx_sub       , npb, sfx_sub_1d(1:nbpb)   , jpi, jpj )        
+ 
          CALL tab_1d_2d( nbpb, hfx_thd       , npb, hfx_thd_1d(1:nbpb)   , jpi, jpj )
          CALL tab_1d_2d( nbpb, hfx_spr       , npb, hfx_spr_1d(1:nbpb)   , jpi, jpj )
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limthd_dh.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 6436)
@@ -74,5 +74,5 @@
 
       REAL(wp) ::   ztmelts             ! local scalar
-      REAL(wp) ::   zfdum       
+      REAL(wp) ::   zdum       
       REAL(wp) ::   zfracs       ! fractionation coefficient for bottom salt entrapment
       REAL(wp) ::   zs_snic      ! snow-ice salinity
@@ -95,4 +95,5 @@
       REAL(wp), POINTER, DIMENSION(:) ::   zq_rema     ! remaining heat at the end of the routine    (J.m-2)
       REAL(wp), POINTER, DIMENSION(:) ::   zf_tt       ! Heat budget to determine melting or freezing(W.m-2)
+      REAL(wp), POINTER, DIMENSION(:) ::   zevap_rema  ! remaining mass flux from sublimation        (kg.m-2)
 
       REAL(wp), POINTER, DIMENSION(:) ::   zdh_s_mel   ! snow melt 
@@ -105,6 +106,4 @@
 
       REAL(wp), POINTER, DIMENSION(:) ::   zqh_i       ! total ice heat content  (J.m-2)
-      REAL(wp), POINTER, DIMENSION(:) ::   zqh_s       ! total snow heat content (J.m-2)
-      REAL(wp), POINTER, DIMENSION(:) ::   zq_s        ! total snow enthalpy     (J.m-3)
       REAL(wp), POINTER, DIMENSION(:) ::   zsnw        ! distribution of snow after wind blowing
 
@@ -122,16 +121,15 @@
       END SELECT
 
-      CALL wrk_alloc( jpij, zqprec, zq_su, zq_bo, zf_tt, zq_rema, zsnw )
-      CALL wrk_alloc( jpij, zdh_s_mel, zdh_s_pre, zdh_s_sub, zqh_i, zqh_s, zq_s )
+      CALL wrk_alloc( jpij, zqprec, zq_su, zq_bo, zf_tt, zq_rema, zsnw, zevap_rema )
+      CALL wrk_alloc( jpij, zdh_s_mel, zdh_s_pre, zdh_s_sub, zqh_i )
       CALL wrk_alloc( jpij, nlay_i, zdeltah, zh_i )
       CALL wrk_alloc( jpij, nlay_i, icount )
        
-      dh_i_surf  (:) = 0._wp ; dh_i_bott  (:) = 0._wp ; dh_snowice(:) = 0._wp
+      dh_i_surf  (:) = 0._wp ; dh_i_bott  (:) = 0._wp ; dh_snowice(:) = 0._wp ; dh_i_sub(:) = 0._wp
       dsm_i_se_1d(:) = 0._wp ; dsm_i_si_1d(:) = 0._wp   
 
       zqprec   (:) = 0._wp ; zq_su    (:) = 0._wp ; zq_bo    (:) = 0._wp ; zf_tt(:) = 0._wp
-      zq_rema  (:) = 0._wp ; zsnw     (:) = 0._wp
+      zq_rema  (:) = 0._wp ; zsnw     (:) = 0._wp ; zevap_rema(:) = 0._wp ;
       zdh_s_mel(:) = 0._wp ; zdh_s_pre(:) = 0._wp ; zdh_s_sub(:) = 0._wp ; zqh_i(:) = 0._wp
-      zqh_s    (:) = 0._wp ; zq_s     (:) = 0._wp     
 
       zdeltah(:,:) = 0._wp ; zh_i(:,:) = 0._wp       
@@ -159,8 +157,8 @@
       !
       DO ji = kideb, kiut
-         zfdum      = qns_ice_1d(ji) + ( 1._wp - i0(ji) ) * qsr_ice_1d(ji) - fc_su(ji) 
+         zdum       = qns_ice_1d(ji) + ( 1._wp - i0(ji) ) * qsr_ice_1d(ji) - fc_su(ji) 
          zf_tt(ji)  = fc_bo_i(ji) + fhtur_1d(ji) + fhld_1d(ji) 
 
-         zq_su (ji) = MAX( 0._wp, zfdum     * rdt_ice ) * MAX( 0._wp , SIGN( 1._wp, t_su_1d(ji) - rt0 ) )
+         zq_su (ji) = MAX( 0._wp, zdum      * rdt_ice ) * MAX( 0._wp , SIGN( 1._wp, t_su_1d(ji) - rt0 ) )
          zq_bo (ji) = MAX( 0._wp, zf_tt(ji) * rdt_ice )
       END DO
@@ -187,10 +185,4 @@
       !  2) Computing layer thicknesses and enthalpies.            !
       !------------------------------------------------------------!
-      !
-      DO jk = 1, nlay_s
-         DO ji = kideb, kiut
-            zqh_s(ji) =  zqh_s(ji) + q_s_1d(ji,jk) * ht_s_1d(ji) * r1_nlay_s
-         END DO
-      END DO
       !
       DO jk = 1, nlay_i
@@ -275,17 +267,15 @@
       END DO
 
-      !----------------------
-      ! 3.2 Snow sublimation 
-      !----------------------
+      !------------------------------
+      ! 3.2 Sublimation (part1: snow) 
+      !------------------------------
       ! qla_ice is always >=0 (upwards), heat goes to the atmosphere, therefore snow sublimates
       ! clem comment: not counted in mass/heat exchange in limsbc since this is an exchange with atm. (not ocean)
-      ! clem comment: ice should also sublimate
       zdeltah(:,:) = 0._wp
-      ! coupled mode: sublimation is set to 0 (evap_ice = 0) until further notice
-      ! forced  mode: snow thickness change due to sublimation
-      DO ji = kideb, kiut
-         zdh_s_sub(ji)  =  MAX( - ht_s_1d(ji) , - evap_ice_1d(ji) * r1_rhosn * rdt_ice )
-         ! Heat flux by sublimation [W.m-2], < 0
-         !      sublimate first snow that had fallen, then pre-existing snow
+      DO ji = kideb, kiut
+         zdh_s_sub(ji)  = MAX( - ht_s_1d(ji) , - evap_ice_1d(ji) * r1_rhosn * rdt_ice )
+         ! remaining evap in kg.m-2 (used for ice melting later on)
+         zevap_rema(ji)  = evap_ice_1d(ji) * rdt_ice + zdh_s_sub(ji) * rhosn
+         ! Heat flux by sublimation [W.m-2], < 0 (sublimate first snow that had fallen, then pre-existing snow)
          zdeltah(ji,1)  = MAX( zdh_s_sub(ji), - zdh_s_pre(ji) )
          hfx_sub_1d(ji) = hfx_sub_1d(ji) + ( zdeltah(ji,1) * zqprec(ji) + ( zdh_s_sub(ji) - zdeltah(ji,1) ) * q_s_1d(ji,1)  &
@@ -309,12 +299,10 @@
       !-------------------------------------------
       ! new temp and enthalpy of the snow (remaining snow precip + remaining pre-existing snow)
-      zq_s(:) = 0._wp 
       DO jk = 1, nlay_s
          DO ji = kideb,kiut
-            rswitch       = MAX(  0._wp , SIGN( 1._wp, ht_s_1d(ji) - epsi20 )  )
-            q_s_1d(ji,jk) = rswitch / MAX( ht_s_1d(ji), epsi20 ) *                          &
-              &            ( (   zdh_s_pre(ji)             ) * zqprec(ji) +  &
-              &              (   ht_s_1d(ji) - zdh_s_pre(ji) ) * rhosn * ( cpic * ( rt0 - t_s_1d(ji,jk) ) + lfus ) )
-            zq_s(ji)     =  zq_s(ji) + q_s_1d(ji,jk)
+            rswitch       = MAX( 0._wp , SIGN( 1._wp, ht_s_1d(ji) - epsi20 ) )
+            q_s_1d(ji,jk) = rswitch / MAX( ht_s_1d(ji), epsi20 ) *           &
+              &            ( ( zdh_s_pre(ji)               ) * zqprec(ji) +  &
+              &              ( ht_s_1d(ji) - zdh_s_pre(ji) ) * rhosn * ( cpic * ( rt0 - t_s_1d(ji,jk) ) + lfus ) )
          END DO
       END DO
@@ -370,5 +358,5 @@
                zQm            = zfmdt * zEw                           ! Energy of the melt water sent to the ocean [J/m2, <0]
                
-               ! Contribution to salt flux (clem: using sm_i_1d and not s_i_1d(jk) is ok)
+               ! Contribution to salt flux >0 (clem: using sm_i_1d and not s_i_1d(jk) is ok)
                sfx_sum_1d(ji) = sfx_sum_1d(ji) - rhoic * a_i_1d(ji) * zdeltah(ji,jk) * sm_i_1d(ji) * r1_rdtice
                
@@ -383,4 +371,20 @@
                
             END IF
+            ! ----------------------
+            ! Sublimation part2: ice
+            ! ----------------------
+            zdum      = MAX( - ( zh_i(ji,jk) + zdeltah(ji,jk) ) , - zevap_rema(ji) * r1_rhoic )
+            zdeltah(ji,jk) = zdeltah(ji,jk) + zdum
+            dh_i_sub(ji)  = dh_i_sub(ji) + zdum
+            ! Salt flux > 0 (clem2016: flux is sent to the ocean for simplicity but salt should remain in the ice except if all ice is melted.
+            !                          It must be corrected at some point)
+            sfx_sub_1d(ji) = sfx_sub_1d(ji) - rhoic * a_i_1d(ji) * zdum * sm_i_1d(ji) * r1_rdtice
+            ! Heat flux [W.m-2], < 0
+            hfx_sub_1d(ji) = hfx_sub_1d(ji) + zdum * q_i_1d(ji,jk) * a_i_1d(ji) * r1_rdtice
+            ! Mass flux > 0
+            wfx_sub_1d(ji) =  wfx_sub_1d(ji) - rhoic * a_i_1d(ji) * zdum * r1_rdtice
+            ! update remaining mass flux
+            zevap_rema(ji)  = zevap_rema(ji) + zdum * rhoic
+            
             ! record which layers have disappeared (for bottom melting) 
             !    => icount=0 : no layer has vanished
@@ -389,5 +393,5 @@
             icount(ji,jk) = NINT( rswitch )
             zh_i(ji,jk)   = MAX( 0._wp , zh_i(ji,jk) + zdeltah(ji,jk) )
-
+                        
             ! update heat content (J.m-2) and layer thickness
             qh_i_old(ji,jk) = qh_i_old(ji,jk) + zdeltah(ji,jk) * q_i_1d(ji,jk)
@@ -397,5 +401,11 @@
       ! update ice thickness
       DO ji = kideb, kiut
-         ht_i_1d(ji) =  MAX( 0._wp , ht_i_1d(ji) + dh_i_surf(ji) )
+         ht_i_1d(ji) =  MAX( 0._wp , ht_i_1d(ji) + dh_i_surf(ji) + dh_i_sub(ji) )
+      END DO
+
+      ! remaining "potential" evap is sent to ocean
+      DO ji = kideb, kiut
+         ii = MOD( npb(ji) - 1, jpi ) + 1 ; ij = ( npb(ji) - 1 ) / jpi + 1
+         wfx_err_sub(ii,ij) = wfx_err_sub(ii,ij) - zevap_rema(ji) * a_i_1d(ji) * r1_rdtice  ! <=0 (net evap for the ocean in kg.m-2.s-1)
       END DO
 
@@ -686,6 +696,6 @@
       WHERE( ht_i_1d == 0._wp ) a_i_1d = 0._wp
       
-      CALL wrk_dealloc( jpij, zqprec, zq_su, zq_bo, zf_tt, zq_rema, zsnw )
-      CALL wrk_dealloc( jpij, zdh_s_mel, zdh_s_pre, zdh_s_sub, zqh_i, zqh_s, zq_s )
+      CALL wrk_dealloc( jpij, zqprec, zq_su, zq_bo, zf_tt, zq_rema, zsnw, zevap_rema )
+      CALL wrk_dealloc( jpij, zdh_s_mel, zdh_s_pre, zdh_s_sub, zqh_i )
       CALL wrk_dealloc( jpij, nlay_i, zdeltah, zh_i )
       CALL wrk_dealloc( jpij, nlay_i, icount )
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90	(revision 6436)
@@ -163,4 +163,20 @@
                rswitch = MAX( 0._wp , SIGN( 1._wp, a_i(ji,jj,jl) - epsi20 ) )   !0 if no ice and 1 if yes
                ht_i(ji,jj,jl) = v_i (ji,jj,jl) / MAX( a_i(ji,jj,jl) , epsi20 ) * rswitch
+            END DO
+         END DO
+      END DO
+      ! Force the upper limit of ht_i to always be < hi_max (99 m).
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            rswitch = MAX( 0._wp , SIGN( 1._wp, ht_i(ji,jj,jpl) - epsi20 ) )
+            ht_i(ji,jj,jpl) = MIN( ht_i(ji,jj,jpl) , hi_max(jpl) )
+            a_i (ji,jj,jpl) = v_i(ji,jj,jpl) / MAX( ht_i(ji,jj,jpl) , epsi20 ) * rswitch
+         END DO
+      END DO
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               rswitch = MAX( 0._wp , SIGN( 1._wp, a_i(ji,jj,jl) - epsi20 ) )   !0 if no ice and 1 if yes
                ht_s(ji,jj,jl) = v_s (ji,jj,jl) / MAX( a_i(ji,jj,jl) , epsi20 ) * rswitch
                o_i(ji,jj,jl)  = oa_i(ji,jj,jl) / MAX( a_i(ji,jj,jl) , epsi20 ) * rswitch
@@ -168,5 +184,5 @@
          END DO
       END DO
-
+      
       IF(  nn_icesal == 2  )THEN
          DO jl = 1, jpl
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 6436)
@@ -182,12 +182,13 @@
       CALL iom_put( "destrp"      , diag_trp_es         )        ! advected snw enthalpy (W/m2)
 
-      CALL iom_put( "sfxbog"      , sfx_bog * rday      )        ! salt flux from brines
-      CALL iom_put( "sfxbom"      , sfx_bom * rday      )        ! salt flux from brines
-      CALL iom_put( "sfxsum"      , sfx_sum * rday      )        ! salt flux from brines
-      CALL iom_put( "sfxsni"      , sfx_sni * rday      )        ! salt flux from brines
-      CALL iom_put( "sfxopw"      , sfx_opw * rday      )        ! salt flux from brines
+      CALL iom_put( "sfxbog"      , sfx_bog * rday      )        ! salt flux from bottom growth
+      CALL iom_put( "sfxbom"      , sfx_bom * rday      )        ! salt flux from bottom melt
+      CALL iom_put( "sfxsum"      , sfx_sum * rday      )        ! salt flux from surface melt
+      CALL iom_put( "sfxsni"      , sfx_sni * rday      )        ! salt flux from snow ice formation
+      CALL iom_put( "sfxopw"      , sfx_opw * rday      )        ! salt flux from open water formation
       CALL iom_put( "sfxdyn"      , sfx_dyn * rday      )        ! salt flux from ridging rafting
-      CALL iom_put( "sfxres"      , sfx_res * rday      )        ! salt flux from limupdate (resultant)
+      CALL iom_put( "sfxres"      , sfx_res * rday      )        ! salt flux from residual
       CALL iom_put( "sfxbri"      , sfx_bri * rday      )        ! salt flux from brines
+      CALL iom_put( "sfxsub"      , sfx_sub * rday      )        ! salt flux from sublimation
       CALL iom_put( "sfx"         , sfx     * rday      )        ! total salt flux
 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/thd_ice.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/thd_ice.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/LIM_SRC_3/thd_ice.F90	(revision 6436)
@@ -45,4 +45,5 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qns_ice_1d  
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   t_bo_1d     
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   rn_amax_1d
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_sum_1d
@@ -51,5 +52,4 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_dif_1d
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_opw_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   rn_amax_1d
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_snw_1d
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_err_1d
@@ -84,4 +84,6 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_res_1d  
 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_sub_1d
+
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sprecip_1d    !: <==> the 2D  sprecip
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   frld_1d       !: <==> the 2D  frld
@@ -92,4 +94,5 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   evap_ice_1d   !: <==> the 2D  evap_ice
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qprec_ice_1d  !: <==> the 2D  qprec_ice
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qevap_ice_1d  !: <==> the 3D  qevap_ice
    !                                                     ! to reintegrate longwave flux inside the ice thermodynamics
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   i0            !: fraction of radiation transmitted to the ice
@@ -108,4 +111,5 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_s_tot      !: Snow accretion/ablation        [m]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_i_surf     !: Ice surface accretion/ablation [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_i_sub      !: Ice surface sublimation [m]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_i_bott     !: Ice bottom accretion/ablation  [m]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_snowice    !: Snow ice formation             [m of ice]
@@ -155,7 +159,7 @@
          &      wfx_sum_1d(jpij)  , wfx_sni_1d (jpij) , wfx_opw_1d (jpij) , wfx_res_1d(jpij) ,  &
          &      dqns_ice_1d(jpij) , evap_ice_1d (jpij),                                         &
-         &      qprec_ice_1d(jpij), i0         (jpij) ,                                         &  
+         &      qprec_ice_1d(jpij), qevap_ice_1d(jpij), i0         (jpij) ,                     &  
          &      sfx_bri_1d (jpij) , sfx_bog_1d (jpij) , sfx_bom_1d (jpij) , sfx_sum_1d (jpij),  &
-         &      sfx_sni_1d (jpij) , sfx_opw_1d (jpij) , sfx_res_1d (jpij) ,                     &
+         &      sfx_sni_1d (jpij) , sfx_opw_1d (jpij) , sfx_res_1d (jpij) , sfx_sub_1d (jpij),  &
          &      dsm_i_fl_1d(jpij) , dsm_i_gd_1d(jpij) , dsm_i_se_1d(jpij) ,                     &     
          &      dsm_i_si_1d(jpij) , hicol_1d    (jpij)                     , STAT=ierr(2) )
@@ -163,6 +167,6 @@
       ALLOCATE( t_su_1d   (jpij) , a_i_1d   (jpij) , ht_i_1d  (jpij) ,    &   
          &      ht_s_1d   (jpij) , fc_su    (jpij) , fc_bo_i  (jpij) ,    &    
-         &      dh_s_tot  (jpij) , dh_i_surf(jpij) , dh_i_bott(jpij) ,    &    
-         &      dh_snowice(jpij) , sm_i_1d  (jpij) , s_i_new  (jpij) ,    &
+         &      dh_s_tot  (jpij) , dh_i_surf(jpij) , dh_i_sub (jpij) ,    &    
+         &      dh_i_bott (jpij) ,dh_snowice(jpij) , sm_i_1d  (jpij) , s_i_new  (jpij) ,    &
          &      t_s_1d(jpij,nlay_s) , t_i_1d(jpij,nlay_i) , s_i_1d(jpij,nlay_i) ,  &            
          &      q_i_1d(jpij,nlay_i+1) , q_s_1d(jpij,nlay_s) ,                        &
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 6436)
@@ -150,10 +150,11 @@
       CALL iom_put("e3v_0", e3t_0(:,:,:) )
       !
-      IF( .NOT.lk_vvl ) THEN
-         CALL iom_put( "e3t" , fse3t_n(:,:,:) )
-         CALL iom_put( "e3u" , fse3u_n(:,:,:) )
-         CALL iom_put( "e3v" , fse3v_n(:,:,:) )
-         CALL iom_put( "e3w" , fse3w_n(:,:,:) )
-      ENDIF
+      CALL iom_put( "e3t" , fse3t_n(:,:,:) )
+      CALL iom_put( "e3u" , fse3u_n(:,:,:) )
+      CALL iom_put( "e3v" , fse3v_n(:,:,:) )
+      CALL iom_put( "e3w" , fse3w_n(:,:,:) )
+      IF( iom_use("e3tdef") )   &
+         CALL iom_put( "e3tdef"  , ( ( fse3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 )
+
 
       CALL iom_put( "ssh" , sshn )                 ! sea surface height
@@ -247,4 +248,7 @@
       CALL iom_put( "avm" , avmu                       )    ! T vert. eddy visc. coef.
       CALL iom_put( "avs" , fsavs(:,:,:)               )    ! S vert. eddy diff. coef. (useful only with key_zdfddm)
+                                                            ! Log of eddy diff coef
+      IF( iom_use('logavt') )   CALL iom_put( "logavt", LOG( MAX( 1.e-20_wp, avt  (:,:,:) ) ) )
+      IF( iom_use('logavs') )   CALL iom_put( "logavs", LOG( MAX( 1.e-20_wp, fsavs(:,:,:) ) ) )
 
       IF ( iom_use("sstgrad") .OR. iom_use("sstgrad2") ) THEN
@@ -311,5 +315,7 @@
          CALL iom_put( "eken", rke )           
       ENDIF
-         
+      !
+      CALL iom_put( "hdiv", hdivn )                  ! Horizontal divergence
+      !
       IF( iom_use("u_masstr") .OR. iom_use("u_heattr") .OR. iom_use("u_salttr") ) THEN
          z3d(:,:,jpk) = 0.e0
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 6436)
@@ -665,14 +665,4 @@
          ht(:,:) = ht(:,:) + fse3t_n(:,:,jk) * tmask(:,:,jk)
       END DO
-
-      ! Write outputs
-      ! =============
-      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( "tpt_dep" , fsde3w_n (:,:,:) )
-      IF( iom_use("e3tdef") )   &
-         CALL iom_put( "e3tdef"  , ( ( fse3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 )
 
       ! write restart file
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/LBC/mppini.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/LBC/mppini.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/LBC/mppini.F90	(revision 6436)
@@ -201,45 +201,4 @@
       
 #endif
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '           defines mpp subdomains'
-         WRITE(numout,*) '           ----------------------'
-         WRITE(numout,*) '           iresti=',iresti,' irestj=',irestj
-         WRITE(numout,*) '           jpni  =',jpni  ,' jpnj  =',jpnj
-         ifreq = 4
-         il1   = 1
-         DO jn = 1, (jpni-1)/ifreq+1
-            il2 = MIN( jpni, il1+ifreq-1 )
-            WRITE(numout,*)
-            WRITE(numout,9200) ('***',ji = il1,il2-1)
-            DO jj = jpnj, 1, -1
-               WRITE(numout,9203) ('   ',ji = il1,il2-1)
-               WRITE(numout,9202) jj, ( ilcit(ji,jj),ilcjt(ji,jj),ji = il1,il2 )
-               WRITE(numout,9203) ('   ',ji = il1,il2-1)
-               WRITE(numout,9200) ('***',ji = il1,il2-1)
-            END DO
-            WRITE(numout,9201) (ji,ji = il1,il2)
-            il1 = il1+ifreq
-         END DO
- 9200    FORMAT('     ***',20('*************',a3))
- 9203    FORMAT('     *     ',20('         *   ',a3))
- 9201    FORMAT('        ',20('   ',i3,'          '))
- 9202    FORMAT(' ',i3,' *  ',20(i3,'  x',i3,'   *   '))
-      ENDIF
-
-      zidom = nreci
-      DO ji = 1, jpni
-         zidom = zidom + ilcit(ji,1) - nreci
-      END DO
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*)' sum ilcit(i,1) = ', zidom, ' jpiglo = ', jpiglo
-      
-      zjdom = nrecj
-      DO jj = 1, jpnj
-         zjdom = zjdom + ilcjt(1,jj) - nrecj
-      END DO
-      IF(lwp) WRITE(numout,*)' sum ilcit(1,j) = ', zjdom, ' jpjglo = ', jpjglo
-      IF(lwp) WRITE(numout,*)
-      
 
       !  2. Index arrays for subdomains
@@ -304,7 +263,54 @@
          nlejt(jn) = nlej
       END DO
-      
-
-      ! 4. From global to local
+
+      ! 4. Subdomain print
+      ! ------------------
+      
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) ' mpp_init: defines mpp subdomains'
+      IF(lwp) WRITE(numout,*) ' ~~~~~~  ----------------------'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'iresti=',iresti,' irestj=',irestj
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'jpni=',jpni,' jpnj=',jpnj
+      zidom = nreci
+      DO ji = 1, jpni
+         zidom = zidom + ilcit(ji,1) - nreci
+      END DO
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*)' sum ilcit(i,1)=', zidom, ' jpiglo=', jpiglo
+
+      zjdom = nrecj
+      DO jj = 1, jpnj
+         zjdom = zjdom + ilcjt(1,jj) - nrecj
+      END DO
+      IF(lwp) WRITE(numout,*)' sum ilcit(1,j)=', zjdom, ' jpjglo=', jpjglo
+      IF(lwp) WRITE(numout,*)
+
+      IF(lwp) THEN
+         ifreq = 4
+         il1   = 1
+         DO jn = 1, (jpni-1)/ifreq+1
+            il2 = MIN( jpni, il1+ifreq-1 )
+            WRITE(numout,*)
+            WRITE(numout,9200) ('***',ji = il1,il2-1)
+            DO jj = jpnj, 1, -1
+               WRITE(numout,9203) ('   ',ji = il1,il2-1)
+               WRITE(numout,9202) jj, ( ilcit(ji,jj),ilcjt(ji,jj),ji = il1,il2 )
+               WRITE(numout,9204) (nfipproc(ji,jj),ji=il1,il2)
+               WRITE(numout,9203) ('   ',ji = il1,il2-1)
+               WRITE(numout,9200) ('***',ji = il1,il2-1)
+            END DO
+            WRITE(numout,9201) (ji,ji = il1,il2)
+            il1 = il1+ifreq
+         END DO
+ 9200     FORMAT('     ***',20('*************',a3))
+ 9203     FORMAT('     *     ',20('         *   ',a3))
+ 9201     FORMAT('        ',20('   ',i3,'          '))
+ 9202     FORMAT(' ',i3,' *  ',20(i3,'  x',i3,'   *   '))
+ 9204     FORMAT('     *  ',20('      ',i3,'   *   '))
+      ENDIF
+
+      ! 5. From global to local
       ! -----------------------
 
@@ -313,5 +319,5 @@
 
 
-      ! 5. Subdomain neighbours
+      ! 6. Subdomain neighbours
       ! ----------------------
 
@@ -436,8 +442,9 @@
          WRITE(numout,*) ' nimpp  = ', nimpp
          WRITE(numout,*) ' njmpp  = ', njmpp
-         WRITE(numout,*) ' nbse   = ', nbse  , ' npse   = ', npse
-         WRITE(numout,*) ' nbsw   = ', nbsw  , ' npsw   = ', npsw
-         WRITE(numout,*) ' nbne   = ', nbne  , ' npne   = ', npne
-         WRITE(numout,*) ' nbnw   = ', nbnw  , ' npnw   = ', npnw
+         WRITE(numout,*) ' nreci  = ', nreci  , ' npse   = ', npse
+         WRITE(numout,*) ' nrecj  = ', nrecj  , ' npsw   = ', npsw
+         WRITE(numout,*) ' jpreci = ', jpreci , ' npne   = ', npne
+         WRITE(numout,*) ' jprecj = ', jprecj , ' npnw   = ', npnw
+         WRITE(numout,*)
       ENDIF
 
@@ -446,7 +453,8 @@
       ! Prepare mpp north fold
 
-      IF (jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
+      IF( jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
          CALL mpp_ini_north
-      END IF
+         IF(lwp) WRITE(numout,*) ' mpp_init : North fold boundary prepared for jpni >1'
+      ENDIF
 
       ! Prepare NetCDF output file (if necessary)
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/LBC/mppini_2.h90	(revision 6436)
@@ -318,10 +318,12 @@
          ENDIF
 
+         ! Check wet points over the entire domain to preserve the MPI communication stencil
          isurf = 0
-         DO jj = 1+jprecj, ilj-jprecj
-            DO  ji = 1+jpreci, ili-jpreci
+         DO jj = 1, ilj
+            DO  ji = 1, ili
                IF( imask(ji+iimppt(ii,ij)-1, jj+ijmppt(ii,ij)-1) == 1) isurf = isurf+1
             END DO
          END DO
+
          IF(isurf /= 0) THEN
             icont = icont + 1
@@ -333,5 +335,4 @@
 
       nfipproc(:,:) = ipproc(:,:)
-
 
       ! Control
@@ -441,4 +442,16 @@
       ii = iin(narea)
       ij = ijn(narea)
+
+      ! set default neighbours
+      noso = ioso(ii,ij)
+      nowe = iowe(ii,ij)
+      noea = ioea(ii,ij)
+      nono = iono(ii,ij) 
+      npse = iose(ii,ij)
+      npsw = iosw(ii,ij)
+      npne = ione(ii,ij)
+      npnw = ionw(ii,ij)
+
+      ! check neighbours location
       IF( ioso(ii,ij) >= 0 .AND. ioso(ii,ij) <= (jpni*jpnj-1) ) THEN 
          iiso = 1 + MOD(ioso(ii,ij),jpni)
@@ -511,4 +524,5 @@
       IF (lwp) THEN
          CALL ctl_opn( inum, 'layout.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea )
+         WRITE(inum,'(a)') '   jpnij     jpi     jpj     jpk  jpiglo  jpjglo'
          WRITE(inum,'(6i8)') jpnij,jpi,jpj,jpk,jpiglo,jpjglo
          WRITE(inum,'(a)') 'NAREA nlci nlcj nldi nldj nlei nlej nimpp njmpp'
@@ -523,13 +537,4 @@
       END IF
 
-      IF( nperio == 1 .AND.jpni /= 1 ) CALL ctl_stop( ' mpp_init2:  error on cyclicity' )
-
-      ! Prepare mpp north fold
-
-      IF( jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
-         CALL mpp_ini_north
-         IF(lwp) WRITE(numout,*) ' mpp_init2 : North fold boundary prepared for jpni >1'
-      ENDIF
-
       ! Defined npolj, either 0, 3 , 4 , 5 , 6
       ! In this case the important thing is that npolj /= 0
@@ -548,28 +553,37 @@
       ENDIF
 
+      ! Periodicity : no corner if nbondi = 2 and nperio != 1
+
+      IF(lwp) THEN
+         WRITE(numout,*) ' nproc  = ', nproc
+         WRITE(numout,*) ' nowe   = ', nowe  , ' noea   =  ', noea
+         WRITE(numout,*) ' nono   = ', nono  , ' noso   =  ', noso
+         WRITE(numout,*) ' nbondi = ', nbondi
+         WRITE(numout,*) ' nbondj = ', nbondj
+         WRITE(numout,*) ' npolj  = ', npolj
+         WRITE(numout,*) ' nperio = ', nperio
+         WRITE(numout,*) ' nlci   = ', nlci
+         WRITE(numout,*) ' nlcj   = ', nlcj
+         WRITE(numout,*) ' nimpp  = ', nimpp
+         WRITE(numout,*) ' njmpp  = ', njmpp
+         WRITE(numout,*) ' nreci  = ', nreci  , ' npse   = ', npse
+         WRITE(numout,*) ' nrecj  = ', nrecj  , ' npsw   = ', npsw
+         WRITE(numout,*) ' jpreci = ', jpreci , ' npne   = ', npne
+         WRITE(numout,*) ' jprecj = ', jprecj , ' npnw   = ', npnw
+         WRITE(numout,*)
+      ENDIF
+
+      IF( nperio == 1 .AND. jpni /= 1 ) CALL ctl_stop( ' mpp_init2: error on cyclicity' )
+
+      ! Prepare mpp north fold
+
+      IF( jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
+         CALL mpp_ini_north
+         IF(lwp) WRITE(numout,*) ' mpp_init2 : North fold boundary prepared for jpni >1'
+      ENDIF
+
       ! Prepare NetCDF output file (if necessary)
       CALL mpp_init_ioipsl
 
-      ! Periodicity : no corner if nbondi = 2 and nperio != 1
-
-      IF(lwp) THEN
-         WRITE(numout,*) ' nproc=  ',nproc
-         WRITE(numout,*) ' nowe=   ',nowe
-         WRITE(numout,*) ' noea=   ',noea
-         WRITE(numout,*) ' nono=   ',nono
-         WRITE(numout,*) ' noso=   ',noso
-         WRITE(numout,*) ' nbondi= ',nbondi
-         WRITE(numout,*) ' nbondj= ',nbondj
-         WRITE(numout,*) ' npolj=  ',npolj
-         WRITE(numout,*) ' nperio= ',nperio
-         WRITE(numout,*) ' nlci=   ',nlci
-         WRITE(numout,*) ' nlcj=   ',nlcj
-         WRITE(numout,*) ' nimpp=  ',nimpp
-         WRITE(numout,*) ' njmpp=  ',njmpp
-         WRITE(numout,*) ' nbse=   ',nbse,' npse= ',npse
-         WRITE(numout,*) ' nbsw=   ',nbsw,' npsw= ',npsw
-         WRITE(numout,*) ' nbne=   ',nbne,' npne= ',npne
-         WRITE(numout,*) ' nbnw=   ',nbnw,' npnw= ',npnw
-      ENDIF
 
    END SUBROUTINE mpp_init2
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 6436)
@@ -188,10 +188,8 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF (miku(ji,jj) .GT. miku(ji+1,jj)) zhmlpu(ji,jj) = MAX(hmlpt(ji  ,jj  ),                   5._wp)
-                  IF (miku(ji,jj) .LT. miku(ji+1,jj)) zhmlpu(ji,jj) = MAX(hmlpt(ji+1,jj  ),                   5._wp)
-                  IF (miku(ji,jj) .EQ. miku(ji+1,jj)) zhmlpu(ji,jj) = MAX(hmlpt(ji  ,jj  ), hmlpt(ji+1,jj  ), 5._wp)
-                  IF (mikv(ji,jj) .GT. miku(ji,jj+1)) zhmlpv(ji,jj) = MAX(hmlpt(ji  ,jj  ),                   5._wp)
-                  IF (mikv(ji,jj) .LT. miku(ji,jj+1)) zhmlpv(ji,jj) = MAX(hmlpt(ji  ,jj+1),                   5._wp)
-                  IF (mikv(ji,jj) .EQ. miku(ji,jj+1)) zhmlpv(ji,jj) = MAX(hmlpt(ji  ,jj  ), hmlpt(ji  ,jj+1), 5._wp)
+               zhmlpu(ji,jj) = ( MAX(hmlpt(ji,jj)  , hmlpt  (ji+1,jj  ), 5._wp)   &
+                  &            - MAX(risfdep(ji,jj), risfdep(ji+1,jj  )       )   )
+               zhmlpv(ji,jj) = ( MAX(hmlpt  (ji,jj), hmlpt  (ji  ,jj+1), 5._wp)   &
+                  &            - MAX(risfdep(ji,jj), risfdep(ji  ,jj+1)       )   )
                ENDDO
             ENDDO
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_ice.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_ice.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_ice.F90	(revision 6436)
@@ -80,5 +80,6 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qemp_oce       !: heat flux of precip and evap over ocean     [W/m2]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qemp_ice       !: heat flux of precip and evap over ice       [W/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qprec_ice      !: heat flux of precip over ice                [J/m3]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qevap_ice      !: heat flux of evap over ice                  [W/m2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   qprec_ice      !: enthalpy of precip over ice                 [J/m3]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   emp_oce        !: evap - precip over ocean                 [kg/m2/s]
 #endif
@@ -144,7 +145,7 @@
 #endif
 #if defined key_lim3
-         &      evap_ice(jpi,jpj,jpl) , devap_ice(jpi,jpj,jpl) , qprec_ice(jpi,jpj) ,  &
-         &      qemp_ice(jpi,jpj)     , qemp_oce(jpi,jpj)      ,                       &
-         &      qns_oce (jpi,jpj)     , qsr_oce (jpi,jpj)      , emp_oce (jpi,jpj)  ,  &
+         &      evap_ice(jpi,jpj,jpl) , devap_ice(jpi,jpj,jpl) , qprec_ice(jpi,jpj) ,   &
+         &      qemp_ice(jpi,jpj)     , qevap_ice(jpi,jpj,jpl) , qemp_oce (jpi,jpj) ,   &
+         &      qns_oce (jpi,jpj)     , qsr_oce  (jpi,jpj)     , emp_oce (jpi,jpj)  ,   &
 #endif
          &      emp_ice(jpi,jpj)      ,  STAT= ierr(1) )
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90	(revision 6436)
@@ -684,4 +684,10 @@
       qprec_ice(:,:) = rhosn * ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus )
 
+      ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- !
+      DO jl = 1, jpl
+         qevap_ice(:,:,jl) = 0._wp ! should be -evap_ice(:,:,jl)*( ( Tice - rt0 ) * cpic * tmask(:,:,1) - lfus )
+                                   ! but then qemp_ice should also include sublimation 
+      END DO
+
       CALL wrk_dealloc( jpi,jpj, zevap, zsnw ) 
 #endif
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 6436)
@@ -612,7 +612,7 @@
       ! --- evaporation --- !
       z1_lsub = 1._wp / Lsub
-      evap_ice (:,:,:) = qla_ice (:,:,:) * z1_lsub ! sublimation
-      devap_ice(:,:,:) = dqla_ice(:,:,:) * z1_lsub
-      zevap    (:,:)   = emp(:,:) + tprecip(:,:)   ! evaporation over ocean
+      evap_ice (:,:,:) = rn_efac * qla_ice (:,:,:) * z1_lsub    ! sublimation
+      devap_ice(:,:,:) = rn_efac * dqla_ice(:,:,:) * z1_lsub    ! d(sublimation)/dT
+      zevap    (:,:)   = rn_efac * ( emp(:,:) + tprecip(:,:) )  ! evaporation over ocean
 
       ! --- evaporation minus precipitation --- !
@@ -637,4 +637,10 @@
       ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- !
       qprec_ice(:,:) = rhosn * ( ( MIN( sf(jp_tair)%fnow(:,:,1), rt0_snow ) - rt0 ) * cpic * tmask(:,:,1) - lfus )
+
+      ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- !
+      DO jl = 1, jpl
+         qevap_ice(:,:,jl) = 0._wp ! should be -evap_ice(:,:,jl)*( ( Tice - rt0 ) * cpic * tmask(:,:,1) )
+                                   ! But we do not have Tice => consider it at 0°C => evap=0 
+      END DO
 
       CALL wrk_dealloc( jpi,jpj, zevap, zsnw ) 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 6436)
@@ -1378,14 +1378,16 @@
       !
       INTEGER ::   jl         ! dummy loop index
-      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zcptn, ztmp, zicefr, zmsk
-      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zemp_tot, zemp_ice, zsprecip, ztprecip, zqns_tot, zqsr_tot
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zqns_ice, zqsr_ice, zdqns_ice
-      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zevap, zsnw, zqns_oce, zqsr_oce, zqprec_ice, zqemp_oce ! for LIM3
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zcptn, ztmp, zicefr, zmsk, zsnw
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap, zevap_ice, zdevap_ice
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('sbc_cpl_ice_flx')
       !
-      CALL wrk_alloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zemp_tot, zemp_ice, zsprecip, ztprecip, zqns_tot, zqsr_tot )
-      CALL wrk_alloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice )
+      CALL wrk_alloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zsnw )
+      CALL wrk_alloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap, zevap_ice, zdevap_ice )
+      CALL wrk_alloc( jpi,jpj,     zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice )
+      CALL wrk_alloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice )
 
       IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0)
@@ -1423,8 +1425,57 @@
       END SELECT
 
-      IF( iom_use('subl_ai_cea') )   &
-         CALL iom_put( 'subl_ai_cea', frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) )   ! Sublimation over sea-ice         (cell average)
-      !   
-      !                                                           ! runoffs and calving (put in emp_tot)
+#if defined key_lim3
+      ! zsnw = snow percentage over ice after wind blowing
+      zsnw(:,:) = 0._wp
+      CALL lim_thd_snwblow( p_frld, zsnw )
+      
+      ! --- evaporation (kg/m2/s) --- !
+      zevap_ice(:,:) = frcv(jpr_ievp)%z3(:,:,1)
+      ! since the sensitivity of evap to temperature (devap/dT) is not prescribed by the atmosphere, we set it to 0
+      ! therefore, sublimation is not redistributed over the ice categories in case no subgrid scale fluxes are provided by atm.
+      zdevap_ice(:,:) = 0._wp
+      
+      ! --- evaporation minus precipitation corrected for the effect of wind blowing on snow --- !
+      zemp_oce(:,:) = zemp_tot(:,:) - zemp_ice(:,:) - zsprecip * (1._wp - zsnw)
+      zemp_ice(:,:) = zemp_ice(:,:) + zsprecip * (1._wp - zsnw)          
+
+      ! Sublimation over sea-ice (cell average)
+      IF( iom_use('subl_ai_cea') )  CALL iom_put( 'subl_ai_cea', zevap_ice(:,:) * zicefr(:,:) )
+      ! runoffs and calving (put in emp_tot)
+      IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
+      IF( srcv(jpr_cal)%laction ) THEN 
+         zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1)
+         CALL iom_put( 'calving_cea', frcv(jpr_cal)%z3(:,:,1) )
+      ENDIF
+
+      IF( ln_mixcpl ) THEN
+         emp_tot(:,:) = emp_tot(:,:) * xcplmask(:,:,0) + zemp_tot(:,:) * zmsk(:,:)
+         emp_ice(:,:) = emp_ice(:,:) * xcplmask(:,:,0) + zemp_ice(:,:) * zmsk(:,:)
+         emp_oce(:,:) = emp_oce(:,:) * xcplmask(:,:,0) + zemp_oce(:,:) * zmsk(:,:)
+         sprecip(:,:) = sprecip(:,:) * xcplmask(:,:,0) + zsprecip(:,:) * zmsk(:,:)
+         tprecip(:,:) = tprecip(:,:) * xcplmask(:,:,0) + ztprecip(:,:) * zmsk(:,:)
+         DO jl=1,jpl
+            evap_ice (:,:,jl) = evap_ice (:,:,jl) * xcplmask(:,:,0) + zevap_ice (:,:) * zmsk(:,:)
+            devap_ice(:,:,jl) = devap_ice(:,:,jl) * xcplmask(:,:,0) + zdevap_ice(:,:) * zmsk(:,:)
+         ENDDO
+      ELSE
+         emp_tot(:,:) =         zemp_tot(:,:)
+         emp_ice(:,:) =         zemp_ice(:,:)
+         emp_oce(:,:) =         zemp_oce(:,:)     
+         sprecip(:,:) =         zsprecip(:,:)
+         tprecip(:,:) =         ztprecip(:,:)
+         DO jl=1,jpl
+            evap_ice (:,:,jl) = zevap_ice (:,:)
+            devap_ice(:,:,jl) = zdevap_ice(:,:)
+         ENDDO
+      ENDIF
+
+                                     CALL iom_put( 'snowpre'    , sprecip                         )  ! Snow
+      IF( iom_use('snow_ao_cea') )   CALL iom_put( 'snow_ao_cea', sprecip(:,:) * ( 1._wp - zsnw ) )  ! Snow over ice-free ocean  (cell average)
+      IF( iom_use('snow_ai_cea') )   CALL iom_put( 'snow_ai_cea', sprecip(:,:) *           zsnw   )  ! Snow over sea-ice         (cell average)    
+#else
+      ! Sublimation over sea-ice (cell average)
+      IF( iom_use('subl_ai_cea') )  CALL iom_put( 'subl_ai_cea', frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) )
+      ! runoffs and calving (put in emp_tot)
       IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
       IF( srcv(jpr_cal)%laction ) THEN 
@@ -1450,4 +1501,5 @@
       IF( iom_use('snow_ai_cea') )   &
          CALL iom_put( 'snow_ai_cea', sprecip(:,:) * zicefr(:,:)             )   ! Snow        over sea-ice         (cell average)
+#endif
 
       !                                                      ! ========================= !
@@ -1505,18 +1557,7 @@
       IF( iom_use('hflx_snow_cea') )    CALL iom_put( 'hflx_snow_cea', ztmp + sprecip(:,:) * zcptn(:,:) )   ! heat flux from snow (cell average)
 
-#if defined key_lim3
-      CALL wrk_alloc( jpi,jpj, zevap, zsnw, zqns_oce, zqprec_ice, zqemp_oce ) 
-
+#if defined key_lim3      
       ! --- evaporation --- !
-      ! clem: evap_ice is set to 0 for LIM3 since we still do not know what to do with sublimation
-      ! the problem is: the atm. imposes both mass evaporation and heat removed from the snow/ice
-      !                 but it is incoherent WITH the ice model  
-      DO jl=1,jpl
-         evap_ice(:,:,jl) = 0._wp  ! should be: frcv(jpr_ievp)%z3(:,:,1)
-      ENDDO
       zevap(:,:) = zemp_tot(:,:) + ztprecip(:,:) ! evaporation over ocean
-
-      ! --- evaporation minus precipitation --- !
-      emp_oce(:,:) = emp_tot(:,:) - emp_ice(:,:)
 
       ! --- non solar flux over ocean --- !
@@ -1525,18 +1566,23 @@
       WHERE( p_frld /= 0._wp )  zqns_oce(:,:) = ( zqns_tot(:,:) - SUM( a_i * zqns_ice, dim=3 ) ) / p_frld(:,:)
 
-      ! --- heat flux associated with emp --- !
-      zsnw(:,:) = 0._wp
-      CALL lim_thd_snwblow( p_frld, zsnw )  ! snow distribution over ice after wind blowing
+      ! --- heat flux associated with emp (W/m2) --- !
       zqemp_oce(:,:) = -      zevap(:,:)                   * p_frld(:,:)      *   zcptn(:,:)   &      ! evap
          &             + ( ztprecip(:,:) - zsprecip(:,:) )                    *   zcptn(:,:)   &      ! liquid precip
          &             +   zsprecip(:,:)                   * ( 1._wp - zsnw ) * ( zcptn(:,:) - lfus ) ! solid precip over ocean
-      qemp_ice(:,:)  = -   frcv(jpr_ievp)%z3(:,:,1)        * zicefr(:,:)      *   zcptn(:,:)   &      ! ice evap
-         &             +   zsprecip(:,:)                   * zsnw             * ( zcptn(:,:) - lfus ) ! solid precip over ice
-
+!      zqemp_ice(:,:) = -   frcv(jpr_ievp)%z3(:,:,1)        * zicefr(:,:)      *   zcptn(:,:)   &      ! ice evap
+!         &             +   zsprecip(:,:)                   * zsnw             * ( zcptn(:,:) - lfus ) ! solid precip over ice
+      zqemp_ice(:,:) =      zsprecip(:,:)                   * zsnw             * ( zcptn(:,:) - lfus ) ! solid precip over ice (only)
+                                                                                                       ! qevap_ice=0 since we consider Tice=0°C
+      
       ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- !
       zqprec_ice(:,:) = rhosn * ( zcptn(:,:) - lfus )
 
-      ! --- total non solar flux --- !
-      zqns_tot(:,:) = zqns_tot(:,:) + qemp_ice(:,:) + zqemp_oce(:,:)
+      ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- !
+      DO jl = 1, jpl
+         zqevap_ice(:,:,jl) = 0._wp ! should be -evap * ( ( Tice - rt0 ) * cpic ) but we do not have Tice, so we consider Tice=0°C
+      END DO
+
+      ! --- total non solar flux (including evap/precip) --- !
+      zqns_tot(:,:) = zqns_tot(:,:) + zqemp_ice(:,:) + zqemp_oce(:,:)
 
       ! --- in case both coupled/forced are active, we must mix values --- ! 
@@ -1545,20 +1591,20 @@
          qns_oce(:,:) = qns_oce(:,:) * xcplmask(:,:,0) + zqns_oce(:,:)* zmsk(:,:)
          DO jl=1,jpl
-            qns_ice(:,:,jl) = qns_ice(:,:,jl) * xcplmask(:,:,0) +  zqns_ice(:,:,jl)* zmsk(:,:)
+            qns_ice  (:,:,jl) = qns_ice  (:,:,jl) * xcplmask(:,:,0) +  zqns_ice  (:,:,jl)* zmsk(:,:)
+            qevap_ice(:,:,jl) = qevap_ice(:,:,jl) * xcplmask(:,:,0) +  zqevap_ice(:,:,jl)* zmsk(:,:)
          ENDDO
          qprec_ice(:,:) = qprec_ice(:,:) * xcplmask(:,:,0) + zqprec_ice(:,:)* zmsk(:,:)
          qemp_oce (:,:) =  qemp_oce(:,:) * xcplmask(:,:,0) +  zqemp_oce(:,:)* zmsk(:,:)
-!!clem         evap_ice(:,:) = evap_ice(:,:) * xcplmask(:,:,0)
+         qemp_ice (:,:) =  qemp_ice(:,:) * xcplmask(:,:,0) +  zqemp_ice(:,:)* zmsk(:,:)
       ELSE
          qns_tot  (:,:  ) = zqns_tot  (:,:  )
          qns_oce  (:,:  ) = zqns_oce  (:,:  )
          qns_ice  (:,:,:) = zqns_ice  (:,:,:)
-         qprec_ice(:,:)   = zqprec_ice(:,:)
-         qemp_oce (:,:)   = zqemp_oce (:,:)
-      ENDIF
-
-      CALL wrk_dealloc( jpi,jpj, zevap, zsnw, zqns_oce, zqprec_ice, zqemp_oce ) 
+         qevap_ice(:,:,:) = zqevap_ice(:,:,:)
+         qprec_ice(:,:  ) = zqprec_ice(:,:  )
+         qemp_oce (:,:  ) = zqemp_oce (:,:  )
+         qemp_ice (:,:  ) = zqemp_ice (:,:  )
+      ENDIF
 #else
-
       ! clem: this formulation is certainly wrong... but better than it was...
       zqns_tot(:,:) = zqns_tot(:,:)                       &            ! zqns_tot update over free ocean with:
@@ -1577,5 +1623,4 @@
          qns_ice(:,:,:) = zqns_ice(:,:,:)
       ENDIF
-
 #endif
 
@@ -1628,5 +1673,4 @@
 
 #if defined key_lim3
-      CALL wrk_alloc( jpi,jpj, zqsr_oce ) 
       ! --- solar flux over ocean --- !
       !         note: p_frld cannot be = 0 since we limit the ice concentration to amax
@@ -1636,6 +1680,4 @@
       IF( ln_mixcpl ) THEN   ;   qsr_oce(:,:) = qsr_oce(:,:) * xcplmask(:,:,0) +  zqsr_oce(:,:)* zmsk(:,:)
       ELSE                   ;   qsr_oce(:,:) = zqsr_oce(:,:)   ;   ENDIF
-
-      CALL wrk_dealloc( jpi,jpj, zqsr_oce ) 
 #endif
 
@@ -1688,6 +1730,8 @@
       fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )
 
-      CALL wrk_dealloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zemp_tot, zemp_ice, zsprecip, ztprecip, zqns_tot, zqsr_tot )
-      CALL wrk_dealloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice )
+      CALL wrk_dealloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zsnw )
+      CALL wrk_dealloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap, zevap_ice, zdevap_ice )
+      CALL wrk_dealloc( jpi,jpj,     zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice )
+      CALL wrk_dealloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice )
       !
       IF( nn_timing == 1 )  CALL timing_stop('sbc_cpl_ice_flx')
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 6436)
@@ -203,5 +203,5 @@
             ! In CLIO the cloud fraction is read in the climatology and the all-sky albedo 
             ! (alb_ice) is computed within the bulk routine
-            CALL blk_ice_clio_flx( t_su, zalb_cs, zalb_os, alb_ice )
+                                 CALL blk_ice_clio_flx( t_su, zalb_cs, zalb_os, alb_ice )
             IF( ln_mixcpl      ) CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=alb_ice, psst=sst_m, pist=t_su )
             IF( nn_limflx /= 2 ) CALL ice_lim_flx( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_limflx )
@@ -209,5 +209,5 @@
             ! albedo depends on cloud fraction because of non-linear spectral effects
             alb_ice(:,:,:) = ( 1. - cldf_ice ) * zalb_cs(:,:,:) + cldf_ice * zalb_os(:,:,:)
-            CALL blk_ice_core_flx( t_su, alb_ice )
+                                 CALL blk_ice_core_flx( t_su, alb_ice )
             IF( ln_mixcpl      ) CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=alb_ice, psst=sst_m, pist=t_su )
             IF( nn_limflx /= 2 ) CALL ice_lim_flx( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_limflx )
@@ -216,7 +216,4 @@
             alb_ice(:,:,:) = ( 1. - cldf_ice ) * zalb_cs(:,:,:) + cldf_ice * zalb_os(:,:,:)
                                  CALL sbc_cpl_ice_flx( p_frld=pfrld, palbi=alb_ice, psst=sst_m, pist=t_su )
-            ! clem: evap_ice is forced to 0 in coupled mode for now 
-            !       but it needs to be changed (along with modif in limthd_dh) once heat flux from evap will be avail. from atm. models
-            evap_ice  (:,:,:) = 0._wp   ;   devap_ice (:,:,:) = 0._wp
             IF( nn_limflx == 2 ) CALL ice_lim_flx( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_limflx )
          END SELECT
@@ -588,5 +585,5 @@
       sfx_bog(:,:) = 0._wp   ;   sfx_dyn(:,:) = 0._wp
       sfx_bom(:,:) = 0._wp   ;   sfx_sum(:,:) = 0._wp
-      sfx_res(:,:) = 0._wp
+      sfx_res(:,:) = 0._wp   ;   sfx_sub(:,:) = 0._wp
       
       wfx_snw(:,:) = 0._wp   ;   wfx_ice(:,:) = 0._wp
@@ -604,6 +601,7 @@
       hfx_spr(:,:) = 0._wp   ;   hfx_dif(:,:) = 0._wp 
       hfx_err(:,:) = 0._wp   ;   hfx_err_rem(:,:) = 0._wp
-      hfx_err_dif(:,:) = 0._wp   ;
-
+      hfx_err_dif(:,:) = 0._wp
+      wfx_err_sub(:,:) = 0._wp
+      
       afx_tot(:,:) = 0._wp   ;
       afx_dyn(:,:) = 0._wp   ;   afx_thd(:,:) = 0._wp
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 6436)
@@ -456,5 +456,6 @@
       !                                                ! ---------------------------------------- !
       IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN
-         CALL iom_put( "empmr" , emp  - rnf )                   ! upward water flux
+         CALL iom_put( "empmr"  , emp    - rnf )                ! upward water flux
+         CALL iom_put( "empbmr" , emp_b  - rnf )                ! before upward water flux ( needed to recalculate the time evolution of ssh in offline )
          CALL iom_put( "saltflx", sfx  )                        ! downward salt flux  
                                                                 ! (includes virtual salt flux beneath ice 
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/TRA/traldf.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/TRA/traldf.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/TRA/traldf.F90	(revision 6436)
@@ -215,4 +215,6 @@
       IF( ierr == 1 )   CALL ctl_stop( ' iso-level in z-coordinate - partial step, not allowed' )
       IF( ierr == 2 )   CALL ctl_stop( ' isoneutral bilaplacian operator does not exist' )
+      IF( ln_traldf_grif .AND. ln_isfcav         )   &
+           CALL ctl_stop( ' ice shelf and traldf_grif not tested')
       IF( lk_traldf_eiv .AND. .NOT.ln_traldf_iso )   &
            CALL ctl_stop( '          eddy induced velocity on tracers',   &
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfmxl.F90	(revision 6436)
@@ -80,7 +80,7 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
       !
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      INTEGER  ::   iikn, iiki, ikt, imkt   ! local integer
-      REAL(wp) ::   zN2_c        ! local scalar
+      INTEGER  ::   ji, jj, jk      ! dummy loop indices
+      INTEGER  ::   iikn, iiki, ikt ! local integer
+      REAL(wp) ::   zN2_c           ! local scalar
       INTEGER, POINTER, DIMENSION(:,:) ::   imld   ! 2D workspace
       !!----------------------------------------------------------------------
@@ -117,6 +117,5 @@
          DO jj = 1, jpj
             DO ji = 1, jpi
-               imkt = mikt(ji,jj)
-               IF( avt (ji,jj,jk) < avt_c )   imld(ji,jj) = MAX( imkt, jk )      ! Turbocline 
+               IF( avt (ji,jj,jk) < avt_c * wmask(ji,jj,jk) )   imld(ji,jj) = jk      ! Turbocline 
             END DO
          END DO
@@ -127,13 +126,25 @@
             iiki = imld(ji,jj)
             iikn = nmln(ji,jj)
-            imkt = mikt(ji,jj)
-            hmld (ji,jj) = ( fsdepw(ji,jj,iiki  ) - fsdepw(ji,jj,imkt ) ) * ssmask(ji,jj)    ! Turbocline depth 
-            hmlp (ji,jj) = ( fsdepw(ji,jj,iikn  ) - fsdepw(ji,jj,imkt ) ) * ssmask(ji,jj)    ! Mixed layer depth
-            hmlpt(ji,jj) = ( fsdept(ji,jj,iikn-1) - fsdepw(ji,jj,imkt ) ) * ssmask(ji,jj)    ! depth of the last T-point inside the mixed layer
+            hmld (ji,jj) = fsdepw(ji,jj,iiki  ) * ssmask(ji,jj)    ! Turbocline depth 
+            hmlp (ji,jj) = fsdepw(ji,jj,iikn  ) * ssmask(ji,jj)    ! Mixed layer depth
+            hmlpt(ji,jj) = fsdept(ji,jj,iikn-1) * ssmask(ji,jj)    ! depth of the last T-point inside the mixed layer
          END DO
       END DO
-      IF( .NOT.lk_offline ) THEN            ! no need to output in offline mode
-         CALL iom_put( "mldr10_1", hmlp )   ! mixed layer depth
-         CALL iom_put( "mldkz5"  , hmld )   ! turbocline depth
+      ! no need to output in offline mode
+      IF( .NOT.lk_offline ) THEN   
+         IF ( iom_use("mldr10_1") ) THEN
+            IF( ln_isfcav ) THEN
+               CALL iom_put( "mldr10_1", hmlp - risfdep)   ! mixed layer thickness
+            ELSE
+               CALL iom_put( "mldr10_1", hmlp )            ! mixed layer depth
+            END IF
+         END IF
+         IF ( iom_use("mldkz5") ) THEN
+            IF( ln_isfcav ) THEN
+               CALL iom_put( "mldkz5"  , hmld - risfdep )   ! turbocline thickness
+            ELSE
+               CALL iom_put( "mldkz5"  , hmld )             ! turbocline depth
+            END IF
+         END IF
       ENDIF
       
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 6436)
@@ -338,4 +338,5 @@
       !
       IF( lrst_oce         )   CALL rst_write( kstp )       ! write output ocean restart file
+      IF( ln_sto_eos       )   CALL sto_rst_write( kstp )   ! write restart file for stochastic parameters
 
 #if defined key_agrif
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90	(revision 6436)
@@ -133,6 +133,6 @@
          !
          CALL p4z_bio( kt, jnt )   ! Biology
-         CALL p4z_sed( kt, jnt )   ! Sedimentation
          CALL p4z_lys( kt, jnt )   ! Compute CaCO3 saturation
+         CALL p4z_sed( kt, jnt )   ! Surface and Bottom boundary conditions
          CALL p4z_flx( kt, jnt )   ! Compute surface fluxes
          !
Index: anches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-athena-xios
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-athena-xios	(revision 6435)
+++ 	(revision )
@@ -1,80 +1,0 @@
-#!/bin/bash 
-#!
-#BSUB -q poe_short
-#BSUB -n NPROCS
-#BSUB -a poe
-#BSUB -J MPI_config
-#BSUB -o poe.stdout.%J
-#BSUB -e poe.stderr.%J
-
- 
-
-###############################################################
-# Test specific settings. Do not hand edit these lines; the fcm_job.sh script will set these
-# (via sed operating on this template job file). 
-#
-  OCEANCORES=NPROCS
-  export SETTE_DIR=DEF_SETTE_DIR
-
-###############################################################
-#
-# set up mpp computing environment
-#
-# Local settings for machine IBM Power6 (VARGAS at IDRIS France)
-#
-
-# export MPIRUN="mpirun -n $OCEANCORES"
-
-export MPIRUN="mpirun.lsf"
-
-#
-# load sette functions (only post_test_tidyup needed)
-#
-  . ${SETTE_DIR}/all_functions.sh
-
-
-# Don't remove neither change the following line 
-# BODY
-
-#
-# These variables are needed by post_test_tidyup function in all_functions.sh
-#
-  export EXE_DIR=DEF_EXE_DIR
-  export INPUT_DIR=DEF_INPUT_DIR
-  export CONFIG_DIR=DEF_CONFIG_DIR
-  export NEMO_VALIDATION_DIR=DEF_NEMO_VALIDATION
-  export NEW_CONF=DEF_NEW_CONF
-  export CMP_NAM=DEF_CMP_NAM
-  export TEST_NAME=DEF_TEST_NAME
-#
-# end of set up
-
-
-###############################################################
-#
-# change to the working directory 
-#
-cd ${EXE_DIR}
-
-#
-  echo Running on host `hostname`
-  echo Time is `date`
-  echo Directory is `pwd`
-# 
-#  Run the parallel MPI executable 
-#
-#  echo "Running time ${MPIRUN} " $OCEANCORES " ./opa"
-#
-
-  if [ MPI_FLAG == "yes" ]; then
-     time ${MPIRUN} ./opa
-  else
-     time ./opa
-  fi
-#
-  post_test_tidyup
-
-# END_BODY
-# Don't remove neither change the previous line 
-
-  exit
Index: anches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-gfortran_athena_xios
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-gfortran_athena_xios	(revision 6435)
+++ 	(revision )
@@ -1,127 +1,0 @@
-#!/bin/bash 
-#!
-#BSUB -q poe_short
-#BSUB -n TOTAL_NPROCS
-#BSUB -a poe
-#BSUB -J MPI_config
-#BSUB -o poe.stdout.%J
-#BSUB -e poe.stderr.%J
-
- 
-
-###############################################################
-# Test specific settings. Do not hand edit these lines; the fcm_job.sh script will set these
-# (via sed operating on this template job file). 
-#
-  OCEANCORES=NPROCS
-  XIOS_NUMPROCS=NXIOPROCS
-  export SETTE_DIR=DEF_SETTE_DIR
-
-###############################################################
-#
-# set up mpp computing environment
-#
-# Local settings for machine IBM Power6 (VARGAS at IDRIS France)
-#
-
-# export MPIRUN="mpirun -n $OCEANCORES"
-
-export MPIRUN="mpirun.lsf"
-export LANG=en_US
-export NLSPATH=/opt/ibmhpc/pecurrent/base/msg/%L/%N:$NLSPATH
-export MP_LABELIO=yes
-export MP_STDOUTMODE=unordered
-export MP_EUILIB=us
-export MP_INFOLEVEL=0
-export MP_EUIDEVELOP=min
-export MP_INSTANCES=1
-export MP_SHARED_MEMORY=yes
-export MP_EAGER_LIMIT_LOCAL=2000000000
-export MP_EUIDEVICE=sn_single
-export MP_BULK_MIN_MSG_SIZE=16384
-export MP_POLLING_INTERVAL=1000000
-export MP_DEVTYPE=ib
-export MP_EAGER_LIMIT=262144
-export MP_TASK_AFFINITY=core
-export MP_BINDPROC=yes
-export MP_DEBUG_CHECK_PARAM=no
-export MP_MSG_API=mpi
-export MP_USE_BULK_XFER=yes
-export MP_WAIT_MODE=poll
-export LDR_CNTRL=TEXTPSIZE=64K@STACKPSIZE=64K@DATAPSIZE=64K
-export LD_LIBRARY_PATH=/users/home/ans040/local/lib:${LD_LIBRARY_PATH}
-
-XIOS_SERVER_PATHNAME="/users/home/ans040/SOFTWARE/XIOS/trunk/bin/xios_server.exe"
-
-
-#
-# load sette functions (only post_test_tidyup needed)
-#
-  . ${SETTE_DIR}/all_functions.sh
-
-
-# Don't remove neither change the following line 
-# BODY
-
-#
-# These variables are needed by post_test_tidyup function in all_functions.sh
-#
-  export EXE_DIR=DEF_EXE_DIR
-  export INPUT_DIR=DEF_INPUT_DIR
-  export CONFIG_DIR=DEF_CONFIG_DIR
-  export NEMO_VALIDATION_DIR=DEF_NEMO_VALIDATION
-  export NEW_CONF=DEF_NEW_CONF
-  export CMP_NAM=DEF_CMP_NAM
-  export TEST_NAME=DEF_TEST_NAME
-#
-# end of set up
-
-
-###############################################################
-#
-# change to the working directory 
-#
-cd ${EXE_DIR}
-
-#
-  echo Running on host `hostname`
-  echo Time is `date`
-  echo Directory is `pwd`
-# 
-#  Run the parallel MPI executable 
-#
-#  echo "Running time ${MPIRUN} " $OCEANCORES " ./opa"
-#
-
-  if [ MPI_FLAG == "yes" ]; then
-     if [ $XIOS_NUMPROCS -eq 0 ]; then
-       time ${MPIRUN} ./opa
-     else
-
-       export MP_PGMMODEL=mpmd
-       export MP_CMDFILE=xioscmdfile
-       rm xioscmdfile &> /dev/null
-       touch xioscmdfile
-       k=0
-       while (( k < $OCEANCORES )) ; do
-          echo ./opa >> xioscmdfile
-          k=`expr $k + 1`
-       done
-       k=0
-       while (( k < $XIOS_NUMPROCS )) ; do
-          echo $XIOS_SERVER_PATHNAME >> xioscmdfile
-          k=`expr $k + 1`
-       done
-
-       time ${MPIRUN}
-     fi
-  else
-     time ./opa
-  fi
-#
-  post_test_tidyup
-
-# END_BODY
-# Don't remove neither change the previous line 
-
-  exit
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-ifort_athena
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-ifort_athena	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-ifort_athena	(revision 6436)
@@ -0,0 +1,80 @@
+#!/bin/bash 
+#!
+#BSUB -q poe_short
+#BSUB -n NPROCS
+#BSUB -a poe
+#BSUB -J MPI_config
+#BSUB -o poe.stdout.%J
+#BSUB -e poe.stderr.%J
+
+ 
+
+###############################################################
+# Test specific settings. Do not hand edit these lines; the fcm_job.sh script will set these
+# (via sed operating on this template job file). 
+#
+  OCEANCORES=NPROCS
+  export SETTE_DIR=DEF_SETTE_DIR
+
+###############################################################
+#
+# set up mpp computing environment
+#
+# Local settings for machine IBM Power6 (VARGAS at IDRIS France)
+#
+
+# export MPIRUN="mpirun -n $OCEANCORES"
+
+export MPIRUN="mpirun.lsf"
+
+#
+# load sette functions (only post_test_tidyup needed)
+#
+  . ${SETTE_DIR}/all_functions.sh
+
+
+# Don't remove neither change the following line 
+# BODY
+
+#
+# These variables are needed by post_test_tidyup function in all_functions.sh
+#
+  export EXE_DIR=DEF_EXE_DIR
+  export INPUT_DIR=DEF_INPUT_DIR
+  export CONFIG_DIR=DEF_CONFIG_DIR
+  export NEMO_VALIDATION_DIR=DEF_NEMO_VALIDATION
+  export NEW_CONF=DEF_NEW_CONF
+  export CMP_NAM=DEF_CMP_NAM
+  export TEST_NAME=DEF_TEST_NAME
+#
+# end of set up
+
+
+###############################################################
+#
+# change to the working directory 
+#
+cd ${EXE_DIR}
+
+#
+  echo Running on host `hostname`
+  echo Time is `date`
+  echo Directory is `pwd`
+# 
+#  Run the parallel MPI executable 
+#
+#  echo "Running time ${MPIRUN} " $OCEANCORES " ./opa"
+#
+
+  if [ MPI_FLAG == "yes" ]; then
+     time ${MPIRUN} ./opa
+  else
+     time ./opa
+  fi
+#
+  post_test_tidyup
+
+# END_BODY
+# Don't remove neither change the previous line 
+
+  exit
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-ifort_athena_xios
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-ifort_athena_xios	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/SETTE/BATCH_TEMPLATE/batch-ifort_athena_xios	(revision 6436)
@@ -0,0 +1,106 @@
+#!/bin/bash 
+#!
+#BSUB -q poe_short
+#BSUB -n TOTAL_NPROCS
+#BSUB -a poe
+#BSUB -J MPI_config
+#BSUB -o poe.stdout.%J
+#BSUB -e poe.stderr.%J
+
+ 
+
+###############################################################
+# Test specific settings. Do not hand edit these lines; the fcm_job.sh script will set these
+# (via sed operating on this template job file). 
+#
+  OCEANCORES=NPROCS
+  XIOS_NUMPROCS=NXIOPROCS
+  export SETTE_DIR=DEF_SETTE_DIR
+
+###############################################################
+#
+# set up mpp computing environment
+#
+# Local settings for machine IBM Power6 (VARGAS at IDRIS France)
+#
+
+# export MPIRUN="mpirun -n $OCEANCORES"
+
+module load  INTEL/intel_xe_2013 NETCDF/netcdf-4.3_parallel NETCDF/parallel-netcdf-1.3.1 HDF5/hdf5-1.8.11_parallel
+export MPIRUN="mpirun.lsf"
+
+export LD_LIBRARY_PATH=${XIOS}/lib:${LD_LIBRARY_PATH}
+
+XIOS_SERVER_PATHNAME="${XIOS}/bin/xios_server.exe"
+
+#
+# load sette functions (only post_test_tidyup needed)
+#
+  . ${SETTE_DIR}/all_functions.sh
+
+
+# Don't remove neither change the following line 
+# BODY
+
+#
+# These variables are needed by post_test_tidyup function in all_functions.sh
+#
+  export EXE_DIR=DEF_EXE_DIR
+  export INPUT_DIR=DEF_INPUT_DIR
+  export CONFIG_DIR=DEF_CONFIG_DIR
+  export NEMO_VALIDATION_DIR=DEF_NEMO_VALIDATION
+  export NEW_CONF=DEF_NEW_CONF
+  export CMP_NAM=DEF_CMP_NAM
+  export TEST_NAME=DEF_TEST_NAME
+#
+# end of set up
+
+
+###############################################################
+#
+# change to the working directory 
+#
+cd ${EXE_DIR}
+
+#
+  echo Running on host `hostname`
+  echo Time is `date`
+  echo Directory is `pwd`
+# 
+#  Run the parallel MPI executable 
+#
+#  echo "Running time ${MPIRUN} " $OCEANCORES " ./opa"
+#
+
+  if [ MPI_FLAG == "yes" ]; then
+     if [ $XIOS_NUMPROCS -eq 0 ]; then
+       time ${MPIRUN} ./opa
+     else
+
+       export MP_PGMMODEL=mpmd
+       export MP_CMDFILE=xioscmdfile
+       rm xioscmdfile &> /dev/null
+       touch xioscmdfile
+       k=0
+       while (( k < $OCEANCORES )) ; do
+          echo ./opa >> xioscmdfile
+          k=`expr $k + 1`
+       done
+       k=0
+       while (( k < $XIOS_NUMPROCS )) ; do
+          echo $XIOS_SERVER_PATHNAME >> xioscmdfile
+          k=`expr $k + 1`
+       done
+
+       time ${MPIRUN}
+     fi
+  else
+     time ./opa
+  fi
+#
+  post_test_tidyup
+
+# END_BODY
+# Don't remove neither change the previous line 
+
+  exit
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/DMP_TOOLS/src/zoom.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/DMP_TOOLS/src/zoom.F90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/DMP_TOOLS/src/zoom.F90	(revision 6436)
@@ -29,7 +29,4 @@
       NAMELIST/nam_zoom_dmp/lzoom_n,lzoom_e,lzoom_w,lzoom_s
       !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start( 'dtacof_zoom')
-      !
       
       ! Read namelist
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/MISCELLANEOUS/icb_pp.py
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/MISCELLANEOUS/icb_pp.py	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/MISCELLANEOUS/icb_pp.py	(revision 6436)
@@ -55,5 +55,5 @@
 if procnum < 1:
    print('Need some files to collate! procnum = ',procnum)
-   sys.exit()
+   sys.exit(11)
 
 icu = []
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/MPP_PREP/src/mpp_optimiz_zoom_nc.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/MPP_PREP/src/mpp_optimiz_zoom_nc.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/MPP_PREP/src/mpp_optimiz_zoom_nc.f90	(revision 6436)
@@ -258,10 +258,13 @@
                  ijlb=ijdom(jni2,jnj2)
               ENDIF
+
+              ! Check wet points over the entire domain to preserve the MPI communication stencil
               isurf=0
-              DO jj=1+jprecj,ippdj(jni2,jnj2)-jprecj
-                 DO  ji=1+jpreci,ippdi(jni2,jnj2)-jpreci
+              DO jj=1,ippdj(jni2,jnj2)
+                 DO  ji=1,ippdi(jni2,jnj2)
                     IF(zmask(ji+iilb-1,jj+ijlb-1).EQ.1.) isurf=isurf+1
                  END DO
               END DO
+
               IF(isurf.EQ.0) THEN
                  ivide=ivide+1
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/MPP_PREP/src/mppopt_showproc_nc.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/MPP_PREP/src/mppopt_showproc_nc.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/MPP_PREP/src/mppopt_showproc_nc.f90	(revision 6436)
@@ -289,11 +289,13 @@
                  ijlb=ijdom(jni2,jnj2)
               ENDIF
+
+              ! Check wet points over the entire domain to preserve the MPI communication stencil
               isurf=0
-
-              DO jj=1+jprecj,ippdj(jni2,jnj2)-jprecj
-                 DO  ji=1+jpreci,ippdi(jni2,jnj2)-jpreci
+              DO jj=1,ippdj(jni2,jnj2)
+                 DO  ji=1,ippdi(jni2,jnj2)
                     IF(zmask(ji+iilb-1,jj+ijlb-1).EQ.1.) isurf=isurf+1
                  END DO
               END DO
+
               IF(isurf.EQ.0) THEN
                  ivide=ivide+1
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/REBUILD_NEMO/icb_combrest.py
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/REBUILD_NEMO/icb_combrest.py	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/REBUILD_NEMO/icb_combrest.py	(revision 6436)
@@ -0,0 +1,273 @@
+import os
+from netCDF4 import Dataset
+from argparse import ArgumentParser
+import numpy as np
+import sys
+
+#
+# Basic iceberg trajectory restart post-processing python script.
+# This script collects iceberg information from the distributed restarts written
+# out by each processing region and writes the information into a global restart file.
+# The global restart file must already exist and contain the collated 2D spatial fields
+# as prepared by utilities such as rebuild_nemo. This python script simply adds the
+# iceberg position and state data that is held using the unlimited dimension 'n' which
+# has been ignored by rebuild_nemo. Each processing region that contains icebergs will
+# (probably) have a different number of icebergs (indicated by differing values for the
+# current size of the unlimited dimension). This script collects all icebergs into a 
+# single unordered list.
+#
+
+parser = ArgumentParser(description='produce a global trajectory restart file from distributed output\
+                                     files, e.g. \n python ./icb_pp.py \
+                                     -f  icebergs_00692992_restart_ -n 480 -o icebergs_restart.nc [-O]')
+
+parser.add_argument('-f',dest='froot',help='fileroot_of_distrbuted_data; root name of \
+                     distributed trajectory restart file (usually completed with XXXX.nc, where \
+                     XXXX is the 4 digit processor number)', 
+                     default='icebergs_00692992_restart_')
+
+parser.add_argument('-n',dest='fnum',help='number of distributed files to process', 
+                     type=int, default=None)
+
+parser.add_argument('-o',dest='fout',help='global_iceberg_restart; file name to append the \
+                     global iceberg restart data to.', default='icebergs_restart.nc')
+
+parser.add_argument('-O',dest='fcre',help='Create the output file from scratch rather than \
+                     append to an existing file.', \
+                     action='store_true', default=False)
+
+args = parser.parse_args()
+
+default_used = 0
+if args.froot is None:
+    pathstart = 'icebergs_00692992_restart_'
+    default_used = 1
+else:
+    pathstart = args.froot
+
+if args.fnum is None:
+    procnum = 0
+    default_used = 1
+else:
+    procnum = args.fnum
+
+if args.fout is None:
+    pathout = 'icebergs_restart.nc'
+    default_used = 1
+else:
+    pathout = args.fout
+
+if default_used == 1:
+   print('At least one default value will be used; command executing is:')
+   print('icb_combrest.py -f ',pathstart,' -n ',procnum,' -o ',pathout)
+
+if procnum < 1:
+   print('Need some files to collate! procnum = ',procnum)
+   sys.exit(11)
+
+icu = []
+times = []
+ntraj = 0
+nk = 0
+#
+# Loop through all distributed datasets to obtain the total number 
+# of icebergs to transfer
+#
+for n in range(procnum):
+ nn = '%4.4d' % n
+ try:
+   fw = Dataset(pathstart+nn+'.nc')
+ except:
+   print 'Error: unable to open input file: ' + pathstart+nn+'.nc'
+   sys.exit(12)
+ for d in fw.dimensions :
+  if d == 'n' :
+   if len(fw.dimensions['n']) > 0:
+#    print 'icebergs found in: ' + pathstart+nn+'.nc' 
+     if len(fw.dimensions['k']) > nk :
+       nk = len(fw.dimensions['k'])
+     ntraj = ntraj + len(fw.dimensions['n'])
+ fw.close()
+#
+print(ntraj, ' icebergs found across all datasets')
+#
+# Declare 2-D arrays to receive the data from all files
+#
+lons = np.zeros(ntraj)
+lats = np.zeros(ntraj)
+xis  = np.zeros(ntraj)
+yjs  = np.zeros(ntraj)
+uvs  = np.zeros(ntraj)
+vvs  = np.zeros(ntraj)
+mas  = np.zeros(ntraj)
+ths  = np.zeros(ntraj)
+wis  = np.zeros(ntraj)
+les  = np.zeros(ntraj)
+dys  = np.zeros(ntraj)
+mss  = np.zeros(ntraj)
+msb  = np.zeros(ntraj)
+hds  = np.zeros(ntraj)
+yrs  = np.zeros(ntraj      , dtype=int)
+num  = np.zeros((ntraj, nk), dtype=int)
+#
+# loop through distributed datasets again, this time
+# collecting all trajectory data
+#
+nt = 0
+for n in range(procnum):
+ nn = '%4.4d' % n
+ fw = Dataset(pathstart+nn+'.nc')
+ for d in fw.dimensions :
+  if d == 'n' :
+# Note many distributed datafiles will contain no iceberg data
+# so skip quickly over these
+    m  = len(fw.dimensions['n'])
+    if m > 0:
+#     print pathstart+nn+'.nc'
+      lons[nt:nt+m]  = fw.variables['lon'][:]
+      lats[nt:nt+m]  = fw.variables['lat'][:]
+      xis[nt:nt+m]   = fw.variables['xi'][:]
+      yjs[nt:nt+m]   = fw.variables['yj'][:]
+      uvs[nt:nt+m]   = fw.variables['uvel'][:]
+      vvs[nt:nt+m]   = fw.variables['vvel'][:]
+      mas[nt:nt+m]   = fw.variables['mass'][:]
+      ths[nt:nt+m]   = fw.variables['thickness'][:]
+      wis[nt:nt+m]   = fw.variables['width'][:]
+      les[nt:nt+m]   = fw.variables['length'][:]
+      dys[nt:nt+m]   = fw.variables['day'][:]
+      mss[nt:nt+m]   = fw.variables['mass_scaling'][:]
+      msb[nt:nt+m]   = fw.variables['mass_of_bits'][:]
+      hds[nt:nt+m]   = fw.variables['heat_density'][:]
+      yrs[nt:nt+m]   = fw.variables['year'][:]
+      num[nt:nt+m,:] = fw.variables['number'][:,:]
+      nt = nt + m
+ fw.close()
+
+# Finally create the output file and write out the collated sets
+#
+if args.fcre :
+  try:
+    fo = Dataset(pathout, 'w', format='NETCDF4')
+  except:
+    print 'Error accessing output file: ' + pathout
+    print 'Check it is a writable location.'
+    sys.exit(13)
+else :
+  # Copy 2D variables across to output file from input file. This step avoids problems if rebuild_nemo 
+  # has created an "n" dimension in the prototype rebuilt file (ie. if there are icebergs on the zeroth 
+  # processor). 
+  try:
+    os.rename(pathout,pathout.replace('.nc','_WORK.nc'))
+  except OSError:
+    print 'Error: unable to move icebergs restart file: '+pathout
+    sys.exit(14)
+  #
+  try:
+    fi = Dataset(pathout.replace('.nc','_WORK.nc'), 'r')
+  except:
+    print 'Error: unable to open icebergs restart file: '+pathout.replace('.nc','_WORK.nc')
+    sys.exit(15)
+  fo = Dataset(pathout, 'w')
+  for dim in ['x','y','c']:
+    indim = fi.dimensions[dim]
+    fo.createDimension(dim, len(indim))
+  for var in ['calving','calving_hflx','stored_ice','stored_heat']:
+    invar = fi.variables[var]
+    fo.createVariable(var, invar.datatype, invar.dimensions)
+    fo.variables[var][:] = invar[:]
+    fo.variables[var].long_name = invar.long_name
+    fo.variables[var].units = invar.units
+    os.remove(pathout.replace('.nc','_WORK.nc'))
+#
+add_k = 1
+for d in fo.dimensions :
+  if d == 'n' :
+    print 'Error: dimension n already exists in output file'
+    sys.exit(16)
+  if d == 'k' :
+    add_k = 0
+onn  = fo.createDimension('n', None)
+if add_k > 0 :
+ onk = fo.createDimension('k', nk)
+olon = fo.createVariable('lon', 'f8',('n'))
+olat = fo.createVariable('lat', 'f8',('n'))
+oxis = fo.createVariable('xi', 'f8',('n'))
+oyjs = fo.createVariable('yj', 'f8',('n'))
+ouvs = fo.createVariable('uvel', 'f8',('n'))
+ovvs = fo.createVariable('vvel', 'f8',('n'))
+omas = fo.createVariable('mass', 'f8',('n'))
+oths = fo.createVariable('thickness', 'f8',('n'))
+owis = fo.createVariable('width', 'f8',('n'))
+oles = fo.createVariable('length', 'f8',('n'))
+odys = fo.createVariable('day', 'f8',('n'))
+omss = fo.createVariable('mass_scaling', 'f8',('n'))
+omsb = fo.createVariable('mass_of_bits', 'f8',('n'))
+ohds = fo.createVariable('heat_density', 'f8',('n'))
+oyrs = fo.createVariable('year', 'i4',('n'))
+onum = fo.createVariable('number', 'i4',('n','k'))
+#
+olon[:] = lons
+olon.long_name = "longitude"
+olon.units = "degrees_E" 
+#
+olat[:] = lats
+olat.long_name = "latitude"
+olat.units = "degrees_N"
+#
+oxis[:] = xis
+oxis.long_name = "x grid box position"
+oxis.units = "fractional"
+#
+oyjs[:] = yjs
+oyjs.long_name = "y grid box position"
+oyjs.units = "fractional"
+#
+ouvs[:] = uvs
+ouvs.long_name = "zonal velocity"
+ouvs.units = "m/s"
+#
+ovvs[:] = vvs
+ovvs.long_name = "meridional velocity"
+ovvs.units = "m/s"
+#
+omas[:] = mas
+omas.long_name = "mass"
+omas.units = "kg"
+#
+oths[:] = ths
+oths.long_name = "thickness"
+oths.units = "m"
+#
+owis[:] = wis
+owis.long_name = "width"
+owis.units = "m"
+#
+oles[:] = les
+oles.long_name = "length"
+oles.units = "m"
+#
+odys[:] = dys
+odys.long_name = "year day of calving event"
+odys.units = "days"
+#
+omss[:] = mss
+omss.long_name = "scaling factor for mass of calving berg"
+omss.units = "none"
+#
+omsb[:] = msb
+omsb.long_name = "mass of bergy bits"
+omsb.units = "kg"
+#
+ohds[:] = hds
+ohds.long_name = "heat density"
+ohds.units = "J/kg"
+#
+oyrs[:] = yrs
+oyrs.long_name = "calendar year of calving event"
+oyrs.units = "years"
+#
+onum[:,:] = num
+onum.long_name = "iceberg number on this processor"
+onum.units = "count"
+#
+fo.close()
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/REBUILD_NEMO/src/rebuild_nemo.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/REBUILD_NEMO/src/rebuild_nemo.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/REBUILD_NEMO/src/rebuild_nemo.f90	(revision 6436)
@@ -200,5 +200,5 @@
       WRITE(numerr,*) 'Attribute DOMAIN_number_total is : ', ndomain_file
       WRITE(numerr,*) 'Number of files specified in namelist is: ', ndomain
-      STOP
+      STOP 9
    ENDIF
   
@@ -268,5 +268,5 @@
       WRITE(numerr,*) 'Attribute DOMAIN_local_sizes is : ', local_sizes
       WRITE(numerr,*) 'Dimensions to be rebuilt are of size : ', outdimlens(rebuild_dims(1)), outdimlens(rebuild_dims(2)) 
-      STOP
+      STOP 9
    ENDIF
 
@@ -384,16 +384,21 @@
             SELECT CASE( xtype )
                CASE( NF90_BYTE )
+                  globaldata_0d_i1 = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_0d_i1 ) )
                CASE( NF90_SHORT )
+                  globaldata_0d_i2 = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_0d_i2 ) )
                CASE( NF90_INT )
+                  globaldata_0d_i4 = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_0d_i4 ) )
                CASE( NF90_FLOAT )
+                  globaldata_0d_sp = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_0d_sp ) )
                CASE( NF90_DOUBLE )
+                  globaldata_0d_dp = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_0d_dp ) )
                CASE DEFAULT
                   WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-                  STOP
+                  STOP 9
             END SELECT
 
@@ -403,20 +408,25 @@
                CASE( NF90_BYTE )
                   ALLOCATE(globaldata_1d_i1(indimlens(dimids(1))))
+                  globaldata_1d_i1(:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_1d_i1 ) )
                CASE( NF90_SHORT )
                   ALLOCATE(globaldata_1d_i2(indimlens(dimids(1))))
+                  globaldata_1d_i2(:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_1d_i2 ) )
                CASE( NF90_INT )
                   ALLOCATE(globaldata_1d_i4(indimlens(dimids(1))))
+                  globaldata_1d_i4(:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_1d_i4 ) )
                CASE( NF90_FLOAT )
                   ALLOCATE(globaldata_1d_sp(indimlens(dimids(1))))
+                  globaldata_1d_sp(:) = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_1d_sp ) )
                CASE( NF90_DOUBLE )
                   ALLOCATE(globaldata_1d_dp(indimlens(dimids(1))))
+                  globaldata_1d_dp(:) = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_1d_dp ) )
                CASE DEFAULT
                   WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-                  STOP
+                  STOP 9
             END SELECT
 
@@ -426,20 +436,25 @@
                CASE( NF90_BYTE )
                   ALLOCATE(globaldata_2d_i1(indimlens(dimids(1)),indimlens(dimids(2))))
+                  globaldata_2d_i1(:,:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_2d_i1 ) )
                CASE( NF90_SHORT )
                   ALLOCATE(globaldata_2d_i2(indimlens(dimids(1)),indimlens(dimids(2))))
+                  globaldata_2d_i2(:,:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_2d_i2 ) )
                CASE( NF90_INT )
                   ALLOCATE(globaldata_2d_i4(indimlens(dimids(1)),indimlens(dimids(2))))
+                  globaldata_2d_i4(:,:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_2d_i4 ) )
                CASE( NF90_FLOAT )
                   ALLOCATE(globaldata_2d_sp(indimlens(dimids(1)),indimlens(dimids(2))))
+                  globaldata_2d_sp(:,:) = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_2d_sp ) )
                CASE( NF90_DOUBLE )
                   ALLOCATE(globaldata_2d_dp(indimlens(dimids(1)),indimlens(dimids(2))))
+                  globaldata_2d_dp(:,:) = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_2d_dp ) )
                CASE DEFAULT
                   WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-                  STOP
+                  STOP 9
             END SELECT
 
@@ -450,24 +465,29 @@
                   ALLOCATE(globaldata_3d_i1(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3))))
+                  globaldata_3d_i1(:,:,:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_3d_i1 ) )
                CASE( NF90_SHORT )
                   ALLOCATE(globaldata_3d_i2(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3))))
+                  globaldata_3d_i2(:,:,:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_3d_i2 ) )
                CASE( NF90_INT )
                   ALLOCATE(globaldata_3d_i4(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3))))
+                  globaldata_3d_i4(:,:,:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_3d_i4 ) )
                CASE( NF90_FLOAT )
                   ALLOCATE(globaldata_3d_sp(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3))))
+                  globaldata_3d_sp(:,:,:) = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_3d_sp ) )
                CASE( NF90_DOUBLE )
                   ALLOCATE(globaldata_3d_dp(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3))))
+                  globaldata_3d_dp(:,:,:) = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_3d_dp ) )
                CASE DEFAULT
                   WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-                  STOP
+                  STOP 9
             END SELECT
 
@@ -478,24 +498,29 @@
                   ALLOCATE(globaldata_4d_i1(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3)),ntchunk))
+                  globaldata_4d_i1(:,:,:,:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_i1, start=(/1,1,1,nt/) ) )
                CASE( NF90_SHORT )
                   ALLOCATE(globaldata_4d_i2(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3)),ntchunk))
+                  globaldata_4d_i2(:,:,:,:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_i2, start=(/1,1,1,nt/) ) )
                CASE( NF90_INT )
                   ALLOCATE(globaldata_4d_i4(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3)),ntchunk))
+                  globaldata_4d_i4(:,:,:,:) = 0
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_i4, start=(/1,1,1,nt/) ) )
                CASE( NF90_FLOAT )
                   ALLOCATE(globaldata_4d_sp(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3)),ntchunk))
+                  globaldata_4d_sp(:,:,:,:) = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_sp, start=(/1,1,1,nt/) ) )
                CASE( NF90_DOUBLE )
                   ALLOCATE(globaldata_4d_dp(indimlens(dimids(1)),indimlens(dimids(2)),       &
                      &                      indimlens(dimids(3)),ntchunk))
+                  globaldata_4d_dp(:,:,:,:) = 0.
                   CALL check_nf90( nf90_get_var( ncid, jv, globaldata_4d_dp, start=(/1,1,1,nt/) ) )
                CASE DEFAULT
                   WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-                  STOP
+                  STOP 9
             END SELECT
 
@@ -517,15 +542,20 @@
                CASE( NF90_BYTE )
                   ALLOCATE(globaldata_1d_i1(outdimlens(dimids(1))))
+                  globaldata_1d_i1(:) = 0
                CASE( NF90_SHORT )
                   ALLOCATE(globaldata_1d_i2(outdimlens(dimids(1))))
+                  globaldata_1d_i2(:) = 0
                CASE( NF90_INT )
                   ALLOCATE(globaldata_1d_i4(outdimlens(dimids(1))))
+                  globaldata_1d_i4(:) = 0
                CASE( NF90_FLOAT )
                   ALLOCATE(globaldata_1d_sp(outdimlens(dimids(1))))
+                  globaldata_1d_sp(:) = 0.
                CASE( NF90_DOUBLE )
                   ALLOCATE(globaldata_1d_dp(outdimlens(dimids(1))))
+                  globaldata_1d_dp(:) = 0.
                CASE DEFAULT
                   WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-                  STOP
+                  STOP 9
             END SELECT
 
@@ -535,15 +565,20 @@
                CASE( NF90_BYTE )
                   ALLOCATE(globaldata_2d_i1(outdimlens(dimids(1)),outdimlens(dimids(2))))
+                  globaldata_2d_i1(:,:) = 0
                CASE( NF90_SHORT )
                   ALLOCATE(globaldata_2d_i2(outdimlens(dimids(1)),outdimlens(dimids(2))))
+                  globaldata_2d_i2(:,:) = 0
                CASE( NF90_INT )
                   ALLOCATE(globaldata_2d_i4(outdimlens(dimids(1)),outdimlens(dimids(2))))
+                  globaldata_2d_i4(:,:) = 0
                CASE( NF90_FLOAT )
                   ALLOCATE(globaldata_2d_sp(outdimlens(dimids(1)),outdimlens(dimids(2))))
+                  globaldata_2d_sp(:,:) = 0.
                CASE( NF90_DOUBLE )
                   ALLOCATE(globaldata_2d_dp(outdimlens(dimids(1)),outdimlens(dimids(2))))
+                  globaldata_2d_dp(:,:) = 0.
                CASE DEFAULT
                   WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-                  STOP
+                  STOP 9
             END SELECT
 
@@ -554,19 +589,24 @@
                   ALLOCATE(globaldata_3d_i1(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3))))
+                  globaldata_3d_i1(:,:,:) = 0
                CASE( NF90_SHORT )
                   ALLOCATE(globaldata_3d_i2(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3))))
+                  globaldata_3d_i2(:,:,:) = 0
                CASE( NF90_INT )
                   ALLOCATE(globaldata_3d_i4(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3))))
+                  globaldata_3d_i4(:,:,:) = 0
                CASE( NF90_FLOAT )
                   ALLOCATE(globaldata_3d_sp(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3))))
+                  globaldata_3d_sp(:,:,:) = 0.
                CASE( NF90_DOUBLE )
                   ALLOCATE(globaldata_3d_dp(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3))))
+                  globaldata_3d_dp(:,:,:) = 0.
                CASE DEFAULT
                   WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-                  STOP
+                  STOP 9
             END SELECT
 
@@ -577,23 +617,28 @@
                   ALLOCATE(globaldata_4d_i1(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3)),ntchunk))
+                   globaldata_4d_i1(:,:,:,:) = 0
                CASE( NF90_SHORT )
                   ALLOCATE(globaldata_4d_i2(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3)),ntchunk))
+                  globaldata_4d_i2(:,:,:,:) = 0
                CASE( NF90_INT )
                   ALLOCATE(globaldata_4d_i4(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3)),ntchunk))
+                  globaldata_4d_i4(:,:,:,:) = 0
                CASE( NF90_FLOAT )
                   ALLOCATE(globaldata_4d_sp(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3)),ntchunk))
+                  globaldata_4d_sp(:,:,:,:) = 0.
                CASE( NF90_DOUBLE )
                   ALLOCATE(globaldata_4d_dp(outdimlens(dimids(1)),outdimlens(dimids(2)),     &
                      &                      outdimlens(dimids(3)),ntchunk))
+                  globaldata_4d_dp(:,:,:,:) = 0.
                CASE DEFAULT
                   WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-                  STOP
+                  STOP 9
             END SELECT
          ELSE
             WRITE(numerr,*) 'ERROR! : A netcdf variable has more than 4 dimensions which is not taken into account'
-            STOP
+            STOP 9
          ENDIF
 
@@ -967,5 +1012,5 @@
             IF( nthreads == 1 .AND. istop /= nf90_noerr )  THEN
                WRITE(numerr,*) '*** NEMO rebuild failed! ***'
-               STOP
+               STOP 9
             ENDIF
         
@@ -976,5 +1021,5 @@
          IF( istop /= nf90_noerr )  THEN
             WRITE(numerr,*) '*** NEMO rebuild failed! ***'
-            STOP
+            STOP 9
          ENDIF
 
@@ -1050,5 +1095,5 @@
             CASE DEFAULT   
                WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-               STOP
+               STOP 9
          END SELECT     
                       
@@ -1073,5 +1118,5 @@
             CASE DEFAULT   
                WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-               STOP
+               STOP 9
          END SELECT     
     
@@ -1096,5 +1141,5 @@
             CASE DEFAULT   
                WRITE(numerr,*) 'Unknown nf90 type: ', xtype
-               STOP
+               STOP 9
          END SELECT     
     
@@ -1146,5 +1191,5 @@
             WRITE(numerr,*) "*** NEMO rebuild failed ***"
             WRITE(numerr,*)
-            STOP
+            STOP 9
          ENDIF
       ENDIF
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/cfg/dummy.cfg
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/cfg/dummy.cfg	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/cfg/dummy.cfg	(revision 6436)
@@ -0,0 +1,5 @@
+&namdum
+   cn_dumvar=""
+   cn_dumdim=""
+   cn_dumatt="history"
+/
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg	(revision 6436)
@@ -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                         
Index: /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/Doxyfile
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/Doxyfile	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/Doxyfile	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/attribute.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/attribute.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/attribute.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/boundary.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90	(revision 6436)
@@ -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: anches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_boundary.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_boundary.f90	(revision 6435)
+++ 	(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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_coord.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_coord.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_coord.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_restart.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_restart.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/create_restart.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/dimension.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/dimension.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/dimension.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 6436)
@@ -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: anches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/3_codingRules.md
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/3_codingRules.md	(revision 6435)
+++ 	(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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md	(revision 6436)
@@ -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: anches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/4_changeLog.md
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/4_changeLog.md	(revision 6435)
+++ 	(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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md	(revision 6436)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/domain.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/domain.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/domain.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/file.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/file.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/file.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/function.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/function.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/function.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/global.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/global.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/global.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/grid.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/interp_linear.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/interp_linear.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/interp_linear.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_dom.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_dom.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_dom.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_mpp.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_mpp.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_mpp.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_rstdimg.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_rstdimg.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/iom_rstdimg.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/logger.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/logger.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/logger.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/math.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/math.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/math.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/mpp.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/multi.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/multi.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/multi.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/phycst.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/phycst.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/phycst.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/variable.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/variable.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/variable.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/vgrid.f90
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/vgrid.f90	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/src/vgrid.f90	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_bathy.nam
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_bathy.nam	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_bathy.nam	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_boundary.nam
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_boundary.nam	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_boundary.nam	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_coord.nam
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_coord.nam	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_coord.nam	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_restart.nam
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_restart.nam	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/create_restart.nam	(revision 6436)
@@ -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/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/merge_bathy.nam
===================================================================
--- /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/merge_bathy.nam	(revision 6435)
+++ /branches/UKMO/nemo_v3_6_STABLE_copy/NEMOGCM/TOOLS/SIREN/templates/merge_bathy.nam	(revision 6436)
@@ -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=
 /
