Index: branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/OPA_SRC/BDY/bdydta.F90
===================================================================
--- branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/OPA_SRC/BDY/bdydta.F90	(revision 5052)
+++ branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/OPA_SRC/BDY/bdydta.F90	(revision 5053)
@@ -35,5 +35,5 @@
    USE par_ice
    USE ice
-   USE limcat_1D          ! redistribute ice input into categories
+   USE limvar          ! redistribute ice input into categories
 #endif
    USE sbcapr
@@ -380,5 +380,5 @@
 #if defined key_lim3
                IF( .NOT. ll_bdylim3 .AND. cn_ice_lim(ib_bdy) /= 'none' .AND. nn_ice_lim_dta(ib_bdy) == 1 ) THEN ! bdy ice input (case input is lim2 type)
-     	          CALL lim_cat_1D ( bf(jfld_hti)%fnow(:,1,1), bf(jfld_hts)%fnow(:,1,1), bf(jfld_ai)%fnow(:,1,1), &
+     	          CALL lim_var_itd ( bf(jfld_hti)%fnow(:,1,1), bf(jfld_hts)%fnow(:,1,1), bf(jfld_ai)%fnow(:,1,1), &
                                   & dta_bdy(ib_bdy)%ht_i,     dta_bdy(ib_bdy)%ht_s,     dta_bdy(ib_bdy)%a_i     )
                ENDIF
Index: branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice_lim.F90
===================================================================
--- branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice_lim.F90	(revision 5052)
+++ branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice_lim.F90	(revision 5053)
@@ -60,6 +60,6 @@
       !!----------------------------------------------------------------------
       INTEGER, INTENT( in ) :: kt     ! Main time step counter
-      !!
       INTEGER               :: ib_bdy ! Loop index
+
       DO ib_bdy=1, nb_bdy
 
@@ -72,5 +72,6 @@
             CALL ctl_stop( 'bdy_ice_lim : unrecognised option for open boundaries for ice fields' )
          END SELECT
-      ENDDO
+
+      END DO
 
    END SUBROUTINE bdy_ice_lim
@@ -247,8 +248,7 @@
             END DO
 
-
-         END DO !jb
+         END DO
  
-         CALL lbc_bdy_lnk(  a_i(:,:,jl), 'T', 1., ib_bdy )                                         ! lateral boundary conditions
+         CALL lbc_bdy_lnk(  a_i(:,:,jl), 'T', 1., ib_bdy )
          CALL lbc_bdy_lnk( ht_i(:,:,jl), 'T', 1., ib_bdy )
          CALL lbc_bdy_lnk( ht_s(:,:,jl), 'T', 1., ib_bdy )
Index: branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90
===================================================================
--- branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 5052)
+++ branches/2015/dev_r5044_CNRS_LIM3CLEAN/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_lim.F90	(revision 5053)
@@ -39,5 +39,4 @@
    USE limtrp          ! Ice transport
    USE limthd          ! Ice thermodynamics
-   USE limitd_th       ! Thermodynamics on ice thickness distribution 
    USE limitd_me       ! Mechanics on ice thickness distribution
    USE limsbc          ! sea surface boundary condition
@@ -109,6 +108,5 @@
       INTEGER, INTENT(in) ::   kblk    ! type of bulk (=3 CLIO, =4 CORE, =5 COUPLED)
       !!
-      INTEGER  ::   jl      ! dummy loop index
-      REAL(wp) ::   zcoef   ! local scalar
+      INTEGER  ::   jl                 ! dummy loop index
       REAL(wp), POINTER, DIMENSION(:,:,:)   ::   zalb_os, zalb_cs  ! ice albedo under overcast/clear sky
       REAL(wp), POINTER, DIMENSION(:,:,:)   ::   zalb_ice          ! mean ice albedo (for coupled)
@@ -117,10 +115,8 @@
       IF( nn_timing == 1 )  CALL timing_start('sbc_ice_lim')
 
-      !                                        !----------------------!
-      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN     !  Ice time-step only  !
-         !                                     !----------------------!
-         !                                           !  Bulk Formulae !
-         !                                           !----------------!
-         !
+      IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN     !  Ice time-step only
+         !-----------------------!                                           
+         ! --- Bulk Formulae --- !                                           
+         !-----------------------!
          u_oce(:,:) = ssu_m(:,:) * umask(:,:,1)      ! mean surface ocean current at ice velocity point
          v_oce(:,:) = ssv_m(:,:) * vmask(:,:,1)      ! (C-grid dynamics :  U- & V-points as the ocean)
@@ -133,6 +129,7 @@
          CALL albedo_ice( t_su, ht_i, ht_s, zalb_cs, zalb_os )  ! cloud-sky and overcast-sky ice albedos
 
+         ! CORE and COUPLED bulk formulations
          SELECT CASE( kblk )
-         CASE( jp_core , jp_cpl )   ! CORE and COUPLED bulk formulations
+         CASE( jp_core , jp_cpl )
 
             ! albedo depends on cloud fraction because of non-linear spectral effects
