Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/ORCA2_LIM3_PISCES/EXP00/namelist_ice_cfg
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/ORCA2_LIM3_PISCES/EXP00/namelist_ice_cfg	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/ORCA2_LIM3_PISCES/EXP00/namelist_ice_cfg	(revision 8752)
@@ -13,5 +13,5 @@
 !!             11 - Ice growth in open water           (namthd_do)
 !!             12 - Ice salinity                       (namthd_sal)
-!!             13 - Ice melt ponds                     (nammp)
+!!             13 - Ice melt ponds                     (namthd_pnd)
 !!             14 - Ice initialization                 (namini)
 !!             15 - Ice/snow albedos                   (namalb)
@@ -20,13 +20,13 @@
 !
 !------------------------------------------------------------------------------
-&nampar     !   Generic parameters
+&nampar         !   Generic parameters
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namitd     !   Ice discretization
+&namitd         !   Ice discretization
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namdyn     !   Ice dynamics
+&namdyn         !   Ice dynamics
 !------------------------------------------------------------------------------
 /
@@ -48,5 +48,5 @@
 /
 !------------------------------------------------------------------------------
-&namthd     !   Ice thermodynamics
+&namthd         !   Ice thermodynamics
 !------------------------------------------------------------------------------
 /
@@ -56,9 +56,9 @@
 /
 !------------------------------------------------------------------------------
-&namthd_da     !   Ice lateral melting
+&namthd_da      !   Ice lateral melting
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namthd_do     !   Ice growth in open water
+&namthd_do      !   Ice growth in open water
 !------------------------------------------------------------------------------
 /
@@ -68,17 +68,17 @@
 /
 !------------------------------------------------------------------------------
-&nammp      !   Melt ponds
+&namthd_pnd     !   Melt ponds
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namini     !   Ice initialization
+&namini         !   Ice initialization
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namalb     !   albedo parameters
+&namalb         !   albedo parameters
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namdia     !   Diagnostics
+&namdia         !   Diagnostics
 !------------------------------------------------------------------------------
 /
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/ORCA2_SAS_LIM3/EXP00/namelist_ice_cfg
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/ORCA2_SAS_LIM3/EXP00/namelist_ice_cfg	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/ORCA2_SAS_LIM3/EXP00/namelist_ice_cfg	(revision 8752)
@@ -1,64 +1,84 @@
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 !! ESIM configuration namelist: Overwrites SHARED/namelist_ice_lim3_ref
-!!              1 - Generic parameters                 (namice_run)
-!!              2 - Ice thickness discretization       (namice_itd)
-!!              3 - Ice dynamics                       (namice_dyn)
-!!              4 - Ice ridging/rafting                (namice_rdgrft)
-!!              5 - Ice rheology                       (namice_rhg)
-!!              6 - Ice advection                      (namice_adv)
-!!              7 - Ice thermodynamics                 (namice_thd)
-!!              8 - Ice salinity                       (namice_sal)
-!!              9 - Ice melt ponds                     (namice_mp)
-!!             10 - Ice initialization                 (namice_ini)
-!!             11 - Ice/snow albedos                   (namice_alb)
-!!             12 - Ice diagnostics                    (namice_dia)
+!!              1 - Generic parameters                 (nampar)
+!!              2 - Ice thickness discretization       (namitd)
+!!              3 - Ice dynamics                       (namdyn)
+!!              4 - Ice ridging/rafting                (namdyn_rdgrft)
+!!              5 - Ice rheology                       (namdyn_rhg)
+!!              6 - Ice advection                      (namdyn_adv)
+!!              7 - Ice surface forcing                (namforcing)
+!!              8 - Ice thermodynamics                 (namthd)
+!!              9 - Ice heat diffusion                 (namthd_zdf)
+!!             10 - Ice lateral melting                (namthd_da)
+!!             11 - Ice growth in open water           (namthd_do)
+!!             12 - Ice salinity                       (namthd_sal)
+!!             13 - Ice melt ponds                     (namthd_pnd)
+!!             14 - Ice initialization                 (namini)
+!!             15 - Ice/snow albedos                   (namalb)
+!!             16 - Ice diagnostics                    (namdia)
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 !
 !------------------------------------------------------------------------------
-&namice_run     !   Generic parameters
+&nampar         !   Generic parameters
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_itd     !   Ice discretization
+&namitd         !   Ice discretization
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_dyn     !   Ice dynamics
+&namdyn         !   Ice dynamics
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_rdgrft  !   Ice ridging/rafting
+&namdyn_rdgrft  !   Ice ridging/rafting
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_rhg     !   Ice rheology
+&namdyn_rhg     !   Ice rheology
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_adv     !   Ice advection
+&namdyn_adv     !   Ice advection
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_thd     !   Ice thermodynamics
+&namforcing     !   Ice surface forcing
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_sal     !   Ice salinity
+&namthd         !   Ice thermodynamics
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namicemp      !   Melt ponds
+&namthd_zdf     !   Ice heat diffusion
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_ini     !   Ice initialization
+&namthd_da      !   Ice lateral melting
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_alb     !   albedo parameters
+&namthd_do      !   Ice growth in open water
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namice_dia     !   Diagnostics
+&namthd_sal     !   Ice salinity
 !------------------------------------------------------------------------------
 /
+!------------------------------------------------------------------------------
+&namthd_pnd     !   Melt ponds
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namini         !   Ice initialization
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namalb         !   albedo parameters
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdia         !   Diagnostics
+!------------------------------------------------------------------------------
+/
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/SHARED/field_def_nemo-lim.xml
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/SHARED/field_def_nemo-lim.xml	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/SHARED/field_def_nemo-lim.xml	(revision 8752)
@@ -132,5 +132,5 @@
          <field id="icevmp"       long_name="melt pond volume"                                             standard_name="sea_ice_meltpond_volume"                            unit="m"            /> 
 
-         <field id="iceconc_cat"  long_name="Sea-ice area fractions in thickness categories"               unit=""   grid_ref="grid_T_3D_ncatice" />
+         <field id="iceconc_cat"  long_name="Sea-ice concentration in thickness categories"                unit=""   grid_ref="grid_T_3D_ncatice" />
          <field id="icethic_cat"  long_name="Sea-ice thickness in thickness categories"                    unit="m"  grid_ref="grid_T_3D_ncatice" />
          <field id="snowthic_cat" long_name="Snow thickness in thickness categories"                       unit="m"  grid_ref="grid_T_3D_ncatice" />
@@ -140,6 +140,8 @@
          <field id="icetemp_cat"  long_name="Ice temperature for categories"                               unit="degC"   grid_ref="grid_T_3D_ncatice" />
          <field id="snwtemp_cat"  long_name="Snow temperature for categories"                              unit="degC"   grid_ref="grid_T_3D_ncatice" />
-         <field id="iceamp_cat"   long_name="Ice melt pond fraction for categories"                        unit="%"      grid_ref="grid_T_3D_ncatice" /> 
+         <field id="iceamp_cat"   long_name="Ice melt pond concentration for categories"                   unit="%"      grid_ref="grid_T_3D_ncatice" /> 
          <field id="icevmp_cat"   long_name="Ice melt pond volume for categories"                          unit="m"      grid_ref="grid_T_3D_ncatice" /> 
+         <field id="icehmp_cat"   long_name="Ice melt pond thickness for categories"                       unit="m"      grid_ref="grid_T_3D_ncatice" /> 
+         <field id="iceafp_cat"   long_name="Ice melt pond fraction for categories"                        unit="m"      grid_ref="grid_T_3D_ncatice" /> 
 
          <field id="micet"        long_name="Mean ice temperature"                                         unit="degC"     />
@@ -186,4 +188,5 @@
          <field id="vfxspr"       long_name="snw precipitation on ice"                                     unit="kg/m2/s"   />
          <field id="vfxthin"      long_name="thermo ice prod. for thin ice(20cm) + open water"             unit="kg/m2/s"   />
+         <field id="vfxpnd"       long_name="melt pond water flux to ocean"                                unit="kg/m2/s"   />
 
          <field id="afxtot"       long_name="area tendency (total)"                                        unit="s-1"   />
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/SHARED/namelist_ice_lim3_ref
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/SHARED/namelist_ice_lim3_ref	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/SHARED/namelist_ice_lim3_ref	(revision 8752)
@@ -13,5 +13,5 @@
 !!             11 - Ice growth in open water           (namthd_do)
 !!             12 - Ice salinity                       (namthd_sal)
-!!             13 - Ice melt ponds                     (nammp)
+!!             13 - Ice melt ponds                     (namthd_pnd)
 !!             14 - Ice initialization                 (namini)
 !!             15 - Ice/snow albedos                   (namalb)
@@ -20,5 +20,5 @@
 !
 !------------------------------------------------------------------------------
-&nampar     !   Generic parameters
+&nampar         !   Generic parameters
 !------------------------------------------------------------------------------
    jpl              =   5             !  number of ice  categories
@@ -39,11 +39,14 @@
 /
 !------------------------------------------------------------------------------
-&namitd     !   Ice discretization
-!------------------------------------------------------------------------------
-   rn_himean        =   2.0           !  expected domain-average ice thickness (m)
+&namitd         !   Ice discretization
+!------------------------------------------------------------------------------
+   ln_cat_hfn       = .true.          !  ice categories are defined by a function following rn_himean**(-0.05)
+      rn_himean     =   2.0           !  expected domain-average ice thickness (m)
+   ln_cat_usr       = .false.         !  ice categories are defined by rn_catbnd below (m)
+      rn_catbnd     =   0.,0.45,1.1,2.1,3.7,6.0  
    rn_himin         =   0.1           !  minimum ice thickness (m) used in remapping
 /
 !------------------------------------------------------------------------------
-&namdyn     !   Ice dynamics
+&namdyn         !   Ice dynamics
 !------------------------------------------------------------------------------
    ln_dynFULL       = .true.          !  dyn.: full ice dynamics               (rheology + advection + ridging/rafting + correction)
@@ -90,5 +93,6 @@
 !------------------------------------------------------------------------------
    ln_rhg_EVP       = .true.          !  EVP rheology
-      rn_creepl     =   1.0e-12       !     creep limit [1/s]
+      ln_aEVP       = .false.         !     adaptive rheology (Kimmritz et al. 2016 & 2017)
+      rn_creepl     =   2.0e-9        !     creep limit [1/s]
       rn_ecc        =   2.0           !     eccentricity of the elliptical yield curve          
       nn_nevp       = 120             !     number of EVP subcycles                             
@@ -118,12 +122,13 @@
                                       !     = 2  Redistribute a single flux over categories
                                       !          ==> coupled mode only
-/
-!------------------------------------------------------------------------------
-&namthd     !   Ice thermodynamics
+   nice_jules       = 1               !  Jules coupling (0=OFF, 1=EMULATED, 2=ACTIVE)
+/
+!------------------------------------------------------------------------------
+&namthd         !   Ice thermodynamics
 !------------------------------------------------------------------------------
    ln_icedH         = .true.          !  activate ice thickness change from growing/melting (T) or not (F)
    ln_icedA         = .true.          !  activate lateral melting param. (T) or not (F)
    ln_icedO         = .true.          !  activate ice growth in open-water (T) or not (F)
-   ln_icedS         = .true.          !  activate gravity drainage and flushing (T) or not (F)
+   ln_icedS         = .true.          !  activate brine drainage (T) or not (F)
 /
 !------------------------------------------------------------------------------
@@ -136,5 +141,4 @@
                                       !     Obs: 0.1-0.5 (Lecomte et al, JAMES 2013)
    rn_kappa_i       =   1.0           !  radiation attenuation coefficient in sea ice [1/m]
-   ln_dqns_i        = .true.          !  change the surface non-solar flux with surface temperature (T) or not (F)
 /
 !------------------------------------------------------------------------------
@@ -150,5 +154,5 @@
 /
 !------------------------------------------------------------------------------
-&namthd_do     !   Ice growth in open water
+&namthd_do      !   Ice growth in open water
 !------------------------------------------------------------------------------
    rn_hinew         =   0.1           !  thickness for new ice formation in open water (m), must be larger than rn_hnewice
@@ -174,15 +178,15 @@
 /
 !------------------------------------------------------------------------------
-&nammp      !   Melt ponds
-!------------------------------------------------------------------------------
-   ln_pnd           = .false.         !  active melt ponds
-   ln_pnd_rad       = .false.         !  active melt ponds radiative coupling
-   ln_pnd_fw        = .false.         !  active melt ponds freshwater coupling
-   nn_pnd_scheme    =   0             !  type of melt pond scheme  : =0 prescribed ( Tsu=0 ), =1 empirical, =2 topographic
-   rn_apnd          =   0.2           !  prescribed pond fraction, at Tsu=0  : (0<rn_apnd<1, nn_pnd_scheme = 0)
-   rn_hpnd          =   0.05          !  prescribed pond depth, at Tsu=0     : (0<rn_apnd<1, nn_pnd_scheme = 0)
-/
-!------------------------------------------------------------------------------
-&namini     !   Ice initialization
+&namthd_pnd     !   Melt ponds
+!------------------------------------------------------------------------------
+   ln_pnd_H12       = .false.         !  activate evolutive melt ponds (from Holland et al 2012)
+      ln_pnd_fwb    = .false.         !     melt ponds store freshwater or not
+   ln_pnd_CST       = .false.         !  activate constant melt ponds
+      rn_apnd       =   0.2           !     prescribed pond fraction, at Tsu=0
+      rn_hpnd       =   0.05          !     prescribed pond depth, at Tsu=0
+   ln_pnd_alb       = .false.         !  melt ponds affect albedo or not
+/
+!------------------------------------------------------------------------------
+&namini         !   Ice initialization
 !------------------------------------------------------------------------------
    ln_iceini        = .true.          !  activate ice initialization (T) or not (F)
@@ -209,19 +213,15 @@
 /
 !------------------------------------------------------------------------------
-&namalb     !   albedo parameters
-!------------------------------------------------------------------------------
-   nn_ice_alb       =    1            !  parameterization of ice/snow albedo
-                                      !     0: Shine & Henderson-Sellers (JGR 1985), giving clear-sky albedo
-                                      !     1: "home made" based on Brandt et al. (JClim 2005)
-                                      !                         and Grenfell & Perovich (JGR 2004), giving cloud-sky albedo
-                                      !     2: as 1 with melt ponds
-   rn_alb_sdry      =   0.85          !  dry snow albedo         : 0.80 (nn_ice_alb = 0); 0.85 (nn_ice_alb = 1); obs 0.85-0.87 (cloud-sky)
-   rn_alb_smlt      =   0.75          !  melting snow albedo     : 0.65 ( '' )          ; 0.75 ( '' )          ; obs 0.72-0.82 ( '' )
-   rn_alb_idry      =   0.60          !  dry ice albedo          : 0.72 ( '' )          ; 0.60 ( '' )          ; obs 0.54-0.65 ( '' )
-   rn_alb_imlt      =   0.50          !  bare puddled ice albedo : 0.53 ( '' )          ; 0.50 ( '' )          ; obs 0.49-0.58 ( '' )
-   rn_alb_dpnd      =   0.27          !  ponded ice albedo       : 0.25 ( '' )          ; 0.27 ( '' )          ; obs 0.10-0.30 ( '' )
-/
-!------------------------------------------------------------------------------
-&namdia     !   Diagnostics
+&namalb         !   albedo parameters
+!------------------------------------------------------------------------------
+   !                                  !                          !  obs range (cloud-sky)
+   rn_alb_sdry      =   0.85          !  dry snow albedo         :  0.85 -- 0.87
+   rn_alb_smlt      =   0.75          !  melting snow albedo     :  0.72 -- 0.82
+   rn_alb_idry      =   0.60          !  dry ice albedo          :  0.54 -- 0.65
+   rn_alb_imlt      =   0.50          !  bare puddled ice albedo :  0.49 -- 0.58
+   rn_alb_dpnd      =   0.27          !  ponded ice albedo       :  0.10 -- 0.30 
+/
+!------------------------------------------------------------------------------
+&namdia         !   Diagnostics
 !------------------------------------------------------------------------------
    ln_icediachk     = .false.         !  check online the heat, mass & salt budgets (T) or not (F)
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/TEST_CASES/SAS_BIPER/EXP00/namelist_ice_cfg
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/TEST_CASES/SAS_BIPER/EXP00/namelist_ice_cfg	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/CONFIG/TEST_CASES/SAS_BIPER/EXP00/namelist_ice_cfg	(revision 8752)
@@ -1,86 +1,94 @@
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-!! LIM3 namelist:  
-!!              1 - Generic parameters                 (namicerun)
-!!              2 - Diagnostics                        (namicediag)
-!!              3 - Ice initialization                 (namiceini)
-!!              4 - Ice discretization                 (namiceitd)
-!!              5 - Ice dynamics and transport         (namicedyn)
-!!              6 - Ice thermodynamics                 (namicethd)
-!!              7 - Ice salinity                       (namicesal)
-!!              8 - Ice mechanical redistribution      (namiceitdme)
-!!              9 - Ice/snow albedos                   (namicealb)
+!! ESIM namelist:  
+!!              1 - Generic parameters                 (nampar)
+!!              2 - Ice thickness discretization       (namitd)
+!!              3 - Ice dynamics                       (namdyn)
+!!              4 - Ice ridging/rafting                (namdyn_rdgrft)
+!!              5 - Ice rheology                       (namdyn_rhg)
+!!              6 - Ice advection                      (namdyn_adv)
+!!              7 - Ice surface forcing                (namforcing)
+!!              8 - Ice thermodynamics                 (namthd)
+!!              9 - Ice heat diffusion                 (namthd_zdf)
+!!             10 - Ice lateral melting                (namthd_da)
+!!             11 - Ice growth in open water           (namthd_do)
+!!             12 - Ice salinity                       (namthd_sal)
+!!             13 - Ice melt ponds                     (namthd_pnd)
+!!             14 - Ice initialization                 (namini)
+!!             15 - Ice/snow albedos                   (namalb)
+!!             16 - Ice diagnostics                    (namdia)
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 !
 !------------------------------------------------------------------------------
-&namicerun     !   Generic parameters
+&nampar         !   Generic parameters
 !------------------------------------------------------------------------------
-   jpl              =    1          !  number of ice  categories
-   nlay_i           =    1          !  number of ice  layers
-   ln_limthd        =  .false.       !  ice thermo   (T) or not (F) => DO NOT TOUCH UNLESS U KNOW WHAT U DO
-   ln_limdyn        =  .true.       !  ice dynamics (T) or not (F) => DO NOT TOUCH UNLESS U KNOW WHAT U DO
-   nn_limdyn        =   0           !     (ln_limdyn=T) switch for ice dynamics
-                                    !      2: total
-                                    !      1: advection only (no diffusion, no ridging/rafting)
-                                    !      0: advection only (as 1 but with prescribed velocity, bypass rheology)
-   rn_uice          =   0.5    !     (nn_limdyn=0) ice u-velocity
-   rn_vice          =   0.0    !     (nn_limdyn=0) ice v-velocity
+   jpl              =   1             !  number of ice  categories
+   nlay_i           =   1             !  number of ice  layers
+   ln_icedyn        = .true.          !  ice dynamics (T) or not (F)
+   ln_icethd        = .false.         !  ice thermo   (T) or not (F)
 /
 !------------------------------------------------------------------------------
-&namicediag    !   Diagnostics
+&namitd         !   Ice discretization
+!------------------------------------------------------------------------------
+   rn_himin         =   0.1           !  minimum ice thickness (m) used in remapping
+/
+!------------------------------------------------------------------------------
+&namdyn         !   Ice dynamics
+!------------------------------------------------------------------------------
+   ln_dynFULL       = .false.         !  dyn.: full ice dynamics               (rheology + advection + ridging/rafting + correction)
+   ln_dynRHGADV     = .false.         !  dyn.: no ridge/raft & no corrections  (rheology + advection)
+   ln_dynADV        = .true.          !  dyn.: only advection w prescribed vel.(rn_uvice + advection)
+      rn_uice       =   0.5           !        prescribed ice u-velocity
+      rn_vice       =   0.            !        prescribed ice v-velocity
+/
+!------------------------------------------------------------------------------
+&namdyn_rdgrft  !   Ice ridging/rafting
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namiceini     !   Ice initialization
-!------------------------------------------------------------------------------
-                  ! -- limistate -- !
-   ln_limini      = .true.         !  activate ice initialization (T) or not (F)
-   ln_limini_file = .true.         !  netcdf file provided for initialization (T) or not (F)
-   cn_dir="./"
-   sn_hti = 'initice'    , -12 ,'hti'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-   sn_hts = 'initice'    , -12 ,'hts'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-   sn_ati = 'initice'    , -12 ,'ati'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-   sn_tsu = 'initice'    , -12 ,'tsu'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-   sn_tmi = 'initice'    , -12 ,'tmi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-   sn_smi = 'initice'    , -12 ,'smi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-/
-!------------------------------------------------------------------------------
-&namiceitd     !   Ice discretization
+&namdyn_rhg     !   Ice rheology
 !------------------------------------------------------------------------------
 /
 !------------------------------------------------------------------------------
-&namicedyn     !   Ice dynamics and transport
+&namdyn_adv     !   Ice advection
 !------------------------------------------------------------------------------
-                  ! -- limtrp & limadv -- !
-   nn_limadv      =    0            !  choose the advection scheme (-1=Prather ; 0=Ultimate-Macho)
-   nn_limadv_ord  =    5            !  choose the order of the advection scheme (if nn_limadv=0)
 /
 !------------------------------------------------------------------------------
-&namicethd     !   Ice thermodynamics
+&namforcing     !   Ice surface forcing
 !------------------------------------------------------------------------------
-                  ! -- limthd_dh -- !
-   ln_limdH       = .true.          !  activate ice thickness change from growing/melting (T) or not (F) => DO NOT TOUCH UNLESS U KNOW WHAT U DO
-                  ! -- limthd_da -- !
-   ln_limdA       = .true.          !  activate lateral melting param. (T) or not (F) => DO NOT TOUCH UNLESS U KNOW WHAT U DO
-                 ! -- limthd_lac -- !
-   ln_limdO       = .true.          !  activate ice growth in open-water (T) or not (F) => DO NOT TOUCH UNLESS U KNOW WHAT U DO
-   rn_hnewice     = 0.02            !  thickness for new ice formation in open water (m)
-                  ! -- limitd_th -- !
-   rn_himin       = 0.01            !  minimum ice thickness (m) used in remapping, must be smaller than rn_hnewice
 /
 !------------------------------------------------------------------------------
-&namicesal     !   Ice salinity
+&namthd         !   Ice thermodynamics
 !------------------------------------------------------------------------------
-                 ! -- limthd_sal -- !
-   ln_limdS       = .true.          !  activate gravity drainage and flushing (T) or not (F) => DO NOT TOUCH UNLESS U KNOW WHAT U DO
 /
 !------------------------------------------------------------------------------
-&namiceitdme   !   Ice mechanical redistribution (ridging and rafting)
+&namthd_zdf     !   Ice heat diffusion
 !------------------------------------------------------------------------------
-                  ! -- limitd_me -- !
-   ln_ridging     =   .true.        !  ridging activated (T) or not (F) => DO NOT TOUCH UNLESS U KNOW WHAT U DO
-   ln_rafting     =   .true.        !  rafting activated (T) or not (F) => DO NOT TOUCH UNLESS U KNOW WHAT U DO
 /
-!-----------------------------------------------------------------------
-&namicealb     !   albedo parameters
-!-----------------------------------------------------------------------
+!------------------------------------------------------------------------------
+&namthd_da      !   Ice lateral melting
+!------------------------------------------------------------------------------
 /
+!------------------------------------------------------------------------------
+&namthd_do      !   Ice growth in open water
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_sal     !   Ice salinity
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_pnd     !   Melt ponds
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namini         !   Ice initialization
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namalb         !   albedo parameters
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdia         !   Diagnostics
+!------------------------------------------------------------------------------
+/
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/ice.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 8752)
@@ -178,4 +178,5 @@
    !
    !                                     !!** ice-rheology namelist (namrhg) **
+   LOGICAL , PUBLIC ::   ln_aEVP          !: using adaptive EVP (T or F) 
    REAL(wp), PUBLIC ::   rn_creepl        !: creep limit : has to be under 1.0e-9
    REAL(wp), PUBLIC ::   rn_ecc           !: eccentricity of the elliptical yield curve
@@ -195,4 +196,10 @@
    !                                      !   = 2  Redistribute a single flux over categories
 
+   INTEGER , PUBLIC            ::   nice_jules            ! Choice of jules coupling 
+   !                                                      ! Associated indices
+   INTEGER , PUBLIC, PARAMETER ::   np_jules_OFF    = 0   ! no Jules coupling (ice thermodynamics forced via qsr and qns)
+   INTEGER , PUBLIC, PARAMETER ::   np_jules_EMULE  = 1   ! emulated Jules coupling via icethd_zdf.F90 (BL99) (1st round compute qcn and qsr_tr, 2nd round use it)
+   INTEGER , PUBLIC, PARAMETER ::   np_jules_ACTIVE = 2   ! active Jules coupling                      (SM0L) (compute qcn and qsr_tr via sbcblk.F90 or sbccpl.F90)
+
    !                                     !!** ice-salinity namelist (namthd_sal) **
    INTEGER , PUBLIC ::   nn_icesal        !: salinity configuration used in the model
@@ -204,13 +211,12 @@
    REAL(wp), PUBLIC ::   rn_simin         !: minimum ice salinity [PSU]
 
-   ! MV MP 2016
-   !                                     !!** melt pond namelist (nammp)
-   LOGICAL , PUBLIC ::   ln_pnd           !: activate ponds or not
-   LOGICAL , PUBLIC ::   ln_pnd_rad       !: ponds radiatively active or not
-   LOGICAL , PUBLIC ::   ln_pnd_fw        !: ponds active wrt meltwater or not
-   INTEGER , PUBLIC ::   nn_pnd_scheme    !: type of melt pond scheme:   =0 prescribed, =1 empirical, =2 topographic
-   REAL(wp), PUBLIC ::   rn_apnd          !: prescribed pond fraction (0<rn_apnd<1), only if nn_pnd_scheme = 0
-   REAL(wp), PUBLIC ::   rn_hpnd          !: prescribed pond depth    (0<rn_hpnd<1), only if nn_pnd_scheme = 0
-   ! END MV MP 2016
+   !                                     !!** namelist namthd_pnd
+   LOGICAL , PUBLIC ::   ln_pnd_H12       !: Melt ponds scheme from Holland et al 2012
+   LOGICAL , PUBLIC ::   ln_pnd_fwb       !: melt ponds store freshwater
+   LOGICAL , PUBLIC ::   ln_pnd_CST       !: Melt ponds scheme with constant fraction and depth
+   REAL(wp), PUBLIC ::   rn_apnd          !: prescribed pond fraction (0<rn_apnd<1)
+   REAL(wp), PUBLIC ::   rn_hpnd          !: prescribed pond depth    (0<rn_hpnd<1)
+   LOGICAL , PUBLIC ::   ln_pnd_alb       !: melt ponds affect albedo
+
    !                                     !!** ice-diagnostics namelist (namdia) **
    LOGICAL , PUBLIC ::   ln_icediachk     !: flag for ice diag (T) or not (F)
Index: anches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/ice1D.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/ice1D.F90	(revision 8751)
+++ 	(revision )
@@ -1,238 +1,0 @@
-MODULE ice1D
-   !!======================================================================
-   !!                       ***  MODULE ice1D  ***
-   !! sea-ice :   Ice thermodynamics variables in 1D
-   !!=====================================================================
-   !! History :  3.0  !  2002-11  (C. Ethe)  F90: Free form and module
-   !!----------------------------------------------------------------------
-#if defined key_lim3
-   !!----------------------------------------------------------------------
-   !!   'key_lim3'                                       ESIM sea-ice model
-   !!----------------------------------------------------------------------
-   USE ice     , ONLY :   nlay_i, nlay_s, jpl   ! number of ice/snow layers and categories
-   !
-   USE in_out_manager ! I/O manager
-   USE lib_mpp        ! MPP library
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   ice1D_alloc   ! called by icestp.F90
-
-   !!----------------------
-   !! * 1D Module variables
-   !!----------------------
-   !: In ice thermodynamics, to spare memory, the vectors are folded
-   !: from 1D to 2D vectors. The following variables, with ending _1d
-   !: are the variables corresponding to 2d vectors
-
-   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   nptidx !: selected points for ice thermo
-   INTEGER , PUBLIC                                  ::   npti   !  number of selected points
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qlead_1d     
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ftr_ice_1d   
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qsr_ice_1d  
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fr1_i0_1d   
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fr2_i0_1d   
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qns_ice_1d  
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   t_bo_1d     
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   rn_amax_1d
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_sum_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_bom_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_bog_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_dif_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_opw_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_snw_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_dyn_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_err_rem_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_err_dif_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_out_1d
-
-   ! heat flux associated with ice-atmosphere mass exchange
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_sub_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_spr_1d
-
-   ! heat flux associated with ice-ocean mass exchange
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_thd_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_res_1d
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_snw_sni_1d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_snw_sum_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_snw_dyn_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_sub_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_snw_sub_1d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_ice_sub_1d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_err_sub_1d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_lam_1d 
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_bog_1d    
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_bom_1d   
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_sum_1d  
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_sni_1d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_opw_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_res_1d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_spr_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_dyn_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_pnd_1d
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_bri_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_bog_1d    
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_bom_1d    
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_sum_1d    
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_sni_1d    
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_opw_1d   
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_res_1d  
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_sub_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_lam_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_dyn_1d
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sprecip_1d    !: <==> the 2D  sprecip
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   at_i_1d        !: <==> the 2D  at_i
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ato_i_1d      !: <==> the 2D  ato_i
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fhtur_1d      !: <==> the 2D  fhtur
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fhld_1d       !: <==> the 2D  fhld
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dqns_ice_1d   !: <==> the 2D  dqns_ice
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   evap_ice_1d   !: <==> the 2D  evap_ice
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qprec_ice_1d  !: <==> the 2D  qprec_ice
-   !                                                     ! to reintegrate longwave flux inside the ice thermodynamics
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   i0            !: fraction of radiation transmitted to the ice
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   t_su_1d       !: <==> the 2D  t_su
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   t_si_1d       !: <==> the 2D  t_si
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   a_i_1d        !: <==> the 2D  a_i
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   a_ib_1d       !: <==> the 2D  a_i_b
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   h_i_1d       !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   h_ib_1d      !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   h_s_1d       !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fc_su         !: Surface Conduction flux 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fc_bo_i       !: Bottom  Conduction flux 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_s_tot      !: Snow accretion/ablation        [m]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_i_surf     !: Ice surface accretion/ablation [m]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_i_sub      !: Ice surface sublimation [m]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_i_bott     !: Ice bottom accretion/ablation  [m]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_snowice    !: Snow ice formation             [m of ice]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   s_i_1d       !: Ice bulk salinity [ppt]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   s_i_new       !: Salinity of new ice at the bottom
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   a_ip_1d       !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   v_ip_1d       !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   v_i_1d        !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   v_s_1d        !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sv_i_1d      !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   oa_i_1d       !:
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   t_s_1d   !: corresponding to the 2D var  t_s
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   t_i_1d   !: corresponding to the 2D var  t_i
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sz_i_1d  !: profiled ice salinity
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e_i_1d   !:    Ice  enthalpy per unit volume
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e_s_1d   !:    Snow enthalpy per unit volume
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   eh_i_old !: ice heat content (q*h, J.m-2)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   h_i_old  !: ice thickness layer (m)
-
-   ! Conduction flux diagnostics (SIMIP)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   diag_fc_bo_1d      !: <==> the 2D  diag_fc_bo
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   diag_fc_su_1d      !: <==> the 2D  diag_fc_su
-
-   ! surface fields from the ocean
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sst_1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sss_1d
-
-   ! 
-   !!----------------------
-   !! * 2D Module variables
-   !!----------------------
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   a_i_2d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   v_i_2d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   v_s_2d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   oa_i_2d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sv_i_2d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   a_ip_2d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   v_ip_2d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   t_su_2d 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   h_i_2d
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   a_ib_2d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   h_ib_2d
-   
-   !!----------------------------------------------------------------------
-   !! NEMO/ICE 4.0 , NEMO Consortium (2017)
-   !! $Id: ice1D.F90 8379 2017-07-26 15:35:49Z clem $
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   FUNCTION ice1D_alloc()
-      !!---------------------------------------------------------------------!
-      !!                ***  ROUTINE ice1D_alloc ***
-      !!---------------------------------------------------------------------!
-      INTEGER ::   ice1D_alloc   ! return value
-      INTEGER ::   ierr(7), ii
-      !!---------------------------------------------------------------------!
-      ierr(:) = 0
-
-      ii = 1
-      ALLOCATE( nptidx   (jpij) ,   &
-         &      qlead_1d (jpij) , ftr_ice_1d(jpij) , qsr_ice_1d (jpij) ,   &
-         &      fr1_i0_1d(jpij) , fr2_i0_1d (jpij) , qns_ice_1d(jpij)  ,   &
-         &      t_bo_1d   (jpij) ,                                         &
-         &      hfx_sum_1d(jpij) , hfx_bom_1d(jpij) ,hfx_bog_1d(jpij) ,    & 
-         &      hfx_dif_1d(jpij) , hfx_opw_1d(jpij) ,hfx_dyn_1d(jpij) ,    &
-         &      rn_amax_1d(jpij) ,                                         &
-         &      hfx_thd_1d(jpij) , hfx_spr_1d(jpij) ,                      &
-         &      hfx_snw_1d(jpij) , hfx_sub_1d(jpij) ,                      &
-         &      hfx_res_1d(jpij) , hfx_err_rem_1d(jpij) , hfx_err_dif_1d(jpij) , hfx_out_1d(jpij), STAT=ierr(ii) )
-      !
-      ii = ii + 1
-      ALLOCATE( sprecip_1d (jpij) , at_i_1d    (jpij) , ato_i_1d(jpij) ,                    &
-         &      fhtur_1d   (jpij) , wfx_snw_sni_1d (jpij) , wfx_spr_1d (jpij) , wfx_snw_sum_1d(jpij) , &
-         &      fhld_1d    (jpij) , wfx_sub_1d (jpij) , wfx_bog_1d (jpij) , wfx_bom_1d(jpij) ,  &
-         &      wfx_sum_1d(jpij)  , wfx_sni_1d (jpij) , wfx_opw_1d (jpij) , wfx_res_1d(jpij) ,  &
-         &      wfx_snw_sub_1d(jpij), wfx_snw_dyn_1d(jpij), wfx_ice_sub_1d(jpij), wfx_err_sub_1d(jpij) ,   &
-         &      wfx_lam_1d(jpij)  , wfx_dyn_1d(jpij), wfx_pnd_1d(jpij),dqns_ice_1d(jpij) , evap_ice_1d (jpij),   &
-         &      qprec_ice_1d(jpij), i0         (jpij) ,                                         &  
-         &      sfx_bri_1d (jpij) , sfx_bog_1d (jpij) , sfx_bom_1d (jpij) , sfx_sum_1d (jpij),  &
-         &      sfx_sni_1d (jpij) , sfx_opw_1d (jpij) , sfx_res_1d (jpij) , sfx_sub_1d (jpij),  &
-         &      sfx_lam_1d (jpij) , sfx_dyn_1d(jpij)  , STAT=ierr(ii) )
-      !
-      ii = ii + 1
-      ALLOCATE( t_su_1d  (jpij) , t_si_1d   (jpij) , a_i_1d  (jpij) , a_ib_1d(jpij) ,                  &
-         &      h_i_1d  (jpij) , h_ib_1d  (jpij) , h_s_1d (jpij) , fc_su  (jpij) , fc_bo_i(jpij) ,  &    
-         &      dh_s_tot (jpij) , dh_i_surf (jpij) , dh_i_sub(jpij) ,                                  &    
-         &      dh_i_bott(jpij) , dh_snowice(jpij) , s_i_1d (jpij) , s_i_new(jpij) , &
-         &      a_ip_1d  (jpij) , v_ip_1d   (jpij) , v_i_1d  (jpij) , v_s_1d (jpij) , &
-         &      sv_i_1d (jpij) , oa_i_1d   (jpij) , STAT=ierr(ii) )
-      !
-      ii = ii + 1
-      ALLOCATE( t_s_1d  (jpij,nlay_s)     , t_i_1d (jpij,nlay_i)     , sz_i_1d(jpij,nlay_i) ,  &            
-         &      e_i_1d  (jpij,nlay_i)     , e_s_1d (jpij,nlay_s)     ,                        &
-         &      eh_i_old(jpij,0:nlay_i+1) , h_i_old(jpij,0:nlay_i+1) , STAT=ierr(ii) )
-      !
-      ii = ii + 1
-      ALLOCATE( diag_fc_bo_1d(jpij)      , diag_fc_su_1d(jpij)      , STAT=ierr(ii) )
-      !
-      ii = ii + 1
-      ALLOCATE( sst_1d(jpij) , sss_1d(jpij) , STAT=ierr(ii) )
-      !
-      ii = ii + 1
-      ALLOCATE( a_i_2d(jpij,jpl) , a_ib_2d(jpij,jpl) , h_i_2d(jpij,jpl) , h_ib_2d(jpij,jpl) , &
-         &      v_i_2d(jpij,jpl) ,v_s_2d(jpij,jpl) ,oa_i_2d(jpij,jpl) ,sv_i_2d(jpij,jpl) ,  &
-         &      a_ip_2d(jpij,jpl) ,v_ip_2d(jpij,jpl) ,t_su_2d(jpij,jpl) ,  &
-         &      STAT=ierr(ii) )
-
-      ice1D_alloc = MAXVAL( ierr(:) )
-      IF( ice1D_alloc /= 0 )   CALL ctl_warn( 'ice1D_alloc: failed to allocate arrays.' )
-      !
-   END FUNCTION ice1D_alloc
-   
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option :         Empty module         NO ESIM sea-ice model
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE ice1D_alloc          ! Empty routine
-   END SUBROUTINE ice1D_alloc
-#endif
- 
-   !!======================================================================
-END MODULE ice1D
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/ice1d.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/ice1d.F90	(revision 8752)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/ice1d.F90	(revision 8752)
@@ -0,0 +1,243 @@
+MODULE ice1D
+   !!======================================================================
+   !!                       ***  MODULE ice1D  ***
+   !! sea-ice :   Ice thermodynamics variables in 1D
+   !!=====================================================================
+   !! History :  3.0  !  2002-11  (C. Ethe)  F90: Free form and module
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3'                                       ESIM sea-ice model
+   !!----------------------------------------------------------------------
+   USE ice     , ONLY :   nlay_i, nlay_s, jpl   ! number of ice/snow layers and categories
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ice1D_alloc   ! called by icestp.F90
+
+   !!----------------------
+   !! * 1D Module variables
+   !!----------------------
+   !: In ice thermodynamics, to spare memory, the vectors are folded
+   !: from 1D to 2D vectors. The following variables, with ending _1d
+   !: are the variables corresponding to 2d vectors
+
+   INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   nptidx !: selected points for ice thermo
+   INTEGER , PUBLIC                                  ::   npti   !  number of selected points
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qlead_1d     
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ftr_ice_1d   
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qsr_ice_1d  
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qns_ice_1d  
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   t_bo_1d     
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   rn_amax_1d
+   
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qml_ice_1d     !: heat available for snow / ice surface melting [W/m2] 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qcn_ice_1d     !: heat available for snow / ice surface sublimation¬ [W/m2] 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qsr_ice_tr_1d  !: solar flux transmitted below the ice surface¬ [W/m2] 
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_sum_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_bom_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_bog_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_dif_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_opw_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_snw_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_dyn_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_err_rem_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_err_dif_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_out_1d
+
+   ! heat flux associated with ice-atmosphere mass exchange
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_sub_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_spr_1d
+
+   ! heat flux associated with ice-ocean mass exchange
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_thd_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   hfx_res_1d
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_snw_sni_1d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_snw_sum_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_snw_dyn_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_sub_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_snw_sub_1d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_ice_sub_1d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_err_sub_1d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_lam_1d 
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_bog_1d    
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_bom_1d   
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_sum_1d  
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_sni_1d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_opw_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_res_1d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_spr_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_dyn_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   wfx_pnd_1d
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_bri_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_bog_1d    
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_bom_1d    
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_sum_1d    
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_sni_1d    
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_opw_1d   
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_res_1d  
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_sub_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_lam_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sfx_dyn_1d
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sprecip_1d    !: <==> the 2D  sprecip
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   at_i_1d       !: <==> the 2D  at_i
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ato_i_1d      !: <==> the 2D  ato_i
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fhtur_1d      !: <==> the 2D  fhtur
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fhld_1d       !: <==> the 2D  fhld
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dqns_ice_1d   !: <==> the 2D  dqns_ice
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   evap_ice_1d   !: <==> the 2D  evap_ice
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   qprec_ice_1d  !: <==> the 2D  qprec_ice
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   t_su_1d       !: <==> the 2D  t_su
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   t_si_1d       !: <==> the 2D  t_si
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   a_i_1d        !: <==> the 2D  a_i
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   a_ib_1d       !: <==> the 2D  a_i_b
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   h_i_1d        !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   h_ib_1d       !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   h_s_1d        !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fc_su         !: Surface Conduction flux 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   fc_bo_i       !: Bottom  Conduction flux 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_s_tot      !: Snow accretion/ablation        [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_i_surf     !: Ice surface accretion/ablation [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_i_sub      !: Ice surface sublimation [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_i_bott     !: Ice bottom accretion/ablation  [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_s_mlt      !: Snow melt [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   dh_snowice    !: Snow ice formation             [m of ice]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   s_i_1d        !: Ice bulk salinity [ppt]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   s_i_new       !: Salinity of new ice at the bottom
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   v_i_1d        !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   v_s_1d        !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sv_i_1d       !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   oa_i_1d       !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   a_ip_1d       !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   v_ip_1d       !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   h_ip_1d       !:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   a_ip_frac_1d  !:
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   t_s_1d      !: corresponding to the 2D var  t_s
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   t_i_1d      !: corresponding to the 2D var  t_i
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sz_i_1d     !: profiled ice salinity
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e_i_1d      !:    Ice  enthalpy per unit volume
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e_s_1d      !:    Snow enthalpy per unit volume
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   eh_i_old    !: ice heat content (q*h, J.m-2)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   h_i_old     !: ice thickness layer (m)
+
+   ! Conduction flux diagnostics (SIMIP)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   diag_fc_bo_1d      !: <==> the 2D  diag_fc_bo
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   diag_fc_su_1d      !: <==> the 2D  diag_fc_su
+
+   ! surface fields from the ocean
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sst_1d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   sss_1d
+
+   ! 
+   !!----------------------
+   !! * 2D Module variables
+   !!----------------------
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   a_i_2d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   v_i_2d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   v_s_2d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   oa_i_2d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sv_i_2d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   a_ip_2d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   v_ip_2d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   t_su_2d 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   h_i_2d
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   a_ib_2d
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   h_ib_2d
+   
+   !!----------------------------------------------------------------------
+   !! NEMO/ICE 4.0 , NEMO Consortium (2017)
+   !! $Id: ice1D.F90 8379 2017-07-26 15:35:49Z clem $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   FUNCTION ice1D_alloc()
+      !!---------------------------------------------------------------------!
+      !!                ***  ROUTINE ice1D_alloc ***
+      !!---------------------------------------------------------------------!
+      INTEGER ::   ice1D_alloc   ! return value
+      INTEGER ::   ierr(7), ii
+      !!---------------------------------------------------------------------!
+      ierr(:) = 0
+
+      ii = 1
+      ALLOCATE( nptidx   (jpij) ,   &
+         &      qlead_1d (jpij) , ftr_ice_1d(jpij) , qsr_ice_1d (jpij) ,   &
+         &      qns_ice_1d(jpij)  ,   &
+         &      qml_ice_1d(jpij), qcn_ice_1d(jpij) , qsr_ice_tr_1d(jpij) , &
+         &      t_bo_1d   (jpij) ,                                         &
+         &      hfx_sum_1d(jpij) , hfx_bom_1d(jpij) ,hfx_bog_1d(jpij) ,    & 
+         &      hfx_dif_1d(jpij) , hfx_opw_1d(jpij) ,hfx_dyn_1d(jpij) ,    &
+         &      rn_amax_1d(jpij) ,                                         &
+         &      hfx_thd_1d(jpij) , hfx_spr_1d(jpij) ,                      &
+         &      hfx_snw_1d(jpij) , hfx_sub_1d(jpij) ,                      &
+         &      hfx_res_1d(jpij) , hfx_err_rem_1d(jpij) , hfx_err_dif_1d(jpij) , hfx_out_1d(jpij), STAT=ierr(ii) )
+      !
+      ii = ii + 1
+      ALLOCATE( sprecip_1d (jpij) , at_i_1d    (jpij) , ato_i_1d(jpij) ,                    &
+         &      fhtur_1d   (jpij) , wfx_snw_sni_1d (jpij) , wfx_spr_1d (jpij) , wfx_snw_sum_1d(jpij) , &
+         &      fhld_1d    (jpij) , wfx_sub_1d (jpij) , wfx_bog_1d (jpij) , wfx_bom_1d(jpij) ,  &
+         &      wfx_sum_1d(jpij)  , wfx_sni_1d (jpij) , wfx_opw_1d (jpij) , wfx_res_1d(jpij) ,  &
+         &      wfx_snw_sub_1d(jpij), wfx_snw_dyn_1d(jpij), wfx_ice_sub_1d(jpij), wfx_err_sub_1d(jpij) ,   &
+         &      wfx_lam_1d(jpij)  , wfx_dyn_1d(jpij), wfx_pnd_1d(jpij),dqns_ice_1d(jpij) , evap_ice_1d (jpij),   &
+         &      qprec_ice_1d(jpij),                                                             &  
+         &      sfx_bri_1d (jpij) , sfx_bog_1d (jpij) , sfx_bom_1d (jpij) , sfx_sum_1d (jpij),  &
+         &      sfx_sni_1d (jpij) , sfx_opw_1d (jpij) , sfx_res_1d (jpij) , sfx_sub_1d (jpij),  &
+         &      sfx_lam_1d (jpij) , sfx_dyn_1d(jpij)  , STAT=ierr(ii) )
+      !
+      ii = ii + 1
+      ALLOCATE( t_su_1d  (jpij) , t_si_1d   (jpij) , a_i_1d  (jpij) , a_ib_1d(jpij) ,                  &
+         &      h_i_1d  (jpij) , h_ib_1d  (jpij) , h_s_1d (jpij) , fc_su  (jpij) , fc_bo_i(jpij) ,  &    
+         &      dh_s_tot (jpij) , dh_i_surf (jpij) , dh_i_sub(jpij) ,                                  &    
+         &      dh_i_bott(jpij) , dh_s_mlt(jpij), dh_snowice(jpij) , s_i_1d (jpij) , s_i_new(jpij) , &
+         &      a_ip_1d  (jpij) , v_ip_1d   (jpij) , v_i_1d  (jpij) , v_s_1d (jpij) , &
+         &      h_ip_1d  (jpij) , a_ip_frac_1d(jpij) , &
+         &      sv_i_1d (jpij) , oa_i_1d   (jpij) , STAT=ierr(ii) )
+      !
+      ii = ii + 1
+      ALLOCATE( t_s_1d  (jpij,nlay_s)     , t_i_1d (jpij,nlay_i)     , sz_i_1d(jpij,nlay_i) ,  &            
+         &      e_i_1d  (jpij,nlay_i)     , e_s_1d (jpij,nlay_s)     ,                        &
+         &      eh_i_old(jpij,0:nlay_i+1) , h_i_old(jpij,0:nlay_i+1) , STAT=ierr(ii) )
+      !
+      ii = ii + 1
+      ALLOCATE( diag_fc_bo_1d(jpij)      , diag_fc_su_1d(jpij)      , STAT=ierr(ii) )
+      !
+      ii = ii + 1
+      ALLOCATE( sst_1d(jpij) , sss_1d(jpij) , STAT=ierr(ii) )
+      !
+      ii = ii + 1
+      ALLOCATE( a_i_2d(jpij,jpl) , a_ib_2d(jpij,jpl) , h_i_2d(jpij,jpl) , h_ib_2d(jpij,jpl) , &
+         &      v_i_2d(jpij,jpl) ,v_s_2d(jpij,jpl) ,oa_i_2d(jpij,jpl) ,sv_i_2d(jpij,jpl) ,  &
+         &      a_ip_2d(jpij,jpl) ,v_ip_2d(jpij,jpl) ,t_su_2d(jpij,jpl) ,  &
+         &      STAT=ierr(ii) )
+
+      ice1D_alloc = MAXVAL( ierr(:) )
+      IF( ice1D_alloc /= 0 )   CALL ctl_warn( 'ice1D_alloc: failed to allocate arrays.' )
+      !
+   END FUNCTION ice1D_alloc
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :         Empty module         NO ESIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE ice1D_alloc          ! Empty routine
+   END SUBROUTINE ice1D_alloc
+#endif
+ 
+   !!======================================================================
+END MODULE ice1D
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icealb.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icealb.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icealb.F90	(revision 8752)
@@ -36,8 +36,4 @@
    !
    ! ** albedo namelist (namalb)
-   INTEGER  ::   nn_ice_alb       ! type of albedo scheme: 0: Shine & Henderson-Sellers (JGR 1985)
-   !                                      !                         1: "home made" based on Brandt et al. (JClim 2005)
-   !                                      !                                             and Grenfell & Perovich (JGR 2004)
-   !                                      !                         2: Same as 1 but with melt ponds
    REAL(wp) ::   rn_alb_sdry      ! dry snow albedo
    REAL(wp) ::   rn_alb_smlt      ! melting snow albedo
@@ -53,5 +49,5 @@
 CONTAINS
 
-   SUBROUTINE ice_alb( pt_ice, ph_ice, ph_snw, pafrac_pnd, ph_pnd, ld_pnd, pa_ice_cs, pa_ice_os )
+   SUBROUTINE ice_alb( pt_su, ph_ice, ph_snw, ld_pnd_alb, pafrac_pnd, ph_pnd, palb_cs, palb_os )
       !!----------------------------------------------------------------------
       !!               ***  ROUTINE ice_alb  ***
@@ -59,10 +55,6 @@
       !! ** Purpose :   Computation of the albedo of the snow/ice system 
       !!       
-      !! ** Method  :   Two schemes are available (from namelist parameter nn_ice_alb)
-      !!                  0: the scheme is that of Shine & Henderson-Sellers (JGR 1985) for clear-skies
-      !!                  1: the scheme is "home made" (for cloudy skies) and based on Brandt et al. (J. Climate 2005)
-      !!                                                                           and Grenfell & Perovich (JGR 2004)
-      !!                  2: fractional surface-based formulation of scheme 1 (NEW)
-      !!                Description of scheme 1:
+      !! ** Method  :   The scheme is "home made" (for cloudy skies) and based on Brandt et al. (J. Climate 2005)
+      !!                                                                      and Grenfell & Perovich (JGR 2004)
       !!                  1) Albedo dependency on ice thickness follows the findings from Brandt et al (2005)
       !!                     which are an update of Allison et al. (JGR 1993) ; Brandt et al. 1999
@@ -76,5 +68,21 @@
       !!                  4) The needed 4 parameters are: dry and melting snow, freezing ice and bare puddled ice
       !!
-      !! ** Note    :   The parameterization from Shine & Henderson-Sellers presents several misconstructions:
+      !!                     compilation of values from literature (reference overcast sky values)
+      !!                        rn_alb_sdry = 0.85      ! dry snow
+      !!                        rn_alb_smlt = 0.75      ! melting snow
+      !!                        rn_alb_idry = 0.60      ! bare frozen ice
+      !!                        rn_alb_imlt = 0.50      ! bare puddled ice albedo
+      !!                        rn_alb_dpnd = 0.36      ! ponded-ice overcast albedo (Lecomte et al, 2015)
+      !!                                                ! early melt pnds 0.27, late melt ponds 0.14 Grenfell & Perovich
+      !!                     Perovich et al 2002 (Sheba) => the only dataset for which all types of ice/snow were retrieved
+      !!                        rn_alb_sdry = 0.85      ! dry snow
+      !!                        rn_alb_smlt = 0.72      ! melting snow
+      !!                        rn_alb_idry = 0.65      ! bare frozen ice
+      !!                     Brandt et al 2005 (East Antarctica)
+      !!                        rn_alb_sdry = 0.87      ! dry snow
+      !!                        rn_alb_smlt = 0.82      ! melting snow
+      !!                        rn_alb_idry = 0.54      ! bare frozen ice
+      !!
+      !! ** Note    :   The old parameterization from Shine & Henderson-Sellers (not here anymore) presented several misconstructions
       !!                  1) ice albedo when ice thick. tends to 0 is different than ocean albedo
       !!                  2) for small ice thick. covered with some snow (<3cm?), albedo is larger 
@@ -87,218 +95,81 @@
       !!                Grenfell & Perovich 2004, JGR, vol 109 
       !!----------------------------------------------------------------------
-      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pt_ice       !  ice surface temperature (Kelvin)
+      REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pt_su        !  ice surface temperature (Kelvin)
       REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   ph_ice       !  sea-ice thickness
       REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   ph_snw       !  snow depth
+      LOGICAL , INTENT(in   )                   ::   ld_pnd_alb   !  effect of melt ponds on albedo
       REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   pafrac_pnd   !  melt pond relative fraction (per unit ice area)
       REAL(wp), INTENT(in   ), DIMENSION(:,:,:) ::   ph_pnd       !  melt pond depth
-      LOGICAL , INTENT(in   )                   ::   ld_pnd       !  melt ponds radiatively active or not
-      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pa_ice_cs    !  albedo of ice under clear    sky
-      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   pa_ice_os    !  albedo of ice under overcast sky
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   palb_cs      !  albedo of ice under clear    sky
+      REAL(wp), INTENT(  out), DIMENSION(:,:,:) ::   palb_os      !  albedo of ice under overcast sky
       !
       INTEGER  ::   ji, jj, jl                ! dummy loop indices
-      REAL(wp) ::   zswitch, z1_c1, z1_c2     ! local scalar
-      REAL(wp) ::   z1_href_pnd               !   -      -                 
-      REAL(wp) ::   zalb_sm, zalb_sf, zalb_st ! albedo of snow melting, freezing, total
-      !
-      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalb, zalb_it   ! intermediate variable & albedo of ice (snow free)
-!! MV MP
-      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalb_pnd        ! ponded sea ice albedo
-      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalb_ice        ! bare sea ice albedo
-      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalb_snw        ! snow-covered sea ice albedo
-      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zafrac_snw      ! relative snow fraction
-      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zafrac_ice      ! relative ice fraction
-      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zafrac_pnd      ! relative ice fraction (effective)
+      REAL(wp) ::   z1_c1, z1_c2,z1_c3, z1_c4 ! local scalar
+      REAL(wp) ::   z1_href_pnd               ! inverse of the characteristic length scale (Lecomte et al. 2015)
+      REAL(wp) ::   zalb_pnd, zafrac_pnd      ! ponded sea ice albedo & relative pound fraction
+      REAL(wp) ::   zalb_ice, zafrac_ice      ! bare sea ice albedo & relative ice fraction
+      REAL(wp) ::   zalb_snw, zafrac_snw      ! snow-covered sea ice albedo & relative snow fraction
       !!---------------------------------------------------------------------
       !
       IF( nn_timing == 1 )   CALL timing_start('icealb')
       !
-      !-----------------------------------------------------
-      !  Snow-free albedo (no ice thickness dependence yet)
-      !-----------------------------------------------------
-      !
-      ! Part common to nn_ice_alb = 0, 1, 2
-      !
-      IF ( .NOT. ld_pnd ) THEN   !--- No melt ponds OR radiatively inactive melt ponds
-         ! Bare ice albedo is prescribed, with implicit assumption on pond fraction and depth
-         WHERE     ( ph_snw == 0._wp .AND. pt_ice >= rt0 )   ;   zalb(:,:,:) = rn_alb_imlt
-         ELSEWHERE                                           ;   zalb(:,:,:) = rn_alb_idry
-         END WHERE
-      ENDIF
-
-      SELECT CASE ( nn_ice_alb )       ! select a parameterization
-      !
-      !              !------------------------------------------
-      CASE( 0 )      !  Shine and Henderson-Sellers (1985)     !   (based on clear sky values)
-         !           !------------------------------------------
-         !
-         !                       ! Thickness-dependent bare ice albedo
-         WHERE    ( 1.5  < ph_ice                     )   ;   zalb_it = zalb
-         ELSEWHERE( 1.0  < ph_ice .AND. ph_ice <= 1.5 )   ;   zalb_it = 0.472  + 2.0 * ( zalb - 0.472 ) * ( ph_ice - 1.0 )
-         ELSEWHERE( 0.05 < ph_ice .AND. ph_ice <= 1.0 )   ;   zalb_it = 0.2467 + 0.7049 * ph_ice              &
-            &                                                                  - 0.8608 * ph_ice * ph_ice     &
-            &                                                                  + 0.3812 * ph_ice * ph_ice * ph_ice
-         ELSEWHERE                                        ;   zalb_it = 0.1    + 3.6    * ph_ice
-         END WHERE
-         !
-         IF ( ld_pnd ) THEN      ! Depth-dependent ponded ice albedo
-            z1_href_pnd = 1. / 0.05    ! inverse of the characteristic length scale (Lecomte et al. 2015)
-            zalb_pnd  = rn_alb_dpnd - ( rn_alb_dpnd - zalb_it ) * EXP( - ph_pnd * z1_href_pnd ) 
-            !                          ! Snow-free ice albedo is a function of pond fraction
-            WHERE ( ph_snw == 0._wp .AND. pt_ice >= rt0 )   
-               zalb_it = zalb_it * ( 1. - pafrac_pnd  ) + zalb_pnd * pafrac_pnd 
-            END WHERE
-         ENDIF 
-         !
-         DO jl = 1, jpl
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  !                    ! Freezing snow
-                  ! no effect of underlying ice layer IF snow thickness > c1. Albedo does not depend on snow thick if > ppc2
-                  zswitch = 1._wp - MAX( 0._wp , SIGN( 1._wp , - ( ph_snw(ji,jj,jl) - ppc1 ) ) )
-                  zalb_sf = ( 1._wp - zswitch ) * (  zalb_it(ji,jj,jl)  &
-                     &                                   + ph_snw(ji,jj,jl) * ( rn_alb_sdry - zalb_it(ji,jj,jl) ) * pp1_c1  )   &
-                     &    +           zswitch   * rn_alb_sdry  
-                     !
-                  !                    ! Melting snow
-                  ! no effect of underlying ice layer. Albedo does not depend on snow thick IF > ppc2
-                  zswitch = MAX( 0._wp , SIGN( 1._wp , ph_snw(ji,jj,jl) - ppc2 ) )
-                  zalb_sm = ( 1._wp - zswitch ) * ( rn_alb_imlt + ph_snw(ji,jj,jl) * ( rn_alb_smlt - rn_alb_imlt ) * pp1_c2 )   &
-                     &      +         zswitch   *   rn_alb_smlt 
-                     !
-                  !                    ! Snow albedo
-                  zswitch =  MAX( 0._wp , SIGN( 1._wp , pt_ice(ji,jj,jl) - rt0_snow ) )   
-                  zalb_st =  zswitch * zalb_sm + ( 1._wp - zswitch ) * zalb_sf
-                  !
-                  !                    ! Surface albedo
-                  zswitch             = 1._wp - MAX( 0._wp , SIGN( 1._wp , - ph_snw(ji,jj,jl) ) )
-                  pa_ice_cs(ji,jj,jl) = zswitch * zalb_st + ( 1._wp - zswitch ) * zalb_it(ji,jj,jl)
-                  !
-               END DO
+      z1_href_pnd = 0.05
+      z1_c1 = 1. / ( LOG(1.5) - LOG(0.05) ) 
+      z1_c2 = 1. / 0.05
+      z1_c3 = 1. / 0.02
+      z1_c4 = 1. / 0.03
+      !
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               !                       !--- Specific snow, ice and pond fractions (for now, we prevent melt ponds and snow at the same time)
+               IF( ph_snw(ji,jj,jl) == 0._wp ) THEN
+                  zafrac_snw = 0._wp
+                  IF( ld_pnd_alb ) THEN
+                     zafrac_pnd = pafrac_pnd(ji,jj,jl)
+                  ELSE
+                     zafrac_pnd = 0._wp
+                  ENDIF
+                  zafrac_ice = 1._wp - zafrac_pnd
+               ELSE
+                  zafrac_snw = 1._wp      ! Snow fully "shades" melt ponds and ice
+                  zafrac_pnd = 0._wp
+                  zafrac_ice = 0._wp
+               ENDIF
+               !
+               !                       !--- Bare ice albedo (for hi > 150cm)
+               IF( ld_pnd_alb ) THEN
+                  zalb_ice = rn_alb_idry
+               ELSE
+                  IF( ph_snw(ji,jj,jl) == 0._wp .AND. pt_su(ji,jj,jl) >= rt0 ) THEN  ;   zalb_ice = rn_alb_imlt
+                  ELSE                                                               ;   zalb_ice = rn_alb_idry   ;   ENDIF
+               ENDIF
+               !                       !--- Bare ice albedo (for hi < 150cm)
+               IF( 0.05 < ph_ice(ji,jj,jl) .AND. ph_ice(ji,jj,jl) <= 1.5 ) THEN      ! 5cm < hi < 150cm
+                  zalb_ice = zalb_ice    + ( 0.18 - zalb_ice   ) * z1_c1 * ( LOG(1.5) - LOG(ph_ice(ji,jj,jl)) )
+               ELSEIF( ph_ice(ji,jj,jl) <= 0.05 ) THEN                               ! 0cm < hi < 5cm
+                  zalb_ice = rn_alb_oce  + ( 0.18 - rn_alb_oce ) * z1_c2 * ph_ice(ji,jj,jl)
+               ENDIF
+               !
+               !                       !--- Snow-covered ice albedo (freezing, melting cases)
+               IF( pt_su(ji,jj,jl) < rt0_snow ) THEN
+                  zalb_snw = rn_alb_sdry - ( rn_alb_sdry - zalb_ice ) * EXP( - ph_snw(ji,jj,jl) * z1_c3 )
+               ELSE
+                  zalb_snw = rn_alb_smlt - ( rn_alb_smlt - zalb_ice ) * EXP( - ph_snw(ji,jj,jl) * z1_c4 )
+               ENDIF
+               !                       !--- Ponded ice albedo
+               IF( ld_pnd_alb ) THEN
+                  zalb_pnd = rn_alb_dpnd - ( rn_alb_dpnd - zalb_ice ) * EXP( - ph_pnd(ji,jj,jl) * z1_href_pnd ) 
+               ELSE
+                  zalb_pnd = rn_alb_dpnd
+               ENDIF
+               !                       !--- Surface albedo is weighted mean of snow, ponds and bare ice contributions
+               palb_os(ji,jj,jl) = zafrac_snw * zalb_snw + zafrac_pnd * zalb_pnd + zafrac_ice * zalb_ice
+               !
             END DO
          END DO
-         !
-         pa_ice_os(:,:,:) = pa_ice_cs(:,:,:) + ppcloud       ! Oberhuber correction for overcast sky
-         !
-         !
-         !           !------------------------------------------
-      CASE( 1 )      !  New parameterization (2016)            !    (based on overcast sky values)
-         !           !------------------------------------------
-         !
-         !                    compilation of values from literature (reference overcast sky values)
-         !                          rn_alb_sdry = 0.85      ! dry snow
-         !                          rn_alb_smlt = 0.75      ! melting snow
-         !                          rn_alb_idry = 0.60      ! bare frozen ice
-         !                          rn_alb_dpnd = 0.36      ! ponded-ice overcast albedo (Lecomte et al, 2015)
-         !                                                  ! early melt pnds 0.27, late melt ponds 0.14 Grenfell & Perovich
-         !                    Perovich et al 2002 (Sheba) => the only dataset for which all types of ice/snow were retrieved
-         !                          rn_alb_sdry = 0.85      ! dry snow
-         !                          rn_alb_smlt = 0.72      ! melting snow
-         !                          rn_alb_idry = 0.65      ! bare frozen ice
-         !                    Brandt et al 2005 (East Antarctica)
-         !                          rn_alb_sdry = 0.87      ! dry snow
-         !                          rn_alb_smlt = 0.82      ! melting snow
-         !                          rn_alb_idry = 0.54      ! bare frozen ice
-         ! 
-         !              !--- Computation of snow-free ice albedo 
-         z1_c1 = 1. / ( LOG(1.5) - LOG(0.05) ) 
-         z1_c2 = 1. / 0.05
-
-         !              !--- Accounting for the ice-thickness dependency
-         WHERE     ( 1.5  < ph_ice                     )   ;   zalb_it = zalb
-         ELSE WHERE( 0.05 < ph_ice .AND. ph_ice <= 1.5 )   ;   zalb_it = zalb + ( 0.18 - zalb ) * z1_c1 * ( LOG(1.5) - LOG(ph_ice) )
-         ELSE WHERE                                        ;   zalb_it = rn_alb_oce + ( 0.18 - rn_alb_oce ) * z1_c2 * ph_ice
-         END WHERE
-         !
-         IF ( ld_pnd ) THEN      ! Depth-dependent ponded ice albedo
-            z1_href_pnd = 0.05        ! inverse of the characteristic length scale (Lecomte et al. 2015)
-            zalb_pnd  = rn_alb_dpnd - ( rn_alb_dpnd - zalb_it ) * EXP( - ph_pnd * z1_href_pnd ) 
-            !
-            !                    ! Snow-free ice albedo is weighted mean of ponded ice and bare ice contributions
-            WHERE ( ph_snw == 0._wp .AND. pt_ice >= rt0 )
-               zalb_it = zalb_it * ( 1. - pafrac_pnd  ) + zalb_pnd * pafrac_pnd
-            END WHERE
-         ENDIF 
-         !
-         !              !--- Overcast sky surface albedo (accounting for snow, ice melt ponds)
-         z1_c1 = 1. / 0.02
-         z1_c2 = 1. / 0.03
-         DO jl = 1, jpl
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  ! Snow depth dependence of snow albedo
-                  zalb_sf = rn_alb_sdry - ( rn_alb_sdry - zalb_it(ji,jj,jl)) * EXP( - ph_snw(ji,jj,jl) * z1_c1 );
-                  zalb_sm = rn_alb_smlt - ( rn_alb_smlt - zalb_it(ji,jj,jl)) * EXP( - ph_snw(ji,jj,jl) * z1_c2 );
-
-                  ! Snow albedo (MV I guess we could use rt0 instead of rt0_snow)
-                  zswitch = MAX( 0._wp , SIGN( 1._wp , pt_ice(ji,jj,jl) - rt0_snow ) )   
-                  zalb_st = zswitch * zalb_sm + ( 1._wp - zswitch ) * zalb_sf
-
-                  ! Surface albedo   
-                  zswitch             = MAX( 0._wp , SIGN( 1._wp , - ph_snw(ji,jj,jl) ) )
-                  pa_ice_os(ji,jj,jl) = ( 1._wp - zswitch ) * zalb_st + zswitch *  zalb_it(ji,jj,jl)
-
-              END DO
-            END DO
-         END DO
-         !
-         !              !--- Clear sky surface albedo
-         pa_ice_cs = pa_ice_os - ( - 0.1010 * pa_ice_os * pa_ice_os + 0.1933 * pa_ice_os - 0.0148 ); 
-         !
-         !
-         !           !------------------------------------------
-      CASE( 2 )      !  Fractional surface-based parameterization (2017)
-         !           !------------------------------------------
-         !              MV: I propose this formulation that is more elegant, and more easy to expand towards
-         !              varying pond and snow fraction.
-         !              Formulation 1 has issues to handle ponds and snow together that can't easily be fixed. 
-         !              This one handles it better, I believe.
-         !
-         !                 !==  Snow, bare ice and ponded ice fractions  ==!
-         !
-         !                       ! Specific fractions (zafrac) refer to relative area covered by snow within each ice category
-         !
-         !                       !--- Effective pond fraction (for now, we prevent melt ponds and snow at the same time)
-         zafrac_pnd = 0._wp
-         IF ( ld_pnd ) THEN
-            WHERE( ph_snw == 0._wp )   zafrac_pnd = pafrac_pnd   ! Snow fully "shades" melt ponds
-         ENDIF         
-         !
-         !                       !--- Specific snow fraction (for now, prescribed)
-         WHERE( ph_snw > 0._wp )   ;   zafrac_snw = 1.
-         ELSEWHERE                 ;   zafrac_snw = 0.
-         END WHERE
-         !
-         !                       !--- Specific ice fraction 
-         zafrac_ice = 1. - zafrac_snw - zafrac_pnd
-         !
-         !                 !==  Snow-covered, pond-covered, and bare ice albedos  ==!
-         !
-         !                       !--- Bare ice albedo
-         z1_c1 = 1. / ( LOG(1.5) - LOG(0.05) ) 
-         z1_c2 = 1. / 0.05
-         WHERE    ( 1.5  < ph_ice                     )   ;   zalb_ice = zalb
-         ELSEWHERE( 0.05 < ph_ice .AND. ph_ice <= 1.5 )   ;   zalb_ice = zalb       + ( 0.18 - zalb       ) * z1_c1 *  &
-            &                                                                       ( LOG(1.5) - LOG(ph_ice) )
-         ELSEWHERE                                        ;   zalb_ice = rn_alb_oce + ( 0.18 - rn_alb_oce ) * z1_c2 * ph_ice
-         END WHERE
-         !
-         z1_c1 = 1. / 0.02       !--- Snow-covered ice albedo (freezing, melting cases)
-         z1_c2 = 1. / 0.03
-         !
-         WHERE( pt_ice < rt0_snow )   ;   zalb_snw = rn_alb_sdry - ( rn_alb_sdry - zalb_ice ) * EXP( - ph_snw * z1_c1 )
-         ELSEWHERE                    ;   zalb_snw = rn_alb_smlt - ( rn_alb_smlt - zalb_ice ) * EXP( - ph_snw * z1_c2 )
-         END WHERE
-         !
-         IF ( ld_pnd ) THEN      !--- Depth-dependent ponded ice albedo
-            z1_href_pnd = 0.05        ! inverse of the characteristic length scale (Lecomte et al. 2015)
-            zalb_pnd  = rn_alb_dpnd - ( rn_alb_dpnd - zalb_ice ) * EXP( - ph_pnd * z1_href_pnd ) 
-         ELSE
-            zalb_pnd  = rn_alb_dpnd
-         ENDIF
-         !                       !--- Surface albedo is weighted mean of snow, ponds and bare ice contributions
-         pa_ice_os = zafrac_snw * zalb_snw  +  zafrac_pnd * zalb_pnd  +  zafrac_ice * zalb_ice
-         pa_ice_cs = pa_ice_os - ( - 0.1010 * pa_ice_os * pa_ice_os + 0.1933 * pa_ice_os - 0.0148 )
-
-      END SELECT
+      END DO
+      !
+      palb_cs(:,:,:) = palb_os(:,:,:) - ( - 0.1010 * palb_os(:,:,:) * palb_os(:,:,:) + 0.1933 * palb_os(:,:,:) - 0.0148 )
       !
       IF( nn_timing == 1 )   CALL timing_stop('icealb')
@@ -317,5 +188,5 @@
       INTEGER  ::   ios                 ! Local integer output status for namelist read
       !!
-      NAMELIST/namalb/ nn_ice_alb, rn_alb_sdry, rn_alb_smlt, rn_alb_idry, rn_alb_imlt, rn_alb_dpnd
+      NAMELIST/namalb/ rn_alb_sdry, rn_alb_smlt, rn_alb_idry, rn_alb_imlt, rn_alb_dpnd
       !!----------------------------------------------------------------------
       !
@@ -334,5 +205,4 @@
          WRITE(numout,*) '~~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist namalb:'
-         WRITE(numout,*) '      choose the albedo parameterization   nn_ice_alb  = ', nn_ice_alb
          WRITE(numout,*) '      albedo of dry snow                   rn_alb_sdry = ', rn_alb_sdry
          WRITE(numout,*) '      albedo of melting snow               rn_alb_smlt = ', rn_alb_smlt
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icectl.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icectl.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icectl.F90	(revision 8752)
@@ -76,7 +76,8 @@
       IF( icount == 0 ) THEN
          !                          ! water flux
-         pdiag_fv = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:)     + wfx_sum(:,:)     + wfx_sni(:,:)     +                     &
-            &                    wfx_opw(:,:) + wfx_res(:,:)     + wfx_dyn(:,:)     + wfx_lam(:,:)     + wfx_ice_sub(:,:) +  &
-            &                    wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) + wfx_spr(:,:)    &
+         pdiag_fv = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) +                  &
+            &                    wfx_opw(:,:) + wfx_res(:,:) + wfx_dyn(:,:) + wfx_lam(:,:) + wfx_pnd(:,:)  +  &
+            &                    wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) +  &
+            &                    wfx_ice_sub(:,:) + wfx_spr(:,:)  &
             &                  ) * e1e2t(:,:) ) * zconv
          !
@@ -96,12 +97,13 @@
 
          pdiag_t = glob_sum( (  SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 )     &
-            &                 + SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 )   ) * e1e2t ) * zconv
+            &                 + SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 ) ) * e1e2t ) * zconv
 
       ELSEIF( icount == 1 ) THEN
 
          ! water flux
-         zfv  = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:)     + wfx_sum(:,:)     + wfx_sni(:,:)     +                     &
-            &                wfx_opw(:,:) + wfx_res(:,:)     + wfx_dyn(:,:)     + wfx_lam(:,:)     + wfx_ice_sub(:,:) +  &
-            &                wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) + wfx_spr(:,:)        &
+         zfv  = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) +                  &
+            &                wfx_opw(:,:) + wfx_res(:,:) + wfx_dyn(:,:) + wfx_lam(:,:) + wfx_pnd(:,:)  +  &
+            &                wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) +  &
+            &                wfx_ice_sub(:,:) + wfx_spr(:,:)  &
             &              ) * e1e2t(:,:) ) * zconv - pdiag_fv
 
@@ -117,8 +119,8 @@
  
          ! outputs
-         zv = ( ( glob_sum( SUM( v_i * rhoic + v_s * rhosn, dim=3 ) * e1e2t  ) * zconv  &
+         zv = ( ( glob_sum( SUM( v_i * rhoic + v_s * rhosn, dim=3 ) * e1e2t ) * zconv  &
             &     - pdiag_v ) * r1_rdtice - zfv ) * rday
 
-         zs = ( ( glob_sum( SUM( sv_i * rhoic            , dim=3 ) * e1e2t ) * zconv  &
+         zs = ( ( glob_sum( SUM( sv_i * rhoic             , dim=3 ) * e1e2t ) * zconv  &
             &     - pdiag_s ) * r1_rdtice + zfs ) * rday
 
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn.F90	(revision 8752)
@@ -172,9 +172,7 @@
             END DO
          END DO
-      END DO
-            
-      IF ( nn_pnd_scheme > 0 ) THEN               !-- correct pond fraction to avoid a_ip > a_i
-         WHERE( a_ip(:,:,:) > a_i(:,:,:) )   a_ip(:,:,:) = a_i(:,:,:)
-      ENDIF
+      END DO 
+      !                                           !-- correct pond fraction to avoid a_ip > a_i
+      WHERE( a_ip(:,:,:) > a_i(:,:,:) )   a_ip(:,:,:) = a_i(:,:,:)
       !
    END SUBROUTINE Hbig
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_adv_pra.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_adv_pra.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_adv_pra.F90	(revision 8752)
@@ -120,5 +120,5 @@
             z0ei(:,:,jk,jl) = pe_i(:,:,jk,jl) * e1e2t(:,:) ! Ice  heat content
          END DO
-         IF ( nn_pnd_scheme > 0 ) THEN
+         IF ( ln_pnd_H12 ) THEN
             z0ap(:,:,jl)  = pa_ip(:,:,jl) * e1e2t(:,:)     ! Melt pond fraction
             z0vp(:,:,jl)  = pv_ip(:,:,jl) * e1e2t(:,:)     ! Melt pond volume
@@ -167,5 +167,5 @@
                      &                                      syye(:,:,jk,jl), sxye(:,:,jk,jl) )
                END DO
-               IF ( nn_pnd_scheme > 0 ) THEN
+               IF ( ln_pnd_H12 ) THEN
                   CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0ap  (:,:,jl), sxap (:,:,jl),   &    !--- melt pond fraction --
                      &                                      sxxap (:,:,jl), syap (:,:,jl), syyap (:,:,jl), sxyap (:,:,jl)  )
@@ -220,5 +220,5 @@
                      &                                      syye(:,:,jk,jl), sxye(:,:,jk,jl) )
                END DO
-               IF ( nn_pnd_scheme > 0 ) THEN
+               IF ( ln_pnd_H12 ) THEN
                   CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0ap  (:,:,jl), sxap (:,:,jl),   &   !--- melt pond fraction ---
                      &                                      sxxap (:,:,jl), syap (:,:,jl), syyap (:,:,jl), sxyap (:,:,jl)  )
@@ -249,5 +249,5 @@
          END DO
          ! MV MP 2016
-         IF ( nn_pnd_scheme > 0 ) THEN
+         IF ( ln_pnd_H12 ) THEN
             pa_ip  (:,:,jl)   = z0ap (:,:,jl) * r1_e1e2t(:,:)
             pv_ip  (:,:,jl)   = z0vp (:,:,jl) * r1_e1e2t(:,:)
@@ -755,5 +755,5 @@
                   sxyage(:,:,jl)= z2d(:,:)
                END DO
-               IF ( nn_pnd_scheme > 0 ) THEN
+               IF ( ln_pnd_H12 ) THEN
                   DO jl = 1, jpl 
                      WRITE(zchar,'(I2.2)') jl
@@ -833,5 +833,5 @@
                syyc0 (:,:,:) = 0._wp   ;   syye (:,:,:,:) = 0._wp   ;   syysal (:,:,:) = 0._wp   ;   syyage (:,:,:) = 0._wp
                sxyc0 (:,:,:) = 0._wp   ;   sxye (:,:,:,:) = 0._wp   ;   sxysal (:,:,:) = 0._wp   ;   sxyage (:,:,:) = 0._wp
-               IF ( nn_pnd_scheme > 0 ) THEN
+               IF ( ln_pnd_H12 ) THEN
                   sxap  (:,:,:) = 0._wp    ; sxvp  (:,:,:) = 0._wp 
                   syap  (:,:,:) = 0._wp    ; syvp  (:,:,:) = 0._wp 
@@ -854,5 +854,5 @@
             syyc0 (:,:,:) = 0._wp   ;   syye (:,:,:,:) = 0._wp   ;   syysal (:,:,:) = 0._wp   ;   syyage (:,:,:) = 0._wp
             sxyc0 (:,:,:) = 0._wp   ;   sxye (:,:,:,:) = 0._wp   ;   sxysal (:,:,:) = 0._wp   ;   sxyage (:,:,:) = 0._wp
-            IF ( nn_pnd_scheme > 0 ) THEN
+            IF ( ln_pnd_H12 ) THEN
                sxap  (:,:,:) = 0._wp    ; sxvp  (:,:,:) = 0._wp 
                syap  (:,:,:) = 0._wp    ; syvp  (:,:,:) = 0._wp 
@@ -989,5 +989,5 @@
             END DO
          END DO
-         IF ( nn_pnd_scheme > 0 ) THEN
+         IF ( ln_pnd_H12 ) THEN
             DO jl = 1, jpl 
                WRITE(zchar,'(I2.2)') jl
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_adv_umx.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_adv_umx.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_adv_umx.F90	(revision 8752)
@@ -124,5 +124,5 @@
             CALL adv_umx( k_order, kt, zdt, zudy, zvdx, zcu_box, zcv_box, pv_s(:,:,jl) )         ! Snow volume
             CALL adv_umx( k_order, kt, zdt, zudy, zvdx, zcu_box, zcv_box, pe_s(:,:,1,jl) )       ! Snow heat content
-            IF ( nn_pnd_scheme > 0 ) THEN
+            IF ( ln_pnd_H12 ) THEN
                CALL adv_umx( k_order, kt, zdt, zudy, zvdx, zcu_box, zcv_box, pa_ip(:,:,jl) )     ! Melt pond fraction
                CALL adv_umx( k_order, kt, zdt, zudy, zvdx, zcu_box, zcv_box, pv_ip(:,:,jl) )     ! Melt pond volume
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_rdgrft.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_rdgrft.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_rdgrft.F90	(revision 8752)
@@ -253,8 +253,6 @@
          CALL tab_3d_2d( npti, nptidx(1:npti), sv_i_2d(1:npti,1:jpl), sv_i(:,:,:) )
          CALL tab_3d_2d( npti, nptidx(1:npti), oa_i_2d(1:npti,1:jpl), oa_i(:,:,:) )
-         IF ( nn_pnd_scheme > 0 ) THEN
-            CALL tab_3d_2d( npti, nptidx(1:npti), a_ip_2d(1:npti,1:jpl), a_ip(:,:,:) )
-            CALL tab_3d_2d( npti, nptidx(1:npti), v_ip_2d(1:npti,1:jpl), v_ip(:,:,:) )
-         ENDIF
+         CALL tab_3d_2d( npti, nptidx(1:npti), a_ip_2d(1:npti,1:jpl), a_ip(:,:,:) )
+         CALL tab_3d_2d( npti, nptidx(1:npti), v_ip_2d(1:npti,1:jpl), v_ip(:,:,:) )
          DO jl = 1, jpl
             DO jk = 1, nlay_s
@@ -270,7 +268,5 @@
          CALL tab_2d_1d( npti, nptidx(1:npti), hfx_dyn_1d    (1:npti), hfx_dyn    (:,:) )
          CALL tab_2d_1d( npti, nptidx(1:npti), wfx_snw_dyn_1d(1:npti), wfx_snw_dyn(:,:) )
-         IF ( nn_pnd_scheme > 0 ) THEN
-            CALL tab_2d_1d( npti, nptidx(1:npti), wfx_pnd_1d(1:npti), wfx_pnd(:,:) )
-         ENDIF
+         CALL tab_2d_1d( npti, nptidx(1:npti), wfx_pnd_1d(1:npti), wfx_pnd(:,:) )
          
          !-----------------------------------------------------------------------------!
@@ -320,8 +316,6 @@
          CALL tab_2d_3d( npti, nptidx(1:npti), sv_i_2d(1:npti,1:jpl), sv_i(:,:,:) )
          CALL tab_2d_3d( npti, nptidx(1:npti), oa_i_2d(1:npti,1:jpl), oa_i(:,:,:) )
-         IF ( nn_pnd_scheme > 0 ) THEN
-            CALL tab_2d_3d( npti, nptidx(1:npti), a_ip_2d(1:npti,1:jpl), a_ip(:,:,:) )
-            CALL tab_2d_3d( npti, nptidx(1:npti), v_ip_2d(1:npti,1:jpl), v_ip(:,:,:) )
-         ENDIF
+         CALL tab_2d_3d( npti, nptidx(1:npti), a_ip_2d(1:npti,1:jpl), a_ip(:,:,:) )
+         CALL tab_2d_3d( npti, nptidx(1:npti), v_ip_2d(1:npti,1:jpl), v_ip(:,:,:) )
          DO jl = 1, jpl
             DO jk = 1, nlay_s
@@ -337,7 +331,5 @@
          CALL tab_1d_2d( npti, nptidx(1:npti), hfx_dyn_1d    (1:npti), hfx_dyn    (:,:) )
          CALL tab_1d_2d( npti, nptidx(1:npti), wfx_snw_dyn_1d(1:npti), wfx_snw_dyn(:,:) )
-         IF ( nn_pnd_scheme > 0 ) THEN
-            CALL tab_1d_2d( npti, nptidx(1:npti), wfx_pnd_1d(1:npti), wfx_pnd(:,:) )
-         ENDIF
+         CALL tab_1d_2d( npti, nptidx(1:npti), wfx_pnd_1d(1:npti), wfx_pnd(:,:) )
 
       ENDIF ! npti > 0
@@ -651,5 +643,5 @@
 
                !MV MP 2016
-               IF ( nn_pnd_scheme > 0 ) THEN
+               IF ( ln_pnd_H12 ) THEN
                   aprdg1     = a_ip_2d(ji,jl1) * afrdg
                   aprdg2(ji) = a_ip_2d(ji,jl1) * afrdg * hi_hrdg(ji,jl1)
@@ -679,5 +671,5 @@
                ! Put the melt pond water into the ocean
                !------------------------------------------            
-               IF ( ( nn_pnd_scheme > 0 ) .AND. ln_pnd_fw ) THEN
+               IF ( ln_pnd_fwb ) THEN
                   wfx_pnd_1d(ji) = wfx_pnd_1d(ji) + ( rhofw * vprdg(ji) * ( 1._wp - rn_fpndrdg )   &        ! fresh water source for ocean
                      &                              + rhofw * vprft(ji) * ( 1._wp - rn_fpndrft ) ) * r1_rdtice
@@ -702,5 +694,5 @@
                oa_i_2d(ji,jl1) = oa_i_2d(ji,jl1) - oirdg1    - oirft1
                ! MV MP 2016
-               IF ( nn_pnd_scheme > 0 ) THEN
+               IF ( ln_pnd_H12 ) THEN
                   a_ip_2d(ji,jl1) = a_ip_2d(ji,jl1) - aprdg1    - aprft1
                   v_ip_2d(ji,jl1) = v_ip_2d(ji,jl1) - vprdg(ji) - vprft(ji)
@@ -766,5 +758,5 @@
                      &                                    vsrft (ji) * rn_fsnwrft * zswitch(ji) )
                   ! MV MP 2016
-                  IF ( nn_pnd_scheme > 0 ) THEN
+                  IF ( ln_pnd_H12 ) THEN
                      v_ip_2d (ji,jl2) = v_ip_2d(ji,jl2) + (   vprdg (ji) * rn_fpndrdg * fvol   (ji)   &
                         &                                   + vprft (ji) * rn_fpndrft * zswitch(ji)   )
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_rhg.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_rhg.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_rhg.F90	(revision 8752)
@@ -78,5 +78,5 @@
       CASE( np_rhgEVP )                ! Elasto-Viscous-Plastic !
          !                             !------------------------!
-         CALL ice_dyn_rhg_evp( kt, stress1_i, stress2_i, stress12_i, u_ice, v_ice, shear_i, divu_i, delta_i )
+         CALL ice_dyn_rhg_evp( kt, stress1_i, stress2_i, stress12_i, shear_i, divu_i, delta_i )
          !         
       END SELECT
@@ -107,5 +107,5 @@
       INTEGER ::   ios, ioptio   ! Local integer output status for namelist read
       !!
-      NAMELIST/namdyn_rhg/  ln_rhg_EVP, rn_creepl, rn_ecc , nn_nevp, rn_relast
+      NAMELIST/namdyn_rhg/  ln_rhg_EVP, ln_aEVP, rn_creepl, rn_ecc , nn_nevp, rn_relast
       !!-------------------------------------------------------------------
       !
@@ -125,4 +125,5 @@
          WRITE(numout,*) '   Namelist namdyn_rhg:'
          WRITE(numout,*) '      rheology EVP (icedyn_rhg_evp)                        ln_rhg_EVP = ', ln_rhg_EVP
+         WRITE(numout,*) '         use adaptive EVP (aEVP)                           ln_aEVP    = ', ln_aEVP
          WRITE(numout,*) '         creep limit                                       rn_creepl  = ', rn_creepl
          WRITE(numout,*) '         eccentricity of the elliptical yield curve        rn_ecc     = ', rn_ecc
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_rhg_evp.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_rhg_evp.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icedyn_rhg_evp.F90	(revision 8752)
@@ -53,5 +53,5 @@
 CONTAINS
 
-   SUBROUTINE ice_dyn_rhg_evp( kt, pstress1_i, pstress2_i, pstress12_i, u_ice, v_ice, pshear_i, pdivu_i, pdelta_i )
+   SUBROUTINE ice_dyn_rhg_evp( kt, pstress1_i, pstress2_i, pstress12_i, pshear_i, pdivu_i, pdelta_i )
       !!-------------------------------------------------------------------
       !!                 ***  SUBROUTINE ice_dyn_rhg_evp  ***
@@ -95,15 +95,16 @@
       !!              5) Diagnostics including charge ellipse
       !!
-      !! ** Notes   : There is the possibility to use mEVP from Bouillon 2013
-      !!              (by uncommenting some lines in part 3 and changing alpha and beta parameters)
-      !!              but this solution appears very unstable (see Kimmritz et al 2016)
+      !! ** Notes   : There is the possibility to use aEVP from the nice work of Kimmritz et al. (2016 & 2017)
+      !!              by setting up ln_aEVP=T (i.e. changing alpha and beta parameters).
+      !!              This is an upgraded version of mEVP from Bouillon et al. 2013
+      !!              (i.e. more stable and better convergence)
       !!
       !! References : Hunke and Dukowicz, JPO97
       !!              Bouillon et al., Ocean Modelling 2009
       !!              Bouillon et al., Ocean Modelling 2013
+      !!              Kimmritz et al., Ocean Modelling 2016 & 2017
       !!-------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt      ! time step
       REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pstress1_i, pstress2_i, pstress12_i
-      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   u_ice, v_ice 
       REAL(wp), DIMENSION(:,:), INTENT(  out) ::   pshear_i, pdivu_i, pdelta_i 
       !!
@@ -114,5 +115,5 @@
       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) ::   zalph1, z1_alph1, zalph2, z1_alph2                       ! alpha coef from Bouillon 2009 or Kimmritz 2017
       REAL(wp) ::   zm1, zm2, zm3, zmassU, zmassV                            ! ice/snow mass
       REAL(wp) ::   zdelta, zp_delf, zds2, zdt, zdt2, zdiv, zdiv2            ! temporary scalars
@@ -126,7 +127,9 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   z1_e1t0, z1_e2t0                ! scale factors
       REAL(wp), DIMENSION(jpi,jpj) ::   zp_delt                         ! P/delta at T points
-      !
+      REAL(wp), DIMENSION(jpi,jpj) ::   zbeta                           ! beta coef from Kimmritz 2017
+      !
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdt_m                           ! (dt / ice-snow_mass) on T points
       REAL(wp), DIMENSION(jpi,jpj) ::   zaU   , zaV                     ! ice fraction on U/V points
-      REAL(wp), DIMENSION(jpi,jpj) ::   zmU_t, zmV_t                    ! ice/snow mass/dt on U/V points
+      REAL(wp), DIMENSION(jpi,jpj) ::   zmU_t, zmV_t                    ! (ice-snow_mass / dt) on U/V points
       REAL(wp), DIMENSION(jpi,jpj) ::   zmf                             ! coriolis parameter at T points
       REAL(wp), DIMENSION(jpi,jpj) ::   zTauU_ia , ztauV_ia             ! ice-atm. stress at U-V points
@@ -231,16 +234,12 @@
 
       ! alpha parameters (Bouillon 2009)
-      zalph1 = ( 2._wp * rn_relast * rdt_ice ) * z1_dtevp
-      zalph2 = zalph1 * z1_ecc2
-
-      ! alpha and beta parameters (Bouillon 2013)
-      !!zalph1 = 40.
-      !!zalph2 = 40.
-      !!zbeta  = 3000.
-      !!zbeta = REAL( nn_nevp )   ! close to classical EVP of Hunke (2001)
-
-      z1_alph1 = 1._wp / ( zalph1 + 1._wp )
-      z1_alph2 = 1._wp / ( zalph2 + 1._wp )
-
+      IF( .NOT. ln_aEVP ) THEN
+         zalph1 = ( 2._wp * rn_relast * rdt_ice ) * z1_dtevp
+         zalph2 = zalph1 * z1_ecc2
+
+         z1_alph1 = 1._wp / ( zalph1 + 1._wp )
+         z1_alph2 = 1._wp / ( zalph2 + 1._wp )
+      ENDIF
+         
       ! Initialise stress tensor 
       zs1 (:,:) = pstress1_i (:,:) 
@@ -304,8 +303,11 @@
             zmf(ji,jj)      = zm1 * ff_t(ji,jj)
 
+            ! dt/m at T points (for alpha and beta coefficients)
+            zdt_m(ji,jj)    = zdtevp / MAX( zm1, zmmin )
+            
             ! 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)
@@ -326,5 +328,5 @@
          END DO
       END DO
-      CALL lbc_lnk( zmf, 'T', 1. )
+      CALL lbc_lnk_multi( zmf, 'T', 1., zdt_m, 'T', 1. )
       !
       !------------------------------------------------------------------------------!
@@ -380,4 +382,14 @@
                ! P/delta at T points
                zp_delt(ji,jj) = strength(ji,jj) / ( zdelta + rn_creepl )
+
+               ! alpha & beta for aEVP
+               !   gamma = 0.5*P/(delta+creepl) * (c*pi)**2/Area * dt/m
+               !   alpha = beta = sqrt(4*gamma)
+               IF( ln_aEVP ) THEN
+                  zalph1   = MAX( 50._wp, rpi * SQRT( 0.5_wp * zp_delt(ji,jj) * r1_e1e2t(ji,jj) * zdt_m(ji,jj) ) )
+                  z1_alph1 = 1._wp / ( zalph1 + 1._wp )
+                  zalph2   = zalph1
+                  z1_alph2 = z1_alph1
+               ENDIF
                
                ! stress at T points
@@ -392,4 +404,11 @@
             DO ji = 1, jpim1
 
+               ! alpha & beta for aEVP
+               IF( ln_aEVP ) THEN
+                  zalph2   = MAX( 50._wp, rpi * SQRT( 0.5_wp * zp_delt(ji,jj) * r1_e1e2t(ji,jj) * zdt_m(ji,jj) ) )
+                  z1_alph2 = 1._wp / ( zalph2 + 1._wp )
+                  zbeta(ji,jj) = zalph2
+               ENDIF
+               
                ! 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) )
@@ -411,6 +430,6 @@
                   &                    ) * 2._wp * r1_e1u(ji,jj)                                                              &
                   &                  ) * r1_e1e2u(ji,jj)
-                  !
-                  !                !--- V points
+               !
+               !                !--- 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)    &
@@ -419,18 +438,17 @@
                   &                    ) * 2._wp * r1_e2v(ji,jj)                                                              &
                   &                  ) * r1_e1e2v(ji,jj)
-                  !
-                  !                !--- u_ice at V point
+               !
+               !                !--- 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_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 --- !
-         !  Bouillon et al. 2013 (eq 47-48) => unstable unless alpha, beta are chosen wisely and large nn_nevp
+         !  Bouillon et al. 2013 (eq 47-48) => unstable unless alpha, beta vary as in Kimmritz 2016 & 2017
          !  Bouillon et al. 2009 (eq 34-35) => stable
          IF( MOD(jter,2) == 0 ) THEN ! even iterations
@@ -438,26 +456,33 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1
-                     !                 !--- tau_io/(v_oce - v_ice)
+                  !                 !--- tau_io/(v_oce - v_ice)
                   zTauO = zaV(ji,jj) * zrhoco * 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) ) )
-                     !                 !--- Ocean-to-Ice stress
+                  !                 !--- Ocean-to-Ice stress
                   ztauy_oi(ji,jj) = zTauO * ( v_oce(ji,jj) - v_ice(ji,jj) )
-                     !
-                     !                 !--- tau_bottom/v_ice
+                  !
+                  !                 !--- tau_bottom/v_ice
                   zvel  = MAX( zepsi, SQRT( v_ice(ji,jj) * v_ice(ji,jj) + u_iceV(ji,jj) * u_iceV(ji,jj) ) )
                   zTauB = - tau_icebfr(ji,jj) / zvel
-                     !
-                     !                 !--- Coriolis at V-points (energy conserving formulation)
+                  !
+                  !                 !--- Coriolis at V-points (energy conserving formulation)
                   zCory(ji,jj)  = - 0.25_wp * r1_e2v(ji,jj) *  &
                      &    ( zmf(ji,jj  ) * ( e2u(ji,jj  ) * u_ice(ji,jj  ) + e2u(ji-1,jj  ) * u_ice(ji-1,jj  ) )  &
                      &    + zmf(ji,jj+1) * ( e2u(ji,jj+1) * u_ice(ji,jj+1) + e2u(ji-1,jj+1) * u_ice(ji-1,jj+1) ) )
-                     !
-                     !                 !--- Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
+                  !
+                  !                 !--- Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
                   zTauE = zfV(ji,jj) + zTauV_ia(ji,jj) + zCory(ji,jj) + zspgV(ji,jj) + ztauy_oi(ji,jj)
-                     !
-                     !                 !--- landfast switch => 0 = static friction ; 1 = sliding friction
+                  !
+                  !                 !--- landfast switch => 0 = static friction ; 1 = sliding friction
                   rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, ztauE - tau_icebfr(ji,jj) ) - SIGN( 1._wp, zTauE ) ) )
-                     !
-                     !                 !--- ice velocity using implicit formulation (cf Madec doc & Bouillon 2009)
+                  !
+                  IF( ln_aEVP ) THEN !--- ice velocity using aEVP (Kimmritz et al 2016 & 2017)
+                  v_ice(ji,jj) = ( (          rswitch * ( zmV_t(ji,jj) * ( zbeta(ji,jj) * v_ice(ji,jj) + v_ice_b(ji,jj) )         & ! previous velocity
+                     &                                  + zTauE + zTauO * v_ice(ji,jj)                                            & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                     &                                  ) / MAX( zepsi, zmV_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
+                     &                 + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )           & ! static friction => slow decrease to v=0
+                     &             ) * zswitchV(ji,jj) + v_oce(ji,jj) * ( 1._wp - zswitchV(ji,jj) )                               & ! v_ice = v_oce if mass < zmmin
+                     &           ) * zmaskV(ji,jj)
+                  ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
                   v_ice(ji,jj) = ( (           rswitch   * ( zmV_t(ji,jj)  * v_ice(ji,jj)                             &  ! previous velocity
                      &                                     + zTauE + zTauO * v_ice(ji,jj)                             &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
@@ -466,10 +491,5 @@
                      &              ) * zswitchV(ji,jj) + v_oce(ji,jj) * ( 1._wp - zswitchV(ji,jj) )                  &  ! v_ice = v_oce if mass < zmmin
                      &            ) * zmaskV(ji,jj)
-                     !
-                  ! Bouillon 2013
-                  !!v_ice(ji,jj) = ( zmV_t(ji,jj) * ( zbeta * v_ice(ji,jj) + v_ice_b(ji,jj) )                  &
-                  !!   &           + zfV(ji,jj) + zCory(ji,jj) + zTauV_ia(ji,jj) + zTauO * v_oce(ji,jj) + zspgV(ji,jj)  &
-                  !!   &           ) / MAX( zmV_t(ji,jj) * ( zbeta + 1._wp ) + zTauO - zTauB, zepsi ) * zswitchV(ji,jj)
-                  !
+                  ENDIF
                END DO
             END DO
@@ -483,29 +503,34 @@
             !
             DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1
-                               
-                  ! tau_io/(u_oce - u_ice)
+               DO ji = fs_2, fs_jpim1          
+                  !                 !--- tau_io/(u_oce - u_ice)
                   zTauO = zaU(ji,jj) * zrhoco * 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) ) )
-
-                  ! Ocean-to-Ice stress
+                  !                 !--- Ocean-to-Ice stress
                   ztaux_oi(ji,jj) = zTauO * ( u_oce(ji,jj) - u_ice(ji,jj) )
-
-                  ! tau_bottom/u_ice
+                  !
+                  !                 !--- tau_bottom/u_ice
                   zvel  = MAX( zepsi, SQRT( v_iceU(ji,jj) * v_iceU(ji,jj) + u_ice(ji,jj) * u_ice(ji,jj) ) )
                   zTauB = - tau_icebfr(ji,jj) / zvel
-
-                  ! Coriolis at U-points (energy conserving formulation)
+                  !
+                  !                 !--- Coriolis at U-points (energy conserving formulation)
                   zCorx(ji,jj)  =   0.25_wp * r1_e1u(ji,jj) *  &
                      &    ( zmf(ji  ,jj) * ( e1v(ji  ,jj) * v_ice(ji  ,jj) + e1v(ji  ,jj-1) * v_ice(ji  ,jj-1) )  &
                      &    + zmf(ji+1,jj) * ( e1v(ji+1,jj) * v_ice(ji+1,jj) + e1v(ji+1,jj-1) * v_ice(ji+1,jj-1) ) )
-                  
-                  ! Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
+                  !
+                  !                 !--- Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
                   zTauE = zfU(ji,jj) + zTauU_ia(ji,jj) + zCorx(ji,jj) + zspgU(ji,jj) + ztaux_oi(ji,jj)
-
-                  ! landfast switch => 0 = static friction ; 1 = sliding friction
+                  !
+                  !                 !--- landfast switch => 0 = static friction ; 1 = sliding friction
                   rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, ztauE - tau_icebfr(ji,jj) ) - SIGN( 1._wp, zTauE ) ) )
-
-                  ! ice velocity using implicit formulation (cf Madec doc & Bouillon 2009)
+                  !
+                  IF( ln_aEVP ) THEN !--- ice velocity using aEVP (Kimmritz et al 2016 & 2017)
+                  u_ice(ji,jj) = ( (          rswitch * ( zmU_t(ji,jj) * ( zbeta(ji,jj) * u_ice(ji,jj) + u_ice_b(ji,jj) )         & ! previous velocity
+                     &                                     + zTauE + zTauO * u_ice(ji,jj)                                         & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                     &                                  ) / MAX( zepsi, zmU_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
+                     &              + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )              & ! static friction => slow decrease to v=0
+                     &              ) * zswitchU(ji,jj) + u_oce(ji,jj) * ( 1._wp - zswitchU(ji,jj) )                              & ! v_ice = v_oce if mass < zmmin 
+                     &            ) * zmaskU(ji,jj)
+                  ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
                   u_ice(ji,jj) = ( (           rswitch   * ( zmU_t(ji,jj)  * u_ice(ji,jj)                             &  ! previous velocity
                      &                                     + zTauE + zTauO * u_ice(ji,jj)                             &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
@@ -514,8 +539,5 @@
                      &              ) * zswitchU(ji,jj) + u_oce(ji,jj) * ( 1._wp - zswitchU(ji,jj) )                  &  ! v_ice = v_oce if mass < zmmin 
                      &            ) * zmaskU(ji,jj)
-                  ! Bouillon 2013
-                  !!u_ice(ji,jj) = ( zmU_t(ji,jj) * ( zbeta * u_ice(ji,jj) + u_ice_b(ji,jj) )                  &
-                  !!   &           + zfU(ji,jj) + zCorx(ji,jj) + zTauU_ia(ji,jj) + zTauO * u_oce(ji,jj) + zspgU(ji,jj)  &
-                  !!   &           ) / MAX( zmU_t(ji,jj) * ( zbeta + 1._wp ) + zTauO - zTauB, zepsi ) * zswitchU(ji,jj)
+                  ENDIF
                END DO
             END DO
@@ -532,38 +554,40 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1
-
-                  ! tau_io/(u_oce - u_ice)
+                  !                 !--- tau_io/(u_oce - u_ice)
                   zTauO = zaU(ji,jj) * zrhoco * 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) ) )
-
-                  ! Ocean-to-Ice stress
+                  !                 !--- Ocean-to-Ice stress
                   ztaux_oi(ji,jj) = zTauO * ( u_oce(ji,jj) - u_ice(ji,jj) )
-
-                  ! tau_bottom/u_ice
+                  !
+                  !                 !--- tau_bottom/u_ice
                   zvel  = MAX( zepsi, SQRT( v_iceU(ji,jj) * v_iceU(ji,jj) + u_ice(ji,jj) * u_ice(ji,jj) ) )
                   zTauB = - tau_icebfr(ji,jj) / zvel
-
-                  ! Coriolis at U-points (energy conserving formulation)
+                  !
+                  !                 !--- Coriolis at U-points (energy conserving formulation)
                   zCorx(ji,jj)  =   0.25_wp * r1_e1u(ji,jj) *  &
                      &    ( zmf(ji  ,jj) * ( e1v(ji  ,jj) * v_ice(ji  ,jj) + e1v(ji  ,jj-1) * v_ice(ji  ,jj-1) )  &
                      &    + zmf(ji+1,jj) * ( e1v(ji+1,jj) * v_ice(ji+1,jj) + e1v(ji+1,jj-1) * v_ice(ji+1,jj-1) ) )
-
-                  ! Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
+                  !
+                  !                 !--- Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
                   zTauE = zfU(ji,jj) + zTauU_ia(ji,jj) + zCorx(ji,jj) + zspgU(ji,jj) + ztaux_oi(ji,jj)
-
-                  ! landfast switch => 0 = static friction ; 1 = sliding friction
+                  !
+                  !                 !--- landfast switch => 0 = static friction ; 1 = sliding friction
                   rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, ztauE - tau_icebfr(ji,jj) ) - SIGN( 1._wp, zTauE ) ) )
-
-                  ! ice velocity using implicit formulation (cf Madec doc & Bouillon 2009)
+                  !
+                  IF( ln_aEVP ) THEN !--- ice velocity using aEVP (Kimmritz et al 2016 & 2017)
+                  u_ice(ji,jj) = ( (          rswitch * ( zmU_t(ji,jj) * ( zbeta(ji,jj) * u_ice(ji,jj) + u_ice_b(ji,jj) )         & ! previous velocity
+                     &                                     + zTauE + zTauO * u_ice(ji,jj)                                         & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                     &                                  ) / MAX( zepsi, zmU_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
+                     &              + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )              & ! static friction => slow decrease to v=0
+                     &              ) * zswitchU(ji,jj) + u_oce(ji,jj) * ( 1._wp - zswitchU(ji,jj) )                              & ! v_ice = v_oce if mass < zmmin 
+                     &            ) * zmaskU(ji,jj)
+                  ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
                   u_ice(ji,jj) = ( (           rswitch   * ( zmU_t(ji,jj)  * u_ice(ji,jj)                             &  ! previous velocity
                      &                                     + zTauE + zTauO * u_ice(ji,jj)                             &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
                      &                                     ) / MAX( zepsi, zmU_t(ji,jj) + zTauO - zTauB )             &  ! m/dt + tau_io(only ice part) + landfast
                      &              + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )  &  ! static friction => slow decrease to v=0
-                     &              ) * zswitchU(ji,jj) + u_oce(ji,jj) * ( 1._wp - zswitchU(ji,jj) )                  &  ! v_ice = v_oce if mass < zmmin
+                     &              ) * zswitchU(ji,jj) + u_oce(ji,jj) * ( 1._wp - zswitchU(ji,jj) )                  &  ! v_ice = v_oce if mass < zmmin 
                      &            ) * zmaskU(ji,jj)
-                  ! Bouillon 2013
-                  !!u_ice(ji,jj) = ( zmU_t(ji,jj) * ( zbeta * u_ice(ji,jj) + u_ice_b(ji,jj) )                  &
-                  !!   &           + zfU(ji,jj) + zCorx(ji,jj) + zTauU_ia(ji,jj) + zTauO * u_oce(ji,jj) + zspgU(ji,jj)  &
-                  !!   &           ) / MAX( zmU_t(ji,jj) * ( zbeta + 1._wp ) + zTauO - zTauB, zepsi ) * zswitchU(ji,jj)
+                  ENDIF
                END DO
             END DO
@@ -578,28 +602,33 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1
-         
-                  ! tau_io/(v_oce - v_ice)
+                  !                 !--- tau_io/(v_oce - v_ice)
                   zTauO = zaV(ji,jj) * zrhoco * 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) ) )
-
-                  ! Ocean-to-Ice stress
+                  !                 !--- Ocean-to-Ice stress
                   ztauy_oi(ji,jj) = zTauO * ( v_oce(ji,jj) - v_ice(ji,jj) )
-
-                  ! tau_bottom/v_ice
+                  !
+                  !                 !--- tau_bottom/v_ice
                   zvel  = MAX( zepsi, SQRT( v_ice(ji,jj) * v_ice(ji,jj) + u_iceV(ji,jj) * u_iceV(ji,jj) ) )
                   ztauB = - tau_icebfr(ji,jj) / zvel
-                  
-                  ! Coriolis at V-points (energy conserving formulation)
+                  !
+                  !                 !--- Coriolis at v-points (energy conserving formulation)
                   zCory(ji,jj)  = - 0.25_wp * r1_e2v(ji,jj) *  &
                      &    ( zmf(ji,jj  ) * ( e2u(ji,jj  ) * u_ice(ji,jj  ) + e2u(ji-1,jj  ) * u_ice(ji-1,jj  ) )  &
                      &    + zmf(ji,jj+1) * ( e2u(ji,jj+1) * u_ice(ji,jj+1) + e2u(ji-1,jj+1) * u_ice(ji-1,jj+1) ) )
-
-                  ! Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
+                  !
+                  !                 !--- Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
                   zTauE = zfV(ji,jj) + zTauV_ia(ji,jj) + zCory(ji,jj) + zspgV(ji,jj) + ztauy_oi(ji,jj)
-
-                  ! landfast switch => 0 = static friction (tau_icebfr > zTauE); 1 = sliding friction
+                  !
+                  !                 !--- landfast switch => 0 = static friction ; 1 = sliding friction
                   rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, zTauE - tau_icebfr(ji,jj) ) - SIGN( 1._wp, zTauE ) ) )
-                  
-                  ! ice velocity using implicit formulation (cf Madec doc & Bouillon 2009)
+                  !
+                  IF( ln_aEVP ) THEN !--- ice velocity using aEVP (Kimmritz et al 2016 & 2017)
+                  v_ice(ji,jj) = ( (          rswitch * ( zmV_t(ji,jj) * ( zbeta(ji,jj) * v_ice(ji,jj) + v_ice_b(ji,jj) )         & ! previous velocity
+                     &                                  + zTauE + zTauO * v_ice(ji,jj)                                            & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                     &                                  ) / MAX( zepsi, zmV_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
+                     &                 + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )           & ! static friction => slow decrease to v=0
+                     &             ) * zswitchV(ji,jj) + v_oce(ji,jj) * ( 1._wp - zswitchV(ji,jj) )                               & ! v_ice = v_oce if mass < zmmin
+                     &           ) * zmaskV(ji,jj)
+                  ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
                   v_ice(ji,jj) = ( (           rswitch   * ( zmV_t(ji,jj)  * v_ice(ji,jj)                             &  ! previous velocity
                      &                                     + zTauE + zTauO * v_ice(ji,jj)                             &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
@@ -608,8 +637,5 @@
                      &              ) * zswitchV(ji,jj) + v_oce(ji,jj) * ( 1._wp - zswitchV(ji,jj) )                  &  ! v_ice = v_oce if mass < zmmin
                      &            ) * zmaskV(ji,jj)
-                  ! Bouillon 2013
-                  !!v_ice(ji,jj) = ( zmV_t(ji,jj) * ( zbeta * v_ice(ji,jj) + v_ice_b(ji,jj) )                  &
-                  !!   &           + zfV(ji,jj) + zCory(ji,jj) + zTauV_ia(ji,jj) + zTauO * v_oce(ji,jj) + zspgV(ji,jj)  &
-                  !!   &           ) / MAX( zmV_t(ji,jj) * ( zbeta + 1._wp ) + zTauO - zTauB, zepsi ) * zswitchV(ji,jj)
+                  ENDIF
                END DO
             END DO
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceforcing.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceforcing.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceforcing.F90	(revision 8752)
@@ -99,5 +99,4 @@
       !!
       !! ** Action  : It provides the following fields used in sea ice model:
-      !!                fr1_i0  , fr2_i0                         = 1sr & 2nd fraction of qsr penetration in ice  [%]
       !!                emp_oce , emp_ice                        = E-P over ocean and sea ice                    [Kg/m2/s]
       !!                sprecip                                  = solid precipitation                           [Kg/m2/s]
@@ -130,5 +129,5 @@
 
       ! --- cloud-sky and overcast-sky ice albedos --- !
-      CALL ice_alb( t_su, h_i, h_s, a_ip_frac, h_ip, ln_pnd_rad, zalb_cs, zalb_os )
+      CALL ice_alb( t_su, h_i, h_s, ln_pnd_alb, a_ip_frac, h_ip, zalb_cs, zalb_os )
 
       ! albedo depends on cloud fraction because of non-linear spectral effects
@@ -142,10 +141,10 @@
          !
       CASE( jp_blk )                !--- bulk formulation
-                                CALL blk_ice_flx( t_su, alb_ice )    ! 
-         IF( ln_mixcpl      )   CALL sbc_cpl_ice_flx( picefr=at_i_b, palbi=alb_ice, psst=sst_m, pist=t_su )
+                                CALL blk_ice_flx( t_su, h_s, h_i, alb_ice )    ! 
+         IF( ln_mixcpl      )   CALL sbc_cpl_ice_flx( picefr=at_i_b, palbi=alb_ice, psst=sst_m, pist=t_su, phs=h_s, phi=h_i )
          IF( nn_iceflx /= 2 )   CALL ice_flx_dist( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_iceflx )
          !
       CASE ( jp_purecpl )           !--- coupled formulation
-                                CALL sbc_cpl_ice_flx( picefr=at_i_b, palbi=alb_ice, psst=sst_m, pist=t_su )
+                                CALL sbc_cpl_ice_flx( picefr=at_i_b, palbi=alb_ice, psst=sst_m, pist=t_su, phs=h_s, phi=h_i )
          IF( nn_iceflx == 2 )   CALL ice_flx_dist( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_iceflx )
          !
@@ -268,5 +267,5 @@
       INTEGER ::   ios, ioptio   ! Local integer output status for namelist read
       !!
-      NAMELIST/namforcing/ rn_cio, rn_blow_s, nn_iceflx
+      NAMELIST/namforcing/ rn_cio, rn_blow_s, nn_iceflx, nice_jules
       !!-------------------------------------------------------------------
       !
@@ -285,7 +284,8 @@
          WRITE(numout,*) '~~~~~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist namforcing:'
-         WRITE(numout,*) '      drag coefficient for oceanic stress              rn_cio    = ', rn_cio
-         WRITE(numout,*) '      coefficient for ice-lead partition of snowfall   rn_blow_s = ', rn_blow_s
-         WRITE(numout,*) '      Multicategory heat flux formulation              nn_iceflx = ', nn_iceflx
+         WRITE(numout,*) '      drag coefficient for oceanic stress              rn_cio     = ', rn_cio
+         WRITE(numout,*) '      coefficient for ice-lead partition of snowfall   rn_blow_s  = ', rn_blow_s
+         WRITE(numout,*) '      Multicategory heat flux formulation              nn_iceflx  = ', nn_iceflx
+         WRITE(numout,*) '      Jules coupling (0=no, 1=emulated, 2=active)      nice_jules = ', nice_jules
       ENDIF
       !
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceistate.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceistate.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceistate.F90	(revision 8752)
@@ -94,5 +94,5 @@
       REAL(wp) ::   ztmelts, zdh
       INTEGER  ::   i_hemis, i_fill, jl0
-      REAL(wp) ::   zarg, zV, zconv, zdv
+      REAL(wp) ::   zarg, zV, zconv, zdv, zfac
       INTEGER , DIMENSION(4)           ::   itest
       REAL(wp), DIMENSION(jpi,jpj)     ::   z2d
@@ -314,5 +314,5 @@
 
          ! for constant salinity in time
-         IF( nn_icesal == 1 .OR. nn_icesal == 3 )  THEN
+         IF( nn_icesal /= 2 )  THEN
             CALL ice_var_salprof
             sv_i = s_i * v_i
@@ -358,20 +358,13 @@
          tn_ice (:,:,:) = t_su (:,:,:)
 
-         ! MV MP 2016
          ! Melt pond volume and fraction
-         IF ( ln_pnd ) THEN
-            DO jl = 1, jpl
-               a_ip_frac(:,:,jl) = 0.2 *  zswitch(:,:)
-               h_ip     (:,:,jl) = 0.05 * zswitch(:,:)
-               a_ip(:,:,jl)      = a_ip_frac(:,:,jl) * a_i (:,:,jl) 
-               v_ip(:,:,jl)      = h_ip     (:,:,jl) * a_ip(:,:,jl)
-            END DO
-         ELSE
-            a_ip(:,:,:)      = 0._wp
-            v_ip(:,:,:)      = 0._wp
-            a_ip_frac(:,:,:) = 0._wp
-            h_ip     (:,:,:) = 0._wp
-         ENDIF
-         ! END MV MP 2016
+         IF ( ln_pnd_CST .OR. ln_pnd_H12 ) THEN   ;   zfac = 1._wp
+         ELSE                                     ;   zfac = 0._wp   ;   ENDIF 
+         DO jl = 1, jpl
+            a_ip_frac(:,:,jl) = rn_apnd * zswitch(:,:) * zfac
+            h_ip     (:,:,jl) = rn_hpnd * zswitch(:,:) * zfac
+         END DO
+         a_ip(:,:,:) = a_ip_frac(:,:,:) * a_i (:,:,:) 
+         v_ip(:,:,:) = h_ip     (:,:,:) * a_ip(:,:,:)
 
       ELSE ! if ln_iceini=false
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceitd.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceitd.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceitd.F90	(revision 8752)
@@ -36,7 +36,15 @@
    PUBLIC   ice_itd_reb   ! called in icecor
 
+   INTEGER ::              nice_catbnd   ! choice of the type of ice category function
+   !                                       ! associated indices:
+   INTEGER, PARAMETER ::   np_cathfn = 1   ! categories defined by a function
+   INTEGER, PARAMETER ::   np_catusr = 2   ! categories defined by the user
+   !
    ! ** namelist (namitd) **
+   LOGICAL  ::   ln_cat_hfn  ! ice categories are defined by function like rn_himean**(-0.05)
    REAL(wp) ::   rn_himean   ! mean thickness of the domain
-
+   LOGICAL  ::   ln_cat_usr  ! ice categories are defined by rn_catbnd
+   REAL(wp), DIMENSION(0:100) ::   rn_catbnd   ! ice categories bounds
+   !
    !!----------------------------------------------------------------------
    !! NEMO/ICE 4.0 , NEMO Consortium (2017)
@@ -293,9 +301,5 @@
             IF ( a_i_1d(ji) > epsi10 .AND. h_i_1d(ji) < rn_himin ) THEN
                a_i_1d (ji) = a_i_1d(ji) * h_i_1d(ji) / rn_himin 
-               ! MV MP 2016
-               IF ( nn_pnd_scheme > 0 ) THEN
-                  a_ip_1d(ji) = a_ip_1d(ji) * h_i_1d(ji) / rn_himin
-               ENDIF
-               ! END MV MP 2016
+               IF ( ln_pnd_H12 )    a_ip_1d(ji) = a_ip_1d(ji) * h_i_1d(ji) / rn_himin
                h_i_1d(ji) = rn_himin
             ENDIF
@@ -457,6 +461,5 @@
                zaTsfn(ji,jl2)  = zaTsfn(ji,jl2) + ztrans
                !  
-               ! MV MP 2016 
-               IF ( nn_pnd_scheme > 0 ) THEN
+               IF ( ln_pnd_H12 ) THEN
                   !                                                  ! Pond fraction
                   ztrans          = a_ip_2d(ji,jl1) * pdaice(ji,jl) !!clem: should be * zworka(ji) but it does not work
@@ -468,5 +471,4 @@
                   v_ip_2d(ji,jl2) = v_ip_2d(ji,jl2) + ztrans
                ENDIF
-               ! END MV MP 2016
                !
             ENDIF   ! jl1 >0
@@ -643,9 +645,9 @@
       !! ** input   :   Namelist namitd
       !!-------------------------------------------------------------------
-      INTEGER  ::   jl    ! dummy loop index
-      INTEGER  ::   ios   ! Local integer output status for namelist read
+      INTEGER  ::   jl            ! dummy loop index
+      INTEGER  ::   ios, ioptio   ! Local integer output status for namelist read
       REAL(wp) ::   zhmax, znum, zden, zalpha   !   -      -
-      !!
-      NAMELIST/namitd/ rn_himean, rn_himin
+      !
+      NAMELIST/namitd/ ln_cat_hfn, rn_himean, ln_cat_usr, rn_catbnd, rn_himin
       !!------------------------------------------------------------------
       !
@@ -664,6 +666,9 @@
          WRITE(numout,*) '~~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist namitd: '
-         WRITE(numout,*) '      mean ice thickness in the domain               rn_himean = ', rn_himean
-         WRITE(numout,*) '      minimum ice thickness                          rn_himin  = ', rn_himin 
+         WRITE(numout,*) '      Ice categories are defined by a function of rn_himean**(-0.05)    ln_cat_hfn = ', ln_cat_hfn
+         WRITE(numout,*) '         mean ice thickness in the domain                               rn_himean  = ', rn_himean
+         WRITE(numout,*) '      Ice categories are defined by rn_catbnd                           ln_cat_usr = ', ln_cat_usr
+         WRITE(numout,*) '         ice categories boundaries (m)                                  rn_catbnd  = ', rn_catbnd 
+         WRITE(numout,*) '      minimum ice thickness                                             rn_himin   = ', rn_himin 
       ENDIF
       !
@@ -671,12 +676,29 @@
       !  Thickness categories boundaries  !
       !-----------------------------------!
-      !
-      zalpha = 0.05_wp              ! max of each category (from h^(-alpha) function)
-      zhmax  = 3._wp * rn_himean
-      DO jl = 1, jpl
-         znum = jpl * ( zhmax+1 )**zalpha
-         zden = REAL( jpl-jl , wp ) * ( zhmax + 1._wp )**zalpha + REAL( jl , wp )
-         hi_max(jl) = ( znum / zden )**(1./zalpha) - 1
-      END DO
+      !                             !== set the choice of ice categories ==!
+      ioptio = 0 
+      IF( ln_cat_hfn ) THEN   ;   ioptio = ioptio + 1   ;   nice_catbnd = np_cathfn    ;   ENDIF
+      IF( ln_cat_usr ) THEN   ;   ioptio = ioptio + 1   ;   nice_catbnd = np_catusr    ;   ENDIF
+      IF( ioptio /= 1 )   CALL ctl_stop( 'ice_itd_init: choose one and only one ice categories boundaries' )
+      !
+      SELECT CASE( nice_catbnd )
+      !                                !------------------------!
+      CASE( np_cathfn )                ! h^(-alpha) function
+         !                             !------------------------!
+         zalpha = 0.05_wp
+         zhmax  = 3._wp * rn_himean
+         DO jl = 1, jpl
+            znum = jpl * ( zhmax+1 )**zalpha
+            zden = REAL( jpl-jl , wp ) * ( zhmax + 1._wp )**zalpha + REAL( jl , wp )
+            hi_max(jl) = ( znum / zden )**(1./zalpha) - 1
+         END DO
+         !                             !------------------------!
+      CASE( np_catusr )                ! user defined
+         !                             !------------------------!
+         DO jl = 0, jpl
+            hi_max(jl) = rn_catbnd(jl)
+         END DO
+         !
+      END SELECT
       !
       DO jl = 1, jpl                ! mean thickness by category
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icerst.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icerst.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icerst.F90	(revision 8752)
@@ -147,17 +147,13 @@
       END DO
 
-      ! MV MP 2016
-      IF ( nn_pnd_scheme > 0 ) THEN
-         DO jl = 1, jpl 
-            WRITE(zchar,'(I2.2)') jl
-            znam = 'a_ip'//'_htc'//zchar
-            z2d(:,:) = a_ip(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! a_ip
-            znam = 'v_ip'//'_htc'//zchar
-            z2d(:,:) = v_ip(:,:,jl)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! v_ip
-         END DO
-      ENDIF
-      ! END MV MP 2016
+      DO jl = 1, jpl 
+         WRITE(zchar,'(I2.2)') jl
+         znam = 'a_ip'//'_htc'//zchar
+         z2d(:,:) = a_ip(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! a_ip
+         znam = 'v_ip'//'_htc'//zchar
+         z2d(:,:) = v_ip(:,:,jl)
+         CALL iom_rstput( iter, nitrst, numriw, znam , z2d ) ! v_ip
+      END DO
 
       DO jl = 1, jpl 
@@ -193,6 +189,7 @@
       !! ** purpose  :   read restart file
       !!----------------------------------------------------------------------
-      INTEGER  :: jk, jl
-      REAL(wp) :: zfice, ziter
+      INTEGER  ::   jk, jl
+      INTEGER  ::   id1            ! local integer
+      REAL(wp) ::   zfice, ziter
       REAL(wp), DIMENSION(jpi,jpj) ::   z2d
       CHARACTER(len=25) ::   znam
@@ -248,6 +245,6 @@
       END DO
 
-      ! MV MP 2016
-      IF ( nn_pnd_scheme > 0 ) THEN
+      id1 = iom_varid( numrir, 'a_ip_htc01' , ldstop = .FALSE. )
+      IF( id1 > 0 ) THEN                       ! fields exist (melt ponds)
          DO jl = 1, jpl 
             WRITE(zchar,'(I2.2)') jl
@@ -259,6 +256,9 @@
             v_ip(:,:,jl) = z2d(:,:)
          END DO
-      ENDIF
-      ! END MV MP 2016
+      ELSE                                     ! start from rest
+         IF(lwp) WRITE(numout,*) '   ==>>   previous run without melt ponds output then set it'
+         a_ip(:,:,:) = 0._wp
+         v_ip(:,:,:) = 0._wp
+      ENDIF
 
       DO jl = 1, jpl 
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icestp.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icestp.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icestp.F90	(revision 8752)
@@ -35,5 +35,4 @@
    USE icedyn         ! sea-ice: dynamics
    USE icethd         ! sea-ice: thermodynamics
-   USE limmp          ! sea-ice: melt ponds
    USE icecor         ! sea-ice: corrections
    USE iceupdate      ! sea-ice: sea surface boundary condition update
@@ -154,5 +153,4 @@
          !------------------------------------------------------!
          ! It provides the following fields used in sea ice model:
-         !    fr1_i0  , fr2_i0     = 1sr & 2nd fraction of qsr penetration in ice  [%]
          !    emp_oce , emp_ice    = E-P over ocean and sea ice                    [Kg/m2/s]
          !    sprecip              = solid precipitation                           [Kg/m2/s]
@@ -170,5 +168,4 @@
          IF( ln_icethd )                CALL ice_thd( kt )            ! -- Ice thermodynamics      
          !
-         IF ( ln_pnd )                  CALL lim_mp( kt )             ! -- Melt ponds
          !
          IF( ln_icethd )                CALL ice_cor( kt , 2 )        ! -- Corrections
@@ -238,6 +235,7 @@
       CALL ice_itd_init                ! ice thickness distribution initialization
       !
-      CALL lim_mp_init                 ! set melt ponds parameters (clem: important to be located here)
-      !
+      IF( ln_icethd ) THEN
+         CALL ice_thd_init             ! set ice thermodynics parameters (clem: important to call it first for melt ponds)
+      ENDIF   
       !                                ! Initial sea-ice state
       IF( .NOT. ln_rstart ) THEN              ! start from rest: sea-ice deduced from sst
@@ -255,8 +253,4 @@
          CALL ice_dyn_init             ! set ice dynamics parameters
       ENDIF
-      !
-      IF( ln_icethd ) THEN
-         CALL ice_thd_init             ! set ice thermodynics parameters
-      ENDIF   
       !
       CALL ice_update_init             ! ice surface boundary condition
@@ -325,7 +319,7 @@
          IF(lwp) WRITE(numout,*) '   nn_monocat forced to 0 as jpl>1, i.e. multi-category case is chosen'
       ENDIF
-      IF ( jpl == 1 .AND. nn_monocat == 0 ) THEN
-         CALL ctl_stop( 'STOP', 'par_init : if jpl=1 then nn_monocat should be between 1 and 4' )
-      ENDIF
+!     IF ( jpl == 1 .AND. nn_monocat == 0 ) THEN
+!        CALL ctl_stop( 'STOP', 'par_init : if jpl=1 then nn_monocat should be between 1 and 4' )
+!     ENDIF
       !
       IF( ln_bdy .AND. ln_icediachk )   CALL ctl_warn('par_init: online conservation check does not work with BDY')
@@ -398,7 +392,5 @@
       wfx_snw_sub(:,:) = 0._wp ; wfx_ice_sub(:,:) = 0._wp
       wfx_snw_sni(:,:) = 0._wp 
-      ! MV MP 2016
       wfx_pnd(:,:) = 0._wp
-      ! END MV MP 2016
 
       hfx_thd(:,:) = 0._wp   ;
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd.F90	(revision 8752)
@@ -26,5 +26,5 @@
    USE sbc_oce , ONLY : sss_m, sst_m, e3t_m, utau, vtau, ssu_m, ssv_m, frq_m, qns_tot, qsr_tot, sprecip, ln_cpl
    USE sbc_ice , ONLY : qsr_oce, qns_oce, qemp_oce, qsr_ice, qns_ice, dqns_ice, evap_ice, qprec_ice, qevap_ice, &
-      &                 fr1_i0, fr2_i0
+      &                 qml_ice, qcn_ice, qsr_ice_tr
    USE ice1D          ! sea-ice: thermodynamics variables
    USE icethd_zdf     ! sea-ice: vertical heat diffusion
@@ -34,4 +34,5 @@
    USE icethd_ent     ! sea-ice: enthalpy redistribution
    USE icethd_do      ! sea-ice: growth in open water
+   USE icethd_pnd     ! sea-ice: melt ponds
    USE iceitd         ! sea-ice: remapping thickness distribution
    USE icetab         ! sea-ice: 1D <==> 2D transformation
@@ -86,5 +87,5 @@
       !!             - call ice_thd_rem  for remapping thickness distribution
       !!             - call ice_thd_do   for ice growth in leads
-      !!---------------------------------------------------------------------
+      !!-------------------------------------------------------------------
       INTEGER, INTENT(in) :: kt    ! number of iteration
       !
@@ -230,9 +231,10 @@
             s_i_new   (1:npti) = 0._wp ; dh_s_tot (1:npti) = 0._wp  ! --- some init --- !  (important to have them here) 
             dh_i_surf (1:npti) = 0._wp ; dh_i_bott(1:npti) = 0._wp
-            dh_snowice(1:npti) = 0._wp ; dh_i_sub (1:npti) = 0._wp
+            dh_snowice(1:npti) = 0._wp ; dh_i_sub (1:npti) = 0._wp ; dh_s_mlt(1:npti) = 0._wp
             !
             IF( ln_icedH ) THEN                                     ! --- growing/melting --- !
                               CALL ice_thd_zdf                             ! Ice/Snow Temperature profile
                               CALL ice_thd_dh                              ! Ice/Snow thickness   
+                              CALL ice_thd_pnd                             ! Melt ponds formation
                               CALL ice_thd_ent( e_i_1d(1:npti,:) )         ! Ice enthalpy remapping
             ENDIF
@@ -362,22 +364,23 @@
          CALL tab_2d_1d( npti, nptidx(1:npti), at_i_1d(1:npti), at_i             )
          CALL tab_2d_1d( npti, nptidx(1:npti), a_i_1d (1:npti), a_i (:,:,kl)     )
-         CALL tab_2d_1d( npti, nptidx(1:npti), h_i_1d(1:npti), h_i(:,:,kl)     )
-         CALL tab_2d_1d( npti, nptidx(1:npti), h_s_1d(1:npti), h_s(:,:,kl)     )
+         CALL tab_2d_1d( npti, nptidx(1:npti), h_i_1d (1:npti), h_i (:,:,kl)     )
+         CALL tab_2d_1d( npti, nptidx(1:npti), h_s_1d (1:npti), h_s (:,:,kl)     )
          CALL tab_2d_1d( npti, nptidx(1:npti), t_su_1d(1:npti), t_su(:,:,kl)     )
-         CALL tab_2d_1d( npti, nptidx(1:npti), s_i_1d(1:npti), s_i(:,:,kl)     )
+         CALL tab_2d_1d( npti, nptidx(1:npti), s_i_1d (1:npti), s_i (:,:,kl)     )
          DO jk = 1, nlay_s
-            CALL tab_2d_1d( npti, nptidx(1:npti), t_s_1d(1:npti,jk), t_s(:,:,jk,kl)   )
-            CALL tab_2d_1d( npti, nptidx(1:npti), e_s_1d(1:npti,jk), e_s(:,:,jk,kl)   )
+            CALL tab_2d_1d( npti, nptidx(1:npti), t_s_1d(1:npti,jk), t_s(:,:,jk,kl)    )
+            CALL tab_2d_1d( npti, nptidx(1:npti), e_s_1d(1:npti,jk), e_s(:,:,jk,kl)    )
          END DO
          DO jk = 1, nlay_i
-            CALL tab_2d_1d( npti, nptidx(1:npti), t_i_1d(1:npti,jk), t_i(:,:,jk,kl)   )
-            CALL tab_2d_1d( npti, nptidx(1:npti), e_i_1d(1:npti,jk), e_i(:,:,jk,kl)   )
-            CALL tab_2d_1d( npti, nptidx(1:npti), sz_i_1d(1:npti,jk), sz_i(:,:,jk,kl)   )
-         END DO
+            CALL tab_2d_1d( npti, nptidx(1:npti), t_i_1d (1:npti,jk), t_i (:,:,jk,kl)  )
+            CALL tab_2d_1d( npti, nptidx(1:npti), e_i_1d (1:npti,jk), e_i (:,:,jk,kl)  )
+            CALL tab_2d_1d( npti, nptidx(1:npti), sz_i_1d(1:npti,jk), sz_i(:,:,jk,kl)  )
+         END DO
+         CALL tab_2d_1d( npti, nptidx(1:npti), a_ip_1d     (1:npti), a_ip     (:,:,kl) )
+         CALL tab_2d_1d( npti, nptidx(1:npti), h_ip_1d     (1:npti), h_ip     (:,:,kl) )
+         CALL tab_2d_1d( npti, nptidx(1:npti), a_ip_frac_1d(1:npti), a_ip_frac(:,:,kl) )
          !
          CALL tab_2d_1d( npti, nptidx(1:npti), qprec_ice_1d(1:npti), qprec_ice        )
          CALL tab_2d_1d( npti, nptidx(1:npti), qsr_ice_1d  (1:npti), qsr_ice (:,:,kl) )
-         CALL tab_2d_1d( npti, nptidx(1:npti), fr1_i0_1d   (1:npti), fr1_i0           )
-         CALL tab_2d_1d( npti, nptidx(1:npti), fr2_i0_1d   (1:npti), fr2_i0           )
          CALL tab_2d_1d( npti, nptidx(1:npti), qns_ice_1d  (1:npti), qns_ice (:,:,kl) )
          CALL tab_2d_1d( npti, nptidx(1:npti), ftr_ice_1d  (1:npti), ftr_ice (:,:,kl) )
@@ -388,4 +391,8 @@
          CALL tab_2d_1d( npti, nptidx(1:npti), fhtur_1d    (1:npti), fhtur            )
          CALL tab_2d_1d( npti, nptidx(1:npti), fhld_1d     (1:npti), fhld             )
+         
+         CALL tab_2d_1d( npti, nptidx(1:npti), qml_ice_1d   (1:npti), qml_ice      (:,:,kl)  )
+         CALL tab_2d_1d( npti, nptidx(1:npti), qcn_ice_1d   (1:npti), qcn_ice      (:,:,kl) )
+         CALL tab_2d_1d( npti, nptidx(1:npti), qsr_ice_tr_1d(1:npti), qsr_ice_tr   (:,:,kl) )
          !
          CALL tab_2d_1d( npti, nptidx(1:npti), wfx_snw_sni_1d(1:npti), wfx_snw_sni   )
@@ -403,4 +410,5 @@
          CALL tab_2d_1d( npti, nptidx(1:npti), wfx_spr_1d (1:npti), wfx_spr          )
          CALL tab_2d_1d( npti, nptidx(1:npti), wfx_lam_1d (1:npti), wfx_lam          )
+         CALL tab_2d_1d( npti, nptidx(1:npti), wfx_pnd_1d (1:npti), wfx_pnd          )
          !
          CALL tab_2d_1d( npti, nptidx(1:npti), sfx_bog_1d (1:npti), sfx_bog          )
@@ -454,23 +462,27 @@
          !
          ! Change thickness to volume (replaces routine ice_var_eqv2glo)
-         v_i_1d(1:npti)  = h_i_1d(1:npti) * a_i_1d(1:npti)
-         v_s_1d(1:npti)  = h_s_1d(1:npti) * a_i_1d(1:npti)
-         sv_i_1d(1:npti) = s_i_1d(1:npti) * v_i_1d(1:npti)
+         v_i_1d (1:npti) = h_i_1d (1:npti) * a_i_1d (1:npti)
+         v_s_1d (1:npti) = h_s_1d (1:npti) * a_i_1d (1:npti)
+         sv_i_1d(1:npti) = s_i_1d (1:npti) * v_i_1d (1:npti)
+         v_ip_1d(1:npti) = h_ip_1d(1:npti) * a_ip_1d(1:npti)
          
          CALL tab_1d_2d( npti, nptidx(1:npti), at_i_1d(1:npti), at_i             )
          CALL tab_1d_2d( npti, nptidx(1:npti), a_i_1d (1:npti), a_i (:,:,kl)     )
-         CALL tab_1d_2d( npti, nptidx(1:npti), h_i_1d(1:npti), h_i(:,:,kl)     )
-         CALL tab_1d_2d( npti, nptidx(1:npti), h_s_1d(1:npti), h_s(:,:,kl)     )
+         CALL tab_1d_2d( npti, nptidx(1:npti), h_i_1d (1:npti), h_i (:,:,kl)     )
+         CALL tab_1d_2d( npti, nptidx(1:npti), h_s_1d (1:npti), h_s (:,:,kl)     )
          CALL tab_1d_2d( npti, nptidx(1:npti), t_su_1d(1:npti), t_su(:,:,kl)     )
-         CALL tab_1d_2d( npti, nptidx(1:npti), s_i_1d(1:npti), s_i(:,:,kl)     )
+         CALL tab_1d_2d( npti, nptidx(1:npti), s_i_1d (1:npti), s_i (:,:,kl)     )
          DO jk = 1, nlay_s
-            CALL tab_1d_2d( npti, nptidx(1:npti), t_s_1d(1:npti,jk), t_s(:,:,jk,kl) )
-            CALL tab_1d_2d( npti, nptidx(1:npti), e_s_1d(1:npti,jk), e_s(:,:,jk,kl) )
+            CALL tab_1d_2d( npti, nptidx(1:npti), t_s_1d(1:npti,jk), t_s(:,:,jk,kl)    )
+            CALL tab_1d_2d( npti, nptidx(1:npti), e_s_1d(1:npti,jk), e_s(:,:,jk,kl)    )
          END DO
          DO jk = 1, nlay_i
-            CALL tab_1d_2d( npti, nptidx(1:npti), t_i_1d(1:npti,jk), t_i(:,:,jk,kl) )
-            CALL tab_1d_2d( npti, nptidx(1:npti), e_i_1d(1:npti,jk), e_i(:,:,jk,kl) )
-            CALL tab_1d_2d( npti, nptidx(1:npti), sz_i_1d(1:npti,jk), sz_i(:,:,jk,kl) )
-         END DO
+            CALL tab_1d_2d( npti, nptidx(1:npti), t_i_1d (1:npti,jk), t_i (:,:,jk,kl)  )
+            CALL tab_1d_2d( npti, nptidx(1:npti), e_i_1d (1:npti,jk), e_i (:,:,jk,kl)  )
+            CALL tab_1d_2d( npti, nptidx(1:npti), sz_i_1d(1:npti,jk), sz_i(:,:,jk,kl)  )
+         END DO
+         CALL tab_1d_2d( npti, nptidx(1:npti), a_ip_1d     (1:npti), a_ip     (:,:,kl) )
+         CALL tab_1d_2d( npti, nptidx(1:npti), h_ip_1d     (1:npti), h_ip     (:,:,kl) )
+         CALL tab_1d_2d( npti, nptidx(1:npti), a_ip_frac_1d(1:npti), a_ip_frac(:,:,kl) )
          !
          CALL tab_1d_2d( npti, nptidx(1:npti), wfx_snw_sni_1d(1:npti), wfx_snw_sni )
@@ -488,4 +500,5 @@
          CALL tab_1d_2d( npti, nptidx(1:npti), wfx_spr_1d (1:npti), wfx_spr        )
          CALL tab_1d_2d( npti, nptidx(1:npti), wfx_lam_1d (1:npti), wfx_lam        )
+         CALL tab_1d_2d( npti, nptidx(1:npti), wfx_pnd_1d (1:npti), wfx_pnd        )
          !
          CALL tab_1d_2d( npti, nptidx(1:npti), sfx_bog_1d (1:npti), sfx_bog        )
@@ -523,4 +536,5 @@
          CALL tab_1d_2d( npti, nptidx(1:npti), v_s_1d (1:npti), v_s (:,:,kl) )
          CALL tab_1d_2d( npti, nptidx(1:npti), sv_i_1d(1:npti), sv_i(:,:,kl) )
+         CALL tab_1d_2d( npti, nptidx(1:npti), v_ip_1d(1:npti), v_ip(:,:,kl) )
          !
       END SELECT
@@ -530,5 +544,5 @@
 
    SUBROUTINE ice_thd_init
-      !!-----------------------------------------------------------------------
+      !!-------------------------------------------------------------------
       !!                   ***  ROUTINE ice_thd_init *** 
       !!                 
@@ -570,9 +584,5 @@
       IF( ln_icedO )   CALL ice_thd_do_init    ! set ice growth in open water parameters
                        CALL ice_thd_sal_init   ! set ice salinity parameters
-      !
-      IF( ln_icedS .AND. nn_icesal == 1 ) THEN
-         ln_icedS = .FALSE.
-         CALL ctl_warn('ln_icedS is set to false since constant ice salinity is chosen (nn_icesal=1)')
-      ENDIF
+                       CALL ice_thd_pnd_init   ! set melt ponds parameters
       !
    END SUBROUTINE ice_thd_init
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd_dh.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd_dh.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd_dh.F90	(revision 8752)
@@ -130,9 +130,32 @@
       !------------------------------------------------------------------------------!
       !
-      DO ji = 1, npti
-         zdum       = qns_ice_1d(ji) + ( 1._wp - i0(ji) ) * qsr_ice_1d(ji) - fc_su(ji) 
+      SELECT CASE ( nice_jules )
+
+         CASE ( np_jules_ACTIVE )
+
+            DO ji = 1, npti
+               zq_su(ji)        =   MAX( 0._wp, qml_ice_1d(ji) * rdt_ice )
+            END DO
+
+         CASE ( np_jules_EMULE )
+
+            DO ji = 1, npti
+               zdum             =   ( qns_ice_1d(ji) + qsr_ice_1d(ji) - qsr_ice_tr_1d(ji) - fc_su(ji) ) 
+               qml_ice_1d(ji)   =   zdum * MAX( 0._wp , SIGN( 1._wp, t_su_1d(ji) - rt0 ) )
+               zq_su(ji)        =   MAX( 0._wp, qml_ice_1d(ji) * rdt_ice )
+            END DO
+
+         CASE ( np_jules_OFF ) 
+
+            DO ji = 1, npti
+               zdum             =   ( qns_ice_1d(ji) + qsr_ice_1d(ji) - qsr_ice_tr_1d(ji) - fc_su(ji) ) 
+               zdum             =   zdum * MAX( 0._wp , SIGN( 1._wp, t_su_1d(ji) - rt0 ) )
+               zq_su(ji)        =   MAX( 0._wp, zdum             * rdt_ice )
+            END DO
+
+      END SELECT
+         
+      DO ji = 1, npti
          zf_tt(ji)  = fc_bo_i(ji) + fhtur_1d(ji) + fhld_1d(ji) 
-
-         zq_su (ji) = MAX( 0._wp, zdum      * rdt_ice ) * MAX( 0._wp , SIGN( 1._wp, t_su_1d(ji) - rt0 ) )
          zq_bo (ji) = MAX( 0._wp, zf_tt(ji) * rdt_ice )
       END DO
@@ -148,6 +171,7 @@
             ! Contribution to mass flux
             wfx_snw_sum_1d(ji) = wfx_snw_sum_1d(ji) + rhosn * h_s_1d(ji) * a_i_1d(ji) * r1_rdtice
+            dh_s_mlt(ji)       = dh_s_mlt(ji) - h_s_1d(ji)
             ! updates
-            h_s_1d(ji)   = 0._wp
+            h_s_1d(ji)    = 0._wp
             e_s_1d (ji,1) = 0._wp
             t_s_1d (ji,1) = rt0
@@ -211,4 +235,5 @@
          ! snow melting only = water into the ocean (then without snow precip), >0
          wfx_snw_sum_1d(ji) = wfx_snw_sum_1d(ji) - rhosn * a_i_1d(ji) * zdeltah(ji,1) * r1_rdtice
+         dh_s_mlt(ji)       = dh_s_mlt(ji) + zdeltah(ji,1)
          ! updates available heat + precipitations after melting
          zq_su     (ji) = MAX( 0._wp , zq_su (ji) + zdeltah(ji,1) * zqprec(ji) )      
@@ -233,7 +258,8 @@
             hfx_snw_1d(ji)   = hfx_snw_1d(ji) - zdeltah(ji,jk) * a_i_1d(ji) * e_s_1d(ji,jk) * r1_rdtice 
             ! snow melting only = water into the ocean (then without snow precip)
-            wfx_snw_sum_1d(ji)   = wfx_snw_sum_1d(ji) - rhosn * a_i_1d(ji) * zdeltah(ji,jk) * r1_rdtice
+            wfx_snw_sum_1d(ji) = wfx_snw_sum_1d(ji) - rhosn * a_i_1d(ji) * zdeltah(ji,jk) * r1_rdtice
+            dh_s_mlt(ji)       = dh_s_mlt(ji) + zdeltah(ji,jk)
             ! updates available heat + thickness
-            zq_su (ji)  = MAX( 0._wp , zq_su (ji) + zdeltah(ji,jk) * e_s_1d(ji,jk) )
+            zq_su (ji) = MAX( 0._wp , zq_su (ji) + zdeltah(ji,jk) * e_s_1d(ji,jk) )
             h_s_1d(ji) = MAX( 0._wp , h_s_1d(ji) + zdeltah(ji,jk) )
          END DO
@@ -571,5 +597,5 @@
          zdeltah  (ji,1) = MIN( 0._wp , MAX( zdeltah(ji,1) , - h_s_1d(ji) ) ) ! bound melting
          dh_s_tot (ji)   = dh_s_tot(ji)  + zdeltah(ji,1)
-         h_s_1d   (ji)  = h_s_1d(ji)   + zdeltah(ji,1)
+         h_s_1d   (ji)   = h_s_1d(ji)   + zdeltah(ji,1)
         
          zq_rema(ji)     = zq_rema(ji) + zdeltah(ji,1) * e_s_1d(ji,1)                ! update available heat (J.m-2)
@@ -577,5 +603,6 @@
          hfx_snw_1d(ji)  = hfx_snw_1d(ji) - zdeltah(ji,1) * a_i_1d(ji) * e_s_1d(ji,1) * r1_rdtice ! W.m-2 (>0)
          ! Contribution to mass flux
-         wfx_snw_sum_1d(ji)  =  wfx_snw_sum_1d(ji) - rhosn * a_i_1d(ji) * zdeltah(ji,1) * r1_rdtice
+         wfx_snw_sum_1d(ji) = wfx_snw_sum_1d(ji) - rhosn * a_i_1d(ji) * zdeltah(ji,1) * r1_rdtice
+         dh_s_mlt(ji)       = dh_s_mlt(ji) + zdeltah(ji,1)
          !    
          ! Remaining heat flux (W.m-2) is sent to the ocean heat budget
@@ -611,5 +638,5 @@
 
          ! Case constant salinity in time: virtual salt flux to keep salinity constant
-         IF( nn_icesal == 1 .OR. nn_icesal == 3 )  THEN
+         IF( nn_icesal /= 2 )  THEN
             sfx_bri_1d(ji) = sfx_bri_1d(ji) - sss_1d (ji) * a_i_1d(ji) * zfmdt                  * r1_rdtice  & ! put back sss_m     into the ocean
                &                            - s_i_1d(ji)  * a_i_1d(ji) * dh_snowice(ji) * rhoic * r1_rdtice    ! and get  rn_icesal from the ocean 
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd_pnd.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd_pnd.F90	(revision 8752)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd_pnd.F90	(revision 8752)
@@ -0,0 +1,290 @@
+MODULE icethd_pnd 
+   !!======================================================================
+   !!                     ***  MODULE  icethd_pnd   ***
+   !!   Melt ponds
+   !!======================================================================
+   !! history :       ! Original code by Daniela Flocco and Adrian Turner
+   !!            1.0  ! 2012    (O. Lecomte) Adaptation for scientific tests (NEMO3.1)
+   !!            2.0  ! 2017    (M. Vancoppenolle, O. Lecomte, C. Rousset) Implementation in NEMO4
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                     ESIM sea-ice model
+   !!----------------------------------------------------------------------
+   !!   ice_thd_pnd_init      : some initialization and namelist read
+   !!   ice_thd_pnd           : main calling routine
+   !!----------------------------------------------------------------------
+   USE phycst         ! physical constants
+   USE dom_oce        ! ocean space and time domain
+   USE ice            ! sea-ice: variables
+   USE ice1D          ! sea-ice: thermodynamics variables
+   USE icetab         ! sea-ice: 1D <==> 2D transformation
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ice_thd_pnd_init    ! routine called by icestp.F90
+   PUBLIC   ice_thd_pnd         ! routine called by icestp.F90
+
+   INTEGER ::              nice_pnd   ! choice of the type of pond scheme
+   !                                               ! associated indices:
+   INTEGER, PARAMETER ::   np_pndNO  = 0   ! No pond scheme
+   INTEGER, PARAMETER ::   np_pndCST = 1   ! Constant pond scheme
+   INTEGER, PARAMETER ::   np_pndH12 = 2   ! Evolutive pond scheme (Holland et al. 2012)
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/ICE 4.0 , NEMO Consortium (2017)
+   !! $Id: icethd_pnd.F90 8420 2017-10-05 13:07:10Z clem $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE ice_thd_pnd
+      !!-------------------------------------------------------------------
+      !!               ***  ROUTINE ice_thd_pnd   ***
+      !!               
+      !! ** Purpose :   change melt pond fraction
+      !!                
+      !! ** Method  :   brut force
+      !!
+      !! ** Action  : - 
+      !!              - 
+      !!-------------------------------------------------------------------
+
+      IF( nn_timing == 1 )  CALL timing_start('ice_thd_pnd')
+
+      SELECT CASE ( nice_pnd )
+
+      CASE (np_pndCST)
+         !                             !-------------------------------!
+         CALL pnd_CST                  ! Constant melt ponds           !
+         !                             !-------------------------------!
+      CASE (np_pndH12)
+         !                             !-------------------------------!
+         CALL pnd_H12                  ! Holland et al 2012 melt ponds !
+         !                             !-------------------------------!
+      END SELECT
+
+      IF( nn_timing == 1 )  CALL timing_stop('ice_thd_pnd')
+
+   END SUBROUTINE ice_thd_pnd 
+
+   SUBROUTINE pnd_CST 
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE pnd_CST  ***
+      !!
+      !! ** Purpose    : Compute melt pond evolution
+      !!
+      !! ** Method     : Melt pond fraction and thickness are prescribed 
+      !!                 to non-zero values when t_su = 0C
+      !!
+      !! ** Tunable parameters : pond fraction (rn_apnd), pond depth (rn_hpnd)
+      !!                
+      !! ** Note       : Coupling with such melt ponds is only radiative
+      !!                 Advection, ridging, rafting... are bypassed
+      !!
+      !! ** References : Bush, G.W., and Trump, D.J. (2017)
+      !!    
+      !!-------------------------------------------------------------------
+      INTEGER  ::   ji        ! loop indices
+      !!-------------------------------------------------------------------
+      DO ji = 1, npti
+         
+         IF( a_i_1d(ji) > 0._wp .AND. t_su_1d(ji) >= rt0 ) THEN
+            a_ip_frac_1d(ji) = rn_apnd
+            h_ip_1d(ji)      = rn_hpnd    
+            a_ip_1d(ji)      = a_ip_frac_1d(ji) * a_i_1d(ji)
+         ELSE
+            a_ip_frac_1d(ji) = 0._wp
+            h_ip_1d(ji)      = 0._wp    
+            a_ip_1d(ji)      = 0._wp
+         ENDIF
+         
+      END DO
+      
+   END SUBROUTINE pnd_CST
+
+   SUBROUTINE pnd_H12
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE pnd_H12  ***
+      !!
+      !! ** Purpose    : Compute melt pond evolution
+      !!
+      !! ** Method     : Empirical method. A fraction of meltwater is accumulated in ponds 
+      !!                 and sent to ocean when surface is freezing
+      !!
+      !!                 pond growth:      Vp = Vp + dVmelt
+      !!                    with dVmelt = R/rhow * ( rhoi*dh_i + rhos*dh_s ) * a_i
+      !!                 pond contraction: Vp = Vp * exp(0.01*MAX(Tp-Tsu,0)/Tp)
+      !!                    with Tp = -2degC
+      !!
+      !! ** Tunable parameters : (no real expertise yet, ideas?)
+      !! 
+      !! ** Note       : Stolen from CICE for quick test of the melt pond
+      !!                 radiation and freshwater interfaces
+      !!                 Coupling can be radiative AND freshwater
+      !!                 Advection, ridging, rafting are called
+      !!
+      !! ** References : Holland, M. M. et al (J Clim 2012)
+      !!    
+      !!-------------------------------------------------------------------
+      REAL(wp), PARAMETER ::   zrmin  = 0.15_wp  ! minimum fraction of available meltwater retained for melt ponding
+      REAL(wp), PARAMETER ::   zrmax  = 0.70_wp  ! maximum   ''           ''       ''        ''            ''
+      REAL(wp), PARAMETER ::   zpnd_aspect = 0.8_wp ! pond aspect ratio
+      REAL(wp), PARAMETER ::   zTp = -2._wp ! 
+
+      REAL(wp) ::   zfr_mlt            ! fraction of available meltwater retained for melt ponding
+      REAL(wp) ::   zdv_mlt          ! available meltwater for melt ponding
+      REAL(wp) ::   z1_Tp        ! reference temperature
+      REAL(wp) ::   z1_rhofw          ! inverse freshwater density
+      REAL(wp) ::   z1_zpnd_aspect    ! inverse pond aspect ratio
+      REAL(wp) ::   zvpnd            ! dummy pond volume
+      REAL(wp) ::   zfac, zdum
+
+      INTEGER  ::   ji        ! loop indices
+      !!-------------------------------------------------------------------
+      z1_rhofw       = 1. / rhofw 
+      z1_zpnd_aspect = 1. / zpnd_aspect
+      z1_Tp          = 1._wp / zTp 
+
+      DO ji = 1, npti
+         !                                                        !--------------------------------!
+         IF( h_i_1d(ji) < rn_himin) THEN                          ! Case ice thickness < rn_himin  !
+            !                                                     !--------------------------------!
+            !--- Remove ponds on thin ice and send water into the ocean
+            IF( ln_pnd_fwb ) THEN
+               wfx_pnd_1d(ji) = wfx_pnd_1d(ji) + h_ip_1d(ji) * a_ip_1d(ji) * rhofw * r1_rdtice
+            ENDIF
+            a_ip_1d(ji)      = 0._wp
+            a_ip_frac_1d(ji) = 0._wp
+            h_ip_1d(ji)      = 0._wp
+            !                                                     !--------------------------------!
+         ELSE                                                     ! Case ice thickness >= rn_himin !
+            !                                                     !--------------------------------!
+            v_ip_1d(ji) = h_ip_1d(ji) * a_ip_1d(ji)   ! record pond volume at previous time step
+            zvpnd       = v_ip_1d(ji)
+
+            ! available meltwater for melt ponding [m, >0] and fraction
+            zdv_mlt = -( dh_i_surf(ji)*rhoic + dh_s_mlt(ji)*rhosn ) * z1_rhofw * a_i_1d(ji)
+            zfr_mlt = zrmin + ( zrmax - zrmin ) * a_i_1d(ji)  !!clem CICE doc
+!!!            zfr_mlt = zrmin + zrmax * a_i_1d(ji)  !!clem Holland paper 
+
+            !--- Pond gowth
+            ! v_ip should never be negative, otherwise code crashes
+            ! MV: as far as I saw, UM5 can create very small negative v_ip values (not Prather)
+            v_ip_1d(ji) = MAX( 0._wp, v_ip_1d(ji) + zfr_mlt * zdv_mlt )
+
+            IF( ln_pnd_fwb .AND. zdv_mlt > 0._wp ) THEN
+               ! melt ponds mass flux (<0)
+               zfac = zfr_mlt * zdv_mlt * rhofw * r1_rdtice
+               wfx_pnd_1d(ji) = wfx_pnd_1d(ji) - zfac
+
+               ! adjust ice/snow melting (>0) to take into account ponding
+               zdum = zfac / ( wfx_snw_sum_1d(ji) + wfx_sum_1d(ji) )
+               wfx_snw_sum_1d(ji) = wfx_snw_sum_1d(ji) * (1._wp + zdum)
+               wfx_sum_1d(ji)     = wfx_sum_1d(ji)     * (1._wp + zdum)
+            ENDIF
+
+            !--- Pond contraction (due to refreezing)
+            v_ip_1d(ji)      = v_ip_1d(ji) * EXP( 0.01_wp * MAX( zTp+rt0 - t_su_1d(ji), 0._wp ) * z1_Tp )
+
+            ! --- Set new pond area and depth assuming linear relation between h_ip and a_ip_frac
+            !        h_ip = zpnd_aspect * a_ip_frac = zpnd_aspect * a_ip/a_i
+            a_ip_1d(ji)      = SQRT( v_ip_1d(ji) * z1_zpnd_aspect * a_i_1d(ji) )
+            !NB: the SQRT has been a recurring source of crash when v_ip or a_i tuns to be even only slightly negative
+            a_ip_frac_1d(ji) = a_ip_1d(ji) / a_i_1d(ji)
+            h_ip_1d(ji)      = zpnd_aspect * a_ip_frac_1d(ji)
+
+            !! clem: there is no clever way to conserve mass here...
+            
+!            IF( ln_pnd_fwb ) THEN
+!               ! melt ponds mass flux (>0 when ponds shrink)
+!               zfac = ( v_ip_1d(ji) - zvpnd ) * rhofw * r1_rdtice
+!               wfx_pnd_1d(ji) = wfx_pnd_1d(ji) - zfac!!
+!
+!               ! adjust ice/snow
+!               zfac = ( v_ip_1d(ji) - zvpnd ) * rhofw / ( a_i_1d(ji)*h_s_1d(ji)*rhosn + a_i_1d(ji)*h_i_1d(ji)*rhoic )!
+!
+!               wfx_snw_sum_1d(ji) = wfx_snw_sum_1d(ji) + h_s_1d(ji) * zfac * a_i_1d(ji) * rhosn * r1_rdtice
+!               wfx_sum_1d(ji)     = wfx_sum_1d(ji)     + h_i_1d(ji) * zfac * a_i_1d(ji) * rhoic * r1_rdtice
+!               
+!               !!h_s_1d(ji) = h_s_1d(ji) * ( 1._wp + zfac )
+!               !!h_i_1d(ji) = h_i_1d(ji) * ( 1._wp + zfac )!
+!
+!            ENDIF
+
+         ENDIF
+      END DO
+
+   END SUBROUTINE pnd_H12
+
+   SUBROUTINE ice_thd_pnd_init 
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE ice_thd_pnd_init   ***
+      !!
+      !! ** Purpose : Physical constants and parameters linked to melt ponds
+      !!              over sea ice
+      !!
+      !! ** Method  :  Read the namthd_pnd  namelist and check the melt pond  
+      !!               parameter values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namthd_pnd  
+      !!-------------------------------------------------------------------
+      INTEGER  ::   ios, ioptio                 ! Local integer output status for namelist read
+      NAMELIST/namthd_pnd/  ln_pnd_H12, ln_pnd_fwb, ln_pnd_CST, rn_apnd, rn_hpnd, ln_pnd_alb
+      !!-------------------------------------------------------------------
+
+      REWIND( numnam_ice_ref )              ! Namelist namthd_pnd  in reference namelist : Melt Ponds  
+      READ  ( numnam_ice_ref, namthd_pnd, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namthd_pnd  in reference namelist', lwp )
+
+      REWIND( numnam_ice_cfg )              ! Namelist namthd_pnd  in configuration namelist : Melt Ponds
+      READ  ( numnam_ice_cfg, namthd_pnd, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namthd_pnd in configuration namelist', lwp )
+      IF(lwm) WRITE ( numoni, namthd_pnd )
+      
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'ice_thd_pnd_init: ice parameters for melt ponds'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namicethd_pnd:'
+         WRITE(numout,*) '      Evolutive melt pond fraction and depth (Holland et al 2012)  ln_pnd_H12 = ', ln_pnd_H12
+         WRITE(numout,*) '         Melt ponds store fresh water or not                       ln_pnd_fwb = ', ln_pnd_fwb
+         WRITE(numout,*) '      Prescribed melt pond fraction and depth                      ln_pnd_Cst = ', ln_pnd_CST
+         WRITE(numout,*) '         Prescribed pond fraction                                  rn_apnd    = ', rn_apnd
+         WRITE(numout,*) '         Prescribed pond depth                                     rn_hpnd    = ', rn_hpnd
+         WRITE(numout,*) '      Melt ponds affect albedo or not                              ln_pnd_alb = ', ln_pnd_alb
+      ENDIF
+      !
+      !                             !== set the choice of ice pond scheme ==!
+      ioptio = 0
+                                                            nice_pnd = np_pndNO
+      IF( ln_pnd_CST ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndCST    ;   ENDIF
+      IF( ln_pnd_H12 ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndH12    ;   ENDIF
+      IF( ioptio > 1 )   CALL ctl_stop( 'ice_thd_pnd_init: choose one and only one pond scheme (ln_pnd_H12 or ln_pnd_CST)' )
+
+      SELECT CASE( nice_pnd )
+      CASE( np_pndNO )         
+         IF(ln_pnd_fwb) THEN ; ln_pnd_fwb = .FALSE. ; CALL ctl_warn( 'ln_pnd_fwb=false when no ponds' ) ; ENDIF
+         IF(ln_pnd_alb) THEN ; ln_pnd_alb = .FALSE. ; CALL ctl_warn( 'ln_pnd_alb=false when no ponds' ) ; ENDIF
+      CASE( np_pndCST)
+         IF(ln_pnd_fwb) THEN ; ln_pnd_fwb = .FALSE. ; CALL ctl_warn( 'ln_pnd_fwb=false when ln_pnd_CST=true' ) ; ENDIF
+      END SELECT
+      !
+   END SUBROUTINE ice_thd_pnd_init
+   
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Empty module          NO ESIM sea-ice model
+   !!----------------------------------------------------------------------
+#endif 
+
+   !!======================================================================
+END MODULE icethd_pnd 
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd_zdf.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd_zdf.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icethd_zdf.F90	(revision 8752)
@@ -34,8 +34,15 @@
    LOGICAL  ::   ln_cndi_U64      ! thermal conductivity: Untersteiner (1964)
    LOGICAL  ::   ln_cndi_P07      ! thermal conductivity: Pringle et al (2007)
-   REAL(wp) ::   rn_cnd_s         ! thermal conductivity of the snow [W/m/K]
    REAL(wp) ::   rn_kappa_i       ! coef. for the extinction of radiation Grenfell et al. (2006) [1/m]
-   LOGICAL  ::   ln_dqns_i        ! change non-solar surface flux with changing surface temperature (T) or not (F)
-
+   REAL(wp), PUBLIC ::   rn_cnd_s ! thermal conductivity of the snow [W/m/K]
+
+   INTEGER  ::   nice_zdf         ! Choice of the type of vertical heat diffusion formulation
+   !                                           ! associated indices:
+   INTEGER, PARAMETER ::   np_BL99    = 1      ! Bitz and Lipscomb (1999)
+
+   INTEGER , PARAMETER ::   np_zdf_jules_OFF    = 0   !   compute all temperatures from qsr and qns
+   INTEGER , PARAMETER ::   np_zdf_jules_SND    = 1   !   compute conductive heat flux and surface temperature from qsr and qns
+   INTEGER , PARAMETER ::   np_zdf_jules_RCV    = 2   !   compute snow and inner ice temperatures from qcnd
+   
    !!----------------------------------------------------------------------
    !! NEMO/ICE 4.0 , NEMO Consortium (2017)
@@ -45,10 +52,54 @@
 CONTAINS
 
-   SUBROUTINE ice_thd_zdf
+      SUBROUTINE ice_thd_zdf
+      
+      !!
       !!-------------------------------------------------------------------
       !!                ***  ROUTINE ice_thd_zdf  ***
       !! ** Purpose :
+      !!           This chooses between the appropriate routine for the 
+      !!           computation of vertical diffusion
+      !!
+      !!-------------------------------------------------------------------
+      !!
+   
+      SELECT CASE ( nice_zdf )      ! Choose the vertical heat diffusion solver
+      
+                                       !-------------      
+         CASE( np_BL99 )               ! BL99 solver
+                                       !-------------
+         
+            IF ( nice_jules == np_jules_OFF ) THEN   ! No Jules coupler     
+
+               CALL ice_thd_zdf_BL99 ( np_zdf_jules_OFF )
+                                       
+            ENDIF
+            
+            IF ( nice_jules == np_jules_EMULE ) THEN   ! Jules coupler is emulated
+            
+               CALL ice_thd_zdf_BL99 ( np_zdf_jules_SND )
+               CALL ice_thd_zdf_BL99 ( np_zdf_jules_RCV )
+                                                   
+            ENDIF
+
+            IF ( nice_jules == np_jules_ACTIVE ) THEN   ! Jules coupler is emulated
+            
+               CALL ice_thd_zdf_BL99 ( np_zdf_jules_RCV )
+                                                   
+            ENDIF
+            
+      END SELECT
+      
+   END SUBROUTINE ice_thd_zdf
+   
+   
+   
+   SUBROUTINE ice_thd_zdf_BL99(k_jules)
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE ice_thd_zdf_BL99  ***
+      !! ** Purpose :
       !!           This routine determines the time evolution of snow and sea-ice 
-      !!           temperature profiles.
+      !!           temperature profiles, using the original Bitz and Lipscomb (1999) algorithm
+      !!
       !! ** Method  :
       !!           This is done by solving the heat equation diffusion with
@@ -83,4 +134,6 @@
       !!           total ice/snow thickness : h_i_1d, h_s_1d
       !!-------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   k_jules     ! Jules coupling (0=OFF, 1=RECEIVE, 2=SEND)
+      
       INTEGER ::   ji, jk         ! spatial loop index
       INTEGER ::   jm             ! current reference number of equation
@@ -101,5 +154,4 @@
       REAL(wp) ::   zdti_bnd  =  1.e-4_wp     ! maximal authorized error on temperature 
       REAL(wp) ::   ztmelt_i                  ! ice melting temperature
-      REAL(wp) ::   z1_hsu
       REAL(wp) ::   zdti_max                  ! current maximal error on temperature 
       REAL(wp) ::   zcpi                      ! Ice specific heat
@@ -111,10 +163,9 @@
       REAL(wp), DIMENSION(jpij)     ::   zh_i, z1_h_i ! ice layer thickness
       REAL(wp), DIMENSION(jpij)     ::   zh_s, z1_h_s ! snow layer thickness
-      REAL(wp), DIMENSION(jpij)     ::   zfsw        ! solar radiation absorbed at the surface
       REAL(wp), DIMENSION(jpij)     ::   zqns_ice_b  ! solar radiation absorbed at the surface
       REAL(wp), DIMENSION(jpij)     ::   zfnet       ! surface flux function
       REAL(wp), DIMENSION(jpij)     ::   zdqns_ice_b ! derivative of the surface flux function
-      REAL(wp), DIMENSION(jpij)     ::   zftrice     ! solar radiation transmitted through the ice
-      
+      
+      REAL(wp), DIMENSION(jpij       )     ::   ztsuold     ! Old surface temperature in the ice
       REAL(wp), DIMENSION(jpij,nlay_i)     ::   ztiold      ! Old temperature in the ice
       REAL(wp), DIMENSION(jpij,nlay_s)     ::   ztsold      ! Old temperature in the snow
@@ -136,4 +187,6 @@
       REAL(wp), DIMENSION(jpij)            ::   zq_ini      ! diag errors on heat
       REAL(wp), DIMENSION(jpij)            ::   zghe        ! G(he), th. conduct enhancement factor, mono-cat
+
+      REAL(wp) ::   zfr1, zfr2, zfrqsr_tr_i   ! dummy factor
       
       ! Mono-category
@@ -166,38 +219,43 @@
       ELSEWHERE                         ;   z1_h_s(1:npti) = 0._wp
       END WHERE
-      !
-      ! temperatures
-      ztsub  (1:npti)   = t_su_1d(1:npti)  ! temperature at the previous iteration
+
+      ! Store initial temperatures and non solar heat fluxes
+      IF ( k_jules == np_zdf_jules_OFF .OR. k_jules == np_zdf_jules_SND  ) THEN ! OFF or SND mode
+
+         ztsub  (1:npti)       =   t_su_1d(1:npti)                          ! surface temperature at iteration n-1
+         ztsuold(1:npti)       =   t_su_1d(1:npti)                          ! surface temperature initial value
+         zdqns_ice_b(1:npti)   =   dqns_ice_1d(1:npti)                      ! derivative of incoming nonsolar flux 
+         zqns_ice_b (1:npti)   =   qns_ice_1d(1:npti)                       ! store previous qns_ice_1d value
+
+         t_su_1d(1:npti)       =   MIN( t_su_1d(1:npti), rt0 - ztsu_err )   ! required to leave the choice between melting or not
+
+      ENDIF   
+
       ztsold (1:npti,:) = t_s_1d(1:npti,:)   ! Old snow temperature
       ztiold (1:npti,:) = t_i_1d(1:npti,:)   ! Old ice temperature
-      t_su_1d(1:npti)   = MIN( t_su_1d(1:npti), rt0 - ztsu_err )   ! necessary
-      !
+
       !-------------
       ! 2) Radiation
       !-------------
-      z1_hsu = 1._wp / 0.1_wp ! threshold for the computation of i0
-      DO ji = 1, npti
-         ! --- Computation of i0 --- !
-         ! i0 describes the fraction of solar radiation which does not contribute
-         ! to the surface energy budget but rather penetrates inside the ice.
-         ! We assume that no radiation is transmitted through the snow
-         ! If there is no no snow
-         ! zfsw    = (1-i0).qsr_ice   is absorbed at the surface 
-         ! zftrice = io.qsr_ice       is below the surface 
-         ! ftr_ice = io.qsr_ice.exp(-k(h_i)) transmitted below the ice 
-         ! fr1_i0_1d = i0 for a thin ice cover, fr1_i0_2d = i0 for a thick ice cover
-         zfac = MAX( 0._wp , 1._wp - ( h_i_1d(ji) * z1_hsu ) )     
-         i0(ji) = ( 1._wp - isnow(ji) ) * ( fr1_i0_1d(ji) + zfac * fr2_i0_1d(ji) )
-
-         ! --- Solar radiation absorbed / transmitted at the surface --- !
-         !     Derivative of the non solar flux
-         zfsw   (ji)     =  qsr_ice_1d(ji) * ( 1 - i0(ji) )   ! Shortwave radiation absorbed at surface
-         zftrice(ji)     =  qsr_ice_1d(ji) *       i0(ji)     ! Solar radiation transmitted below the surface layer
-         zdqns_ice_b(ji) = dqns_ice_1d(ji)                    ! derivative of incoming nonsolar flux 
-         zqns_ice_b (ji) =  qns_ice_1d(ji)                    ! store previous qns_ice_1d value
-      END DO
-
       ! --- Transmission/absorption of solar radiation in the ice --- !
-      zradtr_s(1:npti,0) = zftrice(1:npti)
+!     zfr1 = ( 0.18 * ( 1.0 - 0.81 ) + 0.35 * 0.81 )            !   standard value
+!     zfr2 = ( 0.82 * ( 1.0 - 0.81 ) + 0.65 * 0.81 )            !   zfr2 such that zfr1 + zfr2 to equal 1
+
+!     DO ji = 1, npti
+
+!        zfac = MAX( 0._wp , 1._wp - ( h_i_1d(ji) * 10._wp ) )     
+
+!              zfrqsr_tr_i = zfr1 + zfac * zfr2                         !   below 10 cm, linearly increase zfrqsr_tr_i until 1 at zero thickness
+!              IF ( h_s_1d(ji) >= 0.0_wp )   zfrqsr_tr_i = 0._wp     !   snow fully opaque
+
+!              qsr_ice_tr_1d(ji) = zfrqsr_tr_i * qsr_ice_1d(ji)   !   transmitted solar radiation 
+
+!              zfsw(ji) = qsr_ice_1d(ji) - qsr_ice_tr_1d(ji)
+!              zftrice(ji) = qsr_ice_tr_1d(ji)
+!              i0(ji) = zfrqsr_tr_i
+
+!     END DO
+
+      zradtr_s(1:npti,0) = qsr_ice_tr_1d(1:npti)
       DO jk = 1, nlay_s
          DO ji = 1, npti
@@ -209,5 +267,5 @@
       END DO
          
-      zradtr_i(1:npti,0) = zradtr_s(1:npti,nlay_s) * isnow(1:npti) + zftrice(1:npti) * ( 1._wp - isnow(1:npti) )
+      zradtr_i(1:npti,0) = zradtr_s(1:npti,nlay_s) * isnow(1:npti) + qsr_ice_tr_1d(1:npti) * ( 1._wp - isnow(1:npti) )
       DO jk = 1, nlay_i 
          DO ji = 1, npti
@@ -330,34 +388,50 @@
             END DO
          END DO
-         !
-         !----------------------------
-         ! 6) surface flux computation
-         !----------------------------
-         IF ( ln_dqns_i ) THEN 
-            DO ji = 1, npti
-               ! update of the non solar flux according to the update in T_su
+         
+         !
+         !----------------------------------------!
+         !                                        !
+         !       JULES IF (OFF or SND MODE)       !
+         !                                        !
+         !----------------------------------------!
+         !
+         
+         IF ( k_jules == np_zdf_jules_OFF .OR. k_jules == np_zdf_jules_SND  ) THEN ! OFF or SND mode
+         
+            !
+            ! In OFF mode the original BL99 temperature computation is used
+            ! (with qsr_ice, qns_ice and dqns_ice as inputs)
+            !
+            ! In SND mode, the computation is required to compute the conduction fluxes
+            !
+         
+            !----------------------------
+            ! 6) surface flux computation
+            !----------------------------
+
+            DO ji = 1, npti
+            ! update of the non solar flux according to the update in T_su
                qns_ice_1d(ji) = qns_ice_1d(ji) + dqns_ice_1d(ji) * ( t_su_1d(ji) - ztsub(ji) )
             END DO
-         ENDIF
-
-         DO ji = 1, npti
-            zfnet(ji) = zfsw(ji) + qns_ice_1d(ji) ! incoming = net absorbed solar radiation + non solar total flux (LWup, LWdw, SH, LH)
-         END DO
-         !
-         !----------------------------
-         ! 7) tridiagonal system terms
-         !----------------------------
-         !!layer denotes the number of the layer in the snow or in the ice
-         !!jm denotes the reference number of the equation in the tridiagonal
-         !!system, terms of tridiagonal system are indexed as following :
-         !!1 is subdiagonal term, 2 is diagonal and 3 is superdiagonal one
-
-         !!ice interior terms (top equation has the same form as the others)
-         ztrid   (1:npti,:,:) = 0._wp
-         zindterm(1:npti,:)   = 0._wp
-         zindtbis(1:npti,:)   = 0._wp
-         zdiagbis(1:npti,:)   = 0._wp
-
-         DO jm = nlay_s + 2, nlay_s + nlay_i 
+
+            DO ji = 1, npti
+               zfnet(ji) = qsr_ice_1d(ji) - qsr_ice_tr_1d(ji) + qns_ice_1d(ji) ! net heat flux = net solar - transmitted solar + non solar
+            END DO
+            !
+            !----------------------------
+            ! 7) tridiagonal system terms
+            !----------------------------
+            !!layer denotes the number of the layer in the snow or in the ice
+            !!jm denotes the reference number of the equation in the tridiagonal
+            !!system, terms of tridiagonal system are indexed as following :
+            !!1 is subdiagonal term, 2 is diagonal and 3 is superdiagonal one
+
+            !!ice interior terms (top equation has the same form as the others)
+            ztrid   (1:npti,:,:) = 0._wp
+            zindterm(1:npti,:)   = 0._wp
+            zindtbis(1:npti,:)   = 0._wp
+            zdiagbis(1:npti,:)   = 0._wp
+
+            DO jm = nlay_s + 2, nlay_s + nlay_i 
             DO ji = 1, npti
                jk = jm - nlay_s - 1
@@ -367,8 +441,8 @@
                zindterm(ji,jm) = ztiold(ji,jk) + zeta_i(ji,jk) * zradab_i(ji,jk)
             END DO
-         ENDDO
-
-         jm =  nlay_s + nlay_i + 1
-         DO ji = 1, npti
+            ENDDO
+
+            jm =  nlay_s + nlay_i + 1
+            DO ji = 1, npti
             !!ice bottom term
             ztrid(ji,jm,1)  = - zeta_i(ji,nlay_i)*zkappa_i(ji,nlay_i-1)   
@@ -377,54 +451,54 @@
             zindterm(ji,jm) = ztiold(ji,nlay_i) + zeta_i(ji,nlay_i) *  &
                &            ( zradab_i(ji,nlay_i) + zkappa_i(ji,nlay_i) * zg1 *  t_bo_1d(ji) ) 
-         ENDDO
-
-
-         DO ji = 1, npti
+            ENDDO
+
+
+            DO ji = 1, npti
             !                               !---------------------!
-            IF ( h_s_1d(ji) > 0.0 ) THEN   !  snow-covered cells !
+            IF ( h_s_1d(ji) > 0.0 ) THEN    !  snow-covered cells !
                !                            !---------------------!
                ! snow interior terms (bottom equation has the same form as the others)
                DO jm = 3, nlay_s + 1
-                  jk = jm - 1
-                  ztrid(ji,jm,1)  = - zeta_s(ji,jk) * zkappa_s(ji,jk-1)
-                  ztrid(ji,jm,2)  = 1.0 + zeta_s(ji,jk) * ( zkappa_s(ji,jk-1) + zkappa_s(ji,jk) )
-                  ztrid(ji,jm,3)  = - zeta_s(ji,jk)*zkappa_s(ji,jk)
-                  zindterm(ji,jm) = ztsold(ji,jk) + zeta_s(ji,jk) * zradab_s(ji,jk)
+               jk = jm - 1
+               ztrid(ji,jm,1)  = - zeta_s(ji,jk) * zkappa_s(ji,jk-1)
+               ztrid(ji,jm,2)  = 1.0 + zeta_s(ji,jk) * ( zkappa_s(ji,jk-1) + zkappa_s(ji,jk) )
+               ztrid(ji,jm,3)  = - zeta_s(ji,jk)*zkappa_s(ji,jk)
+               zindterm(ji,jm) = ztsold(ji,jk) + zeta_s(ji,jk) * zradab_s(ji,jk)
                END DO
 
                ! case of only one layer in the ice (ice equation is altered)
                IF ( nlay_i == 1 ) THEN
-                  ztrid(ji,nlay_s+2,3)  = 0.0
-                  zindterm(ji,nlay_s+2) = zindterm(ji,nlay_s+2) + zkappa_i(ji,1) * t_bo_1d(ji) 
+               ztrid(ji,nlay_s+2,3)  = 0.0
+               zindterm(ji,nlay_s+2) = zindterm(ji,nlay_s+2) + zkappa_i(ji,1) * t_bo_1d(ji) 
                ENDIF
 
                IF ( t_su_1d(ji) < rt0 ) THEN   !--  case 1 : no surface melting
 
-                  jm_min(ji) = 1
-                  jm_max(ji) = nlay_i + nlay_s + 1
-
-                  ! surface equation
-                  ztrid(ji,1,1)  = 0.0
-                  ztrid(ji,1,2)  = zdqns_ice_b(ji) - zg1s * zkappa_s(ji,0)
-                  ztrid(ji,1,3)  = zg1s * zkappa_s(ji,0)
-                  zindterm(ji,1) = zdqns_ice_b(ji) * t_su_1d(ji) - zfnet(ji)
-
-                  ! first layer of snow equation
-                  ztrid(ji,2,1)  = - zkappa_s(ji,0) * zg1s * zeta_s(ji,1)
-                  ztrid(ji,2,2)  = 1.0 + zeta_s(ji,1) * ( zkappa_s(ji,1) + zkappa_s(ji,0) * zg1s )
-                  ztrid(ji,2,3)  = - zeta_s(ji,1)* zkappa_s(ji,1)
-                  zindterm(ji,2) = ztsold(ji,1) + zeta_s(ji,1) * zradab_s(ji,1)
+               jm_min(ji) = 1
+               jm_max(ji) = nlay_i + nlay_s + 1
+
+               ! surface equation
+               ztrid(ji,1,1)  = 0.0
+               ztrid(ji,1,2)  = zdqns_ice_b(ji) - zg1s * zkappa_s(ji,0)
+               ztrid(ji,1,3)  = zg1s * zkappa_s(ji,0)
+               zindterm(ji,1) = zdqns_ice_b(ji) * t_su_1d(ji) - zfnet(ji)
+
+               ! first layer of snow equation
+               ztrid(ji,2,1)  = - zkappa_s(ji,0) * zg1s * zeta_s(ji,1)
+               ztrid(ji,2,2)  = 1.0 + zeta_s(ji,1) * ( zkappa_s(ji,1) + zkappa_s(ji,0) * zg1s )
+               ztrid(ji,2,3)  = - zeta_s(ji,1)* zkappa_s(ji,1)
+               zindterm(ji,2) = ztsold(ji,1) + zeta_s(ji,1) * zradab_s(ji,1)
 
                ELSE                            !--  case 2 : surface is melting
-                  !
-                  jm_min(ji) = 2
-                  jm_max(ji) = nlay_i + nlay_s + 1
-
-                  ! first layer of snow equation
-                  ztrid(ji,2,1)  = 0.0
-                  ztrid(ji,2,2)  = 1.0 + zeta_s(ji,1) * ( zkappa_s(ji,1) + zkappa_s(ji,0) * zg1s )
-                  ztrid(ji,2,3)  = - zeta_s(ji,1)*zkappa_s(ji,1) 
-                  zindterm(ji,2) = ztsold(ji,1) + zeta_s(ji,1) *  &
-                     &           ( zradab_s(ji,1) + zkappa_s(ji,0) * zg1s * t_su_1d(ji) ) 
+               !
+               jm_min(ji) = 2
+               jm_max(ji) = nlay_i + nlay_s + 1
+
+               ! first layer of snow equation
+               ztrid(ji,2,1)  = 0.0
+               ztrid(ji,2,2)  = 1.0 + zeta_s(ji,1) * ( zkappa_s(ji,1) + zkappa_s(ji,0) * zg1s )
+               ztrid(ji,2,3)  = - zeta_s(ji,1)*zkappa_s(ji,1) 
+               zindterm(ji,2) = ztsold(ji,1) + zeta_s(ji,1) *  &
+               &           ( zradab_s(ji,1) + zkappa_s(ji,0) * zg1s * t_su_1d(ji) ) 
                ENDIF
             !                               !---------------------!
@@ -433,52 +507,52 @@
                !
                IF ( t_su_1d(ji) < rt0 ) THEN   !--  case 1 : no surface melting
-                  !
-                  jm_min(ji) = nlay_s + 1
-                  jm_max(ji) = nlay_i + nlay_s + 1
-
-                  ! surface equation	
-                  ztrid(ji,jm_min(ji),1)  = 0.0
-                  ztrid(ji,jm_min(ji),2)  = zdqns_ice_b(ji) - zkappa_i(ji,0)*zg1    
-                  ztrid(ji,jm_min(ji),3)  = zkappa_i(ji,0)*zg1
-                  zindterm(ji,jm_min(ji)) = zdqns_ice_b(ji)*t_su_1d(ji) - zfnet(ji)
-
-                  ! first layer of ice equation
-                  ztrid(ji,jm_min(ji)+1,1)  = - zkappa_i(ji,0) * zg1 * zeta_i(ji,1)
-                  ztrid(ji,jm_min(ji)+1,2)  = 1.0 + zeta_i(ji,1) * ( zkappa_i(ji,1) + zkappa_i(ji,0) * zg1 )
-                  ztrid(ji,jm_min(ji)+1,3)  = - zeta_i(ji,1) * zkappa_i(ji,1)  
-                  zindterm(ji,jm_min(ji)+1) = ztiold(ji,1) + zeta_i(ji,1) * zradab_i(ji,1)  
-
-                  ! case of only one layer in the ice (surface & ice equations are altered)
-                  IF ( nlay_i == 1 ) THEN
-                     ztrid(ji,jm_min(ji),1)    = 0.0
-                     ztrid(ji,jm_min(ji),2)    = zdqns_ice_b(ji) - zkappa_i(ji,0) * 2.0
-                     ztrid(ji,jm_min(ji),3)    = zkappa_i(ji,0) * 2.0
-                     ztrid(ji,jm_min(ji)+1,1)  = -zkappa_i(ji,0) * 2.0 * zeta_i(ji,1)
-                     ztrid(ji,jm_min(ji)+1,2)  = 1.0 + zeta_i(ji,1) * ( zkappa_i(ji,0) * 2.0 + zkappa_i(ji,1) )
-                     ztrid(ji,jm_min(ji)+1,3)  = 0.0
-                     zindterm(ji,jm_min(ji)+1) = ztiold(ji,1) + zeta_i(ji,1) *  &
-                        &                      ( zradab_i(ji,1) + zkappa_i(ji,1) * t_bo_1d(ji) )
-                  ENDIF
+               !
+               jm_min(ji) = nlay_s + 1
+               jm_max(ji) = nlay_i + nlay_s + 1
+
+               ! surface equation	
+               ztrid(ji,jm_min(ji),1)  = 0.0
+               ztrid(ji,jm_min(ji),2)  = zdqns_ice_b(ji) - zkappa_i(ji,0)*zg1    
+               ztrid(ji,jm_min(ji),3)  = zkappa_i(ji,0)*zg1
+               zindterm(ji,jm_min(ji)) = zdqns_ice_b(ji)*t_su_1d(ji) - zfnet(ji)
+
+               ! first layer of ice equation
+               ztrid(ji,jm_min(ji)+1,1)  = - zkappa_i(ji,0) * zg1 * zeta_i(ji,1)
+               ztrid(ji,jm_min(ji)+1,2)  = 1.0 + zeta_i(ji,1) * ( zkappa_i(ji,1) + zkappa_i(ji,0) * zg1 )
+               ztrid(ji,jm_min(ji)+1,3)  = - zeta_i(ji,1) * zkappa_i(ji,1)  
+               zindterm(ji,jm_min(ji)+1) = ztiold(ji,1) + zeta_i(ji,1) * zradab_i(ji,1)  
+
+               ! case of only one layer in the ice (surface & ice equations are altered)
+               IF ( nlay_i == 1 ) THEN
+               ztrid(ji,jm_min(ji),1)    = 0.0
+               ztrid(ji,jm_min(ji),2)    = zdqns_ice_b(ji) - zkappa_i(ji,0) * 2.0
+               ztrid(ji,jm_min(ji),3)    = zkappa_i(ji,0) * 2.0
+               ztrid(ji,jm_min(ji)+1,1)  = -zkappa_i(ji,0) * 2.0 * zeta_i(ji,1)
+               ztrid(ji,jm_min(ji)+1,2)  = 1.0 + zeta_i(ji,1) * ( zkappa_i(ji,0) * 2.0 + zkappa_i(ji,1) )
+               ztrid(ji,jm_min(ji)+1,3)  = 0.0
+               zindterm(ji,jm_min(ji)+1) = ztiold(ji,1) + zeta_i(ji,1) *  &
+               &                      ( zradab_i(ji,1) + zkappa_i(ji,1) * t_bo_1d(ji) )
+               ENDIF
 
                ELSE                            !--  case 2 : surface is melting
 
-                  jm_min(ji)    =  nlay_s + 2
-                  jm_max(ji)    =  nlay_i + nlay_s + 1
-
-                  ! first layer of ice equation
-                  ztrid(ji,jm_min(ji),1)  = 0.0
-                  ztrid(ji,jm_min(ji),2)  = 1.0 + zeta_i(ji,1) * ( zkappa_i(ji,1) + zkappa_i(ji,0) * zg1 )  
-                  ztrid(ji,jm_min(ji),3)  = - zeta_i(ji,1) * zkappa_i(ji,1)
-                  zindterm(ji,jm_min(ji)) = ztiold(ji,1) + zeta_i(ji,1) *  &
-                     &                    ( zradab_i(ji,1) + zkappa_i(ji,0) * zg1 * t_su_1d(ji) ) 
-
-                  ! case of only one layer in the ice (surface & ice equations are altered)
-                  IF ( nlay_i == 1 ) THEN
-                     ztrid(ji,jm_min(ji),1)  = 0.0
-                     ztrid(ji,jm_min(ji),2)  = 1.0 + zeta_i(ji,1) * ( zkappa_i(ji,0) * 2.0 + zkappa_i(ji,1) )
-                     ztrid(ji,jm_min(ji),3)  = 0.0
-                     zindterm(ji,jm_min(ji)) = ztiold(ji,1) + zeta_i(ji,1) * ( zradab_i(ji,1) + zkappa_i(ji,1) * t_bo_1d(ji) )  &
-                        &                    + t_su_1d(ji) * zeta_i(ji,1) * zkappa_i(ji,0) * 2.0
-                  ENDIF
+               jm_min(ji)    =  nlay_s + 2
+               jm_max(ji)    =  nlay_i + nlay_s + 1
+
+               ! first layer of ice equation
+               ztrid(ji,jm_min(ji),1)  = 0.0
+               ztrid(ji,jm_min(ji),2)  = 1.0 + zeta_i(ji,1) * ( zkappa_i(ji,1) + zkappa_i(ji,0) * zg1 )  
+               ztrid(ji,jm_min(ji),3)  = - zeta_i(ji,1) * zkappa_i(ji,1)
+               zindterm(ji,jm_min(ji)) = ztiold(ji,1) + zeta_i(ji,1) *  &
+               &                    ( zradab_i(ji,1) + zkappa_i(ji,0) * zg1 * t_su_1d(ji) ) 
+
+               ! case of only one layer in the ice (surface & ice equations are altered)
+               IF ( nlay_i == 1 ) THEN
+               ztrid(ji,jm_min(ji),1)  = 0.0
+               ztrid(ji,jm_min(ji),2)  = 1.0 + zeta_i(ji,1) * ( zkappa_i(ji,0) * 2.0 + zkappa_i(ji,1) )
+               ztrid(ji,jm_min(ji),3)  = 0.0
+               zindterm(ji,jm_min(ji)) = ztiold(ji,1) + zeta_i(ji,1) * ( zradab_i(ji,1) + zkappa_i(ji,1) * t_bo_1d(ji) )  &
+               &                    + t_su_1d(ji) * zeta_i(ji,1) * zkappa_i(ji,0) * 2.0
+               ENDIF
 
                ENDIF
@@ -488,19 +562,19 @@
             zdiagbis(ji,jm_min(ji)) = ztrid(ji,jm_min(ji),2)
             !
-         END DO
-         !
-         !------------------------------
-         ! 8) tridiagonal system solving
-         !------------------------------
-         ! Solve the tridiagonal system with Gauss elimination method.
-         ! Thomas algorithm, from Computational fluid Dynamics, J.D. ANDERSON, McGraw-Hill 1984
-         jm_maxt = 0
-         jm_mint = nlay_i+5
-         DO ji = 1, npti
+            END DO
+            !
+            !------------------------------
+            ! 8) tridiagonal system solving
+            !------------------------------
+            ! Solve the tridiagonal system with Gauss elimination method.
+            ! Thomas algorithm, from Computational fluid Dynamics, J.D. ANDERSON, McGraw-Hill 1984
+            jm_maxt = 0
+            jm_mint = nlay_i+5
+            DO ji = 1, npti
             jm_mint = MIN(jm_min(ji),jm_mint)
             jm_maxt = MAX(jm_max(ji),jm_maxt)
-         END DO
-
-         DO jk = jm_mint+1, jm_maxt
+            END DO
+
+            DO jk = jm_mint+1, jm_maxt
             DO ji = 1, npti
                jm = min(max(jm_min(ji)+1,jk),jm_max(ji))
@@ -508,23 +582,23 @@
                zindtbis(ji,jm) = zindterm(ji,jm) - ztrid(ji,jm,1) * zindtbis(ji,jm-1) / zdiagbis(ji,jm-1)
             END DO
-         END DO
-
-         DO ji = 1, npti
+            END DO
+
+            DO ji = 1, npti
             ! ice temperatures
             t_i_1d(ji,nlay_i) = zindtbis(ji,jm_max(ji)) / zdiagbis(ji,jm_max(ji))
-         END DO
-
-         DO jm = nlay_i + nlay_s, nlay_s + 2, -1
+            END DO
+
+            DO jm = nlay_i + nlay_s, nlay_s + 2, -1
             DO ji = 1, npti
                jk    =  jm - nlay_s - 1
                t_i_1d(ji,jk) = ( zindtbis(ji,jm) - ztrid(ji,jm,3) * t_i_1d(ji,jk+1) ) / zdiagbis(ji,jm)
             END DO
-         END DO
-
-         DO ji = 1, npti
+            END DO
+
+            DO ji = 1, npti
             ! snow temperatures      
             IF( h_s_1d(ji) > 0._wp ) THEN
                t_s_1d(ji,nlay_s) = ( zindtbis(ji,nlay_s+1) - ztrid(ji,nlay_s+1,3) * t_i_1d(ji,1) )  &
-                  &                / zdiagbis(ji,nlay_s+1)
+               &                / zdiagbis(ji,nlay_s+1)
             ENDIF
             ! surface temperature
@@ -532,27 +606,27 @@
             IF( t_su_1d(ji) < rt0 ) THEN
                t_su_1d(ji) = ( zindtbis(ji,jm_min(ji)) - ztrid(ji,jm_min(ji),3) *  &
-                  &          ( isnow(ji) * t_s_1d(ji,1) + ( 1._wp - isnow(ji) ) * t_i_1d(ji,1) ) ) / zdiagbis(ji,jm_min(ji))
-            ENDIF
-         END DO
-         !
-         !--------------------------------------------------------------
-         ! 9) Has the scheme converged ?, end of the iterative procedure
-         !--------------------------------------------------------------
-         ! check that nowhere it has started to melt
-         ! zdti_max is a measure of error, it has to be under zdti_bnd
-         zdti_max = 0._wp
-         DO ji = 1, npti
+               &          ( isnow(ji) * t_s_1d(ji,1) + ( 1._wp - isnow(ji) ) * t_i_1d(ji,1) ) ) / zdiagbis(ji,jm_min(ji))
+            ENDIF
+            END DO
+            !
+            !--------------------------------------------------------------
+            ! 9) Has the scheme converged ?, end of the iterative procedure
+            !--------------------------------------------------------------
+            ! check that nowhere it has started to melt
+            ! zdti_max is a measure of error, it has to be under zdti_bnd
+            zdti_max = 0._wp
+            DO ji = 1, npti
             t_su_1d(ji) = MAX( MIN( t_su_1d(ji) , rt0 ) , rt0 - 100._wp )
             zdti_max = MAX( zdti_max, ABS( t_su_1d(ji) - ztsub(ji) ) )     
-         END DO
-
-         DO jk  =  1, nlay_s
+            END DO
+
+            DO jk  =  1, nlay_s
             DO ji = 1, npti
                t_s_1d(ji,jk) = MAX( MIN( t_s_1d(ji,jk), rt0 ), rt0 - 100._wp )
                zdti_max = MAX( zdti_max, ABS( t_s_1d(ji,jk) - ztsb(ji,jk) ) )
             END DO
-         END DO
-
-         DO jk  =  1, nlay_i
+            END DO
+
+            DO jk  =  1, nlay_i
             DO ji = 1, npti
                ztmelt_i      = -tmut * sz_i_1d(ji,jk) + rt0 
@@ -560,74 +634,291 @@
                zdti_max      =  MAX( zdti_max, ABS( t_i_1d(ji,jk) - ztib(ji,jk) ) )
             END DO
-         END DO
-
-         ! Compute spatial maximum over all errors
-         ! note that this could be optimized substantially by iterating only the non-converging points
-         IF( lk_mpp ) CALL mpp_max( zdti_max, kcom=ncomm_ice )
-
+            END DO
+
+            ! Compute spatial maximum over all errors
+            ! note that this could be optimized substantially by iterating only the non-converging points
+            IF( lk_mpp ) CALL mpp_max( zdti_max, kcom=ncomm_ice )
+         !
+         !----------------------------------------!
+         !                                        !
+         !       JULES IF (RCV MODE)              !
+         !                                        !
+         !----------------------------------------!
+         !
+
+         ELSE IF ( k_jules == np_zdf_jules_RCV  ) THEN ! RCV mode
+         
+            !
+            ! In RCV mode, we use a modified BL99 solver 
+            ! with conduction flux (qcn_ice) as forcing term
+            !
+            !----------------------------
+            ! 7) tridiagonal system terms
+            !----------------------------
+            !!layer denotes the number of the layer in the snow or in the ice
+            !!jm denotes the reference number of the equation in the tridiagonal
+            !!system, terms of tridiagonal system are indexed as following :
+            !!1 is subdiagonal term, 2 is diagonal and 3 is superdiagonal one
+
+            !!ice interior terms (top equation has the same form as the others)
+            ztrid   (1:npti,:,:) = 0._wp
+            zindterm(1:npti,:)   = 0._wp
+            zindtbis(1:npti,:)   = 0._wp
+            zdiagbis(1:npti,:)   = 0._wp
+
+            DO jm = nlay_s + 2, nlay_s + nlay_i 
+            DO ji = 1, npti
+               jk = jm - nlay_s - 1
+               ztrid(ji,jm,1)  = - zeta_i(ji,jk) * zkappa_i(ji,jk-1)
+               ztrid(ji,jm,2)  = 1.0 + zeta_i(ji,jk) * ( zkappa_i(ji,jk-1) + zkappa_i(ji,jk) )
+               ztrid(ji,jm,3)  = - zeta_i(ji,jk) * zkappa_i(ji,jk)
+               zindterm(ji,jm) = ztiold(ji,jk) + zeta_i(ji,jk) * zradab_i(ji,jk)
+            END DO
+            ENDDO
+
+            jm =  nlay_s + nlay_i + 1
+            DO ji = 1, npti
+            !!ice bottom term
+            ztrid(ji,jm,1)  = - zeta_i(ji,nlay_i)*zkappa_i(ji,nlay_i-1)   
+            ztrid(ji,jm,2)  = 1.0 + zeta_i(ji,nlay_i) * ( zkappa_i(ji,nlay_i) * zg1 + zkappa_i(ji,nlay_i-1) )
+            ztrid(ji,jm,3)  = 0.0
+            zindterm(ji,jm) = ztiold(ji,nlay_i) + zeta_i(ji,nlay_i) *  &
+               &            ( zradab_i(ji,nlay_i) + zkappa_i(ji,nlay_i) * zg1 *  t_bo_1d(ji) ) 
+            ENDDO
+
+
+            DO ji = 1, npti
+            !                              !---------------------!
+            IF ( h_s_1d(ji) > 0.0 ) THEN   !  snow-covered cells !
+               !                           !---------------------!
+               ! snow interior terms (bottom equation has the same form as the others)
+               DO jm = 3, nlay_s + 1
+               jk = jm - 1
+               ztrid(ji,jm,1)  = - zeta_s(ji,jk) * zkappa_s(ji,jk-1)
+               ztrid(ji,jm,2)  = 1.0 + zeta_s(ji,jk) * ( zkappa_s(ji,jk-1) + zkappa_s(ji,jk) )
+               ztrid(ji,jm,3)  = - zeta_s(ji,jk)*zkappa_s(ji,jk)
+               zindterm(ji,jm) = ztsold(ji,jk) + zeta_s(ji,jk) * zradab_s(ji,jk)
+               END DO
+
+               ! case of only one layer in the ice (ice equation is altered)
+               IF ( nlay_i == 1 ) THEN
+               ztrid(ji,nlay_s+2,3)  = 0.0
+               zindterm(ji,nlay_s+2) = zindterm(ji,nlay_s+2) + zkappa_i(ji,1) * t_bo_1d(ji) 
+               ENDIF
+
+               jm_min(ji) = 2
+               jm_max(ji) = nlay_i + nlay_s + 1
+
+               ! first layer of snow equation
+               ztrid(ji,2,1)  = 0.0
+               ztrid(ji,2,2)  = 1.0 + zeta_s(ji,1) * zkappa_s(ji,1)
+               ztrid(ji,2,3)  = - zeta_s(ji,1)*zkappa_s(ji,1) 
+               zindterm(ji,2) = ztsold(ji,1) + zeta_s(ji,1) *  &
+               &           ( zradab_s(ji,1) + qcn_ice_1d(ji) ) 
+
+            !                               !---------------------!
+            ELSE                            ! cells without snow  !
+            !                               !---------------------!
+
+               jm_min(ji)    =  nlay_s + 2
+               jm_max(ji)    =  nlay_i + nlay_s + 1
+
+               ! first layer of ice equation
+               ztrid(ji,jm_min(ji),1)  = 0.0
+               ztrid(ji,jm_min(ji),2)  = 1.0 + zeta_i(ji,1) * zkappa_i(ji,1)  
+               ztrid(ji,jm_min(ji),3)  = - zeta_i(ji,1) * zkappa_i(ji,1)
+               zindterm(ji,jm_min(ji)) = ztiold(ji,1) + zeta_i(ji,1) *  &
+               &                    ( zradab_i(ji,1) + qcn_ice_1d(ji) )
+
+               ! case of only one layer in the ice (surface & ice equations are altered)
+               IF ( nlay_i == 1 ) THEN
+               ztrid(ji,jm_min(ji),1)  = 0.0
+               ztrid(ji,jm_min(ji),2)  = 1.0 + zeta_i(ji,1) * zkappa_i(ji,1)
+               ztrid(ji,jm_min(ji),3)  = 0.0
+               zindterm(ji,jm_min(ji)) = ztiold(ji,1) + zeta_i(ji,1) * ( zradab_i(ji,1) + zkappa_i(ji,1) * t_bo_1d(ji)    &
+               &                    + qcn_ice_1d(ji) )
+
+               ENDIF
+
+            ENDIF
+            !
+            zindtbis(ji,jm_min(ji)) = zindterm(ji,jm_min(ji))
+            zdiagbis(ji,jm_min(ji)) = ztrid(ji,jm_min(ji),2)
+            !
+            END DO
+            !
+            !------------------------------
+            ! 8) tridiagonal system solving
+            !------------------------------
+            ! Solve the tridiagonal system with Gauss elimination method.
+            ! Thomas algorithm, from Computational fluid Dynamics, J.D. ANDERSON, McGraw-Hill 1984
+            jm_maxt = 0
+            jm_mint = nlay_i+5
+            DO ji = 1, npti
+            jm_mint = MIN(jm_min(ji),jm_mint)
+            jm_maxt = MAX(jm_max(ji),jm_maxt)
+            END DO
+
+            DO jk = jm_mint+1, jm_maxt
+            DO ji = 1, npti
+               jm = min(max(jm_min(ji)+1,jk),jm_max(ji))
+               zdiagbis(ji,jm) = ztrid(ji,jm,2)  - ztrid(ji,jm,1) * ztrid(ji,jm-1,3)  / zdiagbis(ji,jm-1)
+               zindtbis(ji,jm) = zindterm(ji,jm) - ztrid(ji,jm,1) * zindtbis(ji,jm-1) / zdiagbis(ji,jm-1)
+            END DO
+            END DO
+
+            DO ji = 1, npti
+            ! ice temperatures
+            t_i_1d(ji,nlay_i) = zindtbis(ji,jm_max(ji)) / zdiagbis(ji,jm_max(ji))
+            END DO
+
+            DO jm = nlay_i + nlay_s, nlay_s + 2, -1
+            DO ji = 1, npti
+               jk    =  jm - nlay_s - 1
+               t_i_1d(ji,jk) = ( zindtbis(ji,jm) - ztrid(ji,jm,3) * t_i_1d(ji,jk+1) ) / zdiagbis(ji,jm)
+            END DO
+            END DO
+
+            DO ji = 1, npti
+            ! snow temperatures      
+            IF( h_s_1d(ji) > 0._wp ) THEN
+               t_s_1d(ji,nlay_s) = ( zindtbis(ji,nlay_s+1) - ztrid(ji,nlay_s+1,3) * t_i_1d(ji,1) )  &
+               &                / zdiagbis(ji,nlay_s+1)
+            ENDIF
+            END DO
+            !
+            !--------------------------------------------------------------
+            ! 9) Has the scheme converged ?, end of the iterative procedure
+            !--------------------------------------------------------------
+            ! check that nowhere it has started to melt
+            ! zdti_max is a measure of error, it has to be under zdti_bnd
+            zdti_max = 0._wp
+
+            DO jk  =  1, nlay_s
+            DO ji = 1, npti
+               t_s_1d(ji,jk) = MAX( MIN( t_s_1d(ji,jk), rt0 ), rt0 - 100._wp )
+               zdti_max = MAX( zdti_max, ABS( t_s_1d(ji,jk) - ztsb(ji,jk) ) )
+            END DO
+            END DO
+
+            DO jk  =  1, nlay_i
+            DO ji = 1, npti
+               ztmelt_i      = -tmut * sz_i_1d(ji,jk) + rt0 
+               t_i_1d(ji,jk) =  MAX( MIN( t_i_1d(ji,jk), ztmelt_i ), rt0 - 100._wp )
+               zdti_max      =  MAX( zdti_max, ABS( t_i_1d(ji,jk) - ztib(ji,jk) ) )
+            END DO
+            END DO
+
+            ! Compute spatial maximum over all errors
+            ! note that this could be optimized substantially by iterating only the non-converging points
+            IF( lk_mpp ) CALL mpp_max( zdti_max, kcom=ncomm_ice )
+
+         ENDIF ! k_jules
+         
       END DO  ! End of the do while iterative procedure
-
+      
       IF( ln_icectl .AND. lwp ) THEN
          WRITE(numout,*) ' zdti_max : ', zdti_max
          WRITE(numout,*) ' iconv    : ', iconv
       ENDIF
+      
       !
       !-----------------------------
       ! 10) Fluxes at the interfaces
       !-----------------------------
+      !
+      ! --- update conduction fluxes
+      !
       DO ji = 1, npti
-         !                                ! surface ice conduction flux
+      !                                ! surface ice conduction flux
          fc_su(ji)   =  -           isnow(ji)   * zkappa_s(ji,0) * zg1s * (t_s_1d(ji,1) - t_su_1d(ji))   &
             &           - ( 1._wp - isnow(ji) ) * zkappa_i(ji,0) * zg1  * (t_i_1d(ji,1) - t_su_1d(ji))
-         !                                ! bottom ice conduction flux
+      !                                ! bottom ice conduction flux
          fc_bo_i(ji) =  - zkappa_i(ji,nlay_i) * ( zg1*(t_bo_1d(ji) - t_i_1d(ji,nlay_i)) )
       END DO
-
-      ! --- computes sea ice energy of melting compulsory for icethd_dh --- !
-      CALL ice_thd_enmelt
-
-      ! --- diagnose the change in non-solar flux due to surface temperature change --- !
-      IF ( ln_dqns_i ) THEN
+      
+      !
+      ! --- Diagnose the heat loss due to changing non-solar / conduction flux --- !
+      !
+      DO ji = 1, npti
+            IF ( k_jules == np_zdf_jules_OFF .OR. k_jules == np_zdf_jules_SND  ) THEN 
+                   ! OFF or SND mode
+               hfx_err_dif_1d(ji) = hfx_err_dif_1d(ji) - ( qns_ice_1d(ji)  - zqns_ice_b(ji) ) * a_i_1d(ji) 
+            ELSE   ! RCV mode
+               hfx_err_dif_1d(ji) = hfx_err_dif_1d(ji) - ( fc_su(ji) - qcn_ice_1d(ji) ) * a_i_1d(ji) 
+            ENDIF
+      END DO
+      
+      !
+      ! --- Diagnose the heat loss due to non-fully converged temperature solution (should not be above 10-4 W-m2) --- !
+      !
+
+      IF ( ( k_jules == np_zdf_jules_OFF ) .OR. ( k_jules == np_zdf_jules_RCV ) ) THEN ! OFF
+      
+         CALL ice_thd_enmelt       
+
+         !     zhfx_err = correction on the diagnosed heat flux due to non-convergence of the algorithm used to solve heat equation
          DO ji = 1, npti
-            hfx_err_dif_1d(ji) = hfx_err_dif_1d(ji) - ( qns_ice_1d(ji)  - zqns_ice_b(ji) ) * a_i_1d(ji) 
+            zdq = - zq_ini(ji) + ( SUM( e_i_1d(ji,1:nlay_i) ) * h_i_1d(ji) * r1_nlay_i +  &
+               &                   SUM( e_s_1d(ji,1:nlay_s) ) * h_s_1d(ji) * r1_nlay_s )
+               
+            IF ( ( k_jules == np_zdf_jules_OFF ) ) THEN
+               
+                  IF( t_su_1d(ji) < rt0 ) THEN  ! case T_su < 0degC
+                     zhfx_err = ( qns_ice_1d(ji) + qsr_ice_1d(ji)    - zradtr_i(ji,nlay_i) - fc_bo_i(ji) + zdq * r1_rdtice ) * a_i_1d(ji) 
+                  ELSE                          ! case T_su = 0degC
+                     zhfx_err = ( fc_su(ji)      + qsr_ice_tr_1d(ji) - zradtr_i(ji,nlay_i) - fc_bo_i(ji) + zdq * r1_rdtice ) * a_i_1d(ji)
+                  ENDIF
+            
+            ELSE ! RCV CASE
+            
+               zhfx_err = ( fc_su(ji) + qsr_ice_tr_1d(ji) - zradtr_i(ji,nlay_i) - fc_bo_i(ji) + zdq * r1_rdtice ) * a_i_1d(ji)
+            
+            ENDIF
+            
+            ! total heat sink to be sent to the ocean
+            hfx_err_dif_1d(ji) = hfx_err_dif_1d(ji) + zhfx_err
+
+            ! hfx_dif = Heat flux diagnostic of sensible heat used to warm/cool ice in W.m-2   
+            hfx_dif_1d(ji) = hfx_dif_1d(ji) - zdq * r1_rdtice * a_i_1d(ji)
+   
+         END DO 
+           
+         !
+         ! --- SIMIP diagnostics
+         !
+
+         DO ji = 1, npti
+            !--- Conduction fluxes (positive downwards)
+            diag_fc_bo_1d(ji) = diag_fc_bo_1d(ji) + fc_bo_i(ji) * a_i_1d(ji) / at_i_1d(ji)
+            diag_fc_su_1d(ji) = diag_fc_su_1d(ji) + fc_su(ji)   * a_i_1d(ji) / at_i_1d(ji)
+   
+            !--- Snow-ice interfacial temperature (diagnostic SIMIP)
+            zfac = rn_cnd_s * zh_i(ji) + ztcond_i(ji,1) * zh_s(ji)
+            IF( zh_s(ji) >= 1.e-3 .AND. zfac > epsi10 ) THEN
+               t_si_1d(ji) = ( rn_cnd_s       * zh_i(ji) * t_s_1d(ji,1) +   &
+                  &            ztcond_i(ji,1) * zh_s(ji) * t_i_1d(ji,1) ) / zfac
+            ELSE
+               t_si_1d(ji) = t_su_1d(ji)
+            ENDIF
          END DO
-      END IF
-
-      ! --- diag conservation imbalance on heat diffusion - PART 2 --- !
-      !     hfx_dif = Heat flux used to warm/cool ice in W.m-2
-      !     zhfx_err = correction on the diagnosed heat flux due to non-convergence of the algorithm used to solve heat equation
-      DO ji = 1, npti
-         zdq = - zq_ini(ji) + ( SUM( e_i_1d(ji,1:nlay_i) ) * h_i_1d(ji) * r1_nlay_i +  &
-            &                   SUM( e_s_1d(ji,1:nlay_s) ) * h_s_1d(ji) * r1_nlay_s )
-
-         IF( t_su_1d(ji) < rt0 ) THEN  ! case T_su < 0degC
-            zhfx_err = ( qns_ice_1d(ji) + qsr_ice_1d(ji) - zradtr_i(ji,nlay_i) - fc_bo_i(ji) + zdq * r1_rdtice ) * a_i_1d(ji) 
-         ELSE                          ! case T_su = 0degC
-            zhfx_err = ( fc_su(ji) + i0(ji) * qsr_ice_1d(ji) - zradtr_i(ji,nlay_i) - fc_bo_i(ji) + zdq * r1_rdtice ) * a_i_1d(ji)
-         ENDIF
-         hfx_dif_1d(ji) = hfx_dif_1d(ji) - zdq * r1_rdtice * a_i_1d(ji)
-
-         ! total heat that is sent to the ocean (i.e. not used in the heat diffusion equation)
-         hfx_err_dif_1d(ji) = hfx_err_dif_1d(ji) + zhfx_err
-
-      END DO   
-
-      ! --- Diagnostics SIMIP --- !
-      DO ji = 1, npti
-         !--- Conduction fluxes (positive downwards)
-         diag_fc_bo_1d(ji) = diag_fc_bo_1d(ji) + fc_bo_i(ji) * a_i_1d(ji) / at_i_1d(ji)
-         diag_fc_su_1d(ji) = diag_fc_su_1d(ji) + fc_su(ji)   * a_i_1d(ji) / at_i_1d(ji)
-
-         !--- Snow-ice interfacial temperature (diagnostic SIMIP)
-         zfac = rn_cnd_s * zh_i(ji) + ztcond_i(ji,1) * zh_s(ji)
-         IF( zh_s(ji) >= 1.e-3 .AND. zfac > epsi10 ) THEN
-            t_si_1d(ji) = ( rn_cnd_s       * zh_i(ji) * t_s_1d(ji,1) +   &
-               &            ztcond_i(ji,1) * zh_s(ji) * t_i_1d(ji,1) ) / zfac
-         ELSE
-            t_si_1d(ji) = t_su_1d(ji)
-         ENDIF
-      END DO
-      !
-   END SUBROUTINE ice_thd_zdf
+     
+      ENDIF
+      !
+      !---------------------------------------------------------------------------------------
+      ! 11) Jules coupling: reset inner snow and ice temperatures, update conduction fluxes
+      !---------------------------------------------------------------------------------------
+      !
+      IF ( k_jules == np_zdf_jules_SND ) THEN   ! --- Jules coupling in "SND" mode
+      
+         ! Restore temperatures to their initial values
+         t_s_1d(1:npti,:)        = ztsold (1:npti,:)
+         t_i_1d(1:npti,:)        = ztiold (1:npti,:)
+         qcn_ice_1d(1:npti)      = fc_su(1:npti)
+         
+      ENDIF
+      
+   END SUBROUTINE ice_thd_zdf_BL99
+
 
 
@@ -663,4 +954,5 @@
 
 
+
    SUBROUTINE ice_thd_zdf_init
       !!-----------------------------------------------------------------------
@@ -675,7 +967,7 @@
       !! ** input   :   Namelist namthd_zdf
       !!-------------------------------------------------------------------
-      INTEGER  ::   ios   ! Local integer output status for namelist read
+      INTEGER  ::   ios, ioptio   ! Local integer output status for namelist read
       !!
-      NAMELIST/namthd_zdf/ ln_zdf_BL99, ln_cndi_U64, ln_cndi_P07, rn_cnd_s, rn_kappa_i, ln_dqns_i
+      NAMELIST/namthd_zdf/ ln_zdf_BL99, ln_cndi_U64, ln_cndi_P07, rn_cnd_s, rn_kappa_i
       !!-------------------------------------------------------------------
       !
@@ -694,15 +986,21 @@
          WRITE(numout,*) '~~~~~~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist namthd_zdf:'
-         WRITE(numout,*) '      Diffusion follows a Bitz and Lipscomb (1999)            ln_zdf_BL99  = ', ln_zdf_BL99
+         WRITE(numout,*) '      Bitz and Lipscomb (1999) formulation                    ln_zdf_BL99  = ', ln_zdf_BL99
          WRITE(numout,*) '      thermal conductivity in the ice (Untersteiner 1964)     ln_cndi_U64  = ', ln_cndi_U64
          WRITE(numout,*) '      thermal conductivity in the ice (Pringle et al 2007)    ln_cndi_P07  = ', ln_cndi_P07
          WRITE(numout,*) '      thermal conductivity in the snow                        rn_cnd_s     = ', rn_cnd_s
          WRITE(numout,*) '      extinction radiation parameter in sea ice               rn_kappa_i   = ', rn_kappa_i
-         WRITE(numout,*) '      change the surface non-solar flux with Tsu or not       ln_dqns_i    = ', ln_dqns_i
      ENDIF
+
       !
       IF ( ( ln_cndi_U64 .AND. ln_cndi_P07 ) .OR. ( .NOT.ln_cndi_U64 .AND. .NOT.ln_cndi_P07 ) ) THEN
          CALL ctl_stop( 'ice_thd_zdf_init: choose one and only one formulation for thermal conduction (ln_cndi_U64 or ln_cndi_P07)' )
       ENDIF
+
+      !                             !== set the choice of ice vertical thermodynamic formulation ==!
+      ioptio = 0 
+      !      !--- BL99 thermo dynamics                               (linear liquidus + constant thermal properties)
+      IF( ln_zdf_BL99 ) THEN   ;   ioptio = ioptio + 1   ;   nice_zdf = np_BL99   ;   ENDIF
+      IF( ioptio /= 1 )    CALL ctl_stop( 'ice_thd_init: one and only one ice thermo option has to be defined ' )
       !
    END SUBROUTINE ice_thd_zdf_init
@@ -711,5 +1009,5 @@
    !!----------------------------------------------------------------------
    !!   Default option       Dummy Module             No ESIM sea-ice model
-   !!----------------------------------------------------------------------
+   !!---------------------------------------------------------------------
 #endif
 
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceupdate.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceupdate.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/iceupdate.F90	(revision 8752)
@@ -164,7 +164,5 @@
             ! mass flux from ice/ocean
             wfx_ice(ji,jj) = wfx_bog(ji,jj) + wfx_bom(ji,jj) + wfx_sum(ji,jj) + wfx_sni(ji,jj)   &
-               &           + wfx_opw(ji,jj) + wfx_dyn(ji,jj) + wfx_res(ji,jj) + wfx_lam(ji,jj) 
-
-            IF ( ln_pnd_fw )   wfx_ice(ji,jj) = wfx_ice(ji,jj) + wfx_pnd(ji,jj)
+               &           + wfx_opw(ji,jj) + wfx_dyn(ji,jj) + wfx_res(ji,jj) + wfx_lam(ji,jj) + wfx_pnd(ji,jj)
 
             ! add the snow melt water to snow mass flux to the ocean
@@ -199,5 +197,5 @@
       ! Snow/ice albedo (only if sent to coupler, useless in forced mode)
       !------------------------------------------------------------------
-      CALL ice_alb( t_su, h_i, h_s, a_ip_frac, h_ip, ln_pnd_rad, zalb_cs, zalb_os ) ! cloud-sky and overcast-sky ice albedos
+      CALL ice_alb( t_su, h_i, h_s, ln_pnd_alb, a_ip_frac, h_ip, zalb_cs, zalb_os ) ! cloud-sky and overcast-sky ice albedos
       !
       alb_ice(:,:,:) = ( 1._wp - cldf_ice ) * zalb_cs(:,:,:) + cldf_ice * zalb_os(:,:,:)
@@ -246,5 +244,5 @@
       CALL iom_put( "vfxlam"     , wfx_lam              )        ! lateral melt 
       CALL iom_put( "vfxice"     , wfx_ice              )        ! total ice growth/melt 
-      IF ( ln_pnd )   CALL iom_put( "vfxpnd", wfx_pnd   )        ! melt pond water flux
+      IF ( ln_pnd_fwb )   CALL iom_put( "vfxpnd", wfx_pnd   )        ! melt pond water flux
 
       IF ( iom_use( "vfxthin" ) ) THEN   ! ice production for open water + thin ice (<20cm) => comparable to observations  
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icevar.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icevar.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icevar.F90	(revision 8752)
@@ -97,10 +97,6 @@
       et_i(:,:)  = SUM( SUM( e_i(:,:,:,:), dim=4 ), dim=3 )
 
-      ! MV MP 2016
-      IF ( ln_pnd ) THEN                     ! Melt pond
-         at_ip(:,:) = SUM( a_ip(:,:,:), dim=3 )
-         vt_ip(:,:) = SUM( v_ip(:,:,:), dim=3 )
-      ENDIF
-      ! END MP 2016
+      at_ip(:,:) = SUM( a_ip(:,:,:), dim=3 ) ! melt ponds
+      vt_ip(:,:) = SUM( v_ip(:,:,:), dim=3 )
 
       ato_i(:,:) = 1._wp - at_i(:,:)    ! open water fraction  
@@ -167,7 +163,7 @@
 !!                a criteria for icy area (i.e. a_i > epsi20 and v_i > epsi20 )
 
-      !-------------------------------------------------------
-      ! Ice thickness, snow thickness, ice salinity, ice age
-      !-------------------------------------------------------
+      !---------------------------------------------------------------
+      ! Ice thickness, snow thickness, ice salinity, ice age and ponds
+      !---------------------------------------------------------------
       !                                            !--- inverse of the ice area
       WHERE( a_i(:,:,:) > epsi20 )   ;   z1_a_i(:,:,:) = 1._wp / a_i(:,:,:)
@@ -178,26 +174,31 @@
       ELSEWHERE                      ;   z1_v_i(:,:,:) = 0._wp
       END WHERE
-      !
-      h_i(:,:,:) = v_i (:,:,:) * z1_a_i(:,:,:)    !--- ice thickness
+      !                                           !--- ice thickness
+      h_i(:,:,:) = v_i (:,:,:) * z1_a_i(:,:,:)
 
       zhmax    =          hi_max(jpl)
       z1_zhmax =  1._wp / hi_max(jpl)               
-      WHERE( h_i(:,:,jpl) > zhmax )               !--- bound h_i by hi_max (i.e. 99 m) with associated update of ice area
+      WHERE( h_i(:,:,jpl) > zhmax )   ! bound h_i by hi_max (i.e. 99 m) with associated update of ice area
          h_i  (:,:,jpl) = zhmax
          a_i   (:,:,jpl) = v_i(:,:,jpl) * z1_zhmax 
-         z1_a_i(:,:,jpl) = zhmax * z1_v_i(:,:,jpl)          ! NB: v_i always /=0 as h_i > hi_max
+         z1_a_i(:,:,jpl) = zhmax * z1_v_i(:,:,jpl)
       END WHERE
-
-      h_s(:,:,:) = v_s (:,:,:) * z1_a_i(:,:,:)    !--- snow thickness
-      
-      o_i(:,:,:)  = oa_i(:,:,:) * z1_a_i(:,:,:)    !--- ice age
-
-      IF( nn_icesal == 2 ) THEN                    !--- salinity (with a minimum value imposed everywhere)
+      !                                           !--- snow thickness
+      h_s(:,:,:) = v_s (:,:,:) * z1_a_i(:,:,:)
+      !                                           !--- ice age      
+      o_i(:,:,:) = oa_i(:,:,:) * z1_a_i(:,:,:)
+      !                                           !--- pond fraction and thickness      
+      a_ip_frac(:,:,:) = a_ip(:,:,:) * z1_a_i(:,:,:)
+      WHERE( a_ip_frac(:,:,:) > epsi20 )   ;   h_ip(:,:,:) = v_ip(:,:,:) * z1_a_i(:,:,:) / a_ip_frac(:,:,:)
+      ELSEWHERE                            ;   h_ip(:,:,:) = 0._wp
+      END WHERE
+      !
+      !                                           !---  salinity (with a minimum value imposed everywhere)     
+      IF( nn_icesal == 2 ) THEN
          WHERE( v_i(:,:,:) > epsi20 )   ;   s_i(:,:,:) = MAX( rn_simin , MIN( rn_simax, sv_i(:,:,:) * z1_v_i(:,:,:) ) )
          ELSEWHERE                      ;   s_i(:,:,:) = rn_simin
          END WHERE
       ENDIF
-
-      CALL ice_var_salprof      ! salinity profile
+      CALL ice_var_salprof   ! salinity profile
 
       !-------------------
@@ -242,8 +243,4 @@
       vt_s (:,:) = SUM( v_s, dim=3 )
       at_i (:,:) = SUM( a_i, dim=3 )
-
-! MV MP 2016
-! probably should resum for melt ponds ???
-
       !
    END SUBROUTINE ice_var_glo2eqv
@@ -258,7 +255,8 @@
       !!-------------------------------------------------------------------
       !
-      v_i (:,:,:) = h_i(:,:,:) * a_i(:,:,:)
-      v_s (:,:,:) = h_s(:,:,:) * a_i(:,:,:)
-      sv_i(:,:,:) = s_i(:,:,:) * v_i(:,:,:)
+      v_i (:,:,:) = h_i (:,:,:) * a_i (:,:,:)
+      v_s (:,:,:) = h_s (:,:,:) * a_i (:,:,:)
+      sv_i(:,:,:) = s_i (:,:,:) * v_i (:,:,:)
+      v_ip(:,:,:) = h_ip(:,:,:) * a_ip(:,:,:)
       !
    END SUBROUTINE ice_var_eqv2glo
@@ -478,4 +476,7 @@
                wfx_res(ji,jj)  = wfx_res(ji,jj) + (1._wp - zswitch(ji,jj) ) * v_s (ji,jj,jl)   * rhosn * r1_rdtice
                hfx_res(ji,jj)  = hfx_res(ji,jj) - (1._wp - zswitch(ji,jj) ) * e_s (ji,jj,1,jl) * r1_rdtice ! W.m-2 <0
+               IF( ln_pnd_fwb ) THEN 
+                  wfx_res(ji,jj)  = wfx_res(ji,jj) + (1._wp - zswitch(ji,jj) ) * v_ip(ji,jj,jl) * rhofw * r1_rdtice
+               ENDIF
                !-----------------------------------------------------------------
                ! Zap snow energy 
@@ -498,18 +499,10 @@
                h_s (ji,jj,jl) = h_s (ji,jj,jl) * zswitch(ji,jj)
 
-            END DO
-         END DO
-
-         IF( ln_pnd ) THEN 
-            DO jj = 1 , jpj
-               DO ji = 1 , jpi
-                  IF( ln_pnd_fw )   &
-                     &   wfx_res(ji,jj)  = wfx_res(ji,jj) + (1._wp - zswitch(ji,jj) ) * v_ip(ji,jj,jl) * rhofw * r1_rdtice
-                  a_ip (ji,jj,jl) = a_ip (ji,jj,jl) * zswitch(ji,jj)
-                  v_ip (ji,jj,jl) = v_ip (ji,jj,jl) * zswitch(ji,jj)
-               END DO
-            END DO
-         ENDIF
-         
+               a_ip (ji,jj,jl) = a_ip (ji,jj,jl) * zswitch(ji,jj)
+               v_ip (ji,jj,jl) = v_ip (ji,jj,jl) * zswitch(ji,jj)
+
+            END DO
+         END DO
+        
       END DO 
 
@@ -520,4 +513,5 @@
       ! open water = 1 if at_i=0
       WHERE( at_i(:,:) == 0._wp )   ato_i(:,:) = 1._wp
+
       !
    END SUBROUTINE ice_var_zapsmall
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icewri.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icewri.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/icewri.F90	(revision 8752)
@@ -128,8 +128,6 @@
       CALL iom_put( "snowvol"     , vt_s  * zswi      )        ! snow volume
       
-      IF ( ln_pnd ) THEN
-         CALL iom_put( "iceamp"  , at_ip  * zswi        )   ! melt pond total fraction
-         CALL iom_put( "icevmp"  , vt_ip  * zswi        )   ! melt pond total volume per unit area
-      ENDIF
+      CALL iom_put( "iceamp"  , at_ip  * zswi        )   ! melt pond total fraction
+      CALL iom_put( "icevmp"  , vt_ip  * zswi        )   ! melt pond total volume per unit area
 
       !----------------------------------
@@ -145,10 +143,8 @@
       IF ( iom_use('brinevol_cat') )  CALL iom_put( "brinevol_cat", bv_i * 100. * zswi2 )          ! brine volume
 
-      IF ( ln_pnd ) THEN
-         IF ( iom_use('iceamp_cat') )  CALL iom_put( "iceamp_cat"     , a_ip       * zswi2   )       ! melt pond frac for categories
-         IF ( iom_use('icevmp_cat') )  CALL iom_put( "icevmp_cat"     , v_ip       * zswi2   )       ! melt pond frac for categories
-         IF ( iom_use('icehmp_cat') )  CALL iom_put( "icehmp_cat"     , h_ip       * zswi2   )       ! melt pond frac for categories
-         IF ( iom_use('iceafp_cat') )  CALL iom_put( "iceafp_cat"     , a_ip_frac  * zswi2   )       ! melt pond frac for categories
-      ENDIF
+      IF ( iom_use('iceamp_cat') )  CALL iom_put( "iceamp_cat"     , a_ip       * zswi2   )       ! melt pond frac for categories
+      IF ( iom_use('icevmp_cat') )  CALL iom_put( "icevmp_cat"     , v_ip       * zswi2   )       ! melt pond frac for categories
+      IF ( iom_use('icehmp_cat') )  CALL iom_put( "icehmp_cat"     , h_ip       * zswi2   )       ! melt pond frac for categories
+      IF ( iom_use('iceafp_cat') )  CALL iom_put( "iceafp_cat"     , a_ip_frac  * zswi2   )       ! melt pond frac for categories
 
       !--------------------------------
@@ -316,14 +312,8 @@
       CALL histdef( kid, "sidive", "Ice divergence"          , "10-8s-1",   &
       &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
-
-      ! MV MP 2016
-      IF ( ln_pnd ) THEN
-         CALL histdef( kid, "si_amp", "Melt pond fraction"      , "%"      ,   &
-      &         jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-         CALL histdef( kid, "si_vmp", "Melt pond volume"        ,  "m"     ,   &
-      &         jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
-      ENDIF
-      ! END MV MP 2016
-
+      CALL histdef( kid, "si_amp", "Melt pond fraction"      , "%"      ,   &
+      &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
+      CALL histdef( kid, "si_vmp", "Melt pond volume"        ,  "m"     ,   &
+      &      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 )
@@ -370,10 +360,6 @@
       CALL histwrite( kid, "sidive", kt, divu_i*1.0e8   , jpi*jpj, (/1/) )
 
-      ! MV MP 2016
-      IF ( ln_pnd ) THEN
-         CALL histwrite( kid, "si_amp", kt, at_ip         , jpi*jpj, (/1/) )
-         CALL histwrite( kid, "si_vmp", kt, vt_ip         , jpi*jpj, (/1/) )
-      ENDIF
-      ! END MV MP 2016
+      CALL histwrite( kid, "si_amp", kt, at_ip         , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "si_vmp", kt, vt_ip         , jpi*jpj, (/1/) )
 
       CALL histwrite( kid, "vfxbog", kt, wfx_bog        , jpi*jpj, (/1/) )
@@ -384,6 +370,5 @@
       CALL histwrite( kid, "vfxbom", kt, wfx_bom        , jpi*jpj, (/1/) )
       CALL histwrite( kid, "vfxsum", kt, wfx_sum        , jpi*jpj, (/1/) )
-      IF ( ln_pnd ) &
-         CALL histwrite( kid, "vfxpnd", kt, wfx_pnd     , jpi*jpj, (/1/) )
+      CALL histwrite( kid, "vfxpnd", kt, wfx_pnd        , jpi*jpj, (/1/) )
 
       CALL histwrite( kid, "sithicat", kt, h_i         , jpi*jpj*jpl, (/1/) )    
Index: anches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/limmp.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/LIM_SRC_3/limmp.F90	(revision 8751)
+++ 	(revision )
@@ -1,2140 +1,0 @@
-MODULE limmp 
-   !!======================================================================
-   !!                     ***  MODULE  limmp   ***
-   !!   Melt ponds
-   !!======================================================================
-   !! history :       ! Original code by Daniela Flocco and Adrian Turner
-   !!            1.0  ! 2012    (O. Lecomte) Adaptation for scientific tests (NEMO3.1)
-   !!            2.0  ! 2017    (M. Vancoppenolle, O. Lecomte, C. Rousset) Implementation in NEMO3.6
-   !!                 ! NB: Only lim_mp_cstt and lim_mp_cesm work in this
-   !!                       version
-   !!----------------------------------------------------------------------
-#if defined key_lim3
-   !!----------------------------------------------------------------------
-   !!   'key_lim3' :                                 LIM3 sea-ice model
-   !!----------------------------------------------------------------------
-   !!   lim_mp_init      : some initialization and namelist read
-   !!   lim_mp           : main calling routine
-   !!   lim_mp_topo      : main melt pond routine for the "topographic" formulation (FloccoFeltham)
-   !!   lim_mp_area      : ??? compute melt pond fraction per category
-   !!   lim_mp_perm      : computes permeability (should be a FUNCTION!)
-   !!   calc_hpond       : computes melt pond depth
-   !!   permeability_phy : computes permeability
-
-   !!----------------------------------------------------------------------
-   USE phycst           ! physical constants
-   USE dom_oce          ! ocean space and time domain
-!  USE sbc_ice          ! Surface boundary condition: ice   fields
-   USE ice              ! LIM-3 variables
-!  USE icecons          ! conservation tests
-!  USE limctl           ! control prints
-!  USE limvar
-   !
-   USE lbclnk           ! lateral boundary conditions - MPP exchanges
-   USE lib_mpp          ! MPP library
-   USE in_out_manager   ! I/O manager
-   USE lib_fortran      ! glob_sum
-   USE timing           ! Timing
-
-!OLI_CODE    USE ice_oce, ONLY: rdt_ice, tatm_ice
-!OLI_CODE    USE phycst
-!OLI_CODE    USE dom_ice
-!OLI_CODE    USE dom_oce
-!OLI_CODE    USE sbc_oce
-!OLI_CODE    USE sbc_ice
-!OLI_CODE    USE par_ice
-!OLI_CODE    USE par_oce
-!OLI_CODE    USE ice
-!OLI_CODE    USE thd_ice
-!OLI_CODE    USE in_out_manager
-!OLI_CODE    USE lbclnk
-!OLI_CODE    USE lib_mpp
-!OLI_CODE 
-!OLI_CODE    IMPLICIT NONE
-!OLI_CODE    PRIVATE
-!OLI_CODE 
-!OLI_CODE    PUBLIC   lim_mp_init
-!OLI_CODE    PUBLIC   lim_mp
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   lim_mp_init    ! routine called by icestp.F90
-   PUBLIC   lim_mp         ! routine called by icestp.F90
-
-   !! * Substitutions
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/LIM3 4.0 , UCL - NEMO Consortium (2011)
-   !! $Id: limdyn.F90 6994 2016-10-05 13:07:10Z clem $
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE lim_mp_init 
-      !!-------------------------------------------------------------------
-      !!                  ***  ROUTINE lim_mp_init   ***
-      !!
-      !! ** Purpose : Physical constants and parameters linked to melt ponds
-      !!      over sea ice
-      !!
-      !! ** Method  :  Read the nammp  namelist and check the melt pond  
-      !!       parameter values called at the first timestep (nit000)
-      !!
-      !! ** input   :   Namelist nammp  
-      !!-------------------------------------------------------------------
-      INTEGER  ::   ios                 ! Local integer output status for namelist read
-      NAMELIST/nammp/  ln_pnd, ln_pnd_rad, ln_pnd_fw, nn_pnd_scheme, rn_apnd, rn_hpnd
-      !!-------------------------------------------------------------------
-
-      REWIND( numnam_ice_ref )              ! Namelist nammp  in reference namelist : Melt Ponds  
-      READ  ( numnam_ice_ref, nammp, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nammp  in reference namelist', lwp )
-
-      REWIND( numnam_ice_cfg )              ! Namelist nammp  in configuration namelist : Melt Ponds
-      READ  ( numnam_ice_cfg, nammp, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nammp in configuration namelist', lwp )
-      IF(lwm) WRITE ( numoni, nammp )
-      
-      IF(lwp) THEN                        ! control print
-         WRITE(numout,*)
-         WRITE(numout,*) 'lim_mp_init : ice parameters for melt ponds'
-         WRITE(numout,*) '~~~~~~~~~~~~'
-         WRITE(numout,*) '   Active melt ponds                                           ln_pnd        = ', ln_pnd
-         WRITE(numout,*) '   Active melt ponds radiative coupling                        ln_pnd_rad    = ', ln_pnd_rad
-         WRITE(numout,*) '   Active melt ponds freshwater coupling                       ln_pnd_fw     = ', ln_pnd_fw
-         WRITE(numout,*) '   Type of melt pond scheme =0 presc, =1 empirical = 2 topo    nn_pnd_scheme = ', nn_pnd_scheme
-         WRITE(numout,*) '   Prescribed pond fraction                                    rn_apnd       = ', rn_apnd
-         WRITE(numout,*) '   Prescribed pond depth                                       rn_hpnd       = ', rn_hpnd
-      ENDIF
-
-      IF ( .NOT. ln_pnd ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' Melt ponds are not activated '
-         IF(lwp) WRITE(numout,*) ' ln_pnd_rad and ln_pnd_fw set to .FALSE. '
-         IF(lwp) WRITE(numout,*) ' nn_pnd_scheme, rn_apnd, rn_hpnd set to zero '
-         ln_pnd_rad    = .FALSE.
-         ln_pnd_fw     = .FALSE.
-         nn_pnd_scheme = 0
-         rn_apnd       = 0._wp
-         rn_hpnd       = 0._wp
-
-         IF(lwp) THEN                     ! control print
-            WRITE(numout,*) '    Active melt ponds radiative coupling                        ln_pnd_rad    = ', ln_pnd_rad
-            WRITE(numout,*) '    Active melt ponds freshwater coupling                       ln_pnd_fw     = ', ln_pnd_fw
-            WRITE(numout,*) '    Type of melt pond scheme =0 presc, =1 empirical = 2 topo    nn_pnd_scheme = ', nn_pnd_scheme
-            WRITE(numout,*) '    Prescribed pond fraction                                    rn_apnd       = ', rn_apnd
-            WRITE(numout,*) '    Prescribed pond depth                                       rn_hpnd       = ', rn_hpnd
-         ENDIF
-      ENDIF
-
-      IF ( ln_pnd .AND. ( nn_pnd_scheme == 0 ) .AND. ( ln_pnd_fw ) ) THEN
-         IF(lwp) WRITE(numout,*) ' Prescribed melt ponds do not conserve fresh water mass, hence ln_pnd_fw must be set to false ' 
-         ln_pnd_fw     = .FALSE.
-         IF(lwp) THEN                     ! control print
-            WRITE(numout,*) '    Active melt ponds freshwater coupling                       ln_pnd_fw     = ', ln_pnd_fw
-         ENDIF
-      ENDIF
-
-      IF ( ln_pnd .AND. ( nn_pnd_scheme == 2 ) .AND. ( jpl == 1 ) ) THEN
-         IF(lwp) WRITE(numout,*) ' Topographic melt ponds are incompatible with jpl = 1 '
-         IF(lwp) WRITE(numout,*) ' Run aborted '
-         CALL ctl_stop( 'STOP', 'lim_mp_init: uncompatible options, reset namelist_ice_ref ' )
-      ENDIF
-
-      !
-   END SUBROUTINE lim_mp_init
-   
-
-   SUBROUTINE lim_mp( kt )
-      !!-------------------------------------------------------------------
-      !!               ***  ROUTINE lim_mp   ***
-      !!               
-      !! ** Purpose :   change melt pond fraction
-      !!                
-      !! ** Method  :   brutal force
-      !!
-      !! ** Action  : - 
-      !!              - 
-      !!------------------------------------------------------------------------------------
-
-      INTEGER, INTENT(in) :: kt    ! number of iteration
-      INTEGER  ::   ji, jj, jl     ! dummy loop indices
-
-      !!-------------------------------------------------------------------
-
-      IF( nn_timing == 1 )  CALL timing_start('lim_mp')
-
-      SELECT CASE ( nn_pnd_scheme )
-
-         CASE (0)
-
-            CALL lim_mp_cstt       ! staircase melt ponds
-
-         CASE (1)
-
-            CALL lim_mp_cesm       ! empirical melt ponds
-
-         CASE (2)
-
-            CALL lim_mp_topo   &   ! topographic melt ponds 
-                      &          (at_i, a_i,                                       &
-                      &          vt_i, v_i, v_s,            t_i, sz_i, a_ip_frac,   &
-                      &          h_ip,     t_su)
-
-      END SELECT
-
-      IF( nn_timing == 1 )  CALL timing_stop('lim_mp')
-
-   END SUBROUTINE lim_mp 
-
-   SUBROUTINE lim_mp_cstt 
-       !!-------------------------------------------------------------------
-       !!                ***  ROUTINE lim_mp_cstt  ***
-       !!
-       !! ** Purpose    : Compute melt pond evolution
-       !!
-       !! ** Method     : Melt pond fraction and thickness are prescribed 
-       !!                 to non-zero values when t_su = 0C
-       !!
-       !! ** Tunable parameters : pond fraction (rn_apnd), pond depth (rn_hpnd)
-       !!                
-       !! ** Note       : Coupling with such melt ponds is only radiative
-       !!                 Advection, ridging, rafting... are bypassed
-       !!
-       !! ** References : Bush, G.W., and Trump, D.J. (2017)
-       !!    
-       !!-------------------------------------------------------------------
-       INTEGER                             :: ji, jj, jl
-       REAL(wp)                            :: z1_jpl            ! 1/jpl
-       !!-------------------------------------------------------------------
-
-       z1_jpl     = 1. / FLOAT(jpl)
-
-       WHERE ( ( a_i > epsi10 ) .AND. ( t_su >= rt0-epsi06 ) ) 
-          a_ip_frac = rn_apnd
-          h_ip      = rn_hpnd    
-          v_ip      = a_ip_frac * a_i * h_ip 
-          a_ip      = a_ip_frac * a_i
-       ELSE WHERE
-          a_ip      = 0._wp
-          h_ip      = 0._wp
-          v_ip      = 0._wp
-          a_ip_frac = 0._wp
-       END WHERE
-
-       wfx_pnd(:,:) = 0._wp
-
-   END SUBROUTINE lim_mp_cstt
-
-   SUBROUTINE lim_mp_cesm
-       !!-------------------------------------------------------------------
-       !!                ***  ROUTINE lim_mp_cesm  ***
-       !!
-       !! ** Purpose    : Compute melt pond evolution
-       !!
-       !! ** Method     : Empirical method. A fraction of meltwater is accumulated 
-       !!                 in pond volume. It is then released exponentially when
-       !!                 surface is freezing.
-       !!
-       !! ** Tunable parameters : (no real expertise yet, ideas?)
-       !! 
-       !! ** Note       : Stolen from CICE for quick test of the melt pond
-       !!                 radiation and freshwater interfaces
-       !!                 Coupling can be radiative AND freshwater
-       !!                 Advection, ridging, rafting are called
-       !!
-       !! ** References : Holland, M. M. et al (J Clim 2012)
-       !!    
-       !!-------------------------------------------------------------------
-
-       INTEGER, DIMENSION(jpij)         :: indxi             ! compressed indices for cells with ice melting
-       INTEGER, DIMENSION(jpij)         :: indxj             !
-
-       REAL(wp), DIMENSION(jpi,jpj)     :: zwfx_mlw          ! available meltwater for melt ponding
-       REAL(wp), DIMENSION(jpi,jpj,jpl) :: zrfrac            ! fraction of available meltwater retained for melt ponding
-
-       REAL(wp), PARAMETER :: zrmin  = 0.15_wp  ! minimum fraction of available meltwater retained for melt ponding
-       REAL(wp), PARAMETER :: zrmax  = 0.70_wp  ! maximum   ''           ''       ''        ''            ''
-       REAL(wp), PARAMETER :: zrexp  = 0.01_wp  ! rate constant to refreeze melt ponds
-       REAL(wp), PARAMETER :: zpnd_aspect = 0.8_wp ! pond aspect ratio
-
-       REAL(wp) :: zhi               ! dummy ice thickness
-       REAL(wp) :: zhs               ! dummy snow depth
-       REAL(wp) :: zTp               ! reference temperature
-       REAL(wp) :: zdTs              ! dummy temperature difference
-       REAL(wp) :: z1_rhofw          ! inverse freshwater density
-       REAL(wp) :: z1_zpnd_aspect    ! inverse pond aspect ratio
-       REAL(wp) :: zvpold            ! dummy pond volume
-
-       INTEGER  :: ji, jj, jl, ij    ! loop indices
-       INTEGER  :: icells            ! size of dummy array
-       !!-------------------------------------------------------------------
-        z1_rhofw       = 1. / rhofw 
-        z1_zpnd_aspect = 1. / zpnd_aspect
-        zTp            = -2. 
-
-        a_ip_frac(:,:,:) = 0._wp
-        h_ip     (:,:,:) = 0._wp
- 
-        !------------------------------------------------------------------
-        ! Available melt water for melt ponding and corresponding fraction
-        !------------------------------------------------------------------
- 
-        zwfx_mlw(:,:) = MAX( wfx_sum(:,:) + wfx_snw_sum(:,:), 0._wp )        ! available meltwater for melt ponding
-
-                ! NB: zwfx_mlw can be slightly negative for very small values (why?)
-                ! This can in some occasions give negative
-                ! v_ip in the first category, which then gives crazy pond
-                ! fractions and crashes the code as soon as the melt-pond
-                ! radiative coupling is activated
-                ! if we understand and remove why wfx_sum or wfx_snw could be
-                ! negative, then, we can remove the MAX
-                ! NB: I now changed to wfx_snw_sum, this may fix the problem. 
-                ! We should check
- 
-        zrfrac(:,:,:) = zrmin + ( zrmax - zrmin ) * a_i(:,:,:)  
- 
-        DO jl = 1, jpl   
-
-           !------------------------------------------------------------------------------
-           ! Identify grid cells where ponds should be updated (can probably be improved)
-           !------------------------------------------------------------------------------
- 
-           indxi(:) = 0
-           indxj(:) = 0
-           icells   = 0
- 
-           DO jj = 1, jpj
-             DO ji = 1, jpi
-                IF ( a_i(ji,jj,jl) > epsi10 ) THEN
-                   icells = icells + 1
-                   indxi(icells) = ji
-                   indxj(icells) = jj
-                ENDIF
-             END DO                 ! ji
-          END DO                    ! jj
- 
-          DO ij = 1, icells
- 
-             ji = indxi(ij)
-             jj = indxj(ij)
- 
-             zhi = v_i(ji,jj,jl) / a_i(ji,jj,jl)
-             zhs = v_s(ji,jj,jl) / a_i(ji,jj,jl)
- 
-             IF ( zhi < rn_himin) THEN   !--- Remove ponds on thin ice if ice is too thin
- 
-                a_ip(ji,jj,jl)      = 0._wp                               !--- Dump ponds
-                v_ip(ji,jj,jl)      = 0._wp
-                a_ip_frac(ji,jj,jl) = 0._wp
-                h_ip(ji,jj,jl)      = 0._wp
- 
-                IF ( ln_pnd_fw ) & !--- Give freshwater to the ocean
-                   wfx_pnd(ji,jj)   = wfx_pnd(ji,jj) + v_ip(ji,jj,jl) 
- 
- 
-             ELSE                        !--- Update pond characteristics
- 
-                !--- Add retained melt water to melt ponds
-                ! v_ip should never be positive, otherwise code crashes
-                ! MV: as far as I saw, UM5 can create very small negative v_ip values
-                ! hence I added the max, which was not required with Prather (1 yr run)
-                v_ip(ji,jj,jl)      = MAX( v_ip(ji,jj,jl), 0._wp ) + zrfrac(ji,jj,jl) * z1_rhofw * zwfx_mlw(ji,jj) * a_i(ji,jj,jl) * rdt_ice
- 
-                !--- Shrink pond due to refreezing
-                zdTs                = MAX ( zTp - t_su(ji,jj,jl) + rt0 , 0. )
-                
-                zvpold              = v_ip(ji,jj,jl)
- 
-                v_ip(ji,jj,jl)      = v_ip(ji,jj,jl) * EXP( zrexp * zdTs / zTp )
- 
-                !--- Dump meltwater due to refreezing ( of course this is wrong
-                !--- but this parameterization is too simple )
-                IF ( ln_pnd_fw ) &
-                   wfx_pnd(ji,jj)   = wfx_pnd(ji,jj) + rhofw * ( v_ip(ji,jj,jl) - zvpold ) * r1_rdtice
- 
-                a_ip_frac(ji,jj,jl) = MIN( 1._wp , SQRT( v_ip(ji,jj,jl) * z1_zpnd_aspect / a_i(ji,jj,jl) ) )
-                   !NB: the SQRT has been a recurring source of crash when v_ip or a_i tuns to be even only slightly negative
- 
-                h_ip(ji,jj,jl)      = zpnd_aspect * a_ip_frac(ji,jj,jl)
- 
-                a_ip(ji,jj,jl)      = a_ip_frac(ji,jj,jl) * a_i(ji,jj,jl)
- 
-             !-----------------------------------------------------------
-             ! Limit pond depth
-             !-----------------------------------------------------------
-             ! The original version has pond depth limitation, which I did not
-             ! keep here. Maybe we need it later on
-             !
-             
-             ENDIF
- 
-           END DO
- 
-        END DO ! jpl
- 
-        !--- Remove retained meltwater from surface fluxes 
- 
-        IF ( ln_pnd_fw ) THEN
- 
-            wfx_snw_sum(:,:) = wfx_snw_sum(:,:) *  ( 1. - zrmin - ( zrmax - zrmin ) * at_i(:,:) ) 
-
-            wfx_sum(:,:)     = wfx_sum(:,:) * ( 1. - zrmin - ( zrmax - zrmin ) * at_i(:,:) )
-
-        ENDIF
-
-   END SUBROUTINE lim_mp_cesm
-
-   SUBROUTINE lim_mp_topo    (aice,      aicen,     &
-                              vice,      vicen,     &
-                              vsnon,                &
-                              ticen,     salin,     &
-                              a_ip_frac, h_ip,      &
-                                         Tsfc )
-       !!-------------------------------------------------------------------
-       !!                ***  ROUTINE lim_mp_topo  ***
-       !!
-       !! ** Purpose :   Compute melt pond evolution based on the ice 
-       !!                topography as inferred from the ice thickness 
-       !!                distribution.  
-       !!
-       !! ** Method  :   This code is initially based on Flocco and Feltham 
-       !!                (2007) and Flocco et al. (2010). More to come...
-       !!
-       !! ** Tunable parameters :
-       !! 
-       !! ** Note :
-       !!
-       !! ** References
-       !!    Flocco, D. and D. L. Feltham, 2007.  A continuum model of melt pond 
-       !!    evolution on Arctic sea ice.  J. Geophys. Res. 112, C08016, doi: 
-       !!    10.1029/2006JC003836.
-       !!    Flocco, D., D. L. Feltham and A. K. Turner, 2010.  Incorporation of
-       !!    a physically based melt pond scheme into the sea ice component of a
-       !!    climate model.  J. Geophys. Res. 115, C08012, 
-       !!    doi: 10.1029/2009JC005568.
-       !!    
-       !!-------------------------------------------------------------------
- 
-       REAL (wp), DIMENSION (jpi,jpj), &
-          INTENT(IN) :: &
-          aice, &    ! total ice area fraction
-          vice       ! total ice volume (m)
- 
-       REAL (wp), DIMENSION (jpi,jpj,jpl), &
-          INTENT(IN) :: &
-          aicen, &   ! ice area fraction, per category
-          vsnon, &   ! snow volume, per category (m)
-          vicen      ! ice volume, per category (m)
- 
-       REAL (wp), DIMENSION (jpi,jpj,nlay_i,jpl), &
-          INTENT(IN) :: &
-          ticen, &   ! ice enthalpy, per category
-          salin
- 
-       REAL (wp), DIMENSION (jpi,jpj,jpl), &
-          INTENT(INOUT) :: &
-          a_ip_frac , &   ! pond area fraction of ice, per ice category
-          h_ip       ! pond depth, per ice category (m)
- 
-       REAL (wp), DIMENSION (jpi,jpj,jpl), &
-          INTENT(IN) :: &
-          Tsfc       ! snow/sea ice surface temperature
- 
-       ! local variables
-       REAL (wp), DIMENSION (jpi,jpj,jpl) :: &
-          zTsfcn, & ! ice/snow surface temperature (C)
-          zvolpn, & ! pond volume per unit area, per category (m)
-          zvuin     ! water-equivalent volume of ice lid on melt pond ('upper ice', m)
- 
-       REAL (wp), DIMENSION (jpi,jpj,jpl) :: &
-          zapondn,& ! pond area fraction, per category
-          zhpondn   ! pond depth, per category (m)
- 
-       REAL (wp), DIMENSION (jpi,jpj) :: &
-          zvolp       ! total volume of pond, per unit area of pond (m)
- 
-       REAL (wp) :: &
-          zhi,    & ! ice thickness (m)
-          zdHui,  & ! change in thickness of ice lid (m)
-          zomega, & ! conduction
-          zdTice, & ! temperature difference across ice lid (C)
-          zdvice, & ! change in ice volume (m)
-          zTavg,  & ! mean surface temperature across categories (C)
-          zTp,    & ! pond freezing temperature (C)
-          zdvn      ! change in melt pond volume for fresh water budget
-       INTEGER, DIMENSION (jpi*jpj) :: &
-          indxi, indxj    ! compressed indices for cells with ice melting
- 
-       INTEGER :: n,k,i,j,ij,icells,indxij ! loop indices
- 
-       INTEGER, DIMENSION (jpl) :: &
-          kcells          ! cells where ice lid combines with vice
- 
-       INTEGER, DIMENSION (jpi*jpj,jpl) :: &
-          indxii, indxjj  ! i,j indices for kcells loop
- 
-       REAL (wp), parameter :: &
-          zhicemin  = 0.1_wp , & ! minimum ice thickness with ponds (m) 
-          zTd       = 0.15_wp, & ! temperature difference for freeze-up (C)
-          zr1_rlfus = 1._wp / 0.334e+6 / 917._wp , & ! (J/m^3)
-          zmin_volp = 1.e-4_wp, & ! minimum pond volume (m)
-          z0       = 0._wp,    & 
-          zTimelt   = 0._wp,    &
-          z01      = 0.01_wp,  &
-          z25      = 0.25_wp,  &
-          z5       = 0.5_wp
-
-       !---------------------------------------------------------------
-       ! Initialization
-       !---------------------------------------------------------------
- 
-       zhpondn(:,:,:) = 0._wp
-       zapondn(:,:,:) = 0._wp
-       indxii(:,:) = 0
-       indxjj(:,:) = 0
-       kcells(:)   = 0
-
-       zvolp(:,:) = wfx_sum(:,:) + wfx_snw_sum(:,:) + vt_ip(:,:) ! Total available melt water, to be distributed as melt ponds
-       zTsfcn(:,:,:) = zTsfcn(:,:,:) - rt0                   ! Convert in Celsius
- 
-       ! The freezing temperature for meltponds is assumed slightly below 0C,
-       ! as if meltponds had a little salt in them.  The salt budget is not
-       ! altered for meltponds, but if it were then an actual pond freezing 
-       ! temperature could be computed.
- 
-       ! zTp = zTimelt - zTd  ---> for lids
- 
-       !-----------------------------------------------------------------
-       ! Identify grid cells with ponds
-       !-----------------------------------------------------------------
- 
-       icells = 0
-       DO j = 1, jpj
-       DO i = 1, jpi
-          zhi = z0
-          IF (aice(i,j) > epsi10 ) zhi = vice(i,j)/aice(i,j)
-          IF ( aice(i,j) > z01 .and. zhi > zhicemin .and. &
-             zvolp(i,j) > zmin_volp*aice(i,j)) THEN
-             icells = icells + 1
-             indxi(icells) = i
-             indxj(icells) = j
-          ELSE  ! remove ponds on thin ice
-             !fpond(i,j) = fpond(i,j) - zvolp(i,j)
-             zvolpn(i,j,:) = z0
-             zvuin (i,j,:) = z0
-             zvolp (i,j) = z0
-          END IF
-       END DO                     ! i
-       END DO                     ! j
- 
-       DO ij = 1, icells
-          i = indxi(ij)
-          j = indxj(ij)
- 
-          !--------------------------------------------------------------
-          ! calculate pond area and depth
-          !--------------------------------------------------------------
-          CALL lim_mp_area(aice(i,j),vice(i,j), &
-                    aicen(i,j,:), vicen(i,j,:), vsnon(i,j,:), &
-                    ticen(i,j,:,:), salin(i,j,:,:), &
-                    zvolpn(i,j,:), zvolp(i,j), &
-                    zapondn(i,j,:),zhpondn(i,j,:), zdvn)
-         ! outputs are
-         ! - zdvn
-         ! - zvolpn
-         ! - zvolp
-         ! - zapondn
-         ! - zhpondn
-
-          wfx_pnd(i,j) = wfx_pnd(i,j) + zdvn ! update flux from ponds to ocean
- 
-          ! mean surface temperature MV - why do we need that ? --> for the lid
-
-          ! zTavg = z0
-          ! DO n = 1, jpl
-          !   zTavg = zTavg + zTsfcn(i,j,n)*aicen(i,j,n)
-          ! END DO
-          ! zTavg = zTavg / aice(i,j)
- 
-       END DO ! ij
- 
-       !---------------------------------------------------------------
-       ! Update pond volume and fraction
-       !---------------------------------------------------------------
- 
-       a_ip(:,:,:) = zapondn(:,:,:)
-       v_ip(:,:,:) = zapondn(:,:,:) * zhpondn(:,:,:)
-       a_ip_frac(:,:,:) = 0._wp
-       h_ip     (:,:,:) = 0._wp
-
-    END SUBROUTINE lim_mp_topo
-
-    SUBROUTINE lim_mp_area(aice,vice, &
-                         aicen, vicen, vsnon, ticen, &
-                         salin, zvolpn, zvolp,         &
-                         zapondn,zhpondn,dvolp)
-
-       !!-------------------------------------------------------------------
-       !!                ***  ROUTINE lim_mp_area ***
-       !!
-       !! ** Purpose : Given the total volume of meltwater, update
-       !!              pond fraction (a_ip) and depth (should be volume)
-       !!
-       !! **
-       !!              
-       !!------------------------------------------------------------------
-
-       REAL (wp), INTENT(IN) :: &
-          aice,vice
- 
-       REAL (wp), DIMENSION(jpl), INTENT(IN) :: &
-          aicen, vicen, vsnon
- 
-       REAL (wp), DIMENSION(nlay_i,jpl), INTENT(IN) :: &
-          ticen, salin
- 
-       REAL (wp), DIMENSION(jpl), INTENT(INOUT) :: &
-          zvolpn
- 
-       REAL (wp), INTENT(INOUT) :: &
-          zvolp, dvolp
- 
-       REAL (wp), DIMENSION(jpl), INTENT(OUT) :: &
-          zapondn, zhpondn
- 
-       INTEGER :: &
-          n, ns,   &
-          m_index, &
-          permflag
- 
-       REAL (wp), DIMENSION(jpl) :: &
-          hicen, &
-          hsnon, &
-          asnon, &
-          alfan, &
-          betan, &
-          cum_max_vol, &
-          reduced_aicen        
- 
-       REAL (wp), DIMENSION(0:jpl) :: &
-          cum_max_vol_tmp
- 
-       REAL (wp) :: &
-          hpond, &
-          drain, &
-          floe_weight, &
-          pressure_head, &
-          hsl_rel, &
-          deltah, &
-          perm, &
-          msno
- 
-       REAL (wp), parameter :: & 
-          viscosity = 1.79e-3_wp, &  ! kinematic water viscosity in kg/m/s
-          z0        = 0.0_wp    , &
-          c1        = 1.0_wp    , &
-          p4        = 0.4_wp    , &
-          p6        = 0.6_wp    , &
-          epsi10      = 1.0e-11_wp
-          
-      !-----------|
-      !           |
-      !           |-----------|
-      !___________|___________|______________________________________sea-level
-      !           |           |
-      !           |           |---^--------|
-      !           |           |   |        |
-      !           |           |   |        |-----------|              |-------
-      !           |           |   |alfan(n)|           |              |
-      !           |           |   |        |           |--------------|
-      !           |           |   |        |           |              |
-      !---------------------------v-------------------------------------------
-      !           |           |   ^        |           |              |
-      !           |           |   |        |           |--------------|
-      !           |           |   |betan(n)|           |              |
-      !           |           |   |        |-----------|              |-------
-      !           |           |   |        |
-      !           |           |---v------- |
-      !           |           |
-      !           |-----------|
-      !           |
-      !-----------|
-     
-       !-------------------------------------------------------------------
-       ! initialize
-       !-------------------------------------------------------------------
- 
-       DO n = 1, jpl
- 
-          zapondn(n) = z0
-          zhpondn(n) = z0
- 
-          !----------------------------------------
-          ! X) compute the effective snow fraction
-          !----------------------------------------
-          IF (aicen(n) < epsi10)  THEN
-             hicen(n) =  z0 
-             hsnon(n) = z0
-             reduced_aicen(n) = z0
-          ELSE
-             hicen(n) = vicen(n) / aicen(n)
-             hsnon(n) = vsnon(n) / aicen(n)
-             reduced_aicen(n) = c1 ! n=jpl
-             IF (n < jpl) reduced_aicen(n) = aicen(n) &
-                                  * (-0.024_wp*hicen(n) + 0.832_wp) 
-             asnon(n) = reduced_aicen(n)  ! effective snow fraction (empirical)
-             ! MV should check whether this makes sense to have the same effective snow fraction in here
-          END IF
- 
- ! This choice for alfa and beta ignores hydrostatic equilibium of categories.
- ! Hydrostatic equilibium of the entire ITD is accounted for below, assuming
- ! a surface topography implied by alfa=0.6 and beta=0.4, and rigidity across all
- ! categories.  alfa and beta partition the ITD - they are areas not thicknesses!
- ! Multiplying by hicen, alfan and betan (below) are thus volumes per unit area.
- ! Here, alfa = 60% of the ice area (and since hice is constant in a category, 
- ! alfan = 60% of the ice volume) in each category lies above the reference line, 
- ! and 40% below. Note: p6 is an arbitrary choice, but alfa+beta=1 is required.
-
- ! MV:  
- ! Note that this choice is not in the original FF07 paper and has been adopted in CICE
- ! No reason why is explained in the doc, but I guess there is a reason. I'll try to investigate, maybe
-
- ! Where does that choice come from
- 
-          alfan(n) = 0.6 * hicen(n)
-          betan(n) = 0.4 * hicen(n)
-        
-          cum_max_vol(n)     = z0
-          cum_max_vol_tmp(n) = z0
-     
-       END DO ! jpl
- 
-       cum_max_vol_tmp(0) = z0
-       drain = z0
-       dvolp = z0
-
-       !----------------------------------------------------------
-       ! x) Drain overflow water, update pond fraction and volume
-       !----------------------------------------------------------
-       
-       !--------------------------------------------------------------------------
-       ! the maximum amount of water that can be contained up to each ice category
-       !--------------------------------------------------------------------------
-
-       ! MV
-       ! If melt ponds are too deep to be sustainable given the ITD (OVERFLOW)
-       ! Then the excess volume cum_max_vol(jl) drains out of the system
-       ! It should be added to wfx_pnd
-       ! END MV
-     
-       DO n = 1, jpl-1 ! last category can not hold any volume
- 
-          IF (alfan(n+1) >= alfan(n) .and. alfan(n+1) > z0) THEN
- 
-             ! total volume in level including snow
-             cum_max_vol_tmp(n) = cum_max_vol_tmp(n-1) + &
-                (alfan(n+1) - alfan(n)) * sum(reduced_aicen(1:n)) 
- 
-             ! subtract snow solid volumes from lower categories in current level
-             DO ns = 1, n 
-                cum_max_vol_tmp(n) = cum_max_vol_tmp(n) &
-                   - rhosn/rhofw * &   ! free air fraction that can be filled by water
-                     asnon(ns)  * &    ! effective areal fraction of snow in that category
-                     max(min(hsnon(ns)+alfan(ns)-alfan(n), alfan(n+1)- &
-                                   alfan(n)), z0)  
-             END DO
-
-          ELSE ! assume higher categories unoccupied
-             cum_max_vol_tmp(n) = cum_max_vol_tmp(n-1)
-          END IF
-          !IF (cum_max_vol_tmp(n) < z0) THEN
-          !   call abort_ice('negative melt pond volume')
-          !END IF
-       END DO
-       cum_max_vol_tmp(jpl) = cum_max_vol_tmp(jpl-1)  ! last category holds no volume
-       cum_max_vol  (1:jpl) = cum_max_vol_tmp(1:jpl)
-     
-       !----------------------------------------------------------------
-       ! is there more meltwater than can be held in the floe?
-       !----------------------------------------------------------------
-       IF (zvolp >= cum_max_vol(jpl)) THEN
-          drain = zvolp - cum_max_vol(jpl) + epsi10
-          zvolp = zvolp - drain ! update meltwater volume available
-          dvolp = drain         ! this is the drained water
-          IF (zvolp < epsi10) THEN
-             dvolp = dvolp + zvolp
-             zvolp = z0
-          END IF
-       END IF
-     
-       ! height and area corresponding to the remaining volume
- 
-!      call calc_hpond(reduced_aicen, asnon, hsnon, rhos, alfan, &
-!           zvolp, cum_max_vol, hpond, m_index)
-     
-       DO n=1, m_index
-          zhpondn(n) = hpond - alfan(n) + alfan(1) ! here oui choulde update
-                                                   !  volume instead, no ?
-          zapondn(n) = reduced_aicen(n) 
-          ! in practise, pond fraction depends on the empirical snow fraction
-          ! so in turn on ice thickness
-       END DO
-     
-       !------------------------------------------------------------------------
-       ! Drainage through brine network (permeability)
-       !------------------------------------------------------------------------
-       !!! drainage due to ice permeability - Darcy's law
-     
-       ! sea water level 
-       msno = z0
-       DO n=1,jpl
-         msno = msno + vsnon(n) * rhosn
-       END DO
-       floe_weight = (msno + rhoic*vice + rau0*zvolp) / aice
-       hsl_rel = floe_weight / rau0 &
-               - ((sum(betan(:)*aicen(:))/aice) + alfan(1))
-     
-       deltah = hpond - hsl_rel
-       pressure_head = grav * rau0 * max(deltah, z0)
- 
-       ! drain IF ice is permeable    
-       permflag = 0
-       IF (pressure_head > z0) THEN
-       DO n = 1, jpl-1
-          IF (hicen(n) /= z0) THEN
-             perm = 0. ! MV ugly dummy patch
-             CALL lim_mp_perm(ticen(:,n), salin(:,n), vicen(n), perm)
-             IF (perm > z0) permflag = 1
-
-             drain = perm*zapondn(n)*pressure_head*rdt_ice / &
-                                      (viscosity*hicen(n))
-             dvolp = dvolp + min(drain, zvolp)
-             zvolp = max(zvolp - drain, z0)
-             IF (zvolp < epsi10) THEN
-                dvolp = dvolp + zvolp
-                zvolp = z0
-             END IF
-          END IF
-       END DO
-  
-       ! adjust melt pond DIMENSIONs
-       IF (permflag > 0) THEN
-          ! recompute pond depth    
-!         CALL calc_hpond(reduced_aicen, asnon, hsnon, rhos, alfan, &
-!                         zvolp, cum_max_vol, hpond, m_index)
-          DO n=1, m_index
-             zhpondn(n) = hpond - alfan(n) + alfan(1)
-             zapondn(n) = reduced_aicen(n) 
-          END DO
-       END IF
-       END IF ! pressure_head
- 
-       !-------------------------------
-       ! X) remove water from the snow
-       !-------------------------------
-       !------------------------------------------------------------------------
-       ! total melt pond volume in category DOes not include snow volume
-       ! snow in melt ponds is not melted
-       !------------------------------------------------------------------------
- 
-       ! Calculate pond volume for lower categories
-       DO n=1,m_index-1
-          zvolpn(n) = zapondn(n) * zhpondn(n) & ! what is not in the snow
-                   - (rhosn/rhofw) * asnon(n) * min(hsnon(n), zhpondn(n))
-       END DO
- 
-       ! Calculate pond volume for highest category = remaining pond volume
-
-       ! The following is completely unclear to Martin at least
-       ! Could we redefine properly and recode in a more readable way ?
-
-       ! m_index = last category with melt pond
-
-       IF (m_index == 1) zvolpn(m_index) = zvolp ! volume of mw in 1st category is the total volume of melt water
-
-       IF (m_index > 1) THEN
-         IF (zvolp > sum(zvolpn(1:m_index-1))) THEN
-           zvolpn(m_index) = zvolp - sum(zvolpn(1:m_index-1)) ! 
-         ELSE
-           zvolpn(m_index) = z0
-           zhpondn(m_index) = z0
-           zapondn(m_index) = z0
-           ! If remaining pond volume is negative reduce pond volume of 
-           ! lower category
-           IF (zvolp+epsi10 < sum(zvolpn(1:m_index-1))) & 
-             zvolpn(m_index-1) = zvolpn(m_index-1)-sum(zvolpn(1:m_index-1))&
-                                + zvolp
-         END IF
-       END IF
- 
-       DO n=1,m_index
-          IF (zapondn(n) > epsi10) THEN
-              zhpondn(n) = zvolpn(n) / zapondn(n)
-          ELSE
-             dvolp = dvolp + zvolpn(n)
-             zhpondn(n) = z0
-             zvolpn(n) = z0
-             zapondn(n) = z0
-          end IF
-       END DO
-       DO n = m_index+1, jpl
-          zhpondn(n) = z0
-          zapondn(n) = z0
-          zvolpn (n) = z0
-       END DO
- 
-    END SUBROUTINE lim_mp_area
-
-!OLI_CODE   
-!OLI_CODE 
-!OLI_CODE    SUBROUTINE calc_hpond(aicen, asnon, hsnon, rhos, alfan, &
-!OLI_CODE                          zvolp, cum_max_vol,                &
-!OLI_CODE                          hpond, m_index)
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE       !!                ***  ROUTINE calc_hpond  ***
-!OLI_CODE       !!
-!OLI_CODE       !! ** Purpose :   Compute melt pond depth
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE     
-!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(IN) :: &
-!OLI_CODE          aicen, &
-!OLI_CODE          asnon, &
-!OLI_CODE          hsnon, &
-!OLI_CODE          rhos,  &
-!OLI_CODE          alfan, &
-!OLI_CODE          cum_max_vol
-!OLI_CODE     
-!OLI_CODE       REAL (wp), INTENT(IN) :: &
-!OLI_CODE          zvolp
-!OLI_CODE     
-!OLI_CODE       REAL (wp), INTENT(OUT) :: &
-!OLI_CODE          hpond
-!OLI_CODE     
-!OLI_CODE       INTEGER, INTENT(OUT) :: &
-!OLI_CODE          m_index
-!OLI_CODE     
-!OLI_CODE       INTEGER :: n, ns
-!OLI_CODE     
-!OLI_CODE       REAL (wp), DIMENSION(0:jpl+1) :: &
-!OLI_CODE          hitl, &
-!OLI_CODE          aicetl
-!OLI_CODE     
-!OLI_CODE       REAL (wp) :: &
-!OLI_CODE          rem_vol, &
-!OLI_CODE          area, &
-!OLI_CODE          vol, &
-!OLI_CODE          tmp, &
-!OLI_CODE          z0   = 0.0_wp,    &   
-!OLI_CODE          epsi10 = 1.0e-11_wp
-!OLI_CODE     
-!OLI_CODE       !----------------------------------------------------------------
-!OLI_CODE       ! hpond is zero if zvolp is zero - have we fully drained? 
-!OLI_CODE       !----------------------------------------------------------------
-!OLI_CODE     
-!OLI_CODE       IF (zvolp < epsi10) THEN
-!OLI_CODE        hpond = z0
-!OLI_CODE        m_index = 0
-!OLI_CODE       ELSE
-!OLI_CODE        
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        ! Calculate the category where water fills up to 
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        !----------|
-!OLI_CODE        !          |
-!OLI_CODE        !          |
-!OLI_CODE        !          |----------|                                     -- --
-!OLI_CODE        !__________|__________|_________________________________________ ^
-!OLI_CODE        !          |          |             rem_vol     ^                | Semi-filled
-!OLI_CODE        !          |          |----------|-- -- -- - ---|-- ---- -- -- --v layer
-!OLI_CODE        !          |          |          |              |
-!OLI_CODE        !          |          |          |              |hpond
-!OLI_CODE        !          |          |          |----------|   |     |-------
-!OLI_CODE        !          |          |          |          |   |     |
-!OLI_CODE        !          |          |          |          |---v-----|
-!OLI_CODE        !          |          | m_index  |          |         |
-!OLI_CODE        !-------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        m_index = 0  ! 1:m_index categories have water in them
-!OLI_CODE        DO n = 1, jpl
-!OLI_CODE           IF (zvolp <= cum_max_vol(n)) THEN
-!OLI_CODE              m_index = n
-!OLI_CODE              IF (n == 1) THEN
-!OLI_CODE                 rem_vol = zvolp
-!OLI_CODE              ELSE
-!OLI_CODE                 rem_vol = zvolp - cum_max_vol(n-1)
-!OLI_CODE              END IF
-!OLI_CODE              exit ! to break out of the loop
-!OLI_CODE           END IF
-!OLI_CODE        END DO
-!OLI_CODE        m_index = min(jpl-1, m_index)
-!OLI_CODE        
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        ! semi-filled layer may have m_index different snow in it
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        !-----------------------------------------------------------  ^
-!OLI_CODE        !                                                             |  alfan(m_index+1)
-!OLI_CODE        !                                                             |
-!OLI_CODE        !hitl(3)-->                             |----------|          |
-!OLI_CODE        !hitl(2)-->                |------------| * * * * *|          |
-!OLI_CODE        !hitl(1)-->     |----------|* * * * * * |* * * * * |          |
-!OLI_CODE        !hitl(0)-->-------------------------------------------------  |  ^
-!OLI_CODE        !                various snow from lower categories          |  |alfa(m_index)
-!OLI_CODE        
-!OLI_CODE        ! hitl - heights of the snow layers from thinner and current categories
-!OLI_CODE        ! aicetl - area of each snow depth in this layer
-!OLI_CODE        
-!OLI_CODE        hitl(:) = z0
-!OLI_CODE        aicetl(:) = z0
-!OLI_CODE        DO n = 1, m_index
-!OLI_CODE           hitl(n)   = max(min(hsnon(n) + alfan(n) - alfan(m_index), &
-!OLI_CODE                                  alfan(m_index+1) - alfan(m_index)), z0)
-!OLI_CODE           aicetl(n) = asnon(n)
-!OLI_CODE           
-!OLI_CODE           aicetl(0) = aicetl(0) + (aicen(n) - asnon(n))
-!OLI_CODE        END DO
-!OLI_CODE        hitl(m_index+1) = alfan(m_index+1) - alfan(m_index)
-!OLI_CODE        aicetl(m_index+1) = z0
-!OLI_CODE        
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        ! reorder array according to hitl 
-!OLI_CODE        ! snow heights not necessarily in height order
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        DO ns = 1, m_index+1
-!OLI_CODE           DO n = 0, m_index - ns + 1
-!OLI_CODE              IF (hitl(n) > hitl(n+1)) THEN ! swap order
-!OLI_CODE                 tmp = hitl(n)
-!OLI_CODE                 hitl(n) = hitl(n+1)
-!OLI_CODE                 hitl(n+1) = tmp
-!OLI_CODE                 tmp = aicetl(n)
-!OLI_CODE                 aicetl(n) = aicetl(n+1)
-!OLI_CODE                 aicetl(n+1) = tmp
-!OLI_CODE              END IF
-!OLI_CODE           END DO
-!OLI_CODE        END DO
-!OLI_CODE        
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        ! divide semi-filled layer into set of sublayers each vertically homogenous
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        !hitl(3)----------------------------------------------------------------
-!OLI_CODE        !                                                       | * * * * * * * *  
-!OLI_CODE        !                                                       |* * * * * * * * * 
-!OLI_CODE        !hitl(2)----------------------------------------------------------------
-!OLI_CODE        !                                    | * * * * * * * *  | * * * * * * * *  
-!OLI_CODE        !                                    |* * * * * * * * * |* * * * * * * * * 
-!OLI_CODE        !hitl(1)----------------------------------------------------------------
-!OLI_CODE        !                 | * * * * * * * *  | * * * * * * * *  | * * * * * * * *  
-!OLI_CODE        !                 |* * * * * * * * * |* * * * * * * * * |* * * * * * * * * 
-!OLI_CODE        !hitl(0)----------------------------------------------------------------
-!OLI_CODE        !    aicetl(0)         aicetl(1)           aicetl(2)          aicetl(3)            
-!OLI_CODE        
-!OLI_CODE        ! move up over layers incrementing volume
-!OLI_CODE        DO n = 1, m_index+1
-!OLI_CODE           
-!OLI_CODE           area = sum(aicetl(:)) - &                 ! total area of sub-layer
-!OLI_CODE                (rhos(n)/rau0) * sum(aicetl(n:jpl+1)) ! area of sub-layer occupied by snow
-!OLI_CODE           
-!OLI_CODE           vol = (hitl(n) - hitl(n-1)) * area      ! thickness of sub-layer times area
-!OLI_CODE           
-!OLI_CODE           IF (vol >= rem_vol) THEN  ! have reached the sub-layer with the depth within
-!OLI_CODE              hpond = rem_vol / area + hitl(n-1) + alfan(m_index) - &
-!OLI_CODE                           alfan(1)
-!OLI_CODE              exit
-!OLI_CODE           ELSE  ! still in sub-layer below the sub-layer with the depth
-!OLI_CODE              rem_vol = rem_vol - vol
-!OLI_CODE           END IF
-!OLI_CODE           
-!OLI_CODE        END DO
-!OLI_CODE        
-!OLI_CODE       END IF
-!OLI_CODE     
-!OLI_CODE    END SUBROUTINE calc_hpond
-!OLI_CODE   
-!OLI_CODE 
-    SUBROUTINE lim_mp_perm(ticen, salin, vicen, perm)
-       !!-------------------------------------------------------------------
-       !!                ***  ROUTINE lim_mp_perm ***
-       !!
-       !! ** Purpose :   Determine the liquid fraction of brine in the ice
-       !!                and its permeability
-       !!-------------------------------------------------------------------
-       REAL (wp), DIMENSION(nlay_i), INTENT(IN) :: &
-          ticen,  & ! energy of melting for each ice layer (J/m2)
-          salin
- 
-       REAL (wp), INTENT(IN) :: &
-          vicen     ! ice volume
-     
-       REAL (wp), INTENT(OUT) :: &
-          perm      ! permeability
- 
-       REAL (wp) ::   &
-          Sbr        ! brine salinity
- 
-       REAL (wp), DIMENSION(nlay_i) ::   &
-          Tin, &    ! ice temperature
-          phi       ! liquid fraction
- 
-       INTEGER :: k
-     
-       REAL (wp) :: &
-          c2    = 2.0_wp
-  
-       !-----------------------------------------------------------------
-       ! Compute ice temperatures from enthalpies using quadratic formula
-       !-----------------------------------------------------------------
- 
-       DO k = 1,nlay_i
-          Tin(k) = ticen(k) 
-       END DO
- 
-       !-----------------------------------------------------------------
-       ! brine salinity and liquid fraction
-       !-----------------------------------------------------------------
- 
-       IF (maxval(Tin-rtt) <= -c2) THEN
- 
-          DO k = 1,nlay_i
-             Sbr = - 1.2_wp                 &
-                   -21.8_wp     * (Tin(k)-rtt)    &
-                   - 0.919_wp   * (Tin(k)-rtt)**2 &
-                   - 0.01878_wp * (Tin(k)-rtt)**3
-             phi(k) = salin(k)/Sbr ! liquid fraction
-          END DO ! k
-        
-       ELSE
- 
-          DO k = 1,nlay_i
-             Sbr = -17.6_wp    * (Tin(k)-rtt)    &
-                   - 0.389_wp  * (Tin(k)-rtt)**2 &
-                   - 0.00362_wp* (Tin(k)-rtt)**3
-             phi(k) = salin(k)/Sbr ! liquid fraction
-          END DO
- 
-       END IF
-     
-       !-----------------------------------------------------------------
-       ! permeability
-       !-----------------------------------------------------------------
- 
-       perm = 3.0e-08_wp * (minval(phi))**3 ! REFERENCE PLEASE (this fucking
-                                            ! bastard of Golden)
-     
-    END SUBROUTINE lim_mp_perm
-!OLI_CODE   
-!OLI_CODE #else
-!OLI_CODE    !!----------------------------------------------------------------------
-!OLI_CODE    !!   Default option         Dummy Module          No LIM-3 sea-ice model
-!OLI_CODE    !!----------------------------------------------------------------------
-!OLI_CODE CONTAINS
-!OLI_CODE    SUBROUTINE lim_mp_init          ! Empty routine
-!OLI_CODE    END SUBROUTINE lim_mp_init   
-!OLI_CODE    SUBROUTINE lim_mp               ! Empty routine
-!OLI_CODE    END SUBROUTINE lim_mp
-!OLI_CODE    SUBROUTINE compute_mp_topo      ! Empty routine
-!OLI_CODE    END SUBROUTINE compute_mp_topo        
-!OLI_CODE    SUBROUTINE pond_area            ! Empty routine
-!OLI_CODE    END SUBROUTINE pond_area   
-!OLI_CODE    SUBROUTINE calc_hpond           ! Empty routine
-!OLI_CODE    END SUBROUTINE calc_hpond   
-!OLI_CODE    SUBROUTINE permeability_phy     ! Empty routine
-!OLI_CODE    END SUBROUTINE permeability_phy   
-!OLI_CODE #endif
-!OLI_CODE    !!======================================================================
-!OLI_CODE END MODULE limmp_topo
-
-
-!OLI_CODE MODULE limmp_topo
-!OLI_CODE    !!======================================================================
-!OLI_CODE    !!                       ***  MODULE limmp_topo ***
-!OLI_CODE    !! LIM-3 sea-ice :  computation of melt ponds' properties
-!OLI_CODE    !!======================================================================
-!OLI_CODE    !! History :  Original code by Daniela Flocco and Adrian Turner
-!OLI_CODE    !!            ! 2012-09 (O. Lecomte) Adaptation for routine inclusion in 
-!OLI_CODE    !!                      NEMO-LIM3.1
-!OLI_CODE    !!            ! 2016-11 (O. Lecomte, C. Rousset, M. Vancoppenolle) 
-!OLI_CODE    !!                      Adaptation for merge with NEMO-LIM3.6
-!OLI_CODE    !!----------------------------------------------------------------------
-!OLI_CODE #if defined key_lim3
-!OLI_CODE    !!----------------------------------------------------------------------
-!OLI_CODE    !!   'key_lim3'                                      LIM-3 sea-ice model
-!OLI_CODE    !!----------------------------------------------------------------------
-!OLI_CODE    !!   lim_mp_init     : melt pond properties initialization
-!OLI_CODE    !!   lim_mp          : melt pond routine caller
-!OLI_CODE    !!   compute_mp_topo : Actual melt pond routine
-!OLI_CODE    !!----------------------------------------------------------------------
-!OLI_CODE    USE ice_oce, ONLY: rdt_ice, tatm_ice
-!OLI_CODE    USE phycst
-!OLI_CODE    USE dom_ice
-!OLI_CODE    USE dom_oce
-!OLI_CODE    USE sbc_oce
-!OLI_CODE    USE sbc_ice
-!OLI_CODE    USE par_ice
-!OLI_CODE    USE par_oce
-!OLI_CODE    USE ice
-!OLI_CODE    USE thd_ice
-!OLI_CODE    USE in_out_manager
-!OLI_CODE    USE lbclnk
-!OLI_CODE    USE lib_mpp
-!OLI_CODE 
-!OLI_CODE    IMPLICIT NONE
-!OLI_CODE    PRIVATE
-!OLI_CODE 
-!OLI_CODE    PUBLIC   lim_mp_init
-!OLI_CODE    PUBLIC   lim_mp
-!OLI_CODE 
-!OLI_CODE CONTAINS
-!OLI_CODE 
-!OLI_CODE    SUBROUTINE lim_mp_init
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE       !!                ***  ROUTINE lim_mp_init  ***
-!OLI_CODE       !!
-!OLI_CODE       !! ** Purpose :   Initialize melt ponds
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE       a_ip_frac(:,:,:)    = 0._wp
-!OLI_CODE       a_ip(:,:,:)         = 0._wp
-!OLI_CODE       h_ip(:,:,:)         = 0._wp
-!OLI_CODE       v_ip(:,:,:)         = 0._wp
-!OLI_CODE       h_il(:,:,:)         = 0._wp
-!OLI_CODE       v_il(:,:,:)         = 0._wp
-!OLI_CODE         
-!OLI_CODE    END SUBROUTINE lim_mp_init
-!OLI_CODE 
-!OLI_CODE 
-!OLI_CODE    SUBROUTINE lim_mp
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE       !!                ***  ROUTINE lim_mp  ***
-!OLI_CODE       !!
-!OLI_CODE       !! ** Purpose :   Compute surface heat flux and call main melt pond
-!OLI_CODE       !!                routine
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       INTEGER  ::   ji, jj, jl   ! dummy loop indices
-!OLI_CODE 
-!OLI_CODE       fsurf(:,:) = 0.e0
-!OLI_CODE       DO jl = 1, jpl
-!OLI_CODE          DO jj = 1, jpj
-!OLI_CODE             DO ji = 1, jpi
-!OLI_CODE                fsurf(ji,jj) = fsurf(ji,jj) + a_i(ji,jj,jl) * &
-!OLI_CODE                      (qns_ice(ji,jj,jl) + (1.0 - izero(ji,jj,jl)) &
-!OLI_CODE                        * qsr_ice(ji,jj,jl))
-!OLI_CODE             END DO
-!OLI_CODE          END DO
-!OLI_CODE       END DO
-!OLI_CODE 
-!OLI_CODE       CALL compute_mp_topo(at_i, a_i,                               &
-!OLI_CODE                          vt_i, v_i, v_s, rhosn_glo, t_i, sz_i, a_ip_frac,  &
-!OLI_CODE                       h_ip, h_il, t_su, tatm_ice, diag_sur_me*rdt_ice, &
-!OLI_CODE                          fsurf, fwoc)
-!OLI_CODE 
-!OLI_CODE       at_ip(:,:) = 0.0
-!OLI_CODE       vt_ip(:,:) = 0.0
-!OLI_CODE       vt_il(:,:) = 0.0
-!OLI_CODE       DO jl = 1, jpl
-!OLI_CODE         DO jj = 1, jpj
-!OLI_CODE            DO ji = 1, jpi
-!OLI_CODE               a_ip(ji,jj,jl) = MAX(0.0_wp, a_ip_frac(ji,jj,jl) * &
-!OLI_CODE                                                   a_i(ji,jj,jl))
-!OLI_CODE               v_ip(ji,jj,jl) = MAX(0.0_wp, a_ip_frac(ji,jj,jl) * &
-!OLI_CODE                                   a_i(ji,jj,jl) * h_ip(ji,jj,jl))
-!OLI_CODE               v_il(ji,jj,jl) = MAX(0.0_wp, a_ip_frac(ji,jj,jl) * &
-!OLI_CODE                                   a_i(ji,jj,jl) * h_il(ji,jj,jl))
-!OLI_CODE               at_ip(ji,jj)   = at_ip(ji,jj) + a_ip(ji,jj,jl)
-!OLI_CODE               vt_ip(ji,jj)   = vt_ip(ji,jj) + v_ip(ji,jj,jl)
-!OLI_CODE               vt_il(ji,jj)   = vt_il(ji,jj) + v_il(ji,jj,jl)
-!OLI_CODE            END DO
-!OLI_CODE         END DO
-!OLI_CODE       END DO
-!OLI_CODE 
-!OLI_CODE    END SUBROUTINE lim_mp
-!OLI_CODE 
-!OLI_CODE 
-!OLI_CODE    SUBROUTINE compute_mp_topo(aice,      aicen,     &
-!OLI_CODE                               vice,      vicen,     &
-!OLI_CODE                               vsnon,     rhos,      &
-!OLI_CODE                               ticen,     salin,     &
-!OLI_CODE                               a_ip_frac, h_ip,      &
-!OLI_CODE                               h_il,      Tsfc,      &
-!OLI_CODE                               potT,      meltt,     &
-!OLI_CODE                               fsurf,     fwoc)
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE       !!                ***  ROUTINE compute_mp_topo  ***
-!OLI_CODE       !!
-!OLI_CODE       !! ** Purpose :   Compute melt pond evolution based on the ice 
-!OLI_CODE       !!                topography as inferred from the ice thickness 
-!OLI_CODE       !!                distribution.  
-!OLI_CODE       !!
-!OLI_CODE       !! ** Method  :   This code is initially based on Flocco and Feltham 
-!OLI_CODE       !!                (2007) and Flocco et al. (2010). More to come...
-!OLI_CODE       !!
-!OLI_CODE       !! ** Tunable parameters :
-!OLI_CODE       !! 
-!OLI_CODE       !! ** Note :
-!OLI_CODE       !!
-!OLI_CODE       !! ** References
-!OLI_CODE       !!    Flocco, D. and D. L. Feltham, 2007.  A continuum model of melt pond 
-!OLI_CODE       !!    evolution on Arctic sea ice.  J. Geophys. Res. 112, C08016, doi: 
-!OLI_CODE       !!    10.1029/2006JC003836.
-!OLI_CODE       !!    Flocco, D., D. L. Feltham and A. K. Turner, 2010.  Incorporation of
-!OLI_CODE       !!    a physically based melt pond scheme into the sea ice component of a
-!OLI_CODE       !!    climate model.  J. Geophys. Res. 115, C08012, 
-!OLI_CODE       !!    doi: 10.1029/2009JC005568.
-!OLI_CODE       !!    
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj), &
-!OLI_CODE          INTENT(IN) :: &
-!OLI_CODE          aice, &    ! total ice area fraction
-!OLI_CODE          vice       ! total ice volume (m)
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl), &
-!OLI_CODE          INTENT(IN) :: &
-!OLI_CODE          aicen, &   ! ice area fraction, per category
-!OLI_CODE          vsnon, &   ! snow volume, per category (m)
-!OLI_CODE          rhos,  &   ! equivalent snow density, per category (kg/m^3)
-!OLI_CODE          vicen      ! ice volume, per category (m)
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,nlay_i,jpl), &
-!OLI_CODE          INTENT(IN) :: &
-!OLI_CODE          ticen, &   ! ice enthalpy, per category
-!OLI_CODE          salin
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl), &
-!OLI_CODE          INTENT(INOUT) :: &
-!OLI_CODE          a_ip_frac , &   ! pond area fraction of ice, per ice category
-!OLI_CODE          h_ip , &   ! pond depth, per ice category (m)
-!OLI_CODE          h_il       ! Refrozen ice lid thickness, per ice category (m)
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj), &
-!OLI_CODE          INTENT(IN) :: &
-!OLI_CODE          potT,  &   ! air potential temperature
-!OLI_CODE          meltt, &   ! total surface meltwater flux
-!OLI_CODE          fsurf      ! thermodynamic heat flux at ice/snow surface (W/m^2)
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj), &
-!OLI_CODE          INTENT(INOUT) :: &
-!OLI_CODE          fwoc      ! fresh water flux to the ocean (from draining and other pond volume adjustments)
-!OLI_CODE                    ! (m)
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl), &
-!OLI_CODE          INTENT(IN) :: &
-!OLI_CODE          Tsfc       ! snow/sea ice surface temperature
-!OLI_CODE 
-!OLI_CODE       ! local variables
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl) :: &
-!OLI_CODE          zTsfcn, & ! ice/snow surface temperature (C)
-!OLI_CODE          zvolpn, & ! pond volume per unit area, per category (m)
-!OLI_CODE          zvuin     ! water-equivalent volume of ice lid on melt pond ('upper ice', m)
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj,jpl) :: &
-!OLI_CODE          zapondn,& ! pond area fraction, per category
-!OLI_CODE          zhpondn   ! pond depth, per category (m)
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION (jpi,jpj) :: &
-!OLI_CODE          zvolp       ! total volume of pond, per unit area of pond (m)
-!OLI_CODE 
-!OLI_CODE       REAL (wp) :: &
-!OLI_CODE          zhi,    & ! ice thickness (m)
-!OLI_CODE          zdHui,  & ! change in thickness of ice lid (m)
-!OLI_CODE          zomega, & ! conduction
-!OLI_CODE          zdTice, & ! temperature difference across ice lid (C)
-!OLI_CODE          zdvice, & ! change in ice volume (m)
-!OLI_CODE          zTavg,  & ! mean surface temperature across categories (C)
-!OLI_CODE          zTp,    & ! pond freezing temperature (C)
-!OLI_CODE          zdvn      ! change in melt pond volume for fresh water budget
-!OLI_CODE       INTEGER, DIMENSION (jpi*jpj) :: &
-!OLI_CODE          indxi, indxj    ! compressed indices for cells with ice melting
-!OLI_CODE 
-!OLI_CODE       INTEGER :: n,k,i,j,ij,icells,indxij ! loop indices
-!OLI_CODE 
-!OLI_CODE       INTEGER, DIMENSION (jpl) :: &
-!OLI_CODE          kcells          ! cells where ice lid combines with vice
-!OLI_CODE 
-!OLI_CODE       INTEGER, DIMENSION (jpi*jpj,jpl) :: &
-!OLI_CODE          indxii, indxjj  ! i,j indices for kcells loop
-!OLI_CODE 
-!OLI_CODE       REAL (wp), parameter :: &
-!OLI_CODE          zhicemin  = 0.1_wp , & ! minimum ice thickness with ponds (m) 
-!OLI_CODE          zTd       = 0.15_wp, & ! temperature difference for freeze-up (C)
-!OLI_CODE          zr1_rlfus = 1._wp / 0.334e+6 / 917._wp , & ! (J/m^3)
-!OLI_CODE          zmin_volp = 1.e-4_wp, & ! minimum pond volume (m)
-!OLI_CODE          z0       = 0._wp,    & 
-!OLI_CODE          zTimelt   = 0._wp,    &
-!OLI_CODE          z01      = 0.01_wp,  &
-!OLI_CODE          z25      = 0.25_wp,  &
-!OLI_CODE          z5       = 0.5_wp,   &
-!OLI_CODE          epsi10     = 1.0e-11_wp
-!OLI_CODE       !---------------------------------------------------------------
-!OLI_CODE       ! initialize
-!OLI_CODE       !---------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       DO j = 1, jpj
-!OLI_CODE          DO i = 1, jpi
-!OLI_CODE             zvolp(i,j) = z0
-!OLI_CODE          END DO
-!OLI_CODE       END DO
-!OLI_CODE       DO n = 1, jpl
-!OLI_CODE          DO j = 1, jpj
-!OLI_CODE             DO i = 1, jpi
-!OLI_CODE                ! load tracers
-!OLI_CODE                zvolp(i,j) = zvolp(i,j) + h_ip(i,j,n) &
-!OLI_CODE                                      * a_ip_frac(i,j,n) * aicen(i,j,n)
-!OLI_CODE                zTsfcn(i,j,n) = Tsfc(i,j,n) - rtt ! convert in Celsius - Oli
-!OLI_CODE                zvuin (i,j,n) = h_il(i,j,n) &
-!OLI_CODE                             * a_ip_frac(i,j,n) * aicen(i,j,n)
-!OLI_CODE 
-!OLI_CODE                zhpondn(i,j,n) = z0     ! pond depth, per category
-!OLI_CODE                zapondn(i,j,n) = z0     ! pond area,  per category
-!OLI_CODE             END DO
-!OLI_CODE          END DO
-!OLI_CODE          indxii(:,n) = 0
-!OLI_CODE          indxjj(:,n) = 0
-!OLI_CODE          kcells  (n) = 0
-!OLI_CODE       END DO
-!OLI_CODE 
-!OLI_CODE       ! The freezing temperature for meltponds is assumed slightly below 0C,
-!OLI_CODE       ! as if meltponds had a little salt in them.  The salt budget is not
-!OLI_CODE       ! altered for meltponds, but if it were then an actual pond freezing 
-!OLI_CODE       ! temperature could be computed.
-!OLI_CODE 
-!OLI_CODE       zTp = zTimelt - zTd
-!OLI_CODE 
-!OLI_CODE       !-----------------------------------------------------------------
-!OLI_CODE       ! Identify grid cells with ponds
-!OLI_CODE       !-----------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       icells = 0
-!OLI_CODE       DO j = 1, jpj
-!OLI_CODE       DO i = 1, jpi
-!OLI_CODE          zhi = z0
-!OLI_CODE          IF (aice(i,j) > epsi10) zhi = vice(i,j)/aice(i,j)
-!OLI_CODE          IF ( aice(i,j) > z01 .and. zhi > zhicemin .and. &
-!OLI_CODE             zvolp(i,j) > zmin_volp*aice(i,j)) THEN
-!OLI_CODE             icells = icells + 1
-!OLI_CODE             indxi(icells) = i
-!OLI_CODE             indxj(icells) = j
-!OLI_CODE          ELSE  ! remove ponds on thin ice
-!OLI_CODE             !fpond(i,j) = fpond(i,j) - zvolp(i,j)
-!OLI_CODE             zvolpn(i,j,:) = z0
-!OLI_CODE             zvuin (i,j,:) = z0
-!OLI_CODE             zvolp (i,j) = z0
-!OLI_CODE          END IF
-!OLI_CODE       END DO                     ! i
-!OLI_CODE       END DO                     ! j
-!OLI_CODE 
-!OLI_CODE       DO ij = 1, icells
-!OLI_CODE          i = indxi(ij)
-!OLI_CODE          j = indxj(ij)
-!OLI_CODE 
-!OLI_CODE          !--------------------------------------------------------------
-!OLI_CODE          ! calculate pond area and depth
-!OLI_CODE          !--------------------------------------------------------------
-!OLI_CODE          CALL pond_area(aice(i,j),vice(i,j),rhos(i,j,:), &
-!OLI_CODE                    aicen(i,j,:), vicen(i,j,:), vsnon(i,j,:), &
-!OLI_CODE                    ticen(i,j,:,:), salin(i,j,:,:), &
-!OLI_CODE                    zvolpn(i,j,:), zvolp(i,j), &
-!OLI_CODE                    zapondn(i,j,:),zhpondn(i,j,:), zdvn)
-!OLI_CODE 
-!OLI_CODE          fwoc(i,j) = fwoc(i,j) + zdvn ! -> Goes to fresh water budget
-!OLI_CODE 
-!OLI_CODE          ! mean surface temperature
-!OLI_CODE          zTavg = z0
-!OLI_CODE          DO n = 1, jpl
-!OLI_CODE             zTavg = zTavg + zTsfcn(i,j,n)*aicen(i,j,n)
-!OLI_CODE          END DO
-!OLI_CODE          zTavg = zTavg / aice(i,j)
-!OLI_CODE 
-!OLI_CODE          DO n = 1, jpl-1
-!OLI_CODE                        
-!OLI_CODE             IF (zvuin(i,j,n) > epsi10) THEN
-!OLI_CODE 
-!OLI_CODE          !----------------------------------------------------------------
-!OLI_CODE          ! melting: floating upper ice layer melts in whole or part
-!OLI_CODE          !----------------------------------------------------------------
-!OLI_CODE !               IF (zTsfcn(i,j,n) > zTp) THEN
-!OLI_CODE                IF (zTavg > zTp) THEN
-!OLI_CODE 
-!OLI_CODE                   zdvice = min(meltt(i,j)*zapondn(i,j,n), zvuin(i,j,n))
-!OLI_CODE                   IF (zdvice > epsi10) THEN
-!OLI_CODE                      zvuin (i,j,n) = zvuin (i,j,n) - zdvice
-!OLI_CODE                      zvolpn(i,j,n) = zvolpn(i,j,n) + zdvice
-!OLI_CODE                      zvolp (i,j)   = zvolp (i,j)   + zdvice
-!OLI_CODE                      !fwoc(i,j)   = fwoc(i,j)   + zdvice
-!OLI_CODE                        
-!OLI_CODE                      IF (zvuin(i,j,n) < epsi10 .and. zvolpn(i,j,n) > puny) THEN
-!OLI_CODE                         ! ice lid melted and category is pond covered
-!OLI_CODE                         zvolpn(i,j,n) = zvolpn(i,j,n) + zvuin(i,j,n)
-!OLI_CODE                         !fwoc(i,j)   = fwoc(i,j)   + zvuin(i,j,n)
-!OLI_CODE                         zvuin(i,j,n)  = z0
-!OLI_CODE                      END IF
-!OLI_CODE                      zhpondn(i,j,n) = zvolpn(i,j,n) / zapondn(i,j,n)
-!OLI_CODE                   END IF
-!OLI_CODE 
-!OLI_CODE          !----------------------------------------------------------------
-!OLI_CODE          ! freezing: existing upper ice layer grows
-!OLI_CODE          !----------------------------------------------------------------
-!OLI_CODE                ELSE IF (zvolpn(i,j,n) > epsi10) THEN ! zTavg <= zTp
-!OLI_CODE 
-!OLI_CODE                 ! dIFferential growth of base of surface floating ice layer
-!OLI_CODE                   zdTice = max(-zTavg, z0) ! > 0
-!OLI_CODE                   zomega = rcdic*zdTice * zr1_rlfus 
-!OLI_CODE                   zdHui = sqrt(zomega*rdt_ice + z25*(zvuin(i,j,n)/  &
-!OLI_CODE                         aicen(i,j,n))**2)- z5 * zvuin(i,j,n)/aicen(i,j,n)
-!OLI_CODE 
-!OLI_CODE                   zdvice = min(zdHui*zapondn(i,j,n), zvolpn(i,j,n))   
-!OLI_CODE                   IF (zdvice > epsi10) THEN
-!OLI_CODE                      zvuin (i,j,n) = zvuin (i,j,n) + zdvice
-!OLI_CODE                      zvolpn(i,j,n) = zvolpn(i,j,n) - zdvice
-!OLI_CODE                      zvolp (i,j)   = zvolp (i,j)   - zdvice
-!OLI_CODE                      !fwoc(i,j)   = fwoc(i,j)   - zdvice
-!OLI_CODE                      zhpondn(i,j,n) = zvolpn(i,j,n) / zapondn(i,j,n)
-!OLI_CODE                   END IF
-!OLI_CODE 
-!OLI_CODE                END IF ! zTavg
-!OLI_CODE 
-!OLI_CODE          !----------------------------------------------------------------
-!OLI_CODE          ! freezing: upper ice layer begins to form
-!OLI_CODE          ! note: albedo does not change
-!OLI_CODE          !----------------------------------------------------------------
-!OLI_CODE             ELSE ! zvuin < epsi10
-!OLI_CODE                     
-!OLI_CODE                ! thickness of newly formed ice
-!OLI_CODE                ! the surface temperature of a meltpond is the same as that
-!OLI_CODE                ! of the ice underneath (0C), and the thermodynamic surface 
-!OLI_CODE                ! flux is the same
-!OLI_CODE                zdHui = max(-fsurf(i,j)*rdt_ice*zr1_rlfus, z0)
-!OLI_CODE                zdvice = min(zdHui*zapondn(i,j,n), zvolpn(i,j,n))  
-!OLI_CODE                IF (zdvice > epsi10) THEN
-!OLI_CODE                   zvuin (i,j,n) = zdvice
-!OLI_CODE                   zvolpn(i,j,n) = zvolpn(i,j,n) - zdvice
-!OLI_CODE                   zvolp (i,j)   = zvolp (i,j)   - zdvice
-!OLI_CODE                   !fwoc(i,j)   = fwoc(i,j)   - zdvice
-!OLI_CODE                   zhpondn(i,j,n)= zvolpn(i,j,n) / zapondn(i,j,n)
-!OLI_CODE                END IF
-!OLI_CODE                     
-!OLI_CODE             END IF  ! zvuin
-!OLI_CODE 
-!OLI_CODE          END DO ! jpl
-!OLI_CODE 
-!OLI_CODE       END DO ! ij
-!OLI_CODE 
-!OLI_CODE       !---------------------------------------------------------------
-!OLI_CODE       ! remove ice lid if there is no liquid pond
-!OLI_CODE       ! zvuin may be nonzero on category jpl due to dynamics
-!OLI_CODE       !---------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       DO j = 1, jpj
-!OLI_CODE       DO i = 1, jpi
-!OLI_CODE          DO n = 1, jpl
-!OLI_CODE             IF (aicen(i,j,n) > epsi10 .and. zvolpn(i,j,n) < puny &
-!OLI_CODE                                     .and. zvuin (i,j,n) > epsi10) THEN
-!OLI_CODE                kcells(n) = kcells(n) + 1
-!OLI_CODE                indxij    = kcells(n)
-!OLI_CODE                indxii(indxij,n) = i
-!OLI_CODE                indxjj(indxij,n) = j
-!OLI_CODE             END IF
-!OLI_CODE          END DO
-!OLI_CODE       END DO                     ! i
-!OLI_CODE       END DO                     ! j
-!OLI_CODE 
-!OLI_CODE       DO n = 1, jpl
-!OLI_CODE 
-!OLI_CODE          IF (kcells(n) > 0) THEN
-!OLI_CODE          DO ij = 1, kcells(n)
-!OLI_CODE             i = indxii(ij,n)
-!OLI_CODE             j = indxjj(ij,n)
-!OLI_CODE             fwoc(i,j) = fwoc(i,j) + rhoic/rauw * zvuin(i,j,n) ! Completely refrozen lid goes into ocean (to be changed)
-!OLI_CODE             zvuin(i,j,n) = z0 
-!OLI_CODE          END DO    ! ij
-!OLI_CODE          END IF
-!OLI_CODE 
-!OLI_CODE          ! reload tracers
-!OLI_CODE          DO j = 1, jpj
-!OLI_CODE             DO i = 1, jpi
-!OLI_CODE                IF (zapondn(i,j,n) > epsi10) THEN
-!OLI_CODE                   h_il(i,j,n) = zvuin(i,j,n) / zapondn(i,j,n)
-!OLI_CODE                ELSE
-!OLI_CODE                   zvuin(i,j,n) = z0
-!OLI_CODE                   h_il(i,j,n) = z0
-!OLI_CODE                END IF
-!OLI_CODE                IF (aicen(i,j,n) > epsi10) THEN
-!OLI_CODE                   a_ip_frac(i,j,n) = zapondn(i,j,n) / aicen(i,j,n) * &
-!OLI_CODE                         (1.0_wp - MAX(z0, SIGN(1.0_wp, -zvolpn(i,j,n))))
-!OLI_CODE                   h_ip(i,j,n) = zhpondn(i,j,n)
-!OLI_CODE                ELSE
-!OLI_CODE                   a_ip_frac(i,j,n) = z0
-!OLI_CODE                   h_ip(i,j,n) = z0
-!OLI_CODE                   h_il(i,j,n) = z0
-!OLI_CODE                END IF
-!OLI_CODE             END DO ! i
-!OLI_CODE          END DO    ! j
-!OLI_CODE 
-!OLI_CODE       END DO       ! n
-!OLI_CODE 
-!OLI_CODE    END SUBROUTINE compute_mp_topo
-!OLI_CODE 
-!OLI_CODE 
-!OLI_CODE    SUBROUTINE pond_area(aice,vice,rhos,             &
-!OLI_CODE                         aicen, vicen, vsnon, ticen, &
-!OLI_CODE                         salin, zvolpn, zvolp,         &
-!OLI_CODE                         zapondn,zhpondn,dvolp)
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE       !!                ***  ROUTINE pond_area  ***
-!OLI_CODE       !!
-!OLI_CODE       !! ** Purpose :   Compute melt pond area, depth and melting rates
-!OLI_CODE       !!------------------------------------------------------------------
-!OLI_CODE       REAL (wp), INTENT(IN) :: &
-!OLI_CODE          aice,vice
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(IN) :: &
-!OLI_CODE          aicen, vicen, vsnon, rhos
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION(nlay_i,jpl), INTENT(IN) :: &
-!OLI_CODE          ticen, salin
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(INOUT) :: &
-!OLI_CODE          zvolpn
-!OLI_CODE 
-!OLI_CODE       REAL (wp), INTENT(INOUT) :: &
-!OLI_CODE          zvolp, dvolp
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(OUT) :: &
-!OLI_CODE          zapondn, zhpondn
-!OLI_CODE 
-!OLI_CODE       INTEGER :: &
-!OLI_CODE          n, ns,   &
-!OLI_CODE          m_index, &
-!OLI_CODE          permflag
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION(jpl) :: &
-!OLI_CODE          hicen, &
-!OLI_CODE          hsnon, &
-!OLI_CODE          asnon, &
-!OLI_CODE          alfan, &
-!OLI_CODE          betan, &
-!OLI_CODE          cum_max_vol, &
-!OLI_CODE          reduced_aicen        
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION(0:jpl) :: &
-!OLI_CODE          cum_max_vol_tmp
-!OLI_CODE 
-!OLI_CODE       REAL (wp) :: &
-!OLI_CODE          hpond, &
-!OLI_CODE          drain, &
-!OLI_CODE          floe_weight, &
-!OLI_CODE          pressure_head, &
-!OLI_CODE          hsl_rel, &
-!OLI_CODE          deltah, &
-!OLI_CODE          perm, &
-!OLI_CODE          apond, &
-!OLI_CODE          msno
-!OLI_CODE 
-!OLI_CODE       REAL (wp), parameter :: & 
-!OLI_CODE          viscosity = 1.79e-3_wp, &  ! kinematic water viscosity in kg/m/s
-!OLI_CODE          z0        = 0.0_wp    , &
-!OLI_CODE          c1        = 1.0_wp    , &
-!OLI_CODE          p4        = 0.4_wp    , &
-!OLI_CODE          p6        = 0.6_wp    , &
-!OLI_CODE          epsi10      = 1.0e-11_wp
-!OLI_CODE          
-!OLI_CODE      !-----------|
-!OLI_CODE      !           |
-!OLI_CODE      !           |-----------|
-!OLI_CODE      !___________|___________|______________________________________sea-level
-!OLI_CODE      !           |           |
-!OLI_CODE      !           |           |---^--------|
-!OLI_CODE      !           |           |   |        |
-!OLI_CODE      !           |           |   |        |-----------|              |-------
-!OLI_CODE      !           |           |   |alfan(n)|           |              |
-!OLI_CODE      !           |           |   |        |           |--------------|
-!OLI_CODE      !           |           |   |        |           |              |
-!OLI_CODE      !---------------------------v-------------------------------------------
-!OLI_CODE      !           |           |   ^        |           |              |
-!OLI_CODE      !           |           |   |        |           |--------------|
-!OLI_CODE      !           |           |   |betan(n)|           |              |
-!OLI_CODE      !           |           |   |        |-----------|              |-------
-!OLI_CODE      !           |           |   |        |
-!OLI_CODE      !           |           |---v------- |
-!OLI_CODE      !           |           |
-!OLI_CODE      !           |-----------|
-!OLI_CODE      !           |
-!OLI_CODE      !-----------|
-!OLI_CODE     
-!OLI_CODE       !-------------------------------------------------------------------
-!OLI_CODE       ! initialize
-!OLI_CODE       !-------------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       DO n = 1, jpl
-!OLI_CODE 
-!OLI_CODE          zapondn(n) = z0
-!OLI_CODE          zhpondn(n) = z0
-!OLI_CODE 
-!OLI_CODE          IF (aicen(n) < epsi10)  THEN
-!OLI_CODE             hicen(n) =  z0 
-!OLI_CODE             hsnon(n) = z0
-!OLI_CODE             reduced_aicen(n) = z0
-!OLI_CODE          ELSE
-!OLI_CODE             hicen(n) = vicen(n) / aicen(n)
-!OLI_CODE             hsnon(n) = vsnon(n) / aicen(n)
-!OLI_CODE             reduced_aicen(n) = c1 ! n=jpl
-!OLI_CODE             IF (n < jpl) reduced_aicen(n) = aicen(n) &
-!OLI_CODE                                  * (-0.024_wp*hicen(n) + 0.832_wp) 
-!OLI_CODE             asnon(n) = reduced_aicen(n) 
-!OLI_CODE          END IF
-!OLI_CODE 
-!OLI_CODE ! This choice for alfa and beta ignores hydrostatic equilibium of categories.
-!OLI_CODE ! Hydrostatic equilibium of the entire ITD is accounted for below, assuming
-!OLI_CODE ! a surface topography implied by alfa=0.6 and beta=0.4, and rigidity across all
-!OLI_CODE ! categories.  alfa and beta partition the ITD - they are areas not thicknesses!
-!OLI_CODE ! Multiplying by hicen, alfan and betan (below) are thus volumes per unit area.
-!OLI_CODE ! Here, alfa = 60% of the ice area (and since hice is constant in a category, 
-!OLI_CODE ! alfan = 60% of the ice volume) in each category lies above the reference line, 
-!OLI_CODE ! and 40% below. Note: p6 is an arbitrary choice, but alfa+beta=1 is required.
-!OLI_CODE 
-!OLI_CODE          alfan(n) = p6 * hicen(n)
-!OLI_CODE          betan(n) = p4 * hicen(n)
-!OLI_CODE        
-!OLI_CODE          cum_max_vol(n)     = z0
-!OLI_CODE          cum_max_vol_tmp(n) = z0
-!OLI_CODE     
-!OLI_CODE       END DO ! jpl
-!OLI_CODE 
-!OLI_CODE       cum_max_vol_tmp(0) = z0
-!OLI_CODE       drain = z0
-!OLI_CODE       dvolp = z0
-!OLI_CODE     
-!OLI_CODE       !--------------------------------------------------------------------------
-!OLI_CODE       ! the maximum amount of water that can be contained up to each ice category
-!OLI_CODE       !--------------------------------------------------------------------------
-!OLI_CODE     
-!OLI_CODE       DO n = 1, jpl-1 ! last category can not hold any volume
-!OLI_CODE 
-!OLI_CODE          IF (alfan(n+1) >= alfan(n) .and. alfan(n+1) > z0) THEN
-!OLI_CODE 
-!OLI_CODE             ! total volume in level including snow
-!OLI_CODE             cum_max_vol_tmp(n) = cum_max_vol_tmp(n-1) + &
-!OLI_CODE                (alfan(n+1) - alfan(n)) * sum(reduced_aicen(1:n)) 
-!OLI_CODE 
-!OLI_CODE 
-!OLI_CODE             ! subtract snow solid volumes from lower categories in current level
-!OLI_CODE             DO ns = 1, n 
-!OLI_CODE                cum_max_vol_tmp(n) = cum_max_vol_tmp(n) &
-!OLI_CODE                   - rhos(ns)/rauw  * &    ! fraction of snow that is occupied by solid ??rauw
-!OLI_CODE                     asnon(ns)  * &    ! area of snow from that category
-!OLI_CODE                     max(min(hsnon(ns)+alfan(ns)-alfan(n), alfan(n+1)- &
-!OLI_CODE                                   alfan(n)), z0)  
-!OLI_CODE                                       ! thickness of snow from ns layer in n layer
-!OLI_CODE             END DO
-!OLI_CODE 
-!OLI_CODE          ELSE ! assume higher categories unoccupied
-!OLI_CODE             cum_max_vol_tmp(n) = cum_max_vol_tmp(n-1)
-!OLI_CODE          END IF
-!OLI_CODE          !IF (cum_max_vol_tmp(n) < z0) THEN
-!OLI_CODE          !   call abort_ice('negative melt pond volume')
-!OLI_CODE          !END IF
-!OLI_CODE       END DO
-!OLI_CODE       cum_max_vol_tmp(jpl) = cum_max_vol_tmp(jpl-1)  ! last category holds no volume
-!OLI_CODE       cum_max_vol  (1:jpl) = cum_max_vol_tmp(1:jpl)
-!OLI_CODE     
-!OLI_CODE       !----------------------------------------------------------------
-!OLI_CODE       ! is there more meltwater than can be held in the floe?
-!OLI_CODE       !----------------------------------------------------------------
-!OLI_CODE       IF (zvolp >= cum_max_vol(jpl)) THEN
-!OLI_CODE          drain = zvolp - cum_max_vol(jpl) + epsi10
-!OLI_CODE          zvolp = zvolp - drain
-!OLI_CODE          dvolp = drain
-!OLI_CODE          IF (zvolp < epsi10) THEN
-!OLI_CODE             dvolp = dvolp + zvolp
-!OLI_CODE             zvolp = z0
-!OLI_CODE          END IF
-!OLI_CODE       END IF
-!OLI_CODE     
-!OLI_CODE       ! height and area corresponding to the remaining volume
-!OLI_CODE 
-!OLI_CODE       call calc_hpond(reduced_aicen, asnon, hsnon, rhos, alfan, &
-!OLI_CODE            zvolp, cum_max_vol, hpond, m_index)
-!OLI_CODE     
-!OLI_CODE       DO n=1, m_index
-!OLI_CODE          zhpondn(n) = hpond - alfan(n) + alfan(1)
-!OLI_CODE          zapondn(n) = reduced_aicen(n) 
-!OLI_CODE       END DO
-!OLI_CODE       apond = sum(zapondn(1:m_index))
-!OLI_CODE     
-!OLI_CODE       !------------------------------------------------------------------------
-!OLI_CODE       ! drainage due to ice permeability - Darcy's law
-!OLI_CODE       !------------------------------------------------------------------------
-!OLI_CODE     
-!OLI_CODE       ! sea water level 
-!OLI_CODE       msno = z0
-!OLI_CODE       DO n=1,jpl
-!OLI_CODE         msno = msno + vsnon(n) * rhos(n)
-!OLI_CODE       END DO
-!OLI_CODE       floe_weight = (msno + rhoic*vice + rau0*zvolp) / aice
-!OLI_CODE       hsl_rel = floe_weight / rau0 &
-!OLI_CODE               - ((sum(betan(:)*aicen(:))/aice) + alfan(1))
-!OLI_CODE     
-!OLI_CODE       deltah = hpond - hsl_rel
-!OLI_CODE       pressure_head = grav * rau0 * max(deltah, z0)
-!OLI_CODE 
-!OLI_CODE       ! drain IF ice is permeable    
-!OLI_CODE       permflag = 0
-!OLI_CODE       IF (pressure_head > z0) THEN
-!OLI_CODE       DO n = 1, jpl-1
-!OLI_CODE          IF (hicen(n) /= z0) THEN
-!OLI_CODE             CALL permeability_phi(ticen(:,n), salin(:,n), vicen(n), perm)
-!OLI_CODE             IF (perm > z0) permflag = 1
-!OLI_CODE             drain = perm*zapondn(n)*pressure_head*rdt_ice / &
-!OLI_CODE                                      (viscosity*hicen(n))
-!OLI_CODE             dvolp = dvolp + min(drain, zvolp)
-!OLI_CODE             zvolp = max(zvolp - drain, z0)
-!OLI_CODE             IF (zvolp < epsi10) THEN
-!OLI_CODE                dvolp = dvolp + zvolp
-!OLI_CODE                zvolp = z0
-!OLI_CODE             END IF
-!OLI_CODE          END IF
-!OLI_CODE       END DO
-!OLI_CODE  
-!OLI_CODE       ! adjust melt pond DIMENSIONs
-!OLI_CODE       IF (permflag > 0) THEN
-!OLI_CODE          ! recompute pond depth    
-!OLI_CODE          CALL calc_hpond(reduced_aicen, asnon, hsnon, rhos, alfan, &
-!OLI_CODE                          zvolp, cum_max_vol, hpond, m_index)
-!OLI_CODE          DO n=1, m_index
-!OLI_CODE             zhpondn(n) = hpond - alfan(n) + alfan(1)
-!OLI_CODE             zapondn(n) = reduced_aicen(n) 
-!OLI_CODE          END DO
-!OLI_CODE          apond = sum(zapondn(1:m_index))
-!OLI_CODE       END IF
-!OLI_CODE       END IF ! pressure_head
-!OLI_CODE 
-!OLI_CODE       !------------------------------------------------------------------------
-!OLI_CODE       ! total melt pond volume in category DOes not include snow volume
-!OLI_CODE       ! snow in melt ponds is not melted
-!OLI_CODE       !------------------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       ! Calculate pond volume for lower categories
-!OLI_CODE       DO n=1,m_index-1
-!OLI_CODE          zvolpn(n) = zapondn(n) * zhpondn(n) &
-!OLI_CODE                   - (rhos(n)/rauw) * asnon(n) * min(hsnon(n), zhpondn(n))! 
-!OLI_CODE       END DO
-!OLI_CODE 
-!OLI_CODE       ! Calculate pond volume for highest category = remaining pond volume
-!OLI_CODE       IF (m_index == 1) zvolpn(m_index) = zvolp
-!OLI_CODE       IF (m_index > 1) THEN
-!OLI_CODE         IF (zvolp > sum(zvolpn(1:m_index-1))) THEN
-!OLI_CODE           zvolpn(m_index) = zvolp - sum(zvolpn(1:m_index-1))
-!OLI_CODE         ELSE
-!OLI_CODE           zvolpn(m_index) = z0
-!OLI_CODE           zhpondn(m_index) = z0
-!OLI_CODE           zapondn(m_index) = z0
-!OLI_CODE           ! If remaining pond volume is negative reduce pond volume of 
-!OLI_CODE           ! lower category
-!OLI_CODE           IF (zvolp+epsi10 < sum(zvolpn(1:m_index-1))) & 
-!OLI_CODE             zvolpn(m_index-1) = zvolpn(m_index-1)-sum(zvolpn(1:m_index-1))&
-!OLI_CODE                                + zvolp
-!OLI_CODE         END IF
-!OLI_CODE       END IF
-!OLI_CODE 
-!OLI_CODE       DO n=1,m_index
-!OLI_CODE          IF (zapondn(n) > epsi10) THEN
-!OLI_CODE              zhpondn(n) = zvolpn(n) / zapondn(n)
-!OLI_CODE          ELSE
-!OLI_CODE             dvolp = dvolp + zvolpn(n)
-!OLI_CODE             zhpondn(n) = z0
-!OLI_CODE             zvolpn(n) = z0
-!OLI_CODE             zapondn(n) = z0
-!OLI_CODE          end IF
-!OLI_CODE       END DO
-!OLI_CODE       DO n = m_index+1, jpl
-!OLI_CODE          zhpondn(n) = z0
-!OLI_CODE          zapondn(n) = z0
-!OLI_CODE          zvolpn (n) = z0
-!OLI_CODE       END DO
-!OLI_CODE 
-!OLI_CODE    END SUBROUTINE pond_area
-!OLI_CODE   
-!OLI_CODE 
-!OLI_CODE    SUBROUTINE calc_hpond(aicen, asnon, hsnon, rhos, alfan, &
-!OLI_CODE                          zvolp, cum_max_vol,                &
-!OLI_CODE                          hpond, m_index)
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE       !!                ***  ROUTINE calc_hpond  ***
-!OLI_CODE       !!
-!OLI_CODE       !! ** Purpose :   Compute melt pond depth
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE     
-!OLI_CODE       REAL (wp), DIMENSION(jpl), INTENT(IN) :: &
-!OLI_CODE          aicen, &
-!OLI_CODE          asnon, &
-!OLI_CODE          hsnon, &
-!OLI_CODE          rhos,  &
-!OLI_CODE          alfan, &
-!OLI_CODE          cum_max_vol
-!OLI_CODE     
-!OLI_CODE       REAL (wp), INTENT(IN) :: &
-!OLI_CODE          zvolp
-!OLI_CODE     
-!OLI_CODE       REAL (wp), INTENT(OUT) :: &
-!OLI_CODE          hpond
-!OLI_CODE     
-!OLI_CODE       INTEGER, INTENT(OUT) :: &
-!OLI_CODE          m_index
-!OLI_CODE     
-!OLI_CODE       INTEGER :: n, ns
-!OLI_CODE     
-!OLI_CODE       REAL (wp), DIMENSION(0:jpl+1) :: &
-!OLI_CODE          hitl, &
-!OLI_CODE          aicetl
-!OLI_CODE     
-!OLI_CODE       REAL (wp) :: &
-!OLI_CODE          rem_vol, &
-!OLI_CODE          area, &
-!OLI_CODE          vol, &
-!OLI_CODE          tmp, &
-!OLI_CODE          z0   = 0.0_wp,    &   
-!OLI_CODE          epsi10 = 1.0e-11_wp
-!OLI_CODE     
-!OLI_CODE       !----------------------------------------------------------------
-!OLI_CODE       ! hpond is zero if zvolp is zero - have we fully drained? 
-!OLI_CODE       !----------------------------------------------------------------
-!OLI_CODE     
-!OLI_CODE       IF (zvolp < epsi10) THEN
-!OLI_CODE        hpond = z0
-!OLI_CODE        m_index = 0
-!OLI_CODE       ELSE
-!OLI_CODE        
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        ! Calculate the category where water fills up to 
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        !----------|
-!OLI_CODE        !          |
-!OLI_CODE        !          |
-!OLI_CODE        !          |----------|                                     -- --
-!OLI_CODE        !__________|__________|_________________________________________ ^
-!OLI_CODE        !          |          |             rem_vol     ^                | Semi-filled
-!OLI_CODE        !          |          |----------|-- -- -- - ---|-- ---- -- -- --v layer
-!OLI_CODE        !          |          |          |              |
-!OLI_CODE        !          |          |          |              |hpond
-!OLI_CODE        !          |          |          |----------|   |     |-------
-!OLI_CODE        !          |          |          |          |   |     |
-!OLI_CODE        !          |          |          |          |---v-----|
-!OLI_CODE        !          |          | m_index  |          |         |
-!OLI_CODE        !-------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        m_index = 0  ! 1:m_index categories have water in them
-!OLI_CODE        DO n = 1, jpl
-!OLI_CODE           IF (zvolp <= cum_max_vol(n)) THEN
-!OLI_CODE              m_index = n
-!OLI_CODE              IF (n == 1) THEN
-!OLI_CODE                 rem_vol = zvolp
-!OLI_CODE              ELSE
-!OLI_CODE                 rem_vol = zvolp - cum_max_vol(n-1)
-!OLI_CODE              END IF
-!OLI_CODE              exit ! to break out of the loop
-!OLI_CODE           END IF
-!OLI_CODE        END DO
-!OLI_CODE        m_index = min(jpl-1, m_index)
-!OLI_CODE        
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        ! semi-filled layer may have m_index different snow in it
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        !-----------------------------------------------------------  ^
-!OLI_CODE        !                                                             |  alfan(m_index+1)
-!OLI_CODE        !                                                             |
-!OLI_CODE        !hitl(3)-->                             |----------|          |
-!OLI_CODE        !hitl(2)-->                |------------| * * * * *|          |
-!OLI_CODE        !hitl(1)-->     |----------|* * * * * * |* * * * * |          |
-!OLI_CODE        !hitl(0)-->-------------------------------------------------  |  ^
-!OLI_CODE        !                various snow from lower categories          |  |alfa(m_index)
-!OLI_CODE        
-!OLI_CODE        ! hitl - heights of the snow layers from thinner and current categories
-!OLI_CODE        ! aicetl - area of each snow depth in this layer
-!OLI_CODE        
-!OLI_CODE        hitl(:) = z0
-!OLI_CODE        aicetl(:) = z0
-!OLI_CODE        DO n = 1, m_index
-!OLI_CODE           hitl(n)   = max(min(hsnon(n) + alfan(n) - alfan(m_index), &
-!OLI_CODE                                  alfan(m_index+1) - alfan(m_index)), z0)
-!OLI_CODE           aicetl(n) = asnon(n)
-!OLI_CODE           
-!OLI_CODE           aicetl(0) = aicetl(0) + (aicen(n) - asnon(n))
-!OLI_CODE        END DO
-!OLI_CODE        hitl(m_index+1) = alfan(m_index+1) - alfan(m_index)
-!OLI_CODE        aicetl(m_index+1) = z0
-!OLI_CODE        
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        ! reorder array according to hitl 
-!OLI_CODE        ! snow heights not necessarily in height order
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        DO ns = 1, m_index+1
-!OLI_CODE           DO n = 0, m_index - ns + 1
-!OLI_CODE              IF (hitl(n) > hitl(n+1)) THEN ! swap order
-!OLI_CODE                 tmp = hitl(n)
-!OLI_CODE                 hitl(n) = hitl(n+1)
-!OLI_CODE                 hitl(n+1) = tmp
-!OLI_CODE                 tmp = aicetl(n)
-!OLI_CODE                 aicetl(n) = aicetl(n+1)
-!OLI_CODE                 aicetl(n+1) = tmp
-!OLI_CODE              END IF
-!OLI_CODE           END DO
-!OLI_CODE        END DO
-!OLI_CODE        
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        ! divide semi-filled layer into set of sublayers each vertically homogenous
-!OLI_CODE        !----------------------------------------------------------------
-!OLI_CODE        
-!OLI_CODE        !hitl(3)----------------------------------------------------------------
-!OLI_CODE        !                                                       | * * * * * * * *  
-!OLI_CODE        !                                                       |* * * * * * * * * 
-!OLI_CODE        !hitl(2)----------------------------------------------------------------
-!OLI_CODE        !                                    | * * * * * * * *  | * * * * * * * *  
-!OLI_CODE        !                                    |* * * * * * * * * |* * * * * * * * * 
-!OLI_CODE        !hitl(1)----------------------------------------------------------------
-!OLI_CODE        !                 | * * * * * * * *  | * * * * * * * *  | * * * * * * * *  
-!OLI_CODE        !                 |* * * * * * * * * |* * * * * * * * * |* * * * * * * * * 
-!OLI_CODE        !hitl(0)----------------------------------------------------------------
-!OLI_CODE        !    aicetl(0)         aicetl(1)           aicetl(2)          aicetl(3)            
-!OLI_CODE        
-!OLI_CODE        ! move up over layers incrementing volume
-!OLI_CODE        DO n = 1, m_index+1
-!OLI_CODE           
-!OLI_CODE           area = sum(aicetl(:)) - &                 ! total area of sub-layer
-!OLI_CODE                (rhos(n)/rau0) * sum(aicetl(n:jpl+1)) ! area of sub-layer occupied by snow
-!OLI_CODE           
-!OLI_CODE           vol = (hitl(n) - hitl(n-1)) * area      ! thickness of sub-layer times area
-!OLI_CODE           
-!OLI_CODE           IF (vol >= rem_vol) THEN  ! have reached the sub-layer with the depth within
-!OLI_CODE              hpond = rem_vol / area + hitl(n-1) + alfan(m_index) - &
-!OLI_CODE                           alfan(1)
-!OLI_CODE              exit
-!OLI_CODE           ELSE  ! still in sub-layer below the sub-layer with the depth
-!OLI_CODE              rem_vol = rem_vol - vol
-!OLI_CODE           END IF
-!OLI_CODE           
-!OLI_CODE        END DO
-!OLI_CODE        
-!OLI_CODE       END IF
-!OLI_CODE     
-!OLI_CODE    END SUBROUTINE calc_hpond
-!OLI_CODE   
-!OLI_CODE 
-!OLI_CODE    SUBROUTINE permeability_phi(ticen, salin, vicen, perm)
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE       !!                ***  ROUTINE permeability_phi  ***
-!OLI_CODE       !!
-!OLI_CODE       !! ** Purpose :   Determine the liquid fraction of brine in the ice
-!OLI_CODE       !!                and its permeability
-!OLI_CODE       !!-------------------------------------------------------------------
-!OLI_CODE       REAL (wp), DIMENSION(nlay_i), INTENT(IN) :: &
-!OLI_CODE          ticen,  & ! energy of melting for each ice layer (J/m2)
-!OLI_CODE          salin
-!OLI_CODE 
-!OLI_CODE       REAL (wp), INTENT(IN) :: &
-!OLI_CODE          vicen     ! ice volume
-!OLI_CODE     
-!OLI_CODE       REAL (wp), INTENT(OUT) :: &
-!OLI_CODE          perm      ! permeability
-!OLI_CODE 
-!OLI_CODE       REAL (wp) ::   &
-!OLI_CODE          Sbr        ! brine salinity
-!OLI_CODE 
-!OLI_CODE       REAL (wp), DIMENSION(nlay_i) ::   &
-!OLI_CODE          Tin, &    ! ice temperature
-!OLI_CODE          phi       ! liquid fraction
-!OLI_CODE 
-!OLI_CODE       INTEGER :: k
-!OLI_CODE     
-!OLI_CODE       REAL (wp) :: &
-!OLI_CODE          c2    = 2.0_wp
-!OLI_CODE  
-!OLI_CODE       !-----------------------------------------------------------------
-!OLI_CODE       ! Compute ice temperatures from enthalpies using quadratic formula
-!OLI_CODE       !-----------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       DO k = 1,nlay_i
-!OLI_CODE          Tin(k) = ticen(k) 
-!OLI_CODE       END DO
-!OLI_CODE 
-!OLI_CODE       !-----------------------------------------------------------------
-!OLI_CODE       ! brine salinity and liquid fraction
-!OLI_CODE       !-----------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       IF (maxval(Tin-rtt) <= -c2) THEN
-!OLI_CODE 
-!OLI_CODE          DO k = 1,nlay_i
-!OLI_CODE             Sbr = - 1.2_wp                 &
-!OLI_CODE                   -21.8_wp     * (Tin(k)-rtt)    &
-!OLI_CODE                   - 0.919_wp   * (Tin(k)-rtt)**2 &
-!OLI_CODE                   - 0.01878_wp * (Tin(k)-rtt)**3
-!OLI_CODE             phi(k) = salin(k)/Sbr ! liquid fraction
-!OLI_CODE          END DO ! k
-!OLI_CODE        
-!OLI_CODE       ELSE
-!OLI_CODE 
-!OLI_CODE          DO k = 1,nlay_i
-!OLI_CODE             Sbr = -17.6_wp    * (Tin(k)-rtt)    &
-!OLI_CODE                   - 0.389_wp  * (Tin(k)-rtt)**2 &
-!OLI_CODE                   - 0.00362_wp* (Tin(k)-rtt)**3
-!OLI_CODE             phi(k) = salin(k)/Sbr ! liquid fraction
-!OLI_CODE          END DO
-!OLI_CODE 
-!OLI_CODE       END IF
-!OLI_CODE     
-!OLI_CODE       !-----------------------------------------------------------------
-!OLI_CODE       ! permeability
-!OLI_CODE       !-----------------------------------------------------------------
-!OLI_CODE 
-!OLI_CODE       perm = 3.0e-08_wp * (minval(phi))**3
-!OLI_CODE     
-!OLI_CODE    END SUBROUTINE permeability_phi
-!OLI_CODE   
-!OLI_CODE #else
-!OLI_CODE    !!----------------------------------------------------------------------
-!OLI_CODE    !!   Default option         Dummy Module          No LIM-3 sea-ice model
-!OLI_CODE    !!----------------------------------------------------------------------
-!OLI_CODE CONTAINS
-!OLI_CODE    SUBROUTINE lim_mp_init          ! Empty routine
-!OLI_CODE    END SUBROUTINE lim_mp_init   
-!OLI_CODE    SUBROUTINE lim_mp               ! Empty routine
-!OLI_CODE    END SUBROUTINE lim_mp
-!OLI_CODE    SUBROUTINE compute_mp_topo      ! Empty routine
-!OLI_CODE    END SUBROUTINE compute_mp_topo        
-!OLI_CODE    SUBROUTINE pond_area            ! Empty routine
-!OLI_CODE    END SUBROUTINE pond_area   
-!OLI_CODE    SUBROUTINE calc_hpond           ! Empty routine
-!OLI_CODE    END SUBROUTINE calc_hpond   
-!OLI_CODE    SUBROUTINE permeability_phy     ! Empty routine
-!OLI_CODE    END SUBROUTINE permeability_phy   
-!OLI_CODE #endif
-!OLI_CODE    !!======================================================================
-!OLI_CODE END MODULE limmp_topo
-!OLI_CODE 
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option          Empty module           NO LIM sea-ice model
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE lim_mp_init     ! Empty routine
-   END SUBROUTINE lim_mp_init
-   SUBROUTINE lim_mp          ! Empty routine
-   END SUBROUTINE lim_mp     
-   SUBROUTINE lim_mp_topo     ! Empty routine
-   END SUBROUTINE lim_mp_topo
-   SUBROUTINE lim_mp_cesm     ! Empty routine
-   END SUBROUTINE lim_mp_cesm
-   SUBROUTINE lim_mp_area     ! Empty routine
-   END SUBROUTINE lim_mp_area
-   SUBROUTINE lim_mp_perm     ! Empty routine
-   END SUBROUTINE lim_mp_perm
-#endif 
-
-   !!======================================================================
-END MODULE limmp 
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice.F90	(revision 8752)
@@ -19,7 +19,8 @@
    USE eosbn2          ! equation of state
    USE oce             ! ocean dynamics and tracers variables
-   USE ice             ! LIM_3 ice variables
-   USE icevar
-   USE icectl
+   USE ice             ! sea-ice: variables
+   USE icevar          ! sea-ice: operations
+   USE iceitd          ! sea-ice: rebining
+   USE icectl          ! sea-ice: control prints
    USE par_oce         ! ocean parameters
    USE dom_oce         ! ocean space and time domain variables 
@@ -71,6 +72,6 @@
       END DO
       !
-                        CALL ice_var_zapsmall
-                        CALL ice_var_agg(1)
+      CALL ice_var_zapsmall
+      CALL ice_var_agg(1)
       IF( ln_icectl )   CALL ice_prt( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )
       !
@@ -248,4 +249,8 @@
       END DO !jl
       !
+      ! --- In case categories are out of bounds, do a remapping --- !
+      !     i.e. inputs have not the same ice thickness distribution 
+      !          (set by rn_himean) than the regional simulation
+      IF( jpl > 1 )   CALL ice_itd_reb( kt )
       !      
       IF( nn_timing == 1 )   CALL timing_stop('bdy_ice_frs')
Index: anches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/albedooce.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/albedooce.F90	(revision 8751)
+++ 	(revision )
@@ -1,49 +1,0 @@
-MODULE albedooce
-   !!======================================================================
-   !!                       ***  MODULE  albedooce  ***
-   !! Ocean forcing:  bulk thermohaline forcing of the ocean
-   !!=====================================================================
-   !! History :
-   !!   NEMO     4.0  ! 2017-07  (C. Rousset) Split ocean and ice albedos
-   !!----------------------------------------------------------------------
-   !!   albedo_oce    : albedo for ocean (clear and overcast skies)
-   !!----------------------------------------------------------------------
-   USE phycst         ! physical constants
-   USE in_out_manager ! I/O manager
-   USE lib_mpp        ! MPP library
-   USE wrk_nemo       ! work arrays
-   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   albedo_oce   ! routine called by sbccpl
-  
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2010)
-   !! $Id: albedooce.F90 8268 2017-07-03 15:01:04Z clem $
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE albedo_oce( pa_oce_os , pa_oce_cs )
-      !!----------------------------------------------------------------------
-      !!               ***  ROUTINE albedo_oce  ***
-      !! 
-      !! ** Purpose :   Computation of the albedo of the ocean
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pa_oce_os   !  albedo of ocean under overcast sky
-      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pa_oce_cs   !  albedo of ocean under clear sky
-      !!
-      REAL(wp) ::   zcoef 
-      REAL(wp) ::   rmue = 0.40    !  cosine of local solar altitude
-      !!----------------------------------------------------------------------
-      !
-      zcoef = 0.05 / ( 1.1 * rmue**1.4 + 0.15 )   ! Parameterization of Briegled and Ramanathan, 1982
-      pa_oce_cs(:,:) = zcoef 
-      pa_oce_os(:,:) = 0.06                       ! Parameterization of Kondratyev, 1969 and Payne, 1972
-      !
-   END SUBROUTINE albedo_oce
-
-   !!======================================================================
-END MODULE albedooce
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/ocealb.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/ocealb.F90	(revision 8752)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/ocealb.F90	(revision 8752)
@@ -0,0 +1,49 @@
+MODULE ocealb
+   !!======================================================================
+   !!                       ***  MODULE  ocealb  ***
+   !! Ocean forcing:  bulk thermohaline forcing of the ocean
+   !!=====================================================================
+   !! History :
+   !!   NEMO     4.0  ! 2017-07  (C. Rousset) Split ocean and ice albedos
+   !!----------------------------------------------------------------------
+   !!   oce_alb    : albedo for ocean (clear and overcast skies)
+   !!----------------------------------------------------------------------
+   USE phycst         ! physical constants
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! work arrays
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   oce_alb   ! routine called by sbccpl
+  
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2010)
+   !! $Id: ocealb.F90 8268 2017-07-03 15:01:04Z clem $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE oce_alb( palb_os , palb_cs )
+      !!----------------------------------------------------------------------
+      !!               ***  ROUTINE oce_alb  ***
+      !! 
+      !! ** Purpose :   Computation of the albedo of the ocean
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   palb_os   !  albedo of ocean under overcast sky
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   palb_cs   !  albedo of ocean under clear sky
+      !!
+      REAL(wp) ::   zcoef 
+      REAL(wp) ::   rmue = 0.40    !  cosine of local solar altitude
+      !!----------------------------------------------------------------------
+      !
+      zcoef = 0.05 / ( 1.1 * rmue**1.4 + 0.15 )   ! Parameterization of Briegled and Ramanathan, 1982
+      palb_cs(:,:) = zcoef 
+      palb_os(:,:) = 0.06                         ! Parameterization of Kondratyev, 1969 and Payne, 1972
+      !
+   END SUBROUTINE oce_alb
+
+   !!======================================================================
+END MODULE ocealb
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_ice.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_ice.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_ice.F90	(revision 8752)
@@ -48,8 +48,10 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   alb_ice        !: ice albedo                                       [-]
 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qml_ice        !: heat available for snow / ice surface melting     [W/m2] 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qcn_ice        !: heat conduction flux in the layer below surface   [W/m2] 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   qsr_ice_tr     !: solar flux transmitted below the ice surface      [W/m2]
+
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   utau_ice       !: atmos-ice u-stress. VP: I-pt ; EVP: U,V-pts   [N/m2]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   vtau_ice       !: atmos-ice v-stress. VP: I-pt ; EVP: U,V-pts   [N/m2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   fr1_i0         !: Solar surface transmission parameter, thick ice  [-]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   fr2_i0         !: Solar surface transmission parameter, thin ice   [-]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   emp_ice        !: sublimation - precip over sea ice          [kg/m2/s]
 
@@ -123,7 +125,7 @@
       ALLOCATE( qns_ice (jpi,jpj,jpl) , qsr_ice (jpi,jpj,jpl) ,     &
          &      qla_ice (jpi,jpj,jpl) , dqla_ice(jpi,jpj,jpl) ,     &
-         &      dqns_ice(jpi,jpj,jpl) , tn_ice  (jpi,jpj,jpl) , alb_ice (jpi,jpj,jpl) ,   &
+         &      dqns_ice(jpi,jpj,jpl) , tn_ice  (jpi,jpj,jpl)  , alb_ice (jpi,jpj,jpl) ,   &
+         &      qml_ice(jpi,jpj,jpl)  , qcn_ice(jpi,jpj,jpl)   , qsr_ice_tr(jpi,jpj,jpl),  &
          &      utau_ice(jpi,jpj)     , vtau_ice(jpi,jpj)     , wndm_ice(jpi,jpj)     ,   &
-         &      fr1_i0  (jpi,jpj)     , fr2_i0  (jpi,jpj)     ,     &
          &      evap_ice(jpi,jpj,jpl) , devap_ice(jpi,jpj,jpl) , qprec_ice(jpi,jpj) ,   &
          &      qemp_ice(jpi,jpj)     , qevap_ice(jpi,jpj,jpl) , qemp_oce (jpi,jpj) ,   &
@@ -139,6 +141,6 @@
                 a_i(jpi,jpj,ncat)     , topmelt(jpi,jpj,ncat) , botmelt(jpi,jpj,ncat) , &
                 STAT= ierr(2) )
-      IF( ln_cpl )   ALLOCATE( u_ice(jpi,jpj)        , fr1_i0(jpi,jpj)       , tn_ice (jpi,jpj,1)    , &
-         &                     v_ice(jpi,jpj)        , fr2_i0(jpi,jpj)       , alb_ice(jpi,jpj,1)    , &
+      IF( ln_cpl )   ALLOCATE( u_ice(jpi,jpj)        , tn_ice (jpi,jpj,1)    , &
+         &                     v_ice(jpi,jpj)        , alb_ice(jpi,jpj,1)    , &
          &                     emp_ice(jpi,jpj)      , qns_ice(jpi,jpj,1)    , dqns_ice(jpi,jpj,1)   , &
          &                     STAT= ierr(3) )      
@@ -168,5 +170,5 @@
    REAL            , PUBLIC, PARAMETER ::   cldf_ice = 0.81       !: cloud fraction over sea ice, summer CLIO value   [-]
    INTEGER         , PUBLIC, PARAMETER ::   jpl = 1 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   u_ice, v_ice,fr1_i0,fr2_i0          ! jpi, jpj
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   u_ice, v_ice                        ! jpi, jpj
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   tn_ice, alb_ice, qns_ice, dqns_ice  ! (jpi,jpj,jpl)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   a_i
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk.F90	(revision 8752)
@@ -17,4 +17,5 @@
    !!                                          ==> based on AeroBulk (http://aerobulk.sourceforge.net/)
    !!            4.0  !  2016-10  (G. Madec)  introduce a sbc_blk_init routine
+   !!            4.0  !  2016-10  (M. Vancoppenolle)  Introduce Jules emulator (M. Vancoppenolle) 
    !!----------------------------------------------------------------------
 
@@ -42,4 +43,5 @@
    USE ice     , ONLY :   u_ice, v_ice, jpl, a_i_b, at_i_b, tm_su
    USE icethd_dh      ! for CALL ice_thd_snwblow
+   USE icethd_zdf, ONLY:   rn_cnd_s  ! for blk_ice_qcn
 #endif
    USE sbcblk_algo_ncar     ! => turb_ncar     : NCAR - CORE (Large & Yeager, 2009) 
@@ -64,5 +66,6 @@
    PUBLIC   blk_ice_tau   ! routine called in icestp module
    PUBLIC   blk_ice_flx   ! routine called in icestp module
-#endif
+   PUBLIC   blk_ice_qcn   ! routine called in icestp module
+#endif 
 
 !!Lolo: should ultimately be moved in the module with all physical constants ?
@@ -697,5 +700,5 @@
 
 
-   SUBROUTINE blk_ice_flx( ptsu, palb )
+   SUBROUTINE blk_ice_flx( ptsu, phs, phi, palb )
       !!---------------------------------------------------------------------
       !!                     ***  ROUTINE blk_ice_flx  ***
@@ -710,4 +713,6 @@
       !!---------------------------------------------------------------------
       REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   ptsu   ! sea ice surface temperature
+      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   phs    ! snow thickness
+      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   phi    ! ice thickness
       REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   palb   ! ice albedo (all skies)
       !!
@@ -716,4 +721,6 @@
       REAL(wp) ::   zcoef_dqlw, zcoef_dqla   !   -      -
       REAL(wp) ::   zztmp, z1_lsub           !   -      -
+      REAL(wp) ::   zfrqsr_tr_i              ! sea ice shortwave fraction transmitted below through the ice
+      REAL(wp) ::   zfr1, zfr2, zfac         ! local variables
       REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qlw         ! long wave heat flux over ice
       REAL(wp), DIMENSION(:,:,:), POINTER ::   z_qsb         ! sensible  heat flux over ice
@@ -722,4 +729,5 @@
       REAL(wp), DIMENSION(:,:)  , POINTER ::   zevap, zsnw   ! evaporation and snw distribution after wind blowing (LIM3)
       REAL(wp), DIMENSION(:,:)  , POINTER ::   zrhoa
+
       !!---------------------------------------------------------------------
       !
@@ -830,13 +838,36 @@
       CALL wrk_dealloc( jpi,jpj,   zevap, zsnw )
 
-      !--------------------------------------------------------------------
-      ! FRACTIONs of net shortwave radiation which is not absorbed in the
-      ! thin surface layer and penetrates inside the ice cover
-      ! ( Maykut and Untersteiner, 1971 ; Ebert and Curry, 1993 )
-      !
-      fr1_i0(:,:) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )
-      fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )
-      !
-      !
+      ! --- absorbed and transmitted shortwave radiation (W/m2) --- !
+      !
+      ! former coding was
+      !     fr1_i0(:,:) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )
+      !     fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )
+
+      ! --- surface transmission parameter (i0, Grenfell Maykut 77) --- !
+      zfr1 = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )            !   standard value
+      zfr2 = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )            !   zfr2 such that zfr1 + zfr2 to equal 1
+
+      qsr_ice_tr(:,:,:) = 0._wp
+
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+
+               zfac = MAX( 0._wp , 1._wp - phi(ji,jj,jl) * 10._wp )     !   linear weighting factor: =0 for phi=0, =1 for phi = 0.1
+               zfrqsr_tr_i = zfr1 + zfac * zfr2                         !   below 10 cm, linearly increase zfrqsr_tr_i until 1 at zero thickness
+
+               IF ( phs(ji,jj,jl) <= 0.0_wp ) THEN 
+                  zfrqsr_tr_i  = zfr1            + zfac * zfr2
+               ELSE 
+                  zfrqsr_tr_i  = 0._wp                                  !   snow fully opaque
+               ENDIF
+
+               qsr_ice_tr(ji,jj,jl) = zfrqsr_tr_i * qsr_ice(ji,jj,jl)   !   transmitted solar radiation 
+
+            END DO
+         END DO
+      END DO
+                                                                                      
+
       IF(ln_ctl) THEN
          CALL prt_ctl(tab3d_1=qla_ice , clinfo1=' blk_ice: qla_ice  : ', tab3d_2=z_qsb   , clinfo2=' z_qsb    : ', kdim=jpl)
@@ -854,4 +885,123 @@
 
    END SUBROUTINE blk_ice_flx
+   
+   
+
+   SUBROUTINE blk_ice_qcn( k_monocat, ptsu, ptb, phs, phi )
+   
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE blk_ice_qcn  ***
+      !!
+      !! ** Purpose :   Compute surface temperature and snow/ice conduction flux
+      !!                to force sea ice / snow thermodynamics
+      !!                in the case JULES coupler is emulated
+      !!                
+      !! ** Method  :   compute surface energy balance assuming neglecting heat storage
+      !!                following the 0-layer Semtner (1976) approach
+      !!
+      !! ** Outputs : - ptsu    : sea-ice / snow surface temperature (K)
+      !!              - qcn_ice : surface inner conduction flux (W/m2)
+      !!
+      !!---------------------------------------------------------------------
+      !!
+      INTEGER, INTENT(in)                        ::   k_monocat                 ! single-category option
+
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout)  ::   ptsu                      ! sea ice / snow surface temperature
+
+      REAL(wp), DIMENSION(:,:)  , INTENT(in)     ::   ptb                       ! sea ice base temperature
+      REAL(wp), DIMENSION(:,:,:), INTENT(in)     ::   phs                       ! snow thickness
+      REAL(wp), DIMENSION(:,:,:), INTENT(in)     ::   phi                       ! sea ice thickness
+      
+      INTEGER                                    ::   ji, jj, jl                ! dummy loop indices
+      INTEGER                                    ::   iter                      !
+      REAL(wp)                                   ::   zfac, zfac2, zfac3        ! dummy factors
+      REAL(wp)                                   ::   zkeff_h, ztsu             !
+      REAL(wp)                                   ::   zqc, zqnet                !
+      REAL(wp)                                   ::   zhe, zqa0                 !
+           
+      INTEGER , PARAMETER                        ::   nit = 10                  ! number of iterations
+      REAL(wp), PARAMETER                        ::   zepsilon = 0.1_wp         ! characteristic thickness for enhanced conduction
+
+      REAL(wp), DIMENSION(:,:,:), POINTER        ::   zgfac                    ! enhanced conduction factor
+      
+      !!---------------------------------------------------------------------
+
+      IF( nn_timing == 1 )  CALL timing_start('blk_ice_qcn')
+      !
+      CALL wrk_alloc( jpi,jpj,jpl,   zgfac )
+
+      ! -------------------------------------!
+      !      I   Enhanced conduction factor  !
+      ! -------------------------------------!
+      !
+      ! Emulates the enhancement of conduction by unresolved thin ice (k_monocat = 1/3)
+      ! Fichefet and Morales Maqueda, JGR 1997
+      !
+      zgfac(:,:,:) = 1._wp
+      
+      SELECT CASE ( k_monocat ) 
+      
+         CASE ( 1 , 3 )
+      
+            zfac    =   1._wp /  ( rn_cnd_s + rcdic )
+            zfac2   =   EXP(1._wp) * 0.5_wp * zepsilon
+            zfac3   =   2._wp / zepsilon
+      
+            DO jl = 1, jpl                
+               DO jj = 1 , jpj
+                  DO ji = 1, jpi
+                     !                                ! Effective thickness
+                     zhe               =   ( rn_cnd_s * phi(ji,jj,jl) + rcdic * phs(ji,jj,jl) ) * zfac
+                     !                                ! Enhanced conduction factor
+                     IF( zhe >=  zfac2 )  &
+                        zgfac(ji,jj,jl)   =   MIN( 2._wp, ( 0.5_wp + 0.5 * LOG( zhe * zfac3 ) ) )
+                  END DO
+               END DO
+            END DO
+      
+      END SELECT
+      
+      ! -------------------------------------------------------------!
+      !      II   Surface temperature and conduction flux            !
+      ! -------------------------------------------------------------!
+
+      zfac   =   rcdic * rn_cnd_s 
+                                      ! ========================== !
+      DO jl = 1, jpl                  !  Loop over ice categories  !
+         !                            ! ========================== !
+         DO jj = 1 , jpj
+            DO ji = 1, jpi
+               !                      ! Effective conductivity of the snow-ice system divided by thickness
+               zkeff_h   =   zfac * zgfac(ji,jj,jl) / ( rcdic * phs(ji,jj,jl) + rn_cnd_s * phi(ji,jj,jl) )
+                                      ! Store initial surface temperature
+               ztsu      =   ptsu(ji,jj,jl)
+                                      ! Net initial atmospheric heat flux
+               zqa0      =   qsr_ice(ji,jj,jl) - qsr_ice_tr(ji,jj,jl) + qns_ice(ji,jj,jl)
+               
+               DO iter = 1, nit       ! --- Iteration loop
+               
+                   !                  ! Conduction heat flux through snow-ice system (>0 downwards)
+                   zqc   =   zkeff_h * ( ztsu - ptb(ji,jj) )
+                   !                  ! Surface energy budget
+                   zqnet =   zqa0 + dqns_ice(ji,jj,jl) * ( ztsu - ptsu(ji,jj,jl) ) - zqc
+                   !                  ! Temperature update
+                   ztsu  =   ztsu - zqnet / ( dqns_ice(ji,jj,jl) - zkeff_h )
+               
+               END DO
+               
+               ptsu(ji,jj,jl)    = MIN( rt0, ztsu )
+               
+               qcn_ice(ji,jj,jl) = zkeff_h * ( ptsu(ji,jj,jl) - ptb(ji,jj) )
+               
+            END DO
+         END DO
+         
+      END DO 
+      
+      CALL wrk_dealloc( jpi,jpj,jpl,   zgfac )
+      
+      IF( nn_timing == 1 )  CALL timing_stop('blk_ice_qcn')
+
+   END SUBROUTINE blk_ice_qcn
    
 #endif
@@ -1093,8 +1243,6 @@
       zqi_sat(:,:) = 0.98_wp * q_sat( tm_su(:,:), sf(jp_slp)%fnow(:,:,1) )  ! saturation humidity over ice   [kg/kg]
       !
-!!      DO jj = 2, jpjm1
-!!         DO ji = fs_2, fs_jpim1
-      DO jj = 1, jpj
-         DO ji = 1, jpi
+      DO jj = 2, jpjm1           ! reduced loop is necessary for reproducibility
+         DO ji = fs_2, fs_jpim1
             ! Virtual potential temperature [K]
             zthetav_os = zst(ji,jj)   * ( 1._wp + rctv0 * zqo_sat(ji,jj) )   ! over ocean
@@ -1140,5 +1288,5 @@
          END DO
       END DO
-!!      CALL lbc_lnk_multi( Cd, 'T',  1., Ch, 'T', 1. )
+      CALL lbc_lnk_multi( Cd, 'T',  1., Ch, 'T', 1. )
       !
    END SUBROUTINE Cdn10_Lupkes2015
Index: /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 8751)
+++ /branches/UKMO/dev_r8183_ICEMODEL_svn_removed/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 8752)
@@ -32,5 +32,5 @@
    USE geo2ocean      ! 
    USE oce   , ONLY : tsn, un, vn, sshn, ub, vb, sshb, fraqsr_1lev
-   USE albedooce      ! 
+   USE ocealb         ! 
    USE eosbn2         ! 
    USE sbcrnf, ONLY : l_rnfcpl
@@ -178,5 +178,5 @@
    TYPE( DYNARR ), SAVE, DIMENSION(jprcv) ::   frcv                     ! all fields recieved from the atmosphere
 
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   albedo_oce_mix    ! ocean albedo sent to atmosphere (mix clear/overcast sky)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   alb_oce_mix    ! ocean albedo sent to atmosphere (mix clear/overcast sky)
 
    REAL(wp) ::   rpref = 101000._wp   ! reference atmospheric pressure[N/m2] 
@@ -202,5 +202,5 @@
       ierr(:) = 0
       !
-      ALLOCATE( albedo_oce_mix(jpi,jpj), nrcvinfo(jprcv),  STAT=ierr(1) )
+      ALLOCATE( alb_oce_mix(jpi,jpj), nrcvinfo(jprcv),  STAT=ierr(1) )
       
 #if ! defined key_lim3 && ! defined key_cice
@@ -737,7 +737,7 @@
       !     2. receiving mixed oce-ice solar radiation 
       IF ( TRIM ( sn_snd_alb%cldes ) == 'mixed oce-ice' .OR. TRIM ( sn_rcv_qsr%cldes ) == 'mixed oce-ice' ) THEN
-         CALL albedo_oce( zaos, zacs )
+         CALL oce_alb( zaos, zacs )
          ! Due to lack of information on nebulosity : mean clear/overcast sky
-         albedo_oce_mix(:,:) = ( zacs(:,:) + zaos(:,:) ) * 0.5
+         alb_oce_mix(:,:) = ( zacs(:,:) + zaos(:,:) ) * 0.5
       ENDIF
 
@@ -1530,5 +1530,5 @@
    
 
-   SUBROUTINE sbc_cpl_ice_flx( picefr, palbi, psst, pist )
+   SUBROUTINE sbc_cpl_ice_flx( picefr, palbi, psst, pist, phs, phi )
       !!----------------------------------------------------------------------
       !!             ***  ROUTINE sbc_cpl_ice_flx  ***
@@ -1585,10 +1585,12 @@
       REAL(wp), INTENT(in), DIMENSION(:,:  ), OPTIONAL ::   psst       ! sea surface temperature     [Celsius]
       REAL(wp), INTENT(in), DIMENSION(:,:,:), OPTIONAL ::   pist       ! ice surface temperature     [Kelvin]
-      !
-      INTEGER ::   jl         ! dummy loop index
+      REAL(wp), INTENT(in), DIMENSION(:,:,:), OPTIONAL ::   phs        ! snow depth                  [m]
+      REAL(wp), INTENT(in), DIMENSION(:,:,:), OPTIONAL ::   phi        ! ice thickness               [m]
+      !
+      INTEGER ::   ji,jj,jl         ! dummy loop index
       REAL(wp), POINTER, DIMENSION(:,:  ) ::   zcptn, zcptrain, zcptsnw, ziceld, zmsk, zsnw
       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
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice, zfrqsr_tr_i
       !!----------------------------------------------------------------------
       !
@@ -1598,5 +1600,5 @@
       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 )
+      CALL wrk_alloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice, zfrqsr_tr_i )
 
       IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0)
@@ -1890,5 +1892,5 @@
 !       ( see OASIS3 user guide, 5th edition, p39 )
          zqsr_ice(:,:,1) = frcv(jpr_qsrmix)%z3(:,:,1) * ( 1.- palbi(:,:,1) )   &
-            &            / (  1.- ( albedo_oce_mix(:,:  ) * ziceld(:,:)       &
+            &            / (  1.- ( alb_oce_mix(:,:  ) * ziceld(:,:)       &
             &                     + palbi         (:,:,1) * picefr(:,:) ) )
       END SELECT
@@ -1951,15 +1953,52 @@
       END SELECT
 
-      ! Surface transimission parameter io (Maykut Untersteiner , 1971 ; Ebert and Curry, 1993 )
-      ! Used for LIM3
-      ! Coupled case: since cloud cover is not received from atmosphere 
-      !               ===> used prescribed cloud fraction representative for polar oceans in summer (0.81)
-      fr1_i0(:,:) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )
-      fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )
+      ! --- Transmitted shortwave radiation (W/m2) --- !
+      
+      IF ( nice_jules == 0 ) THEN
+               
+         zfrqsr_tr_i(:,:,:) = 0._wp   !   surface transmission parameter
+     
+         ! former coding was    
+         ! Coupled case: since cloud cover is not received from atmosphere 
+         !               ===> used prescribed cloud fraction representative for polar oceans in summer (0.81)
+         !     fr1_i0(:,:) = ( 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice )
+         !     fr2_i0(:,:) = ( 0.82 * ( 1.0 - cldf_ice ) + 0.65 * cldf_ice )
+         
+         ! to retrieve that coding, we needed to access h_i & h_s from here
+         ! we could even retrieve cloud fraction from the coupler
+               
+         DO jl = 1, jpl
+            DO jj = 1 , jpj
+               DO ji = 1, jpi
+            
+                  !--- surface transmission parameter (Grenfell Maykut 77) --- !
+                  zfrqsr_tr_i(ji,jj,jl) = 0.18 * ( 1.0 - cldf_ice ) + 0.35 * cldf_ice 
+               
+                  ! --- influence of snow and thin ice --- !
+                  IF ( phs(ji,jj,jl) >= 0.0_wp ) zfrqsr_tr_i(ji,jj,jl) = 0._wp   !   snow fully opaque
+                  IF ( phi(ji,jj,jl) <= 0.1_wp ) zfrqsr_tr_i(ji,jj,jl) = 1._wp   !   thin ice transmits all solar radiation
+               END DO
+            END DO
+         END DO
+         
+         qsr_ice_tr(:,:,:) =   zfrqsr_tr_i(:,:,:) * qsr_ice(:,:,:)               !   transmitted solar radiation 
+               
+      ENDIF
+      
+      IF ( nice_jules == 2 ) THEN
+      
+         ! here we must receive the qsr_ice_tr array from the coupler
+         ! for now just assume zero
+         
+         qsr_ice_tr(:,:,:) = 0.0_wp
+      
+      ENDIF
+
+
 
       CALL wrk_dealloc( jpi,jpj,     zcptn, zcptrain, zcptsnw, ziceld, zmsk, zsnw )
       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 )
+      CALL wrk_dealloc( jpi,jpj,jpl, zqns_ice, zqsr_ice, zdqns_ice, zqevap_ice, zfrqsr_tr_i )
       !
       IF( nn_timing == 1 )   CALL timing_stop('sbc_cpl_ice_flx')
@@ -2057,5 +2096,5 @@
                    ztmp1(:,:) = SUM( alb_ice (:,:,1:jpl) * a_i(:,:,1:jpl), dim=3 ) / SUM( a_i(:,:,1:jpl), dim=3 )
                 ELSEWHERE
-                   ztmp1(:,:) = albedo_oce_mix(:,:)
+                   ztmp1(:,:) = alb_oce_mix(:,:)
                 END WHERE
              CASE default   ;   CALL ctl_stop( 'sbc_cpl_snd: wrong definition of sn_snd_alb%clcat' )
@@ -2085,5 +2124,5 @@
 
       IF( ssnd(jps_albmix)%laction ) THEN                         ! mixed ice-ocean
-         ztmp1(:,:) = albedo_oce_mix(:,:) * zfr_l(:,:)
+         ztmp1(:,:) = alb_oce_mix(:,:) * zfr_l(:,:)
          DO jl=1,jpl
             ztmp1(:,:) = ztmp1(:,:) + alb_ice(:,:,jl) * a_i(:,:,jl)
