Index: NEMO/branches/UKMO/NEMO_4.0.1_dan_test_clems_branch/src/ICE/iceistate.F90
===================================================================
--- NEMO/branches/UKMO/NEMO_4.0.1_dan_test_clems_branch/src/ICE/iceistate.F90	(revision 12809)
+++ NEMO/branches/UKMO/NEMO_4.0.1_dan_test_clems_branch/src/ICE/iceistate.F90	(revision 12812)
@@ -41,13 +41,16 @@
    !                             !! ** namelist (namini) **
    LOGICAL, PUBLIC  ::   ln_iceini        !: Ice initialization or not
-   LOGICAL, PUBLIC  ::   ln_iceini_file   !: Ice initialization from 2D netcdf file
+   INTEGER, PUBLIC  ::   nn_iceini_file   !: Ice initialization:
+                                  !        0 = Initialise sea ice based on SSTs
+                                  !        1 = Initialise sea ice from single category netcdf file
+                                  !        2 = Initialise sea ice from multi category restart file
    REAL(wp) ::   rn_thres_sst
    REAL(wp) ::   rn_hti_ini_n, rn_hts_ini_n, rn_ati_ini_n, rn_smi_ini_n, rn_tmi_ini_n, rn_tsu_ini_n, rn_tms_ini_n
    REAL(wp) ::   rn_hti_ini_s, rn_hts_ini_s, rn_ati_ini_s, rn_smi_ini_s, rn_tmi_ini_s, rn_tsu_ini_s, rn_tms_ini_s
-   REAL(wp) ::   rn_apd_ini_n, rn_hpd_ini_n
-   REAL(wp) ::   rn_apd_ini_s, rn_hpd_ini_s
+   REAL(wp) ::   rn_apd_ini_n, rn_hpd_ini_n, rn_hld_ini_n
+   REAL(wp) ::   rn_apd_ini_s, rn_hpd_ini_s, rn_hld_ini_s
    !
-   !                              ! if ln_iceini_file = T
-   INTEGER , PARAMETER ::   jpfldi = 9           ! maximum number of files to read
+   !                              ! if nn_iceini_file = 1
+   INTEGER , PARAMETER ::   jpfldi = 10          ! maximum number of files to read
    INTEGER , PARAMETER ::   jp_hti = 1           ! index of ice thickness    (m)
    INTEGER , PARAMETER ::   jp_hts = 2           ! index of snw thickness    (m)
@@ -59,4 +62,5 @@
    INTEGER , PARAMETER ::   jp_apd = 8           ! index of pnd fraction     (-)
    INTEGER , PARAMETER ::   jp_hpd = 9           ! index of pnd depth        (m)
+   INTEGER , PARAMETER ::   jp_hld = 10          ! index of pnd lid depth    (m)
    TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   si  ! structure of input fields (file informations, fields read)
    !   
@@ -98,8 +102,8 @@
       REAL(wp), DIMENSION(jpi,jpj)     ::   zht_i_ini, zat_i_ini, ztm_s_ini            !data from namelist or nc file
       REAL(wp), DIMENSION(jpi,jpj)     ::   zt_su_ini, zht_s_ini, zsm_i_ini, ztm_i_ini !data from namelist or nc file
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zapnd_ini, zhpnd_ini                       !data from namelist or nc file
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zapnd_ini, zhpnd_ini, zhlid_ini            !data from namelist or nc file
       REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zti_3d , zts_3d                            !temporary arrays
       !!
-      REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   zhi_2d, zhs_2d, zai_2d, zti_2d, zts_2d, ztsu_2d, zsi_2d, zaip_2d, zhip_2d
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   zhi_2d, zhs_2d, zai_2d, zti_2d, zts_2d, ztsu_2d, zsi_2d, zaip_2d, zhip_2d, zhil_2d
       !--------------------------------------------------------------------
 
@@ -155,6 +159,8 @@
       a_ip     (:,:,:) = 0._wp
       v_ip     (:,:,:) = 0._wp
-      a_ip_frac(:,:,:) = 0._wp
+      v_il     (:,:,:) = 0._wp
+      a_ip_eff (:,:,:) = 0._wp
       h_ip     (:,:,:) = 0._wp
