Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/iodef.xml
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/iodef.xml	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/iodef.xml	(revision 7483)
@@ -88,5 +88,5 @@
 	  <field field_ref="u_masstr"     name="vozomatr" />
 	  <field field_ref="u_heattr"     name="sozohetr" />
-      <field field_ref="u_salttr"     name="sozosatr" />
+	  <field field_ref="u_salttr"     name="sozosatr" />
 	</file>
 	
@@ -99,5 +99,5 @@
 	  <field field_ref="v_masstr"     name="vomematr" />
 	  <field field_ref="v_heattr"     name="somehetr" />
-      <field field_ref="v_salttr"     name="somesatr" />
+	  <field field_ref="v_salttr"     name="somesatr" />
 	</file>
 	
@@ -116,14 +116,8 @@
           <field field_ref="iceconc"         name="siconc" />
 
-          <field field_ref="vfxbog"          name="vfxbog" />
-          <field field_ref="vfxdyn"          name="vfxdyn" />
-          <field field_ref="vfxopw"          name="vfxopw" />
-          <field field_ref="vfxsni"          name="vfxsni" />
-          <field field_ref="vfxsum"          name="vfxsum" />
-          <field field_ref="vfxbom"          name="vfxbom" />
-          <field field_ref="vfxres"          name="vfxres" />
           <field field_ref="vfxice"          name="vfxice" />
           <field field_ref="vfxsnw"          name="vfxsnw" />
           <field field_ref="vfxsub"          name="vfxsub" />
+          <field field_ref="vfxsub_err"      name="vfxsub_err" />
           <field field_ref="vfxspr"          name="vfxspr" />
 
@@ -134,37 +128,11 @@
           <field field_ref="destrp"          name="destrp" />
 
-          <field field_ref="sfxbri"          name="sfxbri" />
-          <field field_ref="sfxdyn"          name="sfxdyn" />
-          <field field_ref="sfxres"          name="sfxres" />
-          <field field_ref="sfxbog"          name="sfxbog" />
-          <field field_ref="sfxbom"          name="sfxbom" />
-          <field field_ref="sfxsum"          name="sfxsum" />
-          <field field_ref="sfxsni"          name="sfxsni" />
-          <field field_ref="sfxopw"          name="sfxopw" />
           <field field_ref="sfx"             name="sfx"    />
 
-          <field field_ref="hfxsum"          name="hfxsum"     />
-          <field field_ref="hfxbom"          name="hfxbom"     />
-          <field field_ref="hfxbog"          name="hfxbog"     />
-          <field field_ref="hfxdif"          name="hfxdif"     />
-          <field field_ref="hfxopw"          name="hfxopw"     />
           <field field_ref="hfxout"          name="hfxout"     />
           <field field_ref="hfxin"           name="hfxin"      />
-          <field field_ref="hfxsnw"          name="hfxsnw"     />
-          <field field_ref="hfxerr"          name="hfxerr"     />
-          <field field_ref="hfxerr_rem"      name="hfxerr_rem" />
-
-	  <!-- ice-ocean heat flux from mass exchange -->
-          <field field_ref="hfxdyn"          name="hfxdyn" />
-          <field field_ref="hfxres"          name="hfxres" />
-          <field field_ref="hfxthd"          name="hfxthd" />
-	  <!-- ice-atm. heat flux from mass exchange -->
-          <field field_ref="hfxsub"          name="hfxsub" />
-          <field field_ref="hfxspr"          name="hfxspr" />
+
 
 	  <!-- diags -->
-          <field field_ref="hfxdhc"          name="hfxdhc" />
-          <field field_ref="hfxtur"          name="hfxtur" />
-
           <field field_ref="isst"            name="sst"    />
           <field field_ref="isss"            name="sss"    />
@@ -209,4 +177,5 @@
           <field field_ref="bgsaline"     name="bgsaline"   />
           <field field_ref="bgheatco"     name="bgheatco"   />
+          <field field_ref="bgheatfx"     name="bgheatfx"   />
           <field field_ref="bgsaltco"     name="bgsaltco"   />
           <field field_ref="bgvolssh"     name="bgvolssh"   /> 
@@ -214,56 +183,26 @@
           <field field_ref="bgfrcvol"     name="bgfrcvol"   />
           <field field_ref="bgfrctem"     name="bgfrctem"   />
+          <field field_ref="bgfrchfx"     name="bgfrchfx"   />
           <field field_ref="bgfrcsal"     name="bgfrcsal"   />
 
-          <field field_ref="ibgvoltot"    name="ibgvoltot"  />
-          <field field_ref="sbgvoltot"    name="sbgvoltot"  />
-          <field field_ref="ibgarea"      name="ibgarea"    />
-          <field field_ref="ibgsaline"    name="ibgsaline"  />
-          <field field_ref="ibgtemper"    name="ibgtemper"  />
-          <field field_ref="ibgheatco"    name="ibgheatco"  />
-          <field field_ref="sbgheatco"    name="sbgheatco"  />
-          <field field_ref="ibgsaltco"    name="ibgsaltco"  />
-
-          <field field_ref="ibgvfx"       name="ibgvfx"     />
-          <field field_ref="ibgvfxbog"    name="ibgvfxbog"  />
-          <field field_ref="ibgvfxopw"    name="ibgvfxopw"  />
-          <field field_ref="ibgvfxsni"    name="ibgvfxsni"  />
-          <field field_ref="ibgvfxdyn"    name="ibgvfxdyn"  />
-          <field field_ref="ibgvfxbom"    name="ibgvfxbom"  />
-          <field field_ref="ibgvfxsum"    name="ibgvfxsum"  />
-          <field field_ref="ibgvfxres"    name="ibgvfxres"  />
-          <field field_ref="ibgvfxspr"    name="ibgvfxspr"  />
-          <field field_ref="ibgvfxsnw"    name="ibgvfxsnw"  />
-          <field field_ref="ibgvfxsub"    name="ibgvfxsub"  />
-
-          <field field_ref="ibgsfx"       name="ibgsfx"     />
-          <field field_ref="ibgsfxbri"    name="ibgsfxbri"  />
-          <field field_ref="ibgsfxdyn"    name="ibgsfxdyn"  />
-          <field field_ref="ibgsfxres"    name="ibgsfxres"  />
-          <field field_ref="ibgsfxbog"    name="ibgsfxbog"  />
-          <field field_ref="ibgsfxopw"    name="ibgsfxopw"  />
-          <field field_ref="ibgsfxsni"    name="ibgsfxsni"  />
-          <field field_ref="ibgsfxbom"    name="ibgsfxbom"  />
-          <field field_ref="ibgsfxsum"    name="ibgsfxsum"  />
-
-          <field field_ref="ibghfxdhc"    name="ibghfxdhc"  />
-          <field field_ref="ibghfxspr"    name="ibghfxspr"  />
-
-          <field field_ref="ibghfxres"    name="ibghfxres"  />
-          <field field_ref="ibghfxsub"    name="ibghfxsub"  />
-          <field field_ref="ibghfxdyn"    name="ibghfxdyn"  />
-          <field field_ref="ibghfxthd"    name="ibghfxthd"  />
-          <field field_ref="ibghfxsum"    name="ibghfxsum"  />
-          <field field_ref="ibghfxbom"    name="ibghfxbom"  />
-          <field field_ref="ibghfxbog"    name="ibghfxbog"  />
-          <field field_ref="ibghfxdif"    name="ibghfxdif"  />
-          <field field_ref="ibghfxopw"    name="ibghfxopw"  />
-          <field field_ref="ibghfxout"    name="ibghfxout"  />
-          <field field_ref="ibghfxin"     name="ibghfxin"   />
-          <field field_ref="ibghfxsnw"    name="ibghfxsnw"  />
-
-          <field field_ref="ibgfrcvol"    name="ibgfrcvol"  />
-          <field field_ref="ibgfrcsfx"    name="ibgfrcsfx"  />
-          <field field_ref="ibgvolgrm"    name="ibgvolgrm"  />
+	  <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" />
+	  
+	  <field field_ref="ibgvolume"    name="ibgvolume"   />
+	  <field field_ref="ibgsaltco"    name="ibgsaltco"   />
+	  <field field_ref="ibgheatco"    name="ibgheatco"   />
+          <field field_ref="ibgheatfx"    name="ibgheatfx"   />
+	  
+	  <field field_ref="ibgfrcvoltop" name="ibgfrcvoltop" />
+	  <field field_ref="ibgfrcvolbot" name="ibgfrcvolbot" />
+	  <field field_ref="ibgfrctemtop" name="ibgfrctemtop" />
+	  <field field_ref="ibgfrctembot" name="ibgfrctembot" />
+	  <field field_ref="ibgfrcsal"    name="ibgfrcsal"    />
+          <field field_ref="ibgfrchfxtop" name="ibgfrchfxtop" />
+          <field field_ref="ibgfrchfxbot" name="ibgfrchfxbot" />
 
         </file>
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/CONFIG/SHARED/field_def.xml
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 7483)
@@ -225,5 +225,7 @@
          <field id="hflx_rain_cea" long_name="heat flux due to rainfall"                                standard_name="temperature_flux_due_to_rainfall_expressed_as_heat_flux_into_sea_water"        unit="W/m2"     />
          <field id="hflx_evap_cea" long_name="heat flux due to evaporation"                             standard_name="temperature_flux_due_to_evaporation_expressed_as_heat_flux_out_of_sea_water"   unit="W/m2"     />
-         <field id="hflx_snow_cea" long_name="heat flux due to snow falling over ice-free ocean"        standard_name="heat_flux_into_sea_water_due_to_snow_thermodynamics"                           unit="W/m2"     />
+         <field id="hflx_snow_cea" long_name="heat flux due to snow falling"                            standard_name="heat_flux_onto_ocean_and_ice_due_to_snow_thermodynamics"                       unit="W/m2"     />
+         <field id="hflx_snow_ai_cea" long_name="heat flux due to snow falling over ice"                standard_name="heat_flux_onto_ice_due_to_snow_thermodynamics"                                 unit="W/m2"     />
+         <field id="hflx_snow_ao_cea" long_name="heat flux due to snow falling over ice-free ocean"     standard_name="heat_flux_onto_sea_water_due_to_snow_thermodynamics"                           unit="W/m2"     />
          <field id="hflx_ice_cea"  long_name="heat flux due to ice thermodynamics"                      standard_name="heat_flux_into_sea_water_due_to_sea_ice_thermodynamics"                        unit="W/m2"     />
          <field id="hflx_rnf_cea"  long_name="heat flux due to runoffs"                                 standard_name="temperature_flux_due_to_runoff_expressed_as_heat_flux_into_sea_water"          unit="W/m2"     />
@@ -331,4 +333,5 @@
          <field id="vfxsnw"       long_name="snw melt/growth"                                              unit="m/day"   />
          <field id="vfxsub"       long_name="snw sublimation"                                              unit="m/day"   />
+         <field id="vfxsub_err"   long_name="excess of snw sublimation sent to ocean"                      unit="m/day"   />
          <field id="vfxspr"       long_name="snw precipitation on ice"                                     unit="m/day"   />
          <field id="vfxthin"      long_name="daily thermo ice prod. for thin ice(<20cm) + open water"      unit="m/day"   />
@@ -499,16 +502,15 @@
     	 <field id="bgtemper"     long_name="drift in global mean temperature wrt timestep 1"                 standard_name="change_over_time_in_sea_water_potential_temperature"   unit="degC"     />
     	 <field id="bgsaline"     long_name="drift in global mean salinity wrt timestep 1"                    standard_name="change_over_time_in_sea_water_practical_salinity"      unit="1e-3"     />
-    	 <field id="bgheatco"     long_name="drift in global mean heat content wrt timestep 1"                                                                                      unit="10^9J"    />
-    	 <field id="bgsaltco"     long_name="drift in global mean salt content wrt timestep 1"                                                                                      unit="1e-3*m3"  />
+    	 <field id="bgheatco"     long_name="drift in global mean heat content wrt timestep 1"                                                                                      unit="1.e20J"   />
+     	 <field id="bgheatfx"     long_name="drift in global mean heat flux    wrt timestep 1"                                                                                      unit="W/m2"     />
+   	 <field id="bgsaltco"     long_name="drift in global mean salt content wrt timestep 1"                                                                                      unit="1e-3*km3" />
     	 <field id="bgvolssh"     long_name="drift in global mean ssh volume wrt timestep 1"                                                                                        unit="km3"      />
          <field id="bgvole3t"     long_name="drift in global mean volume variation (e3t) wrt timestep 1"                                                                            unit="km3"      />
-    	 <field id="bgvoltot"     long_name="drift in global mean volume wrt timestep 1"                                                                                            unit="km3"      />
-         <!-- NOTE: No matching iom_put call -->
-    	 <field id="bgsshtot"     long_name="drift in global mean ssh wrt timestep 1"                         standard_name="global_average_sea_level_change"                       unit="m"        />
-    	 <field id="bgfrcvol"     long_name="drift in global mean volume from forcing wrt timestep 1"                                                                               unit="km3"      />
-    	 <field id="bgfrctem"     long_name="drift in global mean heat content from forcing wrt timestep 1"                                                                         unit="10^9J"    />
-    	 <field id="bgfrcsal"     long_name="drift in global mean salt content from forcing wrt timestep 1"                                                                         unit="1e-3*km3" />
-    	 <field id="bgmistem"     long_name="global mean temperature error due to free surface"                                                                                     unit="degC"     />
-    	 <field id="bgmissal"     long_name="global mean salinity error due to free surface"                                                                                        unit="1e-3"     />
+    	 <field id="bgfrcvol"     long_name="global mean volume from forcing"                                                                                                       unit="km3"      />
+    	 <field id="bgfrctem"     long_name="global mean heat content from forcing"                                                                                                 unit="1.e20J"   />
+         <field id="bgfrchfx"     long_name="global mean heat flux from forcing"                                                                                                    unit="W/m2"     />
+    	 <field id="bgfrcsal"     long_name="global mean salt content from forcing"                                                                                                 unit="1e-3*km3" />
+    	 <field id="bgmistem"     long_name="global mean temperature error due to free surface (no vvl)"                                                                            unit="degC"     />
+    	 <field id="bgmissal"     long_name="global mean salinity error due to free surface (no vvl)"                                                                               unit="1e-3"     />
       </field_group>
 
@@ -517,55 +519,23 @@
       <field_group id="SBC_scalar"  domain_ref="1point" >
          <!-- available with ln_limdiaout -->
-         <field id="ibgvoltot"    long_name="global mean ice volume"                                 unit="km3"        />
-         <field id="sbgvoltot"    long_name="global mean snow volume"                                unit="km3"        />
-         <field id="ibgarea"      long_name="global mean ice area"                                   unit="km2"        />
-         <field id="ibgsaline"    long_name="global mean ice salinity"                               unit="1e-3"       />
-         <field id="ibgtemper"    long_name="global mean ice temperature"                            unit="degC"       />
-         <field id="ibgheatco"    long_name="global mean ice heat content"                           unit="10^20J"     />
-         <field id="sbgheatco"    long_name="global mean snow heat content"                          unit="10^20J"     />
-         <field id="ibgsaltco"    long_name="global mean ice salt content"                           unit="1e-3*km3"   />
-
-         <field id="ibgvfx"       long_name="global mean volume flux (emp)"                          unit="m/day"      />
-         <field id="ibgvfxbog"    long_name="global mean volume flux (bottom growth)"                unit="m/day"      />
-         <field id="ibgvfxopw"    long_name="global mean volume flux (open water growth)"            unit="m/day"      />
-         <field id="ibgvfxsni"    long_name="global mean volume flux (snow-ice growth)"              unit="m/day"      />
-         <field id="ibgvfxdyn"    long_name="global mean volume flux (dynamic growth)"               unit="m/day"      />
-         <field id="ibgvfxbom"    long_name="global mean volume flux (bottom melt)"                  unit="m/day"      />
-         <field id="ibgvfxsum"    long_name="global mean volume flux (surface melt)"                 unit="m/day"      />
-         <field id="ibgvfxres"    long_name="global mean volume flux (resultant)"                    unit="m/day"      />
-         <field id="ibgvfxspr"    long_name="global mean volume flux (snow precip)"                  unit="m/day"      />
-         <field id="ibgvfxsnw"    long_name="global mean volume flux (snow melt)"                    unit="m/day"      />
-         <field id="ibgvfxsub"    long_name="global mean volume flux (snow sublimation)"             unit="m/day"      />
-
-         <field id="ibgsfx"       long_name="global mean salt flux (total)"                          unit="1e-3*m/day" />
-         <field id="ibgsfxbri"    long_name="global mean salt flux (brines)"                         unit="1e-3*m/day" />
-         <field id="ibgsfxdyn"    long_name="global mean salt flux (dynamic)"                        unit="1e-3*m/day" />
-         <field id="ibgsfxres"    long_name="global mean salt flux (resultant)"                      unit="1e-3*m/day" />
-         <field id="ibgsfxbog"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
-         <field id="ibgsfxopw"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
-         <field id="ibgsfxsni"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
-         <field id="ibgsfxbom"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
-         <field id="ibgsfxsum"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
-         <field id="ibgsfxsub"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
-
-         <field id="ibghfxdhc"    long_name="Heat content variation in snow and ice"                 unit="W"          />
-         <field id="ibghfxspr"    long_name="Heat content of snow precip"                            unit="W"          />
-
-         <field id="ibghfxthd"    long_name="heat fluxes from ice-ocean exchange during thermo"      unit="W"          />
-         <field id="ibghfxsum"    long_name="heat fluxes causing surface ice melt"                   unit="W"          />
-         <field id="ibghfxbom"    long_name="heat fluxes causing bottom ice melt"                    unit="W"          />
-         <field id="ibghfxbog"    long_name="heat fluxes causing bottom ice growth"                  unit="W"          />
-         <field id="ibghfxdif"    long_name="heat fluxes causing ice temperature change"             unit="W"          />
-         <field id="ibghfxopw"    long_name="heat fluxes causing open water ice formation"           unit="W"          />
-         <field id="ibghfxdyn"    long_name="heat fluxes from ice-ocean exchange during dynamic"     unit="W"          />
-         <field id="ibghfxres"    long_name="heat fluxes from ice-ocean exchange during resultant"   unit="W"          />
-         <field id="ibghfxsub"    long_name="heat fluxes from sublimation"                           unit="W"          />
-         <field id="ibghfxsnw"    long_name="heat fluxes from snow-ocean exchange"                   unit="W"          />
-         <field id="ibghfxout"    long_name="non solar heat fluxes received by the ocean"            unit="W"          />
-         <field id="ibghfxin"     long_name="total heat fluxes at the ice surface"                   unit="W"          />
-
-         <field id="ibgfrcvol"    long_name="global mean forcing volume (emp)"                       unit="km3"        />
-         <field id="ibgfrcsfx"    long_name="global mean forcing salt   (sfx)"                       unit="1e-3*km3"   />
-         <field id="ibgvolgrm"    long_name="global mean ice growth+melt volume"                     unit="km3"        />
+         <field id="ibgfrcvoltop"    long_name="global mean ice/snow forcing at interface ice/snow-atm (volume equivalent ocean volume)"   unit="km3"       />
+         <field id="ibgfrcvolbot"    long_name="global mean ice/snow forcing at interface ice/snow-ocean (volume equivalent ocean volume)" unit="km3"       />
+         <field id="ibgfrctemtop"    long_name="global mean heat on top of ice/snw/ocean-atm "                                             unit="1e20J"     />
+         <field id="ibgfrctembot"    long_name="global mean heat below ice (on top of ocean) "                                             unit="1e20J"     />
+         <field id="ibgfrcsal"       long_name="global mean ice/snow forcing (salt equivalent ocean volume)"                               unit="pss*km3"   />
+         <field id="ibgfrchfxtop"    long_name="global mean heat flux on top of ice/snw/ocean-atm "                                        unit="W/m2"      />
+         <field id="ibgfrchfxbot"    long_name="global mean heat flux below ice (on top of ocean) "                                        unit="W/m2"      />
+ 
+         <field id="ibgvolume"    long_name="drift in ice/snow volume (equivalent ocean volume)"            unit="km3"        />
+         <field id="ibgsaltco"    long_name="drift in ice salt content (equivalent ocean volume)"           unit="pss*km3"    />
+         <field id="ibgheatco"    long_name="drift in ice/snow heat content"                                unit="1e20J"      />
+         <field id="ibgheatfx"    long_name="drift in ice/snow heat flux"                                   unit="W/m2"       />
+
+         <field id="ibgvol_tot"    long_name="global mean ice volume"                                       unit="km3"        />
+         <field id="sbgvol_tot"    long_name="global mean snow volume"                                      unit="km3"        />
+         <field id="ibgarea_tot"   long_name="global mean ice area"                                         unit="km2"        />
+         <field id="ibgsalt_tot"   long_name="global mean ice salt content"                                 unit="1e-3*km3"   />
+         <field id="ibgheat_tot"   long_name="global mean ice heat content"                                 unit="1e20J"      />
+         <field id="sbgheat_tot"   long_name="global mean snow heat content"                                unit="1e20J"      />
       </field_group>
   
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/CONFIG/SHARED/namelist_pisces_ref
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/CONFIG/SHARED/namelist_pisces_ref	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/CONFIG/SHARED/namelist_pisces_ref	(revision 7483)
@@ -66,4 +66,5 @@
    qdfelim    =  7.E-6    ! Optimal quota of diatoms
    caco3r     =  0.3      ! mean rain ratio
+   oxymin    =  1.E-6     ! Half-saturation constant for anoxia
 /
 !'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
@@ -162,5 +163,4 @@
    xsiremlab =  0.03      ! fast remineralization rate of Si
    xsilab    =  0.5       ! Fraction of labile biogenic silica
-   oxymin    =  1.E-6     ! Half-saturation constant for anoxia
 /
 !'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/ice.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 7483)
@@ -243,5 +243,4 @@
    !
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sist        !: Average Sea-Ice Surface Temperature [Kelvin]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   icethi      !: total ice thickness (for all categories) (diag only)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   t_bo        !: Sea-Ice bottom temperature [Kelvin]     
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   frld        !: Leads fraction = 1 - ice fraction
@@ -320,18 +319,20 @@
    !                                                                  !  this is an extensive variable that has to be transported
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   o_i     !: Sea-Ice Age (days)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ov_i    !: Sea-Ice Age times volume per area (days.m)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   oa_i    !: Sea-Ice Age times ice area (days)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   bv_i    !: brine volume
 
    !! Variables summed over all categories, or associated to all the ice in a single grid cell
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   u_ice, v_ice   !: components of the ice velocity (m/s)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   tio_u, tio_v   !: components of the ice-ocean stress (N/m2)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   vt_i , vt_s    !: ice and snow total volume per unit area (m)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   at_i           !: ice total fractional area (ice concentration)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ato_i          !: =1-at_i ; total open water fractional area
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   et_i , et_s    !: ice and snow total heat content
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ot_i           !: mean age over all categories
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   tm_i           !: mean ice temperature over all categories
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   bv_i           !: brine volume averaged over all categories
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   smt_i          !: mean sea ice salinity averaged over all categories [PSU]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   tm_i         !: mean ice temperature over all categories
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   bvm_i        !: brine volume averaged over all categories
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   smt_i        !: mean sea ice salinity averaged over all categories [PSU]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   tm_su        !: mean surface temperature over all categories
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   htm_i        !: mean ice  thickness over all categories
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   htm_s        !: mean snow thickness over all categories
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   om_i         !: mean ice age over all categories
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   t_s        !: Snow temperatures [K]
@@ -435,5 +436,5 @@
 
       ii = ii + 1
-      ALLOCATE( sist   (jpi,jpj) , icethi (jpi,jpj) , t_bo   (jpi,jpj) ,                        &
+      ALLOCATE( sist   (jpi,jpj) , t_bo   (jpi,jpj) ,                        &
          &      frld   (jpi,jpj) , pfrld  (jpi,jpj) , phicif (jpi,jpj) ,                        &
          &      wfx_snw(jpi,jpj) , wfx_ice(jpi,jpj) , wfx_sub(jpi,jpj) ,                        &
@@ -456,10 +457,11 @@
          &      v_s  (jpi,jpj,jpl) , ht_s (jpi,jpj,jpl) , t_su (jpi,jpj,jpl) ,     &
          &      sm_i (jpi,jpj,jpl) , smv_i(jpi,jpj,jpl) , o_i  (jpi,jpj,jpl) ,     &
-         &      ov_i (jpi,jpj,jpl) , oa_i (jpi,jpj,jpl)                      , STAT=ierr(ii) )
-      ii = ii + 1
-      ALLOCATE( u_ice(jpi,jpj) , v_ice(jpi,jpj) , tio_u(jpi,jpj) , tio_v(jpi,jpj) ,     &
+         &      oa_i (jpi,jpj,jpl) , bv_i (jpi,jpj,jpl) , STAT=ierr(ii) )
+      ii = ii + 1
+      ALLOCATE( u_ice(jpi,jpj) , v_ice(jpi,jpj) ,      &
          &      vt_i (jpi,jpj) , vt_s (jpi,jpj) , at_i (jpi,jpj) , ato_i(jpi,jpj) ,     &
-         &      et_i (jpi,jpj) , et_s (jpi,jpj) , ot_i (jpi,jpj) , tm_i (jpi,jpj) ,     &
-         &      bv_i (jpi,jpj) , smt_i(jpi,jpj)                                   , STAT=ierr(ii) )
+         &      et_i (jpi,jpj) , et_s (jpi,jpj) , tm_i (jpi,jpj) , bvm_i(jpi,jpj) ,     &
+         &      smt_i(jpi,jpj) , tm_su(jpi,jpj) , htm_i(jpi,jpj) , htm_s(jpi,jpj) ,     &
+         &      om_i (jpi,jpj)                              , STAT=ierr(ii) )
       ii = ii + 1
       ALLOCATE( t_s(jpi,jpj,nlay_s,jpl) , e_s(jpi,jpj,nlay_s,jpl) , STAT=ierr(ii) )
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limcons.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limcons.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limcons.F90	(revision 7483)
@@ -288,6 +288,7 @@
 #if ! defined key_bdy
       ! heat flux
-      zhfx  = glob_sum( ( hfx_in - hfx_out - diag_heat - diag_trp_ei - diag_trp_es - SUM( qevap_ice * a_i_b, dim=3 ) )  &
-         &              * e12t * tmask(:,:,1) * zconv ) 
+      zhfx  = glob_sum( ( hfx_in - hfx_out - diag_heat - diag_trp_ei - diag_trp_es  &
+      !  &              - SUM( qevap_ice * a_i_b, dim=3 )                           & !!clem: I think this line must be commented (but need check)
+         &              ) * e12t * tmask(:,:,1) * zconv ) 
       ! salt flux
       zsfx  = glob_sum( ( sfx + diag_smvi ) * e12t * tmask(:,:,1) * zconv ) * rday
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limdiahsb.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limdiahsb.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limdiahsb.F90	(revision 7483)
@@ -31,8 +31,9 @@
 
    PUBLIC   lim_diahsb        ! routine called by ice_step.F90
-
-   real(wp) ::   frc_sal, frc_vol   ! global forcing trends
-   real(wp) ::   bg_grme            ! global ice growth+melt trends
-
+   PUBLIC   lim_diahsb_init   ! routine called in sbcice_lim.F90
+
+   REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   vol_loc_ini, sal_loc_ini, tem_loc_ini ! initial volume, salt and heat contents
+   REAL(wp)                              ::   frc_sal, frc_voltop, frc_volbot, frc_temtop, frc_tembot  ! global forcing trends
+   
    !! * Substitutions
 #  include "vectopt_loop_substitute.h90"
@@ -46,5 +47,5 @@
 CONTAINS
 
-   SUBROUTINE lim_diahsb
+   SUBROUTINE lim_diahsb( kt )
       !!---------------------------------------------------------------------------
       !!                  ***  ROUTINE lim_diahsb  ***
@@ -53,169 +54,86 @@
       !!	
       !!---------------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt    ! number of iteration
       !!
-      real(wp)   ::   zbg_ivo, zbg_svo, zbg_are, zbg_sal ,zbg_tem ,zbg_ihc ,zbg_shc
-      real(wp)   ::   zbg_sfx, zbg_sfx_bri, zbg_sfx_bog, zbg_sfx_bom, zbg_sfx_sum, zbg_sfx_sni,   &
-      &               zbg_sfx_opw, zbg_sfx_res, zbg_sfx_dyn, zbg_sfx_sub 
-      real(wp)   ::   zbg_vfx, zbg_vfx_bog, zbg_vfx_opw, zbg_vfx_sni, zbg_vfx_dyn
-      real(wp)   ::   zbg_vfx_bom, zbg_vfx_sum, zbg_vfx_res, zbg_vfx_spr, zbg_vfx_snw, zbg_vfx_sub  
-      real(wp)   ::   zbg_hfx_dhc, zbg_hfx_spr
-      real(wp)   ::   zbg_hfx_res, zbg_hfx_sub, zbg_hfx_dyn, zbg_hfx_thd, zbg_hfx_snw, zbg_hfx_out, zbg_hfx_in   
-      real(wp)   ::   zbg_hfx_sum, zbg_hfx_bom, zbg_hfx_bog, zbg_hfx_dif, zbg_hfx_opw
-      real(wp)   ::   z_frc_vol, z_frc_sal, z_bg_grme 
-      real(wp)   ::   z1_area                     !    -     -
-      REAL(wp)   ::   ztmp
+      real(wp)   ::   zbg_ivol, zbg_svol, zbg_area, zbg_isal, zbg_item ,zbg_stem
+      REAL(wp)   ::   z_frc_voltop, z_frc_volbot, z_frc_sal, z_frc_temtop, z_frc_tembot  
+      REAL(wp)   ::   zdiff_vol, zdiff_sal, zdiff_tem  
       !!---------------------------------------------------------------------------
       IF( nn_timing == 1 )   CALL timing_start('lim_diahsb')
 
