Index: branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/ice.F90
===================================================================
--- branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 7281)
+++ branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/ice.F90	(revision 7293)
@@ -277,4 +277,9 @@
    REAL(wp), PUBLIC ::   rn_fsnowrft      !: fractional snow loss to the ocean during ridging
 
+   ! MV MP 2016
+   !                                     !!** melt pond namelist (namicemp)
+   LOGICAL , PUBLIC ::   ln_limMP         !: activate melt ponds or not
+   INTEGER , PUBLIC ::   nn_limMP         !: type of melt pond implementation (1=full, 2=radiation only, 3=freshwater only)
+
    !                                     !!** some other parameters 
    INTEGER , PUBLIC ::   nstart           !: iteration number of the begining of the run 
@@ -404,4 +409,14 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   s_i      !: ice salinities          [PSU]
 
+   ! MV MP 2016
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   a_ip       !: melt pond fraction per grid cell area
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   v_ip       !: melt pond volume per grid cell area [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   a_ip_frac  !: melt pond volume per ice area
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   h_ip       !: melt pond thickness [m]
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   at_ip      !: total melt pond fraction
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   vt_ip      !: total melt pond volume per unit area [m]
+   ! END MV MP 2016
+
    !!--------------------------------------------------------------------------
    !! * Moments for advection
@@ -415,4 +430,8 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   sxage, syage, sxxage, syyage, sxyage   !: ice age
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   sxe  , sye  , sxxe  , syye  , sxye     !: ice layers heat content
+   ! MV MP 2016
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   sxap , syap , sxxap , syyap , sxyap    !:  melt pond fraction
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   sxvp , syvp , sxxvp , syyvp , sxyvp    !:  melt pond volume
+   ! END MV MP 2016
 
    !!--------------------------------------------------------------------------
Index: branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90
===================================================================
--- branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 7281)
+++ branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 7293)
@@ -407,5 +407,26 @@
          at_i (:,:) = at_i (:,:) + a_i (:,:,jl)
       END DO
+
+      ! MV MP 2016
+
+      ! For now, we just assume that melt ponds are absent initially
+      ! We probably have to revise this and code it as for all other sea ice variables later on
       !
+      !--------------------------------------------------------------------
+      ! X) Melt pond variables
+      !--------------------------------------------------------------------
+      !
+      IF ( ln_limMP ) THEN
+         a_ip(:,:,:) = 0._wp
+         v_ip(:,:,:) = 0._wp
+         h_ip(:,:,:) = 0._wp
+         a_ip_frac(:,:,:) = 0._wp
+
+         at_ip(:,:) = 0._wp
+         vt_ip(:,:) = 0._wp
+      ENDIF
+
+      ! END MV MP 2016
+
       !--------------------------------------------------------------------
       ! 4) Global ice variables for output diagnostics                    | 
@@ -450,4 +471,14 @@
       syyage (:,:,:)  = 0._wp
       sxyage (:,:,:)  = 0._wp
+
+      ! MV MP 2016
+      IF ( ln_limMP ) THEN
+         sxap  (:,:) = 0._wp    ; sxvp  (:,:) = 0._wp 
+         syap  (:,:) = 0._wp    ; syvp  (:,:) = 0._wp 
+         sxxap (:,:) = 0._wp    ; sxxvp (:,:) = 0._wp 
+         syyap (:,:) = 0._wp    ; syyvp (:,:) = 0._wp 
+         sxyap (:,:) = 0._wp    ; sxyvp (:,:) = 0._wp
+      ENDIF
+      ! END MV MP 2016
 
 !!!clem