@@ -183,8 +180,7 @@
          END SELECT
          
-         !                                           !----------------------!
-         !                                           ! LIM-3  time-stepping !
-         !                                           !----------------------!
-         ! 
+         !------------------------------!
+         ! --- LIM-3 main time-step --- !
+         !------------------------------!
          numit = numit + nn_fsbc                     ! Ice model time step
          !
@@ -200,9 +196,8 @@
          v_ice_b(:,:)     = v_ice(:,:)
 
-                          CALL sbc_lim_flx0          ! set diag of mass, heat and salt fluxes to 0
+                          CALL sbc_lim_diag0         ! set diag of mass, heat and salt fluxes to 0
 
                           CALL lim_rst_opn( kt )     ! Open Ice restart file
          !
-         IF( ln_nicep )   CALL lim_prt( kt, jiindx, jjindx, 1, ' - Beginning the time step - ' )   ! control print
          ! ----------------------------------------------
          ! ice dynamics and transport (except in 1D case)
@@ -211,10 +206,10 @@
 
                           CALL lim_dyn( kt )              ! Ice dynamics    ( rheology/dynamics )
+
                           CALL lim_trp( kt )              ! Ice transport   ( Advection/diffusion )
-                          CALL lim_var_glo2eqv            ! equivalent variables, requested for rafting
-         IF( ln_nicep )   CALL lim_prt( kt, jiindx, jjindx,-1, ' - ice dyn & trp - ' )   ! control print
+
          IF( nn_monocat /= 2 )   &
             &             CALL lim_itd_me                 ! Mechanical redistribution ! (ridging/rafting)
-                          CALL lim_var_agg( 1 ) 
+
 #if defined key_bdy
                           ! bdy ice thermo 
@@ -225,16 +220,19 @@
          IF( ln_nicep )   CALL lim_prt( kt, jiindx, jjindx, 1, ' - ice thermo bdy - ' )   ! control print
 #endif
-                          CALL lim_update1
+
+                          CALL lim_update1( kt )
+
          ENDIF
-!                         !- Change old values for new values
-                          u_ice_b(:,:)     = u_ice(:,:)
-                          v_ice_b(:,:)     = v_ice(:,:)
-                          a_i_b  (:,:,:)   = a_i  (:,:,:)
-                          v_s_b  (:,:,:)   = v_s  (:,:,:)
-                          v_i_b  (:,:,:)   = v_i  (:,:,:)
-                          e_s_b  (:,:,:,:) = e_s  (:,:,:,:)
-                          e_i_b  (:,:,:,:) = e_i  (:,:,:,:)
-                          oa_i_b (:,:,:)   = oa_i (:,:,:)
-                          smv_i_b(:,:,:)   = smv_i(:,:,:)
+
+         !- Change old values for new values
+         u_ice_b(:,:)     = u_ice(:,:)
+         v_ice_b(:,:)     = v_ice(:,:)
+         a_i_b  (:,:,:)   = a_i  (:,:,:)
+         v_s_b  (:,:,:)   = v_s  (:,:,:)
+         v_i_b  (:,:,:)   = v_i  (:,:,:)
+         e_s_b  (:,:,:,:) = e_s  (:,:,:,:)
+         e_i_b  (:,:,:,:) = e_i  (:,:,:,:)
+         oa_i_b (:,:,:)   = oa_i (:,:,:)
+         smv_i_b(:,:,:)   = smv_i(:,:,:)
  
          ! ----------------------------------------------
@@ -253,30 +251,21 @@
                              IF( nn_limflx == 2 )   CALL ice_lim_flx( t_su, zalb_ice, qns_ice, qsr_ice ,   &
                           &                                           dqns_ice, qla_ice, dqla_ice, nn_limflx )
-                           ! Latent heat flux is forced to 0 in coupled :
-                           !  it is included in qns (non-solar heat flux)
+                             ! Latent heat flux is forced to 0 in coupled: it is included in qns (non-solar heat flux)
                              qla_ice  (:,:,:) = 0._wp
                              dqla_ice (:,:,:) = 0._wp
                           END SELECT
                           !
-                          CALL lim_var_bv                 ! bulk brine volume (diag)
                           CALL lim_thd( kt )              ! Ice thermodynamics 
-                          zcoef = rdt_ice /rday           !  Ice natural aging
-                          oa_i(:,:,:) = oa_i(:,:,:) + a_i(:,:,:) * zcoef
-         IF( ln_nicep )   CALL lim_prt( kt, jiindx, jjindx, 1, ' - ice thermodyn. - ' )   ! control print
-                          CALL lim_itd_th( kt )           !  Remap ice categories, lateral accretion
-                          CALL lim_update2                ! Global variables update
-
-         IF( ln_nicep )   CALL lim_prt( kt, jiindx, jjindx, 2, ' - Final state - ' )   ! control print
-         !
-                          CALL lim_sbc_flx( kt )     ! Update surface ocean mass, heat and salt fluxes
-         !
-         IF( ln_nicep )   CALL lim_prt( kt, jiindx, jjindx, 3, ' - Final state lim_sbc - ' )   ! control print
+
+                          CALL lim_update2( kt )          ! Global variables update
+         !
+                          CALL lim_sbc_flx( kt )          ! Update surface ocean mass, heat and salt fluxes
          !
          IF(ln_limdiaout) CALL lim_diahsb                 ! Diagnostics and outputs 
 