-      IF( numit == nstart ) CALL lim_diahsb_init 
-
-      ! 1/area
-      z1_area = 1._wp / MAX( glob_sum( e12t(:,:) * tmask(:,:,1) ), epsi06 )
-
-      rswitch = MAX( 0._wp , SIGN( 1._wp , glob_sum( e12t(:,:) * tmask(:,:,1) ) - epsi06 ) )
-      ! ----------------------- !
-      ! 1 -  Content variations !
-      ! ----------------------- !
-      zbg_ivo = glob_sum( vt_i(:,:) * e12t(:,:) * tmask(:,:,1) ) ! volume ice 
-      zbg_svo = glob_sum( vt_s(:,:) * e12t(:,:) * tmask(:,:,1) ) ! volume snow
-      zbg_are = glob_sum( at_i(:,:) * e12t(:,:) * tmask(:,:,1) ) ! area
-      zbg_sal = glob_sum( SUM( smv_i(:,:,:), dim=3 ) * e12t(:,:) * tmask(:,:,1) )       ! mean salt content
-      zbg_tem = glob_sum( ( tm_i(:,:) - rt0 ) * vt_i(:,:) * e12t(:,:) * tmask(:,:,1) )  ! mean temp content
-
-      !zbg_ihc = glob_sum( et_i(:,:) * e12t(:,:) * tmask(:,:,1) ) / MAX( zbg_ivo,epsi06 ) ! ice heat content
-      !zbg_shc = glob_sum( et_s(:,:) * e12t(:,:) * tmask(:,:,1) ) / MAX( zbg_svo,epsi06 ) ! snow heat content
-
-      ! Volume
-      ztmp = rswitch * z1_area * r1_rau0 * rday
-      zbg_vfx     = ztmp * glob_sum(     emp(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_bog = ztmp * glob_sum( wfx_bog(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_opw = ztmp * glob_sum( wfx_opw(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_sni = ztmp * glob_sum( wfx_sni(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_dyn = ztmp * glob_sum( wfx_dyn(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_bom = ztmp * glob_sum( wfx_bom(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_sum = ztmp * glob_sum( wfx_sum(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_res = ztmp * glob_sum( wfx_res(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_spr = ztmp * glob_sum( wfx_spr(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_snw = ztmp * glob_sum( wfx_snw(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_sub = ztmp * glob_sum( wfx_sub(:,:) * e12t(:,:) * tmask(:,:,1) )
-
-      ! Salt
-      zbg_sfx     = ztmp * glob_sum(     sfx(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_bri = ztmp * glob_sum( sfx_bri(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_res = ztmp * glob_sum( sfx_res(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_dyn = ztmp * glob_sum( sfx_dyn(:,:) * e12t(:,:) * tmask(:,:,1) )
-
-      zbg_sfx_bog = ztmp * glob_sum( sfx_bog(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_opw = ztmp * glob_sum( sfx_opw(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_sni = ztmp * glob_sum( sfx_sni(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_bom = ztmp * glob_sum( sfx_bom(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_sum = ztmp * glob_sum( sfx_sum(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_sub = ztmp * glob_sum( sfx_sub(:,:) * e12t(:,:) * tmask(:,:,1) )
-
-      ! Heat budget
-      zbg_ihc      = glob_sum( et_i(:,:) * e12t(:,:) * 1.e-20 ) ! ice heat content  [1.e20 J]
-      zbg_shc      = glob_sum( et_s(:,:) * e12t(:,:) * 1.e-20 ) ! snow heat content [1.e20 J]
-      zbg_hfx_dhc  = glob_sum( diag_heat(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_spr  = glob_sum( hfx_spr(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-
-      zbg_hfx_thd  = glob_sum( hfx_thd(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_dyn  = glob_sum( hfx_dyn(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_res  = glob_sum( hfx_res(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_sub  = glob_sum( hfx_sub(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_snw  = glob_sum( hfx_snw(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_sum  = glob_sum( hfx_sum(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_bom  = glob_sum( hfx_bom(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_bog  = glob_sum( hfx_bog(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_dif  = glob_sum( hfx_dif(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_opw  = glob_sum( hfx_opw(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_out  = glob_sum( hfx_out(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_in   = glob_sum(  hfx_in(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-    
-      ! --------------------------------------------- !
-      ! 2 - Trends due to forcing and ice growth/melt !
-      ! --------------------------------------------- !
-      z_frc_vol = r1_rau0 * glob_sum( - emp(:,:) * e12t(:,:) * tmask(:,:,1) ) ! volume fluxes
-      z_frc_sal = r1_rau0 * glob_sum(   sfx(:,:) * e12t(:,:) * tmask(:,:,1) ) ! salt fluxes
-      z_bg_grme = glob_sum( - ( wfx_bog(:,:) + wfx_opw(:,:) + wfx_sni(:,:) + wfx_dyn(:,:) + &
-                          &     wfx_bom(:,:) + wfx_sum(:,:) + wfx_res(:,:) + wfx_snw(:,:) + &
-                          &     wfx_sub(:,:) ) * e12t(:,:) * tmask(:,:,1) ) ! volume fluxes
-      !
-      frc_vol  = frc_vol  + z_frc_vol  * rdt_ice
-      frc_sal  = frc_sal  + z_frc_sal  * rdt_ice
-      bg_grme  = bg_grme  + z_bg_grme  * rdt_ice
+      ! ----------------------- !
+      ! 1 -  Contents !
+      ! ----------------------- !
+      zbg_ivol = glob_sum( vt_i(:,:) * e12t(:,:) * tmask(:,:,1) * 1.e-9 )                  ! ice volume (km3)
+      zbg_svol = glob_sum( vt_s(:,:) * e12t(:,:) * tmask(:,:,1) * 1.e-9 )                  ! snow volume (km3)
+      zbg_area = glob_sum( at_i(:,:) * e12t(:,:) * tmask(:,:,1) * 1.e-6 )                  ! area (km2)
+      zbg_isal = glob_sum( SUM( smv_i(:,:,:), dim=3 ) * e12t(:,:) * tmask(:,:,1) * 1.e-9 ) ! salt content (pss*km3)
+      zbg_item = glob_sum( et_i * e12t(:,:) * tmask(:,:,1) * 1.e-20 )                      ! heat content (1.e20 J)
+      zbg_stem = glob_sum( et_s * e12t(:,:) * tmask(:,:,1) * 1.e-20 )                      ! heat content (1.e20 J)
       
-      ! difference
-      !frc_vol = zbg_ivo - frc_vol
-      !frc_sal = zbg_sal - frc_sal
-      
-      ! ----------------------- !
-      ! 3 - Diagnostics writing !
-      ! ----------------------- !
-      rswitch = MAX( 0._wp , SIGN( 1._wp , zbg_ivo - epsi06 ) )
-      !
-      IF( iom_use('ibgvoltot') )   &
-      CALL iom_put( 'ibgvoltot' , zbg_ivo * rhoic * r1_rau0 * 1.e-9        )   ! ice volume (km3 equivalent liquid)         
-      IF( iom_use('sbgvoltot') )   &
-      CALL iom_put( 'sbgvoltot' , zbg_svo * rhosn * r1_rau0 * 1.e-9        )   ! snw volume (km3 equivalent liquid)       
-      IF( iom_use('ibgarea') )   &
-      CALL iom_put( 'ibgarea'   , zbg_are * 1.e-6                          )   ! ice area   (km2)
-      IF( iom_use('ibgsaline') )   &
-      CALL iom_put( 'ibgsaline' , rswitch * zbg_sal / MAX( zbg_ivo, epsi06 ) )   ! ice saline (psu)
-      IF( iom_use('ibgtemper') )   &
-      CALL iom_put( 'ibgtemper' , rswitch * zbg_tem / MAX( zbg_ivo, epsi06 ) )   ! ice temper (C)
-      CALL iom_put( 'ibgheatco' , zbg_ihc                                  )   ! ice heat content (1.e20 J)        
-      CALL iom_put( 'sbgheatco' , zbg_shc                                  )   ! snw heat content (1.e20 J)
-      IF( iom_use('ibgsaltco') )   &
-      CALL iom_put( 'ibgsaltco' , zbg_sal * rhoic * r1_rau0 * 1.e-9        )   ! ice salt content (psu*km3 equivalent liquid)        
-
-      CALL iom_put( 'ibgvfx'    , zbg_vfx                                  )   ! volume flux emp (m/day liquid)
-      CALL iom_put( 'ibgvfxbog' , zbg_vfx_bog                              )   ! volume flux bottom growth     -(m/day equivalent liquid)
-      CALL iom_put( 'ibgvfxopw' , zbg_vfx_opw                              )   ! volume flux open water growth -
-      CALL iom_put( 'ibgvfxsni' , zbg_vfx_sni                              )   ! volume flux snow ice growth   -
-      CALL iom_put( 'ibgvfxdyn' , zbg_vfx_dyn                              )   ! volume flux dynamic growth    -
-      CALL iom_put( 'ibgvfxbom' , zbg_vfx_bom                              )   ! volume flux bottom melt       -
-      CALL iom_put( 'ibgvfxsum' , zbg_vfx_sum                              )   ! volume flux surface melt      -
-      CALL iom_put( 'ibgvfxres' , zbg_vfx_res                              )   ! volume flux resultant         -
-      CALL iom_put( 'ibgvfxspr' , zbg_vfx_spr                              )   ! volume flux from snow precip         -
-      CALL iom_put( 'ibgvfxsnw' , zbg_vfx_snw                              )   ! volume flux from snow melt         -
-      CALL iom_put( 'ibgvfxsub' , zbg_vfx_sub                              )   ! volume flux from sublimation         -
-          
-      CALL iom_put( 'ibgsfx'    , zbg_sfx                                  )   ! salt flux         -(psu*m/day equivalent liquid)       
-      CALL iom_put( 'ibgsfxbri' , zbg_sfx_bri                              )   ! salt flux brines  -      
-      CALL iom_put( 'ibgsfxdyn' , zbg_sfx_dyn                              )   ! salt flux dynamic -    
-      CALL iom_put( 'ibgsfxres' , zbg_sfx_res                              )   ! salt flux result  -    
-      CALL iom_put( 'ibgsfxbog' , zbg_sfx_bog                              )   ! salt flux bottom growth   
-      CALL iom_put( 'ibgsfxopw' , zbg_sfx_opw                              )   ! salt flux open water growth -
-      CALL iom_put( 'ibgsfxsni' , zbg_sfx_sni                              )   ! salt flux snow ice growth   -
-      CALL iom_put( 'ibgsfxbom' , zbg_sfx_bom                              )   ! salt flux bottom melt       -
-      CALL iom_put( 'ibgsfxsum' , zbg_sfx_sum                              )   ! salt flux surface melt      -
-      CALL iom_put( 'ibgsfxsub' , zbg_sfx_sub                              )   ! salt flux sublimation      -
-
-      CALL iom_put( 'ibghfxdhc' , zbg_hfx_dhc                              )   ! Heat content variation in snow and ice [W]
-      CALL iom_put( 'ibghfxspr' , zbg_hfx_spr                              )   ! Heat content of snow precip [W]
-
-      CALL iom_put( 'ibghfxres' , zbg_hfx_res                              )   ! 
-      CALL iom_put( 'ibghfxsub' , zbg_hfx_sub                              )   ! 
-      CALL iom_put( 'ibghfxdyn' , zbg_hfx_dyn                              )   ! 
-      CALL iom_put( 'ibghfxthd' , zbg_hfx_thd                              )   ! 
-      CALL iom_put( 'ibghfxsnw' , zbg_hfx_snw                              )   ! 
-      CALL iom_put( 'ibghfxsum' , zbg_hfx_sum                              )   ! 
-      CALL iom_put( 'ibghfxbom' , zbg_hfx_bom                              )   ! 
-      CALL iom_put( 'ibghfxbog' , zbg_hfx_bog                              )   ! 
-      CALL iom_put( 'ibghfxdif' , zbg_hfx_dif                              )   ! 
-      CALL iom_put( 'ibghfxopw' , zbg_hfx_opw                              )   ! 
-      CALL iom_put( 'ibghfxout' , zbg_hfx_out                              )   ! 
-      CALL iom_put( 'ibghfxin'  , zbg_hfx_in                               )   ! 
-
-      CALL iom_put( 'ibgfrcvol' , frc_vol * 1.e-9                          )   ! vol - forcing     (km3 equivalent liquid) 
-      CALL iom_put( 'ibgfrcsfx' , frc_sal * 1.e-9                          )   ! sal - forcing     (psu*km3 equivalent liquid)   
-      IF( iom_use('ibgvolgrm') )   &
-      CALL iom_put( 'ibgvolgrm' , bg_grme * r1_rau0 * 1.e-9                )   ! vol growth + melt (km3 equivalent liquid)         
-
+      ! ---------------------------!
+      ! 2 - Trends due to forcing  !
+      ! ---------------------------!
+      z_frc_volbot = r1_rau0 * glob_sum( - ( wfx_ice(:,:) + wfx_snw(:,:) + wfx_err_sub(:,:) ) * e12t(:,:) * tmask(:,:,1) * 1.e-9 )  ! freshwater flux ice/snow-ocean 
+      z_frc_voltop = r1_rau0 * glob_sum( - ( wfx_sub(:,:) + wfx_spr(:,:) ) * e12t(:,:) * tmask(:,:,1) * 1.e-9 )                     ! freshwater flux ice/snow-atm
+      z_frc_sal    = r1_rau0 * glob_sum( - sfx(:,:) * e12t(:,:) * tmask(:,:,1) * 1.e-9 )                                            ! salt fluxes ice/snow-ocean
+      z_frc_tembot =           glob_sum( hfx_out(:,:) * e12t(:,:) * tmask(:,:,1) * 1.e-20 )                                         ! heat on top of ocean (and below ice)
+      z_frc_temtop =           glob_sum( hfx_in (:,:) * e12t(:,:) * tmask(:,:,1) * 1.e-20 )                                         ! heat on top of ice-coean
+      !
+      frc_voltop  = frc_voltop  + z_frc_voltop  * rdt_ice ! km3
+      frc_volbot  = frc_volbot  + z_frc_volbot  * rdt_ice ! km3
+      frc_sal     = frc_sal     + z_frc_sal     * rdt_ice ! km3*pss
+      frc_temtop  = frc_temtop  + z_frc_temtop  * rdt_ice ! 1.e20 J
+      frc_tembot  = frc_tembot  + z_frc_tembot  * rdt_ice ! 1.e20 J
+            
+      ! ----------------------- !
+      ! 3 -  Content variations !
+      ! ----------------------- !
+      zdiff_vol = r1_rau0 * glob_sum( ( rhoic * vt_i(:,:) + rhosn * vt_s(:,:) - vol_loc_ini(:,:)  &  ! freshwater trend (km3) 
+         &                            ) * e12t(:,:) * tmask(:,:,1) * 1.e-9 ) 
+      zdiff_sal = r1_rau0 * glob_sum( ( rhoic * SUM( smv_i(:,:,:), dim=3 ) - sal_loc_ini(:,:)     &  ! salt content trend (km3*pss)
+         &                            ) * e12t(:,:) * tmask(:,:,1) * 1.e-9 )
+      zdiff_tem =           glob_sum( ( et_i(:,:) + et_s(:,:) - tem_loc_ini(:,:)                  &  ! heat content trend (1.e20 J)
+      !  &                            + SUM( qevap_ice * a_i_b, dim=3 ) &     !! clem: I think this line should be commented (but needs a check)
+         &                            ) * e12t(:,:) * tmask(:,:,1) * 1.e-20 )
+
+      ! ----------------------- !
+      ! 4 -  Drifts             !
+      ! ----------------------- !
+      zdiff_vol = zdiff_vol - ( frc_voltop + frc_volbot )
+      zdiff_sal = zdiff_sal - frc_sal
+      zdiff_tem = zdiff_tem - ( frc_tembot - frc_temtop )
+
+      ! ----------------------- !
+      ! 5 - Diagnostics writing !
+      ! ----------------------- !
+      !
+      IF( iom_use('ibgvolume') )  CALL iom_put( 'ibgvolume' , zdiff_vol        )   ! ice/snow volume  drift            (km3 equivalent ocean water)         
+      IF( iom_use('ibgsaltco') )  CALL iom_put( 'ibgsaltco' , zdiff_sal        )   ! ice salt content drift            (psu*km3 equivalent ocean water)
+      IF( iom_use('ibgheatco') )  CALL iom_put( 'ibgheatco' , zdiff_tem        )   ! ice/snow heat content drift       (1.e20 J)
+      IF( iom_use('ibgheatfx') )  CALL iom_put( 'ibgheatfx' , zdiff_tem /      &   ! ice/snow heat flux drift          (W/m2)
+         &                                                    glob_sum( e12t(:,:) * tmask(:,:,1) * 1.e-20 * kt*rdt ) )
+
+      IF( iom_use('ibgfrcvoltop') )  CALL iom_put( 'ibgfrcvoltop' , frc_voltop )   ! vol  forcing ice/snw-atm          (km3 equivalent ocean water) 
+      IF( iom_use('ibgfrcvolbot') )  CALL iom_put( 'ibgfrcvolbot' , frc_volbot )   ! vol  forcing ice/snw-ocean        (km3 equivalent ocean water) 
+      IF( iom_use('ibgfrcsal') )     CALL iom_put( 'ibgfrcsal'    , frc_sal    )   ! sal - forcing                     (psu*km3 equivalent ocean water)   
+      IF( iom_use('ibgfrctemtop') )  CALL iom_put( 'ibgfrctemtop' , frc_temtop )   ! heat on top of ice/snw/ocean      (1.e20 J)   
+      IF( iom_use('ibgfrctembot') )  CALL iom_put( 'ibgfrctembot' , frc_tembot )   ! heat on top of ocean(below ice)   (1.e20 J)   
+      IF( iom_use('ibgfrchfxtop') )  CALL iom_put( 'ibgfrchfxtop' , frc_temtop / & ! heat on top of ice/snw/ocean      (W/m2) 
+         &                                                    glob_sum( e12t(:,:) * tmask(:,:,1) * 1.e-20 * kt*rdt ) )
+      IF( iom_use('ibgfrchfxbot') )  CALL iom_put( 'ibgfrchfxbot' , frc_tembot / & ! heat on top of ocean(below ice)   (W/m2) 
+         &                                                    glob_sum( e12t(:,:) * tmask(:,:,1) * 1.e-20 * kt*rdt ) )
+
+      IF( iom_use('ibgvol_tot' ) )  CALL iom_put( 'ibgvol_tot'  , zbg_ivol     )   ! ice volume                        (km3)
+      IF( iom_use('sbgvol_tot' ) )  CALL iom_put( 'sbgvol_tot'  , zbg_svol     )   ! snow volume                       (km3)
+      IF( iom_use('ibgarea_tot') )  CALL iom_put( 'ibgarea_tot' , zbg_area     )   ! ice area                          (km2)
+      IF( iom_use('ibgsalt_tot') )  CALL iom_put( 'ibgsalt_tot' , zbg_isal     )   ! ice salinity content              (pss*km3)
+      IF( iom_use('ibgheat_tot') )  CALL iom_put( 'ibgheat_tot' , zbg_item     )   ! ice heat content                  (1.e20 J)
+      IF( iom_use('sbgheat_tot') )  CALL iom_put( 'sbgheat_tot' , zbg_stem     )   ! snow heat content                 (1.e20 J)
       !
       IF( lrst_ice )   CALL lim_diahsb_rst( numit, 'WRITE' )
       !
       IF( nn_timing == 1 )   CALL timing_stop('lim_diahsb')
-!
+      !
    END SUBROUTINE lim_diahsb
 
@@ -233,5 +151,4 @@
       !!             - Compute coefficients for conversion
       !!---------------------------------------------------------------------------
-      INTEGER            ::   jk       ! dummy loop indice
       INTEGER            ::   ierror   ! local integer
       !!
@@ -247,5 +164,11 @@
          WRITE(numout,*) '~~~~~~~~~~~~'
       ENDIF
-      !
+      !      
+      ALLOCATE( vol_loc_ini(jpi,jpj), sal_loc_ini(jpi,jpj), tem_loc_ini(jpi,jpj), STAT=ierror )
+      IF( ierror > 0 )  THEN
+         CALL ctl_stop( 'lim_diahsb: unable to allocate vol_loc_ini' )
+         RETURN
+      ENDIF
+
       CALL lim_diahsb_rst( nstart, 'READ' )  !* read or initialize all required files
       !
@@ -263,24 +186,35 @@
      CHARACTER(len=*), INTENT(in) ::   cdrw   ! "READ"/"WRITE" flag
      !
-     INTEGER ::   id1, id2, id3   ! local integers
      !!----------------------------------------------------------------------
      !
      IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise 
         IF( ln_rstart ) THEN                   !* Read the restart file
-           !id1 = iom_varid( numrir, 'frc_vol'  , ldstop = .TRUE. )
            !
            IF(lwp) WRITE(numout,*) '~~~~~~~'
-           IF(lwp) WRITE(numout,*) ' lim_diahsb_rst at it= ', kt,' date= ', ndastp
-           IF(lwp) WRITE(numout,*) '~~~~~~~'
-           CALL iom_get( numrir, 'frc_vol', frc_vol )
-           CALL iom_get( numrir, 'frc_sal', frc_sal )
-           CALL iom_get( numrir, 'bg_grme', bg_grme )
+           IF(lwp) WRITE(numout,*) ' lim_diahsb_rst read at it= ', kt,' date= ', ndastp
+           IF(lwp) WRITE(numout,*) '~~~~~~~'
+           CALL iom_get( numrir, 'frc_voltop' , frc_voltop  )
+           CALL iom_get( numrir, 'frc_volbot' , frc_volbot  )
+           CALL iom_get( numrir, 'frc_temtop' , frc_temtop  )
+           CALL iom_get( numrir, 'frc_tembot' , frc_tembot  )
+           CALL iom_get( numrir, 'frc_sal'    , frc_sal     )
+           CALL iom_get( numrir, jpdom_autoglo, 'vol_loc_ini', vol_loc_ini )
+           CALL iom_get( numrir, jpdom_autoglo, 'tem_loc_ini', tem_loc_ini )
+           CALL iom_get( numrir, jpdom_autoglo, 'sal_loc_ini', sal_loc_ini )
         ELSE
            IF(lwp) WRITE(numout,*) '~~~~~~~'
            IF(lwp) WRITE(numout,*) ' lim_diahsb at initial state '
            IF(lwp) WRITE(numout,*) '~~~~~~~'
-           frc_vol  = 0._wp                                          
-           frc_sal  = 0._wp                                                 
-           bg_grme  = 0._wp                                       
+           ! set trends to 0
+           frc_voltop  = 0._wp                                          
+           frc_volbot  = 0._wp                                          
+           frc_temtop  = 0._wp                                                 
+           frc_tembot  = 0._wp                                                 
+           frc_sal     = 0._wp                                                 
+           ! record initial ice volume, salt and temp
+           vol_loc_ini(:,:) = rhoic * vt_i(:,:) + rhosn * vt_s(:,:)  ! ice/snow volume (kg/m2)
+           tem_loc_ini(:,:) = et_i(:,:) + et_s(:,:)                  ! ice/snow heat content (J)
+           sal_loc_ini(:,:) = rhoic * SUM( smv_i(:,:,:), dim=3 )     ! ice salt content (pss*kg/m2)
+           
        ENDIF
 
@@ -288,9 +222,14 @@
         !                                   ! -------------------
         IF(lwp) WRITE(numout,*) '~~~~~~~'
-        IF(lwp) WRITE(numout,*) ' lim_diahsb_rst at it= ', kt,' date= ', ndastp
+        IF(lwp) WRITE(numout,*) ' lim_diahsb_rst write at it= ', kt,' date= ', ndastp
         IF(lwp) WRITE(numout,*) '~~~~~~~'
-        CALL iom_rstput( kt, nitrst, numriw, 'frc_vol'   , frc_vol     )
-        CALL iom_rstput( kt, nitrst, numriw, 'frc_sal'   , frc_sal     )
-        CALL iom_rstput( kt, nitrst, numriw, 'bg_grme'   , bg_grme     )
+        CALL iom_rstput( kt, nitrst, numriw, 'frc_voltop' , frc_voltop  )
+        CALL iom_rstput( kt, nitrst, numriw, 'frc_volbot' , frc_volbot  )
+        CALL iom_rstput( kt, nitrst, numriw, 'frc_temtop' , frc_temtop  )
+        CALL iom_rstput( kt, nitrst, numriw, 'frc_tembot' , frc_tembot  )
+        CALL iom_rstput( kt, nitrst, numriw, 'frc_sal'    , frc_sal     )
+        CALL iom_rstput( kt, nitrst, numriw, 'vol_loc_ini', vol_loc_ini )
+        CALL iom_rstput( kt, nitrst, numriw, 'tem_loc_ini', tem_loc_ini )
+        CALL iom_rstput( kt, nitrst, numriw, 'sal_loc_ini', sal_loc_ini )
         !
      ENDIF
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 7483)
@@ -247,6 +247,4 @@
                ztest_1 = 1
             ELSE 
-              ! this write is useful
-              IF(lwp)  WRITE(numout,*) ' * TEST1 AREA NOT CONSERVED *** zA_cons = ', zA_cons,' zat_i_ini = ',zat_i_ini(i_hemis) 
                ztest_1 = 0
             ENDIF
@@ -259,7 +257,4 @@
                ztest_2 = 1
             ELSE
-              ! this write is useful
-              IF(lwp)  WRITE(numout,*) ' * TEST2 VOLUME NOT CONSERVED *** zV_cons = ', zV_cons, &
-                            ' zvt_i_ini = ', zvt_i_ini(i_hemis)
                ztest_2 = 0
             ENDIF
@@ -269,7 +264,4 @@
                ztest_3 = 1
             ELSE
-               ! this write is useful
-               IF(lwp) WRITE(numout,*) ' * TEST 3 THICKNESS OF THE LAST CATEGORY OUT OF BOUNDS *** zh_i_ini(i_fill,i_hemis) = ', &
-               zh_i_ini(i_fill,i_hemis), ' hi_max(jpl-1) = ', hi_max(i_fill-1)
                ztest_3 = 0
             ENDIF
@@ -279,6 +271,4 @@
             DO jl = 1, jpl
                IF ( za_i_ini(jl,i_hemis) .LT. 0._wp ) THEN 
-                  ! this write is useful
-                  IF(lwp) WRITE(numout,*) ' * TEST 4 POSITIVITY NOT OK FOR CAT ', jl, ' WITH A = ', za_i_ini(jl,i_hemis)
                   ztest_4 = 0
                ENDIF
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 7483)
@@ -866,5 +866,5 @@
          DO jj = 1, jpj
             DO ji = 1, jpi
-               strength(ji,jj) = strength(ji,jj) * exp(-5.88*SQRT(MAX(bv_i(ji,jj),0.0)))
+               strength(ji,jj) = strength(ji,jj) * exp(-5.88*SQRT(MAX(bvm_i(ji,jj),0.0)))
             END DO
          END DO
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limrhg.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limrhg.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limrhg.F90	(revision 7483)
@@ -10,4 +10,5 @@
    !!            3.4  !  2011-01  (A. Porter)  dynamical allocation 
    !!            3.5  !  2012-08  (R. Benshila)  AGRIF 
+   !!            3.6  !  2016-06  (C. Rousset) Rewriting (conserves energy)
    !!----------------------------------------------------------------------
 #if defined key_lim3 || (  defined key_lim2 && ! defined key_lim2_vp )
@@ -95,9 +96,8 @@
       !!                 coriolis terms of the momentum equation
       !!              3) Solve the momentum equation (iterative procedure)
-      !!              4) Prevent high velocities if the ice is thin
-      !!              5) Recompute invariants of the strain rate tensor
+      !!              4) Recompute invariants of the strain rate tensor
       !!                 which are inputs of the ITD, store stress
       !!                 for the next time step
-      !!              6) Control prints of residual (convergence)
+      !!              5) Control prints of residual (convergence)
       !!                 and charge ellipse.
       !!                 The user should make sure that the parameters
@@ -106,4 +106,7 @@
       !!                 e.g. in the Canadian Archipelago
       !!
+      !! ** Notes   : Boundary condition for ice is chosen no-slip 
+      !!              but can be adjusted with param rn_shlat
+      !!
       !! References : Hunke and Dukowicz, JPO97
       !!              Bouillon et al., Ocean Modelling 2009
@@ -115,49 +118,48 @@
       INTEGER ::   jter     ! local integers
       CHARACTER (len=50) ::   charout
-      REAL(wp) ::   zt11, zt12, zt21, zt22, ztagnx, ztagny, delta                         !
-      REAL(wp) ::   za, zstms          ! local scalars
-      REAL(wp) ::   zc1, zc2, zc3      ! ice mass
-
-      REAL(wp) ::   dtevp , z1_dtevp              ! time step for subcycling
-      REAL(wp) ::   dtotel, z1_dtotel, ecc2, ecci ! square of yield ellipse eccenticity
-      REAL(wp) ::   z0, zr, zcca, zccb            ! temporary scalars
-      REAL(wp) ::   zu_ice2, zv_ice1              !
-      REAL(wp) ::   zddc, zdtc                    ! delta on corners and on centre
-      REAL(wp) ::   zdst                          ! shear at the center of the grid point
-      REAL(wp) ::   zdsshx, zdsshy                ! term for the gradient of ocean surface
-      REAL(wp) ::   sigma1, sigma2                ! internal ice stress
-
-      REAL(wp) ::   zresm         ! Maximal error on ice velocity
-      REAL(wp) ::   zintb, zintn  ! dummy argument
-
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zpresh           ! temporary array for ice strength
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zpreshc          ! Ice strength on grid cell corners (zpreshc)
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zfrld1, zfrld2   ! lead fraction on U/V points
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zmass1, zmass2   ! ice/snow mass on U/V points
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zcorl1, zcorl2   ! coriolis parameter on U/V points
-      REAL(wp), POINTER, DIMENSION(:,:) ::   za1ct , za2ct    ! temporary arrays
-      REAL(wp), POINTER, DIMENSION(:,:) ::   v_oce1           ! ocean u/v component on U points                           
-      REAL(wp), POINTER, DIMENSION(:,:) ::   u_oce2           ! ocean u/v component on V points
-      REAL(wp), POINTER, DIMENSION(:,:) ::   u_ice2, v_ice1   ! ice u/v component on V/U point
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zf1   , zf2      ! arrays for internal stresses
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zmask            ! mask ocean grid points
+
+      REAL(wp) ::   zdtevp, z1_dtevp                                         ! time step for subcycling
+      REAL(wp) ::   ecc2, z1_ecc2                                            ! square of yield ellipse eccenticity
+      REAL(wp) ::   zbeta, zalph1, z1_alph1, zalph2, z1_alph2                ! alpha and beta from Bouillon 2009 and 2013
+      REAL(wp) ::   zm1, zm2, zm3, zmassU, zmassV                            ! ice/snow mass
+      REAL(wp) ::   zdelta, zp_delf, zds2, zdt, zdt2, zdiv, zdiv2            ! temporary scalars
+      REAL(wp) ::   zTauO, zTauE, zCor                                       ! temporary scalars
+
+      REAL(wp) ::   zsig1, zsig2                                             ! internal ice stress
+      REAL(wp) ::   zresm                                                    ! Maximal error on ice velocity
+      REAL(wp) ::   zintb, zintn                                             ! dummy argument
       
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zdt              ! tension at centre of grid cells
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zds              ! Shear on northeast corner of grid cells
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zs1   , zs2      ! Diagonal stress tensor components zs1 and zs2 
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zs12             ! Non-diagonal stress tensor component zs12
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zu_ice, zv_ice, zresr   ! Local error on velocity
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zpice            ! array used for the calculation of ice surface slope:
-                                                              !   ocean surface (ssh_m) if ice is not embedded
-                                                              !   ice top surface if ice is embedded   
-
-      REAL(wp), PARAMETER               ::   zepsi = 1.0e-20_wp ! tolerance parameter
-      REAL(wp), PARAMETER               ::   zvmin = 1.0e-03_wp ! ice volume below which ice velocity equals ocean velocity
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zpresh                          ! temporary array for ice strength
+      REAL(wp), POINTER, DIMENSION(:,:) ::   z1_e1t0, z1_e2t0                ! scale factors
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zp_delt                         ! P/delta at T points
+      !
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zaU   , zaV                     ! ice fraction on U/V points
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zmU_t, zmV_t                    ! ice/snow mass/dt on U/V points
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zmf                             ! coriolis parameter at T points
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zTauU_ia , ztauV_ia             ! ice-atm. stress at U-V points
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zspgU , zspgV                   ! surface pressure gradient at U/V points
+      REAL(wp), POINTER, DIMENSION(:,:) ::   v_oceU, u_oceV, v_iceU, u_iceV  ! ocean/ice u/v component on V/U points                           
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zfU   , zfV                     ! internal stresses
+      
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zds                             ! shear
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zs1, zs2, zs12                  ! stress tensor components
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zu_ice, zv_ice, zresr           ! check convergence
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zpice                           ! array used for the calculation of ice surface slope:
+                                                                             !   ocean surface (ssh_m) if ice is not embedded
+                                                                             !   ice top surface if ice is embedded   
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zswitchU, zswitchV              ! dummy arrays
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zmaskU, zmaskV                  ! mask for ice presence
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zfmask, zwf                     ! mask at F points for the ice
+
+      REAL(wp), PARAMETER               ::   zepsi  = 1.0e-20_wp             ! tolerance parameter
+      REAL(wp), PARAMETER               ::   zmmin  = 1._wp                  ! ice mass (kg/m2) below which ice velocity equals ocean velocity
+      REAL(wp), PARAMETER               ::   zshlat = 2._wp                  ! boundary condition for sea-ice velocity (2=no slip ; 0=free slip)
       !!-------------------------------------------------------------------
 
-      CALL wrk_alloc( jpi,jpj, zpresh, zfrld1, zmass1, zcorl1, za1ct , zpreshc, zfrld2, zmass2, zcorl2, za2ct )
-      CALL wrk_alloc( jpi,jpj, u_oce2, u_ice2, v_oce1 , v_ice1 , zmask               )
-      CALL wrk_alloc( jpi,jpj, zf1   , zu_ice, zf2   , zv_ice , zdt    , zds  )
-      CALL wrk_alloc( jpi,jpj, zs1   , zs2   , zs12   , zresr , zpice                 )
+      CALL wrk_alloc( jpi,jpj, zpresh, z1_e1t0, z1_e2t0, zp_delt )
+      CALL wrk_alloc( jpi,jpj, zaU, zaV, zmU_t, zmV_t, zmf, zTauU_ia, ztauV_ia )
+      CALL wrk_alloc( jpi,jpj, zspgU, zspgV, v_oceU, u_oceV, v_iceU, u_iceV, zfU, zfV )
+      CALL wrk_alloc( jpi,jpj, zds, zs1, zs2, zs12, zu_ice, zv_ice, zresr, zpice )
+      CALL wrk_alloc( jpi,jpj, zswitchU, zswitchV, zmaskU, zmaskV, zfmask, zwf )
 
 #if  defined key_lim2 && ! defined key_lim2_vp
@@ -176,59 +178,88 @@
       !
       !------------------------------------------------------------------------------!
-      ! 1) Ice strength (zpresh)                                !
-      !------------------------------------------------------------------------------!
-      !
-      ! Put every vector to 0
-      delta_i(:,:) = 0._wp   ;
-      zpresh (:,:) = 0._wp   ;  
-      zpreshc(:,:) = 0._wp
-      u_ice2 (:,:) = 0._wp   ;   v_ice1(:,:) = 0._wp
-      divu_i (:,:) = 0._wp   ;   zdt   (:,:) = 0._wp   ;   zds(:,:) = 0._wp
-      shear_i(:,:) = 0._wp
-
+      ! 0) mask at F points for the ice (on the whole domain, not only k_j1,k_jpj) 
+      !------------------------------------------------------------------------------!
+      ! ocean/land mask
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1      ! NO vector opt.
+            zfmask(ji,jj) = tmask(ji,jj,1) * tmask(ji+1,jj,1) * tmask(ji,jj+1,1) * tmask(ji+1,jj+1,1)
+         END DO
+      END DO
+      CALL lbc_lnk( zfmask, 'F', 1._wp )
+
+      ! Lateral boundary conditions on velocity (modify zfmask)
+      zwf(:,:) = zfmask(:,:)
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            IF( zfmask(ji,jj) == 0._wp ) THEN
+               zfmask(ji,jj) = zshlat * MIN( 1._wp , MAX( zwf(ji+1,jj), zwf(ji,jj+1), zwf(ji-1,jj), zwf(ji,jj-1) ) )
+            ENDIF
+         END DO
+      END DO
+      DO jj = 2, jpjm1
+         IF( zfmask(1,jj) == 0._wp ) THEN
+            zfmask(1  ,jj) = zshlat * MIN( 1._wp , MAX( zwf(2,jj), zwf(1,jj+1), zwf(1,jj-1) ) )
+         ENDIF
+         IF( zfmask(jpi,jj) == 0._wp ) THEN
+            zfmask(jpi,jj) = zshlat * MIN( 1._wp , MAX( zwf(jpi,jj+1), zwf(jpim1,jj), zwf(jpi,jj-1) ) )
+         ENDIF
+      END DO
+      DO ji = 2, jpim1
+         IF( zfmask(ji,1) == 0._wp ) THEN
+            zfmask(ji,1  ) = zshlat * MIN( 1._wp , MAX( zwf(ji+1,1), zwf(ji,2), zwf(ji-1,1) ) )
+         ENDIF
+         IF( zfmask(ji,jpj) == 0._wp ) THEN
+            zfmask(ji,jpj) = zshlat * MIN( 1._wp , MAX( zwf(ji+1,jpj), zwf(ji-1,jpj), zwf(ji,jpjm1) ) )
+         ENDIF
+      END DO
+      CALL lbc_lnk( zfmask, 'F', 1._wp )
+
+      !------------------------------------------------------------------------------!
+      ! 1) define some variables and initialize arrays
+      !------------------------------------------------------------------------------!
+      ! ecc2: square of yield ellipse eccenticrity
+      ecc2    = rn_ecc * rn_ecc
+      z1_ecc2 = 1._wp / ecc2
+
+      ! Time step for subcycling
+      zdtevp   = rdt_ice / REAL( nn_nevp )
+      z1_dtevp = 1._wp / zdtevp
+
+      ! alpha parameters (Bouillon 2009)
 #if defined key_lim3
-      CALL lim_itd_me_icestrength( nn_icestr )      ! LIM-3: Ice strength on T-points
-#endif
-
-      DO jj = k_j1 , k_jpj       ! Ice mass and temp variables
-         DO ji = 1 , jpi
+      zalph1 = ( 2._wp * rn_relast * rdt_ice ) * z1_dtevp
+#else
+      zalph1 = ( 2._wp * telast ) * z1_dtevp
+#endif
+      zalph2 = zalph1 * z1_ecc2
+
+      z1_alph1 = 1._wp / ( zalph1 + 1._wp )
+      z1_alph2 = 1._wp / ( zalph2 + 1._wp )
+
+      ! Initialise stress tensor 
+      zs1 (:,:) = stress1_i (:,:) 
+      zs2 (:,:) = stress2_i (:,:)
+      zs12(:,:) = stress12_i(:,:)
+
+      ! Ice strength
 #if defined key_lim3
-            zpresh(ji,jj) = tmask(ji,jj,1) *  strength(ji,jj)
-#endif
-#if defined key_lim2
-            zpresh(ji,jj) = tmask(ji,jj,1) *  pstar * vt_i(ji,jj) * EXP( -c_rhg * (1. - at_i(ji,jj) ) )
-#endif
-            ! zmask = 1 where there is ice or on land
-            zmask(ji,jj)    = 1._wp - ( 1._wp - MAX( 0._wp , SIGN ( 1._wp , vt_i(ji,jj) - zepsi ) ) ) * tmask(ji,jj,1)
+      CALL lim_itd_me_icestrength( nn_icestr )
+      zpresh(:,:) = tmask(:,:,1) *  strength(:,:)
+#else
+      zpresh(:,:) = tmask(:,:,1) *  pstar * vt_i(:,:) * EXP( -c_rhg * (1. - at_i(:,:) ) )
+#endif
+
+      ! scale factors
+      DO jj = k_j1+1, k_jpj-1
+         DO ji = fs_2, fs_jpim1
+            z1_e1t0(ji,jj) = 1._wp / ( e1t(ji+1,jj  ) + e1t(ji,jj  ) )
+            z1_e2t0(ji,jj) = 1._wp / ( e2t(ji  ,jj+1) + e2t(ji,jj  ) )
          END DO
       END DO
-
-      ! Ice strength on grid cell corners (zpreshc)
-      ! needed for calculation of shear stress 
-      DO jj = k_j1+1, k_jpj-1
-         DO ji = 2, jpim1 !RB caution no fs_ (ji+1,jj+1)
-            zstms          =  tmask(ji+1,jj+1,1) * wght(ji+1,jj+1,2,2) + tmask(ji,jj+1,1) * wght(ji+1,jj+1,1,2) +   &
-               &              tmask(ji+1,jj,1)   * wght(ji+1,jj+1,2,1) + tmask(ji,jj,1)   * wght(ji+1,jj+1,1,1)
-            zpreshc(ji,jj) = ( zpresh(ji+1,jj+1) * wght(ji+1,jj+1,2,2) + zpresh(ji,jj+1) * wght(ji+1,jj+1,1,2) +   &
-               &               zpresh(ji+1,jj)   * wght(ji+1,jj+1,2,1) + zpresh(ji,jj)   * wght(ji+1,jj+1,1,1)     &
-               &             ) / MAX( zstms, zepsi )
-         END DO
-      END DO
-      CALL lbc_lnk( zpreshc(:,:), 'F', 1. )
+            
       !
       !------------------------------------------------------------------------------!
       ! 2) Wind / ocean stress, mass terms, coriolis terms
       !------------------------------------------------------------------------------!
-      !
-      !  Wind stress, coriolis and mass terms on the sides of the squares        
-      !  zfrld1: lead fraction on U-points                                      
-      !  zfrld2: lead fraction on V-points                                     
-      !  zmass1: ice/snow mass on U-points                                    
-      !  zmass2: ice/snow mass on V-points                                   
-      !  zcorl1: Coriolis parameter on U-points                             
-      !  zcorl2: Coriolis parameter on V-points                            
-      !  (ztagnx,ztagny): wind stress on U/V points                       
-      !  v_oce1: ocean v component on u points                          
-      !  u_oce2: ocean u component on v points                         
 
       IF( nn_ice_embd == 2 ) THEN             !== embedded sea ice: compute representative ice top surface ==!
@@ -242,5 +273,5 @@
          zintb = REAL( nn_fsbc + 1 ) / REAL( nn_fsbc ) * 0.5_wp
          !
-         zpice(:,:) = ssh_m(:,:) + (  zintn * snwice_mass(:,:) +  zintb * snwice_mass_b(:,:)  ) * r1_rau0
+         zpice(:,:) = ssh_m(:,:) + ( zintn * snwice_mass(:,:) + zintb * snwice_mass_b(:,:) ) * r1_rau0
          !
       ELSE                                    !== non-embedded sea ice: use ocean surface for slope calculation ==!
@@ -251,53 +282,48 @@
          DO ji = fs_2, fs_jpim1
 
-            zc1 = tmask(ji  ,jj  ,1) * ( rhosn * vt_s(ji  ,jj  ) + rhoic * vt_i(ji  ,jj  ) )
-            zc2 = tmask(ji+1,jj  ,1) * ( rhosn * vt_s(ji+1,jj  ) + rhoic * vt_i(ji+1,jj  ) )
-            zc3 = tmask(ji  ,jj+1,1) * ( rhosn * vt_s(ji  ,jj+1) + rhoic * vt_i(ji  ,jj+1) )
-
-            zt11 = tmask(ji  ,jj,1) * e1t(ji  ,jj)
-            zt12 = tmask(ji+1,jj,1) * e1t(ji+1,jj)
-            zt21 = tmask(ji,jj  ,1) * e2t(ji,jj  )
-            zt22 = tmask(ji,jj+1,1) * e2t(ji,jj+1)
-
-            ! Leads area.
-            zfrld1(ji,jj) = ( zt12 * ( 1.0 - at_i(ji,jj) ) + zt11 * ( 1.0 - at_i(ji+1,jj) ) ) / ( zt11 + zt12 + zepsi )
-            zfrld2(ji,jj) = ( zt22 * ( 1.0 - at_i(ji,jj) ) + zt21 * ( 1.0 - at_i(ji,jj+1) ) ) / ( zt21 + zt22 + zepsi )
-
-            ! Mass, coriolis coeff. and currents
-            zmass1(ji,jj) = ( zt12 * zc1 + zt11 * zc2 ) / ( zt11 + zt12 + zepsi )
-            zmass2(ji,jj) = ( zt22 * zc1 + zt21 * zc3 ) / ( zt21 + zt22 + zepsi )
-            zcorl1(ji,jj) = zmass1(ji,jj) * ( e1t(ji+1,jj) * fcor(ji,jj) + e1t(ji,jj) * fcor(ji+1,jj) )   &
-               &                          / ( e1t(ji,jj) + e1t(ji+1,jj) + zepsi )
-            zcorl2(ji,jj) = zmass2(ji,jj) * ( e2t(ji,jj+1) * fcor(ji,jj) + e2t(ji,jj) * fcor(ji,jj+1) )   &
-               &                          / ( e2t(ji,jj+1) + e2t(ji,jj) + zepsi )
-            !
-            ! Ocean has no slip boundary condition
-            v_oce1(ji,jj)  = 0.5 * ( ( v_oce(ji  ,jj) + v_oce(ji  ,jj-1) ) * e1t(ji,jj)      &
-               &                   + ( v_oce(ji+1,jj) + v_oce(ji+1,jj-1) ) * e1t(ji+1,jj) )  &
-               &                   / ( e1t(ji+1,jj) + e1t(ji,jj) ) * umask(ji,jj,1)  
-
-            u_oce2(ji,jj)  = 0.5 * ( ( u_oce(ji,jj  ) + u_oce(ji-1,jj  ) ) * e2t(ji,jj)      &
-               &                   + ( u_oce(ji,jj+1) + u_oce(ji-1,jj+1) ) * e2t(ji,jj+1) )  &
-               &                   / ( e2t(ji,jj+1) + e2t(ji,jj) ) * vmask(ji,jj,1)
-
-            ! Wind stress at U,V-point
-            ztagnx = ( 1. - zfrld1(ji,jj) ) * utau_ice(ji,jj)
-            ztagny = ( 1. - zfrld2(ji,jj) ) * vtau_ice(ji,jj)
-
-            ! Computation of the velocity field taking into account the ice internal interaction.
-            ! Terms that are independent of the velocity field.
-
-            ! SB On utilise maintenant le gradient de la pente de l'ocean
-            ! include it later
-
-            zdsshx =  ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
-            zdsshy =  ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
-
-            za1ct(ji,jj) = ztagnx - zmass1(ji,jj) * grav * zdsshx
-            za2ct(ji,jj) = ztagny - zmass2(ji,jj) * grav * zdsshy
+            ! ice fraction at U-V points
+            zaU(ji,jj) = 0.5_wp * ( at_i(ji,jj) * e12t(ji,jj) + at_i(ji+1,jj) * e12t(ji+1,jj) ) * r1_e12u(ji,jj) * umask(ji,jj,1)
+            zaV(ji,jj) = 0.5_wp * ( at_i(ji,jj) * e12t(ji,jj) + at_i(ji,jj+1) * e12t(ji,jj+1) ) * r1_e12v(ji,jj) * vmask(ji,jj,1)
+
+            ! Ice/snow mass at U-V points
+            zm1 = ( rhosn * vt_s(ji  ,jj  ) + rhoic * vt_i(ji  ,jj  ) )
+            zm2 = ( rhosn * vt_s(ji+1,jj  ) + rhoic * vt_i(ji+1,jj  ) )
+            zm3 = ( rhosn * vt_s(ji  ,jj+1) + rhoic * vt_i(ji  ,jj+1) )
+            zmassU = 0.5_wp * ( zm1 * e12t(ji,jj) + zm2 * e12t(ji+1,jj) ) * r1_e12u(ji,jj) * umask(ji,jj,1)
+            zmassV = 0.5_wp * ( zm1 * e12t(ji,jj) + zm3 * e12t(ji,jj+1) ) * r1_e12v(ji,jj) * vmask(ji,jj,1)
+
+            ! Ocean currents at U-V points
+            v_oceU(ji,jj)   = 0.5_wp * ( ( v_oce(ji  ,jj) + v_oce(ji  ,jj-1) ) * e1t(ji+1,jj)    &
+               &                       + ( v_oce(ji+1,jj) + v_oce(ji+1,jj-1) ) * e1t(ji  ,jj) ) * z1_e1t0(ji,jj) * umask(ji,jj,1)
+            
+            u_oceV(ji,jj)   = 0.5_wp * ( ( u_oce(ji,jj  ) + u_oce(ji-1,jj  ) ) * e2t(ji,jj+1)    &
+               &                       + ( u_oce(ji,jj+1) + u_oce(ji-1,jj+1) ) * e2t(ji,jj  ) ) * z1_e2t0(ji,jj) * vmask(ji,jj,1)
+
+            ! Coriolis at T points (m*f)
+            zmf(ji,jj)      = zm1 * fcor(ji,jj)
+
+            ! m/dt
+            zmU_t(ji,jj)    = zmassU * z1_dtevp
+            zmV_t(ji,jj)    = zmassV * z1_dtevp
+
+            ! Drag ice-atm.
+            zTauU_ia(ji,jj) = zaU(ji,jj) * utau_ice(ji,jj)
+            zTauV_ia(ji,jj) = zaV(ji,jj) * vtau_ice(ji,jj)
+
+            ! Surface pressure gradient (- m*g*GRAD(ssh)) at U-V points
+            zspgU(ji,jj)    = - zmassU * grav * ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
+            zspgV(ji,jj)    = - zmassV * grav * ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
+
+            ! masks
+            zmaskU(ji,jj) = 1._wp - MAX( 0._wp, SIGN( 1._wp, -zmassU ) )  ! 0 if no ice
+            zmaskV(ji,jj) = 1._wp - MAX( 0._wp, SIGN( 1._wp, -zmassV ) )  ! 0 if no ice
+
+            ! switches
+            zswitchU(ji,jj) = MAX( 0._wp, SIGN( 1._wp, zmassU - zmmin ) ) ! 0 if ice mass < zmmin
+            zswitchV(ji,jj) = MAX( 0._wp, SIGN( 1._wp, zmassV - zmmin ) ) ! 0 if ice mass < zmmin
 
          END DO
       END DO
-
+      CALL lbc_lnk( zmf, 'T', 1. )
       !
       !------------------------------------------------------------------------------!
@@ -305,246 +331,240 @@
       !------------------------------------------------------------------------------!
       !
-      ! Time step for subcycling
-      dtevp  = rdt_ice / nn_nevp
-#if defined key_lim3
-      dtotel = dtevp / ( 2._wp * rn_relast * rdt_ice )
-#else
-      dtotel = dtevp / ( 2._wp * telast )
-#endif
-      z1_dtotel = 1._wp / ( 1._wp + dtotel )
-      z1_dtevp  = 1._wp / dtevp
-      !-ecc2: square of yield ellipse eccenticrity (reminder: must become a namelist parameter)
-      ecc2 = rn_ecc * rn_ecc
-      ecci = 1. / ecc2
-
-      !-Initialise stress tensor 
-      zs1 (:,:) = stress1_i (:,:) 
-      zs2 (:,:) = stress2_i (:,:)
-      zs12(:,:) = stress12_i(:,:)
-
       !                                               !----------------------!
       DO jter = 1 , nn_nevp                           !    loop over jter    !
          !                                            !----------------------!        
-         DO jj = k_j1, k_jpj-1
-            zu_ice(:,jj) = u_ice(:,jj)    ! velocity at previous time step
-            zv_ice(:,jj) = v_ice(:,jj)
-         END DO
-
-         DO jj = k_j1+1, k_jpj-1
-            DO ji = fs_2, fs_jpim1   !RB bug no vect opt due to zmask
-
-               !  
-               !- Divergence, tension and shear (Section a. Appendix B of Hunke & Dukowicz, 2002)
-               !- divu_i(:,:), zdt(:,:): divergence and tension at centre of grid cells
-               !- zds(:,:): shear on northeast corner of grid cells
-               !
-               !- IMPORTANT REMINDER: Dear Gurvan, note that, the way these terms are coded, 
-               !                      there are many repeated calculations. 
-               !                      Speed could be improved by regrouping terms. For
-               !                      the moment, however, the stress is on clarity of coding to avoid
-               !                      bugs (Martin, for Miguel).
-               !
-               !- ALSO: arrays zdt, zds and delta could 
-               !  be removed in the future to minimise memory demand.
-               !
-               !- MORE NOTES: Note that we are calculating deformation rates and stresses on the corners of
-               !              grid cells, exactly as in the B grid case. For simplicity, the indexation on
-               !              the corners is the same as in the B grid.
-               !
-               !
-               divu_i(ji,jj) = (  e2u(ji,jj) * u_ice(ji,jj) - e2u(ji-1,jj) * u_ice(ji-1,jj)   &
-                  &             + e1v(ji,jj) * v_ice(ji,jj) - e1v(ji,jj-1) * v_ice(ji,jj-1)   &
-                  &            ) * r1_e12t(ji,jj)
-
-               zdt(ji,jj) = ( ( u_ice(ji,jj) * r1_e2u(ji,jj) - u_ice(ji-1,jj) * r1_e2u(ji-1,jj) ) * e2t(ji,jj) * e2t(ji,jj)   &
-                  &         - ( v_ice(ji,jj) * r1_e1v(ji,jj) - v_ice(ji,jj-1) * r1_e1v(ji,jj-1) ) * e1t(ji,jj) * e1t(ji,jj)   &
-                  &         ) * r1_e12t(ji,jj)
-
-               !
+         IF(ln_ctl) THEN   ! Convergence test
+            DO jj = k_j1, k_jpj-1
+               zu_ice(:,jj) = u_ice(:,jj) ! velocity at previous time step
+               zv_ice(:,jj) = v_ice(:,jj)
+            END DO
+         ENDIF
+
+         ! --- divergence, tension & shear (Appendix B of Hunke & Dukowicz, 2002) --- !
+         DO jj = k_j1, k_jpj-1         ! loops start at 1 since there is no boundary condition (lbc_lnk) at i=1 and j=1 for F points
+            DO ji = 1, jpim1
+
+               ! shear at F points
                zds(ji,jj) = ( ( u_ice(ji,jj+1) * r1_e1u(ji,jj+1) - u_ice(ji,jj) * r1_e1u(ji,jj) ) * e1f(ji,jj) * e1f(ji,jj)   &
                   &         + ( v_ice(ji+1,jj) * r1_e2v(ji+1,jj) - v_ice(ji,jj) * r1_e2v(ji,jj) ) * e2f(ji,jj) * e2f(ji,jj)   &
-                  &         ) * r1_e12f(ji,jj) * ( 2._wp - fmask(ji,jj,1) )   &
-                  &         * zmask(ji,jj) * zmask(ji,jj+1) * zmask(ji+1,jj) * zmask(ji+1,jj+1)
-
-
-               v_ice1(ji,jj)  = 0.5_wp * ( ( v_ice(ji  ,jj) + v_ice(ji  ,jj-1) ) * e1t(ji+1,jj)     &
-                  &                      + ( v_ice(ji+1,jj) + v_ice(ji+1,jj-1) ) * e1t(ji  ,jj) )   &
-                  &                      / ( e1t(ji+1,jj) + e1t(ji,jj) ) * umask(ji,jj,1) 
-
-               u_ice2(ji,jj)  = 0.5_wp * ( ( u_ice(ji,jj  ) + u_ice(ji-1,jj  ) ) * e2t(ji,jj+1)     &
-                  &                      + ( u_ice(ji,jj+1) + u_ice(ji-1,jj+1) ) * e2t(ji,jj  ) )   &
-                  &                      / ( e2t(ji,jj+1) + e2t(ji,jj) ) * vmask(ji,jj,1)
-            END DO
-         END DO
-
-         CALL lbc_lnk_multi( v_ice1, 'U', -1., u_ice2, 'V', -1. )      ! lateral boundary cond.
-         
+                  &         ) * r1_e12f(ji,jj) * zfmask(ji,jj)
+
+            END DO
+         END DO
+         CALL lbc_lnk( zds, 'F', 1. )
+
          DO jj = k_j1+1, k_jpj-1
-            DO ji = fs_2, fs_jpim1
-
-               !- Calculate Delta at centre of grid cells
-               zdst          = ( e2u(ji,jj) * v_ice1(ji,jj) - e2u(ji-1,jj  ) * v_ice1(ji-1,jj  )   &
-                  &            + e1v(ji,jj) * u_ice2(ji,jj) - e1v(ji  ,jj-1) * u_ice2(ji  ,jj-1)   &
-                  &            ) * r1_e12t(ji,jj)
-
-               delta          = SQRT( divu_i(ji,jj)**2 + ( zdt(ji,jj)**2 + zdst**2 ) * usecc2 )  
-               delta_i(ji,jj) = delta + rn_creepl
-
-               !- Calculate Delta on corners
-               zddc  = (  ( v_ice1(ji,jj+1) * r1_e1u(ji,jj+1) - v_ice1(ji,jj) * r1_e1u(ji,jj) ) * e1f(ji,jj) * e1f(ji,jj)  &
-                  &     + ( u_ice2(ji+1,jj) * r1_e2v(ji+1,jj) - u_ice2(ji,jj) * r1_e2v(ji,jj) ) * e2f(ji,jj) * e2f(ji,jj)  &
-                  &    ) * r1_e12f(ji,jj)
-
-               zdtc  = (- ( v_ice1(ji,jj+1) * r1_e1u(ji,jj+1) - v_ice1(ji,jj) * r1_e1u(ji,jj) ) * e1f(ji,jj) * e1f(ji,jj)  &
-                  &     + ( u_ice2(ji+1,jj) * r1_e2v(ji+1,jj) - u_ice2(ji,jj) * r1_e2v(ji,jj) ) * e2f(ji,jj) * e2f(ji,jj)  &
-                  &    ) * r1_e12f(ji,jj)
-
-               zddc = SQRT( zddc**2 + ( zdtc**2 + zds(ji,jj)**2 ) * usecc2 ) + rn_creepl
-
-               !-Calculate stress tensor components zs1 and zs2 at centre of grid cells (see section 3.5 of CICE user's guide).
-               zs1(ji,jj)  = ( zs1 (ji,jj) + dtotel * ( divu_i(ji,jj) - delta ) / delta_i(ji,jj)   * zpresh(ji,jj)   &
-                  &          ) * z1_dtotel
-               zs2(ji,jj)  = ( zs2 (ji,jj) + dtotel *         ecci * zdt(ji,jj) / delta_i(ji,jj)   * zpresh(ji,jj)   &
-                  &          ) * z1_dtotel
-               !-Calculate stress tensor component zs12 at corners
-               zs12(ji,jj) = ( zs12(ji,jj) + dtotel *         ecci * zds(ji,jj) / ( 2._wp * zddc ) * zpreshc(ji,jj)  &
-                  &          ) * z1_dtotel 
-
-            END DO
-         END DO
-
-         CALL lbc_lnk_multi( zs1 , 'T', 1., zs2, 'T', 1., zs12, 'F', 1. )
+            DO ji = 2, jpim1 ! no vector loop
+
+               ! shear**2 at T points (doc eq. A16)
+               zds2 = ( zds(ji,jj  ) * zds(ji,jj  ) * e12f(ji,jj  ) + zds(ji-1,jj  ) * zds(ji-1,jj  ) * e12f(ji-1,jj  )  &
+                  &   + zds(ji,jj-1) * zds(ji,jj-1) * e12f(ji,jj-1) + zds(ji-1,jj-1) * zds(ji-1,jj-1) * e12f(ji-1,jj-1)  &
+                  &   ) * 0.25_wp * r1_e12t(ji,jj)
+              
+               ! divergence at T points
+               zdiv  = ( e2u(ji,jj) * u_ice(ji,jj) - e2u(ji-1,jj) * u_ice(ji-1,jj)   &
+                  &    + e1v(ji,jj) * v_ice(ji,jj) - e1v(ji,jj-1) * v_ice(ji,jj-1)   &
+                  &    ) * r1_e12t(ji,jj)
+               zdiv2 = zdiv * zdiv
+               
+               ! tension at T points
+               zdt  = ( ( u_ice(ji,jj) * r1_e2u(ji,jj) - u_ice(ji-1,jj) * r1_e2u(ji-1,jj) ) * e2t(ji,jj) * e2t(ji,jj)   &
+                  &   - ( v_ice(ji,jj) * r1_e1v(ji,jj) - v_ice(ji,jj-1) * r1_e1v(ji,jj-1) ) * e1t(ji,jj) * e1t(ji,jj)   &
+                  &   ) * r1_e12t(ji,jj)
+               zdt2 = zdt * zdt
+               
+               ! delta at T points
+               zdelta = SQRT( zdiv2 + ( zdt2 + zds2 ) * usecc2 )  
+
+               ! P/delta at T points
+               zp_delt(ji,jj) = zpresh(ji,jj) / ( zdelta + rn_creepl )
+               
+               ! stress at T points
+               zs1(ji,jj) = ( zs1(ji,jj) * zalph1 + zp_delt(ji,jj) * ( zdiv - zdelta ) ) * z1_alph1
+               zs2(ji,jj) = ( zs2(ji,jj) * zalph2 + zp_delt(ji,jj) * ( zdt * z1_ecc2 ) ) * z1_alph2
+             
+            END DO
+         END DO
+         CALL lbc_lnk( zp_delt, 'T', 1. )
+
+         DO jj = k_j1, k_jpj-1
+            DO ji = 1, jpim1
+
+               ! P/delta at F points
+               zp_delf = 0.25_wp * ( zp_delt(ji,jj) + zp_delt(ji+1,jj) + zp_delt(ji,jj+1) + zp_delt(ji+1,jj+1) )
+               
+               ! stress at F points
+               zs12(ji,jj)= ( zs12(ji,jj) * zalph2 + zp_delf * ( zds(ji,jj) * z1_ecc2 ) * 0.5_wp ) * z1_alph2
+
+            END DO
+         END DO
+         CALL lbc_lnk_multi( zs1, 'T', 1., zs2, 'T', 1., zs12, 'F', 1. )
  
-         ! Ice internal stresses (Appendix C of Hunke and Dukowicz, 2002)
+         ! --- Ice internal stresses (Appendix C of Hunke and Dukowicz, 2002) --- !
          DO jj = k_j1+1, k_jpj-1
-            DO ji = fs_2, fs_jpim1
-               !- contribution of zs1, zs2 and zs12 to zf1
-               zf1(ji,jj) = 0.5 * ( ( zs1(ji+1,jj) - zs1(ji,jj) ) * e2u(ji,jj)  &
-                  &             + ( zs2(ji+1,jj) * e2t(ji+1,jj)**2 - zs2(ji,jj) * e2t(ji,jj)**2 ) * r1_e2u(ji,jj)          &
-                  &             + 2.0 * ( zs12(ji,jj) * e1f(ji,jj)**2 - zs12(ji,jj-1) * e1f(ji,jj-1)**2 ) * r1_e1u(ji,jj)  &
-                  &                ) * r1_e12u(ji,jj)
-               ! contribution of zs1, zs2 and zs12 to zf2
-               zf2(ji,jj) = 0.5 * ( ( zs1(ji,jj+1) - zs1(ji,jj) ) * e1v(ji,jj)  &
-                  &             - ( zs2(ji,jj+1) * e1t(ji,jj+1)**2 - zs2(ji,jj) * e1t(ji,jj)**2 ) * r1_e1v(ji,jj)          &
-                  &             + 2.0 * ( zs12(ji,jj) * e2f(ji,jj)**2 - zs12(ji-1,jj) * e2f(ji-1,jj)**2 ) * r1_e2v(ji,jj)  &
-                  &               )  * r1_e12v(ji,jj)
+            DO ji = fs_2, fs_jpim1               
+
+               ! U points
+               zfU(ji,jj) = 0.5_wp * ( ( zs1(ji+1,jj) - zs1(ji,jj) ) * e2u(ji,jj)                                             &
+                  &                  + ( zs2(ji+1,jj) * e2t(ji+1,jj) * e2t(ji+1,jj) - zs2(ji,jj) * e2t(ji,jj) * e2t(ji,jj)    &
+                  &                    ) * r1_e2u(ji,jj)                                                                      &
+                  &                  + ( zs12(ji,jj) * e1f(ji,jj) * e1f(ji,jj) - zs12(ji,jj-1) * e1f(ji,jj-1) * e1f(ji,jj-1)  &
+                  &                    ) * 2._wp * r1_e1u(ji,jj)                                                              &
+                  &                  ) * r1_e12u(ji,jj)
+
+               ! V points
+               zfV(ji,jj) = 0.5_wp * ( ( zs1(ji,jj+1) - zs1(ji,jj) ) * e1v(ji,jj)                                             &
+                  &                  - ( zs2(ji,jj+1) * e1t(ji,jj+1) * e1t(ji,jj+1) - zs2(ji,jj) * e1t(ji,jj) * e1t(ji,jj)    &
+                  &                    ) * r1_e1v(ji,jj)                                                                      &
+                  &                  + ( zs12(ji,jj) * e2f(ji,jj) * e2f(ji,jj) - zs12(ji-1,jj) * e2f(ji-1,jj) * e2f(ji-1,jj)  &
+                  &                    ) * 2._wp * r1_e2v(ji,jj)                                                              &
+                  &                  ) * r1_e12v(ji,jj)
+
+               ! u_ice at V point
+               u_iceV(ji,jj) = 0.5_wp * ( ( u_ice(ji,jj  ) + u_ice(ji-1,jj  ) ) * e2t(ji,jj+1)     &
+                  &                     + ( u_ice(ji,jj+1) + u_ice(ji-1,jj+1) ) * e2t(ji,jj  ) ) * z1_e2t0(ji,jj) * vmask(ji,jj,1)
+               
+               ! v_ice at U point
+               v_iceU(ji,jj) = 0.5_wp * ( ( v_ice(ji  ,jj) + v_ice(ji  ,jj-1) ) * e1t(ji+1,jj)     &
+                  &                     + ( v_ice(ji+1,jj) + v_ice(ji+1,jj-1) ) * e1t(ji  ,jj) ) * z1_e1t0(ji,jj) * umask(ji,jj,1)
+
             END DO
          END DO
          !
-         ! Computation of ice velocity
-         !
-         ! Both the Coriolis term and the ice-ocean drag are solved semi-implicitly.
-         !
-         IF (MOD(jter,2).eq.0) THEN 
-
+         ! --- Computation of ice velocity --- !
+         !  Bouillon et al. 2013 (eq 47-48) => unstable unless alpha, beta are chosen wisely and large nn_nevp
+         !  Bouillon et al. 2009 (eq 34-35) => stable
+         IF( MOD(jter,2) .EQ. 0 ) THEN ! even iterations
+            
             DO jj = k_j1+1, k_jpj-1
                DO ji = fs_2, fs_jpim1
-                  rswitch      = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zmass1(ji,jj) ) ) ) * umask(ji,jj,1)
-                  z0           = zmass1(ji,jj) * z1_dtevp
-
-                  ! SB modif because ocean has no slip boundary condition
-                  zv_ice1      = 0.5 * ( ( v_ice(ji  ,jj) + v_ice(ji  ,jj-1) ) * e1t(ji  ,jj)     &
-                     &                 + ( v_ice(ji+1,jj) + v_ice(ji+1,jj-1) ) * e1t(ji+1,jj) )   &
-                     &                 / ( e1t(ji+1,jj) + e1t(ji,jj) ) * umask(ji,jj,1)
-                  za           = rhoco * SQRT( ( u_ice(ji,jj) - u_oce(ji,jj) )**2 +  &
-                     &                         ( zv_ice1 - v_oce1(ji,jj) )**2 ) * ( 1.0 - zfrld1(ji,jj) )
-                  zr           = z0 * u_ice(ji,jj) + zf1(ji,jj) + za1ct(ji,jj) + za * u_oce(ji,jj)
-                  zcca         = z0 + za
-                  zccb         = zcorl1(ji,jj)
-                  u_ice(ji,jj) = ( zr + zccb * zv_ice1 ) / ( zcca + zepsi ) * rswitch 
+
+                  ! tau_io/(v_oce - v_ice)
+                  zTauO = zaV(ji,jj) * rhoco * SQRT( ( v_ice (ji,jj) - v_oce (ji,jj) ) * ( v_ice (ji,jj) - v_oce (ji,jj) )  &
+                     &                             + ( u_iceV(ji,jj) - u_oceV(ji,jj) ) * ( u_iceV(ji,jj) - u_oceV(ji,jj) ) )
+
+                  ! Coriolis at V-points (energy conserving formulation)
+                  zCor  = - 0.25_wp * r1_e2v(ji,jj) *  &
+                     &    ( zmf(ji,jj  ) * ( e2u(ji,jj  ) * u_ice(ji,jj  ) + e2u(ji-1,jj  ) * u_ice(ji-1,jj  ) )  &
+                     &    + zmf(ji,jj+1) * ( e2u(ji,jj+1) * u_ice(ji,jj+1) + e2u(ji-1,jj+1) * u_ice(ji-1,jj+1) ) )
+
+                  ! Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
+                  zTauE = zfV(ji,jj) + zTauV_ia(ji,jj) + zCor + zspgV(ji,jj) + zTauO * ( v_oce(ji,jj) - v_ice(ji,jj) )
+                  
+                  ! ice velocity using implicit formulation (cf Madec doc & Bouillon 2009)
+                  v_ice(ji,jj) = ( ( zmV_t(ji,jj) * v_ice(ji,jj) + zTauE + zTauO * v_ice(ji,jj)  &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                     &             ) / MAX( zepsi, zmV_t(ji,jj) + zTauO ) * zswitchV(ji,jj)      &  ! m/dt + tau_io(only ice part)
+                     &             + v_oce(ji,jj) * ( 1._wp - zswitchV(ji,jj) )                  &  ! v_ice = v_oce if mass < zmmin
+                     &           ) * zmaskV(ji,jj)
                END DO
             END DO
-
-            CALL lbc_lnk( u_ice(:,:), 'U', -1. )
+            CALL lbc_lnk( v_ice, 'V', -1. )
+            
+#if defined key_agrif && defined key_lim2
+            CALL agrif_rhg_lim2( jter, nn_nevp, 'V' )
+#endif
+#if defined key_bdy
+            CALL bdy_ice_lim_dyn( 'V' )
+#endif         
+
+            DO jj = k_j1+1, k_jpj-1
+               DO ji = fs_2, fs_jpim1
+                               
+                  ! tau_io/(u_oce - u_ice)
+                  zTauO = zaU(ji,jj) * rhoco * SQRT( ( u_ice (ji,jj) - u_oce (ji,jj) ) * ( u_ice (ji,jj) - u_oce (ji,jj) )  &
+                     &                             + ( v_iceU(ji,jj) - v_oceU(ji,jj) ) * ( v_iceU(ji,jj) - v_oceU(ji,jj) ) )
+
+                  ! Coriolis at U-points (energy conserving formulation)
+                  zCor  =   0.25_wp * r1_e1u(ji,jj) *  &
+                     &    ( zmf(ji  ,jj) * ( e1v(ji  ,jj) * v_ice(ji  ,jj) + e1v(ji  ,jj-1) * v_ice(ji  ,jj-1) )  &
+                     &    + zmf(ji+1,jj) * ( e1v(ji+1,jj) * v_ice(ji+1,jj) + e1v(ji+1,jj-1) * v_ice(ji+1,jj-1) ) )
+                  
+                  ! Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
+                  zTauE = zfU(ji,jj) + zTauU_ia(ji,jj) + zCor + zspgU(ji,jj) + zTauO * ( u_oce(ji,jj) - u_ice(ji,jj) )
+
+                  ! ice velocity using implicit formulation (cf Madec doc & Bouillon 2009)
+                  u_ice(ji,jj) = ( ( zmU_t(ji,jj) * u_ice(ji,jj) + zTauE + zTauO * u_ice(ji,jj)  &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                     &             ) / MAX( zepsi, zmU_t(ji,jj) + zTauO ) * zswitchU(ji,jj)      &  ! m/dt + tau_io(only ice part)
+                     &             + u_oce(ji,jj) * ( 1._wp - zswitchU(ji,jj) )                  &  ! v_ice = v_oce if mass < zmmin 
+                     &           ) * zmaskU(ji,jj)
+               END DO
+            END DO
+            CALL lbc_lnk( u_ice, 'U', -1. )
+            
 #if defined key_agrif && defined key_lim2
             CALL agrif_rhg_lim2( jter, nn_nevp, 'U' )
 #endif
 #if defined key_bdy
-         CALL bdy_ice_lim_dyn( 'U' )
+            CALL bdy_ice_lim_dyn( 'U' )
 #endif         
+
+         ELSE ! odd iterations
 
             DO jj = k_j1+1, k_jpj-1
                DO ji = fs_2, fs_jpim1
-
-                  rswitch      = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zmass2(ji,jj) ) ) ) * vmask(ji,jj,1)
-                  z0           = zmass2(ji,jj) * z1_dtevp
-                  ! SB modif because ocean has no slip boundary condition
-                  zu_ice2      = 0.5 * ( ( u_ice(ji,jj  ) + u_ice(ji-1,jj  ) ) * e2t(ji,jj)       &
-                     &                 + ( u_ice(ji,jj+1) + u_ice(ji-1,jj+1) ) * e2t(ji,jj+1) )   &
-                     &                 / ( e2t(ji,jj+1) + e2t(ji,jj) ) * vmask(ji,jj,1)
-                  za           = rhoco * SQRT( ( zu_ice2 - u_oce2(ji,jj) )**2 +  & 
-                     &                         ( v_ice(ji,jj) - v_oce(ji,jj))**2 ) * ( 1.0 - zfrld2(ji,jj) )
-                  zr           = z0 * v_ice(ji,jj) + zf2(ji,jj) + za2ct(ji,jj) + za * v_oce(ji,jj)
-                  zcca         = z0 + za
-                  zccb         = zcorl2(ji,jj)
-                  v_ice(ji,jj) = ( zr - zccb * zu_ice2 ) / ( zcca + zepsi ) * rswitch
+                               
+                  ! tau_io/(u_oce - u_ice)
+                  zTauO = zaU(ji,jj) * rhoco * SQRT( ( u_ice (ji,jj) - u_oce (ji,jj) ) * ( u_ice (ji,jj) - u_oce (ji,jj) )  &
+                     &                             + ( v_iceU(ji,jj) - v_oceU(ji,jj) ) * ( v_iceU(ji,jj) - v_oceU(ji,jj) ) )
+
+                  ! Coriolis at U-points (energy conserving formulation)
+                  zCor  =   0.25_wp * r1_e1u(ji,jj) *  &
+                     &    ( zmf(ji  ,jj) * ( e1v(ji  ,jj) * v_ice(ji  ,jj) + e1v(ji  ,jj-1) * v_ice(ji  ,jj-1) )  &
+                     &    + zmf(ji+1,jj) * ( e1v(ji+1,jj) * v_ice(ji+1,jj) + e1v(ji+1,jj-1) * v_ice(ji+1,jj-1) ) )
+                  
+                  ! Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
+                  zTauE = zfU(ji,jj) + zTauU_ia(ji,jj) + zCor + zspgU(ji,jj) + zTauO * ( u_oce(ji,jj) - u_ice(ji,jj) )
+
+                  ! ice velocity using implicit formulation (cf Madec doc & Bouillon 2009)
+                  u_ice(ji,jj) = ( ( zmU_t(ji,jj) * u_ice(ji,jj) + zTauE + zTauO * u_ice(ji,jj)  &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                     &             ) / MAX( zepsi, zmU_t(ji,jj) + zTauO ) * zswitchU(ji,jj)      &  ! m/dt + tau_io(only ice part)
+                     &             + u_oce(ji,jj) * ( 1._wp - zswitchU(ji,jj) )                  &  ! v_ice = v_oce if mass < zmmin 
+                     &           ) * zmaskU(ji,jj)
                END DO
             END DO
-
-            CALL lbc_lnk( v_ice(:,:), 'V', -1. )
+            CALL lbc_lnk( u_ice, 'U', -1. )
+            
+#if defined key_agrif && defined key_lim2
+            CALL agrif_rhg_lim2( jter, nn_nevp, 'U' )
+#endif
+#if defined key_bdy
+            CALL bdy_ice_lim_dyn( 'U' )
+#endif         
+
+           DO jj = k_j1+1, k_jpj-1
+               DO ji = fs_2, fs_jpim1
+
+                  ! tau_io/(v_oce - v_ice)
+                  zTauO = zaV(ji,jj) * rhoco * SQRT( ( v_ice (ji,jj) - v_oce (ji,jj) ) * ( v_ice (ji,jj) - v_oce (ji,jj) )  &
+                     &                             + ( u_iceV(ji,jj) - u_oceV(ji,jj) ) * ( u_iceV(ji,jj) - u_oceV(ji,jj) ) )
+
+                  ! Coriolis at V-points (energy conserving formulation)
+                  zCor  = - 0.25_wp * r1_e2v(ji,jj) *  &
+                     &    ( zmf(ji,jj  ) * ( e2u(ji,jj  ) * u_ice(ji,jj  ) + e2u(ji-1,jj  ) * u_ice(ji-1,jj  ) )  &
+                     &    + zmf(ji,jj+1) * ( e2u(ji,jj+1) * u_ice(ji,jj+1) + e2u(ji-1,jj+1) * u_ice(ji-1,jj+1) ) )
+
+                  ! Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
+                  zTauE = zfV(ji,jj) + zTauV_ia(ji,jj) + zCor + zspgV(ji,jj) + zTauO * ( v_oce(ji,jj) - v_ice(ji,jj) )
+                  
+                  ! ice velocity using implicit formulation (cf Madec doc & Bouillon 2009)
+                  v_ice(ji,jj) = ( ( zmV_t(ji,jj) * v_ice(ji,jj) + zTauE + zTauO * v_ice(ji,jj)  &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                     &             ) / MAX( zepsi, zmV_t(ji,jj) + zTauO ) * zswitchV(ji,jj)      &  ! m/dt + tau_io(only ice part)
+                     &             + v_oce(ji,jj) * ( 1._wp - zswitchV(ji,jj) )                  &  ! v_ice = v_oce if mass < zmmin
+                     &           ) * zmaskV(ji,jj)
+               END DO
+            END DO
+            CALL lbc_lnk( v_ice, 'V', -1. )
+            
 #if defined key_agrif && defined key_lim2
             CALL agrif_rhg_lim2( jter, nn_nevp, 'V' )
 #endif
 #if defined key_bdy
-         CALL bdy_ice_lim_dyn( 'V' )
+            CALL bdy_ice_lim_dyn( 'V' )
 #endif         
 
-         ELSE 
+         ENDIF
+         
+         IF(ln_ctl) THEN   ! Convergence test
             DO jj = k_j1+1, k_jpj-1
-               DO ji = fs_2, fs_jpim1
-                  rswitch      = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zmass2(ji,jj) ) ) ) * vmask(ji,jj,1)
-                  z0           = zmass2(ji,jj) * z1_dtevp
-                  ! SB modif because ocean has no slip boundary condition
-                  zu_ice2      = 0.5 * ( ( u_ice(ji,jj  ) + u_ice(ji-1,jj  ) ) * e2t(ji,jj)       &
-                     &                  +( u_ice(ji,jj+1) + u_ice(ji-1,jj+1) ) * e2t(ji,jj+1) )   &
-                     &                 / ( e2t(ji,jj+1) + e2t(ji,jj) ) * vmask(ji,jj,1)   
-
-                  za           = rhoco * SQRT( ( zu_ice2 - u_oce2(ji,jj) )**2 +  &
-                     &                         ( v_ice(ji,jj) - v_oce(ji,jj) )**2 ) * ( 1.0 - zfrld2(ji,jj) )
-                  zr           = z0 * v_ice(ji,jj) + zf2(ji,jj) + za2ct(ji,jj) + za * v_oce(ji,jj)
-                  zcca         = z0 + za
-                  zccb         = zcorl2(ji,jj)
-                  v_ice(ji,jj) = ( zr - zccb * zu_ice2 ) / ( zcca + zepsi ) * rswitch
-               END DO
-            END DO
-
-            CALL lbc_lnk( v_ice(:,:), 'V', -1. )
-#if defined key_agrif && defined key_lim2
-            CALL agrif_rhg_lim2( jter, nn_nevp, 'V' )
-#endif
-#if defined key_bdy
-         CALL bdy_ice_lim_dyn( 'V' )
-#endif         
-
-            DO jj = k_j1+1, k_jpj-1
-               DO ji = fs_2, fs_jpim1
-                  rswitch      = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zmass1(ji,jj) ) ) ) * umask(ji,jj,1)
-                  z0           = zmass1(ji,jj) * z1_dtevp
-                  zv_ice1      = 0.5 * ( ( v_ice(ji  ,jj) + v_ice(ji  ,jj-1) ) * e1t(ji,jj)       &
-                     &                 + ( v_ice(ji+1,jj) + v_ice(ji+1,jj-1) ) * e1t(ji+1,jj) )   &
-                     &                 / ( e1t(ji+1,jj) + e1t(ji,jj) ) * umask(ji,jj,1)
-
-                  za           = rhoco * SQRT( ( u_ice(ji,jj) - u_oce(ji,jj) )**2 +  &
-                     &                         ( zv_ice1 - v_oce1(ji,jj) )**2 ) * ( 1.0 - zfrld1(ji,jj) )
-                  zr           = z0 * u_ice(ji,jj) + zf1(ji,jj) + za1ct(ji,jj) + za * u_oce(ji,jj)
-                  zcca         = z0 + za
-                  zccb         = zcorl1(ji,jj)
-                  u_ice(ji,jj) = ( zr + zccb * zv_ice1 ) / ( zcca + zepsi ) * rswitch 
-               END DO
-            END DO
-
-            CALL lbc_lnk( u_ice(:,:), 'U', -1. )
-#if defined key_agrif && defined key_lim2
-            CALL agrif_rhg_lim2( jter, nn_nevp, 'U' )
-#endif
-#if defined key_bdy
-         CALL bdy_ice_lim_dyn( 'U' )
-#endif         
-
-         ENDIF
-         
-         IF(ln_ctl) THEN
-            !---  Convergence test.
-            DO jj = k_j1+1 , k_jpj-1
                zresr(:,jj) = MAX( ABS( u_ice(:,jj) - zu_ice(:,jj) ), ABS( v_ice(:,jj) - zv_ice(:,jj) ) )
             END DO
@@ -552,5 +572,5 @@
             IF( lk_mpp )   CALL mpp_max( zresm )   ! max over the global domain
          ENDIF
-
+         !
          !                                                ! ==================== !
       END DO                                              !  end loop over jter  !
@@ -558,92 +578,50 @@
       !
       !------------------------------------------------------------------------------!
-      ! 4) Prevent ice velocities when the ice is thin
-      !------------------------------------------------------------------------------!
-      ! If the ice volume is below zvmin then ice velocity should equal the
-      ! ocean velocity. This prevents high velocity when ice is thin
-      DO jj = k_j1+1, k_jpj-1
-         DO ji = fs_2, fs_jpim1
-            IF ( vt_i(ji,jj) <= zvmin ) THEN
-               u_ice(ji,jj) = u_oce(ji,jj)
-               v_ice(ji,jj) = v_oce(ji,jj)
-            ENDIF
+      ! 4) Recompute delta, shear and div (inputs for mechanical redistribution) 
+      !------------------------------------------------------------------------------!
+      DO jj = k_j1, k_jpj-1 
+         DO ji = 1, jpim1
+
+            ! shear at F points
+            zds(ji,jj) = ( ( u_ice(ji,jj+1) * r1_e1u(ji,jj+1) - u_ice(ji,jj) * r1_e1u(ji,jj) ) * e1f(ji,jj) * e1f(ji,jj)   &
+               &         + ( v_ice(ji+1,jj) * r1_e2v(ji+1,jj) - v_ice(ji,jj) * r1_e2v(ji,jj) ) * e2f(ji,jj) * e2f(ji,jj)   &
+               &         ) * r1_e12f(ji,jj) * zfmask(ji,jj)
+
+         END DO
+      END DO           
+      CALL lbc_lnk( zds, 'F', 1. )
+      
+      DO jj = k_j1+1, k_jpj-1 
+         DO ji = 2, jpim1 ! no vector loop
+            
+            ! tension**2 at T points
+            zdt  = ( ( u_ice(ji,jj) * r1_e2u(ji,jj) - u_ice(ji-1,jj) * r1_e2u(ji-1,jj) ) * e2t(ji,jj) * e2t(ji,jj)   &
+               &   - ( v_ice(ji,jj) * r1_e1v(ji,jj) - v_ice(ji,jj-1) * r1_e1v(ji,jj-1) ) * e1t(ji,jj) * e1t(ji,jj)   &
+               &   ) * r1_e12t(ji,jj)
+            zdt2 = zdt * zdt
+            
+            ! shear**2 at T points (doc eq. A16)
+            zds2 = ( zds(ji,jj  ) * zds(ji,jj  ) * e12f(ji,jj  ) + zds(ji-1,jj  ) * zds(ji-1,jj  ) * e12f(ji-1,jj  )  &
+               &   + zds(ji,jj-1) * zds(ji,jj-1) * e12f(ji,jj-1) + zds(ji-1,jj-1) * zds(ji-1,jj-1) * e12f(ji-1,jj-1)  &
+               &   ) * 0.25_wp * r1_e12t(ji,jj)
+            
+            ! shear at T points
+            shear_i(ji,jj) = SQRT( zdt2 + zds2 )
+
+            ! divergence at T points
+            divu_i(ji,jj) = ( e2u(ji,jj) * u_ice(ji,jj) - e2u(ji-1,jj) * u_ice(ji-1,jj)   &
+               &            + e1v(ji,jj) * v_ice(ji,jj) - e1v(ji,jj-1) * v_ice(ji,jj-1)   &
+               &            ) * r1_e12t(ji,jj)
+            
+            ! delta at T points
+            zdelta         = SQRT( divu_i(ji,jj) * divu_i(ji,jj) + ( zdt2 + zds2 ) * usecc2 )  
+            rswitch        = 1._wp - MAX( 0._wp, SIGN( 1._wp, -zdelta ) ) ! 0 if delta=0
+            delta_i(ji,jj) = zdelta + rn_creepl * rswitch
+
          END DO
       END DO
-
-      CALL lbc_lnk_multi( u_ice(:,:), 'U', -1., v_ice(:,:), 'V', -1. )
-
-#if defined key_agrif && defined key_lim2
-      CALL agrif_rhg_lim2( nn_nevp , nn_nevp, 'U' )
-      CALL agrif_rhg_lim2( nn_nevp , nn_nevp, 'V' )
-#endif
-#if defined key_bdy
-      CALL bdy_ice_lim_dyn( 'U' )
-      CALL bdy_ice_lim_dyn( 'V' )
-#endif         
-
-      DO jj = k_j1+1, k_jpj-1 
-         DO ji = fs_2, fs_jpim1
-            IF ( vt_i(ji,jj) <= zvmin ) THEN
-               v_ice1(ji,jj)  = 0.5_wp * ( ( v_ice(ji  ,jj) + v_ice(ji,  jj-1) ) * e1t(ji+1,jj)     &
-                  &                      + ( v_ice(ji+1,jj) + v_ice(ji+1,jj-1) ) * e1t(ji  ,jj) )   &
-                  &                      / ( e1t(ji+1,jj) + e1t(ji,jj) ) * umask(ji,jj,1)
-
-               u_ice2(ji,jj)  = 0.5_wp * ( ( u_ice(ji,jj  ) + u_ice(ji-1,jj  ) ) * e2t(ji,jj+1)     &
-                  &                      + ( u_ice(ji,jj+1) + u_ice(ji-1,jj+1) ) * e2t(ji,jj  ) )   &
-                  &                      / ( e2t(ji,jj+1) + e2t(ji,jj) ) * vmask(ji,jj,1)
-            ENDIF 
-         END DO
-      END DO
-
-      CALL lbc_lnk_multi( u_ice2(:,:), 'V', -1., v_ice1(:,:), 'U', -1. )
-
-      ! Recompute delta, shear and div, inputs for mechanical redistribution 
-      DO jj = k_j1+1, k_jpj-1
-         DO ji = fs_2, jpim1   !RB bug no vect opt due to zmask
-            !- divu_i(:,:), zdt(:,:): divergence and tension at centre 
-            !- zds(:,:): shear on northeast corner of grid cells
-            IF ( vt_i(ji,jj) <= zvmin ) THEN
-
-               divu_i(ji,jj) = (  e2u(ji,jj) * u_ice(ji,jj) - e2u(ji-1,jj  ) * u_ice(ji-1,jj  )   &
-                  &             + e1v(ji,jj) * v_ice(ji,jj) - e1v(ji  ,jj-1) * v_ice(ji  ,jj-1)   &
-                  &            ) * r1_e12t(ji,jj)
-
-               zdt(ji,jj) = ( ( u_ice(ji,jj) * r1_e2u(ji,jj) - u_ice(ji-1,jj) * r1_e2u(ji-1,jj) ) * e2t(ji,jj) * e2t(ji,jj)  &
-                  &          -( v_ice(ji,jj) * r1_e1v(ji,jj) - v_ice(ji,jj-1) * r1_e1v(ji,jj-1) ) * e1t(ji,jj) * e1t(ji,jj)  &
-                  &         ) * r1_e12t(ji,jj)
-               !
-               ! SB modif because ocean has no slip boundary condition 
-               zds(ji,jj) = ( ( u_ice(ji,jj+1) * r1_e1u(ji,jj+1) - u_ice(ji,jj) * r1_e1u(ji,jj) ) * e1f(ji,jj) * e1f(ji,jj)  &
-                  &          +( v_ice(ji+1,jj) * r1_e2v(ji+1,jj) - v_ice(ji,jj) * r1_e2v(ji,jj) ) * e2f(ji,jj) * e2f(ji,jj)  &
-                  &         ) * r1_e12f(ji,jj) * ( 2.0 - fmask(ji,jj,1) )                                     &
-                  &         * zmask(ji,jj) * zmask(ji,jj+1) * zmask(ji+1,jj) * zmask(ji+1,jj+1)
-
-               zdst = ( e2u(ji,jj) * v_ice1(ji,jj) - e2u(ji-1,jj  ) * v_ice1(ji-1,jj  )    &
-                  &   + e1v(ji,jj) * u_ice2(ji,jj) - e1v(ji  ,jj-1) * u_ice2(ji  ,jj-1) ) * r1_e12t(ji,jj)
-
-               delta = SQRT( divu_i(ji,jj)**2 + ( zdt(ji,jj)**2 + zdst**2 ) * usecc2 )  
-               delta_i(ji,jj) = delta + rn_creepl
-            
-            ENDIF
-         END DO
-      END DO
-      !
-      !------------------------------------------------------------------------------!
-      ! 5) Store stress tensor and its invariants
-      !------------------------------------------------------------------------------!
-      ! * Invariants of the stress tensor are required for limitd_me
-      !   (accelerates convergence and improves stability)
-      DO jj = k_j1+1, k_jpj-1
-         DO ji = fs_2, fs_jpim1
-            zdst           = (  e2u(ji,jj) * v_ice1(ji,jj) - e2u( ji-1, jj   ) * v_ice1(ji-1,jj)  &   
-               &              + e1v(ji,jj) * u_ice2(ji,jj) - e1v( ji  , jj-1 ) * u_ice2(ji,jj-1) ) * r1_e12t(ji,jj) 
-            shear_i(ji,jj) = SQRT( zdt(ji,jj) * zdt(ji,jj) + zdst * zdst )
-         END DO
-      END DO
-
-      ! Lateral boundary condition
-      CALL lbc_lnk_multi( divu_i (:,:), 'T', 1., delta_i(:,:), 'T', 1.,  shear_i(:,:), 'T', 1. )
-
-      ! * Store the stress tensor for the next time step
+      CALL lbc_lnk_multi( shear_i, 'T', 1., divu_i, 'T', 1., delta_i, 'T', 1. )
+      
+      ! --- Store the stress tensor for the next time step --- !
       stress1_i (:,:) = zs1 (:,:)
       stress2_i (:,:) = zs2 (:,:)
@@ -652,5 +630,5 @@
       !
       !------------------------------------------------------------------------------!
-      ! 6) Control prints of residual and charge ellipse
+      ! 5) Control prints of residual and charge ellipse
       !------------------------------------------------------------------------------!
       !
@@ -675,6 +653,6 @@
                DO ji = 2, jpim1
                   IF (zpresh(ji,jj) > 1.0) THEN
-                     sigma1 = ( zs1(ji,jj) + (zs2(ji,jj)**2 + 4*zs12(ji,jj)**2 )**0.5 ) / ( 2*zpresh(ji,jj) ) 
-                     sigma2 = ( zs1(ji,jj) - (zs2(ji,jj)**2 + 4*zs12(ji,jj)**2 )**0.5 ) / ( 2*zpresh(ji,jj) )
+                     zsig1 = ( zs1(ji,jj) + (zs2(ji,jj)**2 + 4*zs12(ji,jj)**2 )**0.5 ) / ( 2*zpresh(ji,jj) ) 
+                     zsig2 = ( zs1(ji,jj) - (zs2(ji,jj)**2 + 4*zs12(ji,jj)**2 )**0.5 ) / ( 2*zpresh(ji,jj) )
                      WRITE(charout,FMT="('lim_rhg  :', I4, I4, D23.16, D23.16, D23.16, D23.16, A10)")
                      CALL prt_ctl_info(charout)
@@ -687,8 +665,9 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi,jpj, zpresh, zfrld1, zmass1, zcorl1, za1ct , zpreshc, zfrld2, zmass2, zcorl2, za2ct )
-      CALL wrk_dealloc( jpi,jpj, u_oce2, u_ice2, v_oce1 , v_ice1 , zmask               )
-      CALL wrk_dealloc( jpi,jpj, zf1   , zu_ice, zf2   , zv_ice , zdt    , zds  )
-      CALL wrk_dealloc( jpi,jpj, zs1   , zs2   , zs12   , zresr , zpice                 )
+      CALL wrk_dealloc( jpi,jpj, zpresh, z1_e1t0, z1_e2t0, zp_delt )
+      CALL wrk_dealloc( jpi,jpj, zaU, zaV, zmU_t, zmV_t, zmf, zTauU_ia, ztauV_ia )
+      CALL wrk_dealloc( jpi,jpj, zspgU, zspgV, v_oceU, u_oceV, v_iceU, u_iceV, zfU, zfV )
+      CALL wrk_dealloc( jpi,jpj, zds, zs1, zs2, zs12, zu_ice, zv_ice, zresr, zpice )
+      CALL wrk_dealloc( jpi,jpj, zswitchU, zswitchV, zmaskU, zmaskV, zfmask, zwf )
 
    END SUBROUTINE lim_rhg
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limsbc.F90	(revision 7483)
@@ -110,20 +110,5 @@
       !!---------------------------------------------------------------------
 
-      ! make calls for heat fluxes before it is modified
-      ! pfrld is the lead fraction at the previous time step (actually between TRP and THD)
-      IF( iom_use('qsr_oce') )   CALL iom_put( "qsr_oce" , qsr_oce(:,:) * pfrld(:,:) )                                   !     solar flux at ocean surface
-      IF( iom_use('qns_oce') )   CALL iom_put( "qns_oce" , qns_oce(:,:) * pfrld(:,:) + qemp_oce(:,:) )                   ! non-solar flux at ocean surface
-      IF( iom_use('qsr_ice') )   CALL iom_put( "qsr_ice" , SUM( qsr_ice(:,:,:) * a_i_b(:,:,:), dim=3 ) )                 !     solar flux at ice surface
-      IF( iom_use('qns_ice') )   CALL iom_put( "qns_ice" , SUM( qns_ice(:,:,:) * a_i_b(:,:,:), dim=3 ) + qemp_ice(:,:) ) ! non-solar flux at ice surface
-      IF( iom_use('qtr_ice') )   CALL iom_put( "qtr_ice" , SUM( ftr_ice(:,:,:) * a_i_b(:,:,:), dim=3 ) )                 !     solar flux transmitted thru ice
-      IF( iom_use('qt_oce' ) )   CALL iom_put( "qt_oce"  , ( qsr_oce(:,:) + qns_oce(:,:) ) * pfrld(:,:) + qemp_oce(:,:) )  
-      IF( iom_use('qt_ice' ) )   CALL iom_put( "qt_ice"  , SUM( ( qns_ice(:,:,:) + qsr_ice(:,:,:) )   &
-         &                                                      * a_i_b(:,:,:), dim=3 ) + qemp_ice(:,:) )
-      IF( iom_use('qemp_oce') )  CALL iom_put( "qemp_oce" , qemp_oce(:,:) )  
-      IF( iom_use('qemp_ice') )  CALL iom_put( "qemp_ice" , qemp_ice(:,:) )  
-      IF( iom_use('emp_oce' ) )  CALL iom_put( "emp_oce"  , emp_oce(:,:) )   ! emp over ocean (taking into account the snow blown away from the ice)
-      IF( iom_use('emp_ice' ) )  CALL iom_put( "emp_ice"  , emp_ice(:,:) )   ! emp over ice   (taking into account the snow blown away from the ice)
-
-      ! albedo output
+      ! make call for albedo output before it is modified
       CALL wrk_alloc( jpi,jpj, zalb )    
 
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90	(revision 7483)
@@ -54,5 +54,4 @@
    PUBLIC   lim_var_eqv2glo      
    PUBLIC   lim_var_salprof      
-   PUBLIC   lim_var_icetm        
    PUBLIC   lim_var_bv           
    PUBLIC   lim_var_salprof1d    
@@ -89,23 +88,11 @@
       ! Compute variables
       !--------------------
-      vt_i (:,:) = 0._wp
-      vt_s (:,:) = 0._wp
-      at_i (:,:) = 0._wp
-      ato_i(:,:) = 1._wp
-      !
-      DO jl = 1, jpl
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               !
-               vt_i(ji,jj) = vt_i(ji,jj) + v_i(ji,jj,jl) ! ice volume
-               vt_s(ji,jj) = vt_s(ji,jj) + v_s(ji,jj,jl) ! snow volume
-               at_i(ji,jj) = at_i(ji,jj) + a_i(ji,jj,jl) ! ice concentration
-               !
-               rswitch = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi10 ) ) 
-               icethi(ji,jj) = vt_i(ji,jj) / MAX( at_i(ji,jj) , epsi10 ) * rswitch  ! ice thickness
-            END DO
-         END DO
-      END DO
-
+      ! integrated values
+      vt_i (:,:) = SUM( v_i, dim=3 )
+      vt_s (:,:) = SUM( v_s, dim=3 )
+      at_i (:,:) = SUM( a_i, dim=3 )
+      et_s(:,:)  = SUM( SUM( e_s(:,:,:,:), dim=4 ), dim=3 )
+      et_i(:,:)  = SUM( SUM( e_i(:,:,:,:), dim=4 ), dim=3 )
+      !
       DO jj = 1, jpj
          DO ji = 1, jpi
@@ -115,26 +102,43 @@
 
       IF( kn > 1 ) THEN
-         et_s (:,:) = 0._wp
-         ot_i (:,:) = 0._wp
+         !
+         ! mean ice/snow thickness
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               rswitch      = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi10 ) ) 
+               htm_i(ji,jj) = vt_i(ji,jj) / MAX( at_i(ji,jj) , epsi10 ) * rswitch
+               htm_s(ji,jj) = vt_s(ji,jj) / MAX( at_i(ji,jj) , epsi10 ) * rswitch
+            ENDDO
+         ENDDO
+
+         ! mean temperature (K), salinity and age
          smt_i(:,:) = 0._wp
-         et_i (:,:) = 0._wp
-         !
+         tm_i(:,:)  = 0._wp
+         tm_su(:,:) = 0._wp
+         om_i (:,:) = 0._wp
          DO jl = 1, jpl
+            
             DO jj = 1, jpj
                DO ji = 1, jpi
-                  et_s(ji,jj)  = et_s(ji,jj)  + e_s(ji,jj,1,jl)                                           ! snow heat content
-                  rswitch = MAX( 0._wp , SIGN( 1._wp , vt_i(ji,jj) - epsi20 ) ) 
-                  smt_i(ji,jj) = smt_i(ji,jj) + smv_i(ji,jj,jl) / MAX( vt_i(ji,jj) , epsi20 ) * rswitch   ! ice salinity
-                  rswitch = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi20 ) ) 
-                  ot_i(ji,jj)  = ot_i(ji,jj)  + oa_i(ji,jj,jl)  / MAX( at_i(ji,jj) , epsi20 ) * rswitch   ! ice age
-               END DO
-            END DO
-         END DO
-         !
-         DO jl = 1, jpl
+                  rswitch      = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi10 ) )
+                  tm_su(ji,jj) = tm_su(ji,jj) + rswitch * ( t_su(ji,jj,jl) - rt0 ) * a_i(ji,jj,jl) / MAX( at_i(ji,jj) , epsi10 )
+                  om_i (ji,jj) = om_i (ji,jj) + rswitch *   oa_i(ji,jj,jl)                         / MAX( at_i(ji,jj) , epsi10 )
+               END DO
+            END DO
+            
             DO jk = 1, nlay_i
-               et_i(:,:) = et_i(:,:) + e_i(:,:,jk,jl)       ! ice heat content
-            END DO
-         END DO
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     rswitch = MAX( 0._wp , SIGN( 1._wp , vt_i(ji,jj) - epsi10 ) )
+                     tm_i(ji,jj)  = tm_i(ji,jj)  + r1_nlay_i * rswitch * ( t_i(ji,jj,jk,jl) - rt0 ) * v_i(ji,jj,jl)  &
+                        &            / MAX( vt_i(ji,jj) , epsi10 )
+                     smt_i(ji,jj) = smt_i(ji,jj) + r1_nlay_i * rswitch * s_i(ji,jj,jk,jl) * v_i(ji,jj,jl)  &
+                        &            / MAX( vt_i(ji,jj) , epsi10 )
+                  END DO
+               END DO
+            END DO
+         END DO
+         tm_i  = tm_i  + rt0
+         tm_su = tm_su + rt0
          !
       ENDIF
@@ -246,8 +250,8 @@
       ! Mean temperature
       !-------------------
-      vt_i (:,:) = 0._wp
-      DO jl = 1, jpl
-         vt_i(:,:) = vt_i(:,:) + v_i(:,:,jl)
-      END DO
+      ! integrated values
+      vt_i (:,:) = SUM( v_i, dim=3 )
+      vt_s (:,:) = SUM( v_s, dim=3 )
+      at_i (:,:) = SUM( a_i, dim=3 )
 
       tm_i(:,:) = 0._wp
@@ -397,67 +401,34 @@
    END SUBROUTINE lim_var_salprof
 
-
-   SUBROUTINE lim_var_icetm
-      !!------------------------------------------------------------------
-      !!                ***  ROUTINE lim_var_icetm ***
-      !!
-      !! ** Purpose :   computes mean sea ice temperature
+   SUBROUTINE lim_var_bv
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_var_bv ***
+      !!
+      !! ** Purpose :   computes mean brine volume (%) in sea ice
+      !!
+      !! ** Method  : e = - 0.054 * S (ppt) / T (C)
+      !!
+      !! References : Vancoppenolle et al., JGR, 2007
       !!------------------------------------------------------------------
       INTEGER  ::   ji, jj, jk, jl   ! dummy loop indices
       !!------------------------------------------------------------------
-
-      ! Mean sea ice temperature
-      vt_i (:,:) = 0._wp
-      DO jl = 1, jpl
-         vt_i(:,:) = vt_i(:,:) + v_i(:,:,jl)
-      END DO
-
-      tm_i(:,:) = 0._wp
+      !
+      bvm_i(:,:)   = 0._wp
+      bv_i (:,:,:) = 0._wp
       DO jl = 1, jpl
          DO jk = 1, nlay_i
             DO jj = 1, jpj
                DO ji = 1, jpi
-                  rswitch = MAX( 0._wp , SIGN( 1._wp , vt_i(ji,jj) - epsi10 ) )
-                  tm_i(ji,jj) = tm_i(ji,jj) + r1_nlay_i * rswitch * ( t_i(ji,jj,jk,jl) - rt0 ) * v_i(ji,jj,jl)  &
-                     &            / MAX( vt_i(ji,jj) , epsi10 )
-               END DO
-            END DO
-         END DO
-      END DO
-      tm_i = tm_i + rt0
-
-   END SUBROUTINE lim_var_icetm
-
-
-   SUBROUTINE lim_var_bv
-      !!------------------------------------------------------------------
-      !!                ***  ROUTINE lim_var_bv ***
-      !!
-      !! ** Purpose :   computes mean brine volume (%) in sea ice
-      !!
-      !! ** Method  : e = - 0.054 * S (ppt) / T (C)
-      !!
-      !! References : Vancoppenolle et al., JGR, 2007
-      !!------------------------------------------------------------------
-      INTEGER  ::   ji, jj, jk, jl   ! dummy loop indices
-      REAL(wp) ::   zbvi             ! local scalars
-      !!------------------------------------------------------------------
-      !
-      vt_i (:,:) = 0._wp
-      DO jl = 1, jpl
-         vt_i(:,:) = vt_i(:,:) + v_i(:,:,jl)
-      END DO
-
-      bv_i(:,:) = 0._wp
-      DO jl = 1, jpl
-         DO jk = 1, nlay_i
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  rswitch = (  1._wp - MAX( 0._wp , SIGN( 1._wp , (t_i(ji,jj,jk,jl) - rt0) + epsi10 ) )  )
-                  zbvi  = - rswitch * tmut * s_i(ji,jj,jk,jl) / MIN( t_i(ji,jj,jk,jl) - rt0, - epsi10 )   &
-                     &                   * v_i(ji,jj,jl) * r1_nlay_i
-                  rswitch = (  1._wp - MAX( 0._wp , SIGN( 1._wp , - vt_i(ji,jj) + epsi20 ) )  )
-                  bv_i(ji,jj) = bv_i(ji,jj) + rswitch * zbvi  / MAX( vt_i(ji,jj) , epsi20 )
-               END DO
+                  rswitch        = ( 1._wp - MAX( 0._wp , SIGN( 1._wp , (t_i(ji,jj,jk,jl) - rt0) + epsi10 ) )  )
+                  bv_i(ji,jj,jl) = bv_i(ji,jj,jl) - rswitch * tmut * s_i(ji,jj,jk,jl) * r1_nlay_i  &
+                     &                            / MIN( t_i(ji,jj,jk,jl) - rt0, - epsi10 )
+               END DO
+            END DO
+         END DO
+         
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               rswitch      = MAX( 0._wp , SIGN( 1._wp , vt_i(ji,jj) - epsi10 ) )
+               bvm_i(ji,jj) = bvm_i(ji,jj) + rswitch * bv_i(ji,jj,jl) * v_i(ji,jj,jl) / MAX( vt_i(ji,jj), epsi10 )
             END DO
          END DO
@@ -715,5 +686,6 @@
             zht_i(ji,1:jpl) = 0._wp
             za_i (ji,1:jpl) = 0._wp
-            
+            itest(:)        = 0      
+      
             ! *** case very thin ice: fill only category 1
             IF ( i_fill == 1 ) THEN
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 7483)
@@ -17,5 +17,4 @@
    USE sbc_oce         ! Surface boundary condition: ocean fields
    USE sbc_ice         ! Surface boundary condition: ice fields
-   USE dom_ice
    USE ice
    USE limvar
@@ -40,8 +39,4 @@
    !!----------------------------------------------------------------------
 CONTAINS
-
-#if defined key_dimgout
-# include "limwri_dimg.h90"
-#else
 
    SUBROUTINE lim_wri( kindic )
@@ -59,13 +54,13 @@
       INTEGER  ::  ji, jj, jk, jl  ! dummy loop indices
       REAL(wp) ::  z1_365
-      REAL(wp) ::  ztmp
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zoi, zei, zt_i, zt_s
-      REAL(wp), POINTER, DIMENSION(:,:)   ::  z2d, z2da, z2db, zswi    ! 2D workspace
+      REAL(wp) ::  z2da, z2db, ztmp
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zswi2
+      REAL(wp), POINTER, DIMENSION(:,:)   ::  z2d, zswi    ! 2D workspace
       !!-------------------------------------------------------------------
 
       IF( nn_timing == 1 )  CALL timing_start('limwri')
 
-      CALL wrk_alloc( jpi, jpj, jpl, zoi, zei, zt_i, zt_s )
-      CALL wrk_alloc( jpi, jpj     , z2d, z2da, z2db, zswi )
+      CALL wrk_alloc( jpi, jpj, jpl, zswi2 )
+      CALL wrk_alloc( jpi, jpj     , z2d, zswi )
 
       !-----------------------------
@@ -74,105 +69,74 @@
       z1_365 = 1._wp / 365._wp
 
-      CALL lim_var_icetm      ! mean sea ice temperature
-
-      CALL lim_var_bv         ! brine volume
-
-      DO jj = 1, jpj          ! presence indicator of ice
+      ! brine volume
+      CALL lim_var_bv 
+
+      ! tresholds for outputs
+      DO jj = 1, jpj
          DO ji = 1, jpi
             zswi(ji,jj)  = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi06 ) )
          END DO
       END DO
-      !
-      !
-      !                                             
-      IF ( iom_use( "icethic_cea" ) ) THEN                       ! mean ice thickness
-         DO jj = 1, jpj 
+      DO jl = 1, jpl
+         DO jj = 1, jpj
             DO ji = 1, jpi
-               z2d(ji,jj)  = vt_i(ji,jj) / MAX( at_i(ji,jj), epsi06 ) * zswi(ji,jj)
+               zswi2(ji,jj,jl)  = MAX( 0._wp , SIGN( 1._wp , a_i(ji,jj,jl) - epsi06 ) )
             END DO
          END DO
-         CALL iom_put( "icethic_cea"  , z2d              )
-      ENDIF
-
-      IF ( iom_use( "snowthic_cea" ) ) THEN                      ! snow thickness = mean snow thickness over the cell 
-         DO jj = 1, jpj                                            
-            DO ji = 1, jpi
-               z2d(ji,jj)  = vt_s(ji,jj) / MAX( at_i(ji,jj), epsi06 ) * zswi(ji,jj)
-            END DO
-         END DO
-         CALL iom_put( "snowthic_cea" , z2d              )       
-      ENDIF
+      END DO
       !
+      ! fluxes 
+      ! pfrld is the lead fraction at the previous time step (actually between TRP and THD)
+      IF( iom_use('qsr_oce') )   CALL iom_put( "qsr_oce" , qsr_oce(:,:) * pfrld(:,:) )                                   !     solar flux at ocean surface
+      IF( iom_use('qns_oce') )   CALL iom_put( "qns_oce" , qns_oce(:,:) * pfrld(:,:) + qemp_oce(:,:) )                   ! non-solar flux at ocean surface
+      IF( iom_use('qsr_ice') )   CALL iom_put( "qsr_ice" , SUM( qsr_ice(:,:,:) * a_i_b(:,:,:), dim=3 ) )                 !     solar flux at ice surface
+      IF( iom_use('qns_ice') )   CALL iom_put( "qns_ice" , SUM( qns_ice(:,:,:) * a_i_b(:,:,:), dim=3 ) + qemp_ice(:,:) ) ! non-solar flux at ice surface
+      IF( iom_use('qtr_ice') )   CALL iom_put( "qtr_ice" , SUM( ftr_ice(:,:,:) * a_i_b(:,:,:), dim=3 ) )                 !     solar flux transmitted thru ice
+      IF( iom_use('qt_oce' ) )   CALL iom_put( "qt_oce"  , ( qsr_oce(:,:) + qns_oce(:,:) ) * pfrld(:,:) + qemp_oce(:,:) )  
+      IF( iom_use('qt_ice' ) )   CALL iom_put( "qt_ice"  , SUM( ( qns_ice(:,:,:) + qsr_ice(:,:,:) )   &
+         &                                                      * a_i_b(:,:,:),dim=3 ) + qemp_ice(:,:) )
+      IF( iom_use('qemp_oce') )  CALL iom_put( "qemp_oce" , qemp_oce(:,:) )  
+      IF( iom_use('qemp_ice') )  CALL iom_put( "qemp_ice" , qemp_ice(:,:) )  
+      IF( iom_use('emp_oce' ) )  CALL iom_put( "emp_oce"  , emp_oce(:,:) )   !emp over ocean (taking into account the snow blown away from the ice)
+      IF( iom_use('emp_ice' ) )  CALL iom_put( "emp_ice"  , emp_ice(:,:) )   !emp over ice   (taking into account the snow blown away from the ice)
+
+      ! velocity
       IF ( iom_use( "uice_ipa" ) .OR. iom_use( "vice_ipa" ) .OR. iom_use( "icevel" ) ) THEN 
          DO jj = 2 , jpjm1
             DO ji = 2 , jpim1
-               z2da(ji,jj)  = (  u_ice(ji,jj) * umask(ji,jj,1) + u_ice(ji-1,jj) * umask(ji-1,jj,1) ) * 0.5_wp
-               z2db(ji,jj)  = (  v_ice(ji,jj) * vmask(ji,jj,1) + v_ice(ji,jj-1) * vmask(ji,jj-1,1) ) * 0.5_wp
+               z2da  = ( u_ice(ji,jj) * umask(ji,jj,1) + u_ice(ji-1,jj) * umask(ji-1,jj,1) ) * 0.5_wp
+               z2db  = ( v_ice(ji,jj) * vmask(ji,jj,1) + v_ice(ji,jj-1) * vmask(ji,jj-1,1) ) * 0.5_wp
+               z2d(ji,jj) = SQRT( z2da * z2da + z2db * z2db )
            END DO
          END DO
-         CALL lbc_lnk( z2da, 'T', -1. )
-         CALL lbc_lnk( z2db, 'T', -1. )
-         CALL iom_put( "uice_ipa"     , z2da             )       ! ice velocity u component
-         CALL iom_put( "vice_ipa"     , z2db             )       ! ice velocity v component
-         DO jj = 1, jpj                                 
-            DO ji = 1, jpi
-               z2d(ji,jj)  = SQRT( z2da(ji,jj) * z2da(ji,jj) + z2db(ji,jj) * z2db(ji,jj) ) 
-            END DO
-         END DO
-         CALL iom_put( "icevel"       , z2d              )       ! ice velocity module
+         CALL lbc_lnk( z2d, 'T', 1. )
+         CALL iom_put( "uice_ipa"     , u_ice      )       ! ice velocity u component
+         CALL iom_put( "vice_ipa"     , v_ice      )       ! ice velocity v component
+         CALL iom_put( "icevel"       , z2d        )       ! ice velocity module
       ENDIF
       !
-      IF ( iom_use( "miceage" ) ) THEN 
-         z2d(:,:) = 0.e0
-         DO jl = 1, jpl
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  rswitch    = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - 0.1 ) )
-                  z2d(ji,jj) = z2d(ji,jj) + rswitch * oa_i(ji,jj,jl) / MAX( at_i(ji,jj), 0.1 )
-               END DO
-            END DO
-         END DO
-         CALL iom_put( "miceage"     , z2d * z1_365      )        ! mean ice age
-      ENDIF
-
-      IF ( iom_use( "micet" ) ) THEN 
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               z2d(ji,jj) = ( tm_i(ji,jj) - rt0 ) * zswi(ji,jj)
-            END DO
-         END DO
-         CALL iom_put( "micet"       , z2d               )        ! mean ice temperature
-      ENDIF
+      IF ( iom_use( "miceage" ) )       CALL iom_put( "miceage"     , om_i * zswi * z1_365   )  ! mean ice age
+      IF ( iom_use( "icethic_cea" ) )   CALL iom_put( "icethic_cea" , htm_i * zswi           )  ! ice thickness mean
+      IF ( iom_use( "snowthic_cea" ) )  CALL iom_put( "snowthic_cea", htm_s * zswi           )  ! snow thickness mean
+      IF ( iom_use( "micet" ) )         CALL iom_put( "micet"       , ( tm_i  - rt0 ) * zswi )  ! ice mean    temperature
+      IF ( iom_use( "icest" ) )         CALL iom_put( "icest"       , ( tm_su - rt0 ) * zswi )  ! ice surface temperature
+      IF ( iom_use( "icecolf" ) )       CALL iom_put( "icecolf"     , hicol                  )  ! frazil ice collection thickness
       !
-      IF ( iom_use( "icest" ) ) THEN 
-         z2d(:,:) = 0.e0
-         DO jl = 1, jpl
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  z2d(ji,jj) = z2d(ji,jj) + zswi(ji,jj) * ( t_su(ji,jj,jl) - rt0 ) * a_i(ji,jj,jl) / MAX( at_i(ji,jj) , epsi06 )
-               END DO
-            END DO
-         END DO
-         CALL iom_put( "icest"       , z2d              )        ! ice surface temperature
-      ENDIF
-
-      IF ( iom_use( "icecolf" ) )   CALL iom_put( "icecolf", hicol )  ! frazil ice collection thickness
-
       CALL iom_put( "isst"        , sst_m               )        ! sea surface temperature
       CALL iom_put( "isss"        , sss_m               )        ! sea surface salinity
-      CALL iom_put( "iceconc"     , at_i                )        ! ice concentration
-      CALL iom_put( "icevolu"     , vt_i                )        ! ice volume = mean ice thickness over the cell
-      CALL iom_put( "icehc"       , et_i                )        ! ice total heat content
-      CALL iom_put( "isnowhc"     , et_s                )        ! snow total heat content
-      CALL iom_put( "ibrinv"      , bv_i * 100._wp      )        ! brine volume
+      CALL iom_put( "iceconc"     , at_i  * zswi        )        ! ice concentration
+      CALL iom_put( "icevolu"     , vt_i  * zswi        )        ! ice volume = mean ice thickness over the cell
+      CALL iom_put( "icehc"       , et_i  * zswi        )        ! ice total heat content
+      CALL iom_put( "isnowhc"     , et_s  * zswi        )        ! snow total heat content
+      CALL iom_put( "ibrinv"      , bvm_i * zswi * 100. )        ! brine volume
       CALL iom_put( "utau_ice"    , utau_ice            )        ! wind stress over ice along i-axis at I-point
       CALL iom_put( "vtau_ice"    , vtau_ice            )        ! wind stress over ice along j-axis at I-point
       CALL iom_put( "snowpre"     , sprecip * 86400.    )        ! snow precipitation 
-      CALL iom_put( "micesalt"    , smt_i               )        ! mean ice salinity
-
-      CALL iom_put( "icestr"      , strength * 0.001    )        ! ice strength
-      CALL iom_put( "idive"       , divu_i * 1.0e8      )        ! divergence
-      CALL iom_put( "ishear"      , shear_i * 1.0e8     )        ! shear
-      CALL iom_put( "snowvol"     , vt_s                )        ! snow volume
+      CALL iom_put( "micesalt"    , smt_i   * zswi      )        ! mean ice salinity
+
+      CALL iom_put( "icestr"      , strength * zswi )    ! ice strength
+      CALL iom_put( "idive"       , divu_i * 1.0e8      )    ! divergence
+      CALL iom_put( "ishear"      , shear_i * 1.0e8     )    ! shear
+      CALL iom_put( "snowvol"     , vt_s   * zswi       )        ! snow volume
       
       CALL iom_put( "icetrp"      , diag_trp_vi * rday  )        ! ice volume transport
@@ -183,10 +147,10 @@
 
       CALL iom_put( "sfxbog"      , sfx_bog * rday      )        ! salt flux from bottom growth
-      CALL iom_put( "sfxbom"      , sfx_bom * rday      )        ! salt flux from bottom melt
-      CALL iom_put( "sfxsum"      , sfx_sum * rday      )        ! salt flux from surface melt
+      CALL iom_put( "sfxbom"      , sfx_bom * rday      )        ! salt flux from bottom melting
+      CALL iom_put( "sfxsum"      , sfx_sum * rday      )        ! salt flux from surface melting
       CALL iom_put( "sfxsni"      , sfx_sni * rday      )        ! salt flux from snow ice formation
       CALL iom_put( "sfxopw"      , sfx_opw * rday      )        ! salt flux from open water formation
       CALL iom_put( "sfxdyn"      , sfx_dyn * rday      )        ! salt flux from ridging rafting
-      CALL iom_put( "sfxres"      , sfx_res * rday      )        ! salt flux from residual
+      CALL iom_put( "sfxres"      , sfx_res * rday      )        ! salt flux from limupdate (resultant)
       CALL iom_put( "sfxbri"      , sfx_bri * rday      )        ! salt flux from brines
       CALL iom_put( "sfxsub"      , sfx_sub * rday      )        ! salt flux from sublimation
@@ -202,8 +166,18 @@
       CALL iom_put( "vfxbom"     , wfx_bom * ztmp       )        ! bottom melt 
       CALL iom_put( "vfxice"     , wfx_ice * ztmp       )        ! total ice growth/melt 
+
+      IF ( iom_use( "vfxthin" ) ) THEN   ! ice production for open water + thin ice (<20cm) => comparable to observations  
+         WHERE( htm_i(:,:) < 0.2 .AND. htm_i(:,:) > 0. ) ; z2d = wfx_bog
+         ELSEWHERE                                       ; z2d = 0._wp
+         END WHERE
+         CALL iom_put( "vfxthin", ( wfx_opw + z2d ) * ztmp )
+      ENDIF
+
+      ztmp = rday / rhosn
+      CALL iom_put( "vfxspr"     , wfx_spr * ztmp       )        ! precip (snow)
       CALL iom_put( "vfxsnw"     , wfx_snw * ztmp       )        ! total snw growth/melt 
-      CALL iom_put( "vfxsub"     , wfx_sub * ztmp       )        ! sublimation (snow) 
-      CALL iom_put( "vfxspr"     , wfx_spr * ztmp       )        ! precip (snow)
-      
+      CALL iom_put( "vfxsub"     , wfx_sub * ztmp       )        ! sublimation (snow/ice) 
+      CALL iom_put( "vfxsub_err" , wfx_err_sub * ztmp   )        ! "excess" of sublimation sent to ocean      
+ 
       CALL iom_put( "afxtot"     , afx_tot * rday       )        ! concentration tendency (total)
       CALL iom_put( "afxdyn"     , afx_dyn * rday       )        ! concentration tendency (dynamics)
@@ -225,72 +199,24 @@
       CALL iom_put ('hfxdif'     , hfx_dif(:,:)         )   !  
       CALL iom_put ('hfxopw'     , hfx_opw(:,:)         )   !  
-      CALL iom_put ('hfxtur'     , fhtur(:,:) * SUM(a_i_b(:,:,:), dim=3) ) ! turbulent heat flux at ice base 
+      CALL iom_put ('hfxtur'     , fhtur(:,:) * SUM( a_i_b(:,:,:), dim=3 ) ) ! turbulent heat flux at ice base 
       CALL iom_put ('hfxdhc'     , diag_heat(:,:)       )   ! Heat content variation in snow and ice 
       CALL iom_put ('hfxspr'     , hfx_spr(:,:)         )   ! Heat content of snow precip 
 
-
-      IF ( iom_use( "vfxthin" ) ) THEN   ! ice production for open water + thin ice (<20cm) => comparable to observations  
-         DO jj = 1, jpj 
-            DO ji = 1, jpi
-               z2d(ji,jj)  = vt_i(ji,jj) / MAX( at_i(ji,jj), epsi06 ) * zswi(ji,jj) ! mean ice thickness
-            END DO
-         END DO
-         WHERE( z2d(:,:) < 0.2 .AND. z2d(:,:) > 0. ) ; z2da = wfx_bog
-         ELSEWHERE                                   ; z2da = 0._wp
-         END WHERE
-         CALL iom_put( "vfxthin", ( wfx_opw + z2da ) * ztmp )
-      ENDIF
       
       !--------------------------------
       ! Output values for each category
       !--------------------------------
-      CALL iom_put( "iceconc_cat"      , a_i         )        ! area for categories
-      CALL iom_put( "icethic_cat"      , ht_i        )        ! thickness for categories
-      CALL iom_put( "snowthic_cat"     , ht_s        )        ! snow depth for categories
-      CALL iom_put( "salinity_cat"     , sm_i        )        ! salinity for categories
-
+      IF ( iom_use( "iceconc_cat"  ) )  CALL iom_put( "iceconc_cat"      , a_i   * zswi2   )        ! area for categories
+      IF ( iom_use( "icethic_cat"  ) )  CALL iom_put( "icethic_cat"      , ht_i  * zswi2   )        ! thickness for categories
+      IF ( iom_use( "snowthic_cat" ) )  CALL iom_put( "snowthic_cat"     , ht_s  * zswi2   )        ! snow depth for categories
+      IF ( iom_use( "salinity_cat" ) )  CALL iom_put( "salinity_cat"     , sm_i  * zswi2   )        ! salinity for categories
       ! ice temperature
-      IF ( iom_use( "icetemp_cat" ) ) THEN 
-         zt_i(:,:,:) = SUM( t_i(:,:,:,:), dim=3 ) * r1_nlay_i
-         CALL iom_put( "icetemp_cat"   , zt_i - rt0  )
-      ENDIF
-      
+      IF ( iom_use( "icetemp_cat"  ) )  CALL iom_put( "icetemp_cat", ( SUM( t_i(:,:,:,:), dim=3 ) * r1_nlay_i - rt0 ) * zswi2 )
       ! snow temperature
-      IF ( iom_use( "snwtemp_cat" ) ) THEN 
-         zt_s(:,:,:) = SUM( t_s(:,:,:,:), dim=3 ) * r1_nlay_s
-         CALL iom_put( "snwtemp_cat"   , zt_s - rt0  )
-      ENDIF
-
-      ! Compute ice age
-      IF ( iom_use( "iceage_cat" ) ) THEN 
-         DO jl = 1, jpl 
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  rswitch = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - 0.1 ) )
-                  rswitch = rswitch * MAX( 0._wp , SIGN( 1._wp , a_i(ji,jj,jl) - 0.1 ) )
-                  zoi(ji,jj,jl) = oa_i(ji,jj,jl)  / MAX( a_i(ji,jj,jl) , 0.1 ) * rswitch
-               END DO
-            END DO
-         END DO
-         CALL iom_put( "iceage_cat"   , zoi * z1_365 )        ! ice age for categories
-      ENDIF
-
-      ! Compute brine volume
-      IF ( iom_use( "brinevol_cat" ) ) THEN 
-         zei(:,:,:) = 0._wp
-         DO jl = 1, jpl 
-            DO jk = 1, nlay_i
-               DO jj = 1, jpj
-                  DO ji = 1, jpi
-                     rswitch = MAX( 0._wp , SIGN( 1._wp , a_i(ji,jj,jl) - epsi06 ) )
-                     zei(ji,jj,jl) = zei(ji,jj,jl) + 100.0 *  &
-                        ( - tmut * s_i(ji,jj,jk,jl) / MIN( ( t_i(ji,jj,jk,jl) - rt0 ), - epsi06 ) ) * &
-                        rswitch * r1_nlay_i
-                  END DO
-               END DO
-            END DO
-         END DO
-         CALL iom_put( "brinevol_cat"     , zei      )        ! brine volume for categories
-      ENDIF
+      IF ( iom_use( "snwtemp_cat"  ) )  CALL iom_put( "snwtemp_cat", ( SUM( t_s(:,:,:,:), dim=3 ) * r1_nlay_s - rt0 ) * zswi2 )
+      ! ice age
+      IF ( iom_use( "iceage_cat"   ) )  CALL iom_put( "iceage_cat" , o_i * zswi2 * z1_365 )
+      ! brine volume
+      IF ( iom_use( "brinevol_cat" ) )  CALL iom_put( "brinevol_cat", bv_i * 100. * zswi2 )
 
       !     !  Create an output files (output.lim.abort.nc) if S < 0 or u > 20 m/s
@@ -298,11 +224,10 @@
       !     not yet implemented
       
-      CALL wrk_dealloc( jpi, jpj, jpl, zoi, zei, zt_i, zt_s )
-      CALL wrk_dealloc( jpi, jpj     , z2d, zswi, z2da, z2db )
+      CALL wrk_dealloc( jpi, jpj, jpl, zswi2 )
+      CALL wrk_dealloc( jpi, jpj     , z2d, zswi )
 
       IF( nn_timing == 1 )  CALL timing_stop('limwri')
       
    END SUBROUTINE lim_wri
-#endif
 
  
@@ -319,78 +244,100 @@
       !!   4.0  !  2013-06  (C. Rousset)
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt               ! ocean time-step index)
-      INTEGER, INTENT( in ) ::   kid , kh_i       
+      INTEGER, INTENT( in )   ::   kt               ! ocean time-step index)
+      INTEGER, INTENT( in )   ::   kid , kh_i
+      INTEGER                 ::   nz_i, jl
+      REAL(wp), DIMENSION(jpl) :: jcat
       !!----------------------------------------------------------------------
-
-      CALL histdef( kid, "iicethic", "Ice thickness"           , "m"      ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iiceconc", "Ice concentration"       , "%"      ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicetemp", "Ice temperature"         , "C"      ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicevelu", "i-Ice speed (I-point)"   , "m/s"    ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicevelv", "j-Ice speed (I-point)"   , "m/s"    ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "iicestru", "i-Wind stress over ice (I-pt)", "Pa",   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicestrv", "j-Wind stress over ice (I-pt)", "Pa",   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "iicesflx", "Solar flux over ocean"     , "w/m2" ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "iicenflx", "Non-solar flux over ocean" , "w/m2" ,   &
+      DO jl = 1, jpl
+         jcat(jl) = REAL(jl)
+      ENDDO
+      
+      CALL histvert( kid, "ncatice", "Ice Categories","", jpl, jcat, nz_i, "up")
+
+      CALL histdef( kid, "sithic", "Ice thickness"           , "m"      ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "siconc", "Ice concentration"       , "%"      ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "sitemp", "Ice temperature"         , "C"      ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "sivelu", "i-Ice speed "            , "m/s"    ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "sivelv", "j-Ice speed "            , "m/s"    ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "sistru", "i-Wind stress over ice " , "Pa"     ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "sistrv", "j-Wind stress over ice " , "Pa"     ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "sisflx", "Solar flux over ocean"     , "w/m2" ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "sinflx", "Non-solar flux over ocean" , "w/m2" ,   &
       &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
       CALL histdef( kid, "isnowpre", "Snow precipitation"      , "kg/m2/s",   &
       &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "iicesali", "Ice salinity"            , "PSU"    ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "iicevolu", "Ice volume"              , "m"      ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "iicedive", "Ice divergence"          , "10-8s-1",   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-      CALL histdef( kid, "iicebopr", "Ice bottom production"   , "m/s"    ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicedypr", "Ice dynamic production"  , "m/s"    ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicelapr", "Ice open water prod"     , "m/s"    ,   &
+      CALL histdef( kid, "sisali", "Ice salinity"            , "PSU"    ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "sivolu", "Ice volume"              , "m"      ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+      CALL histdef( kid, "sidive", "Ice divergence"          , "10-8s-1",   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
+
+      CALL histdef( kid, "vfxbog", "Ice bottom production"   , "m/s"    ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "vfxdyn", "Ice dynamic production"  , "m/s"    ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "vfxopw", "Ice open water prod"     , "m/s"    ,   &
       &       jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicesipr", "Snow ice production "    , "m/s"    ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicerepr", "Ice prod from limupdate" , "m/s"    ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicebome", "Ice bottom melt"         , "m/s"    ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iicesume", "Ice surface melt"        , "m/s"    ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iisfxdyn", "Salt flux from dynmics"  , ""       ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      CALL histdef( kid, "iisfxres", "Salt flux from limupdate", ""       ,   &
-      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "vfxsni", "Snow ice production "    , "m/s"    ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "vfxres", "Ice prod from limupdate" , "m/s"    ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "vfxbom", "Ice bottom melt"         , "m/s"    ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "vfxsum", "Ice surface melt"        , "m/s"    ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+
+      CALL histdef( kid, "sithicat", "Ice thickness"         , "m"      ,   &
+      &      jpi, jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "siconcat", "Ice concentration"     , "%"      ,   &
+      &      jpi, jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "sisalcat", "Ice salinity"           , ""      ,   &
+      &      jpi, jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "sitemcat", "Ice temperature"       , "C"      ,   &
+      &      jpi, jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "snthicat", "Snw thickness"         , "m"      ,   &
+      &      jpi, jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "sntemcat", "Snw temperature"       , "C"      ,   &
+      &      jpi, jpj, kh_i, jpl, 1, jpl, nz_i, 32, "inst(x)", rdt, rdt )
 
       CALL histend( kid, snc4set )   ! end of the file definition
 
-      CALL histwrite( kid, "iicethic", kt, icethi        , jpi*jpj, (/1/) )    
-      CALL histwrite( kid, "iiceconc", kt, at_i          , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicetemp", kt, tm_i - rt0    , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicevelu", kt, u_ice          , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicevelv", kt, v_ice          , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicestru", kt, utau_ice       , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicestrv", kt, vtau_ice       , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicesflx", kt, qsr , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicenflx", kt, qns , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sithic", kt, htm_i         , jpi*jpj, (/1/) )    
+      CALL histwrite( kid, "siconc", kt, at_i          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sitemp", kt, tm_i - rt0    , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sivelu", kt, u_ice          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sivelv", kt, v_ice          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sistru", kt, utau_ice       , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sistrv", kt, vtau_ice       , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sisflx", kt, qsr , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sinflx", kt, qns , jpi*jpj, (/1/) )
       CALL histwrite( kid, "isnowpre", kt, sprecip        , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicesali", kt, smt_i          , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicevolu", kt, vt_i           , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicedive", kt, divu_i*1.0e8   , jpi*jpj, (/1/) )
-
-      CALL histwrite( kid, "iicebopr", kt, wfx_bog        , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicedypr", kt, wfx_dyn        , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicelapr", kt, wfx_opw        , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicesipr", kt, wfx_sni        , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicerepr", kt, wfx_res        , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicebome", kt, wfx_bom        , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iicesume", kt, wfx_sum        , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iisfxdyn", kt, sfx_dyn        , jpi*jpj, (/1/) )
-      CALL histwrite( kid, "iisfxres", kt, sfx_res        , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sisali", kt, smt_i          , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sivolu", kt, vt_i           , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "sidive", kt, divu_i*1.0e8   , jpi*jpj, (/1/) )
+
+      CALL histwrite( kid, "vfxbog", kt, wfx_bog        , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "vfxdyn", kt, wfx_dyn        , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "vfxopw", kt, wfx_opw        , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "vfxsni", kt, wfx_sni        , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "vfxres", kt, wfx_res        , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "vfxbom", kt, wfx_bom        , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "vfxsum", kt, wfx_sum        , jpi*jpj, (/1/) )
+
+      CALL histwrite( kid, "sithicat", kt, ht_i        , jpi*jpj*jpl, (/1/) )    
+      CALL histwrite( kid, "siconcat", kt, a_i         , jpi*jpj*jpl, (/1/) )    
+      CALL histwrite( kid, "sisalcat", kt, sm_i        , jpi*jpj*jpl, (/1/) )    
+      CALL histwrite( kid, "sitemcat", kt, tm_i - rt0  , jpi*jpj*jpl, (/1/) )    
+      CALL histwrite( kid, "snthicat", kt, ht_s        , jpi*jpj*jpl, (/1/) )    
+      CALL histwrite( kid, "sntemcat", kt, tm_su - rt0 , jpi*jpj*jpl, (/1/) )    
 
       ! Close the file
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/NST_SRC/agrif_lim2_interp.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/NST_SRC/agrif_lim2_interp.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/NST_SRC/agrif_lim2_interp.F90	(revision 7483)
@@ -392,5 +392,4 @@
       INTEGER :: ji,jj,jn
       REAL(wp) :: zalpha
-      REAL(wp), DIMENSION(jpi,jpj,7) :: tabice_agr 
       !!-----------------------------------------------------------------------      
       !
@@ -529,4 +528,10 @@
             END DO
          END DO
+      ELSE
+         DO jj=MAX(j1,2),j2
+            DO ji=MAX(i1,2),i2
+               uice_agr(ji,jj) = tabres(ji,jj)
+            END DO
+         END DO
       ENDIF
 #else
@@ -541,4 +546,10 @@
             END DO
          END DO
+      ELSE
+         DO jj= j1, j2
+            DO ji= i1, i2
+               uice_agr(ji,jj) = tabres(ji,jj)
+            END DO
+         END DO
       ENDIF
 #endif
@@ -566,4 +577,10 @@
                   tabres(ji,jj) = e1f(ji-1,jj-1) * v_ice(ji,jj)
                ENDIF
+            END DO
+         END DO
+      ELSE
+         DO jj=MAX(j1,2),j2
+            DO ji=MAX(i1,2),i2
+               vice_agr(ji,jj) = tabres(ji,jj)
             END DO
          END DO
@@ -580,4 +597,10 @@
 	         END DO
 	      END DO
+      ELSE
+	      DO jj= j1 ,j2
+	         DO ji = i1, i2
+	            vice_agr(ji,jj) = tabres(ji,jj)
+	         END DO
+	      END DO
       ENDIF
 #endif
@@ -585,5 +608,5 @@
 
 
-   SUBROUTINE interp_adv_ice( tabres, i1, i2, j1, j2, before )
+   SUBROUTINE interp_adv_ice( tabres, i1, i2, j1, j2, k1, k2, before )
       !!-----------------------------------------------------------------------
       !!                    *** ROUTINE interp_adv_ice ***                           
@@ -593,6 +616,6 @@
       !!              put -9999 where no ice for correct extrapolation             
       !!-----------------------------------------------------------------------
-      INTEGER, INTENT(in) :: i1, i2, j1, j2
-      REAL(wp), DIMENSION(i1:i2,j1:j2,7), INTENT(inout) :: tabres
+      INTEGER, INTENT(in) :: i1, i2, j1, j2, k1, k2
+      REAL(wp), DIMENSION(i1:i2,j1:j2,k1:k2), INTENT(inout) :: tabres
       LOGICAL, INTENT(in) :: before
       !!
@@ -601,19 +624,27 @@
       !
       IF( before ) THEN
-	      DO jj=j1,j2
-	         DO ji=i1,i2
-	            IF( tms(ji,jj) == 0. ) THEN
-	               tabres(ji,jj,:) = -9999. 
-	            ELSE
-	               tabres(ji,jj, 1) = frld  (ji,jj)
-	               tabres(ji,jj, 2) = hicif (ji,jj)
-	               tabres(ji,jj, 3) = hsnif (ji,jj)
-	               tabres(ji,jj, 4) = tbif  (ji,jj,1)
-	               tabres(ji,jj, 5) = tbif  (ji,jj,2)
-	               tabres(ji,jj, 6) = tbif  (ji,jj,3)
-	               tabres(ji,jj, 7) = qstoif(ji,jj)
-	            ENDIF
-	         END DO
-	      END DO
+         DO jj=j1,j2
+	    DO ji=i1,i2
+	       IF( tms(ji,jj) == 0. ) THEN
+	          tabres(ji,jj,:) = -9999 
+	       ELSE
+	          tabres(ji,jj, 1) = frld  (ji,jj)
+	          tabres(ji,jj, 2) = hicif (ji,jj)
+	          tabres(ji,jj, 3) = hsnif (ji,jj)
+	          tabres(ji,jj, 4) = tbif  (ji,jj,1)
+	          tabres(ji,jj, 5) = tbif  (ji,jj,2)
+	          tabres(ji,jj, 6) = tbif  (ji,jj,3)
+	          tabres(ji,jj, 7) = qstoif(ji,jj)
+	       ENDIF
+	    END DO
+         END DO
+      ELSE
+	 DO jj=j1,j2
+	    DO ji=i1,i2
+               DO jk=k1, k2
+	          tabice_agr(ji,jj,jk) = tabres(ji,jj,jk)
+               END DO
+	    END DO
+	 END DO
       ENDIF
       !
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/C1D/step_c1d.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/C1D/step_c1d.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/C1D/step_c1d.F90	(revision 7483)
@@ -60,7 +60,7 @@
 
                              indic = 0                ! reset to no error condition
-      IF( kstp == nit000 )   CALL iom_init( "nemo")   ! iom_put initialization (must be done after nemo_init for AGRIF+XIOS+OASIS)
+      IF( kstp == nit000 )   CALL iom_init( cxios_context )   ! iom_put initialization (must be done after nemo_init for AGRIF+XIOS+OASIS)
       IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
-                             CALL iom_setkt( kstp - nit000 + 1, "nemo" )   ! say to iom that we are at time step kstp
+                             CALL iom_setkt( kstp - nit000 + 1, cxios_context )   ! say to iom that we are at time step kstp
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 7483)
@@ -211,21 +211,4 @@
       REAL(wp) ::   zztmp  
       REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   zsaldta   ! Jan/Dec levitus salinity
-      ! reading initial file
-      LOGICAL  ::   ln_tsd_init      !: T & S data flag
-      LOGICAL  ::   ln_tsd_tradmp    !: internal damping toward input data flag
-      CHARACTER(len=100)            ::   cn_dir
-      TYPE(FLD_N)                   ::  sn_tem,sn_sal
-      INTEGER  ::   ios=0
-
-      NAMELIST/namtsd/ ln_tsd_init,ln_tsd_tradmp,cn_dir,sn_tem,sn_sal
-      !
-
-      REWIND( numnam_ref )              ! Namelist namtsd in reference namelist :
-      READ  ( numnam_ref, namtsd, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , ' namtsd in reference namelist for dia_ar5', lwp )
-      REWIND( numnam_cfg )              ! Namelist namtsd in configuration namelist : Parameters of the run
-      READ  ( numnam_cfg, namtsd, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , ' namtsd in configuration namelist for dia_ar5', lwp )
-      IF(lwm) WRITE ( numond, namtsd )
       !
       !!----------------------------------------------------------------------
@@ -233,5 +216,5 @@
       IF( nn_timing == 1 )   CALL timing_start('dia_ar5_init')
       !
-      CALL wrk_alloc( jpi , jpj , jpk, jpts, zsaldta )
+      CALL wrk_alloc( jpi, jpj, jpk, 2, zsaldta )
       !                                      ! allocate dia_ar5 arrays
       IF( dia_ar5_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'dia_ar5_init : unable to allocate arrays' )
@@ -249,8 +232,9 @@
       IF( lk_mpp )   CALL mpp_sum( vol0 )
 
-      CALL iom_open ( TRIM( cn_dir )//TRIM(sn_sal%clname), inum )
-      CALL iom_get  ( inum, jpdom_data, TRIM(sn_sal%clvar), zsaldta(:,:,:,1), 1  )
-      CALL iom_get  ( inum, jpdom_data, TRIM(sn_sal%clvar), zsaldta(:,:,:,2), 12 )
+      CALL iom_open ( 'sali_ref_clim_monthly', inum )
+      CALL iom_get  ( inum, jpdom_data, 'vosaline' , zsaldta(:,:,:,1), 1  )
+      CALL iom_get  ( inum, jpdom_data, 'vosaline' , zsaldta(:,:,:,2), 12 )
       CALL iom_close( inum )
+
       sn0(:,:,:) = 0.5_wp * ( zsaldta(:,:,:,1) + zsaldta(:,:,:,2) )        
       sn0(:,:,:) = sn0(:,:,:) * tmask(:,:,:)
@@ -267,5 +251,5 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi , jpj , jpk, jpts, zsaldta )
+      CALL wrk_dealloc( jpi, jpj, jpk, 2, zsaldta )
       !
       IF( nn_timing == 1 )   CALL timing_stop('dia_ar5_init')
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DIA/diahsb.F90	(revision 7483)
@@ -38,5 +38,4 @@
    PUBLIC   dia_hsb        ! routine called by step.F90
    PUBLIC   dia_hsb_init   ! routine called by nemogcm.F90
-   PUBLIC   dia_hsb_rst    ! routine called by step.F90
 
    LOGICAL, PUBLIC ::   ln_diahsb   !: check the heat and salt budgets
@@ -86,4 +85,5 @@
       !!---------------------------------------------------------------------------
       IF( nn_timing == 1 )   CALL timing_start('dia_hsb')      
+      !
       CALL wrk_alloc( jpi,jpj,   z2d0, z2d1 )
       !
@@ -174,5 +174,7 @@
       ENDDO
 
-      ! Substract forcing from heat content, salt content and volume variations
+      ! ------------------------ !
+      ! 3 -  Drifts              !
+      ! ------------------------ !
       zdiff_v1 = zdiff_v1 - frc_v
       IF( lk_vvl )   zdiff_v2 = zdiff_v2 - frc_v
@@ -187,5 +189,5 @@
 
       ! ----------------------- !
-      ! 3 - Diagnostics writing !
+      ! 4 - Diagnostics writing !
       ! ----------------------- !
       zvol_tot = 0._wp                    ! total ocean volume (calculated with scale factors)
@@ -200,23 +202,27 @@
 !!gm end
 
+      CALL iom_put(   'bgfrcvol' , frc_v    * 1.e-9    )              ! vol - surface forcing (km3) 
+      CALL iom_put(   'bgfrctem' , frc_t    * rau0 * rcp * 1.e-20 )   ! hc  - surface forcing (1.e20 J) 
+      CALL iom_put(   'bgfrchfx' , frc_t    * rau0 * rcp /  &         ! hc  - surface forcing (W/m2) 
+         &                       ( surf_tot * kt * rdt )        )
+      CALL iom_put(   'bgfrcsal' , frc_s    * 1.e-9    )              ! sc  - surface forcing (psu*km3) 
+
       IF( lk_vvl ) THEN
-        CALL iom_put( 'bgtemper' , zdiff_hc / zvol_tot )              ! Temperature variation (C) 
-        CALL iom_put( 'bgsaline' , zdiff_sc / zvol_tot )              ! Salinity    variation (psu)
-        CALL iom_put( 'bgheatco' , zdiff_hc * 1.e-20 * rau0 * rcp )   ! Heat content variation (1.e20 J) 
-        CALL iom_put( 'bgsaltco' , zdiff_sc * 1.e-9    )              ! Salt content variation (psu*km3)
-        CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9    )              ! volume ssh variation (km3)  
-        CALL iom_put( 'bgvole3t' , zdiff_v2 * 1.e-9    )              ! volume e3t variation (km3)  
-        CALL iom_put( 'bgfrcvol' , frc_v    * 1.e-9    )              ! vol - surface forcing (km3) 
-        CALL iom_put( 'bgfrctem' , frc_t / zvol_tot    )              ! hc  - surface forcing (C) 
-        CALL iom_put( 'bgfrcsal' , frc_s / zvol_tot    )              ! sc  - surface forcing (psu) 
+        CALL iom_put( 'bgtemper' , zdiff_hc / zvol_tot )              ! Temperature drift     (C) 
+        CALL iom_put( 'bgsaline' , zdiff_sc / zvol_tot )              ! Salinity    drift     (pss)
+        CALL iom_put( 'bgheatco' , zdiff_hc * 1.e-20 * rau0 * rcp )   ! Heat content drift    (1.e20 J) 
+        CALL iom_put( 'bgheatfx' , zdiff_hc * rau0 * rcp /  &         ! Heat flux drift       (W/m2) 
+           &                       ( surf_tot * kt * rdt )        )
+        CALL iom_put( 'bgsaltco' , zdiff_sc * 1.e-9    )              ! Salt content drift    (psu*km3)
+        CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9    )              ! volume ssh drift      (km3)  
+        CALL iom_put( 'bgvole3t' , zdiff_v2 * 1.e-9    )              ! volume e3t drift      (km3)  
       ELSE
-        CALL iom_put( 'bgtemper' , zdiff_hc1 / zvol_tot)              ! Heat content variation (C) 
-        CALL iom_put( 'bgsaline' , zdiff_sc1 / zvol_tot)              ! Salt content variation (psu)
-        CALL iom_put( 'bgheatco' , zdiff_hc1 * 1.e-20 * rau0 * rcp )  ! Heat content variation (1.e20 J) 
-        CALL iom_put( 'bgsaltco' , zdiff_sc1 * 1.e-9    )             ! Salt content variation (psu*km3)
-        CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9    )              ! volume ssh variation (km3)  
-        CALL iom_put( 'bgfrcvol' , frc_v    * 1.e-9    )              ! vol - surface forcing (km3) 
-        CALL iom_put( 'bgfrctem' , frc_t / zvol_tot    )              ! hc  - surface forcing (C) 
-        CALL iom_put( 'bgfrcsal' , frc_s / zvol_tot    )              ! sc  - surface forcing (psu) 
+        CALL iom_put( 'bgtemper' , zdiff_hc1 / zvol_tot)              ! Heat content drift    (C) 
+        CALL iom_put( 'bgsaline' , zdiff_sc1 / zvol_tot)              ! Salt content drift    (pss)
+        CALL iom_put( 'bgheatco' , zdiff_hc1 * 1.e-20 * rau0 * rcp )  ! Heat content drift    (1.e20 J) 
+        CALL iom_put( 'bgheatfx' , zdiff_hc1 * rau0 * rcp /  &        ! Heat flux drift       (W/m2) 
+           &                       ( surf_tot * kt * rdt )         )
+        CALL iom_put( 'bgsaltco' , zdiff_sc1 * 1.e-9    )             ! Salt content drift    (psu*km3)
+        CALL iom_put( 'bgvolssh' , zdiff_v1 * 1.e-9    )              ! volume ssh drift      (km3)  
         CALL iom_put( 'bgmistem' , zerr_hc1 / zvol_tot )              ! hc  - error due to free surface (C)
         CALL iom_put( 'bgmissal' , zerr_sc1 / zvol_tot )              ! sc  - error due to free surface (psu)
@@ -244,10 +250,8 @@
      !
      INTEGER ::   ji, jj, jk   ! dummy loop indices
-     INTEGER ::   id1          ! local integers
      !!----------------------------------------------------------------------
      !
      IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise 
         IF( ln_rstart ) THEN                   !* Read the restart file
-           !id1 = iom_varid( numror, 'frc_vol'  , ldstop = .FALSE. )
            !
            IF(lwp) WRITE(numout,*) '~~~~~~~'
@@ -261,11 +265,11 @@
               CALL iom_get( numror, 'frc_wn_s', frc_wn_s )
            ENDIF
-           CALL iom_get( numror, jpdom_autoglo, 'ssh_ini', ssh_ini )
-           CALL iom_get( numror, jpdom_autoglo, 'e3t_ini', e3t_ini )
-           CALL iom_get( numror, jpdom_autoglo, 'hc_loc_ini', hc_loc_ini )
-           CALL iom_get( numror, jpdom_autoglo, 'sc_loc_ini', sc_loc_ini )
+           CALL iom_get( numror, jpdom_autoglo, 'ssh_ini', ssh_ini(:,:) )
+           CALL iom_get( numror, jpdom_autoglo, 'e3t_ini', e3t_ini(:,:,:) )
+           CALL iom_get( numror, jpdom_autoglo, 'hc_loc_ini', hc_loc_ini(:,:,:) )
+           CALL iom_get( numror, jpdom_autoglo, 'sc_loc_ini', sc_loc_ini(:,:,:) )
            IF( .NOT. lk_vvl ) THEN
-              CALL iom_get( numror, jpdom_autoglo, 'ssh_hc_loc_ini', ssh_hc_loc_ini )
-              CALL iom_get( numror, jpdom_autoglo, 'ssh_sc_loc_ini', ssh_sc_loc_ini )
+              CALL iom_get( numror, jpdom_autoglo, 'ssh_hc_loc_ini', ssh_hc_loc_ini(:,:) )
+              CALL iom_get( numror, jpdom_autoglo, 'ssh_sc_loc_ini', ssh_sc_loc_ini(:,:) )
            ENDIF
        ELSE
@@ -312,12 +316,13 @@
            CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_s', frc_wn_s )
         ENDIF
-        CALL iom_rstput( kt, nitrst, numrow, 'ssh_ini', ssh_ini )
-        CALL iom_rstput( kt, nitrst, numrow, 'e3t_ini', e3t_ini )
-        CALL iom_rstput( kt, nitrst, numrow, 'hc_loc_ini', hc_loc_ini )
-        CALL iom_rstput( kt, nitrst, numrow, 'sc_loc_ini', sc_loc_ini )
+        CALL iom_rstput( kt, nitrst, numrow, 'ssh_ini', ssh_ini(:,:) )
+        CALL iom_rstput( kt, nitrst, numrow, 'e3t_ini', e3t_ini(:,:,:) )
+        CALL iom_rstput( kt, nitrst, numrow, 'hc_loc_ini', hc_loc_ini(:,:,:) )
+        CALL iom_rstput( kt, nitrst, numrow, 'sc_loc_ini', sc_loc_ini(:,:,:) )
         IF( .NOT. lk_vvl ) THEN
-           CALL iom_rstput( kt, nitrst, numrow, 'ssh_hc_loc_ini', ssh_hc_loc_ini )
-           CALL iom_rstput( kt, nitrst, numrow, 'ssh_sc_loc_ini', ssh_sc_loc_ini )
+           CALL iom_rstput( kt, nitrst, numrow, 'ssh_hc_loc_ini', ssh_hc_loc_ini(:,:) )
+           CALL iom_rstput( kt, nitrst, numrow, 'ssh_sc_loc_ini', ssh_sc_loc_ini(:,:) )
         ENDIF
+
         !
      ENDIF
@@ -338,5 +343,4 @@
       !!             - Compute coefficients for conversion
       !!---------------------------------------------------------------------------
-      INTEGER ::   jk       ! dummy loop indice
       INTEGER ::   ierror   ! local integer
       INTEGER ::   ios
@@ -344,10 +348,4 @@
       NAMELIST/namhsb/ ln_diahsb
       !!----------------------------------------------------------------------
-
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'dia_hsb_init : check the heat and salt budgets'
-         WRITE(numout,*) '~~~~~~~~ '
-      ENDIF
 
       REWIND( numnam_ref )              ! Namelist namhsb in reference namelist
@@ -360,14 +358,11 @@
       IF(lwm) WRITE ( numond, namhsb )
 
-      !
-      IF(lwp) THEN                   ! Control print
+      IF(lwp) THEN
          WRITE(numout,*)
-         WRITE(numout,*) 'dia_hsb_init : check the heat and salt budgets'
-         WRITE(numout,*) '~~~~~~~~~~~~'
-         WRITE(numout,*) '   Namelist namhsb : set hsb parameters'
-         WRITE(numout,*) '      Switch for hsb diagnostic (T) or not (F)  ln_diahsb  = ', ln_diahsb
-         WRITE(numout,*)
-      ENDIF
-
+         WRITE(numout,*) 'dia_hsb_init'
+         WRITE(numout,*) '~~~~~~~~ '
+         WRITE(numout,*) '  check the heat and salt budgets (T) or not (F)       ln_diahsb = ', ln_diahsb
+      ENDIF
+      !
       IF( .NOT. ln_diahsb )   RETURN
          !      IF( .NOT. lk_mpp_rep ) &
@@ -382,10 +377,14 @@
          &      e3t_ini(jpi,jpj,jpk), surf(jpi,jpj),  ssh_ini(jpi,jpj), STAT=ierror )
       IF( ierror > 0 ) THEN
-         CALL ctl_stop( 'dia_hsb: unable to allocate hc_loc_ini' )   ;   RETURN
-      ENDIF
-
-      IF(.NOT. lk_vvl ) ALLOCATE( ssh_hc_loc_ini(jpi,jpj), ssh_sc_loc_ini(jpi,jpj),STAT=ierror )
-      IF( ierror > 0 ) THEN
-         CALL ctl_stop( 'dia_hsb: unable to allocate hc_loc_ini' )   ;   RETURN
+         CALL ctl_stop( 'dia_hsb: unable to allocate hc_loc_ini' )
+         RETURN
+      ENDIF
+
+      IF( .NOT. lk_vvl ) THEN
+         ALLOCATE( ssh_hc_loc_ini(jpi,jpj), ssh_sc_loc_ini(jpi,jpj), STAT=ierror )
+         IF( ierror > 0 )   THEN
+            CALL ctl_stop( 'dia_hsb: unable to allocate hc_loc_ini' )
+            RETURN
+         ENDIF
       ENDIF
 
@@ -393,8 +392,6 @@
       ! 2 - Time independant variables and file opening !
       ! ----------------------------------------------- !
-      IF(lwp) WRITE(numout,*) "dia_hsb: heat salt volume budgets activated"
-      IF(lwp) WRITE(numout,*) '~~~~~~~'
       surf(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:)      ! masked surface grid cell area
-      surf_tot  = glob_sum( surf(:,:) )                                       ! total ocean surface area
+      surf_tot  = glob_sum( surf(:,:) )                   ! total ocean surface area
 
       IF( lk_bdy ) CALL ctl_warn( 'dia_hsb does not take open boundary fluxes into account' )         
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90	(revision 7483)
@@ -158,13 +158,26 @@
          CASE ( 025 )                                ! ORCA_R025 configuration
             !                                        ! =======================
+            isrow = 1207 - jpjglo                    !  eORCA025 R025 - Using full isf­extended  
+                                                     !  domain for reference. - Adjust j­indices
             ncsnr(1)   = 1    ; ncstt(1)   = 0               ! Caspian + Aral sea
-            ncsi1(1)   = 1330 ; ncsj1(1)   = 645
-            ncsi2(1)   = 1400 ; ncsj2(1)   = 795
+            ncsi1(1)   = 1330 ; ncsj1(1)   = 831 - isrow
+            ncsi2(1)   = 1400 ; ncsj2(1)   = 981 - isrow
             ncsir(1,1) = 1    ; ncsjr(1,1) = 1
             !                                        
             ncsnr(2)   = 1    ; ncstt(2)   = 0               ! Azov Sea 
-            ncsi1(2)   = 1284 ; ncsj1(2)   = 722
-            ncsi2(2)   = 1304 ; ncsj2(2)   = 747
+            ncsi1(2)   = 1284 ; ncsj1(2)   = 908 - isrow
+            ncsi2(2)   = 1304 ; ncsj2(2)   = 933 - isrow
             ncsir(2,1) = 1    ; ncsjr(2,1) = 1
+            !
+            ncsnr(3)   = 1    ; ncstt(3)   = 0               ! Great Lakes
+            ncsi1(3)   = 775  ; ncsj1(3)   = 866 - isrow
+            ncsi2(3)   = 848  ; ncsj2(3)   = 931 - isrow
+            ncsir(3,1) = 1    ; ncsjr(3,1) = 1
+            !   
+            ncsnr(4)   = 1    ; ncstt(4)   = 0               ! Lake Victoria
+            ncsi1(4)   = 1270 ; ncsj1(4)   = 661 - isrow
+            ncsi2(4)   = 1295 ; ncsj2(4)   = 696 - isrow
+            ncsir(4,1) = 1    ; ncsjr(4,1) = 1
+            !        
             !
          END SELECT
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 7483)
@@ -601,8 +601,10 @@
             DO jk = 1, jpk
                DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
+                  DO ji = 1, fs_jpim1
                      ze3  = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
                         &   + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) )
-                     IF( ze3 /= 0._wp )   ze3f(ji,jj,jk) = 4.0_wp / ze3
+                     IF   ( ze3 /= 0._wp ) THEN ;   ze3f(ji,jj,jk) = 4.0_wp / ze3
+                     ELSE                       ;   ze3f(ji,jj,jk) = 0.0_wp
+                     ENDIF
                   END DO
                END DO
@@ -611,10 +613,12 @@
             DO jk = 1, jpk
                DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
+                  DO ji = 1, fs_jpim1
                      ze3  = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
                         &   + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) )
                      zmsk = (                   tmask(ji,jj+1,jk) +                     tmask(ji+1,jj+1,jk)   &
                         &                     + tmask(ji,jj  ,jk) +                     tmask(ji+1,jj  ,jk) )
-                     IF( ze3 /= 0._wp )   ze3f(ji,jj,jk) = zmsk / ze3
+                     IF   ( ze3 /= 0._wp ) THEN ;   ze3f(ji,jj,jk) = zmsk / ze3
+                     ELSE                       ;   ze3f(ji,jj,jk) = 0.0_wp
+                     ENDIF
                   END DO
                END DO
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 7483)
@@ -323,9 +323,9 @@
             ze3va =  ( 1._wp - r_vvl ) * fse3v_n(ji,jj,1) + r_vvl   * fse3v_a(ji,jj,1) 
             va(ji,jj,1) = va(ji,jj,1) + p2dt * 0.5_wp * ( vtau_b(ji,jj) + vtau(ji,jj) )   &
-               &                                      / ( ze3va * rau0 ) 
+               &                                      / ( ze3va * rau0 ) * vmask(ji,jj,1)
 #else
             va(ji,jj,1) = vb(ji,jj,1) &
                &                   + p2dt *(va(ji,jj,1) +  0.5_wp * ( vtau_b(ji,jj) + vtau(ji,jj) )   &
-               &                                                       / ( fse3v(ji,jj,1) * rau0     )  )
+               &                                      / ( fse3v(ji,jj,1) * rau0     ) * vmask(ji,jj,1) )
 #endif
          END DO
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/ICB/icbini.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/ICB/icbini.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/ICB/icbini.F90	(revision 7483)
@@ -120,5 +120,5 @@
       ! first entry with narea for this processor is left hand interior index
       ! last  entry                               is right hand interior index
-      jj = jpj/2
+      jj = nlcj/2
       nicbdi = -1
       nicbei = -1
@@ -136,5 +136,5 @@
       !
       ! repeat for j direction
-      ji = jpi/2
+      ji = nlci/2
       nicbdj = -1
       nicbej = -1
@@ -153,9 +153,9 @@
       ! special for east-west boundary exchange we save the destination index
       i1 = MAX( nicbdi-1, 1)
-      i3 = INT( src_calving(i1,jpj/2) )
+      i3 = INT( src_calving(i1,nlcj/2) )
       jj = INT( i3/nicbpack )
       ricb_left = REAL( i3 - nicbpack*jj, wp )
       i1 = MIN( nicbei+1, jpi )
-      i3 = INT( src_calving(i1,jpj/2) )
+      i3 = INT( src_calving(i1,nlcj/2) )
       jj = INT( i3/nicbpack )
       ricb_right = REAL( i3 - nicbpack*jj, wp )
@@ -196,5 +196,5 @@
          WRITE(numicb,*) 'berg left       ', ricb_left
          WRITE(numicb,*) 'berg right      ', ricb_right
-         jj = jpj/2
+         jj = nlcj/2
          WRITE(numicb,*) "central j line:"
          WRITE(numicb,*) "i processor"
@@ -202,5 +202,5 @@
          WRITE(numicb,*) "i point"
          WRITE(numicb,*) (INT(src_calving(ji,jj)), ji=1,jpi)
-         ji = jpi/2
+         ji = nlci/2
          WRITE(numicb,*) "central i line:"
          WRITE(numicb,*) "j processor"
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/LBC/lbcnfd.F90	(revision 7483)
@@ -804,5 +804,5 @@
             ELSE
                startloop = 3
-               pt2dl(2,ijpj) = psgn * pt2dr(3,ijpjm1)
+               pt2dl(2,ijpj) = psgn * pt2dl(3,ijpjm1)
             ENDIF
             DO ji = startloop, nlci
@@ -816,5 +816,5 @@
             ELSE
                startloop = 3
-               pt2dl(2,ijpj) = psgn * pt2dr(3,ijpjm1)
+               pt2dl(2,ijpj) = psgn * pt2dl(3,ijpjm1)
             ENDIF
             DO ji = startloop, nlci
@@ -910,5 +910,5 @@
                DO ji = startloop , endloop
                   ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
-                  pt2dl(ji,ijpj)= 0.5 * (pt2dr(ji,ijpjm1) + psgn * pt2dr(ijt,ijpjm1))
+                  pt2dl(ji,ijpj)= 0.5 * (pt2dl(ji,ijpjm1) + psgn * pt2dr(ijt,ijpjm1))
                END DO
 
@@ -926,5 +926,5 @@
                DO ji = startloop , endloop
                   ijt = jpiglo - ji - nimpp - nfiimpp(isendto(1),jpnj) + 4
-                  pt2dl(ji,ijpj) = pt2dr(ji,ijpjm1)
+                  pt2dl(ji,ijpj) = pt2dl(ji,ijpjm1)
                END DO
 
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 7483)
@@ -2654,5 +2654,6 @@
       !!----------------------------------------------------------------------
       !
-      ALLOCATE( ztab(jpiglo,4,num_fields), znorthloc(jpi,4,num_fields), zfoldwk(jpi,4,num_fields), znorthgloio(jpi,4,num_fields,jpni) )   ! expanded to 3 dimensions
+      ALLOCATE( ztab(jpiglo,4,num_fields), znorthloc(jpi,4,num_fields), zfoldwk(jpi,4,num_fields),   & 
+            &   znorthgloio(jpi,4,num_fields,jpni) )   ! expanded to 3 dimensions
       ALLOCATE( ztabl(jpi,4,num_fields), ztabr(jpi*jpmaxngh, 4,num_fields) )
       !
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv.F90	(revision 7483)
@@ -157,4 +157,14 @@
          END DO
       ENDIF
+
+      ! ORCA R1: Take the minimum between aeiw  and aeiv0
+      IF( cp_cfg == "orca" .AND. jp_cfg == 1 ) THEN
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               aeiw(ji,jj) = MIN( aeiw(ji,jj), aeiv0 )
+            END DO
+         END DO
+      ENDIF
+
       CALL lbc_lnk( aeiw, 'W', 1. )      ! lateral boundary condition on aeiw 
 
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_core.F90	(revision 7483)
@@ -206,5 +206,7 @@
       IF( MOD( kt - 1, nn_fsbc ) == 0 )   THEN
          qlw_ice(:,:,1)   = sf(jp_qlw)%fnow(:,:,1) 
-         qsr_ice(:,:,1)   = sf(jp_qsr)%fnow(:,:,1)
+         IF( ln_dm2dc ) THEN ; qsr_ice(:,:,1) = sbc_dcy( sf(jp_qsr)%fnow(:,:,1) )
+         ELSE                ; qsr_ice(:,:,1) =          sf(jp_qsr)%fnow(:,:,1)
+         ENDIF
          tatm_ice(:,:)    = sf(jp_tair)%fnow(:,:,1)         
          qatm_ice(:,:)    = sf(jp_humi)%fnow(:,:,1)
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 7483)
@@ -1335,39 +1335,48 @@
       !!             ***  ROUTINE sbc_cpl_ice_flx  ***
       !!
-      !! ** Purpose :   provide the heat and freshwater fluxes of the 
-      !!              ocean-ice system.
+      !! ** Purpose :   provide the heat and freshwater fluxes of the ocean-ice system
       !!
       !! ** Method  :   transform the fields received from the atmosphere into
       !!             surface heat and fresh water boundary condition for the 
       !!             ice-ocean system. The following fields are provided:
-      !!              * total non solar, solar and freshwater fluxes (qns_tot, 
+      !!               * total non solar, solar and freshwater fluxes (qns_tot, 
       !!             qsr_tot and emp_tot) (total means weighted ice-ocean flux)
       !!             NB: emp_tot include runoffs and calving.
-      !!              * fluxes over ice (qns_ice, qsr_ice, emp_ice) where
+      !!               * fluxes over ice (qns_ice, qsr_ice, emp_ice) where
       !!             emp_ice = sublimation - solid precipitation as liquid
       !!             precipitation are re-routed directly to the ocean and 
-      !!             runoffs and calving directly enter the ocean.
-      !!              * solid precipitation (sprecip), used to add to qns_tot 
+      !!             calving directly enter the ocean (runoffs are read but included in trasbc.F90)
+      !!               * solid precipitation (sprecip), used to add to qns_tot 
       !!             the heat lost associated to melting solid precipitation
       !!             over the ocean fraction.
-      !!       ===>> CAUTION here this changes the net heat flux received from
-      !!             the atmosphere
-      !!
-      !!                  - the fluxes have been separated from the stress as
-      !!                 (a) they are updated at each ice time step compare to
-      !!                 an update at each coupled time step for the stress, and
-      !!                 (b) the conservative computation of the fluxes over the
-      !!                 sea-ice area requires the knowledge of the ice fraction
-      !!                 after the ice advection and before the ice thermodynamics,
-      !!                 so that the stress is updated before the ice dynamics
-      !!                 while the fluxes are updated after it.
+      !!               * heat content of rain, snow and evap can also be provided,
+      !!             otherwise heat flux associated with these mass flux are
+      !!             guessed (qemp_oce, qemp_ice)
+      !!
+      !!             - the fluxes have been separated from the stress as
+      !!               (a) they are updated at each ice time step compare to
+      !!               an update at each coupled time step for the stress, and
+      !!               (b) the conservative computation of the fluxes over the
+      !!               sea-ice area requires the knowledge of the ice fraction
+      !!               after the ice advection and before the ice thermodynamics,
+      !!               so that the stress is updated before the ice dynamics
+      !!               while the fluxes are updated after it.
+      !!
+      !! ** Details
+      !!             qns_tot = pfrld * qns_oce + ( 1 - pfrld ) * qns_ice   => provided
+      !!                     + qemp_oce + qemp_ice                         => recalculated and added up to qns
+      !!
+      !!             qsr_tot = pfrld * qsr_oce + ( 1 - pfrld ) * qsr_ice   => provided
+      !!
+      !!             emp_tot = emp_oce + emp_ice                           => calving is provided and added to emp_tot (and emp_oce)
+      !!                                                                      river runoff (rnf) is provided but not included here
       !!
       !! ** Action  :   update at each nf_ice time step:
       !!                   qns_tot, qsr_tot  non-solar and solar total heat fluxes
       !!                   qns_ice, qsr_ice  non-solar and solar heat fluxes over the ice
-      !!                   emp_tot            total evaporation - precipitation(liquid and solid) (-runoff)(-calving)
-      !!                   emp_ice            ice sublimation - solid precipitation over the ice
-      !!                   dqns_ice           d(non-solar heat flux)/d(Temperature) over the ice
-      !!                   sprecip             solid precipitation over the ocean  
+      !!                   emp_tot           total evaporation - precipitation(liquid and solid) (-calving)
+      !!                   emp_ice           ice sublimation - solid precipitation over the ice
+      !!                   dqns_ice          d(non-solar heat flux)/d(Temperature) over the ice
+      !!                   sprecip           solid precipitation over the ocean  
       !!----------------------------------------------------------------------
       REAL(wp), INTENT(in   ), DIMENSION(:,:)   ::   p_frld     ! lead fraction                [0 to 1]
@@ -1379,5 +1388,5 @@
       INTEGER ::   jl         ! dummy loop index
       REAL(wp), POINTER, DIMENSION(:,:  ) ::   zcptn, ztmp, zicefr, zmsk, zsnw
-      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap, zevap_ice, zdevap_ice
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice
       REAL(wp), POINTER, DIMENSION(:,:  ) ::   zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice
       REAL(wp), POINTER, DIMENSION(:,:,:) ::   zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice
@@ -1387,5 +1396,5 @@
       !
       CALL wrk_alloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zsnw )
-      CALL wrk_alloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap, zevap_ice, zdevap_ice )
+      CALL wrk_alloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice )
       CALL wrk_alloc( jpi,jpj,     zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice )
       CALL wrk_alloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice )
@@ -1396,29 +1405,30 @@
       !
       !                                                      ! ========================= !
-      !                                                      !    freshwater budget      !   (emp)
+      !                                                      !    freshwater budget      !   (emp_tot)
       !                                                      ! ========================= !
       !
-      !                                                           ! total Precipitation - total Evaporation (emp_tot)
-      !                                                           ! solid precipitation - sublimation       (emp_ice)
-      !                                                           ! solid Precipitation                     (sprecip)
-      !                                                           ! liquid + solid Precipitation            (tprecip)
+      !                                                           ! solid Precipitation                                (sprecip)
+      !                                                           ! liquid + solid Precipitation                       (tprecip)
+      !                                                           ! total Evaporation - total Precipitation            (emp_tot)
+      !                                                           ! sublimation - solid precipitation (cell average)   (emp_ice)
       SELECT CASE( TRIM( sn_rcv_emp%cldes ) )
-      CASE( 'conservative'  )   ! received fields: jpr_rain, jpr_snow, jpr_ievp, jpr_tevp
-         zsprecip(:,:) = frcv(jpr_snow)%z3(:,:,1)                  ! May need to ensure positive here
-         ztprecip(:,:) = frcv(jpr_rain)%z3(:,:,1) + zsprecip(:,:)  ! May need to ensure positive here
-         zemp_tot(:,:) = frcv(jpr_tevp)%z3(:,:,1) - ztprecip(:,:)
-         zemp_ice(:,:) = frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_snow)%z3(:,:,1)
-            CALL iom_put( 'rain'         , frcv(jpr_rain)%z3(:,:,1)              )   ! liquid precipitation 
+      CASE( 'conservative' )   ! received fields: jpr_rain, jpr_snow, jpr_ievp, jpr_tevp
+         zsprecip(:,:) =   frcv(jpr_snow)%z3(:,:,1)                  ! May need to ensure positive here
+         ztprecip(:,:) =   frcv(jpr_rain)%z3(:,:,1) + zsprecip(:,:)  ! May need to ensure positive here
+         zemp_tot(:,:) =   frcv(jpr_tevp)%z3(:,:,1) - ztprecip(:,:)
+         zemp_ice(:,:) = ( frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_snow)%z3(:,:,1) ) * zicefr(:,:)
+         IF( iom_use('precip') )          &
+            &  CALL iom_put( 'precip'       ,   frcv(jpr_rain)%z3(:,:,1) + frcv(jpr_snow)%z3(:,:,1)                              )  ! total  precipitation
+         IF( iom_use('rain') )            &
+            &  CALL iom_put( 'rain'         ,   frcv(jpr_rain)%z3(:,:,1)                                                         )  ! liquid precipitation 
          IF( iom_use('hflx_rain_cea') )   &
-            CALL iom_put( 'hflx_rain_cea', frcv(jpr_rain)%z3(:,:,1) * zcptn(:,:) )   ! heat flux from liq. precip. 
-         IF( iom_use('evap_ao_cea') .OR. iom_use('hflx_evap_cea') )   &
-            ztmp(:,:) = frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:)
+            &  CALL iom_put( 'hflx_rain_cea',   frcv(jpr_rain)%z3(:,:,1) * zcptn(:,:)                                            )  ! heat flux from liq. precip. 
          IF( iom_use('evap_ao_cea'  ) )   &
-            CALL iom_put( 'evap_ao_cea'  , ztmp                   )   ! ice-free oce evap (cell average)
+            &  CALL iom_put( 'evap_ao_cea'  ,   frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:)                )  ! ice-free oce evap (cell average)
          IF( iom_use('hflx_evap_cea') )   &
-            CALL iom_put( 'hflx_evap_cea', ztmp(:,:) * zcptn(:,:) )   ! heat flux from from evap (cell average)
-      CASE( 'oce and ice'   )   ! received fields: jpr_sbpr, jpr_semp, jpr_oemp, jpr_ievp
+            &  CALL iom_put( 'hflx_evap_cea', ( frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) ) * zcptn(:,:) )  ! heat flux from from evap (cell average)
+      CASE( 'oce and ice' )   ! received fields: jpr_sbpr, jpr_semp, jpr_oemp, jpr_ievp
          zemp_tot(:,:) = p_frld(:,:) * frcv(jpr_oemp)%z3(:,:,1) + zicefr(:,:) * frcv(jpr_sbpr)%z3(:,:,1)
-         zemp_ice(:,:) = frcv(jpr_semp)%z3(:,:,1)
+         zemp_ice(:,:) = frcv(jpr_semp)%z3(:,:,1) * zicefr(:,:)
          zsprecip(:,:) = frcv(jpr_ievp)%z3(:,:,1) - frcv(jpr_semp)%z3(:,:,1)
          ztprecip(:,:) = frcv(jpr_semp)%z3(:,:,1) - frcv(jpr_sbpr)%z3(:,:,1) + zsprecip(:,:)
@@ -1426,9 +1436,15 @@
 
 #if defined key_lim3
-      ! zsnw = snow percentage over ice after wind blowing
-      zsnw(:,:) = 0._wp
-      CALL lim_thd_snwblow( p_frld, zsnw )
+      ! zsnw = snow fraction over ice after wind blowing
+      zsnw(:,:) = 0._wp  ;  CALL lim_thd_snwblow( p_frld, zsnw )
       
-      ! --- evaporation (kg/m2/s) --- !
+      ! --- evaporation minus precipitation corrected (because of wind blowing on snow) --- !
+      zemp_ice(:,:) = zemp_ice(:,:) + zsprecip(:,:) * ( zicefr(:,:) - zsnw(:,:) )  ! emp_ice = A * sublimation - zsnw * sprecip
+      zemp_oce(:,:) = zemp_tot(:,:) - zemp_ice(:,:)                                ! emp_oce = emp_tot - emp_ice
+
+      ! --- evaporation over ocean (used later for qemp) --- !
+      zevap_oce(:,:) = frcv(jpr_tevp)%z3(:,:,1) - frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:)
+
+      ! --- evaporation over ice (kg/m2/s) --- !
       zevap_ice(:,:) = frcv(jpr_ievp)%z3(:,:,1)
       ! since the sensitivity of evap to temperature (devap/dT) is not prescribed by the atmosphere, we set it to 0
@@ -1436,14 +1452,11 @@
       zdevap_ice(:,:) = 0._wp
       
-      ! --- evaporation minus precipitation corrected for the effect of wind blowing on snow --- !
-      zemp_oce(:,:) = zemp_tot(:,:) - zemp_ice(:,:) - zsprecip * (1._wp - zsnw)
-      zemp_ice(:,:) = zemp_ice(:,:) + zsprecip * (1._wp - zsnw)          
-
-      ! Sublimation over sea-ice (cell average)
-      IF( iom_use('subl_ai_cea') )  CALL iom_put( 'subl_ai_cea', zevap_ice(:,:) * zicefr(:,:) )
-      ! runoffs and calving (put in emp_tot)
+      ! --- runoffs (included in emp later on) --- !
       IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
+
+      ! --- calving (put in emp_tot and emp_oce) --- !
       IF( srcv(jpr_cal)%laction ) THEN 
          zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1)
+         zemp_oce(:,:) = zemp_oce(:,:) - frcv(jpr_cal)%z3(:,:,1)
          CALL iom_put( 'calving_cea', frcv(jpr_cal)%z3(:,:,1) )
       ENDIF
@@ -1471,10 +1484,9 @@
       ENDIF
 
-                                     CALL iom_put( 'snowpre'    , sprecip                         )  ! Snow
-      IF( iom_use('snow_ao_cea') )   CALL iom_put( 'snow_ao_cea', sprecip(:,:) * ( 1._wp - zsnw ) )  ! Snow over ice-free ocean  (cell average)
-      IF( iom_use('snow_ai_cea') )   CALL iom_put( 'snow_ai_cea', sprecip(:,:) *           zsnw   )  ! Snow over sea-ice         (cell average)    
+      IF( iom_use('subl_ai_cea') )   CALL iom_put( 'subl_ai_cea', zevap_ice(:,:) * zicefr(:,:)         )  ! Sublimation over sea-ice (cell average)
+                                     CALL iom_put( 'snowpre'    , sprecip(:,:)                         )  ! Snow
+      IF( iom_use('snow_ao_cea') )   CALL iom_put( 'snow_ao_cea', sprecip(:,:) * ( 1._wp - zsnw(:,:) ) )  ! Snow over ice-free ocean  (cell average)
+      IF( iom_use('snow_ai_cea') )   CALL iom_put( 'snow_ai_cea', sprecip(:,:) *           zsnw(:,:)   )  ! Snow over sea-ice         (cell average)
 #else
-      ! Sublimation over sea-ice (cell average)
-      IF( iom_use('subl_ai_cea') )  CALL iom_put( 'subl_ai_cea', frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) )
       ! runoffs and calving (put in emp_tot)
       IF( srcv(jpr_rnf)%laction )   rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
@@ -1496,9 +1508,8 @@
       ENDIF
 
-         CALL iom_put( 'snowpre'    , sprecip                                )   ! Snow
-      IF( iom_use('snow_ao_cea') )   &
-         CALL iom_put( 'snow_ao_cea', sprecip(:,:) * p_frld(:,:)             )   ! Snow        over ice-free ocean  (cell average)
-      IF( iom_use('snow_ai_cea') )   &
-         CALL iom_put( 'snow_ai_cea', sprecip(:,:) * zicefr(:,:)             )   ! Snow        over sea-ice         (cell average)
+      IF( iom_use('subl_ai_cea') )  CALL iom_put( 'subl_ai_cea', frcv(jpr_ievp)%z3(:,:,1) * zicefr(:,:) )  ! Sublimation over sea-ice (cell average)
+                                    CALL iom_put( 'snowpre'    , sprecip(:,:)               )   ! Snow
+      IF( iom_use('snow_ao_cea') )  CALL iom_put( 'snow_ao_cea', sprecip(:,:) * p_frld(:,:) )   ! Snow over ice-free ocean  (cell average)
+      IF( iom_use('snow_ai_cea') )  CALL iom_put( 'snow_ai_cea', sprecip(:,:) * zicefr(:,:) )   ! Snow over sea-ice         (cell average)
 #endif
 
@@ -1506,18 +1517,17 @@
       SELECT CASE( TRIM( sn_rcv_qns%cldes ) )                !   non solar heat fluxes   !   (qns)
       !                                                      ! ========================= !
-      CASE( 'oce only' )                                     ! the required field is directly provided
-         zqns_tot(:,:  ) = frcv(jpr_qnsoce)%z3(:,:,1)
-      CASE( 'conservative' )                                      ! the required fields are directly provided
-         zqns_tot(:,:  ) = frcv(jpr_qnsmix)%z3(:,:,1)
+      CASE( 'oce only' )         ! the required field is directly provided
+         zqns_tot(:,:) = frcv(jpr_qnsoce)%z3(:,:,1)
+      CASE( 'conservative' )     ! the required fields are directly provided
+         zqns_tot(:,:) = frcv(jpr_qnsmix)%z3(:,:,1)
          IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN
             zqns_ice(:,:,1:jpl) = frcv(jpr_qnsice)%z3(:,:,1:jpl)
          ELSE
-            ! Set all category values equal for the moment
             DO jl=1,jpl
-               zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1)
+               zqns_ice(:,:,jl) = frcv(jpr_qnsice)%z3(:,:,1) ! Set all category values equal
             ENDDO
          ENDIF
-      CASE( 'oce and ice' )       ! the total flux is computed from ocean and ice fluxes
-         zqns_tot(:,:  ) =  p_frld(:,:) * frcv(jpr_qnsoce)%z3(:,:,1)
+      CASE( 'oce and ice' )      ! the total flux is computed from ocean and ice fluxes
+         zqns_tot(:,:) =  p_frld(:,:) * frcv(jpr_qnsoce)%z3(:,:,1)
          IF ( TRIM(sn_rcv_qns%clcat) == 'yes' ) THEN
             DO jl=1,jpl
@@ -1526,5 +1536,5 @@
             ENDDO
          ELSE
-            qns_tot(:,:   ) = qns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1)
+            qns_tot(:,:) = qns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1)
             DO jl=1,jpl
                zqns_tot(:,:   ) = zqns_tot(:,:) + zicefr(:,:) * frcv(jpr_qnsice)%z3(:,:,1)