+      h_il     (:,:,:) = 0._wp
       !
       ! ice velocities
@@ -167,5 +173,5 @@
       IF( ln_iceini ) THEN
          !                             !---------------!
-         IF( ln_iceini_file )THEN      ! Read a file   !
+         IF( nn_iceini_file == 1 )THEN ! Read a file   !
             !                          !---------------!
             WHERE( ff_t(:,:) >= 0._wp )   ;   zswitch(:,:) = 1._wp
@@ -218,5 +224,11 @@
             IF( TRIM(si(jp_hpd)%clrootname) == 'NOT USED' ) &
                &     si(jp_hpd)%fnow(:,:,1) = ( rn_hpd_ini_n * zswitch + rn_hpd_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+            !
+            ! pond lid depth
+            IF( TRIM(si(jp_hld)%clrootname) == 'NOT USED' ) &
+               &     si(jp_hld)%fnow(:,:,1) = ( rn_hld_ini_n * zswitch + rn_hld_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+            !
             zhpnd_ini(:,:) = si(jp_hpd)%fnow(:,:,1)
+            zhlid_ini(:,:) = si(jp_hld)%fnow(:,:,1)
             !
             ! change the switch for the following
@@ -243,4 +255,5 @@
                zapnd_ini(:,:) = rn_apd_ini_n * zswitch(:,:) * zat_i_ini(:,:) ! rn_apd = pond fraction => rn_apd * a_i = pond conc. 
                zhpnd_ini(:,:) = rn_hpd_ini_n * zswitch(:,:)
+               zhlid_ini(:,:) = rn_hld_ini_n * zswitch(:,:)
             ELSEWHERE
                zht_i_ini(:,:) = rn_hti_ini_s * zswitch(:,:)
@@ -253,4 +266,5 @@
                zapnd_ini(:,:) = rn_apd_ini_s * zswitch(:,:) * zat_i_ini(:,:) ! rn_apd = pond fraction => rn_apd * a_i = pond conc.
                zhpnd_ini(:,:) = rn_hpd_ini_s * zswitch(:,:)
+               zhlid_ini(:,:) = rn_hld_ini_s * zswitch(:,:)
             END WHERE
             !
@@ -261,4 +275,9 @@
             zapnd_ini(:,:) = 0._wp
             zhpnd_ini(:,:) = 0._wp
+            zhlid_ini(:,:) = 0._wp
+         ENDIF
+
+         IF ( .NOT.ln_pnd_lids ) THEN
+            zhlid_ini(:,:) = 0._wp
          ENDIF
          
@@ -287,14 +306,18 @@
          CALL tab_2d_1d( npti, nptidx(1:npti), a_ip_1d(1:npti)  , zapnd_ini )
          CALL tab_2d_1d( npti, nptidx(1:npti), h_ip_1d(1:npti)  , zhpnd_ini )
+         CALL tab_2d_1d( npti, nptidx(1:npti), h_il_1d(1:npti)  , zhlid_ini )
 
          ! allocate temporary arrays
-         ALLOCATE( zhi_2d(npti,jpl), zhs_2d(npti,jpl), zai_2d (npti,jpl), &
-            &      zti_2d(npti,jpl), zts_2d(npti,jpl), ztsu_2d(npti,jpl), zsi_2d(npti,jpl), zaip_2d(npti,jpl), zhip_2d(npti,jpl) )
+         ALLOCATE( zhi_2d (npti,jpl), zhs_2d (npti,jpl), zai_2d (npti,jpl), &
+            &      zti_2d (npti,jpl), zts_2d (npti,jpl), ztsu_2d(npti,jpl), zsi_2d(npti,jpl), &
+            &      zaip_2d(npti,jpl), zhip_2d(npti,jpl), zhil_2d(npti,jpl) )
          
          ! distribute 1-cat into jpl-cat: (jpi*jpj) -> (jpi*jpj,jpl)
-         CALL ice_var_itd( h_i_1d(1:npti)  , h_s_1d(1:npti)  , at_i_1d(1:npti),                                                   &
-            &              zhi_2d          , zhs_2d          , zai_2d         ,                                                   &
-            &              t_i_1d(1:npti,1), t_s_1d(1:npti,1), t_su_1d(1:npti), s_i_1d(1:npti), a_ip_1d(1:npti), h_ip_1d(1:npti), &
-            &              zti_2d          , zts_2d          , ztsu_2d        , zsi_2d        , zaip_2d        , zhip_2d )
+         CALL ice_var_itd( h_i_1d(1:npti)  , h_s_1d(1:npti)  , at_i_1d(1:npti),                  &
+            &              zhi_2d          , zhs_2d          , zai_2d         ,                  &
+            &              t_i_1d(1:npti,1), t_s_1d(1:npti,1), t_su_1d(1:npti),                  &
+            &              s_i_1d(1:npti)  , a_ip_1d(1:npti) , h_ip_1d(1:npti), h_il_1d(1:npti), &
+            &              zti_2d          , zts_2d          , ztsu_2d        ,                  &
+            &              zsi_2d          , zaip_2d         , zhip_2d        , zhil_2d )
 
          ! move to 3D arrays: (jpi*jpj,jpl) -> (jpi,jpj,jpl)
@@ -312,8 +335,9 @@
          CALL tab_2d_3d( npti, nptidx(1:npti), zaip_2d  , a_ip   )
          CALL tab_2d_3d( npti, nptidx(1:npti), zhip_2d  , h_ip   )
+         CALL tab_2d_3d( npti, nptidx(1:npti), zhil_2d  , h_il   )
 
          ! deallocate temporary arrays
          DEALLOCATE( zhi_2d, zhs_2d, zai_2d , &
-            &        zti_2d, zts_2d, ztsu_2d, zsi_2d, zaip_2d, zhip_2d )
+            &        zti_2d, zts_2d, ztsu_2d, zsi_2d, zaip_2d, zhip_2d, zhil_2d )
 
          ! calculate extensive and intensive variables
@@ -357,10 +381,9 @@
 
          ! Melt ponds
-         WHERE( a_i > epsi10 )
-            a_ip_frac(:,:,:) = a_ip(:,:,:) / a_i(:,:,:)
-         ELSEWHERE
-            a_ip_frac(:,:,:) = 0._wp
+         WHERE( a_i > epsi10 )   ;   a_ip_eff(:,:,:) = a_ip(:,:,:) / a_i(:,:,:)
+         ELSEWHERE               ;   a_ip_eff(:,:,:) = 0._wp
          END WHERE
          v_ip(:,:,:) = h_ip(:,:,:) * a_ip(:,:,:)
+         v_il(:,:,:) = h_il(:,:,:) * a_ip(:,:,:)
           
          ! specific temperatures for coupled runs
@@ -434,5 +457,4 @@
       e_s_b  (:,:,:,:) = e_s  (:,:,:,:)
       sv_i_b (:,:,:)   = sv_i (:,:,:)
-      oa_i_b (:,:,:)   = oa_i (:,:,:)
       u_ice_b(:,:)     = u_ice(:,:)
       v_ice_b(:,:)     = v_ice(:,:)
@@ -463,13 +485,13 @@
       !
       CHARACTER(len=256) ::  cn_dir          ! Root directory for location of ice files
-      TYPE(FLD_N)                    ::   sn_hti, sn_hts, sn_ati, sn_smi, sn_tmi, sn_tsu, sn_tms, sn_apd, sn_hpd
+      TYPE(FLD_N)                    ::   sn_hti, sn_hts, sn_ati, sn_smi, sn_tmi, sn_tsu, sn_tms, sn_apd, sn_hpd, sn_hld
       TYPE(FLD_N), DIMENSION(jpfldi) ::   slf_i                 ! array of namelist informations on the fields to read
       !
-      NAMELIST/namini/ ln_iceini, ln_iceini_file, rn_thres_sst, &
+      NAMELIST/namini/ ln_iceini, nn_iceini_file, rn_thres_sst, &
          &             rn_hti_ini_n, rn_hti_ini_s, rn_hts_ini_n, rn_hts_ini_s, &
          &             rn_ati_ini_n, rn_ati_ini_s, rn_smi_ini_n, rn_smi_ini_s, &
          &             rn_tmi_ini_n, rn_tmi_ini_s, rn_tsu_ini_n, rn_tsu_ini_s, rn_tms_ini_n, rn_tms_ini_s, &
-         &             rn_apd_ini_n, rn_apd_ini_s, rn_hpd_ini_n, rn_hpd_ini_s, &
-         &             sn_hti, sn_hts, sn_ati, sn_tsu, sn_tmi, sn_smi, sn_tms, sn_apd, sn_hpd, cn_dir
+         &             rn_apd_ini_n, rn_apd_ini_s, rn_hpd_ini_n, rn_hpd_ini_s, rn_hld_ini_n, rn_hld_ini_s, &
+         &             sn_hti, sn_hts, sn_ati, sn_tsu, sn_tmi, sn_smi, sn_tms, sn_apd, sn_hpd, sn_hld, cn_dir
       !!-----------------------------------------------------------------------------
       !
@@ -485,5 +507,5 @@
       slf_i(jp_ati) = sn_ati  ;  slf_i(jp_smi) = sn_smi
       slf_i(jp_tmi) = sn_tmi  ;  slf_i(jp_tsu) = sn_tsu   ;   slf_i(jp_tms) = sn_tms
-      slf_i(jp_apd) = sn_apd  ;  slf_i(jp_hpd) = sn_hpd
+      slf_i(jp_apd) = sn_apd  ;  slf_i(jp_hpd) = sn_hpd   ;   slf_i(jp_hld) = sn_hld
       !
       IF(lwp) THEN                          ! control print
@@ -493,7 +515,7 @@
          WRITE(numout,*) '   Namelist namini:'
          WRITE(numout,*) '      ice initialization (T) or not (F)                ln_iceini      = ', ln_iceini
-         WRITE(numout,*) '      ice initialization from a netcdf file            ln_iceini_file = ', ln_iceini_file
+         WRITE(numout,*) '      ice initialization from a netcdf file            nn_iceini_file = ', nn_iceini_file
          WRITE(numout,*) '      max ocean temp. above Tfreeze with initial ice   rn_thres_sst   = ', rn_thres_sst
-         IF( ln_iceini .AND. .NOT.ln_iceini_file ) THEN
+         IF( ln_iceini .AND. nn_iceini_file == 0 ) THEN
             WRITE(numout,*) '      initial snw thickness in the north-south         rn_hts_ini     = ', rn_hts_ini_n,rn_hts_ini_s 
             WRITE(numout,*) '      initial ice thickness in the north-south         rn_hti_ini     = ', rn_hti_ini_n,rn_hti_ini_s
@@ -505,8 +527,9 @@
             WRITE(numout,*) '      initial pnd fraction  in the north-south         rn_apd_ini     = ', rn_apd_ini_n,rn_apd_ini_s
             WRITE(numout,*) '      initial pnd depth     in the north-south         rn_hpd_ini     = ', rn_hpd_ini_n,rn_hpd_ini_s
+            WRITE(numout,*) '      initial pnd lid depth in the north-south         rn_hld_ini     = ', rn_hld_ini_n,rn_hld_ini_s
          ENDIF
       ENDIF
       !
-      IF( ln_iceini_file ) THEN                      ! Ice initialization using input file
+      IF( nn_iceini_file == 1 ) THEN                      ! Ice initialization using input file
          !
          ! set si structure
@@ -529,5 +552,10 @@
          rn_apd_ini_n = 0. ; rn_apd_ini_s = 0.
          rn_hpd_ini_n = 0. ; rn_hpd_ini_s = 0.
-         CALL ctl_warn( 'rn_apd_ini & rn_hpd_ini = 0 when no ponds' )
+         rn_hld_ini_n = 0. ; rn_hld_ini_s = 0.
+         CALL ctl_warn( 'rn_apd_ini & rn_hpd_ini = 0 & rn_hld_ini = 0 when no ponds' )
+      ENDIF
+      !
+      IF( .NOT.ln_pnd_lids ) THEN
+         rn_hld_ini_n = 0. ; rn_hld_ini_s = 0.
       ENDIF
       !