Index: branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limmp.F90
===================================================================
--- branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limmp.F90	(revision 7293)
+++ branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limmp.F90	(revision 7293)
@@ -0,0 +1,1115 @@
+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  ! 2016    (O. Lecomte, C. Rousset, M. Vancoppenolle) Implementation in NEMO3.6
+   !!----------------------------------------------------------------------
+#if defined key_lim3
+   !!----------------------------------------------------------------------
+   !!   'key_lim3' :                                 LIM3 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_mp_init      : some initialization and namelist read
+   !!   lim_mp           : main calling routine
+   !!   compute_mp_topo  : actual melt pond routine
+   !!   pond_area        : computes melt pond fraction per category
+   !!   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 lbclnk           ! lateral boundary conditions - MPP exchanges
+   USE lib_mpp          ! MPP library
+   USE wrk_nemo         ! work arrays
+   USE in_out_manager   ! I/O manager
+   USE lib_fortran      ! glob_sum
+   USE timing           ! Timing
+!  USE limcons          ! conservation tests
+!  USE limctl           ! control prints
+!  USE limvar
+
+!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 sbcice_lim.F90
+!  PUBLIC   lim_mp         ! routine called by sbcice_lim.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 namicemp  namelist and check the melt pond  
+      !!       parameter values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicemp  
+      !!-------------------------------------------------------------------
+      INTEGER  ::   ios                 ! Local integer output status for namelist read
+      NAMELIST/namicemp/  ln_limMP, nn_limMP
+      !!-------------------------------------------------------------------
+
+      REWIND( numnam_ice_ref )              ! Namelist namicemp  in reference namelist : Melt Ponds  
+      READ  ( numnam_ice_ref, namicemp, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namicemp  in reference namelist', lwp )
+
+      REWIND( numnam_ice_cfg )              ! Namelist namicemp  in configuration namelist : Melt Ponds
+      READ  ( numnam_ice_cfg, namicemp, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namicemp in configuration namelist', lwp )
+      IF(lwm) WRITE ( numoni, namicemp )
+      
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_mp_init : ice parameters for melt ponds'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+         WRITE(numout,*)'    Activate melt ponds                                         ln_limMP      = ', ln_limMP  
+         WRITE(numout,*)'    Type of melt pond implementation (1=all,2=rad, 3=fw, 4=no)  nn_limMP      = ', nn_limMP  
+      ENDIF
+      !
+   END SUBROUTINE lim_mp_init
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Empty module           NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_mp_init     ! Empty routine
+   END SUBROUTINE lim_mp_init
+#endif 
+
+   !!======================================================================
+END MODULE limmp 
+
+!======================================================================================================================================================
+!======================================================================================================================================================
+!======================================================================================================================================================
+! DIRTY LEFT OVERS FROM ASSHOLES
+!
+!  SUBROUTINE lim_dyn( kt )
+!     !!-------------------------------------------------------------------
+!     !!               ***  ROUTINE lim_dyn  ***
+!     !!               
+!     !! ** Purpose :   compute ice velocity
+!     !!                
+!     !! ** Method  : 
+!     !!
+!     !! ** Action  : - Initialisation
+!     !!              - Call of the dynamic routine for each hemisphere
+!     !!------------------------------------------------------------------------------------
+!     INTEGER, INTENT(in) ::   kt     ! number of iteration
+!     !!
+!     INTEGER  :: jl, jk ! dummy loop indices
+!     REAL(wp) :: zvi_b, zsmv_b, zei_b, zfs_b, zfw_b, zft_b 
+!    !!---------------------------------------------------------------------
+
+!     IF( nn_timing == 1 )  CALL timing_start('limdyn')
+
+!     CALL lim_var_agg(1)                      ! aggregate ice categories
+      !
+!     ! conservation test
+!     IF( ln_limdiachk ) CALL lim_cons_hsm(0, 'limdyn', zvi_b, zsmv_b, zei_b, zfw_b, zfs_b, zft_b)
+!  END SUBROUTINE lim_dyn
+
+!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, s_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          zuny     = 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) > zuny) 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) > zuny) 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 > zuny) 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) < zuny .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) > zuny) 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 > zuny) 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 < zuny
+!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 > zuny) 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) > zuny .and. zvolpn(i,j,n) < puny &
+!OLI_CODE                                     .and. zvuin (i,j,n) > zuny) 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) > zuny) 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) > zuny) 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          zuny      = 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) < zuny)  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) + zuny
+!OLI_CODE          zvolp = zvolp - drain
+!OLI_CODE          dvolp = drain
+!OLI_CODE          IF (zvolp < zuny) 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 < zuny) 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+zuny < 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) > zuny) 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          zuny = 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 < zuny) 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 
Index: branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90
===================================================================
--- branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90	(revision 7281)
+++ branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90	(revision 7293)
@@ -151,4 +151,17 @@
       END DO
 