@@ -1532,10 +1542,10 @@
             ENDDO
          ENDIF
-      CASE( 'mixed oce-ice' )     ! the ice flux is cumputed from the total flux, the SST and ice informations
+      CASE( 'mixed oce-ice' )    ! the ice flux is cumputed from the total flux, the SST and ice informations
 ! ** NEED TO SORT OUT HOW THIS SHOULD WORK IN THE MULTI-CATEGORY CASE - CURRENTLY NOT ALLOWED WHEN INTERFACE INITIALISED **
          zqns_tot(:,:  ) = frcv(jpr_qnsmix)%z3(:,:,1)
          zqns_ice(:,:,1) = frcv(jpr_qnsmix)%z3(:,:,1)    &
             &            + frcv(jpr_dqnsdt)%z3(:,:,1) * ( pist(:,:,1) - ( (rt0 + psst(:,:  ) ) * p_frld(:,:)   &
-            &                                                   +          pist(:,:,1)   * zicefr(:,:) ) )
+            &                                           + pist(:,:,1) * zicefr(:,:) ) )
       END SELECT
 !!gm
@@ -1547,18 +1557,11 @@
 !! similar job should be done for snow and precipitation temperature
       !                                     
-      IF( srcv(jpr_cal)%laction ) THEN                            ! Iceberg melting 
-         ztmp(:,:) = frcv(jpr_cal)%z3(:,:,1) * lfus               ! add the latent heat of iceberg melting 
-         zqns_tot(:,:) = zqns_tot(:,:) - ztmp(:,:)
-         IF( iom_use('hflx_cal_cea') )   &
-            CALL iom_put( 'hflx_cal_cea', ztmp + frcv(jpr_cal)%z3(:,:,1) * zcptn(:,:) )   ! heat flux from calving
-      ENDIF
-
-      ztmp(:,:) = p_frld(:,:) * zsprecip(:,:) * lfus
-      IF( iom_use('hflx_snow_cea') )    CALL iom_put( 'hflx_snow_cea', ztmp + sprecip(:,:) * zcptn(:,:) )   ! heat flux from snow (cell average)
+      IF( srcv(jpr_cal)%laction ) THEN   ! Iceberg melting 
+         zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_cal)%z3(:,:,1) * lfus  ! add the latent heat of iceberg melting
+                                                                         ! we suppose it melts at 0deg, though it should be temp. of surrounding ocean
+         IF( iom_use('hflx_cal_cea') )   CALL iom_put( 'hflx_cal_cea', - frcv(jpr_cal)%z3(:,:,1) * lfus )   ! heat flux from calving
+      ENDIF
 
 #if defined key_lim3      