-                          CALL lim_wri( 1  )              ! Ice outputs 
+                          CALL lim_wri( 1 )               ! Ice outputs 
 
          IF( kt == nit000 .AND. ln_rstart )   &
-            &             CALL iom_close( numrir )        ! clem: close input ice restart file
+            &             CALL iom_close( numrir )        ! close input ice restart file
          !
          IF( lrst_ice )   CALL lim_rst_write( kt )        ! Ice restart file 
@@ -315,5 +304,4 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   via Louvain la Neuve Ice Model (LIM-3) time stepping'
       !
-      !
       !                                ! Allocate the ice arrays
       ierr =        ice_alloc        ()      ! ice variables
@@ -343,10 +331,7 @@
       CALL lim_thd_sal_init            ! set ice salinity parameters
       !
-      rdt_ice   = nn_fsbc * rdttra(1)  ! sea-ice timestep
-      r1_rdtice = 1._wp / rdt_ice      ! sea-ice timestep inverse
-      !
       CALL lim_msh                     ! ice mesh initialization
       !
-      CALL lim_itd_init                 ! ice thickness distribution initialization
+      CALL lim_itd_init                ! ice thickness distribution initialization
       !
       CALL lim_itd_me_init             ! ice thickness distribution initialization
@@ -356,12 +341,10 @@
          numit = nit000 - 1
          CALL lim_istate
-         CALL lim_var_agg(1)
-         CALL lim_var_glo2eqv
       ELSE                                    ! start from a restart file
          CALL lim_rst_read
          numit = nit000 - 1
-         CALL lim_var_agg(1)
-         CALL lim_var_glo2eqv
       ENDIF
+      CALL lim_var_agg(1)
+      CALL lim_var_glo2eqv
       !
       CALL lim_sbc_init                 ! ice surface boundary condition   
@@ -390,5 +373,8 @@
       !! ** input   :   Namelist namicerun
       !!-------------------------------------------------------------------
-      NAMELIST/namicerun/ cn_icerst_in, cn_icerst_out, ln_limdyn, amax, ln_nicep, ln_limdiahsb, ln_limdiaout
+!clem      NAMELIST/namicerun/ jpl, nlay_i, nlay_s, cn_icerst_in, cn_icerst_out,   &
+!clem         &                ln_limdyn, amax, ln_nicep, ln_limdiahsb, ln_limdiaout
+      NAMELIST/namicerun/ cn_icerst_in, cn_icerst_out,   &
+         &                ln_limdyn, amax, ln_nicep, ln_limdiahsb, ln_limdiaout
       INTEGER  ::   ios                 ! Local integer output status for namelist read
       !!-------------------------------------------------------------------
@@ -408,4 +394,7 @@
          WRITE(numout,*) 'ice_run : ice share parameters for dynamics/advection/thermo of sea-ice'
          WRITE(numout,*) ' ~~~~~~'
+!clem         WRITE(numout,*) '   number of ice  categories                               = ', jpl
+!clem         WRITE(numout,*) '   number of ice  layers                                   = ', nlay_i
+!clem         WRITE(numout,*) '   number of snow layers                                   = ', nlay_s
          WRITE(numout,*) '   switch for ice dynamics (1) or not (0)      ln_limdyn   = ', ln_limdyn
          WRITE(numout,*) '   maximum ice concentration                               = ', amax 
@@ -423,4 +412,8 @@
          IF(lwp) WRITE(numout,*) ' The debugging point is : jiindx : ',jiindx, ' jjindx : ',jjindx
       ENDIF
+      !
+      ! sea-ice timestep and inverse
+      rdt_ice   = nn_fsbc * rdttra(1)  
+      r1_rdtice = 1._wp / rdt_ice 
       !
    END SUBROUTINE ice_run
@@ -577,5 +570,5 @@
    END SUBROUTINE ice_lim_flx
 
-   SUBROUTINE sbc_lim_flx0
+   SUBROUTINE sbc_lim_diag0
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE sbc_lim_flx0  ***
@@ -610,5 +603,5 @@
       afx_dyn(:,:) = 0._wp   ;   afx_thd(:,:) = 0._wp
       
-   END SUBROUTINE sbc_lim_flx0
+   END SUBROUTINE sbc_lim_diag0
       
    FUNCTION fice_cell_ave ( ptab )
@@ -623,6 +616,5 @@
       
       DO jl = 1, jpl
-         fice_cell_ave (:,:) = fice_cell_ave (:,:) &
-            &                  + a_i (:,:,jl) * ptab (:,:,jl)
+         fice_cell_ave (:,:) = fice_cell_ave (:,:) + a_i (:,:,jl) * ptab (:,:,jl)
       END DO
       