+      ! MV MP 2016
+      IF ( ln_limMP ) THEN
+         DO jl = 1, jpl 
+            znam = 'a_ip'//'_htc'//zchar
+            z2d(:,:) = a_ip(:,:,jl)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+            znam = 'v_ip'//'_htc'//zchar
+            z2d(:,:) = v_ip(:,:,jl)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+         END DO
+      ENDIF
+      ! END MV MP 2016
+
       DO jl = 1, jpl 
          WRITE(zchar,'(I2.2)') jl
@@ -301,4 +314,40 @@
             END DO
          END DO
+         ! MV MP 2016
+         IF ( ln_limMP ) THEN
+            DO jl = 1, jpl 
+               znam = 'sxap'//'_htc'//zchar
+               z2d(:,:) = sxap(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+               znam = 'syap'//'_htc'//zchar
+               z2d(:,:) = syap(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+               znam = 'sxxap'//'_htc'//zchar
+               z2d(:,:) = sxxap(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+               znam = 'syyap'//'_htc'//zchar
+               z2d(:,:) = syyap(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+               znam = 'sxyap'//'_htc'//zchar
+               z2d(:,:) = sxyap(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+   
+               znam = 'sxvp'//'_htc'//zchar
+               z2d(:,:) = sxvp(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+               znam = 'syvp'//'_htc'//zchar
+               z2d(:,:) = syvp(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+               znam = 'sxxvp'//'_htc'//zchar
+               z2d(:,:) = sxxvp(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+               znam = 'syyvp'//'_htc'//zchar
+               z2d(:,:) = syyvp(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+               znam = 'sxyvp'//'_htc'//zchar
+               z2d(:,:) = sxyvp(:,:,jl)
+               CALL iom_rstput( iter, nitrst, numriw, znam , z2d )
+            END DO
+         ENDIF
 
       ENDIF
@@ -387,4 +436,16 @@
       END DO
 
+      ! MV MP 2016
+      IF ( ln_limMP ) THEN
+         DO jl = 1, jpl 
+            znam = 'a_ip'//'_htc'//zchar
+            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+            a_ip(:,:,jl) = z2d(:,:)
+            znam = 'v_ip'//'_htc'//zchar
+            CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+            v_ip(:,:,jl) = z2d(:,:)
+         END DO
+      ENDIF
+
       DO jl = 1, jpl 
          WRITE(zchar,'(I2.2)') jl
@@ -509,4 +570,41 @@
             sxyage(:,:,jl)= z2d(:,:)
          END DO
+         ! MV MP 2016
+         IF ( ln_limMP ) THEN
+            DO jl = 1, jpl 
+               znam = 'sxap'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               sxap(:,:,jl) = z2d(:,:)
+               znam = 'syap'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               syap(:,:,jl) = z2d(:,:)
+               znam = 'sxxap'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               sxxap(:,:,jl) = z2d(:,:)
+               znam = 'syyap'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               syyap(:,:,jl) = z2d(:,:)
+               znam = 'sxyap'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               sxyap(:,:,jl) = z2d(:,:)
+   
+               znam = 'sxvp'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               sxvp(:,:,jl) = z2d(:,:)
+               znam = 'syvp'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               syvp(:,:,jl) = z2d(:,:)
+               znam = 'sxxvp'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               sxxvp(:,:,jl) = z2d(:,:)
+               znam = 'syyvp'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               syyvp(:,:,jl) = z2d(:,:)
+               znam = 'sxyvp'//'_htc'//zchar
+               CALL iom_get( numrir, jpdom_autoglo, znam , z2d )
+               sxyvp(:,:,jl) = z2d(:,:)
+            END DO
+         ENDIF
+         ! END MV MP 2016
 
          CALL iom_get( numrir, jpdom_autoglo, 'sxopw ' ,  sxopw  )
Index: branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90
===================================================================
--- branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90	(revision 7281)
+++ branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limvar.F90	(revision 7293)
@@ -91,4 +91,11 @@
       et_i(:,:)  = SUM( SUM( e_i(:,:,:,:), dim=4 ), dim=3 )
 
+      ! MV MP 2016
+      IF ( ln_limMP )
+         at_i_p(:,:) = SUM( a_ip, dim=3 )
+         vt_i_p(:,:) = SUM( v_ip, dim=3 )
+      ENDIF
+      ! END MP 2016
+
       ! open water fraction
       DO jj = 1, jpj
@@ -244,8 +251,11 @@
       END DO
 
-      ! integrated values
+      ! integrated values 
       vt_i (:,:) = SUM( v_i, dim=3 )
       vt_s (:,:) = SUM( v_s, dim=3 )
       at_i (:,:) = SUM( a_i, dim=3 )
+
+      ! MV MP 2016
+      ! probably should resum for melt ponds ???
 
       !
Index: branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90
===================================================================
--- branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 7281)
+++ branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 7293)
@@ -207,4 +207,11 @@
       CALL iom_put ('hfxspr'     , hfx_spr(:,:)         )   ! Heat content of snow precip 
 
+      ! MV MP 2016
+      IF ( ln_limMP ) 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
+      ! END MV MP 2016
+
       
       !--------------------------------
@@ -223,4 +230,11 @@
       ! brine volume
       IF ( iom_use( "brinevol_cat" ) )  CALL iom_put( "brinevol_cat", bv_i * 100. * zswi2 )
+
+      ! MV MP 2016
+      IF ( ln_limMP ) 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
+      ENDIF
+      ! END MV MP 2016
 
       !     !  Create an output files (output.lim.abort.nc) if S < 0 or u > 20 m/s
@@ -286,4 +300,13 @@
       &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt ) 
 
+      ! MV MP 2016
+      IF ( ln_limMP ) 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, "vfxbog", "Ice bottom production"   , "m/s"    ,   &
       &      jpi, jpj, kh_i, 1, 1, 1, -99, 32, "inst(x)", rdt, rdt )
@@ -330,4 +353,11 @@
       CALL histwrite( kid, "sidive", kt, divu_i*1.0e8   , jpi*jpj, (/1/) )
 
+      ! MV MP 2016
+      IF ( ln_limMP ) 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, "vfxbog", kt, wfx_bog        , jpi*jpj, (/1/) )
       CALL histwrite( kid, "vfxdyn", kt, wfx_dyn        , jpi*jpj, (/1/) )
Index: branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90
===================================================================
--- branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 7281)
+++ branches/2016/dev_r6859_LIM3_meltponds/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 7293)
@@ -48,4 +48,8 @@
    USE limvar          ! Ice variables switch
 
+   ! MV MP 2016
+   USE limmp
+   ! END MV MP 2016
+
    USE limistate       ! LIM initial state
    USE limthd_sal      ! LIM ice thermodynamics: salinity
@@ -336,5 +340,9 @@
       !
       CALL lim_thd_sal_init            ! set ice salinity parameters
-      !
+       
+      ! MV MP 2016
+      CALL lim_mp_init                 ! set melt ponds parameters
+      ! END MV MP 2016
+
       IF( ln_limdyn )   CALL lim_itd_me_init             ! ice thickness distribution initialization for mecanical deformation
       !                                ! Initial sea-ice state