-      ! --- evaporation --- !
-      zevap(:,:) = zemp_tot(:,:) + ztprecip(:,:) ! evaporation over ocean
-
       ! --- non solar flux over ocean --- !
       !         note: p_frld cannot be = 0 since we limit the ice concentration to amax
@@ -1567,18 +1570,18 @@
 
       ! --- heat flux associated with emp (W/m2) --- !
-      zqemp_oce(:,:) = -      zevap(:,:)                   * p_frld(:,:)      *   zcptn(:,:)   &      ! evap
-         &             + ( ztprecip(:,:) - zsprecip(:,:) )                    *   zcptn(:,:)   &      ! liquid precip
-         &             +   zsprecip(:,:)                   * ( 1._wp - zsnw ) * ( zcptn(:,:) - lfus ) ! solid precip over ocean
+      zqemp_oce(:,:) = -  zevap_oce(:,:)                                      *   zcptn(:,:)   &       ! evap
+         &             + ( ztprecip(:,:) - zsprecip(:,:) )                    *   zcptn(:,:)   &       ! liquid precip
+         &             +   zsprecip(:,:)                   * ( 1._wp - zsnw ) * ( zcptn(:,:) - lfus )  ! solid precip over ocean + snow melting
 !      zqemp_ice(:,:) = -   frcv(jpr_ievp)%z3(:,:,1)        * zicefr(:,:)      *   zcptn(:,:)   &      ! ice evap
 !         &             +   zsprecip(:,:)                   * zsnw             * ( zcptn(:,:) - lfus ) ! solid precip over ice
       zqemp_ice(:,:) =      zsprecip(:,:)                   * zsnw             * ( zcptn(:,:) - lfus ) ! solid precip over ice (only)
