Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/context_nemo-BASIC.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/context_nemo-BASIC.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/context_nemo-BASIC.xml	(revision 14671)
@@ -0,0 +1,46 @@
+<!--
+ ============================================================================================== 
+    NEMO context
+============================================================================================== 
+-->
+<context id="nemo">
+<!-- $id$ -->
+<!-- Fields definition -->
+    <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
+    <field_definition src="./field_def_nemo-ice.xml"/>   <!--  NEMO ocean sea ice                      -->
+<!--    <field_definition src="./field_def_nemo-bgc.xml"/>   <!--  NEMO ocean biogeochemistry with PISCES  -->
+
+
+<!-- Files definition -->
+    <file_definition src="./file_def_nemo-oce-BASIC.xml"/>     <!--  NEMO ocean dynamics                     -->
+    <file_definition src="./file_def_nemo-ice-BASIC.xml"/>     <!--  NEMO ocean sea ice                      -->
+<!--    <file_definition src="./file_def_nemo-bgc.xml"/>     <!--  NEMO ocean biogeochemistry with PISCES  -->
+    <!-- 
+============================================================================================================
+= grid definition = = DO NOT CHANGE =
+============================================================================================================
+    -->
+    
+    <axis_definition>
+      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="deptht300" axis_ref="deptht" >
+         <zoom_axis begin="0" n="35" />
+      </axis>
+      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat" long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
+      <axis id="ncatice" long_name="Ice category"       unit="1"               />
+      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
+      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht_surface" axis_ref="deptht" >
+         <zoom_axis begin=" 0 " n=" 1 " />
+      </axis>
+    </axis_definition>
+ 
+    <domain_definition src="./domain_def_nemo.xml"/>
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+
+</context>
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/context_nemo-CMIP6.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/context_nemo-CMIP6.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/context_nemo-CMIP6.xml	(revision 14671)
@@ -0,0 +1,46 @@
+<!--
+ ============================================================================================== 
+    NEMO context
+============================================================================================== 
+-->
+<context id="nemo">
+<!-- $id$ -->
+<!-- Fields definition -->
+    <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
+    <field_definition src="./field_def_nemo-ice.xml"/>   <!--  NEMO ocean sea ice                      -->
+<!--    <field_definition src="./field_def_nemo-bgc.xml"/>   <!--  NEMO ocean biogeochemistry with PISCES  -->
+
+
+<!-- Files definition -->
+    <file_definition src="./file_def_nemo-oce-CMIP6.xml"/>     <!--  NEMO ocean dynamics                     -->
+    <file_definition src="./file_def_nemo-ice-CMIP6.xml"/>     <!--  NEMO ocean sea ice                      -->
+<!--    <file_definition src="./file_def_nemo-bgc.xml"/>     <!--  NEMO ocean biogeochemistry with PISCES  -->
+    <!-- 
+============================================================================================================
+= grid definition = = DO NOT CHANGE =
+============================================================================================================
+    -->
+    
+    <axis_definition>
+      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="deptht300" axis_ref="deptht" >
+         <zoom_axis begin="0" n="35" />
+      </axis>
+      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat" long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
+      <axis id="ncatice" long_name="Ice category"       unit="1"               />
+      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
+      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht_surface" axis_ref="deptht" >
+         <zoom_axis begin=" 0 " n=" 1 " />
+      </axis>
+    </axis_definition>
+ 
+    <domain_definition src="./domain_def_nemo.xml"/>
+  
+    <grid_definition src="./grid_def_nemo.xml"/>
+
+</context>
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/context_nemo-CUSTOM.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/context_nemo-CUSTOM.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/context_nemo-CUSTOM.xml	(revision 14671)
@@ -0,0 +1,46 @@
+<!--
+ ============================================================================================== 
+    NEMO context
+============================================================================================== 
+-->
+<context id="nemo">
+<!-- $id$ -->
+<!-- Fields definition -->
+    <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
+    <field_definition src="./field_def_nemo-ice.xml"/>   <!--  NEMO ocean sea ice                      -->
+<!--    <field_definition src="./field_def_nemo-bgc.xml"/>   <!--  NEMO ocean biogeochemistry with PISCES  -->
+
+
+<!-- Files definition -->
+    <file_definition src="./file_def_nemo-oce.xml"/>     <!--  NEMO ocean dynamics                     -->
+    <file_definition src="./file_def_nemo-ice.xml"/>     <!--  NEMO ocean sea ice                      -->
+<!--    <file_definition src="./file_def_nemo-bgc.xml"/>     <!--  NEMO ocean biogeochemistry with PISCES  -->
+    <!-- 
+============================================================================================================
+= grid definition = = DO NOT CHANGE =
+============================================================================================================
+    -->
+    
+    <axis_definition>
+      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="deptht300" axis_ref="deptht" >
+         <zoom_axis begin="0" n="35" />
+      </axis>
+      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat" long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
+      <axis id="ncatice" long_name="Ice category"       unit="1"               />
+      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
+      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht_surface" axis_ref="deptht" >
+         <zoom_axis begin=" 0 " n=" 1 " />
+      </axis>
+    </axis_definition>
+ 
+    <domain_definition src="./domain_def_nemo.xml"/>
+
+    <grid_definition src="./grid_def_nemo.xml"/>
+  
+</context>
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-BASIC-10D.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-BASIC-10D.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-BASIC-10D.xml	(revision 14671)
@@ -0,0 +1,162 @@
+<?xml version="1.0"?>
+    <!-- $id$ -->
+    
+ <!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                      Define your own files for sea ice                                   =
+=                                         put the variables you want...                                    =
+============================================================================================================
+ -->
+    
+ <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1mo" min_digits="4">
+   
+   <file_group id="10d" output_freq="10d"  output_level="10" enabled=".TRUE.">  <!-- 10d files -->   	
+     <file id="file21" name_suffix="_icemod" description="ice variables" enabled=".true." >
+
+       <!-- ice mask -->
+       <field field_ref="icemask"          name="simsk"   />
+       <field field_ref="icemask05"        name="simsk05" />
+       <field field_ref="icemask15"        name="simsk15" />
+       
+       <!-- general -->
+       <field field_ref="snwvolu"          name="snvolu" />
+       <field field_ref="icethic"          name="sithic" />
+       <field field_ref="icevolu"          name="sivolu" />
+       <field field_ref="iceconc"          name="siconc" />
+       <field field_ref="icesalt"          name="sisali" />
+       <field field_ref="iceapnd"          name="siapnd" />
+       <field field_ref="icevpnd"          name="sivpnd" />
+       <field field_ref="iceepnd"          name="siepnd" />
+       <field field_ref="icevlid"          name="sivlid" />
+       <!-- sst_m is always the potential temperature even when using teos10 -->
+       <field field_ref="sst_m_pot"        name="sst_m_pot"  />
+       <field field_ref="sss_m_abs"        name="sss_m_abs"  />
+       
+       <!-- heat -->
+       <field field_ref="icetemp"          name="sitemp" />
+       <field field_ref="icettop"          name="sittop" />
+       <field field_ref="icetbot"          name="sitbot" />
+       <field field_ref="icetsni"          name="sitsni" />
+
+       <!-- ponds -->
+       <field field_ref="dvpn_mlt"         name="dvpn_mlt" />
+       <field field_ref="dvpn_lid"         name="dvpn_lid" />
+       <field field_ref="dvpn_rnf"         name="dvpn_rnf" />
+       <field field_ref="dvpn_drn"         name="dvpn_drn" />
+       
+       <!-- momentum -->
+       <field field_ref="uice"             name="sivelu"  />
+       <field field_ref="vice"             name="sivelv"  />
+       <field field_ref="icevel"           name="sivelo"  />
+       <field field_ref="utau_ai"          name="utau_ai" />
+       <field field_ref="vtau_ai"          name="vtau_ai" />
+       <field field_ref="utau_oi"          name="utau_oi" />
+       <field field_ref="vtau_oi"          name="vtau_oi" />
+       
+       <!-- rheology -->
+       <field field_ref="icediv"           name="sidive"  />
+       <field field_ref="iceshe"           name="sishea"  />
+       <field field_ref="icestr"           name="sistre"  />
+       <field field_ref="normstr"          name="normstr" />
+       <field field_ref="sheastr"          name="sheastr" />
+       <field field_ref="isig1"            name="isig1"   />
+       <field field_ref="isig2"            name="isig2"   />
+       <field field_ref="isig3"            name="isig3"   />
+       
+       <!-- heat fluxes -->
+       <field field_ref="qt_oce_ai"        name="qt_oce_ai"  />
+       <field field_ref="qt_atm_oi"        name="qt_atm_oi"  />
+       <field field_ref="qtr_ice_top"      name="qtr_ice_top"/>
+       <field field_ref="qtr_ice_bot"      name="qtr_ice_bot"/>
+       <field field_ref="qt_ice"           name="qt_ice"     />
+       <field field_ref="qsr_ice"          name="qsr_ice"    />
+       <field field_ref="qns_ice"          name="qns_ice"    />
+       <field field_ref="qemp_ice"         name="qemp_ice"   />
+       <field field_ref="albedo"           name="albedo"     />
+       
+       <field field_ref="hfxcndtop"        name="hfxcndtop"  />
+       <field field_ref="hfxcndbot"        name="hfxcndbot"  />
+       <field field_ref="hfxsensib"        name="hfxsensib"  />
+       
+       <!-- salt fluxes -->
+       <field field_ref="sfxice"           name="sfxice" />
+       
+       <!-- mass fluxes -->
+       <field field_ref="vfxice"           name="vfxice" />
+       <field field_ref="vfxsnw"           name="vfxsnw" />
+       
+       <!-- categories -->
+       <field field_ref="icemask_cat"      name="simskcat"/>
+       <field field_ref="snwthic_cat"      name="snthicat"/>
+       <field field_ref="iceconc_cat"      name="siconcat"/>
+       <field field_ref="icethic_cat"      name="sithicat"/>
+       <field field_ref="icesalt_cat"      name="sisalcat"/>
+       <field field_ref="icetemp_cat"      name="sitemcat"/>
+       <field field_ref="iceapnd_cat"      name="siapncat"/>
+       <field field_ref="icevpnd_cat"      name="sivpncat"/>
+       <field field_ref="snwtemp_cat"      name="sntemcat"/>
+
+       <!-- mass balance -->
+       <field field_ref="dmithd"           name="sidmassth"        />
+       <field field_ref="dmidyn"           name="sidmassdyn"       />
+       <field field_ref="dmiopw"           name="sidmassgrowthwat" />
+       <field field_ref="dmibog"           name="sidmassgrowthbot" />
+       <field field_ref="dmisni"           name="sidmasssi"        />
+       <field field_ref="dmisub"           name="sidmassevapsubl"  />
+       <field field_ref="dmisum"           name="sidmassmelttop"   />
+       <field field_ref="dmibom"           name="sidmassmeltbot"   />
+       <field field_ref="dmilam"           name="sidmassmeltlat"   />
+       <field field_ref="dmsspr"           name="sndmasssnf"       />
+       <field field_ref="dmsmel"           name="sndmassmelt"      />
+       <field field_ref="dmssub"           name="sndmasssubl"      />
+       <field field_ref="dmsdyn"           name="sndmassdyn"       />
+       <field field_ref="dmsssi"           name="sndmasssi"        />
+
+     </file>
+     
+     <file id="file22" name_suffix="_SBC_scalar" description="scalar variables" enabled=".true." >
+       <!-- global contents -->
+       <field field_ref="ibgvol_tot"       name="ibgvol_tot"   />
+       <field field_ref="sbgvol_tot"       name="sbgvol_tot"   />
+       <field field_ref="ibgarea_tot"      name="ibgarea_tot"  />
+       <field field_ref="ibgsalt_tot"      name="ibgsalt_tot"  />
+       <field field_ref="ibgheat_tot"      name="ibgheat_tot"  />
+       <field field_ref="sbgheat_tot"      name="sbgheat_tot"  />
+       
+       <!-- global drifts (conservation checks) -->
+       <field field_ref="ibgvolume"        name="ibgvolume"    />
+       <field field_ref="ibgsaltco"        name="ibgsaltco"    />
+       <field field_ref="ibgheatco"        name="ibgheatco"    />
+       <field field_ref="ibgheatfx"        name="ibgheatfx"    />
+       
+       <!-- global forcings  -->
+       <field field_ref="ibgfrcvoltop"     name="ibgfrcvoltop" />
+       <field field_ref="ibgfrcvolbot"     name="ibgfrcvolbot" />
+       <field field_ref="ibgfrctemtop"     name="ibgfrctemtop" />
+       <field field_ref="ibgfrctembot"     name="ibgfrctembot" />
+       <field field_ref="ibgfrcsal"        name="ibgfrcsal"    />
+       <field field_ref="ibgfrchfxtop"     name="ibgfrchfxtop" />
+       <field field_ref="ibgfrchfxbot"     name="ibgfrchfxbot" />
+     </file>
+     
+   </file_group>
+   
+   <file_group id="1ts" output_freq="1ts" output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+   <file_group id="1h"  output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+   <file_group id="2h"  output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+   <file_group id="3h"  output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+   <file_group id="4h"  output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+   <file_group id="6h"  output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->        
+   <file_group id="1m"  output_freq="1mo" output_level="10" enabled=".TRUE."/> <!-- real monthly files -->
+   <file_group id="2m"  output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+   <file_group id="3m"  output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+   <file_group id="4m"  output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+   <file_group id="6m"  output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+   <file_group id="1y"  output_freq="1y"  output_level="10" enabled=".TRUE."/> <!-- real yearly files -->
+   <file_group id="2y"  output_freq="2y"  output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+   <file_group id="5y"  output_freq="5y"  output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+   <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+   
+ </file_definition>
+ 
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-BASIC-1M.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-BASIC-1M.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-BASIC-1M.xml	(revision 14671)
@@ -0,0 +1,162 @@
+<?xml version="1.0"?>
+    <!-- $id$ -->
+    
+ <!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                      Define your own files for sea ice                                   =
+=                                         put the variables you want...                                    =
+============================================================================================================
+ -->
+    
+ <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1mo" min_digits="4">
+   
+   <file_group id="1m" output_freq="1mo"  output_level="10" enabled=".TRUE.">  <!-- 1m files -->   	
+     <file id="file21" name_suffix="_icemod" description="ice variables" enabled=".true." >
+
+       <!-- ice mask -->
+       <field field_ref="icemask"          name="simsk"   />
+       <field field_ref="icemask05"        name="simsk05" />
+       <field field_ref="icemask15"        name="simsk15" />
+       
+       <!-- general -->
+       <field field_ref="snwvolu"          name="snvolu" />
+       <field field_ref="icethic"          name="sithic" />
+       <field field_ref="icevolu"          name="sivolu" />
+       <field field_ref="iceconc"          name="siconc" />
+       <field field_ref="icesalt"          name="sisali" />
+       <field field_ref="iceapnd"          name="siapnd" />
+       <field field_ref="icevpnd"          name="sivpnd" />
+       <field field_ref="iceepnd"          name="siepnd" />
+       <field field_ref="icevlid"          name="sivlid" />
+       <!-- sst_m is always the potential temperature even when using teos10 -->
+       <field field_ref="sst_m_pot"        name="sst_m_pot"  />
+       <field field_ref="sss_m_abs"        name="sss_m_abs"  />
+       
+       <!-- heat -->
+       <field field_ref="icetemp"          name="sitemp" />
+       <field field_ref="icettop"          name="sittop" />
+       <field field_ref="icetbot"          name="sitbot" />
+       <field field_ref="icetsni"          name="sitsni" />
+
+       <!-- ponds -->
+       <field field_ref="dvpn_mlt"         name="dvpn_mlt" />
+       <field field_ref="dvpn_lid"         name="dvpn_lid" />
+       <field field_ref="dvpn_rnf"         name="dvpn_rnf" />
+       <field field_ref="dvpn_drn"         name="dvpn_drn" />
+       
+       <!-- momentum -->
+       <field field_ref="uice"             name="sivelu"  />
+       <field field_ref="vice"             name="sivelv"  />
+       <field field_ref="icevel"           name="sivelo"  />
+       <field field_ref="utau_ai"          name="utau_ai" />
+       <field field_ref="vtau_ai"          name="vtau_ai" />
+       <field field_ref="utau_oi"          name="utau_oi" />
+       <field field_ref="vtau_oi"          name="vtau_oi" />
+       
+       <!-- rheology -->
+       <field field_ref="icediv"           name="sidive"  />
+       <field field_ref="iceshe"           name="sishea"  />
+       <field field_ref="icestr"           name="sistre"  />
+       <field field_ref="normstr"          name="normstr" />
+       <field field_ref="sheastr"          name="sheastr" />
+       <field field_ref="isig1"            name="isig1"   />
+       <field field_ref="isig2"            name="isig2"   />
+       <field field_ref="isig3"            name="isig3"   />
+       
+       <!-- heat fluxes -->
+       <field field_ref="qt_oce_ai"        name="qt_oce_ai"  />
+       <field field_ref="qt_atm_oi"        name="qt_atm_oi"  />
+       <field field_ref="qtr_ice_top"      name="qtr_ice_top"/>
+       <field field_ref="qtr_ice_bot"      name="qtr_ice_bot"/>
+       <field field_ref="qt_ice"           name="qt_ice"     />
+       <field field_ref="qsr_ice"          name="qsr_ice"    />
+       <field field_ref="qns_ice"          name="qns_ice"    />
+       <field field_ref="qemp_ice"         name="qemp_ice"   />
+       <field field_ref="albedo"           name="albedo"     />
+       
+       <field field_ref="hfxcndtop"        name="hfxcndtop"  />
+       <field field_ref="hfxcndbot"        name="hfxcndbot"  />
+       <field field_ref="hfxsensib"        name="hfxsensib"  />
+       
+       <!-- salt fluxes -->
+       <field field_ref="sfxice"           name="sfxice" />
+       
+       <!-- mass fluxes -->
+       <field field_ref="vfxice"           name="vfxice" />
+       <field field_ref="vfxsnw"           name="vfxsnw" />
+       
+       <!-- categories -->
+       <field field_ref="icemask_cat"      name="simskcat"/>
+       <field field_ref="snwthic_cat"      name="snthicat"/>
+       <field field_ref="iceconc_cat"      name="siconcat"/>
+       <field field_ref="icethic_cat"      name="sithicat"/>
+       <field field_ref="icesalt_cat"      name="sisalcat"/>
+       <field field_ref="icetemp_cat"      name="sitemcat"/>
+       <field field_ref="iceapnd_cat"      name="siapncat"/>
+       <field field_ref="icevpnd_cat"      name="sivpncat"/>
+       <field field_ref="snwtemp_cat"      name="sntemcat"/>
+
+       <!-- mass balance -->
+       <field field_ref="dmithd"           name="sidmassth"        />
+       <field field_ref="dmidyn"           name="sidmassdyn"       />
+       <field field_ref="dmiopw"           name="sidmassgrowthwat" />
+       <field field_ref="dmibog"           name="sidmassgrowthbot" />
+       <field field_ref="dmisni"           name="sidmasssi"        />
+       <field field_ref="dmisub"           name="sidmassevapsubl"  />
+       <field field_ref="dmisum"           name="sidmassmelttop"   />
+       <field field_ref="dmibom"           name="sidmassmeltbot"   />
+       <field field_ref="dmilam"           name="sidmassmeltlat"   />
+       <field field_ref="dmsspr"           name="sndmasssnf"       />
+       <field field_ref="dmsmel"           name="sndmassmelt"      />
+       <field field_ref="dmssub"           name="sndmasssubl"      />
+       <field field_ref="dmsdyn"           name="sndmassdyn"       />
+       <field field_ref="dmsssi"           name="sndmasssi"        />
+
+     </file>
+     
+     <file id="file22" name_suffix="_SBC_scalar" description="scalar variables" enabled=".true." >
+       <!-- global contents -->
+       <field field_ref="ibgvol_tot"       name="ibgvol_tot"   />
+       <field field_ref="sbgvol_tot"       name="sbgvol_tot"   />
+       <field field_ref="ibgarea_tot"      name="ibgarea_tot"  />
+       <field field_ref="ibgsalt_tot"      name="ibgsalt_tot"  />
+       <field field_ref="ibgheat_tot"      name="ibgheat_tot"  />
+       <field field_ref="sbgheat_tot"      name="sbgheat_tot"  />
+       
+       <!-- global drifts (conservation checks) -->
+       <field field_ref="ibgvolume"        name="ibgvolume"    />
+       <field field_ref="ibgsaltco"        name="ibgsaltco"    />
+       <field field_ref="ibgheatco"        name="ibgheatco"    />
+       <field field_ref="ibgheatfx"        name="ibgheatfx"    />
+       
+       <!-- global forcings  -->
+       <field field_ref="ibgfrcvoltop"     name="ibgfrcvoltop" />
+       <field field_ref="ibgfrcvolbot"     name="ibgfrcvolbot" />
+       <field field_ref="ibgfrctemtop"     name="ibgfrctemtop" />
+       <field field_ref="ibgfrctembot"     name="ibgfrctembot" />
+       <field field_ref="ibgfrcsal"        name="ibgfrcsal"    />
+       <field field_ref="ibgfrchfxtop"     name="ibgfrchfxtop" />
+       <field field_ref="ibgfrchfxbot"     name="ibgfrchfxbot" />
+     </file>
+     
+   </file_group>
+   
+   <file_group id="1ts" output_freq="1ts" output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+   <file_group id="1h"  output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+   <file_group id="2h"  output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+   <file_group id="3h"  output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+   <file_group id="4h"  output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+   <file_group id="6h"  output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->        
+   <file_group id="1m"  output_freq="1mo" output_level="10" enabled=".TRUE."/> <!-- real monthly files -->
+   <file_group id="2m"  output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+   <file_group id="3m"  output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+   <file_group id="4m"  output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+   <file_group id="6m"  output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+   <file_group id="1y"  output_freq="1y"  output_level="10" enabled=".TRUE."/> <!-- real yearly files -->
+   <file_group id="2y"  output_freq="2y"  output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+   <file_group id="5y"  output_freq="5y"  output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+   <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+   
+ </file_definition>
+ 
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-BASIC-INVALID_PERIOD.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-BASIC-INVALID_PERIOD.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-BASIC-INVALID_PERIOD.xml	(revision 14671)
@@ -0,0 +1,4 @@
+You can't use the standard diagnostic options with the current cycling period.
+Choose the "Custom" option, copy the file_def*.xml files that
+you want to use into the Rose app and adjust the meaning period
+accordingly. 
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-CMIP6-10D.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-CMIP6-10D.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-CMIP6-10D.xml	(revision 14671)
@@ -0,0 +1,162 @@
+<?xml version="1.0"?>
+    <!-- $id$ -->
+    
+ <!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                      Define your own files for sea ice                                   =
+=                                         put the variables you want...                                    =
+============================================================================================================
+ -->
+    
+ <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1mo" min_digits="4">
+   
+   <file_group id="10d" output_freq="10d"  output_level="10" enabled=".TRUE.">  <!-- 10d files -->   	
+     <file id="file21" name_suffix="_icemod" description="ice variables" enabled=".true." >
+
+       <!-- ice mask -->
+       <field field_ref="icemask"          name="simsk"   />
+       <field field_ref="icemask05"        name="simsk05" />
+       <field field_ref="icemask15"        name="simsk15" />
+       
+       <!-- general -->
+       <field field_ref="snwvolu"          name="snvolu" />
+       <field field_ref="icethic"          name="sithic" />
+       <field field_ref="icevolu"          name="sivolu" />
+       <field field_ref="iceconc"          name="siconc" />
+       <field field_ref="icesalt"          name="sisali" />
+       <field field_ref="iceapnd"          name="siapnd" />
+       <field field_ref="icevpnd"          name="sivpnd" />
+       <field field_ref="iceepnd"          name="siepnd" />
+       <field field_ref="icevlid"          name="sivlid" />
+       <!-- sst_m is always the potential temperature even when using teos10 -->
+       <field field_ref="sst_m_pot"        name="sst_m_pot"  />
+       <field field_ref="sss_m_abs"        name="sss_m_abs"  />
+       
+       <!-- heat -->
+       <field field_ref="icetemp"          name="sitemp" />
+       <field field_ref="icettop"          name="sittop" />
+       <field field_ref="icetbot"          name="sitbot" />
+       <field field_ref="icetsni"          name="sitsni" />
+
+       <!-- ponds -->
+       <field field_ref="dvpn_mlt"         name="dvpn_mlt" />
+       <field field_ref="dvpn_lid"         name="dvpn_lid" />
+       <field field_ref="dvpn_rnf"         name="dvpn_rnf" />
+       <field field_ref="dvpn_drn"         name="dvpn_drn" />
+       
+       <!-- momentum -->
+       <field field_ref="uice"             name="sivelu"  />
+       <field field_ref="vice"             name="sivelv"  />
+       <field field_ref="icevel"           name="sivelo"  />
+       <field field_ref="utau_ai"          name="utau_ai" />
+       <field field_ref="vtau_ai"          name="vtau_ai" />
+       <field field_ref="utau_oi"          name="utau_oi" />
+       <field field_ref="vtau_oi"          name="vtau_oi" />
+       
+       <!-- rheology -->
+       <field field_ref="icediv"           name="sidive"  />
+       <field field_ref="iceshe"           name="sishea"  />
+       <field field_ref="icestr"           name="sistre"  />
+       <field field_ref="normstr"          name="normstr" />
+       <field field_ref="sheastr"          name="sheastr" />
+       <field field_ref="isig1"            name="isig1"   />
+       <field field_ref="isig2"            name="isig2"   />
+       <field field_ref="isig3"            name="isig3"   />
+       
+       <!-- heat fluxes -->
+       <field field_ref="qt_oce_ai"        name="qt_oce_ai"  />
+       <field field_ref="qt_atm_oi"        name="qt_atm_oi"  />
+       <field field_ref="qtr_ice_top"      name="qtr_ice_top"/>
+       <field field_ref="qtr_ice_bot"      name="qtr_ice_bot"/>
+       <field field_ref="qt_ice"           name="qt_ice"     />
+       <field field_ref="qsr_ice"          name="qsr_ice"    />
+       <field field_ref="qns_ice"          name="qns_ice"    />
+       <field field_ref="qemp_ice"         name="qemp_ice"   />
+       <field field_ref="albedo"           name="albedo"     />
+       
+       <field field_ref="hfxcndtop"        name="hfxcndtop"  />
+       <field field_ref="hfxcndbot"        name="hfxcndbot"  />
+       <field field_ref="hfxsensib"        name="hfxsensib"  />
+       
+       <!-- salt fluxes -->
+       <field field_ref="sfxice"           name="sfxice" />
+       
+       <!-- mass fluxes -->
+       <field field_ref="vfxice"           name="vfxice" />
+       <field field_ref="vfxsnw"           name="vfxsnw" />
+       
+       <!-- categories -->
+       <field field_ref="icemask_cat"      name="simskcat"/>
+       <field field_ref="snwthic_cat"      name="snthicat"/>
+       <field field_ref="iceconc_cat"      name="siconcat"/>
+       <field field_ref="icethic_cat"      name="sithicat"/>
+       <field field_ref="icesalt_cat"      name="sisalcat"/>
+       <field field_ref="icetemp_cat"      name="sitemcat"/>
+       <field field_ref="iceapnd_cat"      name="siapncat"/>
+       <field field_ref="icevpnd_cat"      name="sivpncat"/>
+       <field field_ref="snwtemp_cat"      name="sntemcat"/>
+
+       <!-- mass balance -->
+       <field field_ref="dmithd"           name="sidmassth"        />
+       <field field_ref="dmidyn"           name="sidmassdyn"       />
+       <field field_ref="dmiopw"           name="sidmassgrowthwat" />
+       <field field_ref="dmibog"           name="sidmassgrowthbot" />
+       <field field_ref="dmisni"           name="sidmasssi"        />
+       <field field_ref="dmisub"           name="sidmassevapsubl"  />
+       <field field_ref="dmisum"           name="sidmassmelttop"   />
+       <field field_ref="dmibom"           name="sidmassmeltbot"   />
+       <field field_ref="dmilam"           name="sidmassmeltlat"   />
+       <field field_ref="dmsspr"           name="sndmasssnf"       />
+       <field field_ref="dmsmel"           name="sndmassmelt"      />
+       <field field_ref="dmssub"           name="sndmasssubl"      />
+       <field field_ref="dmsdyn"           name="sndmassdyn"       />
+       <field field_ref="dmsssi"           name="sndmasssi"        />
+
+     </file>
+     
+     <file id="file22" name_suffix="_SBC_scalar" description="scalar variables" enabled=".true." >
+       <!-- global contents -->
+       <field field_ref="ibgvol_tot"       name="ibgvol_tot"   />
+       <field field_ref="sbgvol_tot"       name="sbgvol_tot"   />
+       <field field_ref="ibgarea_tot"      name="ibgarea_tot"  />
+       <field field_ref="ibgsalt_tot"      name="ibgsalt_tot"  />
+       <field field_ref="ibgheat_tot"      name="ibgheat_tot"  />
+       <field field_ref="sbgheat_tot"      name="sbgheat_tot"  />
+       
+       <!-- global drifts (conservation checks) -->
+       <field field_ref="ibgvolume"        name="ibgvolume"    />
+       <field field_ref="ibgsaltco"        name="ibgsaltco"    />
+       <field field_ref="ibgheatco"        name="ibgheatco"    />
+       <field field_ref="ibgheatfx"        name="ibgheatfx"    />
+       
+       <!-- global forcings  -->
+       <field field_ref="ibgfrcvoltop"     name="ibgfrcvoltop" />
+       <field field_ref="ibgfrcvolbot"     name="ibgfrcvolbot" />
+       <field field_ref="ibgfrctemtop"     name="ibgfrctemtop" />
+       <field field_ref="ibgfrctembot"     name="ibgfrctembot" />
+       <field field_ref="ibgfrcsal"        name="ibgfrcsal"    />
+       <field field_ref="ibgfrchfxtop"     name="ibgfrchfxtop" />
+       <field field_ref="ibgfrchfxbot"     name="ibgfrchfxbot" />
+     </file>
+     
+   </file_group>
+   
+   <file_group id="1ts" output_freq="1ts" output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+   <file_group id="1h"  output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+   <file_group id="2h"  output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+   <file_group id="3h"  output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+   <file_group id="4h"  output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+   <file_group id="6h"  output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->        
+   <file_group id="1m"  output_freq="1mo" output_level="10" enabled=".TRUE."/> <!-- real monthly files -->
+   <file_group id="2m"  output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+   <file_group id="3m"  output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+   <file_group id="4m"  output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+   <file_group id="6m"  output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+   <file_group id="1y"  output_freq="1y"  output_level="10" enabled=".TRUE."/> <!-- real yearly files -->
+   <file_group id="2y"  output_freq="2y"  output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+   <file_group id="5y"  output_freq="5y"  output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+   <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+   
+ </file_definition>
+ 
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-CMIP6-1M.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-CMIP6-1M.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-CMIP6-1M.xml	(revision 14671)
@@ -0,0 +1,162 @@
+<?xml version="1.0"?>
+    <!-- $id$ -->
+    
+ <!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                      Define your own files for sea ice                                   =
+=                                         put the variables you want...                                    =
+============================================================================================================
+ -->
+    
+ <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1mo" min_digits="4">
+   
+   <file_group id="1m" output_freq="1mo"  output_level="10" enabled=".TRUE.">  <!-- 1m files -->   	
+     <file id="file21" name_suffix="_icemod" description="ice variables" enabled=".true." >
+
+       <!-- ice mask -->
+       <field field_ref="icemask"          name="simsk"   />
+       <field field_ref="icemask05"        name="simsk05" />
+       <field field_ref="icemask15"        name="simsk15" />
+       
+       <!-- general -->
+       <field field_ref="snwvolu"          name="snvolu" />
+       <field field_ref="icethic"          name="sithic" />
+       <field field_ref="icevolu"          name="sivolu" />
+       <field field_ref="iceconc"          name="siconc" />
+       <field field_ref="icesalt"          name="sisali" />
+       <field field_ref="iceapnd"          name="siapnd" />
+       <field field_ref="icevpnd"          name="sivpnd" />
+       <field field_ref="iceepnd"          name="siepnd" />
+       <field field_ref="icevlid"          name="sivlid" />
+       <!-- sst_m is always the potential temperature even when using teos10 -->
+       <field field_ref="sst_m_pot"        name="sst_m_pot"  />
+       <field field_ref="sss_m_abs"        name="sss_m_abs"  />
+       
+       <!-- heat -->
+       <field field_ref="icetemp"          name="sitemp" />
+       <field field_ref="icettop"          name="sittop" />
+       <field field_ref="icetbot"          name="sitbot" />
+       <field field_ref="icetsni"          name="sitsni" />
+
+       <!-- ponds -->
+       <field field_ref="dvpn_mlt"         name="dvpn_mlt" />
+       <field field_ref="dvpn_lid"         name="dvpn_lid" />
+       <field field_ref="dvpn_rnf"         name="dvpn_rnf" />
+       <field field_ref="dvpn_drn"         name="dvpn_drn" />
+       
+       <!-- momentum -->
+       <field field_ref="uice"             name="sivelu"  />
+       <field field_ref="vice"             name="sivelv"  />
+       <field field_ref="icevel"           name="sivelo"  />
+       <field field_ref="utau_ai"          name="utau_ai" />
+       <field field_ref="vtau_ai"          name="vtau_ai" />
+       <field field_ref="utau_oi"          name="utau_oi" />
+       <field field_ref="vtau_oi"          name="vtau_oi" />
+       
+       <!-- rheology -->
+       <field field_ref="icediv"           name="sidive"  />
+       <field field_ref="iceshe"           name="sishea"  />
+       <field field_ref="icestr"           name="sistre"  />
+       <field field_ref="normstr"          name="normstr" />
+       <field field_ref="sheastr"          name="sheastr" />
+       <field field_ref="isig1"            name="isig1"   />
+       <field field_ref="isig2"            name="isig2"   />
+       <field field_ref="isig3"            name="isig3"   />
+       
+       <!-- heat fluxes -->
+       <field field_ref="qt_oce_ai"        name="qt_oce_ai"  />
+       <field field_ref="qt_atm_oi"        name="qt_atm_oi"  />
+       <field field_ref="qtr_ice_top"      name="qtr_ice_top"/>
+       <field field_ref="qtr_ice_bot"      name="qtr_ice_bot"/>
+       <field field_ref="qt_ice"           name="qt_ice"     />
+       <field field_ref="qsr_ice"          name="qsr_ice"    />
+       <field field_ref="qns_ice"          name="qns_ice"    />
+       <field field_ref="qemp_ice"         name="qemp_ice"   />
+       <field field_ref="albedo"           name="albedo"     />
+       
+       <field field_ref="hfxcndtop"        name="hfxcndtop"  />
+       <field field_ref="hfxcndbot"        name="hfxcndbot"  />
+       <field field_ref="hfxsensib"        name="hfxsensib"  />
+       
+       <!-- salt fluxes -->
+       <field field_ref="sfxice"           name="sfxice" />
+       
+       <!-- mass fluxes -->
+       <field field_ref="vfxice"           name="vfxice" />
+       <field field_ref="vfxsnw"           name="vfxsnw" />
+       
+       <!-- categories -->
+       <field field_ref="icemask_cat"      name="simskcat"/>
+       <field field_ref="snwthic_cat"      name="snthicat"/>
+       <field field_ref="iceconc_cat"      name="siconcat"/>
+       <field field_ref="icethic_cat"      name="sithicat"/>
+       <field field_ref="icesalt_cat"      name="sisalcat"/>
+       <field field_ref="icetemp_cat"      name="sitemcat"/>
+       <field field_ref="iceapnd_cat"      name="siapncat"/>
+       <field field_ref="icevpnd_cat"      name="sivpncat"/>
+       <field field_ref="snwtemp_cat"      name="sntemcat"/>
+
+       <!-- mass balance -->
+       <field field_ref="dmithd"           name="sidmassth"        />
+       <field field_ref="dmidyn"           name="sidmassdyn"       />
+       <field field_ref="dmiopw"           name="sidmassgrowthwat" />
+       <field field_ref="dmibog"           name="sidmassgrowthbot" />
+       <field field_ref="dmisni"           name="sidmasssi"        />
+       <field field_ref="dmisub"           name="sidmassevapsubl"  />
+       <field field_ref="dmisum"           name="sidmassmelttop"   />
+       <field field_ref="dmibom"           name="sidmassmeltbot"   />
+       <field field_ref="dmilam"           name="sidmassmeltlat"   />
+       <field field_ref="dmsspr"           name="sndmasssnf"       />
+       <field field_ref="dmsmel"           name="sndmassmelt"      />
+       <field field_ref="dmssub"           name="sndmasssubl"      />
+       <field field_ref="dmsdyn"           name="sndmassdyn"       />
+       <field field_ref="dmsssi"           name="sndmasssi"        />
+
+     </file>
+     
+     <file id="file22" name_suffix="_SBC_scalar" description="scalar variables" enabled=".true." >
+       <!-- global contents -->
+       <field field_ref="ibgvol_tot"       name="ibgvol_tot"   />
+       <field field_ref="sbgvol_tot"       name="sbgvol_tot"   />
+       <field field_ref="ibgarea_tot"      name="ibgarea_tot"  />
+       <field field_ref="ibgsalt_tot"      name="ibgsalt_tot"  />
+       <field field_ref="ibgheat_tot"      name="ibgheat_tot"  />
+       <field field_ref="sbgheat_tot"      name="sbgheat_tot"  />
+       
+       <!-- global drifts (conservation checks) -->
+       <field field_ref="ibgvolume"        name="ibgvolume"    />
+       <field field_ref="ibgsaltco"        name="ibgsaltco"    />
+       <field field_ref="ibgheatco"        name="ibgheatco"    />
+       <field field_ref="ibgheatfx"        name="ibgheatfx"    />
+       
+       <!-- global forcings  -->
+       <field field_ref="ibgfrcvoltop"     name="ibgfrcvoltop" />
+       <field field_ref="ibgfrcvolbot"     name="ibgfrcvolbot" />
+       <field field_ref="ibgfrctemtop"     name="ibgfrctemtop" />
+       <field field_ref="ibgfrctembot"     name="ibgfrctembot" />
+       <field field_ref="ibgfrcsal"        name="ibgfrcsal"    />
+       <field field_ref="ibgfrchfxtop"     name="ibgfrchfxtop" />
+       <field field_ref="ibgfrchfxbot"     name="ibgfrchfxbot" />
+     </file>
+     
+   </file_group>
+   
+   <file_group id="1ts" output_freq="1ts" output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+   <file_group id="1h"  output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+   <file_group id="2h"  output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+   <file_group id="3h"  output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+   <file_group id="4h"  output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+   <file_group id="6h"  output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->        
+   <file_group id="1m"  output_freq="1mo" output_level="10" enabled=".TRUE."/> <!-- real monthly files -->
+   <file_group id="2m"  output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+   <file_group id="3m"  output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+   <file_group id="4m"  output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+   <file_group id="6m"  output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+   <file_group id="1y"  output_freq="1y"  output_level="10" enabled=".TRUE."/> <!-- real yearly files -->
+   <file_group id="2y"  output_freq="2y"  output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+   <file_group id="5y"  output_freq="5y"  output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+   <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+   
+ </file_definition>
+ 
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-CMIP6-INVALID_PERIOD.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-CMIP6-INVALID_PERIOD.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-ice-CMIP6-INVALID_PERIOD.xml	(revision 14671)
@@ -0,0 +1,4 @@
+You can't use the standard diagnostic options with the current cycling period.
+Choose the "Custom" option, copy the file_def*.xml files that
+you want to use into the Rose app and adjust the meaning period
+accordingly. 
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-BASIC-10D.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-BASIC-10D.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-BASIC-10D.xml	(revision 14671)
@@ -0,0 +1,98 @@
+<?xml version="1.0"?>
+
+<!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own filesfor ocean dynamics context                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+   
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1d" min_digits="4">
+    
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->     
+    
+
+      <file_group id="10d" output_freq="10d" output_level="10" split_freq="10d" enabled=".TRUE."> <!-- real monthly files -->
+
+        <file id="file8" name_suffix="_grid_T" >
+	  <field field_ref="e3t"          name="thkcello"   />
+          <field field_ref="ssh"          name="zos"        />
+          <field field_ref="ssh2"         name="zossq"      />
+          <field field_ref="sst_con"      name="tos_con"    />
+          <field field_ref="sss_abs"      name="sos_abs"    />
+          <field field_ref="sbt_con"      name="thetaob_con"/>
+          <field field_ref="sbs_abs"      name="sob_abs"    />
+          <field field_ref="toce_con"     name="thetao_con" operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)"   > @toce_con_e3t / @e3t </field>
+          <field field_ref="soce_abs"     name="so_abs"       operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)"    > @soce_abs_e3t / @e3t </field>
+          <field field_ref="mldzint_1"    name="somxzint1"  />
+	  <field field_ref="qt"           name="hfds"       />
+	  <field field_ref="qsr3d"        name="rsdo"       />
+	  <field field_ref="empmr"        name="sowaflup"   />
+          <field field_ref="ice_cover"    name="soicecov"   />
+          <field field_ref="berg_melt"       name="ficeberg"               />
+          <field field_ref="berg_melt_qlat"  name="berg_latent_heat_flux"  />
+	  <field field_ref="emp_oce"      name="soemp_oce"  />
+	  <field field_ref="emp_ice"      name="soemp_ice"  />
+	  <field field_ref="snowpre"      name="snowpre"    />
+	  <field field_ref="precip"       name="soprecip"   />
+	  <field field_ref="fmmflx"       name="fsitherm"   />
+	  <field field_ref="runoffs"      name="friver"     />
+	  <field field_ref="erp"          name="so_erp"     />
+	  <field field_ref="saltflx"      name="sfdsi"      />
+	  <field field_ref="qlatisf"      name="sohflisf"  />
+	  <field field_ref="qhcisf"       name="sohfcisf"   />
+	  <field field_ref="fwfisf"       name="sowflisf"   />
+        </file>
+
+	<file id="file9" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="e3u"          name="thkcello"   />
+          <field field_ref="ssu"          name="sozocrtx"   />
+          <field field_ref="uoce"         name="uo"      operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)"    > @uoce_e3u / @e3u </field>
+          <field field_ref="uoce"         name="u2o" standard_name="square_of_sea_water_x_velocity" long_name="UU"  operation="average" freq_op="10d"  cell_methods="time: mean (thickness weighted)"   > @uoce2_e3u / @e3u </field>
+	  <field field_ref="utau"         name="tauuo"      />
+	</file>
+	
+	<file id="file10" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="e3v"          name="thkcello"  />
+          <field field_ref="ssv"          name="somecrty"  />
+          <field field_ref="voce"         name="vo"      operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)"    > @voce_e3v / @e3v </field>
+          <field field_ref="voce"         name="v2o" standard_name="square_of_sea_water_y_velocity" long_name="VV"  operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)"    > @voce2_e3v / @e3v </field>
+	  <field field_ref="vtau"         name="tauvo"     />
+	</file>
+	
+	<file id="file11" name_suffix="_grid_W" description="ocean W grid variables" >
+	  <field field_ref="e3w" long_name="W-cell thickness"  />
+	  <field field_ref="woce"         name="wo"            />
+	  <field field_ref="avt"          name="difvho"        />
+	  <field field_ref="avm"          name="difvmo"        />
+	</file>
+
+
+      </file_group>
+
+      <file_group id="2m" output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m" output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m" output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m" output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+
+
+      <file_group id="2y"  output_freq="2y" output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y" output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+   </file_definition>
+    
+
+
+
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-BASIC-1M.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-BASIC-1M.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-BASIC-1M.xml	(revision 14671)
@@ -0,0 +1,99 @@
+<?xml version="1.0"?>
+
+<!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own filesfor ocean dynamics context                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+   
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1d" min_digits="4">
+    
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->     
+    
+
+      <file_group id="1m" output_freq="1mo" output_level="10" split_freq="1mo" enabled=".TRUE."> <!-- real monthly files -->
+
+        <file id="file8" name_suffix="_grid_T" >
+	  <field field_ref="e3t"          name="thkcello"  />
+          <field field_ref="ssh"          name="zos"       />
+          <field field_ref="ssh2"         name="zossq"     />
+
+          <field field_ref="sst_con"      name="tos_con"    />
+          <field field_ref="sss_abs"      name="sos_abs"    />
+          <field field_ref="sbt_con"      name="thetaob_con"/>
+          <field field_ref="sbs_abs"      name="sob_abs"    />
+          <field field_ref="toce_con"     name="thetao_con" operation="average" freq_op="1mo"  cell_methods="time: mean (thickness weighted)"   > @toce_con_e3t / @e3t </field>
+          <field field_ref="soce_abs"     name="so_abs"       operation="average" freq_op="1mo"  cell_methods="time: mean (thickness weighted)"   > @soce_abs_e3t / @e3t </field>
+          <field field_ref="mldzint_1"    name="somxzint1"  />
+	  <field field_ref="qt"           name="hfds"       />
+	  <field field_ref="qsr3d"        name="rsdo"       />
+	  <field field_ref="empmr"        name="sowaflup"   />
+          <field field_ref="ice_cover"    name="soicecov"   />
+          <field field_ref="berg_melt"       name="ficeberg"               />
+          <field field_ref="berg_melt_qlat"  name="berg_latent_heat_flux"  />
+	  <field field_ref="emp_oce"      name="soemp_oce"  />
+	  <field field_ref="emp_ice"      name="soemp_ice"  />
+	  <field field_ref="snowpre"      name="snowpre"    />
+	  <field field_ref="precip"       name="soprecip"   />
+	  <field field_ref="fmmflx"       name="fsitherm"   />
+	  <field field_ref="runoffs"      name="friver"     />
+	  <field field_ref="erp"          name="so_erp"     />
+	  <field field_ref="saltflx"      name="sfdsi"      />
+	  <field field_ref="qlatisf"      name="sohflisf"  />
+	  <field field_ref="qhcisf"       name="sohfcisf"   />
+	  <field field_ref="fwfisf"       name="sowflisf"   />
+        </file>
+
+	<file id="file9" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="e3u"          name="thkcello"   />
+          <field field_ref="ssu"          name="sozocrtx"   />
+          <field field_ref="uoce"         name="uo"      operation="average" freq_op="1mo"  cell_methods="time: mean (thickness weighted)"   > @uoce_e3u / @e3u </field>
+          <field field_ref="uoce"         name="u2o" standard_name="square_of_sea_water_x_velocity" long_name="UU"  operation="average" freq_op="1mo"  cell_methods="time: mean (thickness weighted)"   > @uoce2_e3u / @e3u </field>
+	  <field field_ref="utau"         name="tauuo"      />
+	</file>
+	
+	<file id="file10" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="e3v"          name="thkcello"  />
+          <field field_ref="ssv"          name="somecrty"  />
+          <field field_ref="voce"         name="vo"      operation="average" freq_op="1mo"  cell_methods="time: mean (thickness weighted)"   > @voce_e3v / @e3v </field>
+          <field field_ref="voce"         name="v2o" standard_name="square_of_sea_water_y_velocity" long_name="VV"  operation="average" freq_op="1mo" cell_methods="time: mean (thickness weighted)"   > @voce2_e3v / @e3v </field>
+	  <field field_ref="vtau"         name="tauvo"     />
+	</file>
+	
+	<file id="file11" name_suffix="_grid_W" description="ocean W grid variables" >
+	  <field field_ref="e3w" long_name="W-cell thickness"  />
+	  <field field_ref="woce"         name="wo"            />
+	  <field field_ref="avt"          name="difvho"        />
+	  <field field_ref="avm"          name="difvmo"        />
+	</file>
+
+
+      </file_group>
+
+      <file_group id="2m" output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m" output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m" output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m" output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+
+
+      <file_group id="2y"  output_freq="2y" output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y" output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+   </file_definition>
+    
+
+
+
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-BASIC-INVALID_PERIOD.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-BASIC-INVALID_PERIOD.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-BASIC-INVALID_PERIOD.xml	(revision 14671)
@@ -0,0 +1,4 @@
+You can't use the standard diagnostic options with the current cycling period.
+Choose the "Custom" option, copy the file_def*.xml files that
+you want to use into the Rose app and adjust the meaning period
+accordingly. 
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-CMIP6-10D.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-CMIP6-10D.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-CMIP6-10D.xml	(revision 14671)
@@ -0,0 +1,339 @@
+<?xml version="1.0"?>
+
+<!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own filesfor ocean dynamics context                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+   
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1d" min_digits="4">
+    
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->     
+    
+
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE.">  <!-- 1d files -->   
+
+	<file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
+          <field field_ref="sst_con"          name="tos_con"   standard_name="sea_surface_conservative_temperature"                                 />
+          <field field_ref="sst2_con"         name="tossq_com"   />
+          <field field_ref="sss_abs"          name="sos_abs"   standard_name="sea_surface_absolute_salinity"                                    />
+          <field field_ref="sss2_abs"         name="sossq_abs" long_name="Square of Sea Surface Absolute Salinity"   standard_name="square_of_sea_surface_absolute_Salinity"   unit="1e-06"     > sss_abs * sss_abs </field >
+          <field field_ref="mldr0_3"     name="mlotst"   long_name="Ocean Mixed Layer Thickness Defined by Sigma T"         />
+	  <field field_ref="ssh"       name="zos"   standard_name="sea_surface_height_above_geoid" long_name="Sea Surface Height Above Geoid"      />
+<!-- TO FIX
+          <field field_ref="20d"          name="t20d"  standard_name="depth_of_isosurface_of_sea_water_potential_temperature" />
+-->
+	</file>
+	
+	<file id="file2" name_suffix="_grid_U" description="ocean U grid variables" enabled=".FALSE." >
+          <field field_ref="ssu"          name="sozocrtx"   standard_name="sea_surface_eastward_sea_water_velocity"                 />
+	  <field field_ref="utau"         name="sozotaux"   standard_name="surface_downward_x_stress" />
+	</file>
+	
+	<file id="file3" name_suffix="_grid_V" description="ocean V grid variables"  enabled=".FALSE." >
+          <field field_ref="ssv"          name="somecrty"   standard_name="sea_surface_northward_sea_water_velocity"                 />
+	  <field field_ref="vtau"         name="sometauy"   standard_name="surface_downward_y_stress" />
+	</file>
+
+        <file id="file9" name_suffix="_scalar" description="scalar variables"  enabled=".FALSE." >
+          <field field_ref="sshthster"    name="scsshtst"   />
+          <field field_ref="voltot"       name="scvoltot"   />
+        </file>
+
+      </file_group>
+
+      <file_group id="10d" output_freq="10d"  output_level="10" enabled=".TRUE.">  <!-- 10d files -->   
+
+	<file id="file4" name_suffix="_grid_T" description="ocean T grid variables" >
+          <field field_ref="e3t"          name="thkcello"        standard_name="cell_thickness" />
+<!-- Is this dangerous to include rho0 here as a hard coded value -->
+          <field field_ref="e3t"          name="masscello"        standard_name="sea_water_mass_per_unit_area" unit="kg/m2" long_name="Ocean Grid-Cell Mass per area" > @e3t * 1026.0 </field> 
+          <field field_ref="tpt_dep"      name="zfull"        />
+<!-- TO FIX
+          <field field_ref="20d"          name="t20d"  standard_name="depth_of_isosurface_of_sea_water_potential_temperature" />
+-->
+          <field field_ref="toce_con"         name="thetao_con"       operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @toce_con_e3t / @e3t </field>
+<!-- TO FIX
+          <field field_ref="toce_vmean"   name="thetaot"   />
+          <field field_ref="toce_vmean300"   name="thetaot300"   />
+-->
+          <field field_ref="soce_abs"         name="so_abs"     operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @soce_e3t_abs / @e3t </field>
+	  <field field_ref="ssh"       name="zos"   standard_name="sea_surface_height_above_geoid" long_name="Sea Surface Height Above Geoid"      />
+          <field field_ref="ssh2"      name="zossq"  standard_name="square_of_sea_surface_height_above_geoid" long_name="Square of Sea Surface Height Above Geoid"  />
+	  <field field_ref="runoffs"      name="friver"   standard_name="water_flux_into_sea_water_from_rivers"                     />
+	  <field field_ref="qt"           name="hfds"   standard_name="surface_downward_heat_flux_in_sea_water"                     />
+	  <field field_ref="qsr3d"        name="rsdo"   standard_name="downwelling_shortwave_flux_in_sea_water"                     />
+          <field field_ref="mldr0_3"      name="mlotst"   long_name="Ocean Mixed Layer Thickness Defined by Sigma T"         />
+          <field field_ref="mldr0_3"      name="mlotstsq"  long_name="Square of Ocean Mixed Layer Thickness Defined by Sigma T"  standard_name="square_of_ocean_mixed_layer_thickness_defined_by_sigma_theta" > mldr0_3 * mldr0_3 </field>
+          <field field_ref="mldr0_3"      name="mlotstmax"   long_name="Ocean Mixed Layer Thickness Defined by Sigma T" operation="maximum"        />
+          <field field_ref="mldr0_3"      name="mlotstmin"   long_name="Ocean Mixed Layer Thickness Defined by Sigma T" operation="minimum"        />
+          <field field_ref="berg_melt"       name="ficeberg"     standard_name="water_flux_into_sea_water_from_icebergs"      />
+          <field field_ref="berg_melt_qlat"  name="berg_latent_heat_flux"     standard_name="latent_heat_flux_from_icebergs"                                 />
+          <field field_ref="botpres"      name="pbo"                                                                                />
+          <field field_ref="sst_con"          name="tos_con"   standard_name="sea_surface_conservative_temperature"                                 />
+          <field field_ref="sst2_con"          name="tossq_con"   />
+          <field field_ref="sss_abs"          name="sos_abs"   standard_name="sea_surface_absolute_salinity"                                    />
+          <field field_ref="sss2_abs"         name="sossq_abs" long_name="Square of Sea Surface Absolute Salinity"   standard_name="square_of_sea_surface_absolute_Salinity"   unit="1e-06"     > sss_abs * sss_abs </field >
+          <field field_ref="sbt_con"          name="thetaob_con"   standard_name="sea_water_conservative_temperature_at_sea_floor"            />
+          <field field_ref="sbs_abs"          name="sob_abs"   standard_name="sea_water_absolute_salinity_at_sea_floor"                         />
+<!-- TO FIX
+          <field field_ref="rain_ao_cea" name="pr" standard_name="rainfall_flux" long_name="Rainfall Flux" > @rain_ao_cea </field>
+-->
+          <field field_ref="evap_ao_cea" name="evs" standard_name="water_evaporation_flux" long_name="Water Evaporation Flux Where Ice Free Ocean over Sea" />
+          <field field_ref="snow_ao_cea" name="prsn" standard_name="snowfall_flux" long_name="Snowfall Flux" />
+          <field field_ref="hflx_rain_cea" name="hfrainds" long_name="Temperature Flux due to Rain Expressed as Heat Flux In To Sea Water" standard_name="temperature_flux_due_to_rain_expressed_as_heat_flux_into_sea_water" > hflx_rain_cea </field> 
+          <field field_ref="hflx_evap_cea" name="hfevapds" long_name="Temperature Flux due to Evaporation Expressed as Heat Flux Out of Sea Water" standard_name="temperature_flux_due_to_evaporation_expressed_as_heat_flux_out_of_sea_water" />
+          <field field_ref="hflx_rnf_cea" name="hflx_rnf" long_name="Temperature Flux due to Runoff Expressed as Heat Flux into  Sea Water" standard_name="temperature_flux_due_to_runoff_expressed_as_heat_flux_into_sea_water" > hflx_rnf_cea </field> 
+          <field field_ref="saltflx"      name="sfdsi" standard_name="downward_sea_ice_basal_salt_flux" />
+          <field field_ref="fmmflx"       name="fsitherm"      unit="kg/m2/s"   />
+          <field field_ref = "empmr" >@empmr + @fwfisf </field>
+<!-- TO FIX
+          <field field_ref="Age" name="agessc" />
+-->
+          <field field_ref="tnpeo" />
+          <field field_ref="snowpre" name="snowpre" />
+          <field field_ref="snow_ai_cea" name="snow_ai_cea" />
+	  <field field_ref="empmr"        name="sowaflup"   standard_name="water_flux_out_of_sea_ice_and_sea_water"                 />
+	  <field field_ref="saltflx"      name="sosafldo"   standard_name="salt_flux_into_sea_water"                                />
+          <field field_ref="mldkz5"       name="somixhgt"   standard_name="ocean_mixed_layer_thickness_defined_by_vertical_tracer_diffusivity"   />
+          <field field_ref="mldr10_1"     name="somxl010"   standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"      />
+          <field field_ref="mldzint_1"    name="somxzint1"   standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"      />
+          <field field_ref="ice_cover"    name="soicecov"   standard_name="sea_ice_area_fraction"                                   />
+          <field field_ref="wspd"         name="sowindsp"   standard_name="wind_speed"                                              />          
+          <field field_ref="qlatisf"         name="sohflisf"   standard_name=""                                                        />
+          <field field_ref="qlatisf3d"         name="vohflisf"   standard_name=""                                                        />
+          <field field_ref="qhcisf"         name="sohfcisf"   standard_name=""                                                        />
+          <field field_ref="qhcisf3d"         name="vohfcisf"   standard_name=""                                                        />
+          <field field_ref="fwfisf"       name="sowflisf"   standard_name=""                                                        />
+          <field field_ref="fwfisf3d"     name="vowflisf"   standard_name=""                                                        />
+<!-- TO FIX
+          <field field_ref="ketrd_ldf_vsum"     name="dispkexyfo"   standard_name="Dissipation of kinetic energy by lateral viscosity" grid_ref="vert_sum"/>
+-->
+          <field field_ref="tosmint"       name="opottempmint" />
+          <field field_ref="somint"       name="somint" />
+<!-- TO FIX
+          <field field_ref="toce_e3t_300" name="T300m" />
+          <field field_ref="e3t_300" name="e3t300m" />
+          <field field_ref="toce_e3t_vsum300" name="Tsum300m" />
+          <field field_ref="e3t_vsum300" name="e3t_vsum300m" />
+-->
+          <field field_ref="sbs_abs" name="sob_abs" />
+          <field field_ref="bn2" name="obvfsq" />
+<!-- trend diagnostics-->
+          <field field_ref="ttrd_totad_li"   name="opottempadvect"  unit="W/m2"    />
+          <field field_ref="ttrd_iso_li"     name="opottemppmdiff"  unit="W/m2"    />
+          <field field_ref="ttrd_zdfp_li"    name="opottempdiff"    unit="W/m2"    />
+          <field field_ref="ttrd_evd_li"     name="ttrd_evd_li"                    />
+          <field field_ref="ttrd_qns_li"     name="ttrd_qns_li"                    />
+          <field field_ref="ttrd_qsr_li"     name="rsdoabsorb"      unit="W/m2"    />
+          <field field_ref="ttrd_bbl_li"     name="ttrd_bbl_li"                    />
+          <field field_ref="ttrd_atf_li"     name="ttrd_atf_li"                    />
+          <field field_ref="ttrd_tot_li"     name="opottemptend"    unit="W/m2"    />
+          <field field_ref="strd_totad_li"   name="osaltadvect"     unit="Kg/m2/s" />
+          <field field_ref="strd_iso_li"     name="osaltpmdiff"     unit="kg/m2/s" />
+          <field field_ref="strd_zdfp_li"    name="osaltdiff"       unit="kg/m2/s" />
+          <field field_ref="strd_evd_li"     name="strd_evd_li"                    />
+          <field field_ref="strd_tot_li"     name="osalttend"       unit="kg/m2/s" />
+          <field field_ref="strd_bbl_li"     name="strd_bbl_li"                    />
+          <field field_ref="strd_atf_li"     name="strd_atf_li"                    />
+	</file>
+	
+	<file id="file5" name_suffix="_grid_U" description="ocean U grid variables" >
+          <field field_ref="e3u"          name="thkcello"     standard_name="cell_thickness" />
+          <field field_ref="uoce"         name="uo"     operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @uoce_e3u / @e3u </field>
+	  <field field_ref="utau"         name="tauuo"   standard_name="surface_downward_x_stress"  />
+          <field field_ref="ut"           name="uto" standard_name="product_of_xward_sea_water_velocity_and_temperature" long_name="UT"  operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @ut_e3u / @e3u </field>
+          <field field_ref="us"           name="uso" standard_name="product_of_xward_sea_water_velocity_and_salinity" long_name="US"    operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @us_e3u / @e3u </field>
+          <field field_ref="uoce"         name="u2o" standard_name="square_of_sea_water_x_velocity" long_name="UU"  operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @uoce2_e3u / @e3u </field>
+          <!-- available with key_diaar5 -->
+          <field field_ref="u_masstr"     name="umo" /> 
+          <field field_ref="u_masstr_vint"     name="umo_vint" /> 
+          <field field_ref="u_heattr"     name="hfx" > @uadv_heattr + @udiff_heattr </field> 
+          <field field_ref="uadv_heattr"     name="hfx_adv" /> 
+          <field field_ref="udiff_heattr"     name="hfx_diff" /> 
+<!--below here not in CMOR format yet -->
+          <field field_ref="u_salttr"     name="sozosatr" />
+	</file>
+	
+	<file id="file6" name_suffix="_grid_V" description="ocean V grid variables" >
+          <field field_ref="e3v"          name="thkcello"        standard_name="cell_thickness" />
+          <field field_ref="voce"         name="vo"     operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @voce_e3v / @e3v </field>
+	  <field field_ref="vtau"         name="tauvo"   standard_name="surface_downward_y_stress" />
+          <field field_ref="vt"           name="vto" standard_name="product_of_yward_sea_water_velocity_and_temperature" long_name="VT"  operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @vt_e3v / @e3v </field>
+          <field field_ref="vs"           name="vso" standard_name="product_of_yward_sea_water_velocity_and_salinity" long_name="VS"  operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @vs_e3v / @e3v </field>
+          <field field_ref="voce"         name="v2o" standard_name="square_of_sea_water_y_velocity" long_name="VV"  operation="average" freq_op="10d" cell_methods="time: mean (thickness weighted)" > @voce2_e3v / @e3v </field>
+          <!-- available with key_diaar5 -->
+          <field field_ref="v_masstr"     name="vmo" /> 
+          <field field_ref="v_heattr"     name="hfy" > @vadv_heattr + @vdiff_heattr </field>
+          <field field_ref="vadv_heattr"     name="hfy_adv" /> 
+          <field field_ref="vdiff_heattr"     name="hfy_diff" /> 
+<!--below here not in CMOR format yet -->
+          <field field_ref="v_salttr"     name="somesatr" />
+	</file>
+	
+	<file id="file7" name_suffix="_grid_W" description="ocean W grid variables" >
+	  <field field_ref="avt"          name="difvho"   standard_name="ocean_vertical_heat_diffusivity"  />
+	  <field field_ref="avs"          name="difvso"   standard_name="ocean_vertical_salt_diffusivity"   />                 
+          <field field_ref="avm"          name="difvmo"   standard_name="ocean_vertical_momentum_diffusivity"               />
+          <field field_ref="avt_evd"      name="avt_evd"  standard_name="enhanced_vertical_heat_diffusivity"               />
+          <field field_ref="av_tmx"       name="diftrto"  standard_name="ocean_vertical_tracer_diffusivity_due_to_tides"               />
+          <field field_ref="w_masstr"     name="wmo" > w_masstr </field>
+	  <field field_ref="woce"         name="wo" standard_name="upward_sea_water_velocity" long_name="W"                  />
+          <field field_ref="woce"         name="w2o" standard_name="square_of_upward_sea_water_velocity" long_name="WW"  operation="average" > woce * woce </field>
+          <field field_ref="wt"           name="wt"         standard_name="product_of_upward_sea_water_velocity_and_temperature" long_name="WT"         />
+          <field field_ref="ws"           name="ws"         standard_name="product_of_upward_sea_water_velocity_and_salinity" long_name="WS"            />
+<!-- TO FIX
+          <field field_ref="wpt_dep"      name="zhalf"        />
+-->
+	</file>
+	
+        <file id="file8" name_suffix="_scalar" description="scalar variables" enabled=".true." >
+          <field field_ref="voltot"       name="scvoltot"   />
+          <field field_ref="temptot"      name="thetaoga" cell_methods="time: mean (volume weighted)"   />
+          <field field_ref="saltot"       name="soga"     cell_methods="time: mean (volume weighted)"   />
+        </file>
+
+        <file id="file10" name_suffix="_diaptr" description="processed diagnostics" >
+          <field field_ref="zomsfglo"     name="zomsfglo"   standard_name="meridional_streamfunction_global"           grid_ref="gznl_W_3D"       />
+          <field field_ref="zotemglo"     name="zotemglo"   standard_name="zonal_mean_temperature_global"              grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfglo"     name="zosrfglo"   standard_name="zonal_mean_surface_global"                  grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalglo"     name="zosalglo"   standard_name="zonal_mean_salinity_global"                 grid_ref="gznl_T_3D"       />          
+          <field field_ref="zomsfatl"     name="zomsfatl"   standard_name="meridional_streamfunction_atlantic"         grid_ref="gznl_W_3D"       />
+          <field field_ref="zotematl"     name="zotematl"   standard_name="zonal_mean_temperature_atlantic"            grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfatl"     name="zosrfatl"   standard_name="zonal_mean_surface_atlantic"                grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalatl"     name="zosalatl"   standard_name="zonal_mean_salinity_atlantic"               grid_ref="gznl_T_3D"       />          
+          <field field_ref="zomsfpac"     name="zomsfpac"   standard_name="meridional_streamfunction_pacific"          grid_ref="gznl_W_3D"       />
+          <field field_ref="zotempac"     name="zotempac"   standard_name="zonal_mean_temperature_pacific"             grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfpac"     name="zosrfpac"   standard_name="zonal_mean_surface_pacific"                 grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalpac"     name="zosalpac"   standard_name="zonal_mean_salinity_pacific"                grid_ref="gznl_T_3D"       />
+          <field field_ref="zomsfind"     name="zomsfind"   standard_name="meridional_streamfunction_indian"           grid_ref="gznl_W_3D"       />
+          <field field_ref="zotemind"     name="zotemind"   standard_name="zonal_mean_temperature_indian"              grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfind"     name="zosrfind"   standard_name="zonal_mean_surface_indian"                  grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalind"     name="zosalind"   standard_name="zonal_mean_salinity_indian"                 grid_ref="gznl_T_3D"       />          
+          <field field_ref="zomsfipc"     name="zomsfipc"   standard_name="meridional_streamfunction_indian_pacific"   grid_ref="gznl_W_3D"       />
+          <field field_ref="zotemipc"     name="zotemipc"   standard_name="zonal_mean_temperature_indian_pacific"      grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfipc"     name="zosrfipc"   standard_name="zonal_mean_surface_indian_pacific"          grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalipc"     name="zosalipc"   standard_name="zonal_mean_salinity_indian_pacific"         grid_ref="gznl_T_3D"       />          
+          <field field_ref="sophtadv"     name="sophtadv"   standard_name="advective_heat_transport"                   grid_ref="gznl_T_2D"       />
+          <field field_ref="sophtadv_atl"    name="sophtadv_atlantic"   standard_name="advective_heat_transport_atlantic"/>
+          <field field_ref="sophtadv_pac"    name="sophtadv_pacific"   standard_name="advective_heat_transport_pacific" />
+          <field field_ref="sophtadv_ind"    name="sophtadv_indian"   standard_name="advective_heat_transport_indian"   />
+          <field field_ref="sophtadv_ipc"    name="sophtadv_ipc"   standard_name="advective_heat_transport_indopacific"  />
+          <field field_ref="sophtbtr"     name="hfovbaro"   standard_name="barotropic_heat_transport"                   grid_ref="gznl_T_2D"       />
+          <field field_ref="sophtbtr_atl"    name="hfovbaro_atlantic"   standard_name="barotropic_heat_transport_atlantic"/>
+          <field field_ref="sophtbtr_pac"    name="hfovbaro_pacific"   standard_name="barotropic_heat_transport_pacific" />
+          <field field_ref="sophtbtr_ind"    name="hfovbaro_indian"   standard_name="barotropic_heat_transport_indian"   />
+          <field field_ref="sophtbtr_ipc"    name="hfovbaro_ipc"   standard_name="barotropic_heat_transport_indopacific"  />
+          <field field_ref="sopstadv"     name="sopstadv"   standard_name="advective_salt_transport"                   grid_ref="gznl_T_2D"       />
+          <field field_ref="sopstadv_atl"    name="sopstadv_atlantic"   standard_name="advective_salt_transport_atlantic"/>
+          <field field_ref="sopstadv_pac"    name="sopstadv_pacific"   standard_name="advective_salt_transport_pacific" />
+          <field field_ref="sopstadv_ind"    name="sopstadv_indian"   standard_name="advective_salt_transport_indian"   />
+          <field field_ref="sopstadv_ipc"    name="sopstadv_ipc"   standard_name="advective_salt_transport_indopacific"  />
+          <field field_ref="sopstbtr"     name="sltovbaro"   standard_name="barotropic_salt_transport"     />
+          <field field_ref="sopstbtr_atl"    name="sltovbaro_atlantic"   standard_name="barotropic_salt_transport_atlantic"/>
+          <field field_ref="sopstbtr_pac"    name="sltovbaro_pacific"   standard_name="barotropic_salt_transport_pacific" />
+          <field field_ref="sopstbtr_ind"    name="sltovbaro_indian"   standard_name="barotropic_salt_transport_indian"   />
+          <field field_ref="sopstbtr_ipc"    name="sltovbaro_ipc"   standard_name="barotropic_salt_transport_indopacific"  />
+          <!--The following variables are to be merged into a single variableis with a basin dimenesion in postprocessing  -->
+          <!-- hfbasin -->
+          <field field_ref="sophtadv" name="hfbasin_global" standard_name="northward_ocean_heat_transport" > @sophtadv + @sophtldf </field>
+          <field field_ref="sophtadv" name="hfbasin_atlantic" standard_name="northward_ocean_heat_transport" > @sophtadv_atl + @sophtldf_atl </field>
+          <field field_ref="sophtadv" name="hfbasin_pacific" standard_name="northward_ocean_heat_transport" > @sophtadv_pac + @sophtldf_pac </field>
+          <field field_ref="sophtadv" name="hfbasin_indian" standard_name="northward_ocean_heat_transport" > @sophtadv_ind + @sophtldf_ind </field>
+          <field field_ref="sophtadv" name="hfbasin_indopacific" standard_name="northward_ocean_heat_transport" > @sophtadv_ipc + @sophtldf_ipc </field>
+          <!-- hfbasinpadv -->
+          <field field_ref="sophteiv"     name="hfbasinpadv_global"   standard_name="bolus_heat_transport"                       grid_ref="gznl_T_2D"       />
+          <field field_ref="sophteiv_atl"    name="hfbasinpadv_atlantic"   standard_name="bolus_heat_transport_atlantic"/>
+          <field field_ref="sophteiv_pac"    name="hfbasinpadv_pacific"   standard_name="bolus_heat_transport_pacific" />
+          <field field_ref="sophteiv_ind"    name="hfbasinpadv_indian"   standard_name="bolus_heat_transport_indian"   />
+          <field field_ref="sophteiv_ipc"    name="hfbasinpadv_indopacific"   standard_name="bolus_heat_transport_indopacific"   />
+          <!-- hfbasinpmadv -->
+          <field field_ref="sophteiv"     name="hfbasinpmadv_global"   standard_name="bolus_heat_transport"                       grid_ref="gznl_T_2D"       />
+          <field field_ref="sophteiv_atl"    name="hfbasinpmadv_atlantic"   standard_name="bolus_heat_transport_atlantic"/>
+          <field field_ref="sophteiv_pac"    name="hfbasinpmadv_pacific"   standard_name="bolus_heat_transport_pacific" />
+          <field field_ref="sophteiv_ind"    name="hfbasinpmadv_indian"   standard_name="bolus_heat_transport_indian"   />
+          <field field_ref="sophteiv_ipc"    name="hfbasinpmadv_indopacific"   standard_name="bolus_heat_transport_indopacific"   />
+          <!-- hfbasinpmdiff -->
+          <field field_ref="sophtldf"     name="hfbasinpmdiff_global"   standard_name="diffusive_transport"                       grid_ref="gznl_T_2D"       />
+          <field field_ref="sophtldf_atl"    name="hfbasinpmdiff_atlantic"   standard_name="diffusive_transport_atlantic"/>
+          <field field_ref="sophtldf_pac"    name="hfbasinpmdiff_pacific"   standard_name="diffusive_transport_pacific" />
+          <field field_ref="sophtldf_ind"    name="hfbasinpmdiff_indian"   standard_name="diffusive_transport_indian"   />
+          <field field_ref="sophtldf_ipc"    name="hfbasinpmdiff_indopacific"   standard_name="diffusive_transport_indopacific"   />
+          <!-- hfovovrt -->
+          <field field_ref="sophtove"     name="hfovovrt_global"   standard_name="overturning_heat_transport"                   grid_ref="gznl_T_2D"       />
+          <field field_ref="sophtove_atl"    name="hfovovrt_atlantic"   standard_name="overturning_heat_transport_atlantic"/>
+          <field field_ref="sophtove_pac"    name="hfovovrt_pacific"   standard_name="overturning_heat_transport_pacific" />
+          <field field_ref="sophtove_ind"    name="hfovovrt_indian"   standard_name="overturning_heat_transport_indian"   />
+          <field field_ref="sophtove_ipc"    name="hfovovrt_indopacific"   standard_name="overturning_heat_transport_indopacific"   />
+          <!-- hfovgyre IS THIS DONE CORRECTLY? SHOULD WE ALSO SUBTRACT THE BAROTROPIC TERM? The CMIP6 data request says not to so leave it for now-->
+          <field field_ref="sophtove"     name="hfovgyre_global"   standard_name="gyre_heat_transport"         > @sophtadv - @sophtove </field>
+          <field field_ref="sophtove_atl"    name="hfovgyre_atlantic"   standard_name="gyre_heat_transport_atlantic" > @sophtadv_atl - @sophtove_atl </field>
+          <field field_ref="sophtove_pac"    name="hfovgyre_pacific"   standard_name="gyre_heat_transport_pacific"  > @sophtadv_pac - @sophtove_pac </field>
+          <field field_ref="sophtove_ind"    name="hfovgyre_indian"   standard_name="gyre_heat_transport_indian"   > @sophtadv_ind - @sophtove_ind </field>
+          <field field_ref="sophtove_ipc"    name="hfovgyre_indopacific"   standard_name="gyre_heat_transport_indopacific"   > @sophtadv_ipc - @sophtove_ipc </field>
+          <!-- sltbasin -->
+          <field field_ref="sopstadv" name="sltbasin_global" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv + @sopstldf)/1000 </field>
+          <field field_ref="sopstadv" name="sltbasin_atlantic" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv_atl + @sopstldf_atl)/1000 </field>
+          <field field_ref="sopstadv" name="sltbasin_pacific" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv_pac + @sopstldf_pac)/1000 </field>
+          <field field_ref="sopstadv" name="sltbasin_indian" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv_ind + @sopstldf_ind)/1000 </field>
+          <field field_ref="sopstadv" name="sltbasin_indopacific" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv_ipc + @sopstldf_ipc)/1000 </field>
+          <!-- sltbasinpadv -->
+          <field field_ref="sopsteiv"        name="sltbasinpadv_global"   standard_name="bolus_salt_transport"  unit="kg s-1"> @sopsteiv/1000   </field>
+          <field field_ref="sopsteiv_atl"    name="sltbasinpadv_atlantic"   standard_name="bolus_salt_transport_atlantic" unit="kg s-1"> @sopsteiv_atl/1000   </field>
+          <field field_ref="sopsteiv_pac"    name="sltbasinpadv_pacific"   standard_name="bolus_salt_transport_pacific" unit="kg s-1"> @sopsteiv_pac/1000   </field>
+          <field field_ref="sopsteiv_ind"    name="sltbasinpadv_indian"   standard_name="bolus_salt_transport_indian"  unit="kg s-1"> @sopsteiv_ind/1000   </field>
+          <field field_ref="sopsteiv_ipc"    name="sltbasinpadv_indopacific"   standard_name="bolus_salt_transport_indopacific"  unit="kg s-1"> @sopsteiv_ipc/1000   </field>
+          <!-- sltbasinpmadv -->
+          <field field_ref="sopsteiv"        name="sltbasinpmadv_global"   standard_name="bolus_salt_transport"  unit="kg s-1"> @sopsteiv/1000   </field>        
+          <field field_ref="sopsteiv_atl"    name="sltbasinpmadv_atlantic"   standard_name="bolus_salt_transport_atlantic" unit="kg s-1"> @sopsteiv_atl/1000   </field>
+          <field field_ref="sopsteiv_pac"    name="sltbasinpmadv_pacific"   standard_name="bolus_salt_transport_pacific" unit="kg s-1"> @sopsteiv_pac/1000   </field>
+          <field field_ref="sopsteiv_ind"    name="sltbasinpmadv_indian"   standard_name="bolus_salt_transport_indian"  unit="kg s-1"> @sopsteiv_ind/1000   </field>
+          <field field_ref="sopsteiv_ipc"    name="sltbasinpmadv_indopacific"   standard_name="bolus_salt_transport_indopacific"  unit="kg s-1"> @sopsteiv_ipc/1000   </field>
+          <!-- sltbasinpmdiff -->
+          <field field_ref="sopstldf"     name="sltbasinpmdiff_global"   standard_name="diffusive_transport" unit="kg s-1">   @sopstldf/1000   </field>
+          <field field_ref="sopstldf_atl"    name="sltbasinpmdiff_atlantic"   standard_name="diffusive_transport_atlantic" unit="kg s-1"> @sopstldf_atl/1000   </field>
+          <field field_ref="sopstldf_pac"    name="sltbasinpmdiff_pacific"   standard_name="diffusive_transport_pacific" unit="kg s-1"> @sopstldf_pac/1000   </field>
+          <field field_ref="sopstldf_ind"    name="sltbasinpmdiff_indian"   standard_name="diffusive_transport_indian" unit="kg s-1">  @sopstldf_ind/1000   </field>
+          <field field_ref="sopstldf_ipc"    name="sltbasinpmdiff_indopacific"   standard_name="diffusive_transport_indopacific" unit="kg s-1">  @sopstldf_ipc/1000   </field>
+          <!-- sltovovrt -->
+          <field field_ref="sopstove"     name="sltovovrt_global"   standard_name="overturning_salt_transport"  unit="kg s-1">   @sopstove/1000   </field>       
+          <field field_ref="sopstove_atl"    name="sltovovrt_atlantic"   standard_name="overturning_salt_transport_atlantic" unit="kg s-1">   @sopstove_atl/1000   </field>
+          <field field_ref="sopstove_pac"    name="sltovovrt_pacific"   standard_name="overturning_salt_transport_pacific"  unit="kg s-1">   @sopstove_pac/1000   </field>
+          <field field_ref="sopstove_ipc"    name="sltovovrt_indopacific"   standard_name="overturning_salt_transport_indopacific"   unit="kg s-1">   @sopstove_ipc/1000   </field>
+          <!-- sltovgyre IS THIS DONE CORRECTLY? SHOULD WE ALSO SUBTRACT THE BAROTROPIC TERM?-->
+          <field field_ref="sopstove"     name="sltovgyre_global"   standard_name="gyre_salt_transport"    unit="kg s-1" > (@sopstadv - @sopstove)/1000 </field>
+          <field field_ref="sopstove_atl"    name="sltovgyre_atlantic"   standard_name="gyre_salt_transport_atlantic" unit="kg s-1" > (@sopstadv_atl - @sopstove_atl)/1000 </field>
+          <field field_ref="sopstove_pac"    name="sltovgyre_pacific"   standard_name="gyre_salt_transport_pacific" unit="kg s-1"  > (@sopstadv_pac - @sopstove_pac)/1000 </field>
+          <field field_ref="sopstove_ind"    name="sltovgyre_indian"   standard_name="gyre_salt_transport_indian" unit="kg s-1"   > (@sopstadv_ind - @sopstove_ind)/1000 </field>
+          <field field_ref="sopstove_ipc"    name="sltovgyre_indopacific"   standard_name="gyre_salt_transport_ipc" unit="kg s-1"   > (@sopstadv_ipc - @sopstove_ipc)/1000 </field>
+        </file>
+
+      </file_group>
+
+      <file_group id="2m" output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m" output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m" output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m" output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+
+
+      <file_group id="2y"  output_freq="2y" output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y" output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+   </file_definition>
+    
+
+
+
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-CMIP6-1M.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-CMIP6-1M.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-CMIP6-1M.xml	(revision 14671)
@@ -0,0 +1,339 @@
+<?xml version="1.0"?>
+
+<!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own filesfor ocean dynamics context                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+   
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1d" min_digits="4">
+    
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->     
+    
+
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE.">  <!-- 1d files -->   
+
+	<file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
+          <field field_ref="sst_con"          name="tos_con"   standard_name="sea_surface_conservative_temperature"                                 />
+          <field field_ref="sst2_con"          name="tossq_con"   />
+          <field field_ref="sss_abs"          name="sos_abs"   standard_name="sea_surface_absolute_salinity"                                    />
+          <field field_ref="sss2_abs"         name="sossq_abs" long_name="Square of Sea Surface Absolute Salinity"   standard_name="square_of_sea_surface_absolute_Salinity"   unit="1e-06"     > sss_abs * sss_abs </field >
+          <field field_ref="mldr0_3"     name="mlotst"   long_name="Ocean Mixed Layer Thickness Defined by Sigma T"         />
+	  <field field_ref="ssh"       name="zos"   standard_name="sea_surface_height_above_geoid" long_name="Sea Surface Height Above Geoid"      />
+<!-- TO FIX
+          <field field_ref="20d"          name="t20d"  standard_name="depth_of_isosurface_of_sea_water_potential_temperature" />
+-->
+	</file>
+	
+	<file id="file2" name_suffix="_grid_U" description="ocean U grid variables" enabled=".FALSE." >
+          <field field_ref="ssu"          name="sozocrtx"   standard_name="sea_surface_eastward_sea_water_velocity"                 />
+	  <field field_ref="utau"         name="sozotaux"   standard_name="surface_downward_x_stress" />
+	</file>
+	
+	<file id="file3" name_suffix="_grid_V" description="ocean V grid variables"  enabled=".FALSE." >
+          <field field_ref="ssv"          name="somecrty"   standard_name="sea_surface_northward_sea_water_velocity"                 />
+	  <field field_ref="vtau"         name="sometauy"   standard_name="surface_downward_y_stress" />
+	</file>
+
+        <file id="file9" name_suffix="_scalar" description="scalar variables"  enabled=".FALSE." >
+          <field field_ref="sshthster"    name="scsshtst"   />
+          <field field_ref="voltot"       name="scvoltot"   />
+        </file>
+
+      </file_group>
+
+      <file_group id="1m" output_freq="1mo"  output_level="10" enabled=".TRUE.">  <!-- 1mo files -->   
+
+	<file id="file4" name_suffix="_grid_T" description="ocean T grid variables" >
+          <field field_ref="e3t"          name="thkcello"     />
+<!-- Is this dangerous to include rho0 here as a hard coded value -->
+          <field field_ref="e3t"          name="masscello"        standard_name="sea_water_mass_per_unit_area" unit="kg/m2" long_name="Ocean Grid-Cell Mass per area" > @e3t * 1026.0 </field> 
+          <field field_ref="tpt_dep"      name="zfull"        />
+<!-- TO FIX
+          <field field_ref="20d"          name="t20d"  standard_name="depth_of_isosurface_of_sea_water_potential_temperature" />
+-->
+          <field field_ref="toce_con"         name="thetao_con"       operation="average" freq_op="1mo" cell_methods="time: mean (thickness weighted)" > @toce_e3t_con / @e3t </field>
+<!-- TO FIX
+          <field field_ref="toce_vmean"   name="thetaot"   />
+          <field field_ref="toce_vmean300"   name="thetaot300"   />
+-->
+          <field field_ref="soce_abs"         name="so_abs"     operation="average" freq_op="1mo"   cell_methods="time: mean (thickness weighted)" > @soce_e3t_abs / @e3t </field>
+	  <field field_ref="ssh"       name="zos"   standard_name="sea_surface_height_above_geoid" long_name="Sea Surface Height Above Geoid"      />
+          <field field_ref="ssh2"      name="zossq"  standard_name="square_of_sea_surface_height_above_geoid" long_name="Square of Sea Surface Height Above Geoid"  />
+	  <field field_ref="runoffs"      name="friver"   standard_name="water_flux_into_sea_water_from_rivers"                     />
+	  <field field_ref="qt"           name="hfds"   standard_name="surface_downward_heat_flux_in_sea_water"                     />
+	  <field field_ref="qsr3d"        name="rsdo"   standard_name="downwelling_shortwave_flux_in_sea_water"                     />
+          <field field_ref="mldr0_3"      name="mlotst"   long_name="Ocean Mixed Layer Thickness Defined by Sigma T"         />
+          <field field_ref="mldr0_3"      name="mlotstsq"  long_name="Square of Ocean Mixed Layer Thickness Defined by Sigma T"  standard_name="square_of_ocean_mixed_layer_thickness_defined_by_sigma_theta" > mldr0_3 * mldr0_3 </field>
+          <field field_ref="mldr0_3"      name="mlotstmax"   long_name="Ocean Mixed Layer Thickness Defined by Sigma T" operation="maximum"        />
+          <field field_ref="mldr0_3"      name="mlotstmin"   long_name="Ocean Mixed Layer Thickness Defined by Sigma T" operation="minimum"        />
+          <field field_ref="berg_melt"       name="ficeberg"     standard_name="water_flux_into_sea_water_from_icebergs"      />
+          <field field_ref="berg_melt_qlat"  name="berg_latent_heat_flux"     standard_name="latent_heat_flux_from_icebergs"                                 />
+          <field field_ref="botpres"      name="pbo"                                                                                />
+          <field field_ref="sst_con"          name="tos_con"   standard_name="sea_surface_conservative_temperature"                                 />
+          <field field_ref="sst2_con"          name="tossq_con"   />
+          <field field_ref="sss_abs"          name="sos_abs"   standard_name="sea_surface_absolute_salinity"                                    />
+          <field field_ref="sss2_abs"         name="sossq_abs" long_name="Square of Sea Surface Absolute Salinity"   standard_name="square_of_sea_surface_absolute_Salinity"   unit="1e-06"     > sss_abs * sss_abs </field >
+          <field field_ref="sbt_con"          name="thetaob_con"   standard_name="sea_water_conservative_temperature_at_sea_floor"            />
+          <field field_ref="sbs_abs"          name="sob_abs"   standard_name="sea_water_salinity_at_sea_floor"                         />
+<!-- TO FIX
+          <field field_ref="rain_ao_cea" name="pr" standard_name="rainfall_flux" long_name="Rainfall Flux" > @rain_ao_cea </field>
+-->
+          <field field_ref="evap_ao_cea" name="evs" standard_name="water_evaporation_flux" long_name="Water Evaporation Flux Where Ice Free Ocean over Sea" />
+          <field field_ref="snow_ao_cea" name="prsn" standard_name="snowfall_flux" long_name="Snowfall Flux" />
+          <field field_ref="hflx_rain_cea" name="hfrainds" long_name="Temperature Flux due to Rain Expressed as Heat Flux In To Sea Water" standard_name="temperature_flux_due_to_rain_expressed_as_heat_flux_into_sea_water" > hflx_rain_cea </field> 
+          <field field_ref="hflx_evap_cea" name="hfevapds" long_name="Temperature Flux due to Evaporation Expressed as Heat Flux Out of Sea Water" standard_name="temperature_flux_due_to_evaporation_expressed_as_heat_flux_out_of_sea_water" />
+          <field field_ref="hflx_rnf_cea" name="hflx_rnf" long_name="Temperature Flux due to Runoff Expressed as Heat Flux into  Sea Water" standard_name="temperature_flux_due_to_runoff_expressed_as_heat_flux_into_sea_water" > hflx_rnf_cea </field> 
+          <field field_ref="saltflx"      name="sfdsi" standard_name="downward_sea_ice_basal_salt_flux" />
+          <field field_ref="fmmflx"       name="fsitherm"      unit="kg/m2/s"   />
+          <field field_ref = "empmr" >@empmr + @fwfisf </field>
+<!-- TO FIX
+          <field field_ref="Age" name="agessc" />
+-->
+          <field field_ref="tnpeo" />
+          <field field_ref="snowpre"     name="snowpre" />
+          <field field_ref="snow_ai_cea" name="snow_ai_cea" />
+	  <field field_ref="empmr"        name="sowaflup"   standard_name="water_flux_out_of_sea_ice_and_sea_water"                 />
+	  <field field_ref="saltflx"      name="sosafldo"   standard_name="salt_flux_into_sea_water"                                />
+          <field field_ref="mldkz5"       name="somixhgt"   standard_name="ocean_mixed_layer_thickness_defined_by_vertical_tracer_diffusivity"   />
+          <field field_ref="mldr10_1"     name="somxl010"   standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"      />
+          <field field_ref="mldzint_1"    name="somxzint1"   standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"      />
+          <field field_ref="ice_cover"    name="soicecov"   standard_name="sea_ice_area_fraction"                                   />
+          <field field_ref="wspd"         name="sowindsp"   standard_name="wind_speed"                                              />          
+          <field field_ref="qlatisf"         name="sohflisf"   standard_name=""                                                        />
+          <field field_ref="qlatisf3d"         name="vohflisf"   standard_name=""                                                        />
+          <field field_ref="qhcisf"         name="sohfcisf"   standard_name=""                                                        />
+          <field field_ref="qhcisf3d"         name="vohfcisf"   standard_name=""                                                        />
+          <field field_ref="fwfisf"       name="sowflisf"   standard_name=""                                                        />
+          <field field_ref="fwfisf3d"     name="vowflisf"   standard_name=""                                                        />
+<!-- TO FIX
+          <field field_ref="ketrd_ldf_vsum"     name="dispkexyfo"   standard_name="Dissipation of kinetic energy by lateral viscosity" grid_ref="vert_sum"/>
+-->
+          <field field_ref="tosmint"       name="opottempmint" />
+          <field field_ref="somint"       name="somint" />
+<!-- TO FIX
+          <field field_ref="toce_e3t_300" name="T300m" />
+          <field field_ref="e3t_300" name="e3t300m" />
+          <field field_ref="toce_e3t_vsum300" name="Tsum300m" />
+          <field field_ref="e3t_vsum300" name="e3t_vsum300m" />
+-->
+          <field field_ref="sbs_abs" name="sob_abs" />
+          <field field_ref="bn2" name="obvfsq" />
+<!-- trend diagnostics-->
+          <field field_ref="ttrd_totad_li"   name="opottempadvect"  unit="W/m2"    />
+          <field field_ref="ttrd_iso_li"     name="opottemppmdiff"  unit="W/m2"    />
+          <field field_ref="ttrd_zdfp_li"    name="opottempdiff"    unit="W/m2"    />
+          <field field_ref="ttrd_evd_li"     name="ttrd_evd_li"                    />
+          <field field_ref="ttrd_qns_li"     name="ttrd_qns_li"                    />
+          <field field_ref="ttrd_qsr_li"     name="rsdoabsorb"      unit="W/m2"    />
+          <field field_ref="ttrd_bbl_li"     name="ttrd_bbl_li"                    />
+          <field field_ref="ttrd_atf_li"     name="ttrd_atf_li"                    />
+          <field field_ref="ttrd_tot_li"     name="opottemptend"    unit="W/m2"    />
+          <field field_ref="strd_totad_li"   name="osaltadvect"     unit="Kg/m2/s" />
+          <field field_ref="strd_iso_li"     name="osaltpmdiff"     unit="kg/m2/s" />
+          <field field_ref="strd_zdfp_li"    name="osaltdiff"       unit="kg/m2/s" />
+          <field field_ref="strd_evd_li"     name="strd_evd_li"                    />
+          <field field_ref="strd_tot_li"     name="osalttend"       unit="kg/m2/s" />
+          <field field_ref="strd_bbl_li"     name="strd_bbl_li"                    />
+          <field field_ref="strd_atf_li"     name="strd_atf_li"                    />
+	</file>
+	
+	<file id="file5" name_suffix="_grid_U" description="ocean U grid variables" >
+          <field field_ref="e3u"          name="thkcello"     standard_name="cell_thickness" />
+          <field field_ref="uoce"         name="uo"     operation="average" freq_op="1mo"  cell_methods="time: mean (thickness weighted)" > @uoce_e3u / @e3u </field>
+	  <field field_ref="utau"         name="tauuo"   standard_name="surface_downward_x_stress"  />
+          <field field_ref="ut"           name="uto" standard_name="product_of_xward_sea_water_velocity_and_temperature" long_name="UT"  operation="average" freq_op="1mo" cell_methods="time: mean (thickness weighted)" > @ut_e3u / @e3u </field>
+          <field field_ref="us"           name="uso" standard_name="product_of_xward_sea_water_velocity_and_salinity" long_name="US"    operation="average" freq_op="1mo"  cell_methods="time: mean (thickness weighted)"> @us_e3u / @e3u </field>
+          <field field_ref="uoce"         name="u2o" standard_name="square_of_sea_water_x_velocity" long_name="UU"  operation="average" freq_op="1mo"  cell_methods="time: mean (thickness weighted)"> @uoce2_e3u / @e3u </field>
+          <!-- available with key_diaar5 -->
+          <field field_ref="u_masstr"     name="umo" /> 
+          <field field_ref="u_masstr_vint"     name="umo_vint" /> 
+          <field field_ref="u_heattr"     name="hfx" > @uadv_heattr + @udiff_heattr </field> 
+          <field field_ref="uadv_heattr"     name="hfx_adv" /> 
+          <field field_ref="udiff_heattr"     name="hfx_diff" /> 
+<!--below here not in CMOR format yet -->
+          <field field_ref="u_salttr"     name="sozosatr" />
+	</file>
+	
+	<file id="file6" name_suffix="_grid_V" description="ocean V grid variables" >
+          <field field_ref="e3v"          name="thkcello"        standard_name="cell_thickness" />
+          <field field_ref="voce"         name="vo"     operation="average" freq_op="1mo" cell_methods="time: mean (thickness weighted)" > @voce_e3v / @e3v </field>
+	  <field field_ref="vtau"         name="tauvo"   standard_name="surface_downward_y_stress" />
+          <field field_ref="vt"           name="vto" standard_name="product_of_yward_sea_water_velocity_and_temperature" long_name="VT"  operation="average" freq_op="1mo" cell_methods="time: mean (thickness weighted)" > @vt_e3v / @e3v </field>
+          <field field_ref="vs"           name="vso" standard_name="product_of_yward_sea_water_velocity_and_salinity" long_name="VS"  operation="average" freq_op="1mo" cell_methods="time: mean (thickness weighted)" > @vs_e3v / @e3v </field>
+          <field field_ref="voce"         name="v2o" standard_name="square_of_sea_water_y_velocity" long_name="VV"  operation="average" freq_op="1mo" cell_methods="time: mean (thickness weighted)" > @voce2_e3v / @e3v </field>
+          <!-- available with key_diaar5 -->
+          <field field_ref="v_masstr"     name="vmo" /> 
+          <field field_ref="v_heattr"     name="hfy" > @vadv_heattr + @vdiff_heattr </field>
+          <field field_ref="vadv_heattr"     name="hfy_adv" /> 
+          <field field_ref="vdiff_heattr"     name="hfy_diff" /> 
+<!--below here not in CMOR format yet -->
+          <field field_ref="v_salttr"     name="somesatr" />
+	</file>
+	
+	<file id="file7" name_suffix="_grid_W" description="ocean W grid variables" >
+	  <field field_ref="avt"          name="difvho"   standard_name="ocean_vertical_heat_diffusivity"  />
+	  <field field_ref="avs"          name="difvso"   standard_name="ocean_vertical_salt_diffusivity"   />                 
+          <field field_ref="avm"          name="difvmo"   standard_name="ocean_vertical_momentum_diffusivity"               />
+          <field field_ref="avt_evd"      name="avt_evd"  standard_name="enhanced_vertical_heat_diffusivity"               />
+          <field field_ref="av_tmx"       name="diftrto"  standard_name="ocean_vertical_tracer_diffusivity_due_to_tides"               />
+          <field field_ref="w_masstr"     name="wmo" > w_masstr </field>
+	  <field field_ref="woce"         name="wo" standard_name="upward_sea_water_velocity" long_name="W"                  />
+          <field field_ref="woce"         name="w2o" standard_name="square_of_upward_sea_water_velocity" long_name="WW"  operation="average" > woce * woce </field>
+          <field field_ref="wt"           name="wt"         standard_name="product_of_upward_sea_water_velocity_and_temperature" long_name="WT"         />
+          <field field_ref="ws"           name="ws"         standard_name="product_of_upward_sea_water_velocity_and_salinity" long_name="WS"            />
+<!-- TO FIX
+          <field field_ref="wpt_dep"      name="zhalf"        />
+-->
+	</file>
+	
+        <file id="file8" name_suffix="_scalar" description="scalar variables" enabled=".true." >
+          <field field_ref="voltot"       name="scvoltot"   />
+          <field field_ref="temptot"      name="thetaoga"   cell_methods="time: mean (volume weighted)"   />
+          <field field_ref="saltot"       name="soga"       cell_methods="time: mean (volume weighted)"   />
+        </file>
+
+        <file id="file10" name_suffix="_diaptr" description="processed diagnostics" >
+          <field field_ref="zomsfglo"     name="zomsfglo"   standard_name="meridional_streamfunction_global"           grid_ref="gznl_W_3D"       />
+          <field field_ref="zotemglo"     name="zotemglo"   standard_name="zonal_mean_temperature_global"              grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfglo"     name="zosrfglo"   standard_name="zonal_mean_surface_global"                  grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalglo"     name="zosalglo"   standard_name="zonal_mean_salinity_global"                 grid_ref="gznl_T_3D"       />          
+          <field field_ref="zomsfatl"     name="zomsfatl"   standard_name="meridional_streamfunction_atlantic"         grid_ref="gznl_W_3D"       />
+          <field field_ref="zotematl"     name="zotematl"   standard_name="zonal_mean_temperature_atlantic"            grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfatl"     name="zosrfatl"   standard_name="zonal_mean_surface_atlantic"                grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalatl"     name="zosalatl"   standard_name="zonal_mean_salinity_atlantic"               grid_ref="gznl_T_3D"       />          
+          <field field_ref="zomsfpac"     name="zomsfpac"   standard_name="meridional_streamfunction_pacific"          grid_ref="gznl_W_3D"       />
+          <field field_ref="zotempac"     name="zotempac"   standard_name="zonal_mean_temperature_pacific"             grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfpac"     name="zosrfpac"   standard_name="zonal_mean_surface_pacific"                 grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalpac"     name="zosalpac"   standard_name="zonal_mean_salinity_pacific"                grid_ref="gznl_T_3D"       />
+          <field field_ref="zomsfind"     name="zomsfind"   standard_name="meridional_streamfunction_indian"           grid_ref="gznl_W_3D"       />
+          <field field_ref="zotemind"     name="zotemind"   standard_name="zonal_mean_temperature_indian"              grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfind"     name="zosrfind"   standard_name="zonal_mean_surface_indian"                  grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalind"     name="zosalind"   standard_name="zonal_mean_salinity_indian"                 grid_ref="gznl_T_3D"       />          
+          <field field_ref="zomsfipc"     name="zomsfipc"   standard_name="meridional_streamfunction_indian_pacific"   grid_ref="gznl_W_3D"       />
+          <field field_ref="zotemipc"     name="zotemipc"   standard_name="zonal_mean_temperature_indian_pacific"      grid_ref="gznl_T_3D"       />
+          <field field_ref="zosrfipc"     name="zosrfipc"   standard_name="zonal_mean_surface_indian_pacific"          grid_ref="gznl_T_3D"       />
+          <field field_ref="zosalipc"     name="zosalipc"   standard_name="zonal_mean_salinity_indian_pacific"         grid_ref="gznl_T_3D"       />          
+          <field field_ref="sophtadv"     name="sophtadv"   standard_name="advective_heat_transport"                   grid_ref="gznl_T_2D"       />
+          <field field_ref="sophtadv_atl"    name="sophtadv_atlantic"   standard_name="advective_heat_transport_atlantic"/>
+          <field field_ref="sophtadv_pac"    name="sophtadv_pacific"   standard_name="advective_heat_transport_pacific" />
+          <field field_ref="sophtadv_ind"    name="sophtadv_indian"   standard_name="advective_heat_transport_indian"   />
+          <field field_ref="sophtadv_ipc"    name="sophtadv_ipc"   standard_name="advective_heat_transport_indopacific"  />
+          <field field_ref="sophtbtr"     name="hfovbaro"   standard_name="barotropic_heat_transport"                   grid_ref="gznl_T_2D"       />
+          <field field_ref="sophtbtr_atl"    name="hfovbaro_atlantic"   standard_name="barotropic_heat_transport_atlantic"/>
+          <field field_ref="sophtbtr_pac"    name="hfovbaro_pacific"   standard_name="barotropic_heat_transport_pacific" />
+          <field field_ref="sophtbtr_ind"    name="hfovbaro_indian"   standard_name="barotropic_heat_transport_indian"   />
+          <field field_ref="sophtbtr_ipc"    name="hfovbaro_ipc"   standard_name="barotropic_heat_transport_indopacific"  />
+          <field field_ref="sopstadv"     name="sopstadv"   standard_name="advective_salt_transport"                   grid_ref="gznl_T_2D"       />
+          <field field_ref="sopstadv_atl"    name="sopstadv_atlantic"   standard_name="advective_salt_transport_atlantic"/>
+          <field field_ref="sopstadv_pac"    name="sopstadv_pacific"   standard_name="advective_salt_transport_pacific" />
+          <field field_ref="sopstadv_ind"    name="sopstadv_indian"   standard_name="advective_salt_transport_indian"   />
+          <field field_ref="sopstadv_ipc"    name="sopstadv_ipc"   standard_name="advective_salt_transport_indopacific"  />
+          <field field_ref="sopstbtr"     name="sltovbaro"   standard_name="barotropic_salt_transport"     />
+          <field field_ref="sopstbtr_atl"    name="sltovbaro_atlantic"   standard_name="barotropic_salt_transport_atlantic"/>
+          <field field_ref="sopstbtr_pac"    name="sltovbaro_pacific"   standard_name="barotropic_salt_transport_pacific" />
+          <field field_ref="sopstbtr_ind"    name="sltovbaro_indian"   standard_name="barotropic_salt_transport_indian"   />
+          <field field_ref="sopstbtr_ipc"    name="sltovbaro_ipc"   standard_name="barotropic_salt_transport_indopacific"  />
+          <!--The following variables are to be merged into a single variableis with a basin dimenesion in postprocessing  -->
+          <!-- hfbasin -->
+          <field field_ref="sophtadv" name="hfbasin_global" standard_name="northward_ocean_heat_transport" > @sophtadv + @sophtldf </field>
+          <field field_ref="sophtadv" name="hfbasin_atlantic" standard_name="northward_ocean_heat_transport" > @sophtadv_atl + @sophtldf_atl </field>
+          <field field_ref="sophtadv" name="hfbasin_pacific" standard_name="northward_ocean_heat_transport" > @sophtadv_pac + @sophtldf_pac </field>
+          <field field_ref="sophtadv" name="hfbasin_indian" standard_name="northward_ocean_heat_transport" > @sophtadv_ind + @sophtldf_ind </field>
+          <field field_ref="sophtadv" name="hfbasin_indopacific" standard_name="northward_ocean_heat_transport" > @sophtadv_ipc + @sophtldf_ipc </field>
+          <!-- hfbasinpadv -->
+          <field field_ref="sophteiv"     name="hfbasinpadv_global"   standard_name="bolus_heat_transport"                       grid_ref="gznl_T_2D"       />
+          <field field_ref="sophteiv_atl"    name="hfbasinpadv_atlantic"   standard_name="bolus_heat_transport_atlantic"/>
+          <field field_ref="sophteiv_pac"    name="hfbasinpadv_pacific"   standard_name="bolus_heat_transport_pacific" />
+          <field field_ref="sophteiv_ind"    name="hfbasinpadv_indian"   standard_name="bolus_heat_transport_indian"   />
+          <field field_ref="sophteiv_ipc"    name="hfbasinpadv_indopacific"   standard_name="bolus_heat_transport_indopacific"   />
+          <!-- hfbasinpmadv -->
+          <field field_ref="sophteiv"     name="hfbasinpmadv_global"   standard_name="bolus_heat_transport"                       grid_ref="gznl_T_2D"       />
+          <field field_ref="sophteiv_atl"    name="hfbasinpmadv_atlantic"   standard_name="bolus_heat_transport_atlantic"/>
+          <field field_ref="sophteiv_pac"    name="hfbasinpmadv_pacific"   standard_name="bolus_heat_transport_pacific" />
+          <field field_ref="sophteiv_ind"    name="hfbasinpmadv_indian"   standard_name="bolus_heat_transport_indian"   />
+          <field field_ref="sophteiv_ipc"    name="hfbasinpmadv_indopacific"   standard_name="bolus_heat_transport_indopacific"   />
+          <!-- hfbasinpmdiff -->
+          <field field_ref="sophtldf"     name="hfbasinpmdiff_global"   standard_name="diffusive_transport"                       grid_ref="gznl_T_2D"       />
+          <field field_ref="sophtldf_atl"    name="hfbasinpmdiff_atlantic"   standard_name="diffusive_transport_atlantic"/>
+          <field field_ref="sophtldf_pac"    name="hfbasinpmdiff_pacific"   standard_name="diffusive_transport_pacific" />
+          <field field_ref="sophtldf_ind"    name="hfbasinpmdiff_indian"   standard_name="diffusive_transport_indian"   />
+          <field field_ref="sophtldf_ipc"    name="hfbasinpmdiff_indopacific"   standard_name="diffusive_transport_indopacific"   />
+          <!-- hfovovrt -->
+          <field field_ref="sophtove"     name="hfovovrt_global"   standard_name="overturning_heat_transport"                   grid_ref="gznl_T_2D"       />
+          <field field_ref="sophtove_atl"    name="hfovovrt_atlantic"   standard_name="overturning_heat_transport_atlantic"/>
+          <field field_ref="sophtove_pac"    name="hfovovrt_pacific"   standard_name="overturning_heat_transport_pacific" />
+          <field field_ref="sophtove_ind"    name="hfovovrt_indian"   standard_name="overturning_heat_transport_indian"   />
+          <field field_ref="sophtove_ipc"    name="hfovovrt_indopacific"   standard_name="overturning_heat_transport_indopacific"   />
+          <!-- hfovgyre IS THIS DONE CORRECTLY? SHOULD WE ALSO SUBTRACT THE BAROTROPIC TERM? The CMIP6 data request says not to so leave it for now-->
+          <field field_ref="sophtove"     name="hfovgyre_global"   standard_name="gyre_heat_transport"         > @sophtadv - @sophtove </field>
+          <field field_ref="sophtove_atl"    name="hfovgyre_atlantic"   standard_name="gyre_heat_transport_atlantic" > @sophtadv_atl - @sophtove_atl </field>
+          <field field_ref="sophtove_pac"    name="hfovgyre_pacific"   standard_name="gyre_heat_transport_pacific"  > @sophtadv_pac - @sophtove_pac </field>
+          <field field_ref="sophtove_ind"    name="hfovgyre_indian"   standard_name="gyre_heat_transport_indian"   > @sophtadv_ind - @sophtove_ind </field>
+          <field field_ref="sophtove_ipc"    name="hfovgyre_indopacific"   standard_name="gyre_heat_transport_indopacific"   > @sophtadv_ipc - @sophtove_ipc </field>
+          <!-- sltbasin -->
+          <field field_ref="sopstadv" name="sltbasin_global" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv + @sopstldf)/1000 </field>
+          <field field_ref="sopstadv" name="sltbasin_atlantic" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv_atl + @sopstldf_atl)/1000 </field>
+          <field field_ref="sopstadv" name="sltbasin_pacific" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv_pac + @sopstldf_pac)/1000 </field>
+          <field field_ref="sopstadv" name="sltbasin_indian" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv_ind + @sopstldf_ind)/1000 </field>
+          <field field_ref="sopstadv" name="sltbasin_indopacific" standard_name="northward_ocean_heat_transport" unit="kg s-1"> (@sopstadv_ipc + @sopstldf_ipc)/1000 </field>
+          <!-- sltbasinpadv -->
+          <field field_ref="sopsteiv"        name="sltbasinpadv_global"   standard_name="bolus_salt_transport"  unit="kg s-1"> @sopsteiv/1000   </field>
+          <field field_ref="sopsteiv_atl"    name="sltbasinpadv_atlantic"   standard_name="bolus_salt_transport_atlantic" unit="kg s-1"> @sopsteiv_atl/1000   </field>
+          <field field_ref="sopsteiv_pac"    name="sltbasinpadv_pacific"   standard_name="bolus_salt_transport_pacific" unit="kg s-1"> @sopsteiv_pac/1000   </field>
+          <field field_ref="sopsteiv_ind"    name="sltbasinpadv_indian"   standard_name="bolus_salt_transport_indian"  unit="kg s-1"> @sopsteiv_ind/1000   </field>
+          <field field_ref="sopsteiv_ipc"    name="sltbasinpadv_indopacific"   standard_name="bolus_salt_transport_indopacific"  unit="kg s-1"> @sopsteiv_ipc/1000   </field>
+          <!-- sltbasinpmadv -->
+          <field field_ref="sopsteiv"        name="sltbasinpmadv_global"   standard_name="bolus_salt_transport"  unit="kg s-1"> @sopsteiv/1000   </field>        
+          <field field_ref="sopsteiv_atl"    name="sltbasinpmadv_atlantic"   standard_name="bolus_salt_transport_atlantic" unit="kg s-1"> @sopsteiv_atl/1000   </field>
+          <field field_ref="sopsteiv_pac"    name="sltbasinpmadv_pacific"   standard_name="bolus_salt_transport_pacific" unit="kg s-1"> @sopsteiv_pac/1000   </field>
+          <field field_ref="sopsteiv_ind"    name="sltbasinpmadv_indian"   standard_name="bolus_salt_transport_indian"  unit="kg s-1"> @sopsteiv_ind/1000   </field>
+          <field field_ref="sopsteiv_ipc"    name="sltbasinpmadv_indopacific"   standard_name="bolus_salt_transport_indopacific"  unit="kg s-1"> @sopsteiv_ipc/1000   </field>
+          <!-- sltbasinpmdiff -->
+          <field field_ref="sopstldf"     name="sltbasinpmdiff_global"   standard_name="diffusive_transport" unit="kg s-1">   @sopstldf/1000   </field>
+          <field field_ref="sopstldf_atl"    name="sltbasinpmdiff_atlantic"   standard_name="diffusive_transport_atlantic" unit="kg s-1"> @sopstldf_atl/1000   </field>
+          <field field_ref="sopstldf_pac"    name="sltbasinpmdiff_pacific"   standard_name="diffusive_transport_pacific" unit="kg s-1"> @sopstldf_pac/1000   </field>
+          <field field_ref="sopstldf_ind"    name="sltbasinpmdiff_indian"   standard_name="diffusive_transport_indian" unit="kg s-1">  @sopstldf_ind/1000   </field>
+          <field field_ref="sopstldf_ipc"    name="sltbasinpmdiff_indopacific"   standard_name="diffusive_transport_indopacific" unit="kg s-1">  @sopstldf_ipc/1000   </field>
+          <!-- sltovovrt -->
+          <field field_ref="sopstove"     name="sltovovrt_global"   standard_name="overturning_salt_transport"  unit="kg s-1">   @sopstove/1000   </field>       
+          <field field_ref="sopstove_atl"    name="sltovovrt_atlantic"   standard_name="overturning_salt_transport_atlantic" unit="kg s-1">   @sopstove_atl/1000   </field>
+          <field field_ref="sopstove_pac"    name="sltovovrt_pacific"   standard_name="overturning_salt_transport_pacific"  unit="kg s-1">   @sopstove_pac/1000   </field>
+          <field field_ref="sopstove_ipc"    name="sltovovrt_indopacific"   standard_name="overturning_salt_transport_indopacific"   unit="kg s-1">   @sopstove_ipc/1000   </field>
+          <!-- sltovgyre IS THIS DONE CORRECTLY? SHOULD WE ALSO SUBTRACT THE BAROTROPIC TERM?-->
+          <field field_ref="sopstove"     name="sltovgyre_global"   standard_name="gyre_salt_transport"    unit="kg s-1" > (@sopstadv - @sopstove)/1000 </field>
+          <field field_ref="sopstove_atl"    name="sltovgyre_atlantic"   standard_name="gyre_salt_transport_atlantic" unit="kg s-1" > (@sopstadv_atl - @sopstove_atl)/1000 </field>
+          <field field_ref="sopstove_pac"    name="sltovgyre_pacific"   standard_name="gyre_salt_transport_pacific" unit="kg s-1"  > (@sopstadv_pac - @sopstove_pac)/1000 </field>
+          <field field_ref="sopstove_ind"    name="sltovgyre_indian"   standard_name="gyre_salt_transport_indian" unit="kg s-1"   > (@sopstadv_ind - @sopstove_ind)/1000 </field>
+          <field field_ref="sopstove_ipc"    name="sltovgyre_indopacific"   standard_name="gyre_salt_transport_ipc" unit="kg s-1"   > (@sopstadv_ipc - @sopstove_ipc)/1000 </field>
+        </file>
+
+      </file_group>
+
+      <file_group id="2m" output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m" output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m" output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m" output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+
+
+      <file_group id="2y"  output_freq="2y" output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y" output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+   </file_definition>
+    
+
+
+
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-CMIP6-INVALID_PERIOD.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-CMIP6-INVALID_PERIOD.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/file_def_nemo-oce-CMIP6-INVALID_PERIOD.xml	(revision 14671)
@@ -0,0 +1,4 @@
+You can't use the standard diagnostic options with the current cycling period.
+Choose the "Custom" option, copy the file_def*.xml files that
+you want to use into the Rose app and adjust the meaning period
+accordingly. 
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/iodef.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/iodef.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/iodef.xml	(revision 14671)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<simulation> 
+
+<!-- ============================================================================================ -->
+<!-- XIOS context                                                                                 -->
+<!-- ============================================================================================ -->
+
+  <context id="xios" >
+
+      <variable_definition>
+	
+	  <variable id="info_level"                type="int">-1</variable>
+	  <variable id="using_server"              type="bool">true</variable>
+	  <variable id="using_oasis"               type="bool">false</variable>
+	  <variable id="oasis_codes_id"            type="string" >oceanx</variable>
+	
+      </variable_definition>
+  </context>
+
+<!-- ============================================================================================ -->
+<!-- NEMO  CONTEXT add and suppress the components you need                                       -->
+<!-- ============================================================================================ -->
+
+  <context id="nemo" src="./context_nemo.xml"/>       <!--  NEMO       -->
+
+</simulation>
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/iodef_coupled.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/iodef_coupled.xml	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/METO_GO/EXPREF/iodef_coupled.xml	(revision 14671)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<simulation> 
+
+<!-- ============================================================================================ -->
+<!-- XIOS context                                                                                 -->
+<!-- ============================================================================================ -->
+
+  <context id="xios" >
+
+      <variable_definition>
+	
+	  <variable id="info_level"                type="int">-1</variable>
+	  <variable id="using_server"              type="bool">true</variable>
+	  <variable id="using_oasis"               type="bool">true</variable>
+	  <variable id="oasis_codes_id"            type="string" >toyoce</variable>
+	
+      </variable_definition>
+  </context>
+
+<!-- ============================================================================================ -->
+<!-- NEMO  CONTEXT add and suppress the components you need                                       -->
+<!-- ============================================================================================ -->
+
+  <context id="nemo" src="./context_nemo.xml"/>       <!--  NEMO       -->
+
+</simulation>
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-ice.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-ice.xml	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-ice.xml	(revision 14671)
@@ -28,7 +28,7 @@
        <field field_ref="iceapnd"          name="siapnd" />
        <field field_ref="icevpnd"          name="sivpnd" />
-       <field field_ref="sst_m"            name="sst_m"  />
-       <field field_ref="sss_m"            name="sss_m"  />
-       
+       <field field_ref="sst_m_pot"        name="sst_m_pot"  />
+       <field field_ref="sss_m_abs"        name="sss_m_abs"  />
+
        <!-- heat -->
        <field field_ref="icetemp"          name="sitemp" />
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-oce.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-oce.xml	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-oce.xml	(revision 14671)
@@ -14,12 +14,12 @@
         <file id="file11" name_suffix="_grid_T" description="ocean T grid variables" >
           <field field_ref="e3t"      />
-          <field field_ref="toce"         name="thetao"                                                                      operation="instant" freq_op="5d" > @toce_e3t / @e3t </field>
-          <field field_ref="soce"         name="so"                                                                          operation="instant" freq_op="5d" > @soce_e3t / @e3t </field>
-          <field field_ref="sst"          name="tos"   />
-          <field field_ref="sss"          name="sos"   />
+          <field field_ref="toce_con"         name="thetao_con"                                                                      operation="instant" freq_op="5d" > @toce_con_e3t / @e3t </field>
+          <field field_ref="soce_abs"         name="so_abs"                                                                          operation="instant" freq_op="5d" > @soce_abs_e3t / @e3t </field>
+          <field field_ref="sst_con"          name="tos_con"   />
+          <field field_ref="sss_abs"          name="sos_abs"   />
           <field field_ref="ssh"          name="zos"   />
-          <field field_ref="sst"          name="tosstd"       long_name="sea surface temperature standard deviation"         operation="instant" freq_op="5d" > sqrt( @sst2 - @sst * @sst ) </field>
+          <field field_ref="sst_con"          name="tosstd_con"       long_name="sea surface temperature standard deviation"         operation="instant" freq_op="5d" > sqrt( @sst2_con - @sst_con * @sst_con ) </field>
           <field field_ref="ssh"          name="zosstd"       long_name="sea surface height above geoid standard deviation"  operation="instant" freq_op="5d" > sqrt( @ssh2 - @ssh * @ssh ) </field>
-          <field field_ref="sst"          name="sstdcy"       long_name="amplitude of sst diurnal cycle"                     operation="average" freq_op="1d" > @sstmax - @sstmin </field>
+          <field field_ref="sst_con"          name="sstdcy_con"       long_name="amplitude of sst diurnal cycle"                     operation="average" freq_op="1d" > @sstmax_con - @sstmin_con </field>
           <field field_ref="mldkz5"   />
           <field field_ref="mldr10_1" />
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/ORCA2_SAS_ICE/EXPREF/file_def_nemo-ice.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/ORCA2_SAS_ICE/EXPREF/file_def_nemo-ice.xml	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/ORCA2_SAS_ICE/EXPREF/file_def_nemo-ice.xml	(revision 14671)
@@ -28,4 +28,5 @@
        <field field_ref="iceapnd"          name="siapnd" />
        <field field_ref="icevpnd"          name="sivpnd" />
+       <field field_ref="icevlid"          name="sivlid" />
        <field field_ref="sst_m"            name="sst_m"  />
        <field field_ref="sss_m"            name="sss_m"  />
@@ -36,4 +37,10 @@
        <field field_ref="icetbot"          name="sitbot" />
        <field field_ref="icetsni"          name="sitsni" />
+
+       <!-- ponds -->
+       <field field_ref="dvpn_mlt"         name="dvpn_mlt" />
+       <field field_ref="dvpn_lid"         name="dvpn_lid" />
+       <field field_ref="dvpn_rnf"         name="dvpn_rnf" />
+       <field field_ref="dvpn_drn"         name="dvpn_drn" />
        
        <!-- momentum -->
@@ -85,4 +92,6 @@
        <field field_ref="icesalt_cat"      name="sisalcat"/>
        <field field_ref="icetemp_cat"      name="sitemcat"/>
+       <field field_ref="iceapnd_cat"      name="siapncat"/>
+       <field field_ref="icevpnd_cat"      name="sivpncat"/>
        
      </file>
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/domain_def_nemo.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/domain_def_nemo.xml	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/domain_def_nemo.xml	(revision 14671)
@@ -181,11 +181,12 @@
      <domain id="EqW" domain_ref="grid_W" > <zoom_domain id="EqW"/> </domain>
 
-	           <!--   zonal mean grid   -->
-     <domain_group id="gznl">
-        <domain id="gznl" long_name="gznl"/>
-        <domain id="ptr" domain_ref="gznl" > 
-            <zoom_domain id="ptr" ibegin="0000" jbegin="0" ni="1" nj="0000" /> 
-        </domain>
-      </domain_group>
+     
+     <!--   zonal mean grid   -->
+     <domain id="gznl" long_name="gznl"/>
+     <domain id="ptr" domain_ref="gznl" >
+	 <zoom_domain id="ptr" ibegin="0000" jbegin="0" ni="1" nj="0000" />
+     </domain>  
+     <domain id="znl_T" domain_ref="gznl" > <zoom_domain id="znl_T"/> </domain>
+     <domain id="znl_W" domain_ref="gznl" > <zoom_domain id="znl_W"/> </domain>
 
      
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/field_def_nemo-ice.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/field_def_nemo-ice.xml	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/field_def_nemo-ice.xml	(revision 14671)
@@ -44,11 +44,17 @@
           <field id="icefrb"       long_name="Sea-ice freeboard"                                       standard_name="sea_ice_freeboard"                         unit="m"    />
           <field id="icealb"       long_name="Sea-ice or snow albedo"                                  standard_name="sea_ice_albedo"                            unit=""    detect_missing_value="true" />
-	  
-	  <!-- melt ponds -->
-	  <field id="iceapnd"      long_name="melt pond concentration"                                 standard_name="sea_ice_meltpond_concentration"            unit=""  /> 
+
+          <!-- melt ponds -->
+          <field id="iceapnd"      long_name="melt pond concentration"                                 standard_name="sea_ice_meltpond_concentration"            unit=""  /> 
           <field id="icehpnd"      long_name="melt pond depth"                                         standard_name="sea_ice_meltpond_depth"                    unit="m" /> 
           <field id="icevpnd"      long_name="melt pond volume"                                        standard_name="sea_ice_meltpond_volume"                   unit="m" /> 
+          <field id="iceepnd"      long_name="melt pond effective concentration"                       standard_name="sea_ice_meltpond_effective_concentration"            unit=""  />  
           <field id="icehlid"      long_name="melt pond lid depth"                                     standard_name="sea_ice_meltpondlid_depth"                 unit="m" /> 
           <field id="icevlid"      long_name="melt pond lid volume"                                    standard_name="sea_ice_meltpondlid_volume"                unit="m" /> 
+	  
+	  <field id="dvpn_mlt"     long_name="pond volume tendency due to surface melt"                standard_name="sea_ice_pondvolume_tendency_melt"          unit="cm/d" /> 
+	  <field id="dvpn_lid"     long_name="pond volume tendency due to exchanges with lid"          standard_name="sea_ice_pondvolume_tendency_lids"          unit="cm/d" /> 
+	  <field id="dvpn_rnf"     long_name="pond volume tendency due to runoff"                      standard_name="sea_ice_pondvolume_tendency_runoff"        unit="cm/d" /> 
+	  <field id="dvpn_drn"     long_name="pond volume tendency due to drainage"                    standard_name="sea_ice_pondvolume_tendency_drainage"      unit="cm/d" /> 
 	  
 	  <!-- heat -->
@@ -169,6 +175,10 @@
 
 	  <!-- sbcssm variables -->
-          <field id="sst_m"    unit="degC" />
-          <field id="sss_m"    unit="psu"  />
+          <field id="sst_m_pot"    unit="degC" />
+	  <!-- EOS-80 -->
+          <field id="sss_m_pra"    unit="psu"  />
+          <!-- TEOS-10 -->
+          <field id="sss_m_abs"    unit="psu"  />
+
           <field id="ssu_m"    unit="m/s"  />
           <field id="ssv_m"    unit="m/s"  />
@@ -218,5 +228,5 @@
           <field id="dmisum"       long_name="sea-ice mass change through surface melting"             standard_name="tendency_of_sea_ice_amount_due_to_surface_melting"                       unit="kg/m2/s" />
           <field id="dmibom"       long_name="sea-ice mass change through bottom melting"              standard_name="tendency_of_sea_ice_amount_due_to_basal_melting"                         unit="kg/m2/s" />
-          <field id="dmilam"       long_name="sea-ice mass change through lateral melting"             standard_name="tendency_of_sea_ice_amount_due_to_lateral_melting"                       unit="kg/m2/s" />
+	  <field id="dmilam"       long_name="sea-ice mass change through lateral melting"             standard_name="tendency_of_sea_ice_amount_due_to_lateral_melting"                       unit="kg/m2/s" />
           <field id="dmsspr"       long_name="snow mass change through snow fall"                      standard_name="snowfall_flux"                                                           unit="kg/m2/s" />
           <field id="dmsmel"       long_name="snow mass change through melt"                           standard_name="surface_snow_melt_flux"                                                  unit="kg/m2/s" />
@@ -250,35 +260,20 @@
          <field id="xmtrpice_ave"     long_name="Monthly average of x-ice mass transport"   field_ref="xmtrpice"          grid_ref="grid_U_2D"        freq_op="1mo" freq_offset="_reset_"  > @xmtrpice </field>
          <field id="xmtrpice_section"                                                                                     grid_ref="grid_U_scalar"  > xmtrpice_ave </field>
-         <field id="xmtrpice_strait"                                                        field_ref="xmtrpice_section"  grid_ref="grid_U_4strait_ice"  />
-         <field id="xstrait_mifl"                                                           field_ref="xmtrpice_strait"   grid_ref="grid_U_4strait_ice_hsum" unit="kg/s" detect_missing_value="true" > this * maskMFO_u_ice </field>
 
          <field id="ymtrpice_ave"     long_name="Monthly average of y-ice mass transport"   field_ref="ymtrpice"          grid_ref="grid_V_2D"        freq_op="1mo" freq_offset="_reset_"  > @ymtrpice </field>
          <field id="ymtrpice_section"                                                                                     grid_ref="grid_V_scalar"  > ymtrpice_ave </field>
-         <field id="ymtrpice_strait"                                                        field_ref="ymtrpice_section"  grid_ref="grid_V_4strait_ice"  />
-	 <field id="ystrait_mifl"                                                           field_ref="ymtrpice_strait"   grid_ref="grid_V_4strait_ice_hsum" unit="kg/s" detect_missing_value="true"  > this * maskMFO_v_ice </field>
 
          <field id="xmtrpsnw_ave"     long_name="Monthly average of x-snow mass transport"  field_ref="xmtrpsnw"          grid_ref="grid_U_2D"        freq_op="1mo" freq_offset="_reset_"  > @xmtrpsnw </field>
          <field id="xmtrpsnw_section"                                                                                     grid_ref="grid_U_scalar"  > xmtrpsnw_ave </field>
-         <field id="xmtrpsnw_strait"                                                        field_ref="xmtrpsnw_section"  grid_ref="grid_U_4strait_ice"  />
-         <field id="xstrait_msfl"                                                           field_ref="xmtrpsnw_strait"   grid_ref="grid_U_4strait_ice_hsum" unit="kg/s" detect_missing_value="true" > this * maskMFO_u_ice </field>
 
          <field id="ymtrpsnw_ave"     long_name="Monthly average of y-snow mass transport"  field_ref="ymtrpsnw"          grid_ref="grid_V_2D"        freq_op="1mo" freq_offset="_reset_"  > @ymtrpsnw </field>
          <field id="ymtrpsnw_section"                                                                                     grid_ref="grid_V_scalar"  > ymtrpsnw_ave </field>
-         <field id="ymtrpsnw_strait"                                                        field_ref="ymtrpsnw_section"  grid_ref="grid_V_4strait_ice"  />
-	 <field id="ystrait_msfl"                                                           field_ref="ymtrpsnw_strait"   grid_ref="grid_V_4strait_ice_hsum" unit="kg/s" detect_missing_value="true"  > this * maskMFO_v_ice </field>
 
          <field id="xatrp_ave"        long_name="Monthly average of x-ice area transport"   field_ref="xatrp"             grid_ref="grid_U_2D"        freq_op="1mo" freq_offset="_reset_"  > @xatrp </field>
          <field id="xatrp_section"                                                                                        grid_ref="grid_U_scalar"  > xatrp_ave </field>
-         <field id="xatrp_strait"                                                           field_ref="xatrp_section"     grid_ref="grid_U_4strait_ice"  />
-         <field id="xstrait_arfl"                                                           field_ref="xatrp_strait"      grid_ref="grid_U_4strait_ice_hsum" unit="kg/s" detect_missing_value="true" > this * maskMFO_u_ice </field>
 
          <field id="yatrp_ave"        long_name="Monthly average of y-ice area transport"   field_ref="yatrp"             grid_ref="grid_V_2D"        freq_op="1mo" freq_offset="_reset_"  > @yatrp </field>
          <field id="yatrp_section"                                                                                        grid_ref="grid_V_scalar"  > yatrp_ave </field>
-         <field id="yatrp_strait"                                                           field_ref="yatrp_section"     grid_ref="grid_V_4strait_ice"  />
-	 <field id="ystrait_arfl"                                                           field_ref="yatrp_strait"      grid_ref="grid_V_4strait_ice_hsum" unit="m2/s" detect_missing_value="true"  > this * maskMFO_v_ice </field>
-
-         <field id="strait_mifl"      long_name="Sea ice mass flux through straits"      standard_name="sea_ice_mass_transport_across_line"   unit="kg/s"  freq_op="1mo"  grid_ref="grid_4strait_ice" > xstrait_mifl + ystrait_mifl </field>
-         <field id="strait_msfl"      long_name="Snow mass flux through straits"         standard_name="snow_mass_transport_across_line"      unit="kg/s"  freq_op="1mo"  grid_ref="grid_4strait_ice" > xstrait_msfl + ystrait_msfl </field>
-	 <field id="strait_arfl"      long_name="Sea ice area flux through straits"      standard_name="sea_area_mass_transport_across_line"  unit="m2/s"  freq_op="1mo"  grid_ref="grid_4strait_ice" > xstrait_arfl + ystrait_arfl </field>
+
 
 	</field_group> <!-- SBC_2D -->
@@ -295,8 +290,9 @@
           <field id="snwtemp_cat"  long_name="Snow temperature per category"                     unit="degC"    detect_missing_value="true" />
           <field id="icettop_cat"  long_name="Ice/snow surface temperature per category"         unit="degC"    detect_missing_value="true" />
-          <field id="iceapnd_cat"  long_name="Ice melt pond concentration per category"          unit=""        /> 
+          <field id="icevpnd_cat"  long_name="Ice melt pond volume per grid area per category"   unit="m"       /> 
+          <field id="iceapnd_cat"  long_name="Ice melt pond grid fraction"                       unit=""        /> 
           <field id="icehpnd_cat"  long_name="Ice melt pond thickness per category"              unit="m"       detect_missing_value="true" /> 
           <field id="icehlid_cat"  long_name="Ice melt pond lid thickness per category"          unit="m"       detect_missing_value="true" /> 
-          <field id="iceafpnd_cat" long_name="Ice melt pond fraction per category"               unit=""        /> 
+          <field id="iceafpnd_cat" long_name="Ice melt pond ice fraction per category"           unit=""        /> 
           <field id="iceaepnd_cat" long_name="Ice melt pond effective fraction per category"     unit=""        /> 
           <field id="icemask_cat"  long_name="Fraction of time step with sea ice (per category)" unit=""        />
@@ -375,7 +371,11 @@
 	  <field field_ref="icehpnd"          name="sihpnd" />
 	  <field field_ref="icevpnd"          name="sivpnd" />
+	  <field field_ref="iceepnd"          name="siepnd" />
           <field field_ref="iceage"           name="siage"  />
-	  <field field_ref="sst_m"            name="sst_m"  />
-	  <field field_ref="sss_m"            name="sss_m"  />
+	  <field id="sst_m_pot"    unit="degC" />
+	  <!-- EOS-80 -->
+	  <field id="sss_m_pra"    unit="psu"  />
+	  <!-- TEOS-10 -->
+          <field id="sss_m_abs"    unit="psu"  />
 	  
 	  <!-- heat -->
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/field_def_nemo-oce.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/field_def_nemo-oce.xml	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/field_def_nemo-oce.xml	(revision 14671)
@@ -19,16 +19,23 @@
       
       <field_group id="grid_T" grid_ref="grid_T_2D" >
-        <field id="e3t"          long_name="T-cell thickness"                    standard_name="cell_thickness"        unit="m"   grid_ref="grid_T_3D" />
-        <field id="e3ts"         long_name="T-cell thickness"   field_ref="e3t"  standard_name="cell_thickness"        unit="m"   grid_ref="grid_T_SFC"/>
-        <field id="e3t_0"        long_name="Initial T-cell thickness"            standard_name="ref_cell_thickness"    unit="m"   grid_ref="grid_T_3D" />
-        <field id="e3tb"         long_name="bottom T-cell thickness"             standard_name="bottom_cell_thickness" unit="m"   grid_ref="grid_T_2D"/> 
+        <field id="e3t"          long_name="T-cell thickness"                    standard_name="cell_thickness"     unit="m"   grid_ref="grid_T_3D" />
+        <field id="e3ts"     long_name="T-cell thickness"   field_ref="e3t"  standard_name="cell_thickness"     unit="m"   grid_ref="grid_T_SFC"/>
+        <field id="e3t_0"        long_name="Initial T-cell thickness"            standard_name="ref_cell_thickness" unit="m"   grid_ref="grid_T_3D" />
+        <field id="e3tb"         long_name="bottom T-cell thickness"             standard_name="bottom_cell_thickness" unit="m"   grid_ref="grid_T_2D"/>
         <field id="e3t_300"      field_ref="e3t"                grid_ref="grid_T_zoom_300"       detect_missing_value="true" />
-        <field id="e3t_vsum300"  field_ref="e3t_300"            grid_ref="grid_T_vsum"   detect_missing_value="true" />
+	<field id="e3t_vsum300"  field_ref="e3t_300"            grid_ref="grid_T_vsum"   detect_missing_value="true" />
 	<field id="masscello"    long_name="Sea Water Mass per unit area"   standard_name="sea_water_mass_per_unit_area"   unit="kg/m2"   grid_ref="grid_T_3D"/>
-        <field id="volcello"     long_name="Ocean Volume"                   standard_name="ocean_volume"   unit="m3"       grid_ref="grid_T_3D"/> 
-        <field id="toce"         long_name="temperature"                         standard_name="sea_water_potential_temperature"   unit="degC"     grid_ref="grid_T_3D"/>
-        <field id="toce_e3t"     long_name="temperature (thickness weighted)"                                                      unit="degC"     grid_ref="grid_T_3D" > toce * e3t </field >
-        <field id="soce"         long_name="salinity"                            standard_name="sea_water_practical_salinity"      unit="1e-3"     grid_ref="grid_T_3D"/>
-        <field id="soce_e3t"     long_name="salinity    (thickness weighted)"                                                      unit="1e-3"     grid_ref="grid_T_3D" > soce * e3t </field >
+        <field id="volcello"     long_name="Ocean Volume"                   standard_name="ocean_volume"   unit="m3"       grid_ref="grid_T_3D"/>
+
+        <!-- EOS80 -->
+        <field id="toce_pot"         long_name="potential temperature"           standard_name="sea_water_potential_temperature"      unit="degC"     grid_ref="grid_T_3D"/>
+        <field id="toce_pot_e3t"     long_name="potential temperature (thickness weighted)"                                           unit="degC"     grid_ref="grid_T_3D" > toce_pot * e3t </field >
+        <field id="soce_pra"         long_name="practical salinity"              standard_name="sea_water_practical_salinity"      unit="1e-3"     grid_ref="grid_T_3D"/>
+        <field id="soce_pra_e3t"     long_name="practical salinity    (thickness weighted)"                                        unit="1e-3"     grid_ref="grid_T_3D" > soce_pra * e3t </field >
+        <!-- TEOS10 -->
+        <field id="toce_con"         long_name="conservative temperature"        standard_name="sea_water_conservative_temperature"   unit="degC"     grid_ref="grid_T_3D"/>
+        <field id="toce_con_e3t"     long_name="conservative temperature (thickness weighted)"                                        unit="degC"     grid_ref="grid_T_3D" > toce_con * e3t </field >  
+        <field id="soce_abs"         long_name="absolute salinity"               standard_name="sea_water_absolute_salinity"       unit="1e-3"     grid_ref="grid_T_3D"/>
+        <field id="soce_abs_e3t"     long_name="absolute salinity    (thickness weighted)"                                         unit="1e-3"     grid_ref="grid_T_3D" > soce_abs * e3t </field >
 
         <field id="toce_e3t_300"      field_ref="toce_e3t"          unit="degree_C"     grid_ref="grid_T_zoom_300"      detect_missing_value="true" />
@@ -49,22 +56,42 @@
 	<field id="ahmt_3d"      long_name=" 3D      t-eddy viscosity coefficient"   unit="m2/s or m4/s"  grid_ref="grid_T_3D"/>
 
-        <field id="sst"          long_name="sea surface temperature"                            standard_name="sea_surface_temperature"             unit="degC"     />
-        <field id="sst2"         long_name="square of sea surface temperature"                  standard_name="square_of_sea_surface_temperature"   unit="degC2"     > sst * sst </field >
-        <field id="sstmax"       long_name="max of sea surface temperature"   field_ref="sst"   operation="maximum"                                                 />
-        <field id="sstmin"       long_name="min of sea surface temperature"   field_ref="sst"   operation="minimum"                                                 />
-        <field id="sstgrad"      long_name="module of sst gradient"                                                                                 unit="degC/m"   />
-        <field id="sstgrad2"     long_name="square of module of sst gradient"                                                                       unit="degC2/m2" />
-        <field id="sbt"          long_name="sea bottom temperature"                                                                                 unit="degC"     />
-        <field id="tosmint"      long_name="vertical integral of temperature times density"     standard_name="integral_wrt_depth_of_product_of_density_and_potential_temperature"  unit="(kg m2) degree_C" />
-        <field id="sst_wl"       long_name="Delta SST of warm layer"                                                                                unit="degC"     />
-        <field id="sst_cs"       long_name="Delta SST of cool skin"                                                                                 unit="degC"     />
-	<field id="temp_3m"      long_name="temperature at 3m"                                                                                      unit="degC"     />
-        
-        <field id="sss"          long_name="sea surface salinity"                               standard_name="sea_surface_salinity"                unit="1e-3"     />
-        <field id="sss2"         long_name="square of sea surface salinity"                                                                         unit="1e-6"      > sss * sss </field >
-        <field id="sssmax"       long_name="max of sea surface salinity"      field_ref="sss"   operation="maximum"                                                 />
-        <field id="sssmin"       long_name="min of sea surface salinity"      field_ref="sss"   operation="minimum"                                                 />
-        <field id="sbs"          long_name="sea bottom salinity"                                                                                    unit="0.001"    />
-        <field id="somint"       long_name="vertical integral of salinity times density"        standard_name="integral_wrt_depth_of_product_of_density_and_salinity"  unit="(kg m2) x (1e-3)" /> 
+        <!-- EOS80 -->
+        <field id="sst_pot"          long_name="sea surface potential temperature"                            standard_name="sea_surface_temperature"             unit="degC"     />
+        <field id="sst2_pot"         long_name="square of sea surface potential temperature"                  standard_name="square_of_sea_surface_temperature"   unit="degC2"     > sst_pot * sst_pot </field >
+        <field id="sstmax_pot"       long_name="max of sea surface potential temperature"   field_ref="sst_pot"   operation="maximum"                                                 />
+        <field id="sstmin_pot"       long_name="min of sea surface potential temperature"   field_ref="sst_pot"   operation="minimum"                                                 />
+        <field id="sstgrad_pot"      long_name="module of potential sst gradient"                                                                                 unit="degC/m"   />
+        <field id="sstgrad2_pot"     long_name="square of module of potential sst gradient"                                                                       unit="degC2/m2" />
+        <field id="sbt_pot"          long_name="sea bottom potential temperature"                                                                                 unit="degC"     />
+        <field id="tosmint_pot"      long_name="vertical integral of potential temperature times density"     standard_name="integral_wrt_depth_of_product_of_density_and_potential_temperature"  unit="(kg m2) degree_C" />
+        <field id="sst_wl_pot"       long_name="Delta potential SST of warm layer"                                                                                unit="degC"     />
+        <field id="sst_cs_pot"       long_name="Delta potential SST of cool skin"                                                                                 unit="degC"     />
+	<field id="temp_3m_pot"      long_name="potential temperature at 3m"                                                                                      unit="degC"     />
+
+        <field id="sss_pra"          long_name="sea surface practical salinity"                               standard_name="sea_surface_practical_salinity"                unit="1e-3"     />
+        <field id="sss2_pra"         long_name="square of sea surface practical salinity"                                                                         unit="1e-6"      > sss_pra * sss_pra </field >
+        <field id="sssmax_pra"       long_name="max of sea surface practical salinity"      field_ref="sss_pra"   operation="maximum"                                                 />
+        <field id="sssmin_pra"       long_name="min of sea surface practical salinity"      field_ref="sss_pra"   operation="minimum"                                                 />
+        <field id="sbs_pra"          long_name="sea bottom practical salinity"                                                                                    unit="0.001"    />
+        <field id="somint_pra"       long_name="vertical integral of practical salinity times density"        standard_name="integral_wrt_depth_of_product_of_density_and_practical_salinity"  unit="(kg m2) x (1e-3)" /> 
+        <!-- TEOS10 -->
+        <field id="sst_con"          long_name="sea surface conservative temperature"                            standard_name="sea_surface_conservative_temperature"             unit="degC"     />
+        <field id="sst2_con"         long_name="square of sea surface conservative temperature"                  standard_name="square_of_sea_surface_temperature"   unit="degC2"     > sst_con * sst_con </field >
+        <field id="sstmax_con"       long_name="max of sea surface conservative temperature"   field_ref="sst_con"   operation="maximum"                                                 />
+        <field id="sstmin_con"       long_name="min of sea surface conservative temperature"   field_ref="sst_con"   operation="minimum"                                                 />
+        <field id="sstgrad_con"      long_name="module of conservative sst gradient"                                                                                 unit="degC/m"   />
+        <field id="sstgrad2_con"     long_name="square of module of conservative sst gradient"                                                                       unit="degC2/m2" />
+        <field id="sbt_con"          long_name="sea bottom conservative temperature"                                                                                 unit="degC"     />
+        <field id="tosmint_con"      long_name="vertical integral of conservative temperature times density"     standard_name="integral_wrt_depth_of_product_of_density_and_conservative_temperature"  unit="(kg m2) degree_C" />
+        <field id="sst_wl_con"       long_name="Delta conservative SST of warm layer"                                                                                unit="degC"     />
+        <field id="sst_cs_con"       long_name="Delta conservative SST of cool skin"                                                                                 unit="degC"     />
+	<field id="temp_3m_con"      long_name="conservative temperature at 3m"                                                                                      unit="degC"     />
+
+        <field id="sss_abs"          long_name="sea surface absolute salinity"                               standard_name="sea_surface_absolute_salinity"                unit="1e-3"     />
+        <field id="sss2_abs"         long_name="square of sea surface absolute salinity"                                                                         unit="1e-6"      > sss_abs * sss_abs </field >
+        <field id="sssmax_abs"       long_name="max of sea surface absolute salinity"      field_ref="sss_abs"   operation="maximum"                                                 />
+        <field id="sssmin_abs"       long_name="min of sea surface absolute salinity"      field_ref="sss_abs"   operation="minimum"                                                 />
+        <field id="sbs_abs"          long_name="sea bottom absolute salinity"                                                                                    unit="0.001"    />
+        <field id="somint_abs"       long_name="vertical integral of absolute salinity times density"        standard_name="integral_wrt_depth_of_product_of_density_and_absolute_salinity"  unit="(kg m2) x (1e-3)" />
 
         <field id="taubot"       long_name="bottom stress module"                                                                                   unit="N/m2"     /> 
@@ -85,4 +112,14 @@
         <field id="mldr10_1max"  long_name="Max of Mixed Layer Depth (dsigma = 0.01 wrt 10m)"   field_ref="mldr10_1"   operation="maximum"                                                                          />
         <field id="mldr10_1min"  long_name="Min of Mixed Layer Depth (dsigma = 0.01 wrt 10m)"   field_ref="mldr10_1"   operation="minimum"                                                                          />
+         <field id="mldzint_1"    long_name="Mixed Layer Depth interpolated"                     standard_name="ocean_mixed_layer_thickness"                                                       unit="m"          />
+         <field id="mldzint_2"    long_name="Mixed Layer Depth interpolated"                     standard_name="ocean_mixed_layer_thickness"                                                       unit="m"          />
+         <field id="mldzint_3"    long_name="Mixed Layer Depth interpolated"                     standard_name="ocean_mixed_layer_thickness"                                                       unit="m"          />
+         <field id="mldzint_4"    long_name="Mixed Layer Depth interpolated"                     standard_name="ocean_mixed_layer_thickness"                                                       unit="m"          />
+         <field id="mldzint_5"    long_name="Mixed Layer Depth interpolated"                     standard_name="ocean_mixed_layer_thickness"                                                       unit="m"          />
+         <field id="mldhtc_1"     long_name="Mixed Layer Depth integrated heat content"          standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"       />
+         <field id="mldhtc_2"     long_name="Mixed Layer Depth integrated heat content"          standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"       />
+         <field id="mldhtc_3"     long_name="Mixed Layer Depth integrated heat content"          standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"       />
+         <field id="mldhtc_4"     long_name="Mixed Layer Depth integrated heat content"          standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"       />
+         <field id="mldhtc_5"     long_name="Mixed Layer Depth integrated heat content"          standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"       />
         <field id="heatc"        long_name="Heat content vertically integrated"                 standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"       />
         <field id="saltc"        long_name="Salt content vertically integrated"                                                                                                                   unit="1e-3*kg/m2" />
@@ -92,4 +129,10 @@
         <field id="beta"         long_name="haline contraction"                                                        unit="1e3"    grid_ref="grid_T_3D" />
         <field id="rhop"         long_name="potential density (sigma0)"        standard_name="sea_water_sigma_theta"   unit="kg/m3"  grid_ref="grid_T_3D" />
+        <field id="N_2d"         long_name="Depth-mean N"                                                              unit="m/s" />
+        <field id="modslp"       long_name="sqrt( slpi^2 + slpj^2 )"                                                   unit="1"      grid_ref="grid_T_3D" />
+        <field id="RossRad"      long_name="Rossby radius"                                                             unit="m" />
+        <field id="RossRadlim"   long_name="Rossby radius (limited)"                                                   unit="m" />
+        <field id="Tclinic_recip" long_name="recip of baroclinic timescale"                                            unit="s-1" />
+        <field id="RR_GS"        long_name="Rossby radius / min(dx,dy)"                                                unit="1" />
 
         <!-- Energy - horizontal divergence -->
@@ -360,6 +403,10 @@
 	  
 	  <!-- sbcssm variables -->
-          <field id="sst_m"    unit="degC" />
-          <field id="sss_m"    unit="psu"  />
+          <field id="sst_m_pot"    unit="degC" />
+	  <!-- EOS-80 -->
+          <field id="sss_m_pra"    unit="psu"  />
+          <!-- TEOS-10 -->
+          <field id="sss_m_abs"    unit="psu"  />
+
           <field id="ssu_m"    unit="m/s"  />
           <field id="ssv_m"    unit="m/s"  />
@@ -393,4 +440,5 @@
 
 
+        <field id="uoce2_e3u"    long_name="ocean current along i-axis squared (thickness weighted)"                                            unit="m3/s2"      grid_ref="grid_U_3D"  > uoce * uoce * e3u </field>
         <field id="ssu"          long_name="ocean surface current along i-axis"                                                                 unit="m/s"                             />
         <field id="sbu"          long_name="ocean bottom current along i-axis"                                                                  unit="m/s"                             />
@@ -450,4 +498,5 @@
         <field id="voce"         long_name="ocean current along j-axis"                             standard_name="sea_water_y_velocity"        unit="m/s"        grid_ref="grid_V_3D" />
         <field id="voce_e3v"     long_name="ocean current along j-axis  (thickness weighted)"                                                   unit="m/s"        grid_ref="grid_V_3D"  > voce * e3v </field>
+        <field id="voce2_e3v"    long_name="ocean current along j-axis squared (thickness weighted)"                                            unit="m3/s2"      grid_ref="grid_V_3D"  > voce * voce * e3v </field>
         <field id="ssv"          long_name="ocean surface current along j-axis"                                                                 unit="m/s"                             />
         <field id="sbv"          long_name="ocean bottom current along j-axis"                                                                  unit="m/s"                             />
@@ -551,4 +600,26 @@
       <field id="ahmf_2d"      long_name=" surface f-eddy viscosity coefficient"   unit="m2/s or m4/s" />
       <field id="ahmf_3d"      long_name=" 3D      f-eddy viscosity coefficient"   unit="m2/s or m4/s"  grid_ref="grid_T_3D"/>
+
+      <!-- product fields -->
+      <field_group id="diaprod">
+	<field id="ut"           long_name="product_of_sea_water_x_velocity_and_potential_temperature"      unit="degree_C m/s"      grid_ref="grid_U_3D"   />
+        <field id="ut_e3u"       long_name="product_of_sea_water_x_velocity_and_potential_temperature * e3u"  unit="degree_C m2/s"   grid_ref="grid_U_3D" > ut * e3u </field >
+	<field id="us"           long_name="product_of_sea_water_x_velocity_and_salinity"                   unit="PSU m/s"       grid_ref="grid_U_3D"   />
+        <field id="us_e3u"       long_name="product_of_sea_water_x_velocity_and_salinity * e3u"             unit="PSU m2/s"      grid_ref="grid_U_3D" > us * e3u </field >
+	<field id="urhop"        long_name="product_of_sea_water_x_velocity_and_potential_density"          unit="(kg/m3).(m/s)" grid_ref="grid_U_3D"   />
+        <field id="urhop_e3u"    long_name="product_of_sea_water_x_velocity_and_potential_density * e3u"    unit="(kg/m3).(m2/s)"   grid_ref="grid_U_3D" > urhop * e3u </field >
+	<field id="vt"           long_name="product_of_sea_water_y_velocity_and_potential_temperature"      unit="degree_C m/s"      grid_ref="grid_V_3D"   />
+        <field id="vt_e3v"       long_name="product_of_sea_water_y_velocity_and_potential_temperature * e3v"  unit="degree_C m2/s"   grid_ref="grid_V_3D" > vt * e3v </field >
+	<field id="vs"           long_name="product_of_sea_water_y_velocity_and_salinity"                   unit="PSU m/s"       grid_ref="grid_V_3D"   />
+        <field id="vs_e3v"       long_name="product_of_sea_water_y_velocity_and_salinity * e3t"             unit="PSU m2/s"      grid_ref="grid_V_3D" > vs * e3v </field >
+	<field id="vrhop"        long_name="product_of_sea_water_y_velocity_and_potential_density"          unit="(kg/m3).(m/s)" grid_ref="grid_V_3D"   />
+        <field id="vrhop_e3v"    long_name="product_of_sea_water_y_velocity_and_potential_density * e3t"    unit="(kg/m3).(m2/s)"  grid_ref="grid_V_3D" > vrhop * e3v </field >
+	<field id="wt"           long_name="product_of_upward_sea_water_velocity_and_potential_temperature" unit="degree_C m/s"      grid_ref="grid_W_3D"   />
+	<field id="ws"           long_name="product_of_upward_sea_water_velocity_and_salinity"              unit="PSU m/s"       grid_ref="grid_W_3D"   />
+	<field id="wrhop"        long_name="product_of_upward_sea_water_velocity_and_potential_density"     unit="(kg/m3).(m/s)" grid_ref="grid_W_3D"   />
+	<field id="uv"           long_name="product_of_sea_water_x_velocity_and_sea_water_y_velocity"       unit="m2/s2   "      grid_ref="grid_T_3D"   />
+	<field id="uw"           long_name="product_of_upward_sea_water_velocity_and_sea_water_x_velocity"  unit="m2/s2   "      grid_ref="grid_W_3D"   />
+	<field id="vw"           long_name="product_of_upward_sea_water_velocity_and_sea_water_y_velocity"  unit="m2/s2"         grid_ref="grid_W_3D"   />
+      </field_group>
 
       <field_group id="scalar"  grid_ref="grid_scalar"  >
@@ -587,14 +658,9 @@
          <field id="uoce_e3u_ave_vsum"    long_name="Vertical sum of u*e3u"                           field_ref="uoce_e3u_ave"         grid_ref="grid_U_vsum"     />
          <field id="uocetr_vsum_section"  long_name="Total 2D transport in i-direction"               field_ref="uoce_e3u_ave_vsum"    grid_ref="grid_U_scalar"  detect_missing_value="true"> this * e2u </field>
-         <field id="uocetr_strait"        long_name="Total transport across lines in i-direction"     field_ref="uocetr_vsum_section"  grid_ref="grid_U_4strait" />
-         <field id="u_masstr_strait"      long_name="Sea water transport across line in i-direction"  field_ref="uocetr_strait"        grid_ref="grid_U_4strait_hsum" unit="kg/s"> this * maskMFO_u * $rau0 </field>
 
          <field id="voce_e3v_ave"         long_name="Monthly average of v*e3v"                        field_ref="voce_e3v"                    freq_op="1mo"   freq_offset="_reset_" > @voce_e3v </field>
          <field id="voce_e3v_ave_vsum"    long_name="Vertical sum of v*e3v"                           field_ref="voce_e3v_ave"         grid_ref="grid_V_vsum"      />
          <field id="vocetr_vsum_section"  long_name="Total 2D transport of in j-direction"            field_ref="voce_e3v_ave_vsum"    grid_ref="grid_V_scalar"  detect_missing_value="true"> this * e1v </field>
-         <field id="vocetr_strait"        long_name="Total transport across lines in j-direction"     field_ref="vocetr_vsum_section"  grid_ref="grid_V_4strait"  />
-         <field id="v_masstr_strait"      long_name="Sea water transport across line in j-direction"  field_ref="vocetr_strait"        grid_ref="grid_V_4strait_hsum" unit="kg/s"> this * maskMFO_v * $rau0 </field>
-
-         <field id="masstr_strait"        long_name="Sea water transport across line"                                                  grid_ref="grid_4strait"  > u_masstr_strait + v_masstr_strait </field>
+
       </field_group>
 
@@ -897,6 +963,11 @@
     
     <field_group id="mooring" >
-      <field field_ref="toce"         name="thetao"   long_name="sea_water_potential_temperature"      />
-      <field field_ref="soce"         name="so"       long_name="sea_water_salinity"                   />
+      <!-- EOS80 -->
+      <field field_ref="toce_pot"         name="thetao_pot"   long_name="sea_water_potential_temperature"      />
+      <field field_ref="soce_pra"         name="so_pra"       long_name="sea_water_practical_salinity"                   />
+      <!-- TEOS10 -->
+      <field field_ref="toce_con"         name="thetao_con"   long_name="sea_water_conservative_temperature"      />
+      <field field_ref="soce_abs"         name="so_con"       long_name="sea_water_absolute_salinity"                   />
+
       <field field_ref="uoce"         name="uo"       long_name="sea_water_x_velocity"                 />
       <field field_ref="voce"         name="vo"       long_name="sea_water_y_velocity"                 />
@@ -904,9 +975,16 @@
       <field field_ref="avt"          name="difvho"   long_name="ocean_vertical_heat_diffusivity"      />
       <field field_ref="avm"          name="difvmo"   long_name="ocean_vertical_momentum_diffusivity"  />
-      
-      <field field_ref="sst"          name="tos"      long_name="sea_surface_temperature"                       />
-      <field field_ref="sst2"         name="tossq"    long_name="square_of_sea_surface_temperature"             />
-      <field field_ref="sstgrad"      name="tosgrad"  long_name="module_of_sea_surface_temperature_gradient"    />
-      <field field_ref="sss"          name="sos"      long_name="sea_surface_salinity"                          />
+
+      <!-- EOS80 -->
+      <field field_ref="sst_pot"          name="tos_pot"      long_name="sea_surface_potential_temperature"                       />
+      <field field_ref="sst2_pot"         name="tossq_pot"    long_name="square_of_sea_surface_potential_temperature"             />
+      <field field_ref="sstgrad_pot"      name="tosgrad_pot"  long_name="module_of_sea_surface_potential_temperature_gradient"    />
+      <field field_ref="sss_pra"          name="sos_pra"      long_name="sea_surface_absolute_salinity"                          />
+      <!-- TEOS10 -->
+      <field field_ref="sst_con"          name="tos_con"      long_name="sea_surface_conservative_temperature"                       />
+      <field field_ref="sst2_con"         name="tossq_con"    long_name="square_of_sea_surface_conservative_temperature"             />
+      <field field_ref="sstgrad_con"      name="tosgrad_con"  long_name="module_of_sea_surface_conservative_temperature_gradient"    />
+      <field field_ref="sss_abs"          name="sos"      long_name="sea_surface_absolute_salinity"                          />
+
       <field field_ref="ssh"          name="zos"      long_name="sea_surface_height_above_geoid"                />
       <field field_ref="empmr"        name="wfo"      long_name="water_flux_into_sea_water"                     />
@@ -931,9 +1009,17 @@
 
     <field_group id="groupT" >
-      <field field_ref="toce"         name="thetao"   long_name="sea_water_potential_temperature"               />
-      <field field_ref="soce"         name="so"       long_name="sea_water_salinity"                            />
-      <field field_ref="sst"          name="tos"      long_name="sea_surface_temperature"                       />
-      <field field_ref="sst2"         name="tossq"    long_name="square_of_sea_surface_temperature"             />
-      <field field_ref="sss"          name="sos"      long_name="sea_surface_salinity"                          />
+      <!-- EOS80 -->
+      <field field_ref="toce_pot"         name="thetao_pot"   long_name="sea_water_potential_temperature"               />
+      <field field_ref="soce_pra"         name="so_pra"       long_name="sea_water_practical_salinity"                            />
+      <field field_ref="sst_pot"          name="tos_pot"      long_name="sea_surface_potential_temperature"                       />
+      <field field_ref="sst2_pot"         name="tossq_pot"    long_name="square_of_sea_surface_potential_temperature"             />
+      <field field_ref="sss_pra"          name="sos_pra"      long_name="sea_surface_practical_salinity"                          />
+      <!-- TEOS10 -->
+      <field field_ref="toce_con"         name="thetao_con"   long_name="sea_water_conservative_temperature"               />
+      <field field_ref="soce_abs"         name="so_abs"       long_name="sea_water_absolute_salinity"                            />
+      <field field_ref="sst_con"          name="tos_con"      long_name="sea_surface_conservative_temperature"                       />
+      <field field_ref="sst2_con"         name="tossq_con"    long_name="square_of_sea_surface_conservative_temperature"             />
+      <field field_ref="sss_abs"          name="sos_abs"      long_name="sea_surface_absolute_salinity"                          />
+
       <field field_ref="ssh"          name="zos"      long_name="sea_surface_height_above_geoid"                />
       <field field_ref="empmr"        name="wfo"      long_name="water_flux_into_sea_water"                     />
@@ -967,4 +1053,24 @@
     </field_group>
 
+    <!-- TMB diagnostic output -->
+    <field_group  id="1h_grid_T_tmb" grid_ref="grid_T_2D" operation="instant">
+      <!-- EOS80 -->
+      <field id="top_temp_pot"           name="votemper_top_pot"  unit="degC"  />
+      <field id="mid_temp_pot"           name="votemper_mid_pot"  unit="degC"  />
+      <field id="bot_temp_pot"           name="votemper_bot_pot"  unit="degC"  />
+      <field id="top_sal_pra"            name="vosaline_top_pra"  unit="psu"   />
+      <field id="mid_sal_pra"            name="vosaline_mid_pra"  unit="psu"   />
+      <field id="bot_sal_pra"            name="vosaline_bot_pra"  unit="psu"   />
+      <!-- TEOS10 -->
+      <field id="top_temp_con"           name="votemper_top_con"  unit="degC"  />
+      <field id="mid_temp_con"           name="votemper_mid_con"  unit="degC"  />
+      <field id="bot_temp_con"           name="votemper_bot_con"  unit="degC"  />
+      <field id="top_sal_abs"            name="vosaline_top_abs"  unit="psu"   />
+      <field id="mid_sal_abs"            name="vosaline_mid_abs"  unit="psu"   />
+      <field id="bot_sal_abs"            name="vosaline_bot_abs"  unit="psu"   />
+
+      <field id="sshnmasked"         name="sossheig"      unit="m"     /> 
+    </field_group>
+
     <field_group  id="1h_grid_U_tmb" grid_ref="grid_U_2D" operation="instant">
       <field id="top_u"           name="vozocrtx_top"  unit="m/s"  />
@@ -983,7 +1089,13 @@
     <!-- 25h diagnostic output -->
     <field_group id="25h_grid_T" grid_ref="grid_T_3D" operation="instant">
-      <field id="temper25h"         name="potential temperature 25h mean"    unit="degC" />
+      <!-- EOS80 -->
+      <field id="temper25h_pot"         name="potential temperature 25h mean"    unit="degC" />
       <field id="tempis25h"         name="insitu temperature 25h mean"    unit="degC" />
-      <field id="salin25h"          name="salinity 25h mean"                 unit="psu"  />
+      <field id="salin25h_pra"          name="practical salinity 25h mean"                 unit="psu"  />
+      <!-- TEOS10 -->
+      <field id="temper25h_con"         name="conservative temperature 25h mean"    unit="degC" />
+      <field id="tempis25h"         name="insitu temperature 25h mean"    unit="degC" />
+      <field id="salin25h_abs"          name="absolute salinity 25h mean"                 unit="psu"  />
+
       <field id="ssh25h"            name="sea surface height 25h mean"  grid_ref="grid_T_2D"      unit="m"    />
     </field_group>
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/grid_def_nemo.xml
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/grid_def_nemo.xml	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/grid_def_nemo.xml	(revision 14671)
@@ -20,9 +20,4 @@
          <domain domain_ref="grid_T" />
          <axis axis_ref="deptht" />
-       </grid>
-        <!--  -->
-       <grid id="grid_T_3DS" >
-         <domain domain_ref="grid_T" />
-         <axis axis_ref="profsed" />
        </grid>
         <!--  -->
@@ -67,40 +62,4 @@
        </grid>
         <!--  -->
-
-
-       <grid id="grid_znl_T_2D">
-         <domain domain_ref="gznl" />
-         <axis axis_ref="basin" />
-       </grid>
-
-       <grid id="grid_znl_T_3D">
-         <domain domain_ref="gznl" />
-         <axis axis_ref="deptht"  />
-         <axis axis_ref="basin" />
-       </grid>
-
-       <grid id="grid_znl_W_3D">
-         <domain domain_ref="gznl" />
-         <axis axis_ref="depthw"  />
-         <axis axis_ref="basin" />
-       </grid>
-
-      <grid id="grid_ptr_T_2D">
-         <domain domain_ref="ptr" />
-         <axis axis_ref="basin" />
-       </grid>
-
-       <grid id="grid_ptr_T_3D">
-         <domain  domain_ref="ptr" />
-         <axis axis_ref="deptht"  />
-         <axis axis_ref="basin" />
-       </grid>
-
-       <grid id="grid_ptr_W_3D">
-         <domain  domain_ref="ptr" />
-         <axis axis_ref="depthw"  />
-         <axis axis_ref="basin" />
-       </grid>
-
        <grid id="grid_ptr_W_GLO">
          <domain  domain_ref="ptr" />
@@ -155,25 +114,4 @@
        </grid>
 
-       <!-- for ORCA2 grid  -->
-       <grid id="cumul_U">
-         <axis axis_ref="cumul_U" n_glo="182" >
-           <reduce_domain local="true" operation="sum" direction="jDir" />
-           <reduce_axis operation="sum" />
-         </axis>
-         <axis axis_ref="depthu" />
-       </grid>
-
-       <!-- for eORCA1 grid
-
-       <grid id="cumul_U">
-         <axis axis_ref="cumul_U" n_glo="362" >
-           <reduce_domain local="true" operation="sum" direction="jDir" />
-           <reduce_axis operation="sum" />
-         </axis>
-         <axis axis_ref="depthu" />
-       </grid>
-
-      -->
-
 
        <grid id="grid_T_zoom_300">
@@ -192,77 +130,46 @@
        </grid>
  
-       <grid id="grid_U_4strait">
-         <domain domain_ref="grid_U" />
-         <axis axis_ref="section">
-           <duplicate_scalar/>
-         </axis>
-       </grid>
- 
-       <grid id="grid_V_4strait">
-         <domain domain_ref="grid_V" />
-         <axis axis_ref="section">
-           <duplicate_scalar/>
-         </axis>
-       </grid>
- 
-       <grid id="grid_U_4strait_hsum">
-         <scalar >
-           <reduce_domain operation="sum" local="true"/>
-           <reduce_scalar operation="sum" />
-         </scalar>
-         <axis axis_ref="section"/>
-       </grid>
- 
-       <grid id="grid_V_4strait_hsum">
-         <scalar >
-           <reduce_domain operation="sum" local="true"/>
-           <reduce_scalar operation="sum" />
-         </scalar>
-         <axis axis_ref="section"/>
-       </grid>
- 
-       <grid id="grid_4strait">
-         <axis axis_ref="section"/>
-       </grid>
-
-      <grid id="grid_U_4strait_ice">
-        <domain domain_ref="grid_U" />
-        <axis axis_ref="section_ice">
-          <duplicate_scalar/>
-        </axis>
-      </grid>
-
-      <grid id="grid_V_4strait_ice">
-        <domain domain_ref="grid_V" />
-        <axis axis_ref="section_ice">
-         <duplicate_scalar/>
-        </axis>
-      </grid>
-
-      <grid id="grid_U_4strait_ice_hsum">
-        <scalar >
-         <reduce_domain operation="sum" local="true"/>
-         <reduce_scalar operation="sum" />
-        </scalar>
-        <axis axis_ref="section_ice"/>
-      </grid>
-
-     <grid id="grid_V_4strait_ice_hsum">
-        <scalar >
-         <reduce_domain operation="sum" local="true"/>
-         <reduce_scalar operation="sum" />
-        </scalar>
-        <axis axis_ref="section_ice"/>
-     </grid>
-
-     <grid id="grid_4strait_ice">
-       <axis axis_ref="section_ice"/>
-     </grid>
- 
       <!-- scalars -->
       <grid id="grid_scalar" >
         <scalar/>
       </grid>
- 
-    </grid_definition>   
- 
+        <!--  -->
+       <grid id="grid_EqT" >
+         <domain id="EqT" />
+       </grid>
+        <!--  -->
+       <grid id="gznl_T_2D">
+         <domain id="ptr" />
+       </grid>
+        <!--  -->
+       <grid id="gznl_T_3D">
+         <domain id="ptr" />
+         <axis axis_ref="deptht" />
+       </grid>
+        <!--  -->
+       <grid id="gznl_W_2D">
+         <domain id="ptr" />
+       </grid>
+        <!--  -->
+       <grid id="gznl_W_3D">
+         <domain id="ptr" />
+         <axis axis_ref="depthw" />
+       </grid>
+       <grid id="vert_sum">
+         <domain id="grid_T"/>
+         <scalar>
+            <reduce_axis operation="sum" />
+         </scalar>
+       </grid>
+       <grid id="zoom_300">
+         <domain id="grid_T" />
+         <axis axis_ref="deptht300"/>
+       </grid>
+       <grid id="zoom_300_sum">
+         <domain id="grid_T" />
+         <scalar>
+            <reduce_axis operation="sum" />
+         </scalar>
+       </grid>
+    </grid_definition>
+    
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/namelist_ice_ref
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/namelist_ice_ref	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/namelist_ice_ref	(revision 14671)
@@ -195,11 +195,13 @@
 !------------------------------------------------------------------------------
    ln_pnd            = .true.         !  activate melt ponds or not
-      ln_pnd_LEV     = .true.         !  level ice melt ponds (from Flocco et al 2007,2010 & Holland et al 2012)
-         rn_apnd_min =   0.15         !     minimum ice fraction that contributes to melt pond. range: 0.0 -- 0.15 ??
-         rn_apnd_max =   0.85         !     maximum ice fraction that contributes to melt pond. range: 0.7 -- 0.85 ??
+      ln_pnd_TOPO    = .true.         !  topographic melt ponds 
+      ln_pnd_LEV     = .false.        !  level ice melt ponds 
+         rn_apnd_min =   0.15         !     minimum meltwater fraction contributing to pond growth (TOPO and LEV)
+         rn_apnd_max =   0.85         !     maximum meltwater fraction contributing to pond growth (TOPO and LEV)
+         rn_pnd_flush=   0.01         !     pond flushing efficiency (tuning parameter) (LEV)
       ln_pnd_CST     = .false.        !  constant  melt ponds
          rn_apnd     =   0.2          !     prescribed pond fraction, at Tsu=0 degC
          rn_hpnd     =   0.05         !     prescribed pond depth,    at Tsu=0 degC
-      ln_pnd_lids    = .true.         !  frozen lids on top of the ponds (only for ln_pnd_LEV)
+      ln_pnd_lids    = .false.        !  frozen lids on top of the ponds (only for ln_pnd_LEV)
       ln_pnd_alb     = .true.         !  effect of melt ponds on ice albedo
 /
@@ -226,7 +228,7 @@
    rn_tms_ini_n     = 270.            !  initial snw temperature     (K), North
    rn_tms_ini_s     = 270.            !        "            "             South
-   rn_apd_ini_n     =   0.2           !  initial pond fraction       (-), North
+   rn_apd_ini_n     =   0.0           !  initial pond fraction       (-), North
    rn_apd_ini_s     =   0.2           !        "            "             South
-   rn_hpd_ini_n     =   0.05          !  initial pond depth          (m), North
+   rn_hpd_ini_n     =   0.00          !  initial pond depth          (m), North
    rn_hpd_ini_s     =   0.05          !        "            "             South
    rn_hld_ini_n     =   0.0           !  initial pond lid depth      (m), North
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/namelist_ref
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/namelist_ref	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/cfgs/SHARED/namelist_ref	(revision 14671)
@@ -67,4 +67,5 @@
    ln_xios_read = .FALSE.  !  use XIOS to read restart file (only for a single file restart)
    nn_wxios = 0      !  use XIOS to write restart file 0 - no, 1 - single file output, 2 - multiple file output
+   ln_rst_eos = .TRUE.     ! check if the equation of state used to produce the restart is consistent with model
 /
 !-----------------------------------------------------------------------
@@ -745,5 +746,5 @@
 &nameos        !   ocean Equation Of Seawater                           (default: NO selection)
 !-----------------------------------------------------------------------
-   ln_teos10   = .false.         !  = Use TEOS-10
+   ln_teos10   = .true.         !  = Use TEOS-10
    ln_eos80    = .false.         !  = Use EOS80
    ln_seos     = .false.         !  = Use S-EOS (simplified Eq.)
@@ -837,8 +838,9 @@
       !                             !   = 30 F(i,j,k)  =ldf_c2d * ldf_c1d
       !                        !  time invariant coefficients:  aei0 = 1/2  Ue*Le 
-      rn_Ue        = 0.02           !  lateral diffusive velocity [m/s] (nn_aht_ijk_t= 0, 10, 20, 30)
-      rn_Le        = 200.e+3        !  lateral diffusive length   [m]   (nn_aht_ijk_t= 0, 10)
+      rn_Ue        = 0.02           !  lateral diffusive velocity [m/s] (nn_aei_ijk_t= 0, 10, 20, 30)
+      rn_Le        = 200.e+3        !  lateral diffusive length   [m]   (nn_aei_ijk_t= 0, 10)
       !
       ln_ldfeiv_dia =.false.   ! diagnose eiv stream function and velocities
+      nn_ldfeiv_shape = 0           !  shape of bounding coefficient    (nn_aei_ijk_t= 21 only)
 /
 !-----------------------------------------------------------------------
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/ice.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/ice.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/ice.F90	(revision 14671)
@@ -208,7 +208,9 @@
    !                                     !!** ice-ponds namelist (namthd_pnd)
    LOGICAL , PUBLIC ::   ln_pnd           !: Melt ponds (T) or not (F)
-   LOGICAL , PUBLIC ::   ln_pnd_LEV       !: Melt ponds scheme from Holland et al (2012), Flocco et al (2007, 2010)
-   REAL(wp), PUBLIC ::   rn_apnd_min      !: Minimum ice fraction that contributes to melt ponds
-   REAL(wp), PUBLIC ::   rn_apnd_max      !: Maximum ice fraction that contributes to melt ponds
+   LOGICAL , PUBLIC ::   ln_pnd_TOPO      !: Topographic Melt ponds scheme (Flocco et al 2007, 2010)
+   LOGICAL , PUBLIC ::   ln_pnd_LEV       !: Simple melt pond scheme
+   REAL(wp), PUBLIC ::   rn_apnd_min      !: Minimum fraction of melt water contributing to ponds
+   REAL(wp), PUBLIC ::   rn_apnd_max      !: Maximum fraction of melt water contributing to ponds
+   REAL(wp), PUBLIC ::   rn_pnd_flush     !: Pond flushing efficiency (tuning parameter)
    LOGICAL , PUBLIC ::   ln_pnd_CST       !: Melt ponds scheme with constant fraction and depth
    REAL(wp), PUBLIC ::   rn_apnd          !: prescribed pond fraction (0<rn_apnd<1)
@@ -308,4 +310,8 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   t1_ice          !: temperature of the first layer          (ln_cndflx=T) [K]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   cnd_ice         !: effective conductivity of the 1st layer (ln_cndflx=T) [W.m-2.K-1]
+
+   ! meltwater arrays to save for melt ponds
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   dh_i_sum_2d   !: surface melt (2d arrays for ponds)       [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   dh_s_mlt_2d   !: snow surf melt (2d arrays for ponds)     [m]
 
    !!----------------------------------------------------------------------
@@ -458,4 +464,5 @@
       ii = ii + 1
       ALLOCATE( qtr_ice_bot(jpi,jpj,jpl) , cnd_ice(jpi,jpj,jpl) , t1_ice(jpi,jpj,jpl) ,  &
+         &      dh_i_sum_2d(jpi,jpj,jpl) , dh_s_mlt_2d(jpi,jpj,jpl) ,                    &
          &      h_i        (jpi,jpj,jpl) , a_i    (jpi,jpj,jpl) , v_i   (jpi,jpj,jpl) ,  &
          &      v_s        (jpi,jpj,jpl) , h_s    (jpi,jpj,jpl) , t_su  (jpi,jpj,jpl) ,  &
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icedyn_adv_pra.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icedyn_adv_pra.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icedyn_adv_pra.F90	(revision 14671)
@@ -178,5 +178,5 @@
                z0ei(:,:,jk,jl) = pe_i(:,:,jk,jl) * e1e2t(:,:) ! Ice  heat content
             END DO
-            IF ( ln_pnd_LEV ) THEN
+            IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
                z0ap(:,:,jl) = pa_ip(:,:,jl) * e1e2t(:,:)      ! Melt pond fraction
                z0vp(:,:,jl) = pv_ip(:,:,jl) * e1e2t(:,:)      ! Melt pond volume
@@ -214,5 +214,5 @@
             END DO
             !
-            IF ( ln_pnd_LEV ) THEN
+            IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
                CALL adv_x( zdt , zudy , 1._wp , zarea , z0ap , sxap , sxxap , syap , syyap , sxyap )    !--- melt pond fraction
                CALL adv_y( zdt , zvdx , 0._wp , zarea , z0ap , sxap , sxxap , syap , syyap , sxyap ) 
@@ -249,5 +249,5 @@
                   &                                 sxxe(:,:,jk,:), sye(:,:,jk,:), syye(:,:,jk,:), sxye(:,:,jk,:) )
             END DO
-            IF ( ln_pnd_LEV ) THEN
+            IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
                CALL adv_y( zdt , zvdx , 1._wp , zarea , z0ap , sxap , sxxap , syap , syyap , sxyap )    !--- melt pond fraction
                CALL adv_x( zdt , zudy , 0._wp , zarea , z0ap , sxap , sxxap , syap , syyap , sxyap )
@@ -278,5 +278,5 @@
          CALL lbc_lnk_multi( 'icedyn_adv_pra', z0ei  , 'T', 1._wp, sxe   , 'T', -1._wp, sye   , 'T', -1._wp  & ! ice enthalpy
             &                                , sxxe  , 'T', 1._wp, syye  , 'T',  1._wp, sxye  , 'T',  1._wp  )
-         IF ( ln_pnd_LEV ) THEN
+         IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
             CALL lbc_lnk_multi( 'icedyn_adv_pra', z0ap , 'T', 1._wp, sxap , 'T', -1._wp, syap , 'T', -1._wp  & ! melt pond fraction
                &                                , sxxap, 'T', 1._wp, syyap, 'T',  1._wp, sxyap, 'T',  1._wp  &
@@ -302,5 +302,5 @@
                pe_i(:,:,jk,jl) = z0ei(:,:,jk,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
             END DO
-            IF ( ln_pnd_LEV ) THEN
+            IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
                pa_ip(:,:,jl) = z0ap(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
                pv_ip(:,:,jl) = z0vp(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
@@ -780,5 +780,5 @@
                   !                               ! -- check h_ip -- !
                   ! if h_ip is larger than the surrounding 9 pts => reduce h_ip and increase a_ip
-                  IF( ln_pnd_LEV .AND. pv_ip(ji,jj,jl) > 0._wp ) THEN
+                  IF( ( ln_pnd_LEV .OR. ln_pnd_TOPO ) .AND. pv_ip(ji,jj,jl) > 0._wp ) THEN
                      zhip = pv_ip(ji,jj,jl) / MAX( epsi20, pa_ip(ji,jj,jl) )
                      IF( zhip > phip_max(ji,jj,jl) .AND. pa_ip(ji,jj,jl) < 0.15 ) THEN
@@ -1027,5 +1027,5 @@
             END DO
             !
-            IF( ln_pnd_LEV ) THEN                                    ! melt pond fraction
+            IF( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN                                    ! melt pond fraction
                IF( iom_varid( numrir, 'sxap', ldstop = .FALSE. ) > 0 ) THEN
                   CALL iom_get( numrir, jpdom_autoglo, 'sxap' , sxap  )
@@ -1069,5 +1069,5 @@
             sxc0  = 0._wp   ;   syc0  = 0._wp   ;   sxxc0  = 0._wp   ;   syyc0  = 0._wp   ;   sxyc0  = 0._wp      ! snow layers heat content
             sxe   = 0._wp   ;   sye   = 0._wp   ;   sxxe   = 0._wp   ;   syye   = 0._wp   ;   sxye   = 0._wp      ! ice layers heat content
-            IF( ln_pnd_LEV ) THEN
+            IF( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
                sxap = 0._wp ;   syap = 0._wp    ;   sxxap = 0._wp    ;   syyap = 0._wp    ;   sxyap = 0._wp       ! melt pond fraction
                sxvp = 0._wp ;   syvp = 0._wp    ;   sxxvp = 0._wp    ;   syyvp = 0._wp    ;   sxyvp = 0._wp       ! melt pond volume
@@ -1137,5 +1137,5 @@
          END DO
          !
-         IF( ln_pnd_LEV ) THEN                                       ! melt pond fraction
+         IF( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN                                       ! melt pond fraction
             CALL iom_rstput( iter, nitrst, numriw, 'sxap' , sxap  )
             CALL iom_rstput( iter, nitrst, numriw, 'syap' , syap  )
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icedyn_adv_umx.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icedyn_adv_umx.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icedyn_adv_umx.F90	(revision 14671)
@@ -341,5 +341,5 @@
          !
          !== melt ponds ==!
-         IF ( ln_pnd_LEV ) THEN
+         IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
             ! concentration
             zamsk = 1._wp
@@ -361,8 +361,8 @@
          !
          ! --- Lateral boundary conditions --- !
-         IF    ( ln_pnd_LEV .AND. ln_pnd_lids ) THEN
+         IF    ( ( ln_pnd_LEV .OR. ln_pnd_TOPO ) .AND. ln_pnd_lids ) THEN
             CALL lbc_lnk_multi( 'icedyn_adv_umx', pa_i,'T',1._wp, pv_i,'T',1._wp, pv_s,'T',1._wp, psv_i,'T',1._wp, poa_i,'T',1._wp &
                &                                , pa_ip,'T',1._wp, pv_ip,'T',1._wp, pv_il,'T',1._wp )
-         ELSEIF( ln_pnd_LEV .AND. .NOT.ln_pnd_lids ) THEN
+         ELSEIF( ( ln_pnd_LEV .OR. ln_pnd_TOPO ) .AND. .NOT.ln_pnd_lids ) THEN
             CALL lbc_lnk_multi( 'icedyn_adv_umx', pa_i,'T',1._wp, pv_i,'T',1._wp, pv_s,'T',1._wp, psv_i,'T',1._wp, poa_i,'T',1._wp &
                &                                , pa_ip,'T',1._wp, pv_ip,'T',1._wp )
@@ -1611,5 +1611,5 @@
                   !                               ! -- check h_ip -- !
                   ! if h_ip is larger than the surrounding 9 pts => reduce h_ip and increase a_ip
-                  IF( ln_pnd_LEV .AND. pv_ip(ji,jj,jl) > 0._wp ) THEN
+                  IF( ( ln_pnd_LEV .OR. ln_pnd_TOPO ) .AND. pv_ip(ji,jj,jl) > 0._wp ) THEN
                      zhip = pv_ip(ji,jj,jl) / MAX( epsi20, pa_ip(ji,jj,jl) )
                      IF( zhip > phip_max(ji,jj,jl) .AND. pa_ip(ji,jj,jl) < 0.15 ) THEN
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icedyn_rdgrft.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icedyn_rdgrft.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icedyn_rdgrft.F90	(revision 14671)
@@ -567,5 +567,5 @@
                oirft2(ji) = oa_i_2d(ji,jl1)   * afrft * hi_hrft 
 
-               IF ( ln_pnd_LEV ) THEN
+               IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
                   aprdg1     = a_ip_2d(ji,jl1) * afrdg
                   aprdg2(ji) = a_ip_2d(ji,jl1) * afrdg * hi_hrdg(ji,jl1)
@@ -604,5 +604,5 @@
                sv_i_2d(ji,jl1) = sv_i_2d(ji,jl1) - sirdg1    - sirft(ji)
                oa_i_2d(ji,jl1) = oa_i_2d(ji,jl1) - oirdg1    - oirft1
-               IF ( ln_pnd_LEV ) THEN
+               IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
                   a_ip_2d(ji,jl1) = a_ip_2d(ji,jl1) - aprdg1    - aprft1
                   v_ip_2d(ji,jl1) = v_ip_2d(ji,jl1) - vprdg(ji) - vprft(ji)
@@ -701,5 +701,5 @@
                   v_s_2d (ji,jl2) = v_s_2d (ji,jl2) + ( vsrdg (ji) * rn_fsnwrdg * fvol(ji)  +  &
                      &                                  vsrft (ji) * rn_fsnwrft * zswitch(ji) )
-                  IF ( ln_pnd_LEV ) THEN
+                  IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
                      v_ip_2d (ji,jl2) = v_ip_2d(ji,jl2) + (   vprdg (ji) * rn_fpndrdg * fvol   (ji)   &
                         &                                   + vprft (ji) * rn_fpndrft * zswitch(ji)   )
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/iceitd.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/iceitd.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/iceitd.F90	(revision 14671)
@@ -305,5 +305,5 @@
             IF ( a_i_1d(ji) > epsi10 .AND. h_i_1d(ji) < rn_himin ) THEN
                a_i_1d(ji) = a_i_1d(ji) * h_i_1d(ji) / rn_himin 
-               IF( ln_pnd_LEV )   a_ip_1d(ji) = a_ip_1d(ji) * h_i_1d(ji) / rn_himin
+               IF( ln_pnd_LEV .OR. ln_pnd_TOPO )   a_ip_1d(ji) = a_ip_1d(ji) * h_i_1d(ji) / rn_himin
                h_i_1d(ji) = rn_himin
             ENDIF
@@ -476,5 +476,5 @@
                zaTsfn(ji,jl2)  = zaTsfn(ji,jl2) + ztrans
                !  
-               IF ( ln_pnd_LEV ) THEN
+               IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
                   ztrans          = a_ip_2d(ji,jl1) * zworka(ji)     ! Pond fraction
                   a_ip_2d(ji,jl1) = a_ip_2d(ji,jl1) - ztrans
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icerst.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icerst.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icerst.F90	(revision 14671)
@@ -27,4 +27,5 @@
    USE in_out_manager ! I/O manager
    USE iom            ! I/O manager library
+   USE ioipsl, ONLY : ju2ymds    ! for calendar
    USE lib_mpp        ! MPP library
    USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
@@ -52,4 +53,7 @@
       INTEGER, INTENT(in) ::   kt       ! number of iteration
       !
+      INTEGER             ::   iyear, imonth, iday
+      REAL (wp)           ::   zsec
+      REAL (wp)           ::   zfjulday
       CHARACTER(len=20)   ::   clkt     ! ocean time-step define as a character
       CHARACTER(len=50)   ::   clname   ! ice output restart file name
@@ -67,6 +71,13 @@
          IF( nitrst <= nitend .AND. nitrst > 0 ) THEN
             ! beware of the format used to write kt (default is i8.8, that should be large enough...)
-            IF( nitrst > 99999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
-            ELSE                           ;   WRITE(clkt, '(i8.8)') nitrst
+            IF ( ln_rstdate ) THEN
+               zfjulday = fjulday + (2*nn_fsbc+1)*rdt / rday
+               IF( ABS(zfjulday - REAL(NINT(zfjulday),wp)) < 0.1 / rday )   zfjulday = REAL(NINT(zfjulday),wp)   ! avoid truncation error
+               CALL ju2ymds( zfjulday, iyear, imonth, iday, zsec )           
+               WRITE(clkt, '(i4.4,2i2.2)') iyear, imonth, iday
+            ELSE
+               IF( nitrst > 99999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+               ELSE                           ;   WRITE(clkt, '(i8.8)') nitrst
+               ENDIF
             ENDIF
             ! create the file
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icestp.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icestp.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icestp.F90	(revision 14671)
@@ -211,5 +211,5 @@
       ! --- Ocean time step --- !
       !-------------------------!
-      IF( ln_icedyn )                   CALL ice_update_tau( kt, ub(:,:,1), vb(:,:,1) )   ! -- update surface ocean stresses
+      CALL ice_update_tau( kt, ub(:,:,1), vb(:,:,1) )   ! -- update surface ocean stresses
 !!gm   remark, the ocean-ice stress is not saved in ice diag call above .....  find a solution!!!
       !
@@ -414,4 +414,7 @@
             wfx_pnd(ji,jj) = 0._wp
 
+            dh_i_sum_2d(:,:,:) = 0._wp
+            dh_s_mlt_2d(:,:,:) = 0._wp
+
             hfx_thd(ji,jj) = 0._wp   ;
             hfx_snw(ji,jj) = 0._wp   ;   hfx_opw(ji,jj) = 0._wp
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icetab.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icetab.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icetab.F90	(revision 14671)
@@ -40,5 +40,5 @@
       INTEGER , DIMENSION(ndim1d)     , INTENT(in   ) ::   tab_ind  ! input index
       REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(in   ) ::   tab2d    ! input 2D field
-      REAL(wp), DIMENSION(ndim1d,jpl) , INTENT(  out) ::   tab1d    ! output 1D field
+      REAL(wp), DIMENSION(ndim1d,jpl) , INTENT(inout) ::   tab1d    ! output 1D field
       !
       INTEGER ::   jl, jn, jid, jjd
@@ -61,5 +61,5 @@
       INTEGER , DIMENSION(ndim1d) , INTENT(in   ) ::   tab_ind  ! input index
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   tab2d    ! input 2D field
-      REAL(wp), DIMENSION(ndim1d) , INTENT(  out) ::   tab1d    ! output 1D field
+      REAL(wp), DIMENSION(ndim1d) , INTENT(inout) ::   tab1d    ! output 1D field
       !
       INTEGER ::   jn , jid, jjd
@@ -80,5 +80,5 @@
       INTEGER , DIMENSION(ndim1d)     , INTENT(in   ) ::   tab_ind   ! input index
       REAL(wp), DIMENSION(ndim1d,jpl) , INTENT(in   ) ::   tab1d     ! input 1D field
-      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(  out) ::   tab2d     ! output 2D field
+      REAL(wp), DIMENSION(jpi,jpj,jpl), INTENT(inout) ::   tab2d     ! output 2D field
       !
       INTEGER ::   jl, jn, jid, jjd
@@ -101,5 +101,5 @@
       INTEGER , DIMENSION(ndim1d) , INTENT(in   ) ::   tab_ind   ! input index
       REAL(wp), DIMENSION(ndim1d) , INTENT(in   ) ::   tab1d     ! input 1D field
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   tab2d     ! output 2D field
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   tab2d     ! output 2D field
       !
       INTEGER ::   jn , jid, jjd
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icethd.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icethd.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icethd.F90	(revision 14671)
@@ -247,5 +247,4 @@
             IF( ln_icedH ) THEN                                     ! --- Growing/Melting --- !
                               CALL ice_thd_dh                           ! Ice-Snow thickness   
-                              CALL ice_thd_pnd                          ! Melt ponds formation
                               CALL ice_thd_ent( e_i_1d(1:npti,:) )      ! Ice enthalpy remapping
             ENDIF
@@ -268,4 +267,6 @@
       IF( ln_icediachk )   CALL ice_cons2D  (1, 'icethd',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft)
       !                   
+      IF ( ln_pnd  )          CALL ice_thd_pnd                      ! --- Melt ponds
+
       IF( jpl > 1  )          CALL ice_itd_rem( kt )                ! --- Transport ice between thickness categories --- !
       !
@@ -536,4 +537,7 @@
          CALL tab_1d_2d( npti, nptidx(1:npti), cnd_ice_1d(1:npti), cnd_ice(:,:,kl) )
          CALL tab_1d_2d( npti, nptidx(1:npti), t1_ice_1d (1:npti), t1_ice (:,:,kl) )
+         ! ponds
+         CALL tab_1d_2d( npti, nptidx(1:npti), dh_i_sum  (1:npti) , dh_i_sum_2d(:,:,kl) )
+         CALL tab_1d_2d( npti, nptidx(1:npti), dh_s_mlt  (1:npti) , dh_s_mlt_2d(:,:,kl) )
          ! SIMIP diagnostics         
          CALL tab_1d_2d( npti, nptidx(1:npti), t_si_1d       (1:npti), t_si       (:,:,kl) )
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icethd_pnd.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icethd_pnd.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icethd_pnd.F90	(revision 14671)
@@ -20,6 +20,8 @@
    USE ice1D          ! sea-ice: thermodynamics variables
    USE icetab         ! sea-ice: 1D <==> 2D transformation
+   USE sbc_ice        ! surface energy budget
    !
    USE in_out_manager ! I/O manager
+   USE iom            ! I/O manager library
    USE lib_mpp        ! MPP library
    USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
@@ -34,7 +36,43 @@
    INTEGER ::              nice_pnd    ! choice of the type of pond scheme
    !                                   ! associated indices:
-   INTEGER, PARAMETER ::   np_pndNO  = 0   ! No pond scheme
-   INTEGER, PARAMETER ::   np_pndCST = 1   ! Constant ice pond scheme
-   INTEGER, PARAMETER ::   np_pndLEV = 2   ! Level ice pond scheme
+   INTEGER, PARAMETER ::   np_pndNO   = 0   ! No pond scheme
+   INTEGER, PARAMETER ::   np_pndCST  = 1   ! Constant ice pond scheme
+   INTEGER, PARAMETER ::   np_pndLEV  = 2   ! Level ice pond scheme
+   INTEGER, PARAMETER ::   np_pndTOPO = 3   ! Level ice pond scheme
+
+   REAL(wp), PARAMETER :: &   ! shared parameters for topographic melt ponds
+      zhi_min = 0.1_wp        , & ! minimum ice thickness with ponds (m) 
+      zTd     = 273.0_wp      , & ! temperature difference for freeze-up (C)
+      zvp_min = 1.e-4_wp          ! minimum pond volume (m)
+
+   !--------------------------------------------------------------------------
+   ! 
+   ! Pond volume per area budget diags
+   !  
+   ! The idea of diags is the volume of ponds per grid cell area is
+   !
+   ! dV/dt = mlt + drn + lid + rnf
+   ! mlt   = input from surface melting
+   ! drn   = drainage through brine network
+   ! lid   = lid growth & melt
+   ! rnf   = runoff (water directly removed out of surface melting + overflow)
+   !
+   ! In topo mode, the pond water lost because it is in the snow is not included in the budget
+   !
+   ! In level mode, all terms are incorporated
+
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: & ! pond volume budget diagnostics
+      diag_dvpn_mlt,  &     !! meltwater pond volume input      [m/day]
+      diag_dvpn_drn,  &     !! pond volume lost by drainage     [m/day]
+      diag_dvpn_lid,  &     !! exchange with lid / refreezing   [m/day]
+      diag_dvpn_rnf         !! meltwater pond lost to runoff    [m/day]
+      
+   REAL(wp), ALLOCATABLE, DIMENSION(:) ::   & ! pond volume budget diagnostics (1d)
+      diag_dvpn_mlt_1d,  &  !! meltwater pond volume input      [m/day]
+      diag_dvpn_drn_1d,  &  !! pond volume lost by drainage     [m/day]
+      diag_dvpn_lid_1d,  &  !! exchange with lid / refreezing   [m/day]
+      diag_dvpn_rnf_1d      !! meltwater pond lost to runoff    [m/day]
+   !
+   !--------------------------------------------------------------------------
 
    !! * Substitutions
@@ -52,15 +90,46 @@
       !!               
       !! ** Purpose :   change melt pond fraction and thickness
-      !!                
+      !!
+      !! Note: Melt ponds affect only radiative transfer for now
+      !!
+      !!       No heat, no salt.
+      !!       The melt water they carry is collected but 
+      !!       not removed from fw budget or released to the ocean
+      !!
+      !!       A wfx_pnd has been coded for diagnostic purposes
+      !!       It is not fully consistent yet.
+      !!
+      !!       The current diagnostic lacks a contribution from drainage
+      !!
       !!-------------------------------------------------------------------
-      !
+      !!
+      
+      ALLOCATE( diag_dvpn_mlt(jpi,jpj), diag_dvpn_lid(jpi,jpj), diag_dvpn_drn(jpi,jpj), diag_dvpn_rnf(jpi,jpj) )
+      ALLOCATE( diag_dvpn_mlt_1d(jpij), diag_dvpn_lid_1d(jpij), diag_dvpn_drn_1d(jpij), diag_dvpn_rnf_1d(jpij) )
+
+      diag_dvpn_mlt(:,:) = 0._wp    ;   diag_dvpn_drn(:,:)  = 0._wp
+      diag_dvpn_lid(:,:) = 0._wp    ;   diag_dvpn_rnf(:,:)  = 0._wp
+      diag_dvpn_mlt_1d(:) = 0._wp   ;   diag_dvpn_drn_1d(:) = 0._wp
+      diag_dvpn_lid_1d(:) = 0._wp   ;   diag_dvpn_rnf_1d(:) = 0._wp
+
       SELECT CASE ( nice_pnd )
       !
-      CASE (np_pndCST)   ;   CALL pnd_CST    !==  Constant melt ponds  ==!
+      CASE (np_pndCST)   ;   CALL pnd_CST                              !==  Constant melt ponds  ==!
          !
-      CASE (np_pndLEV)   ;   CALL pnd_LEV    !==  Level ice melt ponds  ==!
+      CASE (np_pndLEV)   ;   CALL pnd_LEV                              !==  Level ice melt ponds  ==!
+         !
+      CASE (np_pndTOPO)  ;   CALL pnd_TOPO                             !==  Topographic melt ponds  ==!
          !
       END SELECT
       !
+
+      IF( iom_use('dvpn_mlt'  ) )   CALL iom_put( 'dvpn_mlt', diag_dvpn_mlt * 100._wp * 86400._wp ) ! input from melting
+      IF( iom_use('dvpn_lid'  ) )   CALL iom_put( 'dvpn_lid', diag_dvpn_lid * 100._wp * 86400._wp ) ! exchanges with lid
+      IF( iom_use('dvpn_drn'  ) )   CALL iom_put( 'dvpn_drn', diag_dvpn_drn * 100._wp * 86400._wp ) ! vertical drainage
+      IF( iom_use('dvpn_rnf'  ) )   CALL iom_put( 'dvpn_rnf', diag_dvpn_rnf * 100._wp * 86400._wp ) ! runoff + overflow
+
+      DEALLOCATE( diag_dvpn_mlt, diag_dvpn_lid, diag_dvpn_drn, diag_dvpn_rnf )
+      DEALLOCATE( diag_dvpn_mlt_1d, diag_dvpn_lid_1d, diag_dvpn_drn_1d, diag_dvpn_rnf_1d )
+      
    END SUBROUTINE ice_thd_pnd 
 
@@ -75,5 +144,5 @@
       !!                to non-zero values when t_su = 0C
       !!
-      !! ** Tunable parameters : pond fraction (rn_apnd), pond depth (rn_hpnd)
+      !! ** Tunable parameters : Pond fraction (rn_apnd) & depth (rn_hpnd)
       !!                
       !! ** Note   : Coupling with such melt ponds is only radiative
@@ -145,11 +214,10 @@
       !!                                  a_ip/a_i = a_ip_frac = h_ip / zaspect
       !!
-      !! ** Tunable parameters : ln_pnd_lids, rn_apnd_max, rn_apnd_min
+      !! ** Tunable parameters : rn_apnd_max, rn_apnd_min, rn_pnd_flush
       !! 
-      !! ** Note       :   mostly stolen from CICE
-      !!
-      !! ** References :   Flocco and Feltham (JGR, 2007)
-      !!                   Flocco et al       (JGR, 2010)
-      !!                   Holland et al      (J. Clim, 2012)
+      !! ** Note       :   Mostly stolen from CICE but not only
+      !!
+      !! ** References :   Holland et al (J. Clim, 2012), Hunke et al (OM 2012)
+      !!                   
       !!-------------------------------------------------------------------
       REAL(wp), DIMENSION(nlay_i) ::   ztmp           ! temporary array
@@ -168,138 +236,1110 @@
       REAL(wp) ::   zfac, zdum                        ! temporary arrays
       REAL(wp) ::   z1_rhow, z1_aspect, z1_Tp         ! inverse
-      !!
-      INTEGER  ::   ji, jk                            ! loop indices
+      REAL(wp) ::   zvold                             !
+      !!
+      INTEGER  ::   ji, jj, jk, jl                    ! loop indices
+      
       !!-------------------------------------------------------------------
       z1_rhow   = 1._wp / rhow 
       z1_aspect = 1._wp / zaspect
       z1_Tp     = 1._wp / zTp 
-
-      DO ji = 1, npti
-         !                                                            !----------------------------------------------------!
-         IF( h_i_1d(ji) < rn_himin .OR. a_i_1d(ji) < epsi10 ) THEN    ! Case ice thickness < rn_himin or tiny ice fraction !
-            !                                                         !----------------------------------------------------!
-            !--- Remove ponds on thin ice or tiny ice fractions
-            a_ip_1d(ji)      = 0._wp
-            h_ip_1d(ji)      = 0._wp
-            h_il_1d(ji)      = 0._wp
-            !                                                         !--------------------------------!
-         ELSE                                                         ! Case ice thickness >= rn_himin !
-            !                                                         !--------------------------------!
-            v_ip_1d(ji) = h_ip_1d(ji) * a_ip_1d(ji)   ! retrieve volume from thickness
-            v_il_1d(ji) = h_il_1d(ji) * a_ip_1d(ji)
-            !
-            !------------------!
-            ! case ice melting !
-            !------------------!
-            !
-            !--- available meltwater for melt ponding ---!
-            zdum    = -( dh_i_sum(ji)*rhoi + dh_s_mlt(ji)*rhos ) * z1_rhow * a_i_1d(ji)
-            zfr_mlt = rn_apnd_min + ( rn_apnd_max - rn_apnd_min ) * at_i_1d(ji) !  = ( 1 - r ) = fraction of melt water that is not flushed
-            zdv_mlt = MAX( 0._wp, zfr_mlt * zdum ) ! max for roundoff errors? 
-            !
-            !--- overflow ---!
-            ! If pond area exceeds zfr_mlt * a_i_1d(ji) then reduce the pond volume
-            !    a_ip_max = zfr_mlt * a_i
-            !    => from zaspect = h_ip / (a_ip / a_i), set v_ip_max as: 
-            zv_ip_max = zfr_mlt**2 * a_i_1d(ji) * zaspect
-            zdv_mlt = MAX( 0._wp, MIN( zdv_mlt, zv_ip_max - v_ip_1d(ji) ) )
-
-            ! If pond depth exceeds half the ice thickness then reduce the pond volume
-            !    h_ip_max = 0.5 * h_i
-            !    => from zaspect = h_ip / (a_ip / a_i), set v_ip_max as: 
-            zv_ip_max = z1_aspect * a_i_1d(ji) * 0.25 * h_i_1d(ji) * h_i_1d(ji)
-            zdv_mlt = MAX( 0._wp, MIN( zdv_mlt, zv_ip_max - v_ip_1d(ji) ) )
+      
+      !-----------------------------------------------------------------------------------------------
+      !  Identify grid cells with ice
+      !-----------------------------------------------------------------------------------------------
+      at_i(:,:) = SUM( a_i, dim=3 )
+      !
+      npti = 0   ;   nptidx(:) = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF ( at_i(ji,jj) > epsi10 ) THEN
+               npti = npti + 1
+               nptidx( npti ) = (jj - 1) * jpi + ji
+            ENDIF
+         END DO
+      END DO
+      
+      !-----------------------------------------------------------------------------------------------
+      ! Prepare 1D arrays
+      !-----------------------------------------------------------------------------------------------
+
+      IF( npti > 0 ) THEN
+      
+         CALL tab_2d_1d( npti, nptidx(1:npti), wfx_snw_sum_1d(1:npti), wfx_snw_sum      )
+         CALL tab_2d_1d( npti, nptidx(1:npti), wfx_sum_1d (1:npti)   , wfx_sum          )
+         CALL tab_2d_1d( npti, nptidx(1:npti), wfx_pnd_1d (1:npti)   , wfx_pnd          )
+         
+         CALL tab_2d_1d( npti, nptidx(1:npti), diag_dvpn_mlt_1d (1:npti), diag_dvpn_mlt )
+         CALL tab_2d_1d( npti, nptidx(1:npti), diag_dvpn_drn_1d (1:npti), diag_dvpn_drn )
+         CALL tab_2d_1d( npti, nptidx(1:npti), diag_dvpn_lid_1d (1:npti), diag_dvpn_lid )
+         CALL tab_2d_1d( npti, nptidx(1:npti), diag_dvpn_rnf_1d (1:npti), diag_dvpn_rnf )
+      
+         DO jl = 1, jpl
+         
+            CALL tab_2d_1d( npti, nptidx(1:npti), a_i_1d      (1:npti), a_i      (:,:,jl) )
+            CALL tab_2d_1d( npti, nptidx(1:npti), h_i_1d      (1:npti), h_i      (:,:,jl) )
+            CALL tab_2d_1d( npti, nptidx(1:npti), t_su_1d     (1:npti), t_su     (:,:,jl) )
+            CALL tab_2d_1d( npti, nptidx(1:npti), a_ip_1d     (1:npti), a_ip     (:,:,jl) )
+            CALL tab_2d_1d( npti, nptidx(1:npti), h_ip_1d     (1:npti), h_ip     (:,:,jl) )
+            CALL tab_2d_1d( npti, nptidx(1:npti), h_il_1d     (1:npti), h_il     (:,:,jl) )
+
+            CALL tab_2d_1d( npti, nptidx(1:npti), dh_i_sum    (1:npti), dh_i_sum_2d     (:,:,jl) )
+            CALL tab_2d_1d( npti, nptidx(1:npti), dh_s_mlt    (1:npti), dh_s_mlt_2d     (:,:,jl) )
             
-            !--- Pond growing ---!
-            v_ip_1d(ji) = v_ip_1d(ji) + zdv_mlt
-            !
-            !--- Lid melting ---!
-            IF( ln_pnd_lids )   v_il_1d(ji) = MAX( 0._wp, v_il_1d(ji) - zdv_mlt ) ! must be bounded by 0
-            !
-            !--- mass flux ---!
-            IF( zdv_mlt > 0._wp ) THEN
-               zfac = zdv_mlt * rhow * r1_rdtice                        ! melt pond mass flux < 0 [kg.m-2.s-1]
-               wfx_pnd_1d(ji) = wfx_pnd_1d(ji) - zfac
-               !
-               zdum = zfac / ( wfx_snw_sum_1d(ji) + wfx_sum_1d(ji) )    ! adjust ice/snow melting flux > 0 to balance melt pond flux
-               wfx_snw_sum_1d(ji) = wfx_snw_sum_1d(ji) * (1._wp + zdum)
-               wfx_sum_1d(ji)     = wfx_sum_1d(ji)     * (1._wp + zdum)
-            ENDIF
-
-            !-------------------!
-            ! case ice freezing ! i.e. t_su_1d(ji) < (zTp+rt0)
-            !-------------------!
-            !
-            zdT = MAX( zTp+rt0 - t_su_1d(ji), 0._wp )
-            !
-            !--- Pond contraction (due to refreezing) ---!
-            IF( ln_pnd_lids ) THEN
-               !
-               !--- Lid growing and subsequent pond shrinking ---! 
-               zdv_frz = 0.5_wp * MAX( 0._wp, -v_il_1d(ji) + & ! Flocco 2010 (eq. 5) solved implicitly as aH**2 + bH + c = 0
-                  &                    SQRT( v_il_1d(ji)**2 + a_ip_1d(ji)**2 * 4._wp * rcnd_i * zdT * rdt_ice / (rLfus * rhow) ) ) ! max for roundoff errors
-               
-               ! Lid growing
-               v_il_1d(ji) = MAX( 0._wp, v_il_1d(ji) + zdv_frz )
-               
-               ! Pond shrinking
-               v_ip_1d(ji) = MAX( 0._wp, v_ip_1d(ji) - zdv_frz )
-
-            ELSE
-               ! Pond shrinking
-               v_ip_1d(ji) = v_ip_1d(ji) * EXP( 0.01_wp * zdT * z1_Tp ) ! Holland 2012 (eq. 6)
-            ENDIF
-            !
-            !--- Set new pond area and depth ---! assuming linear relation between h_ip and a_ip_frac
-            ! v_ip     = h_ip * a_ip
-            ! a_ip/a_i = a_ip_frac = h_ip / zaspect (cf Holland 2012, fitting SHEBA so that knowing v_ip we can distribute it to a_ip and h_ip)
-            a_ip_1d(ji)      = MIN( a_i_1d(ji), SQRT( v_ip_1d(ji) * z1_aspect * a_i_1d(ji) ) ) ! make sure a_ip < a_i
-            h_ip_1d(ji)      = zaspect * a_ip_1d(ji) / a_i_1d(ji)
-
-            !---------------!            
-            ! Pond flushing !
-            !---------------!
-            ! height of top of the pond above sea-level
-            zhp = ( h_i_1d(ji) * ( rau0 - rhoi ) + h_ip_1d(ji) * ( rau0 - rhow * a_ip_1d(ji) / a_i_1d(ji) ) ) * r1_rau0
+            DO jk = 1, nlay_i
+               CALL tab_2d_1d( npti, nptidx(1:npti), sz_i_1d(1:npti,jk), sz_i(:,:,jk,jl)  )
+            END DO
             
-            ! Calculate the permeability of the ice (Assur 1958, see Flocco 2010)
-            DO jk = 1, nlay_i
-               zsbr = - 1.2_wp                                  &
-                  &   - 21.8_wp    * ( t_i_1d(ji,jk) - rt0 )    &
-                  &   - 0.919_wp   * ( t_i_1d(ji,jk) - rt0 )**2 &
-                  &   - 0.0178_wp  * ( t_i_1d(ji,jk) - rt0 )**3
-               ztmp(jk) = sz_i_1d(ji,jk) / zsbr
-            END DO
-            zperm = MAX( 0._wp, 3.e-08_wp * MINVAL(ztmp)**3 )
-            
-            ! Do the drainage using Darcy's law
-            zdv_flush   = -zperm * rau0 * grav * zhp * rdt_ice / (zvisc * h_i_1d(ji)) * a_ip_1d(ji)
-            zdv_flush   = MAX( zdv_flush, -v_ip_1d(ji) )
-            v_ip_1d(ji) = v_ip_1d(ji) + zdv_flush
-            
-            !--- Set new pond area and depth ---! assuming linear relation between h_ip and a_ip_frac
-            a_ip_1d(ji)      = MIN( a_i_1d(ji), SQRT( v_ip_1d(ji) * z1_aspect * a_i_1d(ji) ) ) ! make sure a_ip < a_i
-            h_ip_1d(ji)      = zaspect * a_ip_1d(ji) / a_i_1d(ji)
-
-            !--- Corrections and lid thickness ---!
-            IF( ln_pnd_lids ) THEN
-               !--- retrieve lid thickness from volume ---!
-               IF( a_ip_1d(ji) > epsi10 ) THEN   ;   h_il_1d(ji) = v_il_1d(ji) / a_ip_1d(ji)
-               ELSE                              ;   h_il_1d(ji) = 0._wp
-               ENDIF
-               !--- remove ponds if lids are much larger than ponds ---!
-               IF ( h_il_1d(ji) > h_ip_1d(ji) * 10._wp ) THEN
+            !-----------------------------------------------------------------------------------------------
+            ! Go for ponds
+            !-----------------------------------------------------------------------------------------------
+
+            DO ji = 1, npti
+               !                                                            !----------------------------------------------------!
+               IF( h_i_1d(ji) < rn_himin .OR. a_i_1d(ji) < epsi10 ) THEN    ! Case ice thickness < rn_himin or tiny ice fraction !
+                  !                                                         !----------------------------------------------------!
+                  !--- Remove ponds on thin ice or tiny ice fractions
                   a_ip_1d(ji)      = 0._wp
                   h_ip_1d(ji)      = 0._wp
                   h_il_1d(ji)      = 0._wp
+                  !                                                         !--------------------------------!
+               ELSE                                                         ! Case ice thickness >= rn_himin !
+                  !                                                         !--------------------------------!
+                  v_ip_1d(ji) = h_ip_1d(ji) * a_ip_1d(ji)   ! retrieve volume from thickness
+                  v_il_1d(ji) = h_il_1d(ji) * a_ip_1d(ji)
+                  !
+                  !------------------!
+                  ! case ice melting !
+                  !------------------!
+                  !
+                  !--- available meltwater for melt ponding ---!
+                  zdum    = -( dh_i_sum(ji)*rhoi + dh_s_mlt(ji)*rhos ) * z1_rhow * a_i_1d(ji)
+                  zfr_mlt = rn_apnd_min + ( rn_apnd_max - rn_apnd_min ) * at_i_1d(ji) !  = ( 1 - r ) = fraction of melt water that is not flushed
+                  zdv_mlt = MAX( 0._wp, zfr_mlt * zdum ) ! max for roundoff errors? 
+                  
+                  diag_dvpn_mlt_1d(ji) = diag_dvpn_mlt_1d(ji) + zdum * r1_rdtice                      ! surface melt input diag
+                  diag_dvpn_rnf_1d(ji) = diag_dvpn_rnf_1d(ji) + ( 1. - zfr_mlt ) * zdum * r1_rdtice   ! runoff diag
+                  !
+                  !--- overflow ---!
+                  !
+                  ! 1) area driven overflow
+                  !
+                  ! If pond area exceeds zfr_mlt * a_i_1d(ji) then reduce the pond water volume
+                  !    a_ip_max = zfr_mlt * a_i
+                  !    => from zaspect = h_ip / (a_ip / a_i), set v_ip_max as: 
+                  zv_ip_max = zfr_mlt**2 * a_i_1d(ji) * zaspect
+                  zvold     = zdv_mlt
+                  zdv_mlt   = MAX( 0._wp, MIN( zdv_mlt, zv_ip_max - v_ip_1d(ji) ) )                     
+                  
+                  ! 
+                  ! 2) depth driven overflow
+                  !
+                  ! If pond depth exceeds half the ice thickness then reduce the pond volume
+                  !    h_ip_max = 0.5 * h_i
+                  !    => from zaspect = h_ip / (a_ip / a_i), set v_ip_max as: 
+                  zv_ip_max = z1_aspect * a_i_1d(ji) * 0.25 * h_i_1d(ji) * h_i_1d(ji) ! MV dimensions are wrong here or comment is unclear
+                  zdv_mlt = MAX( 0._wp, MIN( zdv_mlt, zv_ip_max - v_ip_1d(ji) ) )
+                  diag_dvpn_rnf_1d(ji) = diag_dvpn_rnf_1d(ji) + ( zdv_mlt - zvold ) * r1_rdtice       ! runoff diag - overflow contribution
+            
+                  !--- Pond growing ---!
+                  v_ip_1d(ji) = v_ip_1d(ji) + zdv_mlt
+                  !
+                  !--- Lid melting ---!
+                  IF( ln_pnd_lids )   v_il_1d(ji) = MAX( 0._wp, v_il_1d(ji) - zdv_mlt ) ! must be bounded by 0
+                  !
+                  !--- mass flux ---!
+                  ! MV I would recommend to remove that
+                  ! Since melt ponds carry no freshwater there is no point in modifying water fluxes
+                  
+                  IF( zdv_mlt > 0._wp ) THEN
+                     zfac = zdv_mlt * rhow * r1_rdtice                        ! melt pond mass flux < 0 [kg.m-2.s-1]
+                     wfx_pnd_1d(ji) = wfx_pnd_1d(ji) - zfac
+                     !
+                     zdum = zfac / ( wfx_snw_sum_1d(ji) + wfx_sum_1d(ji) )    ! adjust ice/snow melting flux > 0 to balance melt pond flux
+                     wfx_snw_sum_1d(ji) = wfx_snw_sum_1d(ji) * (1._wp + zdum)
+                     wfx_sum_1d(ji)     = wfx_sum_1d(ji)     * (1._wp + zdum)
+                  ENDIF
+
+                  !-------------------!
+                  ! case ice freezing ! i.e. t_su_1d(ji) < (zTp+rt0)
+                  !-------------------!
+                  !
+                  zdT = MAX( zTp+rt0 - t_su_1d(ji), 0._wp )
+                  !
+                  !--- Pond contraction (due to refreezing) ---!
+                  zvold       = v_ip_1d(ji) ! for diag
+
+                  IF( ln_pnd_lids ) THEN
+                     !
+                     !--- Lid growing and subsequent pond shrinking ---! 
+                     zdv_frz = 0.5_wp * MAX( 0._wp, -v_il_1d(ji) + & ! Flocco 2010 (eq. 5) solved implicitly as aH**2 + bH + c = 0
+                        &                    SQRT( v_il_1d(ji)**2 + a_ip_1d(ji)**2 * 4._wp * rcnd_i * zdT * rdt_ice / (rLfus * rhow) ) ) ! max for roundoff errors
+               
+                     ! Lid growing
+                     v_il_1d(ji) = MAX( 0._wp, v_il_1d(ji) + zdv_frz )
+               
+                     ! Pond shrinking
+                     v_ip_1d(ji) = MAX( 0._wp, v_ip_1d(ji) - zdv_frz )
+                     
+                  ELSE
+                  
+                     ! Pond shrinking
+                     v_ip_1d(ji) = v_ip_1d(ji) * EXP( 0.01_wp * zdT * z1_Tp ) ! Holland 2012 (eq. 6)
+                     
+                  ENDIF
+
+                  diag_dvpn_lid_1d(ji) = diag_dvpn_lid_1d(ji) + ( v_ip_1d(ji) - zvold ) * r1_rdtice   ! shrinking counted as lid diagnostic
+
+                  !
+                  !--- Set new pond area and depth ---! assuming linear relation between h_ip and a_ip_frac
+                  ! v_ip     = h_ip * a_ip
+                  ! a_ip/a_i = a_ip_frac = h_ip / zaspect (cf Holland 2012, fitting SHEBA so that knowing v_ip we can distribute it to a_ip and h_ip)
+                  a_ip_1d(ji)      = MIN( a_i_1d(ji), SQRT( v_ip_1d(ji) * z1_aspect * a_i_1d(ji) ) ) ! make sure a_ip < a_i
+                  h_ip_1d(ji)      = zaspect * a_ip_1d(ji) / a_i_1d(ji)
+
+                  !------------------------------------------------!            
+                  ! Pond drainage through brine network (flushing) !
+                  !------------------------------------------------!
+                  ! height of top of the pond above sea-level
+                  zhp = ( h_i_1d(ji) * ( rau0 - rhoi ) + h_ip_1d(ji) * ( rau0 - rhow * a_ip_1d(ji) / a_i_1d(ji) ) ) * r1_rau0
+            
+                  ! Calculate the permeability of the ice (Assur 1958, see Flocco 2010)
+                  DO jk = 1, nlay_i
+                     ! MV Assur is inconsistent with SI3
+                     zsbr = - 1.2_wp                                  &
+                        &   - 21.8_wp    * ( t_i_1d(ji,jk) - rt0 )    &
+                        &   - 0.919_wp   * ( t_i_1d(ji,jk) - rt0 )**2 &
+                        &   - 0.0178_wp  * ( t_i_1d(ji,jk) - rt0 )**3
+                     ! MV linear expression more consistent & simpler              zsbr = - ( t_i_1d(ji,jk) - rt0 ) / rTmlt
+                     ztmp(jk) = sz_i_1d(ji,jk) / zsbr
+                  END DO
+                  zperm = MAX( 0._wp, 3.e-08_wp * MINVAL(ztmp)**3 )
+            
+                  ! Do the drainage using Darcy's law
+                  zdv_flush   = - zperm * rau0 * grav * zhp * rdt_ice / (zvisc * h_i_1d(ji)) * a_ip_1d(ji) * rn_pnd_flush
+                  zdv_flush   = MAX( zdv_flush, -v_ip_1d(ji) )
+                  ! zdv_flush   = 0._wp ! MV remove pond drainage for now
+                  v_ip_1d(ji) = v_ip_1d(ji) + zdv_flush
+                  
+                  diag_dvpn_drn_1d(ji) = diag_dvpn_drn_1d(ji) + zdv_flush * r1_rdtice   ! shrinking counted as lid diagnostic
+            
+                  ! MV --- why pond drainage does not give back water into freshwater flux ?            
+                  !--- Set new pond area and depth ---! assuming linear relation between h_ip and a_ip_frac
+                  a_ip_1d(ji)      = MIN( a_i_1d(ji), SQRT( v_ip_1d(ji) * z1_aspect * a_i_1d(ji) ) ) ! make sure a_ip < a_i
+                  h_ip_1d(ji)      = zaspect * a_ip_1d(ji) / a_i_1d(ji)
+
+                  !--- Corrections and lid thickness ---!
+                  IF( ln_pnd_lids ) THEN
+                     !--- retrieve lid thickness from volume ---!
+                     IF( a_ip_1d(ji) > epsi10 ) THEN   ;   h_il_1d(ji) = v_il_1d(ji) / a_ip_1d(ji)
+                     ELSE                              ;   h_il_1d(ji) = 0._wp
+                     ENDIF
+                     !--- remove ponds if lids are much larger than ponds ---!
+                     IF ( h_il_1d(ji) > h_ip_1d(ji) * 10._wp ) THEN
+                        a_ip_1d(ji)      = 0._wp
+                        h_ip_1d(ji)      = 0._wp
+                        h_il_1d(ji)      = 0._wp
+                     ENDIF
+                  ENDIF
+                  !
                ENDIF
+               
+            END DO ! ji
+
+            !-----------------------------------------------------------------------------------------------
+            ! Retrieve 2D arrays
+            !-----------------------------------------------------------------------------------------------
+            
+            v_ip_1d(1:npti) = h_ip_1d(1:npti) * a_ip_1d(1:npti)
+            v_il_1d(1:npti) = h_il_1d(1:npti) * a_ip_1d(1:npti)
+            
+            CALL tab_1d_2d( npti, nptidx(1:npti), a_ip_1d     (1:npti), a_ip     (:,:,jl) )
+            CALL tab_1d_2d( npti, nptidx(1:npti), h_ip_1d     (1:npti), h_ip     (:,:,jl) )
+            CALL tab_1d_2d( npti, nptidx(1:npti), h_il_1d     (1:npti), h_il     (:,:,jl) )
+            CALL tab_1d_2d( npti, nptidx(1:npti), v_ip_1d     (1:npti), v_ip     (:,:,jl) )
+            CALL tab_1d_2d( npti, nptidx(1:npti), v_il_1d     (1:npti), v_il     (:,:,jl) )
+            DO jk = 1, nlay_i
+               CALL tab_1d_2d( npti, nptidx(1:npti), sz_i_1d(1:npti,jk), sz_i(:,:,jk,jl)  )
+            END DO
+   
+         END DO ! ji
+                  
+         CALL tab_1d_2d( npti, nptidx(1:npti), wfx_snw_sum_1d(1:npti), wfx_snw_sum )
+         CALL tab_1d_2d( npti, nptidx(1:npti), wfx_sum_1d (1:npti), wfx_sum        )
+         CALL tab_1d_2d( npti, nptidx(1:npti), wfx_pnd_1d (1:npti), wfx_pnd        )
+         
+         CALL tab_1d_2d( npti, nptidx(1:npti), diag_dvpn_mlt_1d (1:npti), diag_dvpn_mlt        )
+         CALL tab_1d_2d( npti, nptidx(1:npti), diag_dvpn_drn_1d (1:npti), diag_dvpn_drn        )
+         CALL tab_1d_2d( npti, nptidx(1:npti), diag_dvpn_lid_1d (1:npti), diag_dvpn_lid        )
+         CALL tab_1d_2d( npti, nptidx(1:npti), diag_dvpn_rnf_1d (1:npti), diag_dvpn_rnf        )                  
+                           
+      !
+      ENDIF
+      
+   END SUBROUTINE pnd_LEV
+   
+   SUBROUTINE pnd_TOPO    
+                                         
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE pnd_TOPO  ***
+      !!
+      !! ** Purpose :   Compute melt pond evolution based on the ice
+      !!                topography inferred from the ice thickness distribution
+      !!
+      !! ** Method  :   This code is initially based on Flocco and Feltham
+      !!                (2007) and Flocco et al. (2010). 
+      !!
+      !!                - Calculate available pond water base on surface meltwater
+      !!                - Redistribute water as a function of topography, drain water
+      !!                - Exchange water with the lid
+      !!
+      !! ** Tunable parameters :
+      !!
+      !! ** Note :
+      !!
+      !! ** References
+      !!
+      !!    Flocco, D. and D. L. Feltham, 2007.  A continuum model of melt pond
+      !!    evolution on Arctic sea ice.  J. Geophys. Res. 112, C08016, doi:
+      !!    10.1029/2006JC003836.
+      !!
+      !!    Flocco, D., D. L. Feltham and A. K. Turner, 2010.  Incorporation of
+      !!    a physically based melt pond scheme into the sea ice component of a
+      !!    climate model.  J. Geophys. Res. 115, C08012,
+      !!    doi: 10.1029/2009JC005568.
+      !!
+      !!-------------------------------------------------------------------
+
+      ! local variables
+      REAL(wp) :: &
+         zdHui,   &      ! change in thickness of ice lid (m)
+         zomega,  &      ! conduction
+         zdTice,  &      ! temperature difference across ice lid (C)
+         zdvice,  &      ! change in ice volume (m)
+         zTavg,   &      ! mean surface temperature across categories (C)
+         zfsurf,  &      ! net heat flux, excluding conduction and transmitted radiation (W/m2)
+         zTp,     &      ! pond freezing temperature (C)
+         zrhoi_L, &      ! volumetric latent heat of sea ice (J/m^3)
+         zfr_mlt, &      ! fraction and volume of available meltwater retained for melt ponding
+         z1_rhow, &      ! inverse water density
+         zv_pnd  , &     ! volume of meltwater contributing to ponds
+         zv_mlt          ! total amount of meltwater produced
+
+      REAL(wp), DIMENSION(jpi,jpj) ::   zvolp_ini, & !! total melt pond water available before redistribution and drainage
+                                        zvolp    , & !! total melt pond water volume
+                                        zvolp_res    !! remaining melt pond water available after drainage
+                                        
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   z1_a_i
+
+      INTEGER  ::   ji, jj, jk, jl                    ! loop indices
+
+      INTEGER  ::   i_test
+
+      ! Note
+      ! equivalent for CICE translation
+      ! a_ip      -> apond
+      ! a_ip_frac -> apnd
+      
+      !---------------------------------------------------------------
+      ! Initialise
+      !---------------------------------------------------------------
+
+      ! Parameters & constants (move to parameters)
+      zrhoi_L   = rhoi * rLfus      ! volumetric latent heat (J/m^3)
+      zTp       = rt0 - 0.15_wp          ! pond freezing point, slightly below 0C (ponds are bid saline)
+      z1_rhow   = 1._wp / rhow 
+
+      ! Set required ice variables (hard-coded here for now)
+!      zfpond(:,:) = 0._wp          ! contributing freshwater flux (?) 
+      
+      at_i (:,:) = SUM( a_i (:,:,:), dim=3 ) ! ice fraction
+      vt_i (:,:) = SUM( v_i (:,:,:), dim=3 ) ! volume per grid area
+      vt_ip(:,:) = SUM( v_ip(:,:,:), dim=3 ) ! pond volume per grid area
+      vt_il(:,:) = SUM( v_il(:,:,:), dim=3 ) ! lid volume per grid area
+      
+      ! thickness
+      WHERE( a_i(:,:,:) > epsi20 )   ;   z1_a_i(:,:,:) = 1._wp / a_i(:,:,:)
+      ELSEWHERE                      ;   z1_a_i(:,:,:) = 0._wp
+      END WHERE
+      h_i(:,:,:) = v_i (:,:,:) * z1_a_i(:,:,:)
+      
+      !---------------------------------------------------------------
+      ! Change 2D to 1D
+      !---------------------------------------------------------------
+      ! MV 
+      ! a less computing-intensive version would have 2D-1D passage here
+      ! use what we have in iceitd.F90 (incremental remapping)
+
+      !--------------------------------------------------------------
+      ! Collect total available pond water volume
+      !--------------------------------------------------------------
+      ! Assuming that meltwater (+rain in principle) runsoff the surface
+      ! Holland et al (2012) suggest that the fraction of runoff decreases with total ice fraction
+      ! I cite her words, they are very talkative
+      ! "grid cells with very little ice cover (and hence more open water area) 
+      ! have a higher runoff fraction to rep- resent the greater proximity of ice to open water."
+      ! "This results in the same runoff fraction r for each ice category within a grid cell"
+      
+      zvolp(:,:) = 0._wp
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+                 
+               IF ( a_i(ji,jj,jl) > epsi10 ) THEN
+            
+                  !--- Available and contributing meltwater for melt ponding ---!
+                  zv_mlt  = - ( dh_i_sum_2d(ji,jj,jl) * rhoi + dh_s_mlt_2d(ji,jj,jl) * rhos ) &        ! available volume of surface melt water per grid area
+                     &    * z1_rhow * a_i(ji,jj,jl)
+                      ! MV -> could move this directly in ice_thd_dh and get an array (ji,jj,jl) for surface melt water volume per grid area
+                  zfr_mlt = rn_apnd_min + ( rn_apnd_max - rn_apnd_min ) * at_i(ji,jj)                  ! fraction of surface meltwater going to ponds
+                  zv_pnd  = zfr_mlt * zv_mlt                                                           ! contributing meltwater volume for category jl
+
+                  diag_dvpn_mlt(ji,jj) = diag_dvpn_mlt(ji,jj) + zv_mlt * r1_rdtice                     ! diags
+                  diag_dvpn_rnf(ji,jj) = diag_dvpn_rnf(ji,jj) + ( 1. - zfr_mlt ) * zv_mlt * r1_rdtice   
+
+                  !--- Create possible new ponds
+                  ! if pond does not exist, create new pond over full ice area
+                  !IF ( a_ip_frac(ji,jj,jl) < epsi10 ) THEN
+                  IF ( a_ip(ji,jj,jl) < epsi10 ) THEN
+                     a_ip(ji,jj,jl)       = a_i(ji,jj,jl)
+                     a_ip_frac(ji,jj,jl)  = 1.0_wp    ! pond fraction of sea ice (apnd for CICE)
+                  ENDIF
+                  
+                  !--- Deepen existing ponds with no change in pond fraction, before redistribution and drainage
+                  v_ip(ji,jj,jl) = v_ip(ji,jj,jl) +  zv_pnd                                            ! use pond water to increase thickness
+                  h_ip(ji,jj,jl) = v_ip(ji,jj,jl) / a_ip(ji,jj,jl)
+                  
+                  !--- Total available pond water volume (pre-existing + newly produced)j
+                  zvolp(ji,jj)   = zvolp(ji,jj)   + v_ip(ji,jj,jl) 
+!                 zfpond(ji,jj) = zfpond(ji,jj) + zpond * a_ip_frac(ji,jj,jl) ! useless for now
+                   
+               ENDIF ! a_i
+
+            END DO! jl            
+         END DO ! jj
+      END DO ! ji
+
+      zvolp_ini(:,:) = zvolp(:,:)
+                  
+      !--------------------------------------------------------------
+      ! Redistribute and drain water from ponds
+      !--------------------------------------------------------------   
+      CALL ice_thd_pnd_area( zvolp, zvolp_res )
+                                   
+      !--------------------------------------------------------------
+      ! Melt pond lid growth and melt
+      !--------------------------------------------------------------   
+      
+      IF( ln_pnd_lids ) THEN
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+            IF ( at_i(ji,jj) > 0.01 .AND. hm_i(ji,jj) > zhi_min .AND. zvolp_ini(ji,jj) > zvp_min * at_i(ji,jj) ) THEN
+                  
+               !--------------------------
+               ! Pond lid growth and melt
+               !--------------------------
+               ! Mean surface temperature
+               zTavg = 0._wp
+               DO jl = 1, jpl
+                  zTavg = zTavg + t_su(ji,jj,jl)*a_i(ji,jj,jl)
+               END DO
+!! EWB: bug here - should be divided by at_i(ji,jj) but zTavg is not used anywhere
+               zTavg = zTavg / a_i(ji,jj,jl) !!! could get a division by zero here
+         
+               DO jl = 1, jpl-1
+            
+                  IF ( v_il(ji,jj,jl) > epsi10 ) THEN
+               
+                     !----------------------------------------------------------------
+                     ! Lid melting: floating upper ice layer melts in whole or part
+                     !----------------------------------------------------------------
+                     ! Use Tsfc for each category
+                     IF ( t_su(ji,jj,jl) > zTp ) THEN
+
+                        zdvice = MIN( dh_i_sum_2d(ji,jj,jl)*a_ip(ji,jj,jl), v_il(ji,jj,jl) )
+                        
+                        IF ( zdvice > epsi10 ) THEN
+                        
+                           v_il (ji,jj,jl) = v_il (ji,jj,jl)   - zdvice
+                           v_ip(ji,jj,jl)  = v_ip(ji,jj,jl)    + zdvice ! MV: not sure i understand dh_i_sum seems counted twice - 
+                                                                        ! as it is already counted in surface melt
+!                          zvolp(ji,jj)     = zvolp(ji,jj)     + zdvice ! pointless to calculate total volume (done in icevar)
+!                          zfpond(ji,jj)    = fpond(ji,jj)     + zdvice ! pointless to follow fw budget (ponds have no fw)
+                     
+                           IF ( v_il(ji,jj,jl) < epsi10 .AND. v_ip(ji,jj,jl) > epsi10) THEN
+                           ! ice lid melted and category is pond covered
+                              v_ip(ji,jj,jl)  = v_ip(ji,jj,jl)  + v_il(ji,jj,jl) 
+!                             zfpond(ji,jj)    = zfpond (ji,jj)    + v_il(ji,jj,jl) 
+                              v_il(ji,jj,jl)   = 0._wp
+                           ENDIF
+                           h_ip(ji,jj,jl) = v_ip(ji,jj,jl) / a_ip(ji,jj,jl) !!! could get a division by zero here
+                           
+                           diag_dvpn_lid(ji,jj) = diag_dvpn_lid(ji,jj) + zdvice   ! diag
+                           
+                        ENDIF
+                        
+                     !----------------------------------------------------------------
+                     ! Freeze pre-existing lid 
+                     !----------------------------------------------------------------
+
+                     ELSE IF ( v_ip(ji,jj,jl) > epsi10 ) THEN ! Tsfcn(i,j,n) <= Tp
+
+                        ! differential growth of base of surface floating ice layer
+                        ! zdTice = MAX( - t_su(ji,jj,jl) - zTd , 0._wp ) ! > 0  ! line valid for temp in C 
+                        zdTice = MAX( - ( t_su(ji,jj,jl) - zTd ) , 0._wp ) ! > 0   
+                        zomega = rcnd_i * zdTice / zrhoi_L
+                        zdHui  = SQRT( 2._wp * zomega * rdt_ice + ( v_il(ji,jj,jl) / a_i(ji,jj,jl) )**2 ) &
+                               - v_il(ji,jj,jl) / a_i(ji,jj,jl)
+                        zdvice = min( zdHui*a_ip(ji,jj,jl) , v_ip(ji,jj,jl) )
+                  
+                        IF ( zdvice > epsi10 ) THEN
+                           v_il (ji,jj,jl)  = v_il(ji,jj,jl)   + zdvice
+                           v_ip(ji,jj,jl)   = v_ip(ji,jj,jl)   - zdvice
+!                          zvolp(ji,jj)    = zvolp(ji,jj)     - zdvice
+!                          zfpond(ji,jj)   = zfpond(ji,jj)    - zdvice
+                           h_ip(ji,jj,jl)   = v_ip(ji,jj,jl) / a_ip(ji,jj,jl)
+                           
+                           diag_dvpn_lid(ji,jj) = diag_dvpn_lid(ji,jj) - zdvice    ! diag
+                           
+                        ENDIF
+                  
+                     ENDIF ! Tsfcn(i,j,n)
+
+                  !----------------------------------------------------------------
+                  ! Freeze new lids
+                  !----------------------------------------------------------------
+                  !  upper ice layer begins to form
+                  ! note: albedo does not change
+
+                  ELSE ! v_il < epsi10
+                    
+                     ! thickness of newly formed ice
+                     ! the surface temperature of a meltpond is the same as that
+                     ! of the ice underneath (0C), and the thermodynamic surface 
+                     ! flux is the same
+                     
+                     !!! we need net surface energy flux, excluding conduction
+                     !!! fsurf is summed over categories in CICE
+                     !!! we have the category-dependent flux, let us use it ?
+                     zfsurf = qns_ice(ji,jj,jl) + qsr_ice(ji,jj,jl)                     
+                     zdHui  = MAX ( -zfsurf * rdt_ice / zrhoi_L , 0._wp )
+                     zdvice = MIN ( zdHui * a_ip(ji,jj,jl) , v_ip(ji,jj,jl) )
+
+                     IF ( zdvice > epsi10 ) THEN
+
+                        v_il (ji,jj,jl)  = v_il(ji,jj,jl)   + zdvice
+                        v_ip(ji,jj,jl)   = v_ip(ji,jj,jl)   - zdvice
+                        diag_dvpn_lid(ji,jj) = diag_dvpn_lid(ji,jj) - zdvice      ! diag
+
+!                       zvolp(ji,jj)     = zvolp(ji,jj)     - zdvice
+!                       zfpond(ji,jj)    = zfpond(ji,jj)    - zdvice
+
+                        h_ip(ji,jj,jl)   = v_ip(ji,jj,jl) / a_ip(ji,jj,jl) ! MV - in principle, this is useless as h_ip is computed in icevar
+                     ENDIF
+               
+                  ENDIF  ! v_il
+            
+               END DO ! jl
+
+            ELSE  ! remove ponds on thin ice
+
+               v_ip(ji,jj,:) = 0._wp
+               v_il(ji,jj,:) = 0._wp
+!              zfpond(ji,jj) = zfpond(ji,jj)- zvolp(ji,jj)
+!		            zvolp(ji,jj)    = 0._wp         
+
             ENDIF
-            !
-         ENDIF
-         
-      END DO
-      !
-   END SUBROUTINE pnd_LEV
-
+
+      END DO   ! jj
+   END DO   ! ji
+
+      ENDIF ! ln_pnd_lids
+
+      !---------------------------------------------------------------
+      ! Clean-up variables (probably duplicates what icevar would do)
+      !---------------------------------------------------------------
+      ! MV comment
+      ! In the ideal world, the lines above should update only v_ip, a_ip, v_il
+      ! icevar should recompute all other variables (if needed at all)
+
+      DO jl = 1, jpl
+
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+!              ! zap lids on small ponds
+!              IF ( a_i(ji,jj,jl) > epsi10 .AND. v_ip(ji,jj,jl) < epsi10 &
+!                                          .AND. v_il(ji,jj,jl) > epsi10) THEN
+!                 v_il(ji,jj,jl) = 0._wp ! probably uselesss now since we get zap_small
+!              ENDIF
+      
+               ! recalculate equivalent pond variables
+               IF ( a_ip(ji,jj,jl) > epsi10) THEN
+                  h_ip(ji,jj,jl)      = v_ip(ji,jj,jl) / a_ip(ji,jj,jl)
+                  a_ip_frac(ji,jj,jl) = a_ip(ji,jj,jl) / a_i(ji,jj,jl) ! MV in principle, useless as computed in icevar
+                  h_il(ji,jj,jl) = v_il(ji,jj,jl) / a_ip(ji,jj,jl) ! MV in principle, useless as computed in icevar
+               ENDIF
+!                 h_ip(ji,jj,jl)      = 0._wp ! MV in principle, useless as computed in icevar
+!                 h_il(ji,jj,jl)      = 0._wp ! MV in principle, useless as omputed in icevar
+!              ENDIF
+               
+            END DO   ! ji
+         END DO   ! jj
+
+      END DO   ! jl
+
+   END SUBROUTINE pnd_TOPO
+
+   
+   SUBROUTINE ice_thd_pnd_area( zvolp , zdvolp )
+
+       !!-------------------------------------------------------------------
+       !!                ***  ROUTINE ice_thd_pnd_area ***
+       !!
+       !! ** Purpose : Given the total volume of available pond water, 
+       !!              redistribute and drain water
+       !!
+       !! ** Method
+       !!
+       !-----------|
+       !           |
+       !           |-----------|
+       !___________|___________|______________________________________sea-level
+       !           |           |
+       !           |           |---^--------|
+       !           |           |   |        |
+       !           |           |   |        |-----------|              |-------
+       !           |           |   | alfan  |           |              |
+       !           |           |   |        |           |--------------|
+       !           |           |   |        |           |              |
+       !---------------------------v-------------------------------------------
+       !           |           |   ^        |           |              |
+       !           |           |   |        |           |--------------|
+       !           |           |   | betan  |           |              |
+       !           |           |   |        |-----------|              |-------
+       !           |           |   |        |
+       !           |           |---v------- |
+       !           |           |
+       !           |-----------|
+       !           |
+       !-----------|
+       !
+       !!
+       !!------------------------------------------------------------------
+       
+       REAL (wp), DIMENSION(jpi,jpj), INTENT(INOUT) :: &
+          zvolp,                                       &  ! total available pond water
+          zdvolp                                          ! remaining meltwater after redistribution
+
+       INTEGER ::  &
+          ns,      &
+          m_index, &
+          permflag
+
+       REAL (wp), DIMENSION(jpl) :: &
+          hicen, &
+          hsnon, &
+          asnon, &
+          alfan, &
+          betan, &
+          cum_max_vol, &
+          reduced_aicen
+
+       REAL (wp), DIMENSION(0:jpl) :: &
+          cum_max_vol_tmp
+
+       REAL (wp) :: &
+          hpond, &
+          drain, &
+          floe_weight, &
+          pressure_head, &
+          hsl_rel, &
+          deltah, &
+          perm, &
+          msno
+
+       REAL (wp), parameter :: &
+          viscosity = 1.79e-3_wp     ! kinematic water viscosity in kg/m/s
+
+       INTEGER  ::   ji, jj, jk, jl                    ! loop indices
+
+       a_ip(:,:,:) = 0._wp
+       h_ip(:,:,:) = 0._wp
+ 
+       DO jj = 1, jpj
+          DO ji = 1, jpi
+ 
+             IF ( at_i(ji,jj) > 0.01 .AND. hm_i(ji,jj) > zhi_min .AND. zvolp(ji,jj) > zvp_min * at_i(ji,jj) ) THEN
+ 
+        !-------------------------------------------------------------------
+        ! initialize
+        !-------------------------------------------------------------------
+ 
+        DO jl = 1, jpl
+ 
+           !----------------------------------------
+           ! compute the effective snow fraction
+           !----------------------------------------
+ 
+           IF (a_i(ji,jj,jl) < epsi10)  THEN
+              hicen(jl) =  0._wp
+              hsnon(jl) =  0._wp
+              reduced_aicen(jl) = 0._wp
+              asnon(jl) = 0._wp         !js: in CICE 5.1.2: make sense as the compiler may not initiate the variables
+           ELSE
+              hicen(jl) = v_i(ji,jj,jl) / a_i(ji,jj,jl)
+              hsnon(jl) = v_s(ji,jj,jl) / a_i(ji,jj,jl)
+              reduced_aicen(jl) = 1._wp ! n=jpl
+ 
+              !js: initial code in NEMO_DEV
+              !IF (n < jpl) reduced_aicen(jl) = aicen(jl) &
+              !                     * (-0.024_wp*hicen(jl) + 0.832_wp)
+ 
+              !js: from CICE 5.1.2: this limit reduced_aicen to 0.2 when hicen is too large
+              IF (jl < jpl) reduced_aicen(jl) = a_i(ji,jj,jl) & 
+                                   * max(0.2_wp,(-0.024_wp*hicen(jl) + 0.832_wp))
+ 
+              asnon(jl) = reduced_aicen(jl)  ! effective snow fraction (empirical)
+              ! MV should check whether this makes sense to have the same effective snow fraction in here
+              ! OLI: it probably doesn't
+           END IF
+ 
+  ! This choice for alfa and beta ignores hydrostatic equilibium of categories.
+  ! Hydrostatic equilibium of the entire ITD is accounted for below, assuming
+  ! a surface topography implied by alfa=0.6 and beta=0.4, and rigidity across all
+  ! categories.  alfa and beta partition the ITD - they are areas not thicknesses!
+  ! Multiplying by hicen, alfan and betan (below) are thus volumes per unit area.
+  ! Here, alfa = 60% of the ice area (and since hice is constant in a category,
+  ! alfan = 60% of the ice volume) in each category lies above the reference line,
+  ! and 40% below. Note: p6 is an arbitrary choice, but alfa+beta=1 is required.
+ 
+  ! MV:
+  ! Note that this choice is not in the original FF07 paper and has been adopted in CICE
+  ! No reason why is explained in the doc, but I guess there is a reason. I'll try to investigate, maybe
+ 
+  ! Where does that choice come from ? => OLI : Coz' Chuck Norris said so...
+ 
+           alfan(jl) = 0.6 * hicen(jl)
+           betan(jl) = 0.4 * hicen(jl)
+ 
+           cum_max_vol(jl)     = 0._wp
+           cum_max_vol_tmp(jl) = 0._wp
+ 
+        END DO ! jpl
+ 
+        cum_max_vol_tmp(0) = 0._wp
+        drain = 0._wp
+        zdvolp(ji,jj) = 0._wp
+ 
+        !----------------------------------------------------------
+        ! Drain overflow water, update pond fraction and volume
+        !----------------------------------------------------------
+ 
+        !--------------------------------------------------------------------------
+        ! the maximum amount of water that can be contained up to each ice category
+        !--------------------------------------------------------------------------
+        ! If melt ponds are too deep to be sustainable given the ITD (OVERFLOW)
+        ! Then the excess volume cum_max_vol(jl) drains out of the system
+        ! It should be added to wfx_pnd_out
+ 
+        DO jl = 1, jpl-1 ! last category can not hold any volume
+ 
+           IF (alfan(jl+1) >= alfan(jl) .AND. alfan(jl+1) > 0._wp ) THEN
+ 
+              ! total volume in level including snow
+              cum_max_vol_tmp(jl) = cum_max_vol_tmp(jl-1) + &
+                 (alfan(jl+1) - alfan(jl)) * sum(reduced_aicen(1:jl))
+ 
+              ! subtract snow solid volumes from lower categories in current level
+              DO ns = 1, jl
+                 cum_max_vol_tmp(jl) = cum_max_vol_tmp(jl) &
+                    - rhos/rhow * &     ! free air fraction that can be filled by water
+                      asnon(ns)  * &    ! effective areal fraction of snow in that category
+                      max(min(hsnon(ns)+alfan(ns)-alfan(jl), alfan(jl+1)-alfan(jl)), 0._wp)
+              END DO
+ 
+           ELSE ! assume higher categories unoccupied
+              cum_max_vol_tmp(jl) = cum_max_vol_tmp(jl-1)
+           END IF
+           !IF (cum_max_vol_tmp(jl) < z0) THEN
+           !   CALL abort_ice('negative melt pond volume')
+           !END IF
+        END DO
+        cum_max_vol_tmp(jpl) = cum_max_vol_tmp(jpl-1)  ! last category holds no volume
+        cum_max_vol  (1:jpl) = cum_max_vol_tmp(1:jpl)
+ 
+        !----------------------------------------------------------------
+        ! is there more meltwater than can be held in the floe?
+        !----------------------------------------------------------------
+        IF (zvolp(ji,jj) >= cum_max_vol(jpl)) THEN
+           drain = zvolp(ji,jj) - cum_max_vol(jpl) + epsi10
+           zvolp(ji,jj) = zvolp(ji,jj) - drain ! update meltwater volume available
+ 
+           diag_dvpn_rnf(ji,jj) = - drain      ! diag - overflow counted in the runoff part (arbitrary choice)
+           
+           zdvolp(ji,jj) = drain         ! this is the drained water
+           IF (zvolp(ji,jj) < epsi10) THEN
+              zdvolp(ji,jj) = zdvolp(ji,jj) + zvolp(ji,jj)
+              zvolp(ji,jj) = 0._wp
+           END IF
+        END IF
+ 
+        ! height and area corresponding to the remaining volume
+        ! routine leaves zvolp unchanged
+        CALL ice_thd_pnd_depth(reduced_aicen, asnon, hsnon, alfan, zvolp(ji,jj), cum_max_vol, hpond, m_index)
+ 
+        DO jl = 1, m_index
+           !h_ip(jl) = hpond - alfan(jl) + alfan(1) ! here oui choulde update
+           !                                         !  volume instead, no ?
+           h_ip(ji,jj,jl) = max((hpond - alfan(jl) + alfan(1)), 0._wp)      !js: from CICE 5.1.2
+           a_ip(ji,jj,jl) = reduced_aicen(jl)
+           ! in practise, pond fraction depends on the empirical snow fraction
+           ! so in turn on ice thickness
+        END DO
+        !zapond = sum(a_ip(1:m_index))     !js: from CICE 5.1.2; not in Icepack1.1.0-6-gac6195d
+ 
+        !------------------------------------------------------------------------
+        ! Drainage through brine network (permeability)
+        !------------------------------------------------------------------------
+        !!! drainage due to ice permeability - Darcy's law
+ 
+        ! sea water level
+        msno = 0._wp 
+        DO jl = 1 , jpl
+          msno = msno + v_s(ji,jj,jl) * rhos
+        END DO
+        floe_weight = ( msno + rhoi*vt_i(ji,jj) + rau0*zvolp(ji,jj) ) / at_i(ji,jj)
+        hsl_rel = floe_weight / rau0 &
+                - ( ( sum(betan(:)*a_i(ji,jj,:)) / at_i(ji,jj) ) + alfan(1) )
+ 
+        deltah = hpond - hsl_rel
+        pressure_head = grav * rau0 * max(deltah, 0._wp)
+ 
+        ! drain if ice is permeable
+        permflag = 0
+ 
+        IF (pressure_head > 0._wp) THEN
+           DO jl = 1, jpl-1
+              IF ( hicen(jl) /= 0._wp ) THEN
+ 
+              !IF (hicen(jl) > 0._wp) THEN           !js: from CICE 5.1.2
+ 
+                 perm = 0._wp ! MV ugly dummy patch
+                 CALL ice_thd_pnd_perm(t_i(ji,jj,:,jl),  sz_i(ji,jj,:,jl), perm) ! bof 
+                 IF (perm > 0._wp) permflag = 1
+ 
+                 drain = perm*a_ip(ji,jj,jl)*pressure_head*rdt_ice / &
+                                          (viscosity*hicen(jl))
+                 zdvolp(ji,jj) = zdvolp(ji,jj) + min(drain, zvolp(ji,jj))
+                 zvolp(ji,jj) = max(zvolp(ji,jj) - drain, 0._wp)
+ 
+                 diag_dvpn_drn(ji,jj) = - drain ! diag (could be better coded)
+                 
+                 IF (zvolp(ji,jj) < epsi10) THEN
+                    zdvolp(ji,jj) = zdvolp(ji,jj) + zvolp(ji,jj)
+                    zvolp(ji,jj) = 0._wp
+                 END IF
+             END IF
+          END DO
+ 
+           ! adjust melt pond dimensions
+           IF (permflag > 0) THEN
+              ! recompute pond depth
+             CALL ice_thd_pnd_depth(reduced_aicen, asnon, hsnon, alfan, zvolp(ji,jj), cum_max_vol, hpond, m_index)
+              DO jl = 1, m_index
+                 h_ip(ji,jj,jl) = hpond - alfan(jl) + alfan(1)
+                 a_ip(ji,jj,jl) = reduced_aicen(jl)
+              END DO
+              !zapond = sum(a_ip(1:m_index))       !js: from CICE 5.1.2; not in Icepack1.1.0-6-gac6195d
+           END IF
+        END IF ! pressure_head
+ 
+        !-------------------------------
+        ! remove water from the snow
+        !-------------------------------
+        !------------------------------------------------------------------------
+        ! total melt pond volume in category does not include snow volume
+        ! snow in melt ponds is not melted
+        !------------------------------------------------------------------------
+        
+        ! MV here, it seems that we remove some meltwater from the ponds, but I can't really tell
+        ! how much, so I did not diagnose it
+        ! so if there is a problem here, nobody is going to see it...
+        
+ 
+        ! Calculate pond volume for lower categories
+        DO jl = 1,m_index-1
+           v_ip(ji,jj,jl) = a_ip(ji,jj,jl) * h_ip(ji,jj,jl) & ! what is not in the snow
+                          - (rhos/rhow) * asnon(jl) * min(hsnon(jl), h_ip(ji,jj,jl))
+        END DO
+ 
+        ! Calculate pond volume for highest category = remaining pond volume
+ 
+        ! The following is completely unclear to Martin at least
+        ! Could we redefine properly and recode in a more readable way ?
+ 
+        ! m_index = last category with melt pond
+ 
+        IF (m_index == 1) v_ip(ji,jj,m_index) = zvolp(ji,jj) ! volume of mw in 1st category is the total volume of melt water
+ 
+        IF (m_index > 1) THEN
+          IF (zvolp(ji,jj) > sum( v_ip(ji,jj,1:m_index-1))) THEN
+             v_ip(ji,jj,m_index) = zvolp(ji,jj) - sum(v_ip(ji,jj,1:m_index-1))
+          ELSE
+             v_ip(ji,jj,m_index) = 0._wp 
+             h_ip(ji,jj,m_index) = 0._wp
+             a_ip(ji,jj,m_index) = 0._wp
+             ! If remaining pond volume is negative reduce pond volume of
+             ! lower category
+             IF ( zvolp(ji,jj) + epsi10 < SUM(v_ip(ji,jj,1:m_index-1))) &
+              v_ip(ji,jj,m_index-1) = v_ip(ji,jj,m_index-1) - sum(v_ip(ji,jj,1:m_index-1)) + zvolp(ji,jj)
+          END IF
+        END IF
+ 
+        DO jl = 1,m_index
+           IF (a_ip(ji,jj,jl) > epsi10) THEN
+               h_ip(ji,jj,jl) = v_ip(ji,jj,jl) / a_ip(ji,jj,jl)
+           ELSE
+              zdvolp(ji,jj) = zdvolp(ji,jj) + v_ip(ji,jj,jl)
+              h_ip(ji,jj,jl) = 0._wp 
+              v_ip(ji,jj,jl)  = 0._wp
+              a_ip(ji,jj,jl) = 0._wp
+           END IF
+        END DO
+        DO jl = m_index+1, jpl
+           h_ip(ji,jj,jl) = 0._wp 
+           a_ip(ji,jj,jl) = 0._wp 
+           v_ip(ji,jj,jl) = 0._wp 
+        END DO
+        
+           ENDIF
+        END DO ! ji
+     END DO ! jj
+
+    END SUBROUTINE ice_thd_pnd_area
+
+
+    SUBROUTINE ice_thd_pnd_depth(aicen, asnon, hsnon, alfan, zvolp, cum_max_vol, hpond, m_index)
+       !!-------------------------------------------------------------------
+       !!                ***  ROUTINE ice_thd_pnd_depth  ***
+       !!
+       !! ** Purpose :   Compute melt pond depth
+       !!-------------------------------------------------------------------
+
+       REAL (wp), DIMENSION(jpl), INTENT(IN) :: &
+          aicen, &
+          asnon, &
+          hsnon, &
+          alfan, &
+          cum_max_vol
+
+       REAL (wp), INTENT(IN) :: &
+          zvolp
+
+       REAL (wp), INTENT(OUT) :: &
+          hpond
+
+       INTEGER, INTENT(OUT) :: &
+          m_index
+
+       INTEGER :: n, ns
+
+       REAL (wp), DIMENSION(0:jpl+1) :: &
+          hitl, &
+          aicetl
+
+       REAL (wp) :: &
+          rem_vol, &
+          area, &
+          vol, &
+          tmp, &
+          z0   = 0.0_wp
+
+       !----------------------------------------------------------------
+       ! hpond is zero if zvolp is zero - have we fully drained?
+       !----------------------------------------------------------------
+
+       IF (zvolp < epsi10) THEN
+        hpond = z0
+        m_index = 0
+       ELSE
+
+        !----------------------------------------------------------------
+        ! Calculate the category where water fills up to
+        !----------------------------------------------------------------
+
+        !----------|
+        !          |
+        !          |
+        !          |----------|                                     -- --
+        !__________|__________|_________________________________________ ^
+        !          |          |             rem_vol     ^                | Semi-filled
+        !          |          |----------|-- -- -- - ---|-- ---- -- -- --v layer
+        !          |          |          |              |
+        !          |          |          |              |hpond
+        !          |          |          |----------|   |     |-------
+        !          |          |          |          |   |     |
+        !          |          |          |          |---v-----|
+        !          |          | m_index  |          |         |
+        !-------------------------------------------------------------
+
+        m_index = 0  ! 1:m_index categories have water in them
+        DO n = 1, jpl
+           IF (zvolp <= cum_max_vol(n)) THEN
+              m_index = n
+              IF (n == 1) THEN
+                 rem_vol = zvolp
+              ELSE
+                 rem_vol = zvolp - cum_max_vol(n-1)
+              END IF
+              exit ! to break out of the loop
+           END IF
+        END DO
+        m_index = min(jpl-1, m_index)
+
+        !----------------------------------------------------------------
+        ! semi-filled layer may have m_index different snow in it
+        !----------------------------------------------------------------
+
+        !-----------------------------------------------------------  ^
+        !                                                             |  alfan(m_index+1)
+        !                                                             |
+        !hitl(3)-->                             |----------|          |
+        !hitl(2)-->                |------------| * * * * *|          |
+        !hitl(1)-->     |----------|* * * * * * |* * * * * |          |
+        !hitl(0)-->-------------------------------------------------  |  ^
+        !                various snow from lower categories          |  |alfa(m_index)
+
+        ! hitl - heights of the snow layers from thinner and current categories
+        ! aicetl - area of each snow depth in this layer
+
+        hitl(:) = z0
+        aicetl(:) = z0
+        DO n = 1, m_index
+           hitl(n)   = max(min(hsnon(n) + alfan(n) - alfan(m_index), &
+                                  alfan(m_index+1) - alfan(m_index)), z0)
+           aicetl(n) = asnon(n)
+
+           aicetl(0) = aicetl(0) + (aicen(n) - asnon(n))
+        END DO
+
+        hitl(m_index+1) = alfan(m_index+1) - alfan(m_index)
+        aicetl(m_index+1) = z0
+
+        !----------------------------------------------------------------
+        ! reorder array according to hitl
+        ! snow heights not necessarily in height order
+        !----------------------------------------------------------------
+
+        DO ns = 1, m_index+1
+           DO n = 0, m_index - ns + 1
+              IF (hitl(n) > hitl(n+1)) THEN ! swap order
+                 tmp = hitl(n)
+                 hitl(n) = hitl(n+1)
+                 hitl(n+1) = tmp
+                 tmp = aicetl(n)
+                 aicetl(n) = aicetl(n+1)
+                 aicetl(n+1) = tmp
+              END IF
+           END DO
+        END DO
+
+        !----------------------------------------------------------------
+        ! divide semi-filled layer into set of sublayers each vertically homogenous
+        !----------------------------------------------------------------
+
+        !hitl(3)----------------------------------------------------------------
+        !                                                       | * * * * * * * *
+        !                                                       |* * * * * * * * *
+        !hitl(2)----------------------------------------------------------------
+        !                                    | * * * * * * * *  | * * * * * * * *
+        !                                    |* * * * * * * * * |* * * * * * * * *
+        !hitl(1)----------------------------------------------------------------
+        !                 | * * * * * * * *  | * * * * * * * *  | * * * * * * * *
+        !                 |* * * * * * * * * |* * * * * * * * * |* * * * * * * * *
+        !hitl(0)----------------------------------------------------------------
+        !    aicetl(0)         aicetl(1)           aicetl(2)          aicetl(3)
+
+        ! move up over layers incrementing volume
+        DO n = 1, m_index+1
+
+           area = sum(aicetl(:)) - &                 ! total area of sub-layer
+                (rhos/rau0) * sum(aicetl(n:jpl+1)) ! area of sub-layer occupied by snow
+
+           vol = (hitl(n) - hitl(n-1)) * area      ! thickness of sub-layer times area
+
+           IF (vol >= rem_vol) THEN  ! have reached the sub-layer with the depth within
+              hpond = rem_vol / area + hitl(n-1) + alfan(m_index) - alfan(1)
+
+              exit
+           ELSE  ! still in sub-layer below the sub-layer with the depth
+              rem_vol = rem_vol - vol
+           END IF
+
+        END DO
+
+       END IF
+
+    END SUBROUTINE ice_thd_pnd_depth
+
+
+    SUBROUTINE ice_thd_pnd_perm(ticen, salin, perm)
+       !!-------------------------------------------------------------------
+       !!                ***  ROUTINE ice_thd_pnd_perm ***
+       !!
+       !! ** Purpose :   Determine the liquid fraction of brine in the ice
+       !!                and its permeability
+       !!-------------------------------------------------------------------
+
+       REAL (wp), DIMENSION(nlay_i), INTENT(IN) :: &
+          ticen,  &     ! internal ice temperature (K)
+          salin         ! salinity (ppt)     !js: ppt according to cice
+
+       REAL (wp), INTENT(OUT) :: &
+          perm      ! permeability
+
+       REAL (wp) ::   &
+          Sbr       ! brine salinity
+
+       REAL (wp), DIMENSION(nlay_i) ::   &
+          Tin, &    ! ice temperature
+          phi       ! liquid fraction
+
+       INTEGER :: k
+
+       !-----------------------------------------------------------------
+       ! Compute ice temperatures from enthalpies using quadratic formula
+       !-----------------------------------------------------------------
+
+       DO k = 1,nlay_i
+          Tin(k) = ticen(k) - rt0   !js: from K to degC
+       END DO
+
+       !-----------------------------------------------------------------
+       ! brine salinity and liquid fraction
+       !-----------------------------------------------------------------
+
+       DO k = 1, nlay_i
+       
+          ! Sbr    = - Tin(k) / rTmlt ! Consistent expression with SI3 (linear liquidus)
+          ! Best expression to date is that one
+          Sbr  = - 18.7 * Tin(k) - 0.519 * Tin(k)**2 - 0.00535 * Tin(k) **3
+          phi(k) = salin(k) / Sbr
+          
+       END DO
+
+       !-----------------------------------------------------------------
+       ! permeability
+       !-----------------------------------------------------------------
+
+       perm = 3.0e-08_wp * (minval(phi))**3 ! Golden et al. (2007)
+
+   END SUBROUTINE ice_thd_pnd_perm
+   
+   
+!----------------------------------------------------------------------------------------------------------------------
 
    SUBROUTINE ice_thd_pnd_init 
@@ -317,6 +1357,7 @@
       INTEGER  ::   ios, ioptio   ! Local integer
       !!
-      NAMELIST/namthd_pnd/  ln_pnd, ln_pnd_LEV , rn_apnd_min, rn_apnd_max, &
-         &                          ln_pnd_CST , rn_apnd, rn_hpnd,         &
+      NAMELIST/namthd_pnd/  ln_pnd, ln_pnd_LEV , rn_apnd_min, rn_apnd_max, rn_pnd_flush, &
+         &                          ln_pnd_CST , rn_apnd, rn_hpnd,                       &
+         &                          ln_pnd_TOPO ,                                        &
          &                          ln_pnd_lids, ln_pnd_alb
       !!-------------------------------------------------------------------
@@ -336,7 +1377,9 @@
          WRITE(numout,*) '   Namelist namicethd_pnd:'
          WRITE(numout,*) '      Melt ponds activated or not                                 ln_pnd       = ', ln_pnd
+         WRITE(numout,*) '         Topographic melt pond scheme                             ln_pnd_TOPO  = ', ln_pnd_TOPO
          WRITE(numout,*) '         Level ice melt pond scheme                               ln_pnd_LEV   = ', ln_pnd_LEV
          WRITE(numout,*) '            Minimum ice fraction that contributes to melt ponds   rn_apnd_min  = ', rn_apnd_min
          WRITE(numout,*) '            Maximum ice fraction that contributes to melt ponds   rn_apnd_max  = ', rn_apnd_max
+         WRITE(numout,*) '            Pond flushing efficiency                              rn_pnd_flush = ', rn_pnd_flush
          WRITE(numout,*) '         Constant ice melt pond scheme                            ln_pnd_CST   = ', ln_pnd_CST
          WRITE(numout,*) '            Prescribed pond fraction                              rn_apnd      = ', rn_apnd
@@ -351,6 +1394,7 @@
       IF( ln_pnd_CST  ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndCST    ;   ENDIF
       IF( ln_pnd_LEV  ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndLEV    ;   ENDIF
+      IF( ln_pnd_TOPO ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndTOPO   ;   ENDIF
       IF( ioptio /= 1 )   &
-         & CALL ctl_stop( 'ice_thd_pnd_init: choose either none (ln_pnd=F) or only one pond scheme (ln_pnd_LEV or ln_pnd_CST)' )
+         & CALL ctl_stop( 'ice_thd_pnd_init: choose either none (ln_pnd=F) or only one pond scheme (ln_pnd_LEV, ln_pnd_CST or ln_pnd_TOPO)' )
       !
       SELECT CASE( nice_pnd )
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/iceupdate.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/iceupdate.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/iceupdate.F90	(revision 14671)
@@ -146,5 +146,5 @@
             !
             ! the non-solar is simply derived from the solar flux
-            qns(ji,jj) = qt_oce_ai(ji,jj) - zqsr              
+            qns(ji,jj) = qt_oce_ai(ji,jj) - qsr(ji,jj)              
 
             ! Mass flux at the atm. surface       
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icevar.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icevar.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icevar.F90	(revision 14671)
@@ -244,5 +244,5 @@
       ELSEWHERE( h_il(:,:,:) >= zhl_max )  ;   a_ip_eff(:,:,:) = 0._wp                  ! lid is very thick. Cover all the pond up with ice and snow
       ELSEWHERE                            ;   a_ip_eff(:,:,:) = a_ip_frac(:,:,:) * &   ! lid is in between. Expose part of the pond
-         &                                                       ( h_il(:,:,:) - zhl_min ) / ( zhl_max - zhl_min )
+         &                                                       ( zhl_max - h_il(:,:,:) ) / ( zhl_max - zhl_min )
       END WHERE
       !
@@ -565,4 +565,20 @@
             END DO
          END DO
+
+         !-----------------------------------------------------------------
+         ! zap small ponds
+         !-----------------------------------------------------------------
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( v_ip(ji,jj,jl) <= epsi10 ) THEN
+                  a_ip(ji,jj,jl)      = 0._wp
+                  a_ip_frac(ji,jj,jl) = 0._wp
+                  v_ip(ji,jj,jl)      = 0._wp
+                  h_ip(ji,jj,jl)      = 0._wp
+                  v_il(ji,jj,jl)      = 0._wp
+                  h_il(ji,jj,jl)      = 0._wp
+                ENDIF
+            END DO
+         END DO
          !
       END DO 
@@ -696,5 +712,5 @@
       WHERE( pe_i (1:npti,:,:) < 0._wp .AND. pe_i (1:npti,:,:) > -epsi06 )   pe_i (1:npti,:,:) = 0._wp   !  e_i must be >= 0
       WHERE( pe_s (1:npti,:,:) < 0._wp .AND. pe_s (1:npti,:,:) > -epsi06 )   pe_s (1:npti,:,:) = 0._wp   !  e_s must be >= 0
-      IF( ln_pnd_LEV ) THEN
+      IF( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
          WHERE( pa_ip(1:npti,:) < 0._wp .AND. pa_ip(1:npti,:) > -epsi10 )    pa_ip(1:npti,:)   = 0._wp   ! a_ip must be >= 0
          WHERE( pv_ip(1:npti,:) < 0._wp .AND. pv_ip(1:npti,:) > -epsi10 )    pv_ip(1:npti,:)   = 0._wp   ! v_ip must be >= 0
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icewri.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icewri.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/ICE/icewri.F90	(revision 14671)
@@ -104,5 +104,5 @@
       IF( iom_use('snwthic' ) )   CALL iom_put( 'snwthic', hm_s        * zmsk00 )                                           ! snw thickness
       IF( iom_use('icebrv'  ) )   CALL iom_put( 'icebrv' , bvm_i* 100. * zmsk00 )                                           ! brine volume
-      IF( iom_use('iceage'  ) )   CALL iom_put( 'iceage' , om_i / rday * zmsk15 + zmiss_val * ( 1._wp - zmsk15 ) )          ! ice age
+      IF( iom_use('iceage'  ) )   CALL iom_put( 'iceage' , om_i / rday * zmsk15 )                                           ! ice age
       IF( iom_use('icehnew' ) )   CALL iom_put( 'icehnew', ht_i_new             )                                           ! new ice thickness formed in the leads
       IF( iom_use('snwvolu' ) )   CALL iom_put( 'snwvolu', vt_s        * zmsksn )                                           ! snow volume
@@ -116,15 +116,16 @@
       IF( iom_use('icehpnd' ) )   CALL iom_put( 'icehpnd', hm_ip  * zmsk00      )                                           ! melt pond depth
       IF( iom_use('icevpnd' ) )   CALL iom_put( 'icevpnd', vt_ip  * zmsk00      )                                           ! melt pond total volume per unit area
+      IF( iom_use('iceepnd' ) )   CALL iom_put( 'iceepnd', SUM( a_ip_eff * a_i, dim=3 ) * zmsk00  )                         ! melt pond total effective fraction per cell area
       IF( iom_use('icehlid' ) )   CALL iom_put( 'icehlid', hm_il  * zmsk00      )                                           ! melt pond lid depth
       IF( iom_use('icevlid' ) )   CALL iom_put( 'icevlid', vt_il  * zmsk00      )                                           ! melt pond lid total volume per unit area
       ! salt
-      IF( iom_use('icesalt' ) )   CALL iom_put( 'icesalt', sm_i                 * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) ) ! mean ice salinity
+      IF( iom_use('icesalt' ) )   CALL iom_put( 'icesalt', sm_i                 * zmsk00 )                                  ! mean ice salinity
       IF( iom_use('icesalm' ) )   CALL iom_put( 'icesalm', st_i * rhoi * 1.0e-3 * zmsk00 )                                  ! Mass of salt in sea ice per cell area
       ! heat
-      IF( iom_use('icetemp' ) )   CALL iom_put( 'icetemp', ( tm_i  - rt0 ) * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) )      ! ice mean temperature
-      IF( iom_use('snwtemp' ) )   CALL iom_put( 'snwtemp', ( tm_s  - rt0 ) * zmsksn + zmiss_val * ( 1._wp - zmsksn ) )      ! snw mean temperature
-      IF( iom_use('icettop' ) )   CALL iom_put( 'icettop', ( tm_su - rt0 ) * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) )      ! temperature at the ice surface
-      IF( iom_use('icetbot' ) )   CALL iom_put( 'icetbot', ( t_bo  - rt0 ) * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) )      ! temperature at the ice bottom
-      IF( iom_use('icetsni' ) )   CALL iom_put( 'icetsni', ( tm_si - rt0 ) * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) )      ! temperature at the snow-ice interface
+      IF( iom_use('icetemp' ) )   CALL iom_put( 'icetemp', ( tm_i  - rt0 ) * zmsk00  )                                      ! ice mean temperature
+      IF( iom_use('snwtemp' ) )   CALL iom_put( 'snwtemp', ( tm_s  - rt0 ) * zmsksn  )                                      ! snw mean temperature
+      IF( iom_use('icettop' ) )   CALL iom_put( 'icettop', ( tm_su - rt0 ) * zmsk00  )                                      ! temperature at the ice surface
+      IF( iom_use('icetbot' ) )   CALL iom_put( 'icetbot', ( t_bo  - rt0 ) * zmsk00  )                                      ! temperature at the ice bottom
+      IF( iom_use('icetsni' ) )   CALL iom_put( 'icetsni', ( tm_si - rt0 ) * zmsk00  )                                      ! temperature at the snow-ice interface
       IF( iom_use('icehc'   ) )   CALL iom_put( 'icehc'  ,  -et_i          * zmsk00 )                                       ! ice heat content
       IF( iom_use('snwhc'   ) )   CALL iom_put( 'snwhc'  ,  -et_s          * zmsksn )                                       ! snow heat content
@@ -153,18 +154,19 @@
       IF( iom_use('icemask_cat' ) )   CALL iom_put( 'icemask_cat' ,                  zmsk00l                                   ) ! ice mask 0%
       IF( iom_use('iceconc_cat' ) )   CALL iom_put( 'iceconc_cat' , a_i            * zmsk00l                                   ) ! area for categories
-      IF( iom_use('icethic_cat' ) )   CALL iom_put( 'icethic_cat' , h_i            * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! thickness for categories
-      IF( iom_use('snwthic_cat' ) )   CALL iom_put( 'snwthic_cat' , h_s            * zmsksnl + zmiss_val * ( 1._wp - zmsksnl ) ) ! snow depth for categories
-      IF( iom_use('icesalt_cat' ) )   CALL iom_put( 'icesalt_cat' , s_i            * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! salinity for categories
-      IF( iom_use('iceage_cat'  ) )   CALL iom_put( 'iceage_cat'  , o_i / rday     * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! ice age
+      IF( iom_use('icethic_cat' ) )   CALL iom_put( 'icethic_cat' , h_i            * zmsk00l                                   ) ! thickness for categories
+      IF( iom_use('snwthic_cat' ) )   CALL iom_put( 'snwthic_cat' , h_s            * zmsksnl                                   ) ! snow depth for categories
+      IF( iom_use('icesalt_cat' ) )   CALL iom_put( 'icesalt_cat' , s_i            * zmsk00l                                   ) ! salinity for categories
+      IF( iom_use('iceage_cat'  ) )   CALL iom_put( 'iceage_cat'  , o_i / rday     * zmsk00l                                   ) ! ice age
       IF( iom_use('icetemp_cat' ) )   CALL iom_put( 'icetemp_cat' , ( SUM( t_i, dim=3 ) * r1_nlay_i - rt0 ) &
-         &                                                                         * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! ice temperature
+         &                                                                         * zmsk00l                                   ) ! ice temperature
       IF( iom_use('snwtemp_cat' ) )   CALL iom_put( 'snwtemp_cat' , ( SUM( t_s, dim=3 ) * r1_nlay_s - rt0 ) &
-         &                                                                         * zmsksnl + zmiss_val * ( 1._wp - zmsksnl ) ) ! snow temperature
-      IF( iom_use('icettop_cat' ) )   CALL iom_put( 'icettop_cat' , ( t_su - rt0 ) * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! surface temperature
-      IF( iom_use('icebrv_cat'  ) )   CALL iom_put( 'icebrv_cat'  ,   bv_i * 100.  * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! brine volume
+         &                                                                         * zmsksnl                                   ) ! snow temperature
+      IF( iom_use('icettop_cat' ) )   CALL iom_put( 'icettop_cat' , ( t_su - rt0 ) * zmsk00l                                   ) ! surface temperature
+      IF( iom_use('icebrv_cat'  ) )   CALL iom_put( 'icebrv_cat'  ,   bv_i * 100.  * zmsk00l                                   ) ! brine volume
       IF( iom_use('iceapnd_cat' ) )   CALL iom_put( 'iceapnd_cat' ,   a_ip         * zmsk00l                                   ) ! melt pond frac for categories
+      IF( iom_use('icevpnd_cat' ) )   CALL iom_put( 'icevpnd_cat' ,   v_ip         * zmsk00l                                   ) ! melt pond volume for categories
       IF( iom_use('icehpnd_cat' ) )   CALL iom_put( 'icehpnd_cat' ,   h_ip         * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! melt pond thickness for categories
       IF( iom_use('icehlid_cat' ) )   CALL iom_put( 'icehlid_cat' ,   h_il         * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! melt pond lid thickness for categories
-      IF( iom_use('iceafpnd_cat') )   CALL iom_put( 'iceafpnd_cat',   a_ip_frac    * zmsk00l                                   ) ! melt pond frac for categories
+      IF( iom_use('iceafpnd_cat') )   CALL iom_put( 'iceafpnd_cat',   a_ip_frac    * zmsk00l                                   ) ! melt pond frac per ice area for categories
       IF( iom_use('iceaepnd_cat') )   CALL iom_put( 'iceaepnd_cat',   a_ip_eff     * zmsk00l                                   ) ! melt pond effective frac for categories
       IF( iom_use('icealb_cat'  ) )   CALL iom_put( 'icealb_cat'  ,   alb_ice      * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! ice albedo for categories
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DIA/diaprod.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DIA/diaprod.F90	(revision 14671)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DIA/diaprod.F90	(revision 14671)
@@ -0,0 +1,270 @@
+MODULE diaprod
+! Requires key_iom_put
+# if defined key_iomput
+   !!======================================================================
+   !!                     ***  MODULE  diaprod  ***
+   !! Ocean diagnostics :  write ocean product diagnostics
+   !!=====================================================================
+   !! History :  3.4  ! 2012  (D. Storkey)  Original code
+   !!            4.0  ! 2019  (D. Storkey)
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dia_prod      : calculate and write out product diagnostics
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE domvvl          ! for thickness weighted diagnostics if key_vvl
+   USE eosbn2          ! equation of state  (eos call)
+   USE phycst          ! physical constants
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE in_out_manager  ! I/O manager
+   USE iom
+   USE ioipsl
+   USE lib_mpp         ! MPP library
+   USE timing          ! preformance summary
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dia_prod                 ! routines called by step.F90
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.4 , NEMO Consortium (2012)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dia_prod( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dia_prod  ***
+      !!                   
+      !! ** Purpose :   Write out product diagnostics (uT, vS etc.)
+      !!
+      !! ** Method  :  use iom_put
+      !!               Product diagnostics are not thickness-weighted in this routine.
+      !!               They should be thickness-weighted using XIOS if key_vvl is set. 
+      !!----------------------------------------------------------------------
+      !!
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !!
+      INTEGER                      ::   ji, jj, jk              ! dummy loop indices
+      REAL(wp)                     ::   zztmp, zztmpx, zztmpy   ! 
+      !!
+      REAL(wp), POINTER, DIMENSION(:,:)   :: z2d      ! 2D workspace
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: z3d      ! 3D workspace
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zrhop    ! potential density
+      !!----------------------------------------------------------------------
+      ! 
+      IF( ln_timing )   CALL timing_start('dia_prod')
+      ! 
+      ALLOCATE( z2d(jpi,jpj), z3d(jpi,jpj,jpk), zrhop(jpi,jpj,jpk) )
+      !
+
+      IF( iom_use("urhop") .OR. iom_use("vrhop") .OR. iom_use("wrhop") &
+#if ! defined key_diaar5
+     &  .OR. iom_use("rhop") &
+#endif
+     & ) THEN
+         CALL eos( tsn, z3d, zrhop )                 ! now in situ and potential density
+         zrhop(:,:,:) = zrhop(:,:,:)-1000.e0         ! reference potential density to 1000 to avoid precision issues in rhop2 calculation
+         zrhop(:,:,jpk) = 0._wp
+#if ! defined key_diaar5
+         CALL iom_put( 'rhop', zrhop )
+#else
+         ! If key_diaar5 set then there is already an iom_put call to output rhop.
+         ! Really should be a standard diagnostics option?
+#endif
+      ENDIF
+
+      IF( iom_use("ut") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = un(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_tem) + tsn(ji+1,jj,jk,jp_tem) )
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "ut", z3d )                  ! product of temperature and zonal velocity at U points
+      ENDIF
+
+      IF( iom_use("vt") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = vn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_tem) + tsn(ji,jj+1,jk,jp_tem) )
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "vt", z3d )                  ! product of temperature and meridional velocity at V points
+      ENDIF
+
+      IF( iom_use("wt") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z3d(ji,jj,1) = wn(ji,jj,1) * tsn(ji,jj,1,jp_tem)
+            END DO
+         END DO
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = wn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk-1,jp_tem) + tsn(ji,jj,jk,jp_tem) )
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "wt", z3d )                  ! product of temperature and vertical velocity at W points
+      ENDIF
+
+      IF( iom_use("us") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = un(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_sal) + tsn(ji+1,jj,jk,jp_sal) )
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "us", z3d )                  ! product of salinity and zonal velocity at U points
+      ENDIF
+
+      IF( iom_use("vs") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = vn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk,jp_sal) + tsn(ji,jj+1,jk,jp_sal) )
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "vs", z3d )                  ! product of salinity and meridional velocity at V points
+      ENDIF
+
+      IF( iom_use("ws") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z3d(ji,jj,1) = wn(ji,jj,1) * tsn(ji,jj,1,jp_sal)
+            END DO
+         END DO
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = wn(ji,jj,jk) * 0.5 * ( tsn(ji,jj,jk-1,jp_sal) + tsn(ji,jj,jk,jp_sal) )
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "ws", z3d )                  ! product of salinity and vertical velocity at W points
+      ENDIF
+
+      IF( iom_use("uv") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = 0.25 * ( un(ji-1,jj,jk) + un(ji,jj,jk) ) * ( vn(ji,jj-1,jk) + vn(ji,jj,jk) ) 
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "uv", z3d )                  ! product of zonal velocity and meridional velocity at T points
+      ENDIF
+
+      IF( iom_use("uw") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z3d(ji,jj,1) = 0.5 * ( wn(ji,jj,1) + wn(ji+1,jj,1) ) * un(ji,jj,1) 
+            END DO
+         END DO
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = 0.25 * ( wn(ji,jj,jk) + wn(ji+1,jj,jk) ) * ( un(ji,jj,jk-1) + un(ji,jj,jk) ) 
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "uw", z3d )                  ! product of zonal velocity and vertical velocity at UW points
+      ENDIF
+
+      IF( iom_use("vw") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z3d(ji,jj,1) = 0.5 * ( wn(ji,jj,1) + wn(ji,jj+1,1) ) * vn(ji,jj,1) 
+            END DO
+         END DO
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = 0.25 * ( wn(ji,jj,jk) + wn(ji,jj+1,jk) ) * ( vn(ji,jj,jk-1) + vn(ji,jj,jk) ) 
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "vw", z3d )                  ! product of meriodional velocity and vertical velocity at VW points
+      ENDIF
+
+      IF( iom_use("urhop") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = un(ji,jj,jk) * 0.5 * ( zrhop(ji,jj,jk) + zrhop(ji+1,jj,jk) )
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "urhop", z3d )                  ! product of density and zonal velocity at U points
+      ENDIF
+
+      IF( iom_use("vrhop") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = vn(ji,jj,jk) * 0.5 * ( zrhop(ji,jj,jk) + zrhop(ji,jj+1,jk) )
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "vrhop", z3d )                  ! product of density and meridional velocity at V points
+      ENDIF
+
+      IF( iom_use("wrhop") ) THEN
+         z3d(:,:,:) = 0.e0 
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               z3d(ji,jj,1) = wn(ji,jj,1) * zrhop(ji,jj,1)
+            END DO
+         END DO
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z3d(ji,jj,jk) = wn(ji,jj,jk) * 0.5 * ( zrhop(ji,jj,jk-1) + zrhop(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         CALL iom_put( "wrhop", z3d )                  ! product of density and vertical velocity at W points
+      ENDIF
+
+      !
+      DEALLOCATE( z2d, z3d, zrhop )
+      !
+      IF( ln_timing )   CALL timing_stop('dia_prod')
+      !
+   END SUBROUTINE dia_prod
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                                         NO diaprod
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER :: lk_diaprod = .FALSE.   ! coupled flag
+CONTAINS
+   SUBROUTINE dia_prod( kt )   ! Empty routine
+      INTEGER ::   kt
+      WRITE(*,*) 'dia_prod: You should not have seen this print! error?', kt
+   END SUBROUTINE dia_prod
+#endif
+   !!======================================================================
+END MODULE diaprod
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DIA/diawri.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DIA/diawri.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DIA/diawri.F90	(revision 14671)
@@ -49,5 +49,5 @@
    USE iom            ! 
    USE ioipsl         ! 
-
+   USE eosbn2
 #if defined key_si3
    USE ice 
@@ -113,6 +113,29 @@
       REAL(wp), DIMENSION(jpi,jpj)     ::   z2d   ! 2D workspace
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   z3d   ! 3D workspace
+      CHARACTER(len=4),SAVE :: ttype , stype           ! temperature and salinity type
       !!----------------------------------------------------------------------
       ! 
+      IF( kt == nit000 ) THEN
+         IF( ln_TEOS10 ) THEN
+            IF ( iom_use("toce_pot") .OR. iom_use("soce_pra") .OR. iom_use("sst_pot") .OR. iom_use("sss_pra") &
+                  & .OR. iom_use("sbt_pot") .OR. iom_use("sbs_pra") .OR. iom_use("sstgrad_pot") .OR. iom_use("sstgrad2_pot") &
+                  & .OR. iom_use("tosmint_pot") .OR. iom_use("somint_pra"))  THEN 
+               CALL ctl_stop( 'diawri: potential temperature and practical salinity not available with ln_TEOS10' )
+            ELSE
+               ttype='con' ; stype='abs'   ! teos-10 using conservative temperature and absolute salinity
+            ENDIF 
+         ELSE IF( ln_EOS80  ) THEN
+            IF ( iom_use("toce_con") .OR. iom_use("soce_abs") .OR. iom_use("sst_con") .OR. iom_use("sss_abs") &
+                  & .OR. iom_use("sbt_con") .OR. iom_use("sbs_abs") .OR. iom_use("sstgrad_con") .OR. iom_use("sstgrad2_con") &
+                  & .OR. iom_use("tosmint_con") .OR. iom_use("somint_abs"))  THEN 
+               CALL ctl_stop( 'diawri: conservative temperature and absolute salinity not available with ln_EOS80' )
+            ELSE
+               ttype='pot' ; stype='pra'   ! eos-80 using potential temperature and practical salinity
+            ENDIF
+         ELSE IF ( ln_SEOS) THEN
+            ttype='seos' ; stype='seos' ! seos using Simplified Equation of state
+         ENDIF
+      ENDIF
+
       IF( ln_timing )   CALL timing_start('dia_wri')
       ! 
@@ -144,7 +167,7 @@
          CALL iom_put( "wetdep" , ht_0(:,:) + sshn(:,:) )
       
-      CALL iom_put( "toce", tsn(:,:,:,jp_tem) )    ! 3D temperature
-      CALL iom_put(  "sst", tsn(:,:,1,jp_tem) )    ! surface temperature
-      IF ( iom_use("sbt") ) THEN
+      CALL iom_put( "toce_"//ttype, tsn(:,:,:,jp_tem) )    ! 3D temperature
+      CALL iom_put(  "sst_"//ttype, tsn(:,:,1,jp_tem) )    ! surface temperature
+      IF ( iom_use("sbt_"//ttype) ) THEN
          DO jj = 1, jpj
             DO ji = 1, jpi
@@ -153,10 +176,10 @@
             END DO
          END DO
-         CALL iom_put( "sbt", z2d )                ! bottom temperature
+         CALL iom_put( "sbt_"//ttype, z2d )                ! bottom temperature
       ENDIF
       
-      CALL iom_put( "soce", tsn(:,:,:,jp_sal) )    ! 3D salinity
-      CALL iom_put(  "sss", tsn(:,:,1,jp_sal) )    ! surface salinity
-      IF ( iom_use("sbs") ) THEN
+      CALL iom_put( "soce_"//stype, tsn(:,:,:,jp_sal) )    ! 3D salinity
+      CALL iom_put(  "sss_"//stype, tsn(:,:,1,jp_sal) )    ! surface salinity
+      IF ( iom_use("sbs_"//stype) ) THEN
          DO jj = 1, jpj
             DO ji = 1, jpi
@@ -165,5 +188,5 @@
             END DO
          END DO
-         CALL iom_put( "sbs", z2d )                ! bottom salinity
+         CALL iom_put( "sbs_"//stype, z2d )                ! bottom salinity
       ENDIF
 
@@ -233,5 +256,5 @@
       IF( iom_use('logavs') )   CALL iom_put( "logavs", LOG( MAX( 1.e-20_wp, avs(:,:,:) ) ) )
 
-      IF ( iom_use("sstgrad") .OR. iom_use("sstgrad2") ) THEN
+      IF ( iom_use("sstgrad_"//ttype) .OR. iom_use("sstgrad2_"//ttype) ) THEN
          DO jj = 2, jpjm1                                    ! sst gradient
             DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -244,7 +267,7 @@
          END DO
          CALL lbc_lnk( 'diawri', z2d, 'T', 1. )
-         CALL iom_put( "sstgrad2",  z2d )          ! square of module of sst gradient
+         CALL iom_put( "sstgrad2_"//ttype,  z2d )          ! square of module of sst gradient
          z2d(:,:) = SQRT( z2d(:,:) )
-         CALL iom_put( "sstgrad" ,  z2d )          ! module of sst gradient
+         CALL iom_put( "sstgrad_"//ttype ,  z2d )          ! module of sst gradient
       ENDIF
          
@@ -365,5 +388,13 @@
       ENDIF
 
-      IF( iom_use("tosmint") ) THEN
+      IF( (.NOT.l_ldfeiv_time) .AND. ( iom_use('RossRad')  .OR. iom_use('RossRadlim') &
+            &                     .OR. iom_use('Tclinic_recip') .OR. iom_use('RR_GS')      &
+            &                     .OR. iom_use('aeiu_2d')  .OR. iom_use('aeiv_2d') ) ) THEN
+         CALL ldf_eiv(kt, 75.0, z2d, z3d(:,:,1))
+         CALL iom_put('aeiu_2d', z2d)
+         CALL iom_put('aeiv_2d', z3d(:,:,1))
+      ENDIF
+
+      IF( iom_use("tosmint_"//ttype) ) THEN
          z2d(:,:) = 0._wp
          DO jk = 1, jpkm1
@@ -375,7 +406,7 @@
          END DO
          CALL lbc_lnk( 'diawri', z2d, 'T', -1. )
-         CALL iom_put( "tosmint", rau0 * z2d )        ! Vertical integral of temperature
-      ENDIF
-      IF( iom_use("somint") ) THEN
+         CALL iom_put( "tosmint_"//ttype, rau0 * z2d )        ! Vertical integral of temperature
+      ENDIF
+      IF( iom_use("somint_"//stype) ) THEN
          z2d(:,:)=0._wp
          DO jk = 1, jpkm1
@@ -387,5 +418,5 @@
          END DO
          CALL lbc_lnk( 'diawri', z2d, 'T', -1. )
-         CALL iom_put( "somint", rau0 * z2d )         ! Vertical integral of salinity
+         CALL iom_put( "somint_"//stype, rau0 * z2d )         ! Vertical integral of salinity
       ENDIF
 
@@ -930,5 +961,4 @@
          CALL iom_rstput( 0, 0, inum, 'sdvecrtz', wsd            )    ! now StokesDrift k-velocity
       ENDIF
- 
 #if defined key_si3
       IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + ice-model but no-ice in child grid
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DOM/domain.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DOM/domain.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DOM/domain.F90	(revision 14671)
@@ -292,5 +292,6 @@
          &             nn_it000, nn_itend , nn_date0    , nn_time0     , nn_leapy  , nn_istate ,     &
          &             nn_stock, nn_write , ln_mskland  , ln_clobber   , nn_chunksz, nn_euler  ,     &
-         &             ln_cfmeta, ln_iscpl, ln_xios_read, nn_wxios
+         &             ln_cfmeta, ln_iscpl, ln_xios_read, nn_wxios, ln_rstdate, ln_rst_eos
+
       NAMELIST/namdom/ ln_linssh, rn_isfhmin, rn_rdt, rn_atfp, ln_crs, ln_meshmask
 #if defined key_netcdf4
@@ -340,8 +341,11 @@
 #endif
          WRITE(numout,*) '      mask land points                ln_mskland      = ', ln_mskland
+         WRITE(numout,*) '      date-stamp restart files        ln_rstdate = ', ln_rstdate
          WRITE(numout,*) '      additional CF standard metadata ln_cfmeta       = ', ln_cfmeta
          WRITE(numout,*) '      overwrite an existing file      ln_clobber      = ', ln_clobber
          WRITE(numout,*) '      NetCDF chunksize (bytes)        nn_chunksz      = ', nn_chunksz
          WRITE(numout,*) '      IS coupling at the restart step ln_iscpl        = ', ln_iscpl
+         WRITE(numout,*) '      check restart equation of state ln_rst_eos      = ', ln_rst_eos
+
          IF( TRIM(Agrif_CFixed()) == '0' ) THEN
             WRITE(numout,*) '      READ restart for a single file using XIOS ln_xios_read =', ln_xios_read
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DOM/dommsk.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DOM/dommsk.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/DOM/dommsk.F90	(revision 14671)
@@ -32,4 +32,6 @@
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp        ! Massively Parallel Processing library
+   USE iom             ! For shlat2d
+   USE fldread         ! for sn_shlat2d
 
    IMPLICIT NONE
@@ -93,5 +95,10 @@
       INTEGER  ::   ios, inum
       !!
-      NAMELIST/namlbc/ rn_shlat, ln_vorlat
+      REAL(wp) :: zshlat           !: locally modified shlat for some strait
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zshlat2d
+      LOGICAL                         :: ln_shlat2d
+      CHARACTER(len = 256)            :: cn_shlat2d_file, cn_shlat2d_var  
+      !!
+      NAMELIST/namlbc/ rn_shlat, ln_vorlat, ln_shlat2d, cn_shlat2d_file, cn_shlat2d_var
       NAMELIST/nambdy/ ln_bdy ,nb_bdy, ln_coords_file, cn_coords_file,         &
          &             ln_mask_file, cn_mask_file, cn_dyn2d, nn_dyn2d_dta,     &
@@ -120,10 +127,19 @@
       !
       IF(lwp) WRITE(numout,*)
-      IF     (      rn_shlat == 0.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  free-slip'
-      ELSEIF (      rn_shlat == 2.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  no-slip'
-      ELSEIF ( 0. < rn_shlat .AND. rn_shlat < 2. ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  partial-slip'
-      ELSEIF ( 2. < rn_shlat                     ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  strong-slip'
+
+      IF ( ln_shlat2d ) THEN
+         IF(lwp) WRITE(numout,*) '         READ shlat as a 2D coefficient in a file '
+         ALLOCATE( zshlat2d(jpi,jpj) )
+         CALL iom_open(TRIM(cn_shlat2d_file), inum)
+         CALL iom_get (inum, jpdom_data, TRIM(cn_shlat2d_var), zshlat2d, 1) !
+         CALL iom_close(inum)
       ELSE
-         CALL ctl_stop( 'dom_msk: wrong value for rn_shlat (i.e. a negalive value). We stop.' )
+         IF     (      rn_shlat == 0.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  free-slip'
+         ELSEIF (      rn_shlat == 2.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  no-slip'
+         ELSEIF ( 0. < rn_shlat .AND. rn_shlat < 2. ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  partial-slip'
+         ELSEIF ( 2. < rn_shlat                     ) THEN   ;   IF(lwp) WRITE(numout,*) '   ==>>>   ocean lateral  strong-slip'
+         ELSE
+            CALL ctl_stop( 'dom_msk: wrong value for rn_shlat (i.e. a negalive value). We stop.' )
+         ENDIF
       ENDIF
 
@@ -240,15 +256,26 @@
       ! Lateral boundary conditions on velocity (modify fmask)
       ! ---------------------------------------  
-      IF( rn_shlat /= 0 ) THEN      ! Not free-slip lateral boundary condition
+      IF( rn_shlat /= 0 .or. ln_shlat2d ) THEN      ! Not free-slip lateral boundary condition everywhere
          !
          DO jk = 1, jpk
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( fmask(ji,jj,jk) == 0._wp ) THEN
-                     fmask(ji,jj,jk) = rn_shlat * MIN( 1._wp , MAX( umask(ji,jj,jk), umask(ji,jj+1,jk), &
-                        &                                           vmask(ji,jj,jk), vmask(ji+1,jj,jk) ) )
-                  ENDIF
+            IF (  ln_shlat2d ) THEN
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     IF( fmask(ji,jj,jk) == 0._wp ) THEN
+                        fmask(ji,jj,jk) = zshlat2d(ji,jj) * MIN( 1._wp , MAX( umask(ji,jj,jk), umask(ji,jj+1,jk),   &
+                           &                                                  vmask(ji,jj,jk), vmask(ji+1,jj,jk)  )  )
+                     ENDIF
+                  END DO
                END DO
-            END DO
+            ELSE
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     IF( fmask(ji,jj,jk) == 0._wp ) THEN
+                        fmask(ji,jj,jk) = rn_shlat * MIN( 1._wp , MAX( umask(ji,jj,jk), umask(ji,jj+1,jk),   &
+                           &                                           vmask(ji,jj,jk), vmask(ji+1,jj,jk)   )  )
+                     ENDIF
+                  END DO
+               END DO
+            ENDIF
             DO jj = 2, jpjm1
                IF( fmask(1,jj,jk) == 0._wp ) THEN
@@ -277,4 +304,6 @@
          END DO
          !
+         IF( ln_shlat2d ) DEALLOCATE( zshlat2d )
+         !
          CALL lbc_lnk( 'dommsk', fmask, 'F', 1._wp )      ! Lateral boundary conditions on fmask
          !
@@ -284,7 +313,10 @@
       
       ! User defined alteration of fmask (use to reduce ocean transport in specified straits)
+      ! Only call if we are not using the shlat2d option.
       ! -------------------------------- 
       !
-      CALL usr_def_fmask( cn_cfg, nn_cfg, fmask )
+      IF ( .not. ln_shlat2d ) THEN      
+         CALL usr_def_fmask( cn_cfg, nn_cfg, fmask )
+      ENDIF
       !
    END SUBROUTINE dom_msk
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbdia.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbdia.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbdia.F90	(revision 14671)
@@ -83,8 +83,9 @@
    REAL(wp)                      ::  heat_to_bergs_net, heat_to_ocean_net, melt_net
    REAL(wp)                      ::  calving_to_bergs_net
+   REAL(wp)                      ::  vel_factor_min
 
    INTEGER                       ::  nbergs_start, nbergs_end, nbergs_calved
    INTEGER                       ::  nbergs_melted
-   INTEGER                       ::  nspeeding_tickets
+   INTEGER , DIMENSION(4)        ::  nspeeding_tickets
    INTEGER , DIMENSION(nclasses) ::  nbergs_calved_by_class
 
@@ -124,5 +125,6 @@
       nbergs_calved             = 0
       nbergs_calved_by_class(:) = 0
-      nspeeding_tickets         = 0
+      nspeeding_tickets(:)      = 0
+      vel_factor_min            = 1._wp
       stored_heat_end           = 0._wp
       floating_heat_end         = 0._wp
@@ -157,5 +159,5 @@
       IF( lk_mpp ) THEN
          ALLOCATE( rsumbuf(23) )          ; rsumbuf(:) = 0._wp
-         ALLOCATE( nsumbuf(4+nclasses) )  ; nsumbuf(:) = 0
+         ALLOCATE( nsumbuf(7+nclasses) )  ; nsumbuf(:) = 0
          rsumbuf(1) = floating_mass_start
          rsumbuf(2) = bergs_mass_start
@@ -265,18 +267,19 @@
             nsumbuf(2) = nbergs_calved
             nsumbuf(3) = nbergs_melted
-            nsumbuf(4) = nspeeding_tickets
+            nsumbuf(4:7) = nspeeding_tickets(:)
             DO ik = 1, nclasses
-               nsumbuf(4+ik) = nbergs_calved_by_class(ik)
+               nsumbuf(7+ik) = nbergs_calved_by_class(ik)
             END DO
-            CALL mpp_sum( 'icbdia', nsumbuf(1:nclasses+4), nclasses+4 )
+            CALL mpp_sum( 'icbdia', nsumbuf(1:nclasses+7), nclasses+7 )
             !
             nbergs_end        = nsumbuf(1)
             nbergs_calved     = nsumbuf(2)
             nbergs_melted     = nsumbuf(3)
-            nspeeding_tickets = nsumbuf(4)
+            nspeeding_tickets(:) = nsumbuf(4:7)
             DO ik = 1,nclasses
-               nbergs_calved_by_class(ik)= nsumbuf(4+ik)
+               nbergs_calved_by_class(ik)= nsumbuf(7+ik)
             END DO
             !
+            CALL mpp_min( 'icbdia', vel_factor_min, 1 )
          ENDIF
          !
@@ -329,5 +332,8 @@
          IF (nn_verbose_level > 0) THEN
             WRITE( numicb, '("calved by class = ",i6,20(",",i6))') (nbergs_calved_by_class(ik),ik=1,nclasses)
-            IF( nspeeding_tickets > 0 )   WRITE( numicb, '("speeding tickets issued = ",i6)') nspeeding_tickets
+            WRITE( numicb, '("n speeding tickets by RK4 stage = ",i6,3(",",i6))') (nspeeding_tickets(ik),ik=1,4)
+            IF( SUM(nspeeding_tickets) > 0 ) THEN
+               WRITE( numicb, '("min velocity reduction factor = ",f12.8)') vel_factor_min
+            ENDIF
          ENDIF
          !
@@ -337,5 +343,6 @@
          nbergs_calved             = 0
          nbergs_calved_by_class(:) = 0
-         nspeeding_tickets         = 0
+         nspeeding_tickets(:)      = 0
+         vel_factor_min            = 1._wp
          stored_heat_start         = stored_heat_end
          floating_heat_start       = floating_heat_end
@@ -474,10 +481,13 @@
 
 
-   SUBROUTINE icb_dia_speed()
-      !!----------------------------------------------------------------------
-      !!----------------------------------------------------------------------
-      !
-      IF( .NOT.ln_bergdia )   RETURN
-      nspeeding_tickets = nspeeding_tickets + 1
+   SUBROUTINE icb_dia_speed(pvel_factor, pn_stage)
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in) ::   pvel_factor   ! factor by which velocity reduced
+      INTEGER , INTENT(in) ::   pn_stage  ! which stage of the RK4 calculation are we on
+      !
+      IF( (.NOT.ln_bergdia) .OR. pn_stage .lt. 1 .OR. pn_stage .gt. 4 )   RETURN
+      nspeeding_tickets(pn_stage) = nspeeding_tickets(pn_stage) + 1
+      vel_factor_min = MIN(vel_factor_min,pvel_factor)   ! keep track of minimum reduction factor
       !
    END SUBROUTINE icb_dia_speed
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbdyn.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbdyn.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbdyn.F90	(revision 14671)
@@ -85,5 +85,5 @@
          !                                         !**   A1 = A(X1,V1)
          CALL icb_accel( berg , zxi1, ze1, zuvel1, zuvel1, zax1,     &
-            &                   zyj1, ze2, zvvel1, zvvel1, zay1, zdt_2 )
+            &                   zyj1, ze2, zvvel1, zvvel1, zay1, zdt_2, 1 )
          !
          zu1 = zuvel1 / ze1                           !**   V1 in d(i,j)/dt
@@ -102,5 +102,5 @@
          !                                         !**   A2 = A(X2,V2)
          CALL icb_accel( berg , zxi2, ze1, zuvel2, zuvel1, zax2,    &
-            &                   zyj2, ze2, zvvel2, zvvel1, zay2, zdt_2 )
+            &                   zyj2, ze2, zvvel2, zvvel1, zay2, zdt_2, 2 )
          !
          zu2 = zuvel2 / ze1                           !**   V2 in d(i,j)/dt
@@ -118,5 +118,5 @@
          !                                         !**   A3 = A(X3,V3)
          CALL icb_accel( berg , zxi3, ze1, zuvel3, zuvel1, zax3,    &
-            &                   zyj3, ze2, zvvel3, zvvel1, zay3, zdt )
+            &                   zyj3, ze2, zvvel3, zvvel1, zay3, zdt, 3 )
          !
          zu3 = zuvel3 / ze1                           !**   V3 in d(i,j)/dt
@@ -134,5 +134,5 @@
          !                                         !**   A4 = A(X4,V4)
          CALL icb_accel( berg , zxi4, ze1, zuvel4, zuvel1, zax4,    &
-            &                   zyj4, ze2, zvvel4, zvvel1, zay4, zdt )
+            &                   zyj4, ze2, zvvel4, zvvel1, zay4, zdt, 4 )
 
          zu4 = zuvel4 / ze1                           !**   V4 in d(i,j)/dt
@@ -235,5 +235,5 @@
 
    SUBROUTINE icb_accel( berg , pxi, pe1, puvel, puvel0, pax,                &
-      &                         pyj, pe2, pvvel, pvvel0, pay, pdt )
+      &                         pyj, pe2, pvvel, pvvel0, pay, pdt, pstage )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE icb_accel  ***
@@ -250,4 +250,5 @@
       REAL(wp)               , INTENT(inout) ::   pax, pay         ! berg acceleration
       REAL(wp)               , INTENT(in   ) ::   pdt              ! berg time step
+      INTEGER                , INTENT(in   ) ::   pstage           ! RK4 stage (for speed limiter)
       !
       REAL(wp), PARAMETER ::   pp_alpha     = 0._wp      !
@@ -265,5 +266,5 @@
       REAL(wp) ::   zampl, zwmod, zCr, zLwavelength, zLcutoff, zLtop
       REAL(wp) ::   zlambda, zdetA, zA11, zA12, zaxe, zaye, zD_hi
-      REAL(wp) ::   zuveln, zvveln, zus, zvs, zspeed, zloc_dx, zspeed_new
+      REAL(wp) ::   zuveln, zvveln, zus, zvs, zspeed, zloc_dx, zspeed_new, zvel_factor, zcfl_scale
       !!----------------------------------------------------------------------
 
@@ -361,10 +362,21 @@
          zspeed = SQRT( zuveln*zuveln + zvveln*zvveln )    ! Speed of berg
          IF( zspeed > 0._wp ) THEN
-            zloc_dx = MIN( pe1, pe2 )                          ! minimum grid spacing
-            zspeed_new = zloc_dx / pdt * rn_speed_limit        ! Speed limit as a factor of dx / dt
+            zloc_dx = MIN( pe1, pe2 )                                ! minimum grid spacing
+            ! cfl scale is function of the RK4 step
+            IF( pstage .le. 2 ) THEN
+               zcfl_scale=0.5
+            ELSE
+               zcfl_scale=1.0
+            ENDIF
+            zspeed_new = zloc_dx / pdt * rn_speed_limit * zcfl_scale ! Speed limit as a factor of dx / dt
             IF( zspeed_new < zspeed ) THEN
-               zuveln = zuveln * ( zspeed_new / zspeed )        ! Scale velocity to reduce speed
-               zvveln = zvveln * ( zspeed_new / zspeed )        ! without changing the direction
-               CALL icb_dia_speed()
+               zvel_factor = zspeed_new / zspeed
+               zuveln = zuveln * ( zvel_factor )             ! Scale velocity to reduce speed
+               zvveln = zvveln * ( zvel_factor )             ! without changing the direction
+               pax = (zuveln - puvel0)/pdt
+               pay = (zvveln - pvvel0)/pdt
+               WRITE(numicb,*) 'speeding ticket (zspeed_new/zspeed): ',zvel_factor, pdt, zcfl_scale
+               CALL FLUSH(numicb)
+               CALL icb_dia_speed(zvel_factor,pstage)
             ENDIF
          ENDIF
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbrst.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbrst.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbrst.F90	(revision 14671)
@@ -25,4 +25,5 @@
    USE netcdf         ! netcdf routines for IO
    USE iom
+   USE ioipsl, ONLY : ju2ymds    ! for calendar
    USE icb_oce        ! define iceberg arrays
    USE icbutl         ! iceberg utility routines
@@ -191,7 +192,10 @@
       INTEGER ::   idg  ! number of digits
       INTEGER ::   ix_dim, iy_dim, ik_dim, in_dim
-      CHARACTER(len=256)     :: cl_path
-      CHARACTER(len=256)     :: cl_filename
-      CHARACTER(len=8  )     :: cl_kt
+      INTEGER             ::   iyear, imonth, iday
+      REAL (wp)           ::   zsec
+      REAL (wp)           ::   zfjulday
+      CHARACTER(len=256)  :: cl_path
+      CHARACTER(len=256)  :: cl_filename
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
       CHARACTER(LEN=12 )     :: clfmt            ! writing format
       TYPE(iceberg), POINTER :: this
@@ -209,6 +213,15 @@
          cl_path = TRIM(cn_ocerst_outdir)
          IF( cl_path(LEN_TRIM(cl_path):) /= '/' ) cl_path = TRIM(cl_path) // '/'
-         WRITE(cl_kt, '(i8.8)') kt
-         cl_filename = TRIM(cexper)//"_icebergs_"//cl_kt//"_restart"
+         IF ( ln_rstdate ) THEN
+            zfjulday = fjulday + rdt / rday
+            IF( ABS(zfjulday - REAL(NINT(zfjulday),wp)) < 0.1 / rday )   zfjulday = REAL(NINT(zfjulday),wp)   ! avoid truncation error
+            CALL ju2ymds( zfjulday, iyear, imonth, iday, zsec )           
+            WRITE(clkt, '(i4.4,2i2.2)') iyear, imonth, iday
+         ELSE
+            IF( kt > 999999999 ) THEN   ;   WRITE(clkt, *       ) kt
+            ELSE                        ;   WRITE(clkt, '(i8.8)') kt
+            ENDIF
+         ENDIF
+         cl_filename = TRIM(cexper)//"_icebergs_"//TRIM(ADJUSTL(clkt))//"_restart"
          IF( lk_mpp ) THEN
             idg = MAX( INT(LOG10(REAL(MAX(1,jpnij-1),wp))) + 1, 4 )          ! how many digits to we need to write? min=4, max=9
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbutl.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbutl.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ICB/icbutl.F90	(revision 14671)
@@ -428,5 +428,7 @@
       IF( ij == jpj ) THEN ; ij = ij-1 ; ierr = ierr + 1 ; END IF
       !
-      IF ( ierr > 0 ) CALL ctl_stop('STOP','icb_utl_bilin_e: an icebergs coordinates is out of valid range (out of bound error)')
+      IF ( ierr > 0 ) CALL ctl_stop('STOP', &
+     &                'icb_utl_bilin_e: an icebergs coordinates is out of valid range (out of bound error)', &
+     &                'This can be fixed using rn_speed_limit=0.4 in &namberg.')
       !
       IF(    0.0_wp <= zi .AND. zi < 0.5_wp   ) THEN
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/IOM/in_out_manager.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/IOM/in_out_manager.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/IOM/in_out_manager.F90	(revision 14671)
@@ -28,4 +28,5 @@
    LOGICAL       ::   ln_rstart        !: start from (F) rest or (T) a restart file
    LOGICAL       ::   ln_rst_list      !: output restarts at list of times (T) or by frequency (F)
+   LOGICAL       ::   ln_rst_eos       !: check equation of state used for the restart is consistent with model
    INTEGER       ::   nn_rstctl        !: control of the time step (0, 1 or 2)
    INTEGER       ::   nn_rstssh   = 0  !: hand made initilization of ssh or not (1/0)
@@ -40,4 +41,5 @@
    INTEGER, DIMENSION(10) :: nn_stocklist  !: restart dump times
    LOGICAL       ::   ln_mskland       !: mask land points in NetCDF outputs (costly: + ~15%)
+   LOGICAL       ::   ln_rstdate       !: T=> stamp output restart files with date instead of timestep
    LOGICAL       ::   ln_cfmeta        !: output additional data to netCDF files required for compliance with the CF metadata standard
    LOGICAL       ::   ln_clobber       !: clobber (overwrite) an existing file
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/IOM/iom.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/IOM/iom.F90	(revision 14671)
@@ -368,4 +368,6 @@
 !from restart.F90
    CALL iom_set_rstw_var_active("rdt")
+   CALL iom_set_rstw_var_active("neos")
+
    IF ( .NOT. ln_diurnal_only ) THEN
         CALL iom_set_rstw_var_active('ub'  )
@@ -417,4 +419,5 @@
         i = 0
         i = i + 1; fields(i)%vname="rdt";            fields(i)%grid="grid_scalar"
+        i = i + 1; fields(i)%vname="neos";           fields(i)%grid="grid_scalar"
         i = i + 1; fields(i)%vname="un";             fields(i)%grid="grid_N_3D"
         i = i + 1; fields(i)%vname="ub";             fields(i)%grid="grid_N_3D"
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/IOM/restart.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/IOM/restart.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/IOM/restart.F90	(revision 14671)
@@ -27,4 +27,5 @@
    USE in_out_manager  ! I/O manager
    USE iom             ! I/O module
+   USE ioipsl, ONLY : ju2ymds    ! for calendar
    USE diurnal_bulk
    USE lib_mpp         ! distribued memory computing library
@@ -59,4 +60,7 @@
       INTEGER, INTENT(in) ::   kt     ! ocean time-step
       !!
+      INTEGER             ::   iyear, imonth, iday
+      REAL (wp)           ::   zsec
+      REAL (wp)           ::   zfjulday
       CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
       CHARACTER(LEN=50)   ::   clname   ! ocean output restart file name
@@ -90,6 +94,13 @@
          IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 
             ! beware of the format used to write kt (default is i8.8, that should be large enough...)
-            IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
-            ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
+            IF ( ln_rstdate ) THEN
+               zfjulday = fjulday + rdt / rday
+               IF( ABS(zfjulday - REAL(NINT(zfjulday),wp)) < 0.1 / rday )   zfjulday = REAL(NINT(zfjulday),wp)   ! avoid truncation error
+               CALL ju2ymds( zfjulday, iyear, imonth, iday, zsec )           
+               WRITE(clkt, '(i4.4,2i2.2)') iyear, imonth, iday
+            ELSE
+               IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+               ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
+               ENDIF
             ENDIF
             ! create the file
@@ -173,4 +184,7 @@
                   END IF
       ENDIF
+                     CALL iom_rstput( kt, nitrst, numrow, 'neos'    , REAL(neos)      , ldxios = lwxios)   ! equation of state
+                     !CALL iom_rstput( kt, nitrst, numrow, 'neos'    , neos      , ktype = jp_i1, ldxios = lwxios)   ! equation of state
+
       
       IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst, ldxios = lwxios )  
@@ -249,4 +263,5 @@
       !!----------------------------------------------------------------------
       REAL(wp) ::   zrdt
+      REAL(wp) ::   zeos
       INTEGER  ::   jk
       REAL(wp), DIMENSION(jpi, jpj, jpk) :: w3d
@@ -255,6 +270,16 @@
       CALL rst_read_open           ! open restart for reading (if not already opened)
 
+      IF ( ln_rst_eos ) THEN
+         ! Check equation of state used is consistent with the restart
+         IF( iom_varid( numror, 'neos') == -1) THEN
+            CALL ctl_stop( 'restart, rst_read: variable neos not found. STOP check that the equations of state in the restart file and in the namelist nameos are consistent and use ln_rst_eos=F')
+         ELSE
+            CALL iom_get( numror, 'neos', zeos, ldxios = lrxios )
+            IF ( INT(zeos) /= neos ) CALL ctl_stop( 'restart, rst_read: equation of state used in restart file differs from namelist nameos')
+         ENDIF
+      ENDIF
+
       ! Check dynamics and tracer time-step consistency and force Euler restart if changed
-      IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN
+      IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN 
          CALL iom_get( numror, 'rdt', zrdt, ldxios = lrxios )
          IF( zrdt /= rdt )   neuler = 0
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/LDF/ldftra.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/LDF/ldftra.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/LDF/ldftra.F90	(revision 14671)
@@ -72,4 +72,5 @@
    REAL(wp), PUBLIC ::      rn_Ue               !: lateral diffusive velocity  [m/s]
    REAL(wp), PUBLIC ::      rn_Le               !: lateral diffusive length    [m]
+   INTEGER,  PUBLIC ::   nn_ldfeiv_shape     !: shape of bounding coefficient (Treguier et al formulation only)
    
    !                                  ! Flag to control the type of lateral diffusive operator
@@ -409,5 +410,6 @@
       !!----------------------------------------------------------------------
       !
-      IF( ln_ldfeiv .AND. nn_aei_ijk_t == 21 ) THEN       ! eddy induced velocity coefficients
+      IF( ln_ldfeiv .AND. ( nn_aei_ijk_t == 21 .OR. nn_aei_ijk_t == 22 ) ) THEN       
+         !                                ! eddy induced velocity coefficients
          !                                ! =F(growth rate of baroclinic instability)
          !                                ! max value aeiv_0 ; decreased to 0 within 20N-20S
@@ -502,5 +504,6 @@
       !!
       NAMELIST/namtra_eiv/ ln_ldfeiv   , ln_ldfeiv_dia,   &   ! eddy induced velocity (eiv)
-         &                 nn_aei_ijk_t, rn_Ue, rn_Le         ! eiv  coefficient
+         &                 nn_aei_ijk_t, rn_Ue, rn_Le,    &   ! eiv  coefficient
+         &                 nn_ldfeiv_shape
       !!----------------------------------------------------------------------
       !
@@ -525,5 +528,5 @@
          WRITE(numout,*) '      eiv streamfunction & velocity diag.        ln_ldfeiv_dia = ', ln_ldfeiv_dia
          WRITE(numout,*) '      coefficients :'
-         WRITE(numout,*) '         type of time-space variation            nn_aei_ijk_t  = ', nn_aht_ijk_t
+         WRITE(numout,*) '         type of time-space variation            nn_aei_ijk_t  = ', nn_aei_ijk_t
          WRITE(numout,*) '         lateral diffusive velocity (if cst)     rn_Ue         = ', rn_Ue, ' m/s'
          WRITE(numout,*) '         lateral diffusive length   (if cst)     rn_Le         = ', rn_Le, ' m'
@@ -595,4 +598,5 @@
             IF(lwp) WRITE(numout,*) '                                       = F( growth rate of baroclinic instability )'
             IF(lwp) WRITE(numout,*) '           maximum allowed value: aei0 = ', aei0, ' m2/s'
+            IF(lwp) WRITE(numout,*) '           shape of bounding coefficient : ',nn_ldfeiv_shape
             !
             l_ldfeiv_time = .TRUE.     ! will be calculated by call to ldf_tra routine in step.F90
@@ -638,16 +642,22 @@
       !!----------------------------------------------------------------------
       INTEGER                         , INTENT(in   ) ::   kt             ! ocean time-step index
-      REAL(wp)                        , INTENT(inout) ::   paei0          ! max value            [m2/s]
+      REAL(wp)                        , INTENT(in   ) ::   paei0          ! max value            [m2/s]
       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   paeiu, paeiv   ! eiv coefficient      [m2/s]
       !
       INTEGER  ::   ji, jj, jk    ! dummy loop indices
-      REAL(wp) ::   zfw, ze3w, zn2, z1_f20, zaht, zaht_min, zzaei    ! local scalars
-      REAL(wp), DIMENSION(jpi,jpj) ::   zn, zah, zhw, zRo, zaeiw   ! 2D workspace
+      REAL(wp) ::   zfw, ze3w, zn2, z1_f20, zaht, zaht_min, zzaei, z2_3    ! local scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::   zn, zah, zhw, zRo, zRo_lim, zTclinic_recip, zaeiw, zratio   ! 2D workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zmodslp ! 3D workspace
       !!----------------------------------------------------------------------
       !
       zn (:,:) = 0._wp        ! Local initialization
+      zmodslp(:,:,:) = 0._wp
       zhw(:,:) = 5._wp
       zah(:,:) = 0._wp
       zRo(:,:) = 0._wp
+      zRo_lim(:,:) = 0._wp
+      zTclinic_recip(:,:) = 0._wp
+      zratio(:,:) = 0._wp 
+      zaeiw(:,:) = 0._wp    
       !                       ! Compute lateral diffusive coefficient at T-point
       IF( ln_traldf_triad ) THEN
@@ -682,6 +692,7 @@
                   ! T^-1 = sqrt(m_jpk(N^2*(r1^2+r2^2)*e3w))
                   ze3w = e3w_n(ji,jj,jk) * wmask(ji,jj,jk)
-                  zah(ji,jj) = zah(ji,jj) + zn2 * ( wslpi(ji,jj,jk) * wslpi(ji,jj,jk)   &
-                     &                            + wslpj(ji,jj,jk) * wslpj(ji,jj,jk) ) * ze3w
+                  zmodslp(ji,jj,jk) =  wslpi(ji,jj,jk) * wslpi(ji,jj,jk)   &
+                     &               + wslpj(ji,jj,jk) * wslpj(ji,jj,jk)
+                  zah(ji,jj) = zah(ji,jj) + zn2 * zmodslp(ji,jj,jk) * ze3w
                   zhw(ji,jj) = zhw(ji,jj) + ze3w
                END DO
@@ -693,19 +704,88 @@
          DO ji = fs_2, fs_jpim1   ! vector opt.
             zfw = MAX( ABS( 2. * omega * SIN( rad * gphit(ji,jj) ) ) , 1.e-10 )
-            ! Rossby radius at w-point taken betwenn 2 km and  40km
-            zRo(ji,jj) = MAX(  2.e3 , MIN( .4 * zn(ji,jj) / zfw, 40.e3 )  )
+            ! Rossby radius at w-point taken between 2 km and  40km
+            zRo(ji,jj) = .4 * zn(ji,jj) / zfw
+            zRo_lim(ji,jj) = MAX(  2.e3 , MIN( zRo(ji,jj), 40.e3 )  )
             ! Compute aeiw by multiplying Ro^2 and T^-1
-            zaeiw(ji,jj) = zRo(ji,jj) * zRo(ji,jj) * SQRT( zah(ji,jj) / zhw(ji,jj) ) * tmask(ji,jj,1)
+            zTclinic_recip(ji,jj) = SQRT( MAX(zah(ji,jj),0._wp) / zhw(ji,jj) ) * tmask(ji,jj,1)
+            zaeiw(ji,jj) = zRo_lim(ji,jj) * zRo_lim(ji,jj) * zTclinic_recip(ji,jj) 
          END DO
       END DO
-
+      IF( iom_use('N_2d') ) CALL iom_put('N_2d',zn(:,:)/zhw(:,:))
+      IF( iom_use('modslp') ) CALL iom_put('modslp',SQRT(zmodslp(:,:,:)) )
+      CALL iom_put('RossRad',zRo)
+      CALL iom_put('RossRadlim',zRo_lim)
+      CALL iom_put('Tclinic_recip',zTclinic_recip)
       !                                         !==  Bound on eiv coeff.  ==!
       z1_f20 = 1._wp / (  2._wp * omega * sin( rad * 20._wp )  )
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            zzaei = MIN( 1._wp, ABS( ff_t(ji,jj) * z1_f20 ) ) * zaeiw(ji,jj)     ! tropical decrease
-            zaeiw(ji,jj) = MIN( zzaei , paei0 )                                  ! Max value = paei0
-         END DO
-      END DO
+      z2_3 = 2._wp/3._wp
+
+      SELECT CASE(nn_ldfeiv_shape)
+         CASE(0) !! Standard shape applied - decrease in tropics and cap. 
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zzaei = MIN( 1._wp, ABS( ff_t(ji,jj) * z1_f20 ) ) * zaeiw(ji,jj)     ! tropical decrease
+                  zaeiw(ji,jj) = MIN( zzaei, paei0 )
+               END DO
+            END DO
+
+         CASE(1) !! Abrupt cut-off on Rossby radius:
+! JD : modifications here to introduce scaling by local rossby radius of deformation vs local grid scale
+! arbitrary decision that GM is de-activated if local rossy radius larger than 2 times local grid scale
+! based on Hallberg (2013)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  IF ( zRo(ji,jj) >= ( 2._wp * MIN( e1t(ji,jj), e2t(ji,jj) ) ) ) THEN
+! TODO : use a version of zRo that integrates over a few time steps ?
+                      zaeiw(ji,jj) = 0._wp
+                  ELSE
+                      zaeiw(ji,jj) = MIN( zaeiw(ji,jj), paei0 )
+                  ENDIF
+               END DO
+            END DO
+
+         CASE(2) !! Rossby radius ramp type 1:
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zratio(ji,jj) = zRo(ji,jj)/MIN(e1t(ji,jj),e2t(ji,jj))
+                  zaeiw(ji,jj) = MIN( zaeiw(ji,jj), MAX( 0._wp, MIN( 1._wp, z2_3*(2._wp - zratio(ji,jj)) ) ) * paei0 )
+               END DO
+            END DO
+            CALL iom_put('RR_GS',zratio)
+
+         CASE(3) !! Rossby radius ramp type 2:
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zratio(ji,jj) = MIN(e1t(ji,jj),e2t(ji,jj))/zRo(ji,jj)
+                  zaeiw(ji,jj) = MIN( zaeiw(ji,jj), MAX( 0._wp, MIN( 1._wp, z2_3*( zratio(ji,jj) - 0.5_wp ) ) ) * paei0 )
+               END DO
+            END DO
+
+         CASE(4) !! bathymetry ramp:
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zaeiw(ji,jj) = MIN( zaeiw(ji,jj), MAX( 0._wp, MIN( 1._wp, 0.001*(ht_0(ji,jj) - 2000._wp) ) ) * paei0 )
+               END DO
+            END DO
+
+         CASE(5) !! Rossby radius ramp type 1 applied to Treguier et al coefficient rather than cap:
+                 !! Note the ramp is RR/GS=[2.0,1.0] (not [2.0,0.5] as for cases 2,3) and we ramp up 
+                 !! to 5% of the Treguier et al coefficient, aiming for peak values of around 100m2/s
+                 !! at high latitudes rather than 2000m2/s which is what you get in eORCA025 with an 
+                 !! uncapped coefficient.
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zratio(ji,jj) = zRo(ji,jj)/MIN(e1t(ji,jj),e2t(ji,jj))
+                  zaeiw(ji,jj) = MAX( 0._wp, MIN( 1._wp, 2._wp - zratio(ji,jj) ) ) * 0.05 * zaeiw(ji,jj)
+                  zaeiw(ji,jj) = MIN( zaeiw(ji,jj), paei0 )
+               END DO
+            END DO
+            CALL iom_put('RR_GS',zratio)
+
+         CASE DEFAULT
+               CALL ctl_stop('ldf_eiv: Unrecognised option for nn_ldfeiv_shape.')         
+
+      END SELECT
+
       CALL lbc_lnk( 'ldftra', zaeiw(:,:), 'W', 1. )       ! lateral boundary condition
       !               
@@ -722,5 +802,5 @@
          paeiv(:,:,jk) = paeiv(:,:,1) * vmask(:,:,jk)
       END DO
-      !  
+      !
    END SUBROUTINE ldf_eiv
 
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/SBC/sbcssm.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/SBC/sbcssm.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/SBC/sbcssm.F90	(revision 14671)
@@ -57,5 +57,15 @@
       REAL(wp) ::   zcoef, zf_sbc       ! local scalar
       REAL(wp), DIMENSION(jpi,jpj,jpts) :: zts
+      CHARACTER(len=4),SAVE :: stype
       !!---------------------------------------------------------------------
+      IF( kt == nit000 ) THEN
+         IF( ln_TEOS10 ) THEN
+            stype='abs'   ! teos-10: using absolute salinity (sst is converted to potential temperature for the surface module)
+         ELSE IF( ln_EOS80  ) THEN
+            stype='pra'   ! eos-80: using practical salinity
+         ELSE IF ( ln_SEOS) THEN
+            stype='seos' ! seos using Simplified Equation of state (sst is converted to potential temperature for the surface module)
+         ENDIF
+      ENDIF
       !
       !                                        !* surface T-, U-, V- ocean level variables (T, S, depth, velocity)
@@ -174,6 +184,6 @@
          CALL iom_put( 'ssu_m', ssu_m )
          CALL iom_put( 'ssv_m', ssv_m )
-         CALL iom_put( 'sst_m', sst_m )
-         CALL iom_put( 'sss_m', sss_m )
+         CALL iom_put( 'sst_m_pot', sst_m )
+         CALL iom_put( 'sss_m_'//stype, sss_m )
          CALL iom_put( 'ssh_m', ssh_m )
          CALL iom_put( 'e3t_m', e3t_m )
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ZDF/zdfmxl.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ZDF/zdfmxl.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/ZDF/zdfmxl.F90	(revision 14671)
@@ -15,4 +15,5 @@
    USE trc_oce  , ONLY: l_offline         ! ocean space and time domain variables
    USE zdf_oce        ! ocean vertical physics
+   USE eosbn2         ! for zdf_mxl_zint
    !
    USE in_out_manager ! I/O manager
@@ -31,7 +32,18 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlp    !: mixed layer depth  (rho=rho0+zdcrit) [m]   (used by LDF)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hmlpt   !: depth of the last T-point inside the mixed layer [m] (used by LDF)
+   REAL(wp), PUBLIC, ALLOCATABLE,       DIMENSION(:,:) ::   hmld_zint  !: vertically-interpolated mixed layer depth   [m]
+   REAL(wp), PUBLIC, ALLOCATABLE,       DIMENSION(:,:) ::   htc_mld    ! Heat content of hmld_zint
+   LOGICAL, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)    :: ll_found   ! Is T_b to be found by interpolation ?
+   LOGICAL, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)  :: ll_belowml ! Flag points below mixed layer when ll_found=F
 
    REAL(wp), PUBLIC ::   rho_c = 0.01_wp    !: density criterion for mixed layer depth
    REAL(wp), PUBLIC ::   avt_c = 5.e-4_wp   ! Kz criterion for the turbocline depth
+
+   TYPE, PUBLIC :: MXL_ZINT   !: Structure for MLD defs
+      INTEGER   :: mld_type   ! mixed layer type     
+      REAL(wp)  :: zref       ! depth of initial T_ref
+      REAL(wp)  :: dT_crit    ! Critical temp diff
+      REAL(wp)  :: iso_frac   ! Fraction of rn_dT_crit 
+   END TYPE MXL_ZINT
 
    !!----------------------------------------------------------------------
@@ -48,5 +60,6 @@
       zdf_mxl_alloc = 0      ! set to zero if no array to be allocated
       IF( .NOT. ALLOCATED( nmln ) ) THEN
-         ALLOCATE( nmln(jpi,jpj), hmld(jpi,jpj), hmlp(jpi,jpj), hmlpt(jpi,jpj), STAT= zdf_mxl_alloc )
+         ALLOCATE( nmln(jpi,jpj), hmld(jpi,jpj), hmlp(jpi,jpj), hmlpt(jpi,jpj), hmld_zint(jpi,jpj),     &
+ 	&          htc_mld(jpi,jpj), ll_found(jpi,jpj), ll_belowml(jpi,jpj,jpk), STAT= zdf_mxl_alloc )         
          !
          CALL mpp_sum ( 'zdfmxl', zdf_mxl_alloc )
@@ -137,7 +150,342 @@
       ENDIF
       !
+      ! Vertically-interpolated mixed-layer depth diagnostic
+      CALL zdf_mxl_zint( kt )
+      !
       IF(ln_ctl)   CALL prt_ctl( tab2d_1=REAL(nmln,wp), clinfo1=' nmln : ', tab2d_2=hmlp, clinfo2=' hmlp : ' )
       !
    END SUBROUTINE zdf_mxl
+
+   SUBROUTINE zdf_mxl_zint_mld( sf ) 
+      !!---------------------------------------------------------------------------------- 
+      !!                    ***  ROUTINE zdf_mxl_zint_mld  *** 
+      !                                                                        
+      !   Calculate vertically-interpolated mixed layer depth diagnostic. 
+      !            
+      !   This routine can calculate the mixed layer depth diagnostic suggested by
+      !   Kara et al, 2000, JGR, 105, 16803, but is more general and can calculate
+      !   vertically-interpolated mixed-layer depth diagnostics with other parameter
+      !   settings set in the namzdf_mldzint namelist.  
+      ! 
+      !   If mld_type=1 the mixed layer depth is calculated as the depth at which the  
+      !   density has increased by an amount equivalent to a temperature difference of  
+      !   0.8C at the surface. 
+      ! 
+      !   For other values of mld_type the mixed layer is calculated as the depth at  
+      !   which the temperature differs by 0.8C from the surface temperature.  
+      !                                                                        
+      !   David Acreman, Daley Calvert                                      
+      ! 
+      !!----------------------------------------------------------------------------------- 
+
+      TYPE(MXL_ZINT), INTENT(in)  :: sf
+
+      ! Diagnostic criteria
+      INTEGER   :: nn_mld_type   ! mixed layer type     
+      REAL(wp)  :: rn_zref       ! depth of initial T_ref
+      REAL(wp)  :: rn_dT_crit    ! Critical temp diff
+      REAL(wp)  :: rn_iso_frac   ! Fraction of rn_dT_crit used
+
+      ! Local variables
+      REAL(wp), PARAMETER :: zepsilon = 1.e-30          ! local small value
+      INTEGER, DIMENSION(jpi,jpj) :: ikmt          ! number of active tracer levels 
+      INTEGER, DIMENSION(jpi,jpj) :: ik_ref        ! index of reference level 
+      INTEGER, DIMENSION(jpi,jpj) :: ik_iso        ! index of last uniform temp level 
+      REAL, DIMENSION(jpi,jpj,jpk)  :: zT            ! Temperature or density 
+      REAL, DIMENSION(jpi,jpj)    :: ppzdep        ! depth for use in calculating d(rho) 
+      REAL, DIMENSION(jpi,jpj)    :: zT_ref        ! reference temperature 
+      REAL    :: zT_b                                   ! base temperature 
+      REAL, DIMENSION(jpi,jpj,jpk)  :: zdTdz         ! gradient of zT 
+      REAL, DIMENSION(jpi,jpj,jpk)  :: zmoddT        ! Absolute temperature difference 
+      REAL    :: zdz                                    ! depth difference 
+      REAL    :: zdT                                    ! temperature difference 
+      REAL, DIMENSION(jpi,jpj)    :: zdelta_T      ! difference critereon 
+      REAL, DIMENSION(jpi,jpj)    :: zRHO1, zRHO2  ! Densities 
+      INTEGER :: ji, jj, jk                             ! loop counter 
+
+      !!------------------------------------------------------------------------------------- 
+      !  
+      ! Unpack structure
+      nn_mld_type = sf%mld_type
+      rn_zref     = sf%zref
+      rn_dT_crit  = sf%dT_crit
+      rn_iso_frac = sf%iso_frac
+
+      ! Set the mixed layer depth criterion at each grid point 
+      IF( nn_mld_type == 0 ) THEN
+         zdelta_T(:,:) = rn_dT_crit
+         zT(:,:,:) = rhop(:,:,:)
+      ELSE IF( nn_mld_type == 1 ) THEN
+         ppzdep(:,:)=0.0 
+         call eos ( tsn(:,:,1,:), ppzdep(:,:), zRHO1(:,:) ) 
+! Use zT temporarily as a copy of tsn with rn_dT_crit added to SST 
+! [assumes number of tracers less than number of vertical levels] 
+         zT(:,:,1:jpts)=tsn(:,:,1,1:jpts) 
+         zT(:,:,jp_tem)=zT(:,:,1)+rn_dT_crit 
+         CALL eos( zT(:,:,1:jpts), ppzdep(:,:), zRHO2(:,:) ) 
+         zdelta_T(:,:) = abs( zRHO1(:,:) - zRHO2(:,:) ) * rau0 
+         ! RHO from eos (2d version) doesn't calculate north or east halo: 
+         CALL lbc_lnk( 'zdfmxl', zdelta_T, 'T', 1. ) 
+         zT(:,:,:) = rhop(:,:,:) 
+      ELSE 
+         zdelta_T(:,:) = rn_dT_crit                      
+         zT(:,:,:) = tsn(:,:,:,jp_tem)                           
+      END IF 
+
+      ! Calculate the gradient of zT and absolute difference for use later 
+      DO jk = 1 ,jpk-2 
+         zdTdz(:,:,jk)  =    ( zT(:,:,jk+1) - zT(:,:,jk) ) / e3w_n(:,:,jk+1) 
+         zmoddT(:,:,jk) = abs( zT(:,:,jk+1) - zT(:,:,jk) ) 
+      END DO 
+
+      ! Find density/temperature at the reference level (Kara et al use 10m).          
+      ! ik_ref is the index of the box centre immediately above or at the reference level 
+      ! Find rn_zref in the array of model level depths and find the ref    
+      ! density/temperature by linear interpolation.                                   
+      DO jk = jpkm1, 2, -1 
+         WHERE ( gdept_n(:,:,jk) > rn_zref ) 
+           ik_ref(:,:) = jk - 1 
+           zT_ref(:,:) = zT(:,:,jk-1) + zdTdz(:,:,jk-1) * ( rn_zref - gdept_n(:,:,jk-1) ) 
+         END WHERE 
+      END DO 
+
+      ! If the first grid box centre is below the reference level then use the 
+      ! top model level to get zT_ref 
+      WHERE ( gdept_n(:,:,1) > rn_zref )  
+         zT_ref = zT(:,:,1) 
+         ik_ref = 1 
+      END WHERE 
+
+      ! The number of active tracer levels is 1 less than the number of active w levels 
+      ikmt(:,:) = mbkt(:,:) - 1 
+
+      ! Initialize / reset
+      ll_found(:,:) = .false.
+
+      IF ( rn_iso_frac - zepsilon > 0. ) THEN
+         ! Search for a uniform density/temperature region where adjacent levels          
+         ! differ by less than rn_iso_frac * deltaT.                                      
+         ! ik_iso is the index of the last level in the uniform layer  
+         ! ll_found indicates whether the mixed layer depth can be found by interpolation 
+         ik_iso(:,:)   = ik_ref(:,:) 
+         DO jj = 1, nlcj 
+            DO ji = 1, nlci 
+!CDIR NOVECTOR 
+               DO jk = ik_ref(ji,jj), ikmt(ji,jj)-1 
+                  IF ( zmoddT(ji,jj,jk) > ( rn_iso_frac * zdelta_T(ji,jj) ) ) THEN 
+                     ik_iso(ji,jj)   = jk 
+                     ll_found(ji,jj) = ( zmoddT(ji,jj,jk) > zdelta_T(ji,jj) ) 
+                     EXIT 
+                  END IF 
+               END DO 
+            END DO 
+         END DO 
+
+         ! Use linear interpolation to find depth of mixed layer base where possible 
+         hmld_zint(:,:) = rn_zref 
+         DO jj = 1, jpj 
+            DO ji = 1, jpi 
+               IF (ll_found(ji,jj) .and. tmask(ji,jj,1) == 1.0) THEN 
+                  zdz =  abs( zdelta_T(ji,jj) / zdTdz(ji,jj,ik_iso(ji,jj)) ) 
+                  hmld_zint(ji,jj) = gdept_n(ji,jj,ik_iso(ji,jj)) + zdz 
+               END IF 
+            END DO 
+         END DO 
+      END IF
+
+      ! If ll_found = .false. then calculate MLD using difference of zdelta_T    
+      ! from the reference density/temperature 
+ 
+! Prevent this section from working on land points 
+      WHERE ( tmask(:,:,1) /= 1.0 ) 
+         ll_found = .true. 
+      END WHERE 
+ 
+      DO jk=1, jpk 
+         ll_belowml(:,:,jk) = abs( zT(:,:,jk) - zT_ref(:,:) ) >= zdelta_T(:,:)  
+      END DO 
+ 
+! Set default value where interpolation cannot be used (ll_found=false)  
+      DO jj = 1, jpj 
+         DO ji = 1, jpi 
+            IF ( .not. ll_found(ji,jj) )  hmld_zint(ji,jj) = gdept_n(ji,jj,ikmt(ji,jj)) 
+         END DO 
+      END DO 
+
+      DO jj = 1, jpj 
+         DO ji = 1, jpi 
+!CDIR NOVECTOR 
+            DO jk = ik_ref(ji,jj)+1, ikmt(ji,jj) 
+               IF ( ll_found(ji,jj) ) EXIT 
+               IF ( ll_belowml(ji,jj,jk) ) THEN                
+                  zT_b = zT_ref(ji,jj) + zdelta_T(ji,jj) * SIGN(1.0, zdTdz(ji,jj,jk-1) ) 
+                  zdT  = zT_b - zT(ji,jj,jk-1)                                      
+                  zdz  = zdT / zdTdz(ji,jj,jk-1)                                       
+                  hmld_zint(ji,jj) = gdept_n(ji,jj,jk-1) + zdz 
+                  EXIT                                                   
+               END IF 
+            END DO 
+         END DO 
+      END DO 
+
+      hmld_zint(:,:) = hmld_zint(:,:)*tmask(:,:,1) 
+      !  
+   END SUBROUTINE zdf_mxl_zint_mld
+
+   SUBROUTINE zdf_mxl_zint_htc( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_mxl_zint_htc  ***
+      !! 
+      !! ** Purpose :   
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+
+      INTEGER :: ji, jj, jk
+      INTEGER :: ikmax
+      REAL(wp) :: zc, zcoef
+      !
+      INTEGER,  ALLOCATABLE, DIMENSION(:,:) ::   ilevel
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zthick_0, zthick
+
+      !!----------------------------------------------------------------------
+
+      IF( .NOT. ALLOCATED(ilevel) ) THEN
+         ALLOCATE( ilevel(jpi,jpj), zthick_0(jpi,jpj), &
+         &         zthick(jpi,jpj), STAT=ji )
+         IF( lk_mpp  )   CALL mpp_sum( 'zdfmxl', ji )
+         IF( ji /= 0 )   CALL ctl_stop( 'STOP', 'zdf_mxl_zint_htc : unable to allocate arrays' )
+      ENDIF
+
+      ! Find last whole model T level above the MLD
+      ilevel(:,:)   = 0
+      zthick_0(:,:) = 0._wp
+
+      DO jk = 1, jpkm1  
+         DO jj = 1, jpj
+            DO ji = 1, jpi                    
+               zthick_0(ji,jj) = zthick_0(ji,jj) + e3t_n(ji,jj,jk)
+               IF( zthick_0(ji,jj) < hmld_zint(ji,jj) )   ilevel(ji,jj) = jk
+            END DO
+         END DO
+         WRITE(numout,*) 'zthick_0(jk =',jk,') =',zthick_0(2,2)
+         WRITE(numout,*) 'gdepw_n(jk+1 =',jk+1,') =',gdepw_n(2,2,jk+1)
+      END DO
+
+      ! Surface boundary condition
+      IF( ln_linssh ) THEN  ;   zthick(:,:) = sshn(:,:)   ;   htc_mld(:,:) = tsn(:,:,1,jp_tem) * sshn(:,:) * tmask(:,:,1)   
+      ELSE                  ;   zthick(:,:) = 0._wp       ;   htc_mld(:,:) = 0._wp                                   
+      ENDIF
+
+      ! Deepest whole T level above the MLD
+      ikmax = MIN( MAXVAL( ilevel(:,:) ), jpkm1 )
+
+      ! Integration down to last whole model T level
+      DO jk = 1, ikmax
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zc = e3t_n(ji,jj,jk) * REAL( MIN( MAX( 0, ilevel(ji,jj) - jk + 1 ) , 1  )  )    ! 0 below ilevel
+               zthick(ji,jj) = zthick(ji,jj) + zc
+               htc_mld(ji,jj) = htc_mld(ji,jj) + zc * tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+
+      ! Subsequent partial T level
+      zthick(:,:) = hmld_zint(:,:) - zthick(:,:)   !   remaining thickness to reach MLD
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            htc_mld(ji,jj) = htc_mld(ji,jj) + tsn(ji,jj,ilevel(ji,jj)+1,jp_tem)  & 
+      &                      * MIN( e3t_n(ji,jj,ilevel(ji,jj)+1), zthick(ji,jj) ) * tmask(ji,jj,ilevel(ji,jj)+1)
+         END DO
+      END DO
+
+      WRITE(numout,*) 'htc_mld(after) =',htc_mld(2,2)
+
+      ! Convert to heat content
+      zcoef = rau0 * rcp
+      htc_mld(:,:) = zcoef * htc_mld(:,:)
+
+   END SUBROUTINE zdf_mxl_zint_htc
+
+   SUBROUTINE zdf_mxl_zint( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zdf_mxl_zint  ***
+      !! 
+      !! ** Purpose :   
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+
+      INTEGER :: ios
+      INTEGER :: jn
+
+      INTEGER :: nn_mld_diag = 0    ! number of diagnostics
+
+      CHARACTER(len=1) :: cmld
+
+      TYPE(MXL_ZINT) :: sn_mld1, sn_mld2, sn_mld3, sn_mld4, sn_mld5
+      TYPE(MXL_ZINT), SAVE, DIMENSION(5) ::   mld_diags
+
+      NAMELIST/namzdf_mldzint/ nn_mld_diag, sn_mld1, sn_mld2, sn_mld3, sn_mld4, sn_mld5
+
+      !!----------------------------------------------------------------------
+      
+      IF( kt == nit000 ) THEN
+         REWIND( numnam_ref )              ! Namelist namzdf_mldzint in reference namelist 
+         READ  ( numnam_ref, namzdf_mldzint, IOSTAT = ios, ERR = 901)
+901      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_mldzint in reference namelist' )
+
+         REWIND( numnam_cfg )              ! Namelist namzdf_mldzint in configuration namelist 
+         READ  ( numnam_cfg, namzdf_mldzint, IOSTAT = ios, ERR = 902 )
+902      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_mldzint in configuration namelist' )
+         IF(lwm) WRITE ( numond, namzdf_mldzint )
+
+         IF( nn_mld_diag > 5 )   CALL ctl_stop( 'STOP', 'zdf_mxl_ini: Specify no more than 5 MLD definitions' )
+
+         mld_diags(1) = sn_mld1
+         mld_diags(2) = sn_mld2
+         mld_diags(3) = sn_mld3
+         mld_diags(4) = sn_mld4
+         mld_diags(5) = sn_mld5
+
+         IF( lwp .AND. (nn_mld_diag > 0) ) THEN
+            WRITE(numout,*) '=============== Vertically-interpolated mixed layer ================'
+            WRITE(numout,*) '(Diagnostic number, nn_mld_type, rn_zref, rn_dT_crit, rn_iso_frac)'
+            DO jn = 1, nn_mld_diag
+               WRITE(numout,*) 'MLD criterion',jn,':'
+               WRITE(numout,*) '    nn_mld_type =', mld_diags(jn)%mld_type
+               WRITE(numout,*) '    rn_zref ='    , mld_diags(jn)%zref
+               WRITE(numout,*) '    rn_dT_crit =' , mld_diags(jn)%dT_crit
+               WRITE(numout,*) '    rn_iso_frac =', mld_diags(jn)%iso_frac
+            END DO
+            WRITE(numout,*) '===================================================================='
+         ENDIF
+      ENDIF
+
+      IF( nn_mld_diag > 0 ) THEN
+         DO jn = 1, nn_mld_diag
+            WRITE(cmld,'(I1)') jn
+            IF( iom_use( "mldzint_"//cmld ) .OR. iom_use( "mldhtc_"//cmld ) ) THEN
+               CALL zdf_mxl_zint_mld( mld_diags(jn) )
+
+               IF( iom_use( "mldzint_"//cmld ) ) THEN
+                  CALL iom_put( "mldzint_"//cmld, hmld_zint(:,:) )
+               ENDIF
+
+               IF( iom_use( "mldhtc_"//cmld ) )  THEN
+                  CALL zdf_mxl_zint_htc( kt )
+                  CALL iom_put( "mldhtc_"//cmld , htc_mld(:,:)   )
+               ENDIF
+            ENDIF
+         END DO
+      ENDIF
+
+   END SUBROUTINE zdf_mxl_zint
 
    !!======================================================================
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/step.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/step.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/step.F90	(revision 14671)
@@ -207,4 +207,5 @@
       IF( ln_diaptr  )   CALL dia_ptr                 ! Poleward adv/ldf TRansports diagnostics
       IF( ln_diaharm )   CALL dia_harm( kstp )        ! Tidal harmonic analysis
+                         CALL dia_prod( kstp )        ! ocean model: product diagnostics
                          CALL dia_wri ( kstp )        ! ocean model: outputs
       !
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/step_oce.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/step_oce.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/OCE/step_oce.F90	(revision 14671)
@@ -80,4 +80,5 @@
    USE diahsb          ! heat, salt and volume budgets    (dia_hsb routine)
    USE diaharm
+   USE diaprod
    USE diacfl
    USE diaobs          ! Observation operator
Index: NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/SAS/sbcssm.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/SAS/sbcssm.F90	(revision 14670)
+++ NEMO/branches/UKMO/NEMO_4.0.4_fix_topo_minor/src/SAS/sbcssm.F90	(revision 14671)
@@ -77,5 +77,15 @@
       REAL(wp) ::   ztinta     ! ratio applied to after  records when doing time interpolation
       REAL(wp) ::   ztintb     ! ratio applied to before records when doing time interpolation
-      !!----------------------------------------------------------------------
+      CHARACTER(len=4),SAVE :: stype
+      !!---------------------------------------------------------------------
+      IF( kt == nit000 ) THEN
+         IF( ln_TEOS10 ) THEN
+            stype='abs'   ! teos-10: using absolute salinity (sst is converted to potential temperature for the surface module)
+         ELSE IF( ln_EOS80  ) THEN
+            stype='pra'   ! eos-80: using practical salinity
+         ELSE IF ( ln_SEOS) THEN
+            stype='seos' ! seos using Simplified Equation of state (sst is converted to potential temperature for the surface module)
+         ENDIF
+      ENDIF
       !
       IF( ln_timing )   CALL timing_start( 'sbc_ssm')
@@ -144,6 +154,6 @@
          CALL iom_put( 'ssu_m', ssu_m )
          CALL iom_put( 'ssv_m', ssv_m )
-         CALL iom_put( 'sst_m', sst_m )
-         CALL iom_put( 'sss_m', sss_m )
+         CALL iom_put( 'sst_m_pot', sst_m )
+         CALL iom_put( 'sss_m_'//stype, sss_m )
          CALL iom_put( 'ssh_m', ssh_m )
          IF( .NOT.ln_linssh )   CALL iom_put( 'e3t_m', e3t_m )