-                                                                                                       ! qevap_ice=0 since we consider Tice=0°C
+                                                                                                       ! qevap_ice=0 since we consider Tice=0degC
       
-      ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- !
+      ! --- enthalpy of snow precip over ice in J/m3 (to be used in 1D-thermo) --- !
       zqprec_ice(:,:) = rhosn * ( zcptn(:,:) - lfus )
 
       ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- !
       DO jl = 1, jpl
-         zqevap_ice(:,:,jl) = 0._wp ! should be -evap * ( ( Tice - rt0 ) * cpic ) but we do not have Tice, so we consider Tice=0°C
+         zqevap_ice(:,:,jl) = 0._wp ! should be -evap * ( ( Tice - rt0 ) * cpic ) but we do not have Tice, so we consider Tice=0degC
       END DO
 
@@ -1606,4 +1609,11 @@
          qemp_ice (:,:  ) = zqemp_ice (:,:  )
       ENDIF
+
+      ! some more outputs
+      IF( iom_use('hflx_snow_cea') )    CALL iom_put('hflx_snow_cea',   sprecip(:,:) * ( zcptn(:,:) - Lfus ) )                       ! heat flux from snow (cell average)
+      IF( iom_use('hflx_rain_cea') )    CALL iom_put('hflx_rain_cea', ( tprecip(:,:) - sprecip(:,:) ) * zcptn(:,:) )                 ! heat flux from rain (cell average)
+      IF( iom_use('hflx_snow_ao_cea') ) CALL iom_put('hflx_snow_ao_cea',sprecip(:,:) * ( zcptn(:,:) - Lfus ) * (1._wp - zsnw(:,:)) ) ! heat flux from snow (cell average)
+      IF( iom_use('hflx_snow_ai_cea') ) CALL iom_put('hflx_snow_ai_cea',sprecip(:,:) * ( zcptn(:,:) - Lfus ) * zsnw(:,:) )           ! heat flux from snow (cell average)
+
 #else
       ! clem: this formulation is certainly wrong... but better than it was...
@@ -1611,5 +1621,5 @@
          &          - ztmp(:,:)                           &            ! remove the latent heat flux of solid precip. melting
          &          - (  zemp_tot(:,:)                    &            ! remove the heat content of mass flux (assumed to be at SST)
-         &             - zemp_ice(:,:) * zicefr(:,:)  ) * zcptn(:,:) 
+         &             - zemp_ice(:,:) ) * zcptn(:,:) 
 
      IF( ln_mixcpl ) THEN
@@ -1731,5 +1741,5 @@
 
       CALL wrk_dealloc( jpi,jpj,     zcptn, ztmp, zicefr, zmsk, zsnw )
-      CALL wrk_dealloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap, zevap_ice, zdevap_ice )
+      CALL wrk_dealloc( jpi,jpj,     zemp_tot, zemp_ice, zemp_oce, ztprecip, zsprecip, zevap_oce, zevap_ice, zdevap_ice )
       CALL wrk_dealloc( jpi,jpj,     zqns_tot, zqns_oce, zqsr_tot, zqsr_oce, zqprec_ice, zqemp_oce, zqemp_ice )
       CALL wrk_dealloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice )
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 7483)
@@ -229,5 +229,5 @@
          CALL lim_sbc_flx( kt )                     ! Update surface ocean mass, heat and salt fluxes
          !
-         IF(ln_limdiaout) CALL lim_diahsb           ! Diagnostics and outputs 
+         IF(ln_limdiaout) CALL lim_diahsb( kt )     ! Diagnostics and outputs 
          !
          CALL lim_wri( 1 )                          ! Ice outputs 
@@ -310,8 +310,10 @@
          numit = nit000 - 1
       ENDIF
-      CALL lim_var_agg(1)
+      CALL lim_var_agg(2)
       CALL lim_var_glo2eqv
       !
       CALL lim_sbc_init                 ! ice surface boundary condition   
+      !
+      IF( ln_limdiaout) CALL lim_diahsb_init  ! initialization for diags
       !
       fr_i(:,:)     = at_i(:,:)         ! initialisation of sea-ice fraction
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 7483)
@@ -173,12 +173,11 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
                   ! total intermediate advective trends
-                  ztra = - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                     &             + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
-                     &             + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) )
+                  ztra = - (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
+                     &      + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
+                     &      + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) ) / e1e2t(ji,jj)
                   ! update and guess with monotonic sheme
-                  pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn)         + ztra   * tmask(ji,jj,jk)
-                  zwi(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + z2dtt * ztra ) * tmask(ji,jj,jk)
+                  pta(ji,jj,jk,jn) =                       pta(ji,jj,jk,jn) +         ztra   / fse3t_n(ji,jj,jk) * tmask(ji,jj,jk)
+                  zwi(ji,jj,jk)    = ( fse3t_b(ji,jj,jk) * ptb(ji,jj,jk,jn) + z2dtt * ztra ) / fse3t_a(ji,jj,jk) * tmask(ji,jj,jk)
                END DO
             END DO
@@ -410,12 +409,11 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1._wp / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
                   ! total intermediate advective trends
-                  ztra = - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                     &             + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
-                     &             + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) )
+                  ztra = - (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
+                     &      + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
+                     &      + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) ) / e1e2t(ji,jj)
                   ! update and guess with monotonic sheme
-                  pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn)         + ztra
-                  zwi(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + z2dtt * ztra ) * tmask(ji,jj,jk)
+                  pta(ji,jj,jk,jn) =                       pta(ji,jj,jk,jn) +         ztra   / fse3t_n(ji,jj,jk) * tmask(ji,jj,jk)
+                  zwi(ji,jj,jk)    = ( fse3t_b(ji,jj,jk) * ptb(ji,jj,jk,jn) + z2dtt * ztra ) / fse3t_a(ji,jj,jk) * tmask(ji,jj,jk)
                END DO
             END DO
@@ -438,8 +436,7 @@
          ! --------------------------------------------------
          ! antidiffusive flux on i and j
-
-
-         DO jk = 1, jpkm1
-
+         !
+         DO jk = 1, jpkm1
+            !
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
@@ -472,4 +469,6 @@
          !
          ztrs(:,:,:,1) = ptb(:,:,:,jn)
+         ztrs(:,:,1,2) = ptb(:,:,1,jn)
+         ztrs(:,:,1,3) = ptb(:,:,1,jn)
          zwzts(:,:,:) = 0._wp
 
@@ -572,4 +571,5 @@
    END SUBROUTINE tra_adv_tvd_zts
 
+
    SUBROUTINE nonosc( pbef, paa, pbb, pcc, paft, p2dt )
       !!---------------------------------------------------------------------
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/TRA/trasbc.F90	(revision 7483)
@@ -158,4 +158,5 @@
          ELSE                                         ! No restart or restart not found: Euler forward time stepping
             zfact = 1._wp
+            sbc_tsc(:,:,:) = 0._wp
             sbc_tsc_b(:,:,:) = 0._wp
          ENDIF
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 7483)
@@ -162,5 +162,8 @@
                   &                               + avmv(ji,jj,jk) + avmv(ji,jj-1,jk)  )   &
                   &          + avtb(jk) * tmask(ji,jj,jk)
-               !                                            ! Add the background coefficient on eddy viscosity
+            END DO
+         END DO
+         DO jj = 2, jpjm1                                   ! Add the background coefficient on eddy viscosity
+            DO ji = 2, jpim1
                avmu(ji,jj,jk) = avmu(ji,jj,jk) + avmb(jk) * umask(ji,jj,jk)
                avmv(ji,jj,jk) = avmv(ji,jj,jk) + avmb(jk) * vmask(ji,jj,jk)
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 7483)
@@ -337,4 +337,6 @@
       IF( lk_vvl           )   CALL dom_vvl_sf_swp( kstp )  ! swap of vertical scale factors
       !
+      IF( ln_diahsb        )   CALL dia_hsb( kstp )         ! - ML - global conservation diagnostics
+
       IF( lrst_oce         )   CALL rst_write( kstp )       ! write output ocean restart file
       IF( ln_sto_eos       )   CALL sto_rst_write( kstp )   ! write restart file for stochastic parameters
@@ -351,6 +353,5 @@
       ENDIF
 #endif
-      IF( ln_diahsb        )   CALL dia_hsb( kstp )         ! - ML - global conservation diagnostics
-      IF( lk_diaobs  )         CALL dia_obs( kstp )         ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
+      IF( lk_diaobs        )   CALL dia_obs( kstp )         ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zche.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zche.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zche.F90	(revision 7483)
@@ -31,6 +31,7 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sio3eq   ! chemistry of Si
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   fekeq    ! chemistry of Fe
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   chemc    ! Solubilities of O2 and CO2
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   chemc    ! Solubilities of O2 and CO2
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   chemo2   ! Solubilities of O2 and CO2
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   tempis   ! In situ temperature
 
    REAL(wp), PUBLIC ::   atcox  = 0.20946         ! units atm
@@ -39,38 +40,9 @@
    REAL(wp) ::   o2atm  = 1. / ( 1000. * 0.20946 )  
 
-   REAL(wp) ::   akcc1  = -171.9065       ! coeff. for apparent solubility equilibrium
-   REAL(wp) ::   akcc2  =   -0.077993     ! Millero et al. 1995 from Mucci 1983
-   REAL(wp) ::   akcc3  = 2839.319        
-   REAL(wp) ::   akcc4  =   71.595        
-   REAL(wp) ::   akcc5  =   -0.77712      
-   REAL(wp) ::   akcc6  =    0.00284263   
-   REAL(wp) ::   akcc7  =  178.34        
-   REAL(wp) ::   akcc8  =   -0.07711     
-   REAL(wp) ::   akcc9  =    0.0041249   
-
-   REAL(wp) ::   rgas   = 83.143         ! universal gas constants
+   REAL(wp) ::   rgas   = 83.14472       ! universal gas constants
    REAL(wp) ::   oxyco  = 1. / 22.4144   ! converts from liters of an ideal gas to moles
 
    REAL(wp) ::   bor1   = 0.00023        ! borat constants
    REAL(wp) ::   bor2   = 1. / 10.82
-
-   REAL(wp) ::   ca0    = -162.8301      ! WEISS & PRICE 1980, units mol/(kg atm)
-   REAL(wp) ::   ca1    =  218.2968
-   REAL(wp) ::   ca2    =   90.9241
-   REAL(wp) ::   ca3    =   -1.47696
-   REAL(wp) ::   ca4    =    0.025695
-   REAL(wp) ::   ca5    =   -0.025225
-   REAL(wp) ::   ca6    =    0.0049867
-
-   REAL(wp) ::   c10    = -3670.7        ! Coeff. for 1. dissoc. of carbonic acid (Edmond and Gieskes, 1970)   
-   REAL(wp) ::   c11    =    62.008     
-   REAL(wp) ::   c12    =    -9.7944    
-   REAL(wp) ::   c13    =     0.0118     
-   REAL(wp) ::   c14    =    -0.000116
-
-   REAL(wp) ::   c20    = -1394.7       ! coeff. for 2. dissoc. of carbonic acid (Millero, 1995)   
-   REAL(wp) ::   c21    =    -4.777   
-   REAL(wp) ::   c22    =     0.0184   
-   REAL(wp) ::   c23    =    -0.000118
 
    REAL(wp) ::   st1    =      0.14     ! constants for calculate concentrations for sulfate
@@ -190,6 +162,6 @@
       REAL(wp) ::   ztgg , ztgg2, ztgg3 , ztgg4 , ztgg5
       REAL(wp) ::   zpres, ztc  , zcl   , zcpexp, zoxy  , zcpexp2
-      REAL(wp) ::   zsqrt, ztr  , zlogt , zcek1
-      REAL(wp) ::   zis  , zis2 , zsal15, zisqrt
+      REAL(wp) ::   zsqrt, ztr  , zlogt , zcek1, zc1, zplat
+      REAL(wp) ::   zis  , zis2 , zsal15, zisqrt, za1  , za2
       REAL(wp) ::   zckb , zck1 , zck2  , zckw  , zak1 , zak2  , zakb , zaksp0, zakw
       REAL(wp) ::   zst  , zft  , zcks  , zckf  , zaksp1
@@ -202,4 +174,20 @@
       IF( nn_timing == 1 )  CALL timing_start('p4z_che')
       !
+      ! Computations of chemical constants require in situ temperature
+      ! Here a quite simple formulation is used to convert 
+      ! potential temperature to in situ temperature. The errors is less than 
+      ! 0.04°C relative to an exact computation
+      ! ---------------------------------------------------------------------
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zpres = fsdept(ji,jj,jk) / 1000.
+               za1 = 0.04 * ( 1.0 + 0.185 * tsn(ji,jj,jk,jp_tem) + 0.035 * (tsn(ji,jj,jk,jp_sal) - 35.0) )
+               za2 = 0.0075 * ( 1.0 - tsn(ji,jj,jk,jp_tem) / 30.0 )
+               tempis(ji,jj,jk) = tsn(ji,jj,jk,jp_tem) - za1 * zpres + za2 * zpres**2
+            END DO
+         END DO
+      END DO
+      !
       ! CHEMICAL CONSTANTS - SURFACE LAYER
       ! ----------------------------------
@@ -209,5 +197,5 @@
          DO ji = 1, jpi
             !                             ! SET ABSOLUTE TEMPERATURE
-            ztkel = tsn(ji,jj,1,jp_tem) + 273.15
+            ztkel = tempis(ji,jj,1) + 273.15
             zt    = ztkel * 0.01
             zt2   = zt * zt
@@ -217,7 +205,10 @@
             !                             ! LN(K0) OF SOLUBILITY OF CO2 (EQ. 12, WEISS, 1980)
             !                             !     AND FOR THE ATMOSPHERE FOR NON IDEAL GAS
-            zcek1 = ca0 + ca1 / zt + ca2 * zlogt + ca3 * zt2 + zsal * ( ca4 + ca5 * zt + ca6 * zt2 )
+            zcek1 = 9345.17/ztkel - 60.2409 + 23.3585 * LOG(zt) + zsal*(0.023517 - 0.00023656*ztkel    &
+            &       + 0.0047036e-4*ztkel**2)
             !                             ! SET SOLUBILITIES OF O2 AND CO2 
-            chemc(ji,jj) = EXP( zcek1 ) * 1.e-6 * rhop(ji,jj,1) / 1000.  ! mol/(L uatm)
+            chemc(ji,jj,1) = EXP( zcek1 ) * 1.e-6 * rhop(ji,jj,1) / 1000. ! mol/(kg uatm)
+            chemc(ji,jj,2) = -1636.75 + 12.0408*ztkel - 0.0327957*ztkel**2 + 0.0000316528*ztkel**3
+            chemc(ji,jj,3) = 57.7 - 0.118*ztkel
             !
          END DO
@@ -232,8 +223,8 @@
 !CDIR NOVERRCHK
             DO ji = 1, jpi
-              ztkel = tsn(ji,jj,jk,jp_tem) + 273.15
+              ztkel = tempis(ji,jj,jk) + 273.15
               zsal  = tsn(ji,jj,jk,jp_sal) + ( 1.- tmask(ji,jj,jk) ) * 35.
               zsal2 = zsal * zsal
-              ztgg  = LOG( ( 298.15 - tsn(ji,jj,jk,jp_tem) ) / ztkel )  ! Set the GORDON & GARCIA scaled temperature
+              ztgg  = LOG( ( 298.15 - tempis(ji,jj,jk) ) / ztkel )  ! Set the GORDON & GARCIA scaled temperature
               ztgg2 = ztgg  * ztgg
               ztgg3 = ztgg2 * ztgg
@@ -306,9 +297,12 @@
             DO ji = 1, jpi
 
-               ! SET PRESSION
-               zpres   = 1.025e-1 * fsdept(ji,jj,jk)
+               ! SET PRESSION ACCORDING TO SAUNDER (1980)
+               zplat   = SIN ( ABS(gphit(ji,jj)*3.141592654/180.) )
+               zc1 = 5.92E-3 + zplat**2 * 5.25E-3
+               zpres = ((1-zc1)-SQRT(((1-zc1)**2)-(8.84E-6*fsdept(ji,jj,jk)))) / 4.42E-6
+               zpres = zpres / 10.0
 
                ! SET ABSOLUTE TEMPERATURE
-               ztkel   = tsn(ji,jj,jk,jp_tem) + 273.15
+               ztkel   = tempis(ji,jj,jk) + 273.15
                zsal    = tsn(ji,jj,jk,jp_sal) + ( 1.-tmask(ji,jj,jk) ) * 35.
                zsqrt  = SQRT( zsal )
@@ -319,5 +313,5 @@
                zis2   = zis * zis
                zisqrt = SQRT( zis )
-               ztc     = tsn(ji,jj,jk,jp_tem) + ( 1.- tmask(ji,jj,jk) ) * 20.
+               ztc     = tempis(ji,jj,jk) + ( 1.- tmask(ji,jj,jk) ) * 20.
 
                ! CHLORINITY (WOOSTER ET AL., 1969)
@@ -352,6 +346,10 @@
 
 
-               zck1    = c10 * ztr + c11 + c12 * zlogt + c13 * zsal + c14 * zsal * zsal
-               zck2    = c20 * ztr + c21 + c22 * zsal   + c23 * zsal**2
+               ! DISSOCIATION COEFFICIENT FOR CARBONATE ACCORDING TO 
+               ! MEHRBACH (1973) REFIT BY MILLERO (1995), seawater scale
+               zck1    = -1.0*(3633.86*ztr - 61.2172 + 9.6777*zlogt  &
+                  - 0.011555*zsal + 0.0001152*zsal*zsal)
+               zck2    = -1.0*(471.78*ztr + 25.9290 - 3.16967*zlogt      &
+                  - 0.01781*zsal + 0.0001122*zsal*zsal)
 
                ! PKW (H2O) (DICKSON AND RILEY, 1979)
@@ -362,6 +360,7 @@
                ! APPARENT SOLUBILITY PRODUCT K'SP OF CALCITE IN SEAWATER
                !       (S=27-43, T=2-25 DEG C) at pres =0 (atmos. pressure) (MUCCI 1983)
-               zaksp0  = akcc1 + akcc2 * ztkel + akcc3 * ztr + akcc4 * LOG10( ztkel )   &
-                  &   + ( akcc5 + akcc6 * ztkel + akcc7 * ztr ) * zsqrt + akcc8 * zsal + akcc9 * zsal15
+               zaksp0  = -171.9065 -0.077993*ztkel + 2839.319*ztr + 71.595*LOG10( ztkel )   &
+                  &      + (-0.77712 + 0.00284263*ztkel + 178.34*ztr) * zsqrt  &
+                  &      - 0.07711*zsal + 0.0041249*zsal15
 
                ! K1, K2 OF CARBONIC ACID, KB OF BORIC ACID, KW (H2O) (LIT.?)
@@ -436,10 +435,10 @@
 
       ierr(:) = 0
-      ALLOCATE( sio3eq(jpi,jpj,jpk), fekeq(jpi,jpj,jpk), chemc(jpi,jpj), chemo2(jpi,jpj,jpk), STAT= ierr(1) )
+      ALLOCATE( sio3eq(jpi,jpj,jpk), fekeq(jpi,jpj,jpk), chemc(jpi,jpj,3), chemo2(jpi,jpj,jpk),   &
+      &         tempis(jpi,jpj,jpk), STAT= ierr(1) )
+      !
       IF (lk_gas) ALLOCATE ( chemcos(jpi,jpj,3), k_hydr(jpi,jpj,jpk), chemn2o(jpi,jpj), STAT= ierr(2) )
-
+      !
       p4z_che_alloc = MAXVAL( ierr )
-      
-      !
       IF( p4z_che_alloc /= 0 )   CALL ctl_warn('p4z_che_alloc : failed to allocate arrays.')
       !
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zflx.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zflx.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zflx.F90	(revision 7483)
@@ -90,8 +90,9 @@
       REAL(wp) ::   ztc, ztc2, ztc3, ztc4, zws, zkgwan
       REAL(wp) ::   zfld, zflu, zfld16, zflu16, zfact
+      REAL(wp) ::   zvapsw, zsal, zfco2, zxc2, xCO2approx, ztkel, zfugcoeff
       REAL(wp) ::   zph, zah2, zbot, zdic, zalk, zsch_o2, zalka, zsch_co2
       REAL(wp) ::   zyr_dec, zdco2dt
       CHARACTER (len=25) :: charout
-      REAL(wp), POINTER, DIMENSION(:,:) :: zkgco2, zkgo2, zh2co3, zoflx, zw2d 
+      REAL(wp), POINTER, DIMENSION(:,:) :: zkgco2, zkgo2, zh2co3, zoflx, zw2d, zpco2atm 
       REAL(wp) ::   zsch_dms, zfludms,zflddms
       REAL(wp) ::   zfldco, zfluco, zsch_co, zkin_vis, zD
@@ -108,5 +109,5 @@
       IF( nn_timing == 1 )  CALL timing_start('p4z_flx')
       !
-      CALL wrk_alloc( jpi, jpj, zkgco2, zkgo2, zh2co3, zoflx )
+      CALL wrk_alloc( jpi, jpj, zkgco2, zkgo2, zh2co3, zoflx, zpco2atm )
       IF( lk_gas ) THEN
          CALL wrk_alloc( jpi, jpj, zkgco, zcoflx, zkgisp, zispflx )
@@ -235,15 +236,24 @@
       DO jj = 1, jpj
          DO ji = 1, jpi
+            ztkel  = tsn(ji,jj,1,jp_tem) + 273.15
+            zsal   = tsn(ji,jj,1,jp_sal) + ( 1.- tmask(ji,jj,1) ) * 35.
+            zvapsw = EXP(24.4543 - 67.4509*(100.0/ztkel) - 4.8489*LOG(ztkel/100) - 0.000544*zsal)
+            zpco2atm(ji,jj) = satmco2(ji,jj) * ( patm(ji,jj) - zvapsw )
+            zxc2 = (1.0 - zpco2atm(ji,jj) * 1E-6 )**2
+            zfugcoeff = EXP(patm(ji,jj) * (chemc(ji,jj,2) + 2.0 * zxc2 * chemc(ji,jj,3) )   &
+            &           / (82.05736 * ztkel))
+            zfco2 = zpco2atm(ji,jj) * zfugcoeff
+
             ! Compute CO2 flux for the sea and air
-            zfld = satmco2(ji,jj) * patm(ji,jj) * tmask(ji,jj,1) * chemc(ji,jj) * zkgco2(ji,jj)   ! (mol/L) * (m/s)
-            zflu = zh2co3(ji,jj) * tmask(ji,jj,1) * zkgco2(ji,jj)                                   ! (mol/L) (m/s) ?
+            zfld = zfco2 * chemc(ji,jj,1) * zkgco2(ji,jj)  ! (mol/L) * (m/s)
+            zflu = zh2co3(ji,jj) * zkgco2(ji,jj)                                   ! (mol/L) (m/s) ?
             oce_co2(ji,jj) = ( zfld - zflu ) * rfact2 * e1e2t(ji,jj) * tmask(ji,jj,1) * 1000.
             ! compute the trend
-            tra(ji,jj,1,jpdic) = tra(ji,jj,1,jpdic) + ( zfld - zflu ) * rfact2 / fse3t(ji,jj,1)
+            tra(ji,jj,1,jpdic) = tra(ji,jj,1,jpdic) + ( zfld - zflu ) * rfact2 / fse3t(ji,jj,1) * tmask(ji,jj,1)
 
             ! Compute O2 flux 
-            zfld16 = patm(ji,jj) * chemo2(ji,jj,1) * tmask(ji,jj,1) * zkgo2(ji,jj)          ! (mol/L) * (m/s)
-            zflu16 = trb(ji,jj,1,jpoxy) * tmask(ji,jj,1) * zkgo2(ji,jj)
-            zoflx(ji,jj) = zfld16 - zflu16
+            zfld16 = patm(ji,jj) * chemo2(ji,jj,1) * zkgo2(ji,jj)          ! (mol/L) * (m/s)
+            zflu16 = trb(ji,jj,1,jpoxy) * zkgo2(ji,jj)
+            zoflx(ji,jj) = ( zfld16 - zflu16 ) * tmask(ji,jj,1)
             tra(ji,jj,1,jpoxy) = tra(ji,jj,1,jpoxy) + zoflx(ji,jj) * rfact2 / fse3t(ji,jj,1)
          END DO
@@ -313,5 +323,5 @@
          ENDIF
          IF( iom_use( "Dpco2" ) ) THEN
-           zw2d(:,:) = ( satmco2(:,:) * patm(:,:) - zh2co3(:,:) / ( chemc(:,:) + rtrn ) ) * tmask(:,:,1)
+           zw2d(:,:) = ( zpco2atm(:,:) - zh2co3(:,:) / ( chemc(:,:,1) + rtrn ) ) * tmask(:,:,1)
            CALL iom_put( "Dpco2" ,  zw2d )
          ENDIF
@@ -356,9 +366,9 @@
             trc2d(:,:,jp_pcs0_2d + 1) = zoflx(:,:) * 1000 * tmask(:,:,1) 
             trc2d(:,:,jp_pcs0_2d + 2) = zkgco2(:,:) * tmask(:,:,1) 
-            trc2d(:,:,jp_pcs0_2d + 3) = ( satmco2(:,:) * patm(:,:) - zh2co3(:,:) / ( chemc(:,:) + rtrn ) ) * tmask(:,:,1) 
-         ENDIF
-      ENDIF
-      !
-      CALL wrk_dealloc( jpi, jpj, zkgco2, zkgo2, zh2co3, zoflx )
+            trc2d(:,:,jp_pcs0_2d + 3) = ( zpco2atm(:,:) - zh2co3(:,:) / ( chemc(:,:,1) + rtrn ) ) * tmask(:,:,1)
+         ENDIF
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi, jpj, zkgco2, zkgo2, zh2co3, zoflx, zpco2atm )
       !
       IF( nn_timing == 1 )  CALL timing_stop('p4z_flx')
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlim.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlim.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlim.F90	(revision 7483)
@@ -44,4 +44,5 @@
    REAL(wp), PUBLIC ::  xkdoc       !:  2nd half-sat. of DOC remineralization  
    REAL(wp), PUBLIC ::  concbfe     !:  Fe half saturation for bacteria 
+   REAL(wp), PUBLIC ::  oxymin      !:  half saturation constant for anoxia
    REAL(wp), PUBLIC ::  qnfelim     !:  optimal Fe quota for nanophyto
    REAL(wp), PUBLIC ::  qdfelim     !:  optimal Fe quota for diatoms
@@ -138,5 +139,5 @@
                zlim1    = xnanono3(ji,jj,jk) + xnanonh4(ji,jj,jk)
                zlim2    = trb(ji,jj,jk,jppo4) / ( trb(ji,jj,jk,jppo4) + concbnh4 )
-               zlim3    = trb(ji,jj,jk,jpfer) / ( concbfe + trb(ji,jj,jk,jpfer) )
+               zlim3    = biron(ji,jj,jk)     / ( concbfe + biron(ji,jj,jk) )
                zlim4    = trb(ji,jj,jk,jpdoc) / ( xkdoc   + trb(ji,jj,jk,jpdoc) )
                xlimbacl(ji,jj,jk) = MIN( zlim1, zlim2, zlim3 )
@@ -259,4 +260,15 @@
       ENDIF
       !
+      DO jk = 1, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               ! denitrification factor computed from O2 levels
+               nitrfac(ji,jj,jk) = MAX(  0.e0, 0.4 * ( 6.e-6  - trb(ji,jj,jk,jpoxy) )    &
+                  &                                / ( oxymin + trb(ji,jj,jk,jpoxy) )  )
+               nitrfac(ji,jj,jk) = MIN( 1., nitrfac(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+      !
       IF( lk_iomput .AND. knt == nrdttrc ) THEN        ! save output diagnostics
         IF( iom_use( "xfracal" ) ) CALL iom_put( "xfracal", xfracal(:,:,:) * tmask(:,:,:) )  ! euphotic layer deptht
@@ -291,5 +303,5 @@
          &                xkdocdms, xknpo4, xkdpo4, &
 #endif
-         &                xksi1, xksi2, xkdoc, qnfelim, qdfelim, caco3r
+         &                xksi1, xksi2, xkdoc, qnfelim, qdfelim, caco3r, oxymin
       
       INTEGER :: ios                 ! Local integer output status for namelist read
@@ -325,4 +337,5 @@
          WRITE(numout,*) '    Minimum size criteria for nanophyto      xsizephy  = ', xsizephy
          WRITE(numout,*) '    Fe half saturation for bacteria          concbfe   = ', concbfe
+         WRITE(numout,*) '    halk saturation constant for anoxia       oxymin   =' , oxymin
          WRITE(numout,*) '    optimal Fe quota for nano.               qnfelim   = ', qnfelim
          WRITE(numout,*) '    Optimal Fe quota for diatoms             qdfelim   = ', qdfelim
@@ -341,5 +354,7 @@
         ENDIF
       ENDIF
-
+      !
+      nitrfac (:,:,:) = 0._wp
+      !
    END SUBROUTINE p4z_lim_init
 
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlys.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlys.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlys.F90	(revision 7483)
@@ -65,10 +65,10 @@
       REAL(wp) ::   zomegaca, zexcess, zexcess0
       CHARACTER (len=25) :: charout
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zco3, zcaldiss   
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zco3, zco3sat, zcaldiss   
       !!---------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('p4z_lys')
       !
-      CALL wrk_alloc( jpi, jpj, jpk, zco3, zcaldiss )
+      CALL wrk_alloc( jpi, jpj, jpk, zco3, zco3sat, zcaldiss )
       !
       zco3    (:,:,:) = 0.
@@ -120,5 +120,6 @@
                zcalcon  = calcon * ( tsn(ji,jj,jk,jp_sal) / 35._wp )
                zfact    = rhop(ji,jj,jk) / 1000._wp
-               zomegaca = ( zcalcon * zco3(ji,jj,jk) * zfact ) / aksp(ji,jj,jk) 
+               zomegaca = ( zcalcon * zco3(ji,jj,jk) ) / ( aksp(ji,jj,jk) * zfact + rtrn )
+               zco3sat(ji,jj,jk) = aksp(ji,jj,jk) * zfact / ( zcalcon + rtrn )
 
                ! SET DEGREE OF UNDER-/SUPERSATURATION
@@ -149,12 +150,12 @@
       IF( lk_iomput .AND. knt == nrdttrc ) THEN
          IF( iom_use( "PH"     ) ) CALL iom_put( "PH"    , -1. * LOG10( hi(:,:,:) )          * tmask(:,:,:) )
-         IF( iom_use( "CO3"    ) ) CALL iom_put( "CO3"   , zco3(:,:,:) * 1.e+3               * tmask(:,:,:) )
-         IF( iom_use( "CO3sat" ) ) CALL iom_put( "CO3sat", aksp(:,:,:) * 1.e+3 / calcon      * tmask(:,:,:) )
-         IF( iom_use( "DCAL"   ) ) CALL iom_put( "DCAL"  , zcaldiss(:,:,:) * 1.e+3 * rfact2r   * tmask(:,:,:) )
+         IF( iom_use( "CO3"    ) ) CALL iom_put( "CO3"   , zco3(:,:,:)    * 1.e+3            * tmask(:,:,:) )
+         IF( iom_use( "CO3sat" ) ) CALL iom_put( "CO3sat", zco3sat(:,:,:) * 1.e+3            * tmask(:,:,:) )
+         IF( iom_use( "DCAL"   ) ) CALL iom_put( "DCAL"  , zcaldiss(:,:,:) * 1.e+3 * rfact2r * tmask(:,:,:) )
       ELSE
          IF( ln_diatrc ) THEN
             trc3d(:,:,:,jp_pcs0_3d    ) = -1. * LOG10( hi(:,:,:) ) * tmask(:,:,:)
             trc3d(:,:,:,jp_pcs0_3d + 1) = zco3(:,:,:)              * tmask(:,:,:)
-            trc3d(:,:,:,jp_pcs0_3d + 2) = aksp(:,:,:) / calcon     * tmask(:,:,:)
+            trc3d(:,:,:,jp_pcs0_3d + 2) = zco3sat(:,:,:)           * tmask(:,:,:)
          ENDIF
       ENDIF
@@ -166,5 +167,5 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi, jpj, jpk, zco3, zcaldiss )
+      CALL wrk_dealloc( jpi, jpj, jpk, zco3, zco3sat, zcaldiss )
       !
       IF( nn_timing == 1 )  CALL timing_stop('p4z_lys')
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90	(revision 7483)
@@ -83,5 +83,6 @@
       REAL(wp) ::   zchl
       REAL(wp) ::   zc0 , zc1 , zc2, zc3, z1_dep
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: zdepmoy, zetmp1, zetmp2, zetmp3, zetmp4, zqsr100
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zdepmoy, zetmp1, zetmp2, zetmp3, zetmp4
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zqsr100, zqsr_corr
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zpar, ze0, ze1, ze2, ze3
       REAL(wp) ::  za300, za400, za440, zpera440
@@ -91,5 +92,6 @@
       !
       ! Allocate temporary workspace
-      CALL wrk_alloc( jpi, jpj,      zqsr100, zdepmoy, zetmp1, zetmp2, zetmp3, zetmp4 )
+      CALL wrk_alloc( jpi, jpj,      zdepmoy, zetmp1, zetmp2, zetmp3, zetmp4 )
+      CALL wrk_alloc( jpi, jpj,      zqsr100, zqsr_corr )
       CALL wrk_alloc( jpi, jpj, jpk, zpar, ze0, ze1, ze2, ze3 )
 
@@ -150,8 +152,8 @@
       !                                        !  --------------------------------------
       IF( l_trcdm2dc ) THEN                     !  diurnal cycle
-         ! 1% of qsr to compute euphotic layer
-         zqsr100(:,:) = 0.01 * qsr_mean(:,:)     !  daily mean qsr
-         !
-         CALL p4z_opt_par( kt, qsr_mean, ze1, ze2, ze3 ) 
+         !
+         zqsr_corr(:,:) = qsr_mean(:,:) / ( 1. - fr_i(:,:) + rtrn )
+         !
+         CALL p4z_opt_par( kt, zqsr_corr, ze1, ze2, ze3, pqsr100 = zqsr100 ) 
          !
          DO jk = 1, nksrp      
@@ -161,5 +163,7 @@
          END DO
          !
-         CALL p4z_opt_par( kt, qsr, ze1, ze2, ze3 ) 
+         zqsr_corr(:,:) = qsr(:,:) / ( 1. - fr_i(:,:) + rtrn )
+         !
+         CALL p4z_opt_par( kt, zqsr_corr, ze1, ze2, ze3 ) 
          !
          DO jk = 1, nksrp      
@@ -168,8 +172,8 @@
          !
       ELSE
-         ! 1% of qsr to compute euphotic layer
-         zqsr100(:,:) = 0.01 * qsr(:,:)
-         !
-         CALL p4z_opt_par( kt, qsr, ze1, ze2, ze3 ) 
+         !
+         zqsr_corr(:,:) = qsr(:,:) / ( 1. - fr_i(:,:) + rtrn )
+         !
+         CALL p4z_opt_par( kt, zqsr_corr, ze1, ze2, ze3, pqsr100 = zqsr100 ) 
          !
          DO jk = 1, nksrp      
@@ -216,5 +220,5 @@
          DO jj = 1, jpj
            DO ji = 1, jpi
-              IF( etot_ndcy(ji,jj,jk) * tmask(ji,jj,jk) >= 0.43 * zqsr100(ji,jj) )  THEN
+              IF( etot_ndcy(ji,jj,jk) * tmask(ji,jj,jk) >= zqsr100(ji,jj) )  THEN
                  neln(ji,jj) = jk+1                    ! Euphotic level : 1rst T-level strictly below Euphotic layer
                  !                                     ! nb: ensure the compatibility with nmld_trc definition in trd_mld_trc_zint
@@ -285,5 +289,6 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi, jpj,      zqsr100, zdepmoy, zetmp1, zetmp2, zetmp3, zetmp4 )
+      CALL wrk_dealloc( jpi, jpj,      zdepmoy, zetmp1, zetmp2, zetmp3, zetmp4 )
+      CALL wrk_dealloc( jpi, jpj,      zqsr100, zqsr_corr )
       CALL wrk_dealloc( jpi, jpj, jpk, zpar,  ze0, ze1, ze2, ze3 )
       !
@@ -292,5 +297,5 @@
    END SUBROUTINE p4z_opt
 
-   SUBROUTINE p4z_opt_par( kt, pqsr, pe1, pe2, pe3, pe0 ) 
+   SUBROUTINE p4z_opt_par( kt, pqsr, pe1, pe2, pe3, pe0, pqsr100 ) 
       !!----------------------------------------------------------------------
       !!                  ***  routine p4z_opt_par  ***
@@ -301,8 +306,9 @@
       !!----------------------------------------------------------------------
       !! * arguments
-      INTEGER, INTENT(in)                                       ::  kt            !   ocean time-step
-      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in)              ::  pqsr          !   shortwave
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)           ::  pe1 , pe2 , pe3   !  PAR ( R-G-B)
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout), OPTIONAL ::  pe0  
+      INTEGER, INTENT(in)                                        ::  kt            !   ocean time-step
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in)               ::  pqsr          !   shortwave
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout)            ::  pe1 , pe2 , pe3   !  PAR ( R-G-B)
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout), OPTIONAL  ::  pe0 
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(out)  , OPTIONAL  ::  pqsr100  
       !! * local variables
       INTEGER    ::   ji, jj, jk     ! dummy loop indices
@@ -314,4 +320,7 @@
       ELSE                  ;  zqsr(:,:) = xparsw         * pqsr(:,:)
       ENDIF
+
+      !  Light at the euphotic depth 
+      IF( PRESENT( pqsr100 ) )  pqsr100(:,:) = 0.01 * 3. * zqsr(:,:)
       !
       IF( PRESENT( pe0 ) ) THEN     !  W-level
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zprod.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zprod.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zprod.F90	(revision 7483)
@@ -217,17 +217,13 @@
                       zdiattot    = ediat(ji,jj,jk) * zstrn(ji,jj)
                       !
-                      zpislopead (ji,jj,jk) = pislope  * ( 1.+ zadap  * EXP( -znanotot ) )
-                      zpislopead2(ji,jj,jk) = (pislope * zconctemp2 + pislope2 * zconctemp)  / ( trb(ji,jj,jk,jpdia) + rtrn )
-
-                      zpislopen =  zpislopead(ji,jj,jk) * trb(ji,jj,jk,jpnch)                &
-                        &          / ( trb(ji,jj,jk,jpphy) * 12.                  + rtrn )   &
-                        &          / ( prmax(ji,jj,jk) * rday * xlimphy(ji,jj,jk) + rtrn )
-
-                      zpislope2n = zpislopead2(ji,jj,jk) * trb(ji,jj,jk,jpdch)                &
-                        &          / ( trb(ji,jj,jk,jpdia) * 12.                  + rtrn )   &
-                        &          / ( prmax(ji,jj,jk) * rday * xlimdia(ji,jj,jk) + rtrn )
+                      zpislopead (ji,jj,jk) = pislope  * ( 1.+ zadap  * EXP( -znanotot ) )           &
+                         &                   * trb(ji,jj,jk,jpnch) /( trb(ji,jj,jk,jpphy) * 12. + rtrn)
+                      zpislopead2(ji,jj,jk) = (pislope * zconctemp2 + pislope2 * zconctemp)  / ( trb(ji,jj,jk,jpdia) + rtrn )   &
+                         &                   * trb(ji,jj,jk,jpdch) /( trb(ji,jj,jk,jpdia) * 12. + rtrn)
 
                       ! Computation of production function for Carbon
                       !  ---------------------------------------------
+                      zpislopen  =  zpislopead(ji,jj,jk)  / ( prmax(ji,jj,jk) * rday * xlimphy(ji,jj,jk) + rtrn )
+                      zpislope2n =  zpislopead2(ji,jj,jk) / ( prmax(ji,jj,jk) * rday * xlimdia(ji,jj,jk) + rtrn )
                       zprbio(ji,jj,jk) = zprbio(ji,jj,jk) * ( 1.- EXP( -zpislopen  * znanotot ) )
                       zprdia(ji,jj,jk) = zprdia(ji,jj,jk) * ( 1.- EXP( -zpislope2n * zdiattot ) )
@@ -235,6 +231,6 @@
                       !  Computation of production function for Chlorophyll
                       !--------------------------------------------------
-                      zprnch(ji,jj,jk) = prmax(ji,jj,jk) * ( 1.- EXP( -zpislopen  * enano(ji,jj,jk) ) )
-                      zprdch(ji,jj,jk) = prmax(ji,jj,jk) * ( 1.- EXP( -zpislope2n * ediat(ji,jj,jk) ) )
+                      zprnch(ji,jj,jk) = prmax(ji,jj,jk) * ( 1.- EXP( -zpislopen  * znanotot ) )
+                      zprdch(ji,jj,jk) = prmax(ji,jj,jk) * ( 1.- EXP( -zpislope2n * zdiattot ) )
                   ENDIF
                END DO
@@ -242,6 +238,5 @@
          END DO
       ENDIF
-
-
+      
       !  Computation of a proxy of the N/C ratio
       !  ---------------------------------------
@@ -293,10 +288,12 @@
             zmxltst = MAX( 0.e0, hmld(ji,jj) - heup(ji,jj) )
             zmxlday = zmxltst * zmxltst * r1_rday
-            zmixnano(ji,jj) = 1. - zmxlday / ( 2. + zmxlday )
-            zmixdiat(ji,jj) = 1. - zmxlday / ( 4. + zmxlday )
+            zmixnano(ji,jj) = 1. - zmxlday / ( 1. + zmxlday )
+            zmixdiat(ji,jj) = 1. - zmxlday / ( 2. + zmxlday )
          END DO
       END DO
  
-      !  Mixed-layer effect on production                                                                               
+      !  Mixed-layer effect on production 
+      !  Sea-ice effect on production
+
       DO jk = 1, jpkm1
          DO jj = 1, jpj
@@ -306,4 +303,6 @@
                   zprdia(ji,jj,jk) = zprdia(ji,jj,jk) * zmixdiat(ji,jj)
                ENDIF
+                  zprbio(ji,jj,jk) = zprbio(ji,jj,jk) * ( 1. - fr_i(ji,jj) )
+                  zprdia(ji,jj,jk) = zprdia(ji,jj,jk) * ( 1. - fr_i(ji,jj) )
             END DO
          END DO
@@ -345,57 +344,31 @@
       END DO
 
-      IF( ln_newprod ) THEN
-!CDIR NOVERRCHK
-         DO jk = 1, jpkm1
-!CDIR NOVERRCHK
-            DO jj = 1, jpj
-!CDIR NOVERRCHK
-               DO ji = 1, jpi
-                  IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
-                     zprnch(ji,jj,jk) = zprnch(ji,jj,jk) * zmixnano(ji,jj)
-                     zprdch(ji,jj,jk) = zprdch(ji,jj,jk) * zmixdiat(ji,jj)
-                  ENDIF
-                  IF( etot_ndcy(ji,jj,jk) > 1.E-3 ) THEN
-                     !  production terms for nanophyto. ( chlorophyll )
-                     znanotot = enano(ji,jj,jk) * zstrn(ji,jj)
-                     zprod    = rday * zprorca(ji,jj,jk) * zprnch(ji,jj,jk) * xlimphy(ji,jj,jk)
-                     zprochln(ji,jj,jk) = chlcmin * 12. * zprorca (ji,jj,jk)
-                     zprochln(ji,jj,jk) = zprochln(ji,jj,jk) + (chlcnm-chlcmin) * 12. * zprod / &
-                                        & (  zpislopead(ji,jj,jk) * znanotot +rtrn)
-                     !  production terms for diatomees ( chlorophyll )
-                     zdiattot = ediat(ji,jj,jk) * zstrn(ji,jj)
-                     zprod = rday * zprorcad(ji,jj,jk) * zprdch(ji,jj,jk) * xlimdia(ji,jj,jk)
-                     zprochld(ji,jj,jk) = chlcmin * 12. * zprorcad(ji,jj,jk)
-                     zprochld(ji,jj,jk) = zprochld(ji,jj,jk) + (chlcdm-chlcmin) * 12. * zprod / &
-                                        & ( zpislopead2(ji,jj,jk) * zdiattot +rtrn )
-                  ENDIF
-               END DO
-            END DO
-         END DO
-      ELSE
-!CDIR NOVERRCHK
-         DO jk = 1, jpkm1
-!CDIR NOVERRCHK
-            DO jj = 1, jpj
-!CDIR NOVERRCHK
-               DO ji = 1, jpi
-                  IF( etot_ndcy(ji,jj,jk) > 1.E-3 ) THEN
-                     !  production terms for nanophyto. ( chlorophyll )
-                     znanotot = enano(ji,jj,jk)
-                     zprod = rday * zprorca(ji,jj,jk) * zprnch(ji,jj,jk) * trb(ji,jj,jk,jpphy) * xlimphy(ji,jj,jk)
-                     zprochln(ji,jj,jk) = chlcmin * 12. * zprorca (ji,jj,jk)
-                     zprochln(ji,jj,jk) = zprochln(ji,jj,jk) + (chlcnm-chlcmin) * 144. * zprod            &
-                     &                    / ( zpislopead(ji,jj,jk) * trb(ji,jj,jk,jpnch) * znanotot +rtrn )
-                     !  production terms for diatomees ( chlorophyll )
-                     zdiattot = ediat(ji,jj,jk)
-                     zprod = rday * zprorcad(ji,jj,jk) * zprdch(ji,jj,jk) * trb(ji,jj,jk,jpdia) * xlimdia(ji,jj,jk)
-                     zprochld(ji,jj,jk) = chlcmin * 12. * zprorcad(ji,jj,jk)
-                     zprochld(ji,jj,jk) = zprochld(ji,jj,jk) + (chlcdm-chlcmin) * 144. * zprod             &
-                     &                    / ( zpislopead2(ji,jj,jk) * trb(ji,jj,jk,jpdch) * zdiattot +rtrn )
-                  ENDIF
-               END DO
-            END DO
-         END DO
-      ENDIF
+!CDIR NOVERRCHK
+      DO jk = 1, jpkm1
+!CDIR NOVERRCHK
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
+                  zprnch(ji,jj,jk) = zprnch(ji,jj,jk) * zmixnano(ji,jj)
+                  zprdch(ji,jj,jk) = zprdch(ji,jj,jk) * zmixdiat(ji,jj)
+               ENDIF
+               IF( etot_ndcy(ji,jj,jk) > 1.E-3 ) THEN
+                  !  production terms for nanophyto. ( chlorophyll )
+                  znanotot = enano(ji,jj,jk) * zstrn(ji,jj)
+                  zprod    = rday * zprorca(ji,jj,jk) * zprnch(ji,jj,jk) * xlimphy(ji,jj,jk)
+                  zprochln(ji,jj,jk) = chlcmin * 12. * zprorca (ji,jj,jk)
+                  zprochln(ji,jj,jk) = zprochln(ji,jj,jk) + (chlcnm-chlcmin) * 12. * zprod / &
+                                     & (  zpislopead(ji,jj,jk) * znanotot +rtrn)
+                  !  production terms for diatomees ( chlorophyll )
+                  zdiattot = ediat(ji,jj,jk) * zstrn(ji,jj)
+                  zprod = rday * zprorcad(ji,jj,jk) * zprdch(ji,jj,jk) * xlimdia(ji,jj,jk)
+                  zprochld(ji,jj,jk) = chlcmin * 12. * zprorcad(ji,jj,jk)
+                  zprochld(ji,jj,jk) = zprochld(ji,jj,jk) + (chlcdm-chlcmin) * 12. * zprod / &
+                                     & ( zpislopead2(ji,jj,jk) * zdiattot +rtrn )
+               ENDIF
+            END DO
+         END DO
+      END DO
 
       !   Update the arrays TRA which contain the biological sources and sinks
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zrem.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zrem.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zrem.F90	(revision 7483)
@@ -44,5 +44,4 @@
    REAL(wp), PUBLIC ::  xsiremlab  !: fast remineralisation rate of POC 
    REAL(wp), PUBLIC ::  xsilab     !: fraction of labile biogenic silica 
-   REAL(wp), PUBLIC ::  oxymin     !: halk saturation constant for anoxia 
 #if defined key_gas
    REAL(wp), PUBLIC ::  xlightdms   !: photodegradation rate constant of DMS
@@ -137,15 +136,4 @@
                   zdepprod(ji,jj,jk) = zdepmin**0.273
                ENDIF
-            END DO
-         END DO
-      END DO
-
-      DO jk = 1, jpkm1
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               ! denitrification factor computed from O2 levels
-               nitrfac(ji,jj,jk) = MAX(  0.e0, 0.4 * ( 6.e-6  - trb(ji,jj,jk,jpoxy) )    &
-                  &                                / ( oxymin + trb(ji,jj,jk,jpoxy) )  )
-               nitrfac(ji,jj,jk) = MIN( 1., nitrfac(ji,jj,jk) )
             END DO
          END DO
@@ -513,9 +501,9 @@
       !!
       !!----------------------------------------------------------------------
-      NAMELIST/nampisrem/ xremik, xremip, nitrif, xsirem, xsiremlab, xsilab,   &
+      NAMELIST/nampisrem/ xremik, xremip, xsirem, xsiremlab, xsilab,   &
 #if defined key_gas
       &                   xlightdms, xsinkdms, xvsinkdms, xprodco, xsinkco, xsinkisp, & 
 #endif
-      &                   oxymin
+      &                   nitrif 
       INTEGER :: ios                 ! Local integer output status for namelist read
 
@@ -539,5 +527,4 @@
          WRITE(numout,*) '    fraction of labile biogenic silica        xsilab    =', xsilab
          WRITE(numout,*) '    NH4 nitrification rate                    nitrif    =', nitrif
-         WRITE(numout,*) '    halk saturation constant for anoxia       oxymin    =', oxymin
 #if defined key_gas
          WRITE(numout,*) '    photodegradation rate constant of DMS     xlightdms =', xlightdms 
@@ -550,5 +537,4 @@
       ENDIF
       !
-      nitrfac (:,:,:) = 0._wp
       denitr  (:,:,:) = 0._wp
       denitnh4(:,:,:) = 0._wp
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90	(revision 7483)
@@ -159,10 +159,11 @@
       IF( ln_ndepo ) THEN
          IF( kt == nit000 .OR. ( kt /= nit000 .AND. ntimes_ndep > 1 ) ) THEN
-            CALL fld_read( kt, 1, sf_ndepo )
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  nitdep(ji,jj) = sf_ndepo(1)%fnow(ji,jj,1) / rno3 / ( 14E6 * ryyss * fse3t(ji,jj,1) + rtrn )
-               END DO
-            END DO
+             zcoef = rno3 * 14E6 * ryyss
+             CALL fld_read( kt, 1, sf_ndepo )
+             nitdep(:,:) = sf_ndepo(1)%fnow(:,:,1) / zcoef / fse3t(:,:,1) 
+         ENDIF
+         IF( lk_vvl ) THEN
+           zcoef = rno3 * 14E6 * ryyss
+           nitdep(:,:) = sf_ndepo(1)%fnow(:,:,1) / zcoef / fse3t(:,:,1) 
          ENDIF
       ENDIF
@@ -266,5 +267,5 @@
       IF( lk_offline ) THEN
         nk_rnf(:,:) = 1
-        h_rnf (:,:) = fsdept(:,:,1)
+        h_rnf (:,:) = e3t_0(:,:,1)
       ENDIF
 
@@ -455,5 +456,5 @@
             DO jj = 1, jpj
                DO ji = 1, jpi
-                  zexpide   = MIN( 8.,( fsdept(ji,jj,jk) / 500. )**(-1.5) )
+                  zexpide   = MIN( 8.,( gdept_0(ji,jj,jk) / 500. )**(-1.5) )
                   zdenitide = -0.9543 + 0.7662 * LOG( zexpide ) - 0.235 * LOG( zexpide )**2
                   zcmask(ji,jj,jk) = zcmask(ji,jj,jk) * MIN( 1., EXP( zdenitide ) / 0.5 )
@@ -465,5 +466,5 @@
          ironsed(:,:,jpk) = 0._wp
          DO jk = 1, jpkm1
-            ironsed(:,:,jk) = sedfeinput * zcmask(:,:,jk) / ( fse3t(:,:,jk) * rday )
+            ironsed(:,:,jk) = sedfeinput * zcmask(:,:,jk) / ( e3t_0(:,:,jk) * rday )
          END DO
          DEALLOCATE( zcmask)
@@ -483,5 +484,7 @@
          CALL iom_close( numhydro )
          !
-         hydrofe(:,:,:) = ( hydrofe(:,:,:) * hratio ) / ( cvol(:,:,:) * ryyss + rtrn ) / 1000._wp
+         DO jk = 1, jpk
+            hydrofe(:,:,jk) = ( hydrofe(:,:,jk) * hratio ) / ( e1e2t(:,:) * e3t_0(:,:,jk) * ryyss + rtrn ) / 1000._wp
+         ENDDO
          !
       ENDIF
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 7483)
@@ -35,5 +35,5 @@
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   restotr   ! restoring coeff. on tracers (s-1)
 
-   INTEGER, PARAMETER           ::   npncts   = 5        ! number of closed sea
+   INTEGER, PARAMETER           ::   npncts   = 8        ! number of closed sea
    INTEGER, DIMENSION(npncts)   ::   nctsi1, nctsj1      ! south-west closed sea limits (i,j)
    INTEGER, DIMENSION(npncts)   ::   nctsi2, nctsj2      ! north-east closed sea limits (i,j)
@@ -107,6 +107,5 @@
                
                jl = n_trc_index(jn) 
-               CALL trc_dta( kt, sf_trcdta(jl) )   ! read tracer data at nit000
-               ztrcdta(:,:,:) = sf_trcdta(jl)%fnow(:,:,:) * tmask(:,:,:) * rf_trfac(jl)
+               CALL trc_dta( kt, sf_trcdta(jl), rf_trfac(jl), ztrcdta )   ! read tracer data at nit000
 
                SELECT CASE ( nn_zdmp_tr )
@@ -187,4 +186,5 @@
       INTEGER :: ji , jj, jk, jn, jl, jc                     ! dummy loop indicesa
       INTEGER :: isrow                                      ! local index
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta       ! 3D  workspace
 
       !!----------------------------------------------------------------------
@@ -207,6 +207,27 @@
             !
                                                         ! Caspian Sea
-            nctsi1(1)   = 332  ; nctsj1(1)   = 243 - isrow
-            nctsi2(1)   = 344  ; nctsj2(1)   = 275 - isrow
+            nctsi1(1)   = 333  ; nctsj1(1)   = 243 - isrow
+            nctsi2(1)   = 342  ; nctsj2(1)   = 274 - isrow
+            !                                           ! Lake Superior
+            nctsi1(2)   = 198  ; nctsj1(2)   = 258 - isrow
+            nctsi2(2)   = 204  ; nctsj2(2)   = 262 - isrow
+            !                                           ! Lake Michigan
+            nctsi1(3)   = 201  ; nctsj1(3)   = 250 - isrow
+            nctsi2(3)   = 203  ; nctsj2(3)   = 256 - isrow
+            !                                           ! Lake Huron
+            nctsi1(4)   = 204  ; nctsj1(4)   = 252 - isrow
+            nctsi2(4)   = 209  ; nctsj2(4)   = 256 - isrow
+            !                                           ! Lake Erie
+            nctsi1(5)   = 206  ; nctsj1(5)   = 249 - isrow
+            nctsi2(5)   = 209  ; nctsj2(5)   = 251 - isrow
+            !                                           ! Lake Ontario
+            nctsi1(6)   = 210  ; nctsj1(6)   = 252 - isrow
+            nctsi2(6)   = 212  ; nctsj2(6)   = 252 - isrow
+            !                                           ! Victoria Lake
+            nctsi1(7)   = 321  ; nctsj1(7)   = 180 - isrow
+            nctsi2(7)   = 322  ; nctsj2(7)   = 189 - isrow
+            !                                           ! Baltic Sea
+            nctsi1(8)   = 297  ; nctsj1(8)   = 270 - isrow
+            nctsi2(8)   = 308  ; nctsj2(8)   = 293 - isrow
             !                                        
             !                                           ! =======================
@@ -277,13 +298,15 @@
          IF(lwp)  WRITE(numout,*)
          !
+         CALL wrk_alloc( jpi, jpj, jpk, ztrcdta )   ! Memory allocation
+         !
          DO jn = 1, jptra
             IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
                 jl = n_trc_index(jn)
-                CALL trc_dta( kt, sf_trcdta(jl) )   ! read tracer data at nit000
+                CALL trc_dta( kt, sf_trcdta(jl), rf_trfac(jl), ztrcdta )   ! read tracer data at nit000
                 DO jc = 1, npncts
                    DO jk = 1, jpkm1
                       DO jj = nctsj1(jc), nctsj2(jc)
                          DO ji = nctsi1(jc), nctsi2(jc)
-                            trn(ji,jj,jk,jn) = sf_trcdta(jl)%fnow(ji,jj,jk) * tmask(ji,jj,jk) * rf_trfac(jl)
+                            trn(ji,jj,jk,jn) = ztrcdta(ji,jj,jk)
                             trb(ji,jj,jk,jn) = trn(ji,jj,jk,jn)
                          ENDDO
@@ -293,5 +316,5 @@
              ENDIF
           ENDDO
-          !
+          CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta )
       ENDIF
       !
@@ -313,4 +336,6 @@
       IF( nn_timing == 1 )  CALL timing_start('trc_dmp_init')
       !
+      !Allocate arrays
+      IF( trc_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'trc_dmp_init: unable to allocate arrays' )
 
       IF( lzoom )   nn_zdmp_tr = 0           ! restoring to climatology at closed north or south boundaries
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 7483)
@@ -102,5 +102,5 @@
          IF(lwp) WRITE(numout,*) '~~~~~~~ '
 
-         IF( ln_rsttr .AND.    &                     ! Restart: read in restart  file
+         IF( ln_rsttr .AND. .NOT.ln_top_euler .AND.   &                     ! Restart: read in restart  file
             iom_varid( numrtr, 'sbc_'//TRIM(ctrcnm(1))//'_b', ldstop = .FALSE. ) > 0 ) THEN
             IF(lwp) WRITE(numout,*) '          nittrc000-nn_dttrc surface tracer content forcing fields red in the restart file'
@@ -190,5 +190,5 @@
       !                                           Write in the tracer restar  file
       !                                          *******************************
-      IF( lrst_trc ) THEN
+      IF( lrst_trc .AND. .NOT.ln_top_euler ) THEN
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) 'sbc : ocean surface tracer content forcing fields written in tracer restart file ',   &
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 7483)
@@ -68,4 +68,9 @@
          IF( ln_trcdmp )        CALL trc_dmp( kstp )            ! internal damping trends
                                 CALL trc_adv( kstp )            ! horizontal & vertical advection 
+         IF( ln_zps ) THEN
+           IF( ln_isfcav ) THEN ; CALL zps_hde_isf( kstp, jptra, trb, pgtu=gtru, pgtv=gtrv, pgtui=gtrui, pgtvi=gtrvi )  ! both top & bottom
+           ELSE                 ; CALL zps_hde    ( kstp, jptra, trb, gtru, gtrv )                                      !  only bottom
+           ENDIF
+         ENDIF
                                 CALL trc_ldf( kstp )            ! lateral mixing
          IF( .NOT. lk_offline .AND. lk_zdfkpp )    &
@@ -75,4 +80,5 @@
 #endif
                                 CALL trc_zdf( kstp )            ! vertical mixing and after tracer fields
+         !
                                 CALL trc_nxt( kstp )            ! tracer fields at next time step     
          IF( ln_trcrad )        CALL trc_rad( kstp )            ! Correct artificial negative concentrations
@@ -83,10 +89,4 @@
 #endif
 
-         IF( ln_zps  .AND. .NOT. ln_isfcav)        &
-            &            CALL zps_hde    ( kstp, jptra, trn, gtru, gtrv )   ! Partial steps: now horizontal gradient of passive
-         IF( ln_zps .AND.        ln_isfcav)        &
-            &            CALL zps_hde_isf( kstp, jptra, trn, pgtu=gtru, pgtv=gtrv, pgtui=gtrui, pgtvi=gtrvi )  ! Partial steps: now horizontal gradient of passive
-                                                                ! tracers at the bottom ocean level
-         !
       ELSE                                               ! 1D vertical configuration
                                 CALL trc_sbc( kstp )            ! surface boundary condition
@@ -100,4 +100,6 @@
       !
       IF( nn_timing == 1 )   CALL timing_stop('trc_trp')
+      !
+9400  FORMAT(a25,i4,D23.16)
       !
    END SUBROUTINE trc_trp
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcdta.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcdta.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcdta.F90	(revision 7483)
@@ -77,5 +77,5 @@
       ALLOCATE( n_trc_index(ntrc), slf_i(ntrc), STAT=ierr0 )
       IF( ierr0 > 0 ) THEN
-         CALL ctl_stop( 'trc_nam: unable to allocate n_trc_index' )   ;   RETURN
+         CALL ctl_stop( 'trc_dta_init: unable to allocate n_trc_index' )   ;   RETURN
       ENDIF
       nb_trcdta      = 0
@@ -91,4 +91,6 @@
       IF(lwp) THEN
          WRITE(numout,*) ' '
+         WRITE(numout,*) 'trc_dta_init : Passive tracers Initial Conditions '
+         WRITE(numout,*) '~~~~~~~~~~~~~~ '
          WRITE(numout,*) ' number of passive tracers to be initialize by data :', ntra
          WRITE(numout,*) ' '
@@ -107,14 +109,18 @@
          DO jn = 1, ntrc
             IF( ln_trc_ini(jn) )  THEN    ! open input file only if ln_trc_ini(jn) is true
-               clndta = TRIM( sn_trcdta(jn)%clvar ) 
-               clntrc = TRIM( ctrcnm   (jn)       ) 
+               clndta = TRIM( sn_trcdta(jn)%clvar )
+               if (jn > jptra) then
+                  clntrc='Dummy' ! By pass weird formats in ocean.output if ntrc > jptra
+               else
+                  clntrc = TRIM( ctrcnm   (jn)       )
+               endif
                zfact  = rn_trfac(jn)
-               IF( clndta /=  clntrc ) THEN 
-                  CALL ctl_warn( 'trc_dta_init: passive tracer data initialisation :  ',   &
-                  &              'the variable name in the data file : '//clndta//   & 
-                  &              '  must be the same than the name of the passive tracer : '//clntrc//' ')
+               IF( clndta /=  clntrc ) THEN
+                  CALL ctl_warn( 'trc_dta_init: passive tracer data initialisation    ',   &
+                  &              'Input name of data file : '//TRIM(clndta)//   &
+                  &              ' differs from that of tracer : '//TRIM(clntrc)//' ')
                ENDIF
-               WRITE(numout,*) ' read an initial file for passive tracer number :', jn, ' name : ', clndta, & 
-               &               ' multiplicative factor : ', zfact
+               WRITE(numout,'(a, i4,3a,e11.3)') ' Read IC file for tracer number :', &
+               &            jn, ', name : ', TRIM(clndta), ', Multiplicative Scaling factor : ', zfact
             ENDIF
          END DO
@@ -124,5 +130,5 @@
          ALLOCATE( sf_trcdta(nb_trcdta), rf_trfac(nb_trcdta), STAT=ierr1 )
          IF( ierr1 > 0 ) THEN
-            CALL ctl_stop( 'trc_dta_ini: unable to allocate  sf_trcdta structure' )   ;   RETURN
+            CALL ctl_stop( 'trc_dta_init: unable to allocate  sf_trcdta structure' )   ;   RETURN
          ENDIF
          !
@@ -135,5 +141,5 @@
                IF( sn_trcdta(jn)%ln_tint )  ALLOCATE( sf_trcdta(jl)%fdta(jpi,jpj,jpk,2) , STAT=ierr3 )
                IF( ierr2 + ierr3 > 0 ) THEN
-                 CALL ctl_stop( 'trc_dta : unable to allocate passive tracer data arrays' )   ;   RETURN
+                 CALL ctl_stop( 'trc_dta_init : unable to allocate passive tracer data arrays' )   ;   RETURN
                ENDIF
             ENDIF
@@ -141,5 +147,5 @@
          ENDDO
          !                         ! fill sf_trcdta with slf_i and control print
-         CALL fld_fill( sf_trcdta, slf_i, cn_dir, 'trc_dta', 'Passive tracer data', 'namtrc' )
+         CALL fld_fill( sf_trcdta, slf_i, cn_dir, 'trc_dta_init', 'Passive tracer data', 'namtrc' )
          !
       ENDIF
@@ -151,5 +157,5 @@
 
 
-   SUBROUTINE trc_dta( kt, sf_dta )
+   SUBROUTINE trc_dta( kt, sf_dta, ptrfac, ptrc)
       !!----------------------------------------------------------------------
       !!                   ***  ROUTINE trc_dta  ***
@@ -164,9 +170,12 @@
       !!----------------------------------------------------------------------
       INTEGER                     , INTENT(in   ) ::   kt     ! ocean time-step
-      TYPE(FLD), DIMENSION(1)   , INTENT(inout) ::   sf_dta     ! array of information on the field to read
+      TYPE(FLD), DIMENSION(1)     , INTENT(inout) ::   sf_dta     ! array of information on the field to read
+      REAL(wp)                    , INTENT(in   ) ::   ptrfac  ! multiplication factor
+      REAL(wp), DIMENSION(jpi,jpj,jpk), OPTIONAL  , INTENT(out  ) ::   ptrc
       !
       INTEGER ::   ji, jj, jk, jl, jkk, ik    ! dummy loop indices
       REAL(wp)::   zl, zi
       REAL(wp), DIMENSION(jpk) ::  ztp                ! 1D workspace
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta   ! 3D  workspace
       CHARACTER(len=100) :: clndta
       !!----------------------------------------------------------------------
@@ -176,5 +185,8 @@
       IF( nb_trcdta > 0 ) THEN
          !
+         CALL wrk_alloc( jpi, jpj, jpk, ztrcdta )    ! Memory allocation
+         !
          CALL fld_read( kt, 1, sf_dta )      !==   read data at kt time step   ==!
+         ztrcdta(:,:,:) = sf_dta(1)%fnow(:,:,:) * tmask(:,:,:)    ! Mask
          !
          IF( ln_sco ) THEN                   !==   s- or mixed s-zps-coordinate   ==!
@@ -185,51 +197,58 @@
             ENDIF
             !
-               DO jj = 1, jpj                         ! vertical interpolation of T & S
+            DO jj = 1, jpj                         ! vertical interpolation of T & S
+               DO ji = 1, jpi
+                  DO jk = 1, jpk                        ! determines the intepolated T-S profiles at each (i,j) points
+                     zl = fsdept_n(ji,jj,jk)
+                     IF(     zl < gdept_1d(1  ) ) THEN         ! above the first level of data
+                        ztp(jk) = ztrcdta(ji,jj,1)
+                     ELSEIF( zl > gdept_1d(jpk) ) THEN         ! below the last level of data
+                        ztp(jk) =  ztrcdta(ji,jj,jpkm1)
+                     ELSE                                      ! inbetween : vertical interpolation between jkk & jkk+1
+                        DO jkk = 1, jpkm1                                  ! when  gdept(jkk) < zl < gdept(jkk+1)
+                           IF( (zl-gdept_1d(jkk)) * (zl-gdept_1d(jkk+1)) <= 0._wp ) THEN
+                              zi = ( zl - gdept_1d(jkk) ) / (gdept_1d(jkk+1)-gdept_1d(jkk))
+                              ztp(jk) = ztrcdta(ji,jj,jkk) + ( ztrcdta(ji,jj,jkk+1) - &
+                                        ztrcdta(ji,jj,jkk) ) * zi 
+                           ENDIF
+                        END DO
+                     ENDIF
+                  END DO
+                  DO jk = 1, jpkm1
+                    ztrcdta(ji,jj,jk) = ztp(jk) * tmask(ji,jj,jk)     ! mask required for mixed zps-s-coord
+                  END DO
+                  ztrcdta(ji,jj,jpk) = 0._wp
+                END DO
+            END DO
+            ! 
+         ELSE                                !==   z- or zps- coordinate   ==!
+            !
+            IF( ln_zps ) THEN                      ! zps-coordinate (partial steps) interpolation at the last ocean level
+               DO jj = 1, jpj
                   DO ji = 1, jpi
-                     DO jk = 1, jpk                        ! determines the intepolated T-S profiles at each (i,j) points
-                        zl = fsdept_n(ji,jj,jk)
-                        IF(     zl < gdept_1d(1  ) ) THEN         ! above the first level of data
-                           ztp(jk) =  sf_dta(1)%fnow(ji,jj,1)
-                        ELSEIF( zl > gdept_1d(jpk) ) THEN         ! below the last level of data
-                           ztp(jk) =  sf_dta(1)%fnow(ji,jj,jpkm1)
-                        ELSE                                      ! inbetween : vertical interpolation between jkk & jkk+1
-                           DO jkk = 1, jpkm1                                  ! when  gdept(jkk) < zl < gdept(jkk+1)
-                              IF( (zl-gdept_1d(jkk)) * (zl-gdept_1d(jkk+1)) <= 0._wp ) THEN
-                                 zi = ( zl - gdept_1d(jkk) ) / (gdept_1d(jkk+1)-gdept_1d(jkk))
-                                 ztp(jk) = sf_dta(1)%fnow(ji,jj,jkk) + ( sf_dta(1)%fnow(ji,jj,jkk+1) - &
-                                           sf_dta(1)%fnow(ji,jj,jkk) ) * zi 
-                              ENDIF
-                           END DO
-                        ENDIF
-                     END DO
-                     DO jk = 1, jpkm1
-                        sf_dta(1)%fnow(ji,jj,jk) = ztp(jk) * tmask(ji,jj,jk)     ! mask required for mixed zps-s-coord
-                     END DO
-                     sf_dta(1)%fnow(ji,jj,jpk) = 0._wp
+                     ik = mbkt(ji,jj) 
+                     IF( ik > 1 ) THEN
+                        zl = ( gdept_1d(ik) - fsdept_n(ji,jj,ik) ) / ( gdept_1d(ik) - gdept_1d(ik-1) )
+                        ztrcdta(ji,jj,ik) = (1.-zl) * ztrcdta(ji,jj,ik) + zl * ztrcdta(ji,jj,ik-1)
+                     ENDIF
+                     ik = mikt(ji,jj)
+                     IF( ik > 1 ) THEN
+                        zl = ( fsdept_n(ji,jj,ik) - gdept_1d(ik) ) / ( gdept_1d(ik+1) - gdept_1d(ik) )
+                        ztrcdta(ji,jj,ik) = (1.-zl) * ztrcdta(ji,jj,ik) + zl * ztrcdta(ji,jj,ik+1)
+                     ENDIF
                   END DO
                END DO
-            ! 
-         ELSE                                !==   z- or zps- coordinate   ==!
-            !                             
-               sf_dta(1)%fnow(:,:,:) = sf_dta(1)%fnow(:,:,:) * tmask(:,:,:)    ! Mask
-               !
-               IF( ln_zps ) THEN                      ! zps-coordinate (partial steps) interpolation at the last ocean level
-                  DO jj = 1, jpj
-                     DO ji = 1, jpi
-                        ik = mbkt(ji,jj) 
-                        IF( ik > 1 ) THEN
-                           zl = ( gdept_1d(ik) - fsdept_n(ji,jj,ik) ) / ( gdept_1d(ik) - gdept_1d(ik-1) )
-                           sf_dta(1)%fnow(ji,jj,ik) = (1.-zl) * sf_dta(1)%fnow(ji,jj,ik) + zl * sf_dta(1)%fnow(ji,jj,ik-1)
-                        ENDIF
-                        ik = mikt(ji,jj)
-                        IF( ik > 1 ) THEN
-                           zl = ( gdept_0(ji,jj,ik) - gdept_1d(ik) ) / ( gdept_1d(ik+1) - gdept_1d(ik) )
-                           sf_dta(1)%fnow(ji,jj,ik) = (1.-zl) * sf_dta(1)%fnow(ji,jj,ik) + zl * sf_dta(1)%fnow(ji,jj,ik+1)
-                        ENDIF
-                     END DO
-                  END DO
-               ENDIF
-            !
-         ENDIF
+            ENDIF
+            !
+         ENDIF
+         !
+         ! Add multiplicative factor
+         ztrcdta(:,:,:) = ztrcdta(:,:,:) * ptrfac
+         !
+         ! Data structure for trc_ini (and BFMv5.1 coupling)
+         IF( .NOT. PRESENT(ptrc) ) sf_dta(1)%fnow(:,:,:) = ztrcdta(:,:,:)
+         !
+         ! Data structure for trc_dmp
+         IF( PRESENT(ptrc) )  ptrc(:,:,:) = ztrcdta(:,:,:)
          !
          IF( lwp .AND. kt == nit000 ) THEN
@@ -238,11 +257,14 @@
                WRITE(numout,*)
                WRITE(numout,*)'  level = 1'
-               CALL prihre( sf_dta(1)%fnow(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+               CALL prihre( ztrcdta(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
                WRITE(numout,*)'  level = ', jpk/2
-               CALL prihre( sf_dta(1)%fnow(:,:,jpk/2), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+               CALL prihre( ztrcdta(:,:,jpk/2), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
                WRITE(numout,*)'  level = ', jpkm1
-               CALL prihre( sf_dta(1)%fnow(:,:,jpkm1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+               CALL prihre( ztrcdta(:,:,jpkm1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
                WRITE(numout,*)
          ENDIF
+         !
+         CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta )
+         !
       ENDIF
       !
@@ -255,5 +277,5 @@
    !!----------------------------------------------------------------------
 CONTAINS
-   SUBROUTINE trc_dta( kt, sf_dta, zrf_trfac )        ! Empty routine
+   SUBROUTINE trc_dta( kt, sf_dta, ptrfac, ptrc)        ! Empty routine
       WRITE(*,*) 'trc_dta: You should not have seen this print! error?', kt
    END SUBROUTINE trc_dta
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcini.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcini.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcini.F90	(revision 7483)
@@ -26,5 +26,4 @@
    USE trcdta          ! initialisation from files
    USE daymod          ! calendar manager
-   USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
    USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
    USE trcsub          ! variables to substep passive tracers
@@ -123,7 +122,6 @@
                IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
                   jl = n_trc_index(jn) 
-                  CALL trc_dta( nit000, sf_trcdta(jl) )   ! read tracer data at nit000
-                  trn(:,:,:,jn) = sf_trcdta(jl)%fnow(:,:,:) * tmask(:,:,:) * rf_trfac(jl)
-                  !
+                  CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl) )   ! read tracer data at nit000
+                  trn(:,:,:,jn) = sf_trcdta(jl)%fnow(:,:,:) 
                   IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN      !== deallocate data structure   ==!
                      !                                                    (data used only for initialisation)
@@ -143,10 +141,4 @@
  
       tra(:,:,:,:) = 0._wp
-      IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav )   &              ! Partial steps: before horizontal gradient of passive
-        &    CALL zps_hde    ( nit000, jptra, trn, gtru, gtrv  )  ! Partial steps: before horizontal gradient
-      IF( ln_zps .AND. .NOT. lk_c1d .AND.       ln_isfcav )   &
-        &    CALL zps_hde_isf( nit000, jptra, trn, pgtu=gtru, pgtv=gtrv, pgtui=gtrui, pgtvi=gtrvi )       ! tracers at the bottom ocean level
-
-
       !
       IF( nn_dttrc /= 1 )        CALL trc_sub_ini      ! Initialize variables for substepping passive tracers
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcrst.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcrst.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcrst.F90	(revision 7483)
@@ -304,5 +304,5 @@
          IF(lwp) WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), zmean, zmin, zmax, zdrift
       END DO
-      WRITE(numout,*) 
+      IF(lwp) WRITE(numout,*) 
 9000  FORMAT(' tracer nb :',i2,'    name :',a10,'    mean :',e18.10,'    min :',e18.10, &
       &      '    max :',e18.10,'    drift :',e18.10, ' %')
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcstp.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcstp.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcstp.F90	(revision 7483)
@@ -33,5 +33,5 @@
    REAL(wp) :: rdt_sampl
    INTEGER  :: nb_rec_per_day
-   INTEGER  :: isecfst, iseclast
+   REAL(wp) :: rsecfst, rseclast
    LOGICAL  :: llnew
 
@@ -59,5 +59,4 @@
       REAL(wp)              ::  ztrai
       CHARACTER (len=25)    ::  charout 
-
       !!-------------------------------------------------------------------
       !
@@ -94,4 +93,5 @@
                                    CALL trc_sms      ( kt )       ! tracers: sinks and sources
                                    CALL trc_trp      ( kt )       ! transport of passive tracers
+
          IF( kt == nittrc000 ) THEN
             CALL iom_close( numrtr )       ! close input tracer restart file
@@ -105,4 +105,5 @@
       ENDIF
       !
+
       ztrai = 0._wp                                                   !  content of all tracers
       DO jn = 1, jptra
@@ -110,5 +111,5 @@
       END DO
       IF( lwp ) WRITE(numstr,9300) kt,  ztrai / areatot
-9300  FORMAT(i10,e18.10)
+9300  FORMAT(i10,D23.16)
       !
       IF( nn_timing == 1 )   CALL timing_stop('trc_stp')
@@ -130,12 +131,15 @@
       INTEGER, INTENT(in) ::   kt
       INTEGER  :: jn
+      REAL(wp) :: zkt
+      CHARACTER(len=1)               ::   cl1                      ! 1 character
+      CHARACTER(len=2)               ::   cl2                      ! 2 characters
 
       IF( kt == nittrc000 ) THEN
          IF( ln_cpl )  THEN  
-            rdt_sampl = 86400. / ncpl_qsr_freq
+            rdt_sampl = rday / ncpl_qsr_freq
             nb_rec_per_day = ncpl_qsr_freq
          ELSE  
-            rdt_sampl = MAX( 3600., rdt * nn_dttrc )
-            nb_rec_per_day = INT( 86400 / rdt_sampl )
+            rdt_sampl = MAX( 3600., rdttrc(1) )
+            nb_rec_per_day = INT( rday / rdt_sampl )
          ENDIF
          !
@@ -146,29 +150,42 @@
          ENDIF
          !
+         ALLOCATE( qsr_arr(jpi,jpj,nb_rec_per_day ) )
+         !
          !                                            !* Restart: read in restart file
-         IF( ln_rsttr .AND. iom_varid( numrtr, 'qsr_mean', ldstop = .FALSE. ) > 0 ) THEN 
-            IF(lwp) WRITE(numout,*) 'trc_qsr_mean:   qsr_mean read in the restart file'
+         IF( ln_rsttr .AND. iom_varid( numrtr, 'qsr_mean' , ldstop = .FALSE. ) > 0 .AND. &
+                            iom_varid( numrtr, 'qsr_arr_1', ldstop = .FALSE. ) > 0 .AND. &
+                            iom_varid( numrtr, 'ktdcy'    , ldstop = .FALSE. ) > 0 ) THEN 
+            CALL iom_get( numrtr, 'ktdcy', zkt )   !  A mean of qsr
+            rsecfst = INT( zkt ) * rdttrc(1)
+            IF(lwp) WRITE(numout,*) 'trc_qsr_mean:   qsr_mean read in the restart file at time-step rsecfst =', rsecfst, ' s '
             CALL iom_get( numrtr, jpdom_autoglo, 'qsr_mean', qsr_mean )   !  A mean of qsr
+            DO jn = 1, nb_rec_per_day 
+             IF( jn <= 9 )  THEN
+               WRITE(cl1,'(i1)') jn
+               CALL iom_get( numrtr, jpdom_autoglo, 'qsr_arr_'//cl1, qsr_arr(:,:,jn) )   !  A mean of qsr
+             ELSE
+               WRITE(cl2,'(i2.2)') jn
+               CALL iom_get( numrtr, jpdom_autoglo, 'qsr_arr_'//cl2, qsr_arr(:,:,jn) )   !  A mean of qsr
+             ENDIF
+           ENDDO
          ELSE                                         !* no restart: set from nit000 values
             IF(lwp) WRITE(numout,*) 'trc_qsr_mean:   qsr_mean set to nit000 values'
+            rsecfst  = kt * rdttrc(1)
+            !
             qsr_mean(:,:) = qsr(:,:)
-         ENDIF
-         !
-         ALLOCATE( qsr_arr(jpi,jpj,nb_rec_per_day ) )
-         DO jn = 1, nb_rec_per_day
-             qsr_arr(:,:,jn) = qsr_mean(:,:)
-         ENDDO
-         !
-         isecfst  = nsec_year + nsec1jan000   !   number of seconds between Jan. 1st 00h of nit000 year and the middle of time step
-         iseclast = isecfst
-         !
-      ENDIF
-      !
-      iseclast = nsec_year + nsec1jan000
-      llnew   = ( iseclast - isecfst )  > INT( rdt_sampl )   !   new shortwave to store
-      IF( kt /= nittrc000 .AND. llnew ) THEN
+            DO jn = 1, nb_rec_per_day
+               qsr_arr(:,:,jn) = qsr_mean(:,:)
+            ENDDO
+         ENDIF
+         !
+      ENDIF
+      !
+      rseclast = kt * rdttrc(1)
+      !
+      llnew   = ( rseclast - rsecfst ) .ge.  rdt_sampl    !   new shortwave to store
+      IF( llnew ) THEN
           IF( lwp ) WRITE(numout,*) ' New shortwave to sample for TOP at time kt = ', kt, &
-             &                      ' time = ', (iseclast+rdt*nn_dttrc/2.)/3600.,'hours '
-          isecfst = iseclast
+             &                      ' time = ', rseclast/3600.,'hours '
+          rsecfst = rseclast
           DO jn = 1, nb_rec_per_day - 1
              qsr_arr(:,:,jn) = qsr_arr(:,:,jn+1)
@@ -182,7 +199,18 @@
          IF(lwp) WRITE(numout,*) 'trc_mean_qsr : write qsr_mean in restart file  kt =', kt
          IF(lwp) WRITE(numout,*) '~~~~~~~'
+         zkt = REAL( kt, wp )
+         CALL iom_rstput( kt, nitrst, numrtw, 'ktdcy', zkt )
+          DO jn = 1, nb_rec_per_day 
+             IF( jn <= 9 )  THEN
+               WRITE(cl1,'(i1)') jn
+               CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl1, qsr_arr(:,:,jn) )
+             ELSE
+               WRITE(cl2,'(i2.2)') jn
+               CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl2, qsr_arr(:,:,jn) )
+             ENDIF
+         ENDDO
          CALL iom_rstput( kt, nitrst, numrtw, 'qsr_mean', qsr_mean(:,:) )
       ENDIF
-     !
+      !
    END SUBROUTINE trc_mean_qsr
 
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcsub.F90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcsub.F90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/NEMO/TOP_SRC/trcsub.F90	(revision 7483)
@@ -16,10 +16,4 @@
    USE in_out_manager
    USE lbclnk
-#if defined key_zdftke
-   USE zdftke          ! twice TKE (en)
-#endif
-#if defined key_zdfgls
-   USE zdfgls, ONLY: en
-#endif
    USE trabbl
    USE zdf_oce
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/NESTING/agulhas
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/NESTING/agulhas	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/NESTING/agulhas	(revision 7483)
@@ -41,5 +41,5 @@
     N  = 31
     ldbletanh   = .FALSE.
-    ppa2        = 0.0
+    pa2         = 0.0
     ppkth2      = 0.0
     ppacr2      = 0.0
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/NESTING/src/agrif_types.f90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/NESTING/src/agrif_types.f90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/NESTING/src/agrif_types.f90	(revision 7483)
@@ -76,5 +76,5 @@
   NAMELIST /nesting/imin,imax,jmin,jmax,rho,rhot,bathy_update,updated_parent_file      
   !
-  NAMELIST /vertical_grid/ppkth,ppacr,ppdzmin,pphmax,psur,pa0,pa1,N,ldbletanh,ppa2,ppkth2,ppacr2
+  NAMELIST /vertical_grid/ppkth,ppacr,ppdzmin,pphmax,psur,pa0,pa1,N,ldbletanh,pa2,ppkth2,ppacr2
   ! 
   NAMELIST /partial_cells/partial_steps,parent_bathy_meter,parent_batmet_name,e3zps_min,e3zps_rat      
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/REBUILD_NEMO/icb_combrest.py
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/REBUILD_NEMO/icb_combrest.py	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/REBUILD_NEMO/icb_combrest.py	(revision 7483)
@@ -169,13 +169,15 @@
     sys.exit(15)
   fo = Dataset(pathout, 'w')
-  for dim in ['x','y','c']:
+  for dim in ['x','y','c','k']:
     indim = fi.dimensions[dim]
     fo.createDimension(dim, len(indim))
-  for var in ['calving','calving_hflx','stored_ice','stored_heat']:
+  for var in ['kount','calving','calving_hflx','stored_ice','stored_heat']:
     invar = fi.variables[var]
     fo.createVariable(var, invar.datatype, invar.dimensions)
     fo.variables[var][:] = invar[:]
-    fo.variables[var].long_name = invar.long_name
-    fo.variables[var].units = invar.units
+    if "long_name" in invar.ncattrs():
+        fo.variables[var].long_name = invar.long_name
+    if "units" in invar.ncattrs():
+        fo.variables[var].units = invar.units
   os.remove(pathout.replace('.nc','_WORK.nc'))
 #
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/boundary.f90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 7483)
@@ -1529,5 +1529,8 @@
    !> @author J.Paul 
    !> @date November, 2013 - Initial Version 
-   ! 
+   !> @date June, 2016
+   !> - Bug fix: take into account that boundaries are compute on T point,
+   !>   but expressed on U,V point
+   !>
    !> @param[inout] td_bdy boundary structure 
    !> @param[in] td_var    variable structure 
@@ -1552,7 +1555,8 @@
       il_max(jp_west )=td_var%t_dim(2)%i_len
  
-      il_maxindex(jp_north)=td_var%t_dim(2)%i_len-ip_ghost
+      ! index expressed on U,V point, move on T point.
+      il_maxindex(jp_north)=td_var%t_dim(2)%i_len-ip_ghost+1
       il_maxindex(jp_south)=td_var%t_dim(2)%i_len-ip_ghost
-      il_maxindex(jp_east )=td_var%t_dim(1)%i_len-ip_ghost
+      il_maxindex(jp_east )=td_var%t_dim(1)%i_len-ip_ghost+1
       il_maxindex(jp_west )=td_var%t_dim(1)%i_len-ip_ghost
 
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 7483)
@@ -35,5 +35,5 @@
 Here after we briefly describe how to use each programs,
 and so how to create your own regional configuration.
-@note As demonstrator for a first start a set of GLORYS files (global reanalysis on *ORCA025* grid), as well as examples of namelists are available [here](https://cloud.mercator-ocean.fr/public.php?service=files&t=877fb1b6e4f589340fc0df1ea6a53228).
+@note As demonstrator for a first start a set of GLORYS files (global reanalysis on *ORCA025* grid), as well as examples of namelists are available [here](https://cloud.mercator-ocean.fr/public.php?service=files&t=1658ec1aaeda2878f2b3915ed140af37).
 
 <!-- ######################################################################  -->
@@ -440,7 +440,7 @@
 Finally, this **namout** sub-namelist defines the output files.<br/>
 Here we ask for output on 81 processors, with *restart_out.nc* as file "basename".<br/>
-So SIREN computes the optimal layout for 81 porcessors
+So SIREN computes the optimal layout for 81 processors
 available,<br/>
-and split restart on output files named *restart_out_num.nc*, where *num* is the porc number.
+and split restart on output files named *restart_out_num.nc*, where *num* is the proc number.
 
 @note SIREN could also create the other fields you may need for
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 7483)
@@ -3,10 +3,21 @@
 @tableofcontents
 
-# Release
-Initial release (2016-04-11)
+# Release 2016-11-28
 
 ## Changes
 ## New Features
 ## Bug fixes
+ - boundary.f90: take into account that boundaries are compute on T point, but expressed on U,V point
+ - iom_cdf.f90: define type cdf4 as cdf
+
+release (2016-07-01)
+
+## Changes
+## New Features
+## Bug fixes
+ - correct check of boundary indices
+
+# Release
+Initial release (2016-04-11)
 
  <HR>
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/file.f90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/file.f90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/file.f90	(revision 7483)
@@ -495,4 +495,5 @@
          END SELECT
       ELSE
+         CALL logger_debug("FILE INIT: look for file type "//TRIM(file_init%c_name))
          file_init%c_type=TRIM(file_get_type(cd_file))
       ENDIF
@@ -572,4 +573,5 @@
          CASE('.nc','.cdf')
             CALL logger_debug(" FILE GET TYPE: file "//TRIM(cd_file)//" is cdf")
+            ! Warning : type could be change to cdf4 when opening file.
             file_get_type='cdf'
          CASE('.dimg')
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/grid.f90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 7483)
@@ -1341,5 +1341,5 @@
          il_dim(:)=td_var%t_dim(:)%i_len
 
-         CALL logger_debug("GRID GET PERIO: use varibale "//TRIM(td_var%c_name))
+         CALL logger_debug("GRID GET PERIO: use variable "//TRIM(td_var%c_name))
          CALL logger_debug("GRID GET PERIO: fill value "//TRIM(fct_str(td_var%d_fill)))
          CALL logger_debug("GRID GET PERIO: first value "//TRIM(fct_str(td_var%d_value(1,1,1,1))))
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/iom.f90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/iom.f90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/iom.f90	(revision 7483)
@@ -174,4 +174,5 @@
          CASE('cdf')
             CALL iom_cdf_open(td_file)
+         !CASE('cdf4')
          CASE('dimg')
             CALL iom_rstdimg_open(td_file)
@@ -240,4 +241,5 @@
             CALL iom_rstdimg_close(td_file)
          CASE DEFAULT
+            CALL logger_debug( "IOM CLOSE: type "//TRIM(td_file%c_type))
             CALL logger_error( "IOM CLOSE: can't close file "//&
             &               TRIM(td_file%c_name)//": type unknown " )
Index: branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90
===================================================================
--- branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 7070)
+++ branches/CNRS/dev_r6526_PISCES_GAS/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 7483)
@@ -340,6 +340,8 @@
             td_file%c_type='cdf'
          CASE(nf90_format_netcdf4, nf90_format_netcdf4_classic)
-            td_file%c_type='cdf4'
+            td_file%c_type='cdf'
+            !td_file%c_type='cdf4'
       END SELECT
+      CALL logger_debug("IOM CDF GET INFO: type "//TRIM(td_file%c_type)) 
 
       ! record header infos
