Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/albedo_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/albedo_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/albedo_2.F90	(revision 823)
@@ -0,0 +1,229 @@
+MODULE albedo_2
+   !!======================================================================
+   !!                       ***  MODULE  albedo_2  ***
+   !! Ocean forcing:  bulk thermohaline forcing of the ocean (or ice)
+   !!=====================================================================
+   !!----------------------------------------------------------------------
+   !!   flx_blk_albedo_2 : albedo for ocean and ice (clear and overcast skies)
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                        LIM 2.0 ice model
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE cpl_oce         ! ???
+   USE phycst          ! physical constants
+   USE daymod
+   USE blk_oce         ! bulk variables
+   USE flx_oce         ! forcings variables
+   USE ocfzpt          ! ???
+   USE in_out_manager
+   USE lbclnk
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC flx_blk_albedo_2 ! routine called by limflx.F90 in coupled
+                         ! and in flxblk.F90 in forced
+   !! * Module variables
+   INTEGER  ::             &  !: nameos : ocean physical parameters
+      albd_init = 0           !: control flag for initialization
+
+   REAL(wp)  ::            &  ! constant values
+      zzero   = 0.e0    ,  &
+      zone    = 1.0
+
+   !! * constants for albedo computation (flx_blk_albedo)
+   REAL(wp) ::   &
+      c1     = 0.05  ,     &   ! constants values
+      c2     = 0.10  ,     &
+      albice = 0.50  ,     &   !  albedo of melting ice in the arctic and antarctic (Shine & Hendersson-Sellers)
+      cgren  = 0.06  ,     &   !  correction of the snow or ice albedo to take into account
+                               !  effects of cloudiness (Grenfell & Perovich, 1984)
+      alphd  = 0.80  ,     &   !  coefficients for linear interpolation used to compute
+      alphdi = 0.72  ,     &   !  albedo between two extremes values (Pyane, 1972)
+      alphc  = 0.65  ,     &
+      zmue   = 0.40            !  cosine of local solar altitude
+
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE flx_blk_albedo_2( palb , palcn , palbp , palcnp )
+      !!----------------------------------------------------------------------
+      !!               ***  ROUTINE flx_blk_albedo_2  ***
+      !!          
+      !! ** Purpose :   Computation of the albedo of the snow/ice system 
+      !!      as well as the ocean one
+      !!       
+      !! ** Method  : - Computation of the albedo of snow or ice (choose the 
+      !!      rignt one by a large number of tests
+      !!              - Computation of the albedo of the ocean
+      !!
+      !! References :
+      !!      Shine and Hendersson-Sellers 1985, JGR, 90(D1), 2243-2250.
+      !!
+      !! History :
+      !!  8.0   !  01-04  (LIM 1.0)
+      !!  8.5   !  03-07  (C. Ethe, G. Madec)  Optimization (old name:shine)
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      USE ice_2                   ! ???
+
+      !! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(out) ::  &
+         palb         ,     &    !  albedo of ice under overcast sky
+         palcn        ,     &    !  albedo of ocean under overcast sky
+         palbp        ,     &    !  albedo of ice under clear sky 
+         palcnp                  !  albedo of ocean under clear sky
+
+      !! * Local variables
+      INTEGER ::    &
+         ji, jj                   ! dummy loop indices
+      REAL(wp) ::   & 
+         zmue14         ,     &   !  zmue**1.4
+         zalbpsnm       ,     &   !  albedo of ice under clear sky when snow is melting
+         zalbpsnf       ,     &   !  albedo of ice under clear sky when snow is freezing
+         zalbpsn        ,     &   !  albedo of snow/ice system when ice is coverd by snow
+         zalbpic        ,     &   !  albedo of snow/ice system when ice is free of snow
+         zithsn         ,     &   !  = 1 for hsn >= 0 ( ice is cov. by snow ) ; = 0 otherwise (ice is free of snow)
+         zitmlsn        ,     &   !  = 1 freezinz snow (sist >=rt0_snow) ; = 0 melting snow (sist<rt0_snow)
+         zihsc1         ,     &   !  = 1 hsn <= c1 ; = 0 hsn > c1
+         zihsc2                   !  = 1 hsn >= c2 ; = 0 hsn < c2
+      REAL(wp), DIMENSION(jpi,jpj) ::  &
+         zalbfz         ,     &   !  ( = alphdi for freezing ice ; = albice for melting ice )
+         zficeth                  !  function of ice thickness
+      LOGICAL , DIMENSION(jpi,jpj) ::  &
+         llmask
+      !!---------------------------------------------------------------------
+      
+      ! initialization 
+      IF( albd_init == 0 )   CALL albedo_init_2
+
+      !-------------------------                                                             
+      !  Computation of  zficeth
+      !-------------------------- 
+      
+      llmask = (hsnif == 0.e0) .AND. ( sist >= rt0_ice )
+      WHERE ( llmask )   !  ice free of snow and melts
+         zalbfz = albice
+      ELSEWHERE                   
+         zalbfz = alphdi
+      END WHERE
+      
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( hicif(ji,jj) > 1.5 ) THEN
+               zficeth(ji,jj) = zalbfz(ji,jj)
+            ELSEIF( hicif(ji,jj) > 1.0  .AND. hicif(ji,jj) <= 1.5 ) THEN
+               zficeth(ji,jj) = 0.472 + 2.0 * ( zalbfz(ji,jj) - 0.472 ) * ( hicif(ji,jj) - 1.0 )
+            ELSEIF( hicif(ji,jj) > 0.05 .AND. hicif(ji,jj) <= 1.0 ) THEN
+               zficeth(ji,jj) = 0.2467 + 0.7049 * hicif(ji,jj)                                &
+                  &                    - 0.8608 * hicif(ji,jj) * hicif(ji,jj)                 &
+                  &                    + 0.3812 * hicif(ji,jj) * hicif(ji,jj) * hicif (ji,jj)
+            ELSE
+               zficeth(ji,jj) = 0.1 + 3.6 * hicif(ji,jj) 
+            ENDIF
+         END DO
+      END DO
+      
+      !----------------------------------------------- 
+      !    Computation of the snow/ice albedo system 
+      !-------------------------- ---------------------
+      
+      !    Albedo of snow-ice for clear sky.
+      !-----------------------------------------------    
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            !  Case of ice covered by snow.             
+            
+            !  melting snow        
+            zihsc1       = 1.0 - MAX ( zzero , SIGN ( zone , - ( hsnif(ji,jj) - c1 ) ) )
+            zalbpsnm     = ( 1.0 - zihsc1 ) * ( zficeth(ji,jj) + hsnif(ji,jj) * ( alphd - zficeth(ji,jj) ) / c1 ) &
+               &                 + zihsc1   * alphd  
+            !  freezing snow                
+            zihsc2       = MAX ( zzero , SIGN ( zone , hsnif(ji,jj) - c2 ) )
+            zalbpsnf     = ( 1.0 - zihsc2 ) * ( albice + hsnif(ji,jj) * ( alphc - albice ) / c2 )                 &
+               &                 + zihsc2   * alphc 
+            
+            zitmlsn      =  MAX ( zzero , SIGN ( zone , sist(ji,jj) - rt0_snow ) )   
+            zalbpsn      =  zitmlsn * zalbpsnf + ( 1.0 - zitmlsn ) * zalbpsnm 
+            
+            !  Case of ice free of snow.
+            zalbpic      = zficeth(ji,jj) 
+            
+            ! albedo of the system   
+            zithsn       = 1.0 - MAX ( zzero , SIGN ( zone , - hsnif(ji,jj) ) )
+            palbp(ji,jj) =  zithsn * zalbpsn + ( 1.0 - zithsn ) *  zalbpic
+         END DO
+      END DO
+      
+      !    Albedo of snow-ice for overcast sky.
+      !----------------------------------------------  
+      palb(:,:)   = palbp(:,:) + cgren                                           
+      
+      !--------------------------------------------
+      !    Computation of the albedo of the ocean 
+      !-------------------------- -----------------                                                          
+      
+      !  Parameterization of Briegled and Ramanathan, 1982 
+      zmue14      = zmue**1.4                                       
+      palcnp(:,:) = 0.05 / ( 1.1 * zmue14 + 0.15 )                
+      
+      !  Parameterization of Kondratyev, 1969 and Payne, 1972
+      palcn(:,:)  = 0.06                                                 
+      
+   END SUBROUTINE flx_blk_albedo_2
+
+   SUBROUTINE albedo_init_2
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE albedo_init_2  ***
+      !!
+      !! ** Purpose :   initializations for the albedo parameters
+      !!
+      !! ** Method  :   Read the namelist namalb
+      !!
+      !! ** Action  :  
+      !!
+      !!
+      !! History :
+      !!   9.0  !  04-11  (C. Talandier)  Original code
+      !!----------------------------------------------------------------------
+      NAMELIST/namalb/ cgren, albice, alphd, alphdi, alphc
+      !!----------------------------------------------------------------------
+      !!  OPA 9.0, LODYC-IPSL (2004)
+      !!----------------------------------------------------------------------
+
+      ! set the initialization flag to 1
+      albd_init = 1           ! indicate that the initialization has been done
+
+      ! Read Namelist namalb : albedo parameters
+      REWIND( numnam )
+      READ  ( numnam, namalb )
+
+      ! Control print
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'albedo_init_2 : albedo '
+         WRITE(numout,*) '~~~~~~~~~~~~~'
+         WRITE(numout,*) '          Namelist namalb : set albedo parameters'
+         WRITE(numout,*)
+         WRITE(numout,*) '             correction of the snow or ice albedo to take into account cgren = ', cgren
+         WRITE(numout,*) '             albedo of melting ice in the arctic and antarctic        albice = ', albice
+         WRITE(numout,*) '             coefficients for linear                                   alphd = ', alphd
+         WRITE(numout,*) '             interpolation used to compute albedo                     alphdi = ', alphdi
+         WRITE(numout,*) '             between two extremes values (Pyane, 1972)                 alphc = ', alphc
+         WRITE(numout,*)
+      ENDIF
+
+   END SUBROUTINE albedo_init_2
+   !!======================================================================
+#endif
+END MODULE albedo_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/dom_ice_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/dom_ice_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/dom_ice_2.F90	(revision 823)
@@ -0,0 +1,37 @@
+MODULE dom_ice_2
+#if defined key_lim2
+   !!======================================================================
+   !!                   ***  MODULE  dom_ice  ***
+   !! LIM 2.0 Sea Ice :   Domain  variables
+   !!======================================================================
+   !! History :   2.0  !  03-08  (C. Ethe)  Free form and module
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0, UCL-LOCEAN-IPSL (2005)
+   !! $Header$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+   USE par_ice_2
+
+   IMPLICIT NONE
+   PRIVATE
+
+   LOGICAL, PUBLIC ::   l_jeq     = .TRUE.     !: Equator inside the domain flag
+   LOGICAL, PUBLIC ::   ln_limini = .FALSE.    !: Ice initialization state
+   LOGICAL, PUBLIC ::   ln_limdmp = .FALSE.    !: Ice damping
+
+   INTEGER, PUBLIC ::   njeq , njeqm1          !: j-index of the equator if it is inside the domain
+      !                                        !  (otherwise = jpj+10 (SH) or -10 (SH) )
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj)         ::   fs2cor , fcor,   &  !: coriolis factor and coeficient
+      &                                              covrai ,         &  !: sine of geographic latitude
+      &                                              area   ,         &  !: surface of grid cell 
+      &                                              tms    , tmu        !: temperature and velocity points masks
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,2,2)     ::   wght   ,         &  !: weight of the 4 neighbours to compute averages
+      &                                              akappa , bkappa     !: first and third group of metric coefficients
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,2,2,2,2) ::   alambd   !: second group of metric coefficients
+
+   !!======================================================================
+#endif
+END MODULE dom_ice_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/flxblk_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/flxblk_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/flxblk_2.F90	(revision 823)
@@ -0,0 +1,746 @@
+MODULE flxblk_2
+   !!======================================================================
+   !!                       ***  MODULE  flxblk  ***
+   !! Ocean forcing:  bulk thermohaline forcing of the ocean (or ice)
+   !!=====================================================================
+#if ( defined key_flx_bulk_monthly || defined key_flx_bulk_daily ) && defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_flx_bulk_monthly'   or                            MONTHLY bulk
+   !!   'key_flx_bulk_daily'                                     DAILY bulk
+   !!----------------------------------------------------------------------
+   !!   flx_blk        : thermohaline fluxes from bulk
+   !!   flx_blk_declin : solar declinaison
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE cpl_oce         ! ???
+   USE phycst          ! physical constants
+   USE daymod
+   USE blk_oce         ! bulk variables
+   USE flx_oce         ! forcings variables
+   USE ocfzpt          ! ???
+   USE in_out_manager
+   USE lbclnk
+   USE albedo_2
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC flx_blk_2        ! routine called by flx.F90 
+
+   !! * Module variables
+   INTEGER, PARAMETER  ::   &
+      jpintsr = 24          ! number of time step between sunrise and sunset
+      !                     ! uses for heat flux computation
+   LOGICAL ::   &
+      lbulk_init = .TRUE.   ! flag, bulk initialization done or not)
+
+   REAL(wp), DIMENSION(jpi,jpj) ::   &
+      stauc            ,  &   ! cloud optical depth 
+      sbudyko   
+
+   !! * constants for bulk computation (flx_blk)
+   REAL(wp), DIMENSION(19)  ::  &
+      budyko                  ! BUDYKO's coefficient
+   ! BUDYKO's coefficient (cloudiness effect on LW radiation):
+   DATA budyko / 1.00, 0.98, 0.95, 0.92, 0.89, 0.86, 0.83, 0.80, 0.78, 0.75,  &
+      &          0.72, 0.69, 0.67, 0.64, 0.61, 0.58, 0.56, 0.53, 0.50 /
+   REAL(wp), DIMENSION(20)  :: &
+      tauco                  ! cloud optical depth coefficient
+   ! Cloud optical depth coefficient
+   DATA tauco / 6.6, 6.6, 7.0, 7.2, 7.1, 6.8, 6.5, 6.6, 7.1, 7.6,   &
+      &         6.6, 6.1, 5.6, 5.5, 5.8, 5.8, 5.6, 5.6, 5.6, 5.6 /
+   REAL(wp)  ::            &  ! constant values
+      zeps    = 1.e-20  ,  &
+      zeps0   = 1.e-13  ,  &
+      zeps1   = 1.e-06  ,  &
+      zzero   = 0.e0    ,  &
+      zone    = 1.0
+
+   !! * constants for solar declinaison computation (flx_blk_declin)
+   REAL(wp) ::                &
+      a0  =  0.39507671   ,   &  ! coefficients
+      a1  = 22.85684301   ,   &
+      a2  = -0.38637317   ,   &
+      a3  =  0.15096535   ,   &
+      a4  = -0.00961411   ,   &
+      b1  = -4.29692073   ,   &
+      b2  =  0.05702074   ,   &
+      b3  = -0.09028607   ,   &
+      b4  =  0.00592797
+   !!----------------------------------------------------------------------
+   !!   OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE flx_blk_2( psst )
+      !!---------------------------------------------------------------------------
+      !!                     ***  ROUTINE flx_blk  ***
+      !!                 
+      !!  ** Purpose :   Computation of the heat fluxes at ocean and snow/ice
+      !!       surface the solar heat at ocean and snow/ice surfaces and the 
+      !!       sensitivity of total heat fluxes to the SST variations
+      !!         
+      !!  ** Method  :   The flux of heat at the ice and ocean surfaces are derived
+      !!       from semi-empirical ( or bulk ) formulae which relate the flux to 
+      !!       the properties of the surface and of the lower atmosphere. Here, we
+      !!       follow the work of Oberhuber, 1988   
+      !!
+      !!  ** Action  :   call flx_blk_albedo to compute ocean and ice albedo 
+      !!          computation of snow precipitation
+      !!          computation of solar flux at the ocean and ice surfaces
+      !!          computation of the long-wave radiation for the ocean and sea/ice
+      !!          computation of turbulent heat fluxes over water and ice
+      !!          computation of evaporation over water
+      !!          computation of total heat fluxes sensitivity over ice (dQ/dT)
+      !!          computation of latent heat flux sensitivity over ice (dQla/dT)
+      !!
+      !! History :
+      !!   8.0  !  97-06  (Louvain-La-Neuve)  Original code
+      !!   8.5  !  02-09  (C. Ethe , G. Madec )  F90: Free form and module
+      !!----------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp), INTENT( in ), DIMENSION(jpi,jpj) ::   &
+         &                          psst      ! Sea Surface Temperature 
+
+      !! * Local variables
+      INTEGER  ::             &
+         ji, jj, jt        ,  &  ! dummy loop indices
+         indaet            ,  &  !  = -1, 0, 1 for odd, normal and leap years resp.
+         iday              ,  &  ! integer part of day
+         indxb             ,  &  ! index for budyko coefficient
+         indxc                   ! index for cloud depth coefficient
+
+      REAL(wp)  ::            & 
+         zalat , zclat     ,  &  ! latitude in degrees 
+         zmt1, zmt2, zmt3  ,  &  ! tempory air temperatures variables
+         ztatm3, ztatm4    ,  &  ! power 3 and 4 of air temperature
+         z4tatm3           ,  &  ! 4 * ztatm3
+         zcmue             ,  &  ! cosine of local solar altitude
+         zcmue2            ,  &  ! root of zcmue1 
+         zscmue            ,  &  ! square-root of zcmue1 
+         zpcmue            ,  &  ! zcmue1**1.4
+         zdecl             ,  &  ! solar declination
+         zsdecl , zcdecl   ,  &  ! sine and cosine of solar declination 
+         zalbo             ,  &  ! albedo of sea-water
+         zalbi             ,  &  ! albedo of ice
+         ztamr             ,  &  ! air temperature minus triple point of water (rtt)
+         ztaevbk           ,  &  ! part of net longwave radiation
+         zevi , zevo       ,  &  ! vapour pressure of ice and ocean 
+         zind1,zind2,zind3 ,  &  ! switch for testing the values of air temperature
+         zinda             ,  &  ! switch for testing the values of sea ice cover
+         zpis2             ,  &  ! pi / 2
+         z2pi                    ! 2 * pi 
+
+      REAL(wp)  ::            & 
+         zxday             ,  &  ! day of year
+         zdist             ,  &  ! distance between the sun and the earth during the year
+         zdaycor           ,  &  ! corr. factor to take into account the variation of 
+         !                       ! zday when calc. the solar rad.    
+         zesi, zeso        ,  &  ! vapour pressure of ice and ocean at saturation
+         zesi2             ,  &  ! root of zesi 
+         zqsato            ,  &  ! humidity close to the ocean surface (at saturation)   
+         zqsati            ,  &  ! humidity close to the ice surface (at saturation) 
+         zqsati2           ,  &  ! root of  zqsati 
+         zdesidt           ,  &  ! derivative of zesi, function of ice temperature
+         zdteta            ,  &  ! diff. betw. sst and air temperature
+         zdeltaq           ,  &  ! diff. betw. spec. hum. and hum. close to the surface
+         ztvmoy, zobouks   ,  &  ! tempory scalars
+         zpsims, zpsihs, zpsils, zobouku, zxins, zpsimu ,  & 
+         zpsihu, zpsilu, zstab,zpsim, zpsih, zpsil      ,  & 
+         zvatmg, zcmn, zchn, zcln, zcmcmn, zdenum       ,  & 
+         zdtetar, ztvmoyr, zlxins, zcmn2, zchcm, zclcm , zcoef
+
+      REAL(wp)  ::            & 
+         zrhova            ,  &  ! air density per wind speed
+         zcsho , zcleo     ,  &  ! transfer coefficient over ocean
+         zcshi , zclei     ,  &  ! transfer coefficient over ice-free
+         zrhovacleo        ,  &  ! air density per wind speed per transfer coef.
+         zrhovacsho, zrhovaclei, zrhovacshi, & 
+         ztice3            ,  &  ! power 3 of ice temperature
+         zticemb, zticemb2 ,  &  ! tempory air temperatures variables
+         zdqlw_ice         ,  &  ! sensitivity of long-wave flux over ice
+         zdqsb_ice         ,  &  ! sensitivity of sensible heat flux over ice
+         zdqla_ice         ,  &  ! sensitivity of latent heat flux over ice
+         zdl, zdr                ! fractionnal part of latitude
+      REAL(wp), DIMENSION(jpi,jpj) :: & 
+         zpatm            ,  &   ! atmospheric pressure
+         zqatm            ,  &   ! specific humidity
+         zes              ,  &   ! vapour pressure at saturation
+         zev, zevsqr      ,  &   ! vapour pressure and his square-root
+         zrhoa            ,  &   ! air density
+         ztatm            ,  &   ! air temperature in Kelvins
+         zfrld            ,  &   ! fraction of sea ice cover 
+         zcatm1           ,  &   ! fraction of cloud
+         zcldeff                 ! correction factor to account cloud effect
+      REAL(wp), DIMENSION(jpi,jpj) ::   & 
+         zalbocsd         ,  &   ! albedo of ocean
+         zalboos          ,  &   ! albedo of ocean under overcast sky
+         zalbics          ,  &   ! albedo of ice under clear sky
+         zalbios          ,  &   ! albedo of ice under overcast sky
+         zalbomu          ,  &   ! albedo of ocean when zcmue is 0.4
+         zqsro            ,  &   ! solar radiation over ocean
+         zqsrics          ,  &   ! solar radiation over ice under clear sky
+         zqsrios          ,  &   ! solar radiation over ice under overcast sky
+         zcldcor          ,  &   ! cloud correction
+         zlsrise, zlsset  ,  &   ! sunrise and sunset
+         zlmunoon         ,  &   ! local noon solar altitude
+         zdlha            ,  &   ! length of the ninstr segments of the solar day
+         zps              ,  &   ! sine of latitude per sine of solar decli.
+         zpc                     ! cosine of latitude per cosine of solar decli. 
+
+      REAL(wp), DIMENSION(jpi,jpj) ::   & 
+         zqlw_oce         ,  &   ! long-wave heat flux over ocean
+         zqlw_ice         ,  &   ! long-wave heat flux over ice
+         zqla_oce         ,  &   ! latent heat flux over ocean
+         zqla_ice         ,  &   ! latent heat flux over ice
+         zqsb_oce         ,  &   ! sensible heat flux over ocean
+         zqsb_ice                ! sensible heat flux over ice
+ 
+      REAL(wp), DIMENSION(jpi,jpj,jpintsr) ::    &
+         zlha             ,  &   ! local hour angle
+         zalbocs          ,  &   ! tempory var. of ocean albedo under clear sky
+         zsqsro           ,  &   ! tempory var. of solar rad. over ocean 
+         zsqsrics         ,  &   ! temp. var. of solar rad. over ice under clear sky
+         zsqsrios                ! temp. var. of solar rad. over ice under overcast sky
+      !!---------------------------------------------------------------------
+
+      !---------------------
+      !   Initilization    !
+      !---------------------
+!#if ! defined key_lim2
+!      tn_ice(:,:) = psst(:,:)
+!#endif
+
+      !  Determine cloud optical depths as a function of latitude (Chou et al., 1981).
+      !  and the correction factor for taking into account  the effect of clouds 
+      !------------------------------------------------------
+      IF( lbulk_init ) THEN
+         DO jj = 1, jpj  
+            DO ji = 1 , jpi
+               zalat          = ( 90.e0 - ABS( gphit(ji,jj) ) ) /  5.e0
+               zclat          = ( 95.e0 -      gphit(ji,jj)   ) / 10.e0
+               indxb          = 1 + INT( zalat ) 
+               !  correction factor to account for the effect of clouds 
+               sbudyko(ji,jj) = budyko(indxb)  
+               indxc          = 1 + INT( zclat )  
+               zdl            = zclat - INT( zclat ) 
+               zdr            = 1.0 - zdl
+               stauc(ji,jj)   = zdr * tauco( indxc ) + zdl * tauco( indxc + 1 ) 
+            END DO
+         END DO
+         IF( nleapy == 1 ) THEN
+            yearday = 366.e0
+         ELSE IF( nleapy == 0 ) THEN
+            yearday = 365.e0
+         ELSEIF( nleapy == 30) THEN
+            yearday = 360.e0
+         ENDIF
+         lbulk_init = .FALSE.
+      ENDIF
+
+      zqlw_oce(:,:) = 0.e0
+      zqla_oce(:,:) = 0.e0
+      zqsb_oce(:,:) = 0.e0
+      zqlw_ice(:,:) = 0.e0
+      zqla_ice(:,:) = 0.e0
+      zqsb_ice(:,:) = 0.e0
+
+      zpis2       = rpi / 2.
+      z2pi        = 2. * rpi
+
+ !CDIR NOVERRCHK
+      DO jj = 1, jpj
+ !CDIR NOVERRCHK
+         DO ji = 1, jpi
+
+            ztatm (ji,jj) = 273.15 + tatm  (ji,jj)  !  air temperature in Kelvins 
+            zcatm1(ji,jj) = 1.0    - catm  (ji,jj)  !  fractional cloud cover
+            zfrld (ji,jj) = 1.0    - freeze(ji,jj)  !  fractional sea ice cover
+            zpatm(ji,jj)  = 101000.               !  pressure 
+      
+            !  Computation of air density, obtained from the equation of state for dry air. 
+            zrhoa(ji,jj) = zpatm(ji,jj) / ( 287.04 * ztatm(ji,jj) )
+      
+            !  zes : Saturation water vapour
+            ztamr = ztatm(ji,jj) - rtt
+            zmt1  = SIGN( 17.269, ztamr )
+            zmt2  = SIGN( 21.875, ztamr )
+            zmt3  = SIGN( 28.200, -ztamr )
+            zes(ji,jj) = 611.0 * EXP (  ABS( ztamr ) * MIN ( zmt1, zmt2 )   &
+               &                      / ( ztatm(ji,jj) - 35.86  + MAX( zzero, zmt3 ) ) )
+
+            !  zev : vapour pressure  (hatm is relative humidity)  
+            zev(ji,jj)   = hatm(ji,jj) * zes(ji,jj) 
+            !  square-root of vapour pressure
+!CDIR NOVERRCHK
+            zevsqr(ji,jj) = SQRT( zev(ji,jj) * 0.01 )
+            !  zqapb  : specific humidity 
+            zqatm(ji,jj) = 0.622 * zev(ji,jj) / ( zpatm(ji,jj) - 0.378 * zev(ji,jj) )
+
+
+            !----------------------------------------------------
+            !   Computation of snow precipitation (Ledley, 1985) |
+            !----------------------------------------------------
+
+            zmt1  =   253.0 - ztatm(ji,jj)
+            zmt2  = ( 272.0 - ztatm(ji,jj) ) / 38.0 
+            zmt3  = ( 281.0 - ztatm(ji,jj) ) / 18.0
+            zind1 = MAX( zzero, SIGN( zone, zmt1 ) )
+            zind2 = MAX( zzero, SIGN( zone, zmt2 ) )
+            zind3 = MAX( zzero, SIGN( zone, zmt3 ) )
+            ! total precipitation
+            tprecip(ji,jj) = watm(ji,jj)
+            ! solid  (snow) precipitation
+            sprecip(ji,jj) = tprecip(ji,jj) *       &
+               &             (           zind1      &
+               &               + ( 1.0 - zind1 ) * ( zind2 * ( 0.5 + zmt2 ) + ( 1.0 - zind2 ) *  zind3 * zmt3 ) ) 
+         END DO
+      END DO
+
+      !----------------------------------------------------------
+      !   Computation of albedo (need to calculates heat fluxes)|
+      !-----------------------------------------------------------
+      
+      CALL flx_blk_albedo_2( zalbios, zalboos, zalbics, zalbomu )
+
+      !-------------------------------------
+      !   Computation of solar irradiance. |
+      !----------------------------------------
+      indaet   = 1  
+      !  compution of the day of the year at which the fluxes have to be calculate 
+      !--The date corresponds to the middle of the time step.
+      zxday=nday_year + rdtbs2/rday
+
+      iday   = INT( zxday )
+
+      IF(ln_ctl) CALL prt_ctl_info('declin : iday ', ivar1=iday, clinfo2=' nfbulk= ', ivar2=nfbulk)
+
+      !   computation of the solar declination, his sine and his cosine
+      CALL flx_blk_declin_2( indaet, iday, zdecl )
+      
+      zdecl    = zdecl * rad
+      zsdecl   = SIN( zdecl )
+      zcdecl   = COS( zdecl )
+      
+      !  correction factor added for computation of shortwave flux to take into account the variation of
+      !  the distance between the sun and the earth during the year (Oberhuber 1988)
+      zdist    = zxday * z2pi / yearday
+      zdaycor  = 1.0 + 0.0013 * SIN( zdist ) + 0.0342 * COS( zdist )
+
+!CDIR NOVERRCHK
+      DO jj = 1, jpj
+!CDIR NOVERRCHK
+         DO ji = 1, jpi
+            !  product of sine of latitude and sine of solar declination
+            zps     (ji,jj) = SIN( gphit(ji,jj) * rad ) * zsdecl
+            !  product of cosine of latitude and cosine of solar declination
+            zpc     (ji,jj) = COS( gphit(ji,jj) * rad ) * zcdecl
+            !  computation of the both local time of sunrise and sunset
+            zlsrise (ji,jj) = ACOS( - SIGN( zone, zps(ji,jj) ) * MIN( zone, SIGN( zone, zps(ji,jj) )  &
+               &                     * ( zps(ji,jj) / zpc(ji,jj) ) ) ) 
+            zlsset  (ji,jj) = - zlsrise(ji,jj)
+            !  dividing the solar day into jpintsr segments of length zdlha
+            zdlha   (ji,jj) = ( zlsrise(ji,jj) - zlsset(ji,jj) ) / REAL( jpintsr )
+            !  computation of the local noon solar altitude
+            zlmunoon(ji,jj) = ASIN ( ( zps(ji,jj) + zpc(ji,jj) ) ) / rad
+            
+            !  cloud correction taken from Reed (1977) (imposed lower than 1)
+            zcldcor (ji,jj) = MIN( zone, ( 1.e0 - 0.62 * catm(ji,jj) + 0.0019 * zlmunoon(ji,jj) ) )
+         END DO
+      END DO
+
+         !  Computation of solar heat flux at each time of the day between sunrise and sunset. 
+         !  We do this to a better optimisation of the code 
+         !------------------------------------------------------       
+
+!CDIR NOVERRCHK   
+      DO jt = 1, jpintsr   
+         zcoef = FLOAT( jt ) - 0.5
+!CDIR NOVERRCHK     
+         DO jj = 1, jpj
+!CDIR NOVERRCHK
+            DO ji = 1, jpi
+               !  local hour angle
+               zlha (ji,jj,jt) = COS ( zlsrise(ji,jj) - zcoef * zdlha(ji,jj) )
+
+               ! cosine of local solar altitude
+               zcmue              = MAX ( zzero ,   zps(ji,jj) + zpc(ji,jj) * zlha (ji,jj,jt)  )
+               zcmue2             = 1368.0 * zcmue * zcmue
+               zscmue             = SQRT ( zcmue )
+               zpcmue             = zcmue**1.4
+               ! computation of sea-water albedo (Payne, 1972)
+               zalbocs(ji,jj,jt)  = 0.05 / ( 1.1 * zpcmue + 0.15 )
+               zalbo              = zcatm1(ji,jj) * zalbocs(ji,jj,jt) + catm(ji,jj) * zalboos(ji,jj)
+               ! solar heat flux absorbed at ocean surfaces (Zillman, 1972)
+               zevo               = zev(ji,jj) * 1.0e-05
+               zsqsro(ji,jj,jt)   =  ( 1.0 - zalbo ) * zdlha(ji,jj) * zcmue2                &
+                                   / ( ( zcmue + 2.7 ) * zevo + 1.085 * zcmue +  0.10 )
+               !  solar heat flux absorbed at sea/ice surfaces 
+               !  Formulation of Shine and Crane, 1984 adapted for high albedo surfaces 
+
+               !  For clear sky        
+               zevi               = zevo
+               zalbi              = zalbics(ji,jj)
+               zsqsrics(ji,jj,jt) =  ( 1.0 - zalbi ) * zdlha(ji,jj) * zcmue2                &
+                  &                / ( ( 1.0 + zcmue ) * zevi + 1.2 * zcmue + 0.0455 )
+
+               ! For overcast sky
+               zalbi              = zalbios(ji,jj)
+               zsqsrios(ji,jj,jt) = zdlha(ji,jj) *                                                           &
+                  &                 ( ( 53.5 + 1274.5 * zcmue      ) *  zscmue * ( 1.0 - 0.996  * zalbi ) )  &
+                  &                 / (  1.0 + 0.139  * stauc(ji,jj) *           ( 1.0 - 0.9435 * zalbi ) )
+            END DO
+         END DO
+      END DO
+
+
+      !  Computation of daily (between sunrise and sunset) solar heat flux absorbed 
+      !  at the ocean and snow/ice surfaces.
+      !--------------------------------------------------------------------
+
+      zalbocsd(:,:) = 0.e0
+      zqsro   (:,:) = 0.e0
+      zqsrics (:,:) = 0.e0
+      zqsrios (:,:) = 0.e0
+
+      DO jt = 1, jpintsr 
+#   if defined key_vectopt_loop 
+         DO ji = 1, jpij  
+            zalbocsd(ji,1) = zalbocsd(ji,1) + zdlha   (ji,1) * zalbocs(ji,1,jt)   &
+               &                                             / MAX( 2.0 * zlsrise(ji,1) , zeps0 )
+            zqsro   (ji,1) = zqsro   (ji,1) + zsqsro  (ji,1,jt)
+            zqsrics (ji,1) = zqsrics (ji,1) + zsqsrics(ji,1,jt)
+            zqsrios (ji,1) = zqsrios (ji,1) + zsqsrios(ji,1,jt)
+         END DO
+#  else
+         DO jj = 1, jpj
+            DO ji = 1, jpi  
+               zalbocsd(ji,jj) = zalbocsd(ji,jj) + zdlha(ji,jj) * zalbocs(ji,jj,jt)   &
+                  &                                              / MAX( 2.0 * zlsrise(ji,jj) , zeps0 )
+               zqsro  (ji,jj)  = zqsro   (ji,jj) + zsqsro  (ji,jj,jt)
+               zqsrics(ji,jj)  = zqsrics (ji,jj) + zsqsrics(ji,jj,jt)
+               zqsrios(ji,jj)  = zqsrios (ji,jj) + zsqsrios(ji,jj,jt)
+            END DO
+         END DO
+#  endif
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi 
+
+            !------------------------------------------- 
+            !  Computation of shortwave radiation.
+            !-------------------------------------------
+
+            ! the solar heat flux absorbed at ocean and snow/ice surfaces
+            !------------------------------------------------------------
+
+            ! For ocean
+            qsr_oce(ji,jj) = srgamma * zcldcor(ji,jj) * zqsro(ji,jj) / z2pi
+            zinda          = SIGN( zone , -( -0.5 - zfrld(ji,jj) ) )
+            zinda          = 1.0 - MAX( zzero , zinda )
+            qsr_oce(ji,jj) = ( 1.- zinda ) * qsr_oce(ji,jj)
+
+            ! For snow/ice 
+            qsr_ice(ji,jj) = ( zcatm1(ji,jj) * zqsrics(ji,jj) + catm(ji,jj) * zqsrios(ji,jj) ) / z2pi
+
+
+            ! Taking into account the ellipsity of the earth orbit
+            !-----------------------------------------------------
+
+            qsr_ice(ji,jj) = qsr_ice(ji,jj) * zdaycor
+            qsr_oce(ji,jj) = qsr_oce(ji,jj) * zdaycor
+
+            !  fraction of net shortwave radiation which is not absorbed in the 
+            !  thin surface layer and penetrates inside the ice cover 
+            !  ( Maykut and Untersteiner, 1971 ; Elbert anbd Curry, 1993 )
+            !------------------------------------------------------------------
+
+            fr1_i0(ji,jj) = 0.18  * zcatm1(ji,jj) + 0.35 * catm(ji,jj) 
+            fr2_i0(ji,jj) = 0.82  * zcatm1(ji,jj) + 0.65 * catm(ji,jj)
+
+            !---------------------------------------------------------------------------
+            !   Computation of long-wave radiation  ( Berliand 1952 ; all latitudes )
+            !---------------------------------------------------------------------------
+
+            ! tempory variables
+            ztatm3         = ztatm(ji,jj) * ztatm(ji,jj) * ztatm(ji,jj)
+            ztatm4         = ztatm3 * ztatm(ji,jj)
+            z4tatm3        = 4. * ztatm3
+            zcldeff(ji,jj) = 1.0 - sbudyko(ji,jj) * catm(ji,jj) * catm(ji,jj)    
+            ztaevbk        = ztatm4 * zcldeff(ji,jj) * ( 0.39 - 0.05 * zevsqr(ji,jj) ) 
+
+            !  Long-Wave for Ice
+            !----------------------
+            zqlw_ice(ji,jj) = - emic * stefan * ( ztaevbk + z4tatm3 * ( tn_ice(ji,jj) - ztatm(ji,jj) ) ) 
+
+            !  Long-Wave for Ocean
+            !-----------------------
+            zqlw_oce(ji,jj) = - emic * stefan * ( ztaevbk + z4tatm3 * ( psst  (ji,jj) - ztatm(ji,jj) ) ) 
+
+         END DO
+      END DO
+
+      !----------------------------------------
+      !  Computation of turbulent heat fluxes  ( Latent and sensible ) 
+      !----------------------------------------        
+      !CDIR NOVERRCHK
+      DO jj = 2 , jpjm1
+!ib   DO jj = 1 , jpj
+         !CDIR NOVERRCHK
+         DO  ji = 1, jpi
+
+            !  Turbulent heat fluxes over water
+            !----------------------------------
+
+            ! zeso     : vapour pressure at saturation of ocean
+            ! zqsato   : humidity close to the ocean surface (at saturation)
+            zeso          =  611.0 * EXP ( 17.2693884 * ( psst(ji,jj) - rtt ) * tmask(ji,jj,1) / ( psst(ji,jj) - 35.86 ) )
+            zqsato        = ( 0.622 * zeso ) / ( zpatm(ji,jj) - 0.378 * zeso )
+
+            !  Drag coefficients from Large and Pond (1981,1982)
+            !---------------------------------------------------
+    
+            !  Stability parameters
+            zdteta         = psst(ji,jj) - ztatm(ji,jj)
+            zdeltaq        = zqatm(ji,jj) - zqsato
+            ztvmoy         = ztatm(ji,jj) * ( 1. + 2.2e-3 * ztatm(ji,jj) * zqatm(ji,jj) )
+            zdenum         = MAX( vatm(ji,jj) * vatm(ji,jj) * ztvmoy, zeps )
+!i
+!i          if( zdenum == 0.e0 ) then
+!i               write(numout,*) 'flxblk  zdenum=0 ', ji,jj
+!i               zdenum = zeps
+!i          endif
+!i
+            zdtetar        = zdteta / zdenum
+            ztvmoyr        = ztvmoy * ztvmoy * zdeltaq / zdenum
+            
+            ! For stable atmospheric conditions
+            zobouks        = -70.0 * 10. * ( zdtetar + 3.2e-3 * ztvmoyr )
+            zobouks        = MAX( zzero , zobouks )
+            zpsims         = -7.0 * zobouks
+            zpsihs         =  zpsims
+            zpsils         =  zpsims
+
+            !  For unstable atmospheric conditions
+            zobouku        = -100.0 * 10.0 * ( zdtetar + 2.2e-3 * ztvmoyr )
+            zobouku        = MIN( zzero , zobouku )
+            zxins          = ( 1. - 16. * zobouku )**0.25
+            zlxins         = LOG( ( 1. + zxins * zxins ) / 2. )
+            zpsimu         = 2. * LOG( ( 1 + zxins ) / 2. )  + zlxins - 2. * ATAN( zxins ) + zpis2
+            zpsihu         = 2. * zlxins
+            zpsilu         = zpsihu
+
+            ! computation of intermediate values
+            zstab          = MAX( zzero , SIGN( zone , zdteta ) )
+            zpsim          = zstab * zpsimu + (1.0 - zstab ) * zpsims
+            zpsih          = zstab * zpsihu + (1.0 - zstab ) * zpsihs
+            zpsil          = zpsih
+            
+            zvatmg         = MAX( 0.032 * 1.5e-3 * vatm(ji,jj) * vatm(ji,jj) / grav, zeps )
+!i
+!!          if( zvatmg == 0.e0 ) then
+!!               write(numout,*) 'flxblk  zvatmg=0 ', ji,jj
+!!               zvatmg = zeps
+!!          endif
+!i
+
+            zcmn           = vkarmn / LOG ( 10. / zvatmg )
+            zcmn2          = zcmn * zcmn
+            zchn           = 0.0327 * zcmn
+            zcln           = 0.0346 * zcmn
+            zcmcmn         = 1 / ( 1 - zcmn * zpsim / vkarmn )
+            zchcm          = zcmcmn / ( 1 - zchn * zpsih / ( vkarmn * zcmn ) )
+            zclcm          = zchcm
+
+
+            !  Transfer cofficient zcsho and zcleo over ocean according to Large and Pond (1981,1982)
+            !-------------------------------------------------------------- 
+            zcsho          = zchn * zchcm
+            zcleo          = zcln * zclcm 
+
+
+            !   Computation of sensible and latent fluxes over Ocean 
+            !----------------------------------------------------------------
+
+            !  computation of intermediate values
+            zrhova         = zrhoa(ji,jj) * vatm(ji,jj)
+            zrhovacsho     = zrhova * zcsho
+            zrhovacleo     = zrhova * zcleo
+
+            ! sensible heat flux
+            zqsb_oce(ji,jj) = zrhovacsho * 1004.0  * ( psst(ji,jj) - ztatm(ji,jj) )  
+         
+            !  latent heat flux 
+            zqla_oce(ji,jj) = MAX(0.e0, zrhovacleo * 2.5e+06 * ( zqsato      - zqatm(ji,jj) ) )
+               
+            !  Calculate evaporation over water. (kg/m2/s)
+            !-------------------------------------------------
+            evap(ji,jj)    = zqla_oce(ji,jj) / cevap
+               
+               
+            !  Turbulent heat fluxes over snow/ice.
+            !--------------------------------------------------
+            
+            !  zesi     : vapour pressure at saturation of ice
+            !  zqsati   : humidity close to the ice surface (at saturation)
+            zesi           =  611.0 * EXP ( 21.8745587 * tmask(ji,jj,1)   &   ! tmask needed to avoid overflow in the exponential
+               &                                       * ( tn_ice(ji,jj) - rtt ) / ( tn_ice(ji,jj) - 7.66 ) )
+            zqsati         = ( 0.622 * zesi ) / ( zpatm(ji,jj) - 0.378 * zesi )
+               
+            !  computation of intermediate values
+            zticemb        = ( tn_ice(ji,jj) - 7.66 )
+            zticemb2       = zticemb * zticemb  
+            ztice3         = tn_ice(ji,jj) * tn_ice(ji,jj) * tn_ice(ji,jj)
+            zqsati2        = zqsati * zqsati
+            zesi2          = zesi * zesi
+            zdesidt        = zesi * ( 9.5 * LOG( 10.0 ) * ( rtt - 7.66 )  / zticemb2 )
+               
+            !  Transfer cofficient zcshi and zclei over ice. Assumed to be constant Parkinson 1979 ; Maykut 1982
+            !--------------------------------------------------------------------
+            zcshi          = 1.75e-03
+            zclei          = zcshi
+               
+            !  Computation of sensible and latent fluxes over ice
+            !----------------------------------------------------------------
+               
+            !  computation of intermediate values
+            zrhova          = zrhoa(ji,jj) * vatm(ji,jj)
+            zrhovacshi      = zrhova * zcshi * 2.834e+06
+            zrhovaclei      = zrhova * zclei * 1004.0
+            
+            !  sensible heat flux
+            zqsb_ice(ji,jj) = zrhovaclei * ( tn_ice(ji,jj) - ztatm(ji,jj) )
+            
+            !  latent heat flux 
+            zqla_ice(ji,jj) = zrhovacshi * ( zqsati        - zqatm(ji,jj) )
+            qla_ice (ji,jj) = MAX(0.e0, zqla_ice(ji,jj) )
+              
+            !  Computation of sensitivity of non solar fluxes (dQ/dT)
+            !---------------------------------------------------------------
+               
+            !  computation of long-wave, sensible and latent flux sensitivity
+            zdqlw_ice       = 4.0 * emic * stefan * ztice3
+            zdqsb_ice       = zrhovaclei
+            zdqla_ice       = zrhovacshi * ( zdesidt * ( zqsati2 / zesi2 ) * ( zpatm(ji,jj) / 0.622 ) )         
+            
+            !  total non solar sensitivity
+            dqns_ice(ji,jj) = -( zdqlw_ice + zdqsb_ice + zdqla_ice ) 
+            
+            ! latent flux sensitivity
+            dqla_ice(ji,jj) = zdqla_ice
+            
+         END DO
+      END DO
+
+      ! total non solar heat flux over ice
+      qnsr_ice(:,:) = zqlw_ice(:,:) - zqsb_ice(:,:) - zqla_ice(:,:)
+      ! total non solar heat flux over water 
+      qnsr_oce(:,:) = zqlw_oce(:,:) - zqsb_oce(:,:) - zqla_oce(:,:)
+
+      ! solid precipitations ( kg/m2/day -> kg/m2/s)
+      tprecip(:,:) = tprecip  (:,:) / rday 
+      ! snow  precipitations ( kg/m2/day -> kg/m2/s)
+      sprecip(:,:) = sprecip  (:,:) / rday  
+!i
+      CALL lbc_lnk( qsr_oce (:,:) , 'T', 1. )
+      CALL lbc_lnk( qnsr_oce(:,:) , 'T', 1. )
+      CALL lbc_lnk( qsr_ice (:,:) , 'T', 1. )
+      CALL lbc_lnk( qnsr_ice(:,:) , 'T', 1. )
+      CALL lbc_lnk( qla_ice (:,:) , 'T', 1. )
+      CALL lbc_lnk( dqns_ice(:,:) , 'T', 1. )
+      CALL lbc_lnk( dqla_ice(:,:) , 'T', 1. )
+      CALL lbc_lnk( fr1_i0  (:,:) , 'T', 1. )
+      CALL lbc_lnk( fr2_i0  (:,:) , 'T', 1. )
+      CALL lbc_lnk( tprecip (:,:) , 'T', 1. )
+      CALL lbc_lnk( sprecip (:,:) , 'T', 1. )
+      CALL lbc_lnk( evap    (:,:) , 'T', 1. )
+!i
+!i
+      qsr_oce (:,:) = qsr_oce (:,:)*tmask(:,:,1)
+      qnsr_oce(:,:) = qnsr_oce(:,:)*tmask(:,:,1)
+      qsr_ice (:,:) = qsr_ice (:,:)*tmask(:,:,1)
+      qnsr_ice(:,:) = qnsr_ice(:,:)*tmask(:,:,1)
+      qla_ice (:,:) = qla_ice (:,:)*tmask(:,:,1)
+      dqns_ice(:,:) = dqns_ice(:,:)*tmask(:,:,1)
+      dqla_ice(:,:) = dqla_ice(:,:)*tmask(:,:,1)
+      fr1_i0  (:,:) = fr1_i0  (:,:)*tmask(:,:,1)
+      fr2_i0  (:,:) = fr2_i0  (:,:)*tmask(:,:,1)
+      tprecip (:,:) = tprecip (:,:)*tmask(:,:,1)
+      sprecip (:,:) = sprecip (:,:)*tmask(:,:,1)
+      evap    (:,:) = evap    (:,:)*tmask(:,:,1)
+!i
+
+   END SUBROUTINE flx_blk_2
+
+
+   SUBROUTINE flx_blk_declin_2( ky, kday, pdecl )
+      !!---------------------------------------------------------------------------
+      !!               ***  ROUTINE flx_blk_declin  ***
+      !!          
+      !! ** Purpose :   Computation of the solar declination for the day
+      !!	        kday ( in decimal degrees ).
+      !!       
+      !! ** Method  :
+      !!
+      !! History :
+      !!         original    : 01-04 (LIM)
+      !!         addition    : 02-08 (C. Ethe, G. Madec)
+      !!---------------------------------------------------------------------
+      !! * Arguments
+      INTEGER, INTENT( in ) ::   &
+         ky  ,        &  ! = -1, 0, 1 for odd, normal and leap years resp.
+         kday            ! day of the year ( kday = 1 on january 1)
+      REAL(wp), INTENT(out) ::  &
+         pdecl            ! solar declination
+
+      !! * Local variables
+      REAL(wp) ::                & 
+         zday                ,   &  ! corresponding day of type year (cf. ky)
+         zp1, zp2, zp3, zp4         ! temporary scalars
+      !!---------------------------------------------------------------------
+      
+      zday = FLOAT( kday ) 
+      
+      IF( ky == 1 )  THEN 
+         zday = zday - 0.5
+      ELSEIF( ky == 3 )  THEN
+         zday = zday - 1.
+      ELSE 
+         zday = REAL( kday )
+      ENDIF
+      
+      zp1 = rpi * ( 2.0 * zday - 367.0 ) / yearday
+      zp2 = 2. * zp1
+      zp3 = 3. * zp1
+      zp4 = 4. * zp1
+      
+      pdecl  = a0                                                                      &
+         &   + a1 * COS( zp1 ) + a2 * COS( zp2 ) + a3 * COS( zp3 ) + a4 * COS( zp4 )   &
+         &   + b1 * SIN( zp1 ) + b2 * SIN( zp2 ) + b3 * SIN( zp3 ) + b4 * SIN( zp4 )
+      
+   END SUBROUTINE flx_blk_declin_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :           Empty module                     NO bulk
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE flx_blk_2(psst)            ! Empty routine
+   USE par_oce 
+   USE in_out_manager
+      REAL(wp), INTENT( in ), DIMENSION(jpi,jpj) ::   &
+         &                          psst      
+    WRITE(numout,*) MAXVAL(psst)
+   END SUBROUTINE flx_blk_2
+#endif
+
+   !!======================================================================
+END MODULE flxblk_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/ice_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/ice_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/ice_2.F90	(revision 823)
@@ -0,0 +1,130 @@
+MODULE ice_2
+   !!======================================================================
+   !!                        ***  MODULE ice  ***
+   !! Sea Ice physics:  diagnostics variables of ice defined in memory
+   !!=====================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !! History :
+   !!   2.0  !  03-08  (C. Ethe)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   !!  LIM 2.0, UCL-LOCEAN-IPSL (2005)
+   !! $Header$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_ice_2          ! LIM sea-ice parameters
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Share Module variables
+   INTEGER , PUBLIC ::   & !!: ** ice-dynamic namelist (namicedyn) **
+      nbiter = 1      ,  &  !: number of sub-time steps for relaxation
+      nbitdr = 250          !: maximum number of iterations for relaxation
+
+   REAL(wp), PUBLIC ::   & !!: ** ice-dynamic namelist (namicedyn) **
+      epsd   = 1.0e-20,  &  !: tolerance parameter for dynamic
+      alpha  = 0.5    ,  &  !: coefficient for semi-implicit coriolis
+      dm     = 0.6e+03,  &  !: diffusion constant for dynamics
+      om     = 0.5    ,  &  !: relaxation constant
+      resl   = 5.0e-05,  &  !: maximum value for the residual of relaxation
+      cw     = 5.0e-03,  &  !: drag coefficient for oceanic stress
+      angvg  = 0.e0   ,  &  !: turning angle for oceanic stress
+      pstar  = 1.0e+04,  &  !: first bulk-rheology parameter
+      c_rhg  = 20.e0  ,  &  !: second bulk-rhelogy parameter
+      etamn  = 0.e+07,   &  !: minimun value for viscosity
+      creepl = 2.e-08,   &  !: creep limit
+      ecc    = 2.e0   ,  &  !: eccentricity of the elliptical yield curve
+      ahi0   = 350.e0       !: sea-ice hor. eddy diffusivity coeff. (m2/s)
+
+   REAL(wp), PUBLIC ::   &  !:
+      usecc2          ,  &  !:  = 1.0 / ( ecc * ecc )
+      rhoco           ,  &  !: = rau0 * cw
+      sangvg, cangvg  ,  &  !: sin and cos of the turning angle for ocean stress
+      pstarh                !: pstar / 2.0
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  &  !:
+      u_oce, v_oce,      &  !: surface ocean velocity used in ice dynamics
+      ahiu , ahiv ,      &  !: hor. diffusivity coeff. at ocean U- and V-points (m2/s)
+      pahu , pahv ,      &  !: ice hor. eddy diffusivity coef. at ocean U- and V-points
+      hsnm , hicm ,      &  !: mean snow and ice thicknesses
+      ust2s                 !: friction velocity
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::  &  !:
+        sst_ini,         &  !: sst read from a file for ice model initialization 
+        sss_ini             !: sss read from a file for ice model initialization 
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
+      firic  ,   &  !: IR flux over the ice (only used for outputs)
+      fcsic  ,   &  !: Sensible heat flux over the ice (only used for outputs)
+      fleic  ,   &  !: Latent heat flux over the ice (only used for outputs)
+      qlatic ,   &  !: latent flux
+      rdvosif,   &  !: Variation of volume at surface (only used for outputs)
+      rdvobif,   &  !: Variation of ice volume at the bottom ice (only used for outputs)
+      fdvolif,   &  !: Total variation of ice volume (only used for outputs)
+      rdvonif,   &  !: Lateral Variation of ice volume (only used for outputs)
+      sist   ,   &  !: Sea-Ice Surface Temperature (Kelvin ??? degree ??? I don't know)
+      tfu    ,   &  !: Melting point temperature of sea water
+      hsnif  ,   &  !: Snow thickness
+      hicif  ,   &  !: Ice thickness
+      hicifp ,   &  !: Ice production/melting
+      frld   ,   &  !: Leads fraction = 1-a/totalarea
+      phicif ,   &  !: ice thickness  at previous time 
+      pfrld  ,   &  !: Leads fraction at previous time  
+      qstoif ,   &  !: Energy stored in the brine pockets
+      fbif   ,   &  !: Heat flux at the ice base
+      rdmsnif,   &  !: Variation of snow mass
+      rdmicif,   &  !: Variation of ice mass
+      qldif  ,   &  !: heat balance of the lead (or of the open ocean)
+      qcmif  ,   &  !: Energy needed to bring the ocean surface layer until its freezing 
+      fdtcn  ,   &  !: net downward heat flux from the ice to the ocean
+      qdtcn  ,   &  !: energy from the ice to the ocean
+      !             !  point (at a factor 2)
+      thcm   ,   &  !: part of the solar energy used in the lead heat budget
+      fstric ,   &  !: Solar flux transmitted trough the ice
+      ffltbif,   &  !: Array linked with the max heat contained in brine pockets (?)
+      fscmbq ,   &  !: Linked with the solar flux below the ice (?)
+      fsbbq  ,   &  !: Also linked with the solar flux below the ice (?)
+      qfvbq  ,   &  !: Array used to store energy in case of toral lateral ablation (?)
+      dmgwi         !: Variation of the mass of snow ice
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
+      albege ,   &  !: Albedo of the snow or ice (only for outputs)
+      albecn ,   &  !: Albedo of the ocean (only for outputs)
+      tauc   ,   &  !: Cloud optical depth
+      sdvt          !: u*^2/(Stress/density)
+
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
+      u_ice, v_ice,   &  !: two components of the ice velocity (m/s)
+      tio_u, tio_v       !: two components of the ice-ocean stress (N/m2)
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpsmax) ::   &  !:
+      scal0              !: ???
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jplayersp1) ::   &  !:
+      tbif          !: Temperature inside the ice/snow layer
+
+   REAL(wp), DIMENSION(jpi,jpj,0:jpkmax+1) ::    &  !:
+      reslum        !: Relative absorption of solar radiation in each ocean level
+
+   REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   &  !:
+         sxice, syice, sxxice, syyice, sxyice,      &  !: moments for advection
+         sxsn,  sysn,  sxxsn,  syysn,  sxysn,       &  !:
+         sxa,   sya,   sxxa,   syya,   sxya,        &  !:
+         sxc0,  syc0,  sxxc0,  syyc0,  sxyc0,       &  !:
+         sxc1,  syc1,  sxxc1,  syyc1,  sxyc1,       &  !:
+         sxc2,  syc2,  sxxc2,  syyc2,  sxyc2,       &  !:
+         sxst,  syst,  sxxst,  syyst,  sxyst           !:
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty module        NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE ice_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/iceini_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/iceini_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/iceini_2.F90	(revision 823)
@@ -0,0 +1,132 @@
+MODULE iceini_2
+   !!======================================================================
+   !!                       ***  MODULE iceini   ***
+   !!   Sea-ice model : LIM 2.0 Sea ice model Initialization
+   !!======================================================================
+   !! History :   1.0  !  02-08  (G. Madec)  F90: Free form and modules
+   !!             2.0  !  03-08  (C. Ethe)  add ice_run
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   ice_init_2       : sea-ice model initialization
+   !!   ice_run_2        : Definition some run parameter for ice model
+   !!----------------------------------------------------------------------
+   USE dom_oce
+   USE dom_ice_2
+   USE in_out_manager
+   USE ice_oce         ! ice variables
+   USE flx_oce
+   USE phycst          ! Define parameters for the routines
+   USE ocfzpt
+   USE ice_2
+   USE limmsh_2
+   USE limistate_2
+   USE limrst_2   
+   USE ini1d           ! initialization of the 1D configuration
+      
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ice_init_2               ! called by opa.F90
+
+   LOGICAL , PUBLIC               ::   ln_limdyn = .TRUE.   !: flag for ice dynamics (T) or not (F)
+   REAL(wp), PUBLIC               ::   hsndif = 0.e0        !: computation of temp. in snow (0) or not (9999)
+   REAL(wp), PUBLIC               ::   hicdif = 0.e0        !: computation of temp. in ice (0) or not (9999)
+   REAL(wp), PUBLIC, DIMENSION(2) ::   acrit  = (/ 1.e-06 , 1.e-06 /)    !: minimum fraction for leads in 
+      !                                                                  !  north and south hemisphere
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ice_init_2
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ice_init_2  ***
+      !!
+      !! ** purpose :   
+      !!----------------------------------------------------------------------
+      CHARACTER(len=80) :: namelist_icename
+      !!----------------------------------------------------------------------
+      !
+      ! Open the namelist file 
+      namelist_icename = 'namelist_ice'
+      CALL ctlopn(numnam_ice,namelist_icename,'OLD', 'FORMATTED', 'SEQUENTIAL',   &
+                     1,numout,.FALSE.,1)      
+      CALL ice_run_2                    !  read in namelist some run parameters
+                 
+      ! Louvain la Neuve Ice model
+      IF( nacc == 1 ) THEN
+          dtsd2   = nfice * rdtmin * 0.5
+          rdt_ice = nfice * rdtmin
+      ELSE
+          dtsd2   = nfice * rdt * 0.5
+          rdt_ice = nfice * rdt
+      ENDIF
+
+      CALL lim_msh_2                  ! ice mesh initialization
+     
+      ! Initial sea-ice state
+      IF( .NOT.ln_rstart ) THEN
+         CALL lim_istate_2            ! start from rest: sea-ice deduced from sst
+      ELSE
+         CALL lim_rst_read_2          ! start from a restart file
+      ENDIF
+      
+      tn_ice(:,:) = sist(:,:)         ! initialisation of ice temperature   
+      freeze(:,:) = 1.0 - frld(:,:)   ! initialisation of sea/ice cover    
+# if defined key_coupled
+      alb_ice(:,:) = albege(:,:)      ! sea-ice albedo
+# endif
+      !
+   END SUBROUTINE ice_init_2
+
+
+   SUBROUTINE ice_run_2
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE ice_run_2 ***
+      !!                 
+      !! ** Purpose :   Definition some run parameter for ice model
+      !!
+      !! ** Method  :   Read the namicerun namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicerun
+      !!-------------------------------------------------------------------
+      NAMELIST/namicerun/ ln_limdyn, ln_limdmp, acrit, hsndif, hicdif
+      !!-------------------------------------------------------------------
+      !                    
+      REWIND ( numnam_ice )                       ! Read Namelist namicerun 
+      READ   ( numnam_ice , namicerun )
+
+      IF( lk_cfg_1d  )   ln_limdyn = .FALSE.      ! No ice transport in 1D configuration
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'ice_run : ice share parameters for dynamics/advection/thermo of sea-ice'
+         WRITE(numout,*) ' ~~~~~~'
+         WRITE(numout,*) '   switch for ice dynamics (1) or not (0)      ln_limdyn   = ', ln_limdyn
+         WRITE(numout,*) '   Ice damping                                 ln_limdmp   = ', ln_limdmp
+         WRITE(numout,*) '   minimum fraction for leads in the NH (SH)  acrit(1/2)   = ', acrit(:)
+         WRITE(numout,*) '   computation of temp. in snow (=0) or not (=9999) hsndif = ', hsndif
+         WRITE(numout,*) '   computation of temp. in ice  (=0) or not (=9999) hicdif = ', hicdif
+      ENDIF
+      !
+   END SUBROUTINE ice_run_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :        Empty module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE ice_init_2      ! Empty routine
+   END SUBROUTINE ice_init_2
+#endif
+
+   !!======================================================================
+END MODULE iceini_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/icestp_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/icestp_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/icestp_2.F90	(revision 823)
@@ -0,0 +1,286 @@
+MODULE icestp_2
+   !!======================================================================
+   !!                       ***  MODULE icestp_2   ***
+   !!   Sea-Ice model : LIM Sea ice model time-stepping
+   !!======================================================================
+   !! History :   1.0  !  99-11  (M. Imbard)  Original code
+   !!        !  01-03  (D. Ludicone, E. Durand, G. Madec) free surf.
+   !!   2.0  !  02-09  (G. Madec, C. Ethe)  F90: Free form and module
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   ice_stp_2       : sea-ice model time-stepping
+   !!----------------------------------------------------------------------
+   USE dom_oce
+   USE oce  ! dynamics and tracers variables
+   USE in_out_manager
+   USE ice_oce         ! ice variables
+   USE flx_oce         ! forcings variables
+   USE dom_ice_2
+   USE cpl_oce
+   USE daymod
+   USE phycst          ! Define parameters for the routines
+   USE taumod
+   USE ice_2
+   USE ocesbc
+   USE lbclnk
+   USE limdyn_2
+   USE limtrp_2
+   USE limthd_2
+   USE limflx_2
+   USE limdia_2
+   USE limwri_2
+   USE limrst_2
+   USE limdmp_2        ! Ice damping
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ice_stp_2  ! called by step.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!-----------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!-----------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE ice_stp_2 ( kt )
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE ice_stp_2  ***
+      !!                   
+      !! ** Purpose :   Louvain la Neuve Sea Ice Model time stepping 
+      !!
+      !! ** Action  : - call the ice dynamics routine 
+      !!              - call the ice advection/diffusion routine 
+      !!              - call the ice thermodynamics routine 
+      !!              - call the routine that computes mass and 
+      !!                heat fluxes at the ice/ocean interface
+      !!              - save the outputs 
+      !!              - save the outputs for restart when necessary
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)          ::   kt       ! ocean time-step index
+
+      INTEGER                      ::   ji, jj   ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj) ::   zsss_io, zsss2_io, zsss3_io          ! tempory workspaces
+      !!----------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF( lk_cpl ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'ice_stp : Louvain la Neuve Ice Model (LIM)'
+            IF(lwp) WRITE(numout,*) '~~~~~~~   coupled case'
+         ELSE
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'ice_stp : Louvain la Neuve Ice Model (LIM)' 
+            IF(lwp) WRITE(numout,*) '~~~~~~~   forced case using bulk formulea'
+         ENDIF
+         !  Initialize fluxes fields
+         gtaux(:,:) = 0.e0
+         gtauy(:,:) = 0.e0
+      ENDIF
+
+      ! Temperature , salinity and horizonta wind
+      ! sst_io  and sss_io, u_io and v_io  are initialized at nit000 in limistate.F90 (or limrst.F90) with :
+      !              sst_io = sst_io + (nfice - 1) * (tn(:,:,1)+rt0 )
+      !              sss_io = sss_io + (nfice - 1) * sn(:,:,1)
+      !              u_io  = u_io  + (nfice - 1) * 0.5 * ( un(ji-1,jj  ,1) + un(ji-1,jj-1,1) )
+      !              v_io  = v_io  + (nfice - 1) * 0.5 * ( vn(ji  ,jj-1,1) + vn(ji-1,jj-1,1) )
+      !    cumulate fields
+      !
+      sst_io(:,:) = sst_io(:,:) + tn(:,:,1) + rt0
+      sss_io(:,:) = sss_io(:,:) + sn(:,:,1)
+
+ 
+      ! vectors at F-point
+      DO jj = 2, jpj
+         DO ji = fs_2, jpi   ! vector opt.
+            u_io(ji,jj) = u_io(ji,jj) + 0.5 * ( un(ji-1,jj  ,1) + un(ji-1,jj-1,1) )
+            v_io(ji,jj) = v_io(ji,jj) + 0.5 * ( vn(ji  ,jj-1,1) + vn(ji-1,jj-1,1) )
+         END DO
+      END DO
+      
+      
+      IF( MOD( kt-1, nfice ) == 0 ) THEN
+         
+         ! The LIM model is going to be call
+         sst_io(:,:) = sst_io(:,:) / FLOAT( nfice ) * tmask(:,:,1)
+         sss_io(:,:) = sss_io(:,:) / FLOAT( nfice )
+
+         ! stress from ocean U- and V-points to ice U,V point
+         DO jj = 2, jpj
+            DO ji = fs_2, jpi   ! vector opt.
+               gtaux(ji,jj) = 0.5 * ( taux(ji-1,jj  ) + taux(ji-1,jj-1) )
+               gtauy(ji,jj) = 0.5 * ( tauy(ji  ,jj-1) + tauy(ji-1,jj-1) )
+               u_io  (ji,jj) = u_io(ji,jj) / FLOAT( nfice )
+               v_io  (ji,jj) = v_io(ji,jj) / FLOAT( nfice )
+            END DO
+         END DO
+
+         ! lateral boundary condition
+         CALL lbc_lnk( gtaux(:,:), 'I', -1. )   ! I-point (i.e. ice U-V point)
+         CALL lbc_lnk( gtauy(:,:), 'I', -1. )   ! I-point (i.e. ice U-V point)
+         CALL lbc_lnk( u_io (:,:), 'I', -1. )   ! I-point (i.e. ice U-V point)
+         CALL lbc_lnk( v_io (:,:), 'I', -1. )   ! I-point (i.e. ice U-V point)
+
+!!gmbug  in the ocean freezing point computed as :
+!!gm           fzptn (ji,jj) = ( -0.0575 + 1.710523e-3 * SQRT( sn(ji,jj,1) )   &
+!!gm                                     - 2.154996e-4 *       sn(ji,jj,1)   ) * sn(ji,jj,1)   !!   &
+!!gm           !!                        - 7.53e-4 * pressure
+!!gm
+!!gm!bug this is much more accurate and efficient computation
+!!gm       **************************************************
+!!gm freezing point from unesco:
+!!gm     real function tf(s,p)
+!!gm   function to compute the freezing point of seawater
+!!gm
+!!gm   reference: unesco tech. papers in the marine science no. 28. 1978
+!!gm   eighth report jpots
+!!gm   annex 6 freezing point of seawater f.j. millero pp.29-35.
+!!gm
+!!gm  units:
+!!gm         pressure      p          decibars
+!!gm         salinity      s          pss-78
+!!gm         temperature   tf         degrees celsius
+!!gm         freezing pt.
+!!gm************************************************************
+!!gm  checkvalue: tf= -2.588567 deg. c for s=40.0, p=500. decibars
+!!gm     tf=(-.0575+1.710523e-3*sqrt(abs(s))-2.154996e-4*s)*s-7.53e-4*p
+!!gm     return
+!!gm     end
+!!gm!bug
+
+
+!!gm      DO jj = 1, jpj
+!!gm         DO ji = 1, jpi
+!!gm            tfu(ji,jj)  = (  rt0 + ( - 0.0575                              &
+!!gm               &                     + 1.710523e-3 * SQRT( sss_io(ji,jj) )   &
+!!gm               &                     - 2.154996e-4 *       sss_io(ji,jj)   ) * sss_io(ji,jj)  ) * tms(ji,jj)
+!!gm         END DO
+!!gm      END DO
+!!gm
+      zsss_io (:,:) = SQRT( sss_io(:,:) ) 
+      zsss2_io(:,:) =  sss_io(:,:) *  sss_io(:,:)
+      zsss3_io(:,:) = zsss_io(:,:) * zsss_io(:,:) * zsss_io(:,:)
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            tfu(ji,jj)  = ABS ( rt0 - 0.0575       *   sss_io(ji,jj)   &
+               &                    + 1.710523e-03 * zsss3_io(ji,jj)   &
+               &                    - 2.154996e-04 * zsss2_io(ji,jj) ) * tms(ji,jj)
+         END DO
+      END DO
+   
+         
+
+         IF(ln_ctl) THEN         ! print mean trends (used for debugging)
+            CALL prt_ctl_info('Ice Forcings ')
+            CALL prt_ctl(tab2d_1=qsr_oce ,clinfo1=' qsr_oce  : ', tab2d_2=qsr_ice , clinfo2=' qsr_ice   : ')
+            CALL prt_ctl(tab2d_1=qnsr_oce,clinfo1=' qnsr_oce : ', tab2d_2=qnsr_ice, clinfo2=' qnsr_ice  : ')
+            CALL prt_ctl(tab2d_1=evap    ,clinfo1=' evap     : ')
+            CALL prt_ctl(tab2d_1=tprecip ,clinfo1=' precip   : ', tab2d_2=sprecip , clinfo2=' Snow      : ')
+            CALL prt_ctl(tab2d_1=gtaux   ,clinfo1=' u-stress : ', tab2d_2=gtauy   , clinfo2=' v-stress  : ')
+            CALL prt_ctl(tab2d_1=sst_io  ,clinfo1=' sst      : ', tab2d_2=sss_io  , clinfo2=' sss       : ')
+            CALL prt_ctl(tab2d_1=u_io    ,clinfo1=' u_io     : ', tab2d_2=v_io    , clinfo2=' v_io      : ')
+            CALL prt_ctl(tab2d_1=hsnif   ,clinfo1=' hsnif  1 : ', tab2d_2=hicif   , clinfo2=' hicif     : ')
+            CALL prt_ctl(tab2d_1=frld    ,clinfo1=' frld   1 : ', tab2d_2=sist    , clinfo2=' sist      : ')
+         ENDIF
+
+         !                                                           !-----------------------!
+         CALL lim_rst_opn_2( kt )                                    ! Open Ice restart file !
+         !                                                           !-----------------------!
+
+         !                                                           !--------------!
+         CALL lim_dyn_2( kt )                                        ! Ice dynamics !   ( rheology/dynamics )
+         !                                                           !--------------!
+         IF(ln_ctl) THEN
+            CALL prt_ctl(tab2d_1=hsnif ,clinfo1=' hsnif  2 : ', tab2d_2=hicif , clinfo2=' hicif     : ')
+            CALL prt_ctl(tab2d_1=frld  ,clinfo1=' frld   2 : ', tab2d_2=sist  , clinfo2=' sist      : ')
+         ENDIF
+
+
+         !                                                           !---------------!
+         CALL lim_trp_2( kt )                                        ! Ice transport !  ( Advection/diffusion )
+         !                                                           !---------------!
+         IF(ln_ctl) THEN
+            CALL prt_ctl(tab2d_1=hsnif ,clinfo1=' hsnif  3 : ', tab2d_2=hicif , clinfo2=' hicif     : ')
+            CALL prt_ctl(tab2d_1=frld  ,clinfo1=' frld   3 : ', tab2d_2=sist  , clinfo2=' sist      : ')
+         ENDIF
+
+         !                                                           !-------------!
+         IF( ln_limdmp ) THEN                                        ! Ice damping !
+         !                                                           !-------------!
+#if defined key_agrif
+            IF( Agrif_Root() )   CALL lim_dmp_2(kt)
+#else
+            CALL lim_dmp_2(kt)                                         
+#endif
+         ENDIF
+         !                                                           !--------------------!
+         CALL lim_thd_2( kt )                                        ! Ice thermodynamics !
+         !                                                           !--------------------!
+         IF(ln_ctl) THEN
+            CALL prt_ctl(tab2d_1=hsnif ,clinfo1=' hsnif  4 : ', tab2d_2=hicif , clinfo2=' hicif     : ')
+            CALL prt_ctl(tab2d_1=frld  ,clinfo1=' frld   4 : ', tab2d_2=sist  , clinfo2=' sist      : ')
+         ENDIF
+
+
+         ! Mass and heat fluxes from ice to ocean
+         !                                                           !------------------------------!
+         CALL lim_flx_2                                              ! Ice/Ocean Mass & Heat fluxes !
+         !                                                           !------------------------------!
+
+         IF( MOD( kt + nfice -1, ninfo ) == 0 .OR. ntmoy == 1 )  THEN        !-----------------!
+            CALL lim_dia_2( kt )                                             ! Ice Diagnostics !
+         ENDIF                                                               !-----------------!
+
+         !                                                           !-------------!
+         CALL lim_wri_2( kt )                                        ! Ice outputs !
+         !                                                           !-------------!
+
+         !                                                           !------------------------!
+         IF( lrst_ice ) CALL lim_rst_write_2( kt )                   ! Write Ice restart file !
+         !                                                           !------------------------!
+
+         ! Re-initialization of forcings
+         qsr_oce (:,:) = 0.e0
+         qsr_ice (:,:) = 0.e0
+         qnsr_oce(:,:) = 0.e0
+         qnsr_ice(:,:) = 0.e0 
+         dqns_ice(:,:) = 0.e0 
+         tprecip (:,:) = 0.e0 
+         sprecip (:,:) = 0.e0
+         fr1_i0  (:,:) = 0.e0
+         fr2_i0  (:,:) = 0.e0
+         evap    (:,:) = 0.e0
+#if defined key_coupled 
+         rrunoff (:,:) = 0.e0
+         calving (:,:) = 0.e0
+#else
+         qla_ice (:,:) = 0.e0
+         dqla_ice(:,:) = 0.e0
+#endif
+      ENDIF
+      !
+   END SUBROUTINE ice_stp_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option           Dummy module      NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE ice_stp_2 ( kt )     ! Dummy routine
+      WRITE(*,*) 'ice_stp_2: You should not have seen this print! error?', kt
+   END SUBROUTINE ice_stp_2
+#endif
+
+   !!======================================================================
+END MODULE icestp_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limadv_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limadv_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limadv_2.F90	(revision 823)
@@ -0,0 +1,448 @@
+MODULE limadv_2 
+   !!======================================================================
+   !!                       ***  MODULE limadv_2   ***
+   !! LIM 2.0 sea-ice model : sea-ice advection
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_adv_x_2  : advection of sea ice on x axis
+   !!   lim_adv_y_2  : advection of sea ice on y axis
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce
+   USE dom_ice_2
+   USE ice_oce         ! ice variables
+   USE in_out_manager  ! I/O manager
+   USE lbclnk
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_adv_x_2    ! called by lim_trp
+   PUBLIC lim_adv_y_2    ! called by lim_trp
+
+   !! * Module variables
+   REAL(wp)  ::            &  ! constant values
+      epsi20 = 1e-20    ,  &
+      rzero  = 0.e0     ,  &
+      rone   = 1.e0
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_adv_x_2( pdf, put , pcrh, psm , ps0 ,   &
+      &                    psx, psxx, psy , psyy, psxy )
+      !!---------------------------------------------------------------------
+      !!                **  routine lim_adv_x_2  **
+      !!  
+      !! ** purpose :   Computes and adds the advection trend to sea-ice
+      !!      variable on x axis
+      !!
+      !! ** method  :   Uses Prather second order scheme that advects
+      !!      tracers but also theirquadratic forms. The method preserves
+      !!      tracer structures by conserving second order moments.
+      !!      Ref.: "Numerical Advection by Conservation of Second Order
+      !!      Moments", JGR, VOL. 91. NO. D6. PAGES 6671-6681. MAY 20, 1986
+      !!     
+      !! History :
+      !!        !  00-01 (LIM)
+      !!        !  01-05 (G. Madec, R. Hordoir) opa norm
+      !!        !  03-10 (C. Ethe) F90, module
+      !!        !  03-12 (R. Hordoir, G. Madec) mpp
+      !!--------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp)                    , INTENT(in)  ::  &
+         pdf ,       &  ! ???
+         pcrh           ! = 1. : lim_adv_x is called before lim_adv_y
+         !              ! = 0. : lim_adv_x is called after  lim_adv_y
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in)  ::  &
+         put            ! i-direction ice velocity at ocean U-point (m/s)
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::  & 
+         ps0 , psm , &  ! ???
+         psx , psy , &  ! ??? 
+         psxx, psyy, psxy
+
+      !! * Local declarations
+      INTEGER ::   ji, jj      ! dummy loop indices
+      REAL(wp)       ::  &
+         zrdt, zslpmax, ztemp, zin0,     &  ! temporary scalars
+         zs1max, zs1new, zs2new,         &  !    "         "
+         zalf, zalfq, zalf1, zalf1q,     &  !    "         "
+         zbt , zbt1                         !    "         "
+      REAL(wp), DIMENSION(jpi,jpj)  ::   &  ! temporary workspace
+         zf0 , zfx , zfy , zbet,         &  !    "           "
+         zfxx, zfyy, zfxy,               &  !    "           "
+         zfm, zalg, zalg1, zalg1q           !    "           "
+      !---------------------------------------------------------------------
+
+      ! Limitation of moments.                                           
+
+      zrdt      = rdt_ice * pdf   ! If ice drift field is too fast, use an appropriate time step for advection.
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zslpmax = MAX( rzero, ps0(ji,jj) )
+            zs1max  = 1.5 * zslpmax
+            zs1new  = MIN( zs1max, MAX( -zs1max, psx(ji,jj) ) )
+            zs2new  = MIN(  2.0 * zslpmax - 0.3334 * ABS( zs1new ),      &
+               &            MAX( ABS( zs1new ) - zslpmax, psxx(ji,jj) )  )
+            zin0    = ( 1.0 - MAX( rzero, sign ( rone, -zslpmax) ) ) * tms(ji,jj)   ! Case of empty boxes & Apply mask
+
+            ps0 (ji,jj) = zslpmax  
+            psx (ji,jj) = zs1new      * zin0
+            psxx(ji,jj) = zs2new      * zin0
+            psy (ji,jj) = psy (ji,jj) * zin0
+            psyy(ji,jj) = psyy(ji,jj) * zin0
+            psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * zin0
+         END DO
+      END DO
+
+      !  Initialize volumes of boxes  (=area if adv_x first called, =psm otherwise)                                     
+      psm (:,:)  = MAX( pcrh * area(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20 )
+
+      !  Calculate fluxes and moments between boxes i<-->i+1              
+      DO jj = 2, jpjm1                    !  Flux from i to i+1 WHEN u GT 0 
+!i bug   DO ji = 1, jpim1 
+!i    DO jj = 1, jpj                      !  Flux from i to i+1 WHEN u GT 0 
+         DO ji = 1, jpi
+            zbet(ji,jj)  =  MAX( rzero, SIGN( rone, put(ji,jj) ) )
+            zalf         =  MAX( rzero, put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji,jj)
+            zalfq        =  zalf * zalf
+            zalf1        =  1.0 - zalf
+            zalf1q       =  zalf1 * zalf1
+            zfm (ji,jj)  =  zalf  * psm(ji,jj)
+            zf0 (ji,jj)  =  zalf  * ( ps0(ji,jj) + zalf1 * ( psx(ji,jj) + (zalf1 - zalf) * psxx(ji,jj)  ) )
+            zfx (ji,jj)  =  zalfq * ( psx(ji,jj) + 3.0 * zalf1 * psxx(ji,jj) )
+            zfxx(ji,jj)  =  zalf  * zalfq * psxx(ji,jj)
+            zfy (ji,jj)  =  zalf  * ( psy(ji,jj) + zalf1 * psxy(ji,jj) )
+            zfxy(ji,jj)  =  zalfq * psxy(ji,jj)
+            zfyy(ji,jj)  =  zalf  * psyy(ji,jj)
+
+            !  Readjust moments remaining in the box.
+            psm (ji,jj)  =  psm (ji,jj) - zfm(ji,jj)
+            ps0 (ji,jj)  =  ps0 (ji,jj) - zf0(ji,jj)
+            psx (ji,jj)  =  zalf1q * ( psx(ji,jj) - 3.0 * zalf * psxx(ji,jj) )
+            psxx(ji,jj)  =  zalf1  * zalf1q * psxx(ji,jj)
+            psy (ji,jj)  =  psy (ji,jj) - zfy(ji,jj)
+            psyy(ji,jj)  =  psyy(ji,jj) - zfyy(ji,jj)
+            psxy(ji,jj)  =  zalf1q * psxy(ji,jj)
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1                      !  Flux from i+1 to i when u LT 0.
+!i    DO jj = 1, jpjm1                      !  Flux from i+1 to i when u LT 0.
+         DO ji = 1, jpim1
+            zalf          = MAX( rzero, -put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji+1,jj) 
+            zalg  (ji,jj) = zalf
+            zalfq         = zalf * zalf
+            zalf1         = 1.0 - zalf
+            zalg1 (ji,jj) = zalf1
+            zalf1q        = zalf1 * zalf1
+            zalg1q(ji,jj) = zalf1q
+            zfm   (ji,jj) = zfm (ji,jj) + zalf  * psm(ji+1,jj)
+            zf0   (ji,jj) = zf0 (ji,jj) + zalf  * ( ps0(ji+1,jj) - zalf1 * ( psx(ji+1,jj) - (zalf1 - zalf ) * psxx(ji+1,jj) ) )
+            zfx   (ji,jj) = zfx (ji,jj) + zalfq * ( psx(ji+1,jj) - 3.0 * zalf1 * psxx(ji+1,jj) )
+            zfxx  (ji,jj) = zfxx(ji,jj) + zalf  * zalfq * psxx(ji+1,jj)
+            zfy   (ji,jj) = zfy (ji,jj) + zalf  * ( psy(ji+1,jj) - zalf1 * psxy(ji+1,jj) )
+            zfxy  (ji,jj) = zfxy(ji,jj) + zalfq * psxy(ji+1,jj)
+            zfyy  (ji,jj) = zfyy(ji,jj) + zalf  * psyy(ji+1,jj)
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1                     !  Readjust moments remaining in the box. 
+         DO ji = 2, jpim1
+            zbt  =       zbet(ji-1,jj)
+            zbt1 = 1.0 - zbet(ji-1,jj)
+            psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji-1,jj) )
+            ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji-1,jj) )
+            psx (ji,jj) = zalg1q(ji-1,jj) * ( psx(ji,jj) + 3.0 * zalg(ji-1,jj) * psxx(ji,jj) )
+            psxx(ji,jj) = zalg1 (ji-1,jj) * zalg1q(ji-1,jj) * psxx(ji,jj)
+            psy (ji,jj) = zbt * psy (ji,jj) + zbt1 * ( psy (ji,jj) - zfy (ji-1,jj) )
+            psyy(ji,jj) = zbt * psyy(ji,jj) + zbt1 * ( psyy(ji,jj) - zfyy(ji-1,jj) )
+            psxy(ji,jj) = zalg1q(ji-1,jj) * psxy(ji,jj)
+         END DO
+      END DO
+
+      !   Put the temporary moments into appropriate neighboring boxes.    
+      DO jj = 2, jpjm1                     !   Flux from i to i+1 IF u GT 0.
+         DO ji = 2, jpim1
+            zbt  =       zbet(ji-1,jj)
+            zbt1 = 1.0 - zbet(ji-1,jj)
+            psm(ji,jj)  = zbt * ( psm(ji,jj) + zfm(ji-1,jj) ) + zbt1 * psm(ji,jj)
+            zalf        = zbt * zfm(ji-1,jj) / psm(ji,jj)
+            zalf1       = 1.0 - zalf
+            ztemp       = zalf * ps0(ji,jj) - zalf1 * zf0(ji-1,jj)
+            ps0(ji,jj)  = zbt * (ps0(ji,jj) + zf0(ji-1,jj)) + zbt1 * ps0(ji,jj)
+            psx(ji,jj)  = zbt * ( zalf * zfx(ji-1,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp ) + zbt1 * psx(ji,jj)
+            psxx(ji,jj) = zbt * ( zalf * zalf * zfxx(ji-1,jj) + zalf1 * zalf1 * psxx(ji,jj)   &
+               &                + 5.0 * ( zalf * zalf1 * ( psx (ji,jj) - zfx(ji-1,jj) ) - ( zalf1 - zalf ) * ztemp )  )   &
+               &        + zbt1 * psxx(ji,jj)
+            psxy(ji,jj) = zbt * ( zalf * zfxy(ji-1,jj) + zalf1 * psxy(ji,jj)             &
+               &                + 3.0 * (- zalf1*zfy(ji-1,jj)  + zalf * psy(ji,jj) ) )   &
+               &         + zbt1 * psxy(ji,jj)
+            psy (ji,jj) = zbt * ( psy (ji,jj) + zfy (ji-1,jj) ) + zbt1 * psy (ji,jj)
+            psyy(ji,jj) = zbt * ( psyy(ji,jj) + zfyy(ji-1,jj) ) + zbt1 * psyy(ji,jj)
+         END DO
+      END DO
+
+      DO jj = 2, jpjm1                     !  Flux from i+1 to i IF u LT 0.
+         DO ji = 2, jpim1
+            zbt  =       zbet(ji,jj)
+            zbt1 = 1.0 - zbet(ji,jj)
+            psm(ji,jj)  = zbt * psm(ji,jj)  + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
+            zalf        = zbt1 * zfm(ji,jj) / psm(ji,jj)
+            zalf1       = 1.0 - zalf
+            ztemp       = -zalf * ps0(ji,jj) + zalf1 * zf0(ji,jj)
+            ps0(ji,jj)  = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) + zf0(ji,jj) )
+            psx(ji,jj)  = zbt  * psx(ji,jj)   &
+               &        + zbt1 * ( zalf * zfx(ji,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp )
+            psxx(ji,jj) = zbt  * psxx(ji,jj)   &
+               &        + zbt1 * (  zalf * zalf * zfxx(ji,jj)  + zalf1 * zalf1 * psxx(ji,jj)  &
+               &                 + 5.0 *( zalf * zalf1 * ( - psx(ji,jj) + zfx(ji,jj) ) + ( zalf1 - zalf ) * ztemp ) )
+            psxy(ji,jj) = zbt  * psxy(ji,jj)   &
+               &        + zbt1 * (  zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj)  &
+               &                 + 3.0 * ( zalf1 * zfy(ji,jj) - zalf * psy(ji,jj) )  )
+            psy(ji,jj)  = zbt * psy (ji,jj)  + zbt1 * ( psy (ji,jj) + zfy (ji,jj) )
+            psyy(ji,jj) = zbt * psyy(ji,jj)  + zbt1 * ( psyy(ji,jj) + zfyy(ji,jj) )
+         END DO
+      END DO
+
+      !-- Lateral boundary conditions
+      CALL lbc_lnk( psm , 'T', 1. )
+      CALL lbc_lnk( ps0 , 'T', 1. )
+      CALL lbc_lnk( psx , 'T', 1. )
+      CALL lbc_lnk( psxx, 'T', 1. )
+      CALL lbc_lnk( psy , 'T', 1. )
+      CALL lbc_lnk( psyy, 'T', 1. )
+      CALL lbc_lnk( psxy, 'T', 1. )
+
+      IF(ln_ctl)   THEN
+         CALL prt_ctl(tab2d_1=psm  , clinfo1=' lim_adv_x: psm  :', tab2d_2=ps0 , clinfo2=' ps0  : ')
+         CALL prt_ctl(tab2d_1=psx  , clinfo1=' lim_adv_x: psx  :', tab2d_2=psxx, clinfo2=' psxx : ')
+         CALL prt_ctl(tab2d_1=psy  , clinfo1=' lim_adv_x: psy  :', tab2d_2=psyy, clinfo2=' psyy : ')
+         CALL prt_ctl(tab2d_1=psxy , clinfo1=' lim_adv_x: psxy :')
+      ENDIF
+
+   END SUBROUTINE lim_adv_x_2
+
+
+   SUBROUTINE lim_adv_y_2( pdf, pvt , pcrh, psm , ps0 ,   &
+      &                    psx, psxx, psy , psyy, psxy )
+      !!---------------------------------------------------------------------
+      !!                **  routine lim_adv_y_2  **
+      !!            
+      !! ** purpose :   Computes and adds the advection trend to sea-ice 
+      !!      variable on y axis
+      !!
+      !! ** method  :   Uses Prather second order scheme that advects tracers
+      !!      but also their quadratic forms. The method preserves tracer
+      !!      structures by conserving second order moments.
+      !!
+      !! History :
+      !!   1.0  !  00-01 (LIM)
+      !!        !  01-05 (G. Madec, R. Hordoir) opa norm
+      !!   2.0  !  03-10 (C. Ethe) F90, module
+      !!        !  03-12 (R. Hordoir, G. Madec) mpp
+      !!---------------------------------------------------------------------
+      !! * Arguments
+      REAL(wp),                     INTENT(in)  :: &
+         pdf,        &  ! ???
+         pcrh           ! = 1. : lim_adv_x is called before lim_adv_y
+         !              ! = 0. : lim_adv_x is called after  lim_adv_y
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in)  :: &
+         pvt            ! j-direction ice velocity at ocean V-point (m/s)
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: &
+         psm , ps0 , psx , psy,   &
+         psxx, psyy, psxy
+
+      !! * Local Variables
+      INTEGER  ::   ji, jj                ! dummy loop indices
+      REAL(wp) ::   &
+         zrdt, zslpmax, zin0, ztemp,  &   ! temporary scalars
+         zs1max, zs1new, zs2new,      &   !    "         "
+         zalf, zalfq, zalf1, zalf1q,  &   !    "         "
+         zbt , zbt1                       !
+      REAL(wp), DIMENSION(jpi,jpj)  :: &
+         zf0 , zfx , zfy ,             &  ! temporary workspace
+         zfxx, zfyy, zfxy,             &  !    "           "
+         zfm , zbet,                   &  !    "           "
+         zalg, zalg1, zalg1q              !    "           "
+      !---------------------------------------------------------------------
+
+      ! Limitation of moments.
+
+      zrdt = rdt_ice * pdf ! If ice drift field is too fast, use an appropriate time step for advection.
+
+       DO jj = 1, jpj
+          DO ji = 1, jpi
+             zslpmax = MAX( rzero, ps0(ji,jj) )
+             zs1max  = 1.5 * zslpmax
+             zs1new  = MIN( zs1max, MAX( -zs1max, psy(ji,jj) ) )
+             zs2new  = MIN(  ( 2.0 * zslpmax - 0.3334 * ABS( zs1new ) ),   &
+                &             MAX( ABS( zs1new )-zslpmax, psyy(ji,jj) )  )
+             zin0    = ( 1.0 - MAX( rzero, sign ( rone, -zslpmax) ) ) * tms(ji,jj)   ! Case of empty boxes & Apply mask
+             ps0 (ji,jj) = zslpmax  
+             psx (ji,jj)  = psx (ji,jj) * zin0
+             psxx(ji,jj)  = psxx(ji,jj) * zin0
+             psy (ji,jj) = zs1new * zin0
+             psyy(ji,jj) = zs2new * zin0
+             psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * zin0
+          END DO
+       END DO
+
+       !  Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
+       psm (:,:)  = MAX( pcrh * area(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20 )
+
+       !  Calculate fluxes and moments between boxes j<-->j+1              
+!!bug  DO jj = 2, jpjm1
+       DO jj = 1, jpj
+          DO ji = 2, jpim1
+!!bug     DO ji = 1, jpim1
+             !  Flux from j to j+1 WHEN v GT 0   
+             zbet(ji,jj)  =  MAX( rzero, SIGN( rone, pvt(ji,jj) ) )
+             zalf         =  MAX( rzero, pvt(ji,jj) ) * zrdt * e1v(ji,jj) / psm(ji,jj)
+             zalfq        =  zalf * zalf
+             zalf1        =  1.0 - zalf
+             zalf1q       =  zalf1 * zalf1
+             zfm (ji,jj)  =  zalf  * psm(ji,jj)
+             zf0 (ji,jj)  =  zalf  * ( ps0(ji,jj) + zalf1 * ( psy(ji,jj)  + (zalf1-zalf) * psyy(ji,jj)  ) ) 
+             zfy (ji,jj)  =  zalfq *( psy(ji,jj) + 3.0*zalf1*psyy(ji,jj) )
+             zfyy(ji,jj)  =  zalf  * zalfq * psyy(ji,jj)
+             zfx (ji,jj)  =  zalf  * ( psx(ji,jj) + zalf1 * psxy(ji,jj) )
+             zfxy(ji,jj)  =  zalfq * psxy(ji,jj)
+             zfxx(ji,jj)  =  zalf  * psxx(ji,jj)
+
+             !  Readjust moments remaining in the box.
+             psm (ji,jj)  =  psm (ji,jj) - zfm(ji,jj)
+             ps0 (ji,jj)  =  ps0 (ji,jj) - zf0(ji,jj)
+             psy (ji,jj)  =  zalf1q * ( psy(ji,jj) -3.0 * zalf * psyy(ji,jj) )
+             psyy(ji,jj)  =  zalf1 * zalf1q * psyy(ji,jj)
+             psx (ji,jj)  =  psx (ji,jj) - zfx(ji,jj)
+             psxx(ji,jj)  =  psxx(ji,jj) - zfxx(ji,jj)
+             psxy(ji,jj)  =  zalf1q * psxy(ji,jj)
+          END DO
+       END DO
+
+       DO jj = 1, jpjm1                   !  Flux from j+1 to j when v LT 0.
+          DO ji = 2, jpim1
+!i     DO jj = 1, jpjm1                   !  Flux from j+1 to j when v LT 0.
+!i        DO ji = 2, jpim1
+             zalf          = ( MAX(rzero, -pvt(ji,jj) ) * zrdt * e1v(ji,jj) ) / psm(ji,jj+1) 
+             zalg  (ji,jj) = zalf
+             zalfq         = zalf * zalf
+             zalf1         = 1.0 - zalf
+             zalg1 (ji,jj) = zalf1
+             zalf1q        = zalf1 * zalf1
+             zalg1q(ji,jj) = zalf1q
+             zfm   (ji,jj) = zfm (ji,jj) + zalf  * psm(ji,jj+1)
+             zf0   (ji,jj) = zf0 (ji,jj) + zalf  * ( ps0(ji,jj+1) - zalf1 * (psy(ji,jj+1) - (zalf1 - zalf ) * psyy(ji,jj+1) ) )
+             zfy   (ji,jj) = zfy (ji,jj) + zalfq * ( psy(ji,jj+1) - 3.0 * zalf1 * psyy(ji,jj+1) )
+             zfyy  (ji,jj) = zfyy(ji,jj) + zalf  * zalfq * psyy(ji,jj+1)
+             zfx   (ji,jj) = zfx (ji,jj) + zalf  * ( psx(ji,jj+1) - zalf1 * psxy(ji,jj+1) )
+             zfxy  (ji,jj) = zfxy(ji,jj) + zalfq * psxy(ji,jj+1)
+             zfxx  (ji,jj) = zfxx(ji,jj) + zalf  * psxx(ji,jj+1)
+          END DO
+       END DO
+ 
+       !  Readjust moments remaining in the box. 
+       DO jj = 2, jpjm1
+          DO ji = 2, jpim1
+             zbt  =         zbet(ji,jj-1)
+             zbt1 = ( 1.0 - zbet(ji,jj-1) )
+             psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji,jj-1) )
+             ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji,jj-1) )
+             psy (ji,jj) = zalg1q(ji,jj-1) * ( psy(ji,jj) + 3.0 * zalg(ji,jj-1) * psyy(ji,jj) )
+             psyy(ji,jj) = zalg1 (ji,jj-1)  * zalg1q(ji,jj-1) * psyy(ji,jj)
+             psx (ji,jj) = zbt * psx (ji,jj) + zbt1 * ( psx (ji,jj) - zfx (ji,jj-1) )
+             psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) - zfxx(ji,jj-1) )
+             psxy(ji,jj) = zalg1q(ji,jj-1) * psxy(ji,jj)
+          END DO
+       END DO
+
+       !   Put the temporary moments into appropriate neighboring boxes.    
+       DO jj = 2, jpjm1                    !   Flux from j to j+1 IF v GT 0.
+          DO ji = 2, jpim1
+             zbt  =         zbet(ji,jj-1)
+             zbt1 = ( 1.0 - zbet(ji,jj-1) )
+             psm(ji,jj)  = zbt * ( psm(ji,jj) + zfm(ji,jj-1) ) + zbt1 * psm(ji,jj) 
+             zalf        = zbt * zfm(ji,jj-1) / psm(ji,jj) 
+             zalf1       = 1.0 - zalf
+             ztemp       = zalf * ps0(ji,jj) - zalf1 * zf0(ji,jj-1)
+             ps0(ji,jj)  = zbt * (ps0(ji,jj) + zf0(ji,jj-1)) + zbt1 * ps0(ji,jj)
+
+             psy(ji,jj)  = zbt  * ( zalf * zfy(ji,jj-1) + zalf1 * psy(ji,jj) + 3.0 * ztemp )   &
+                &        + zbt1 * psy(ji,jj)  
+
+             psyy(ji,jj) = zbt  * ( zalf * zalf * zfyy(ji,jj-1) + zalf1 * zalf1 * psyy(ji,jj)                             &
+                &                 + 5.0 * ( zalf * zalf1 * ( psy(ji,jj) - zfy(ji,jj-1) ) - ( zalf1 - zalf ) * ztemp ) )   & 
+                &        + zbt1 * psyy(ji,jj)
+
+             psxy(ji,jj) = zbt  * ( zalf * zfxy(ji,jj-1) + zalf1 * psxy(ji,jj)              &
+                                  + 3.0 * (- zalf1 * zfx(ji,jj-1) + zalf * psx(ji,jj) ) )   &
+                         + zbt1 * psxy(ji,jj)
+             psx (ji,jj) = zbt * ( psx (ji,jj) + zfx (ji,jj-1) ) + zbt1 * psx (ji,jj)
+             psxx(ji,jj) = zbt * ( psxx(ji,jj) + zfxx(ji,jj-1) ) + zbt1 * psxx(ji,jj)
+          END DO
+       END DO
+
+       DO jj = 2, jpjm1                   !  Flux from j+1 to j IF v LT 0.
+          DO ji = 2, jpim1
+             zbt  =         zbet(ji,jj)
+             zbt1 = ( 1.0 - zbet(ji,jj) )
+             psm(ji,jj)  = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
+             zalf        = zbt1 * zfm(ji,jj) / psm(ji,jj)
+             zalf1       = 1.0 - zalf
+             ztemp       = -zalf * ps0(ji,jj) + zalf1 * zf0(ji,jj)
+             ps0(ji,jj)  = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) + zf0(ji,jj) )
+             psy(ji,jj)  = zbt  * psy(ji,jj)  &
+                &        + zbt1 * ( zalf*zfy(ji,jj) + zalf1 * psy(ji,jj) + 3.0 * ztemp )
+             psyy(ji,jj) = zbt  * psyy(ji,jj)  &
+                &        + zbt1 * ( zalf * zalf * zfyy(ji,jj) + zalf1 * zalf1 * psyy(ji,jj)   &
+                &                 + 5.0 *( zalf *zalf1 *( -psy(ji,jj) + zfy(ji,jj) ) + ( zalf1 - zalf ) * ztemp ) )
+             psxy(ji,jj) = zbt  * psxy(ji,jj)   &
+                &        + zbt1 * ( zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj)   &
+                &                 + 3.0 * ( zalf1 * zfx(ji,jj) - zalf * psx(ji,jj) ) )
+             psx(ji,jj)  = zbt * psx (ji,jj) + zbt1 * ( psx (ji,jj) + zfx (ji,jj) )
+             psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) + zfxx(ji,jj) )
+          END DO
+       END DO
+
+      !-- Lateral boundary conditions
+      CALL lbc_lnk( psm , 'T', 1. )
+      CALL lbc_lnk( ps0 , 'T', 1. )
+      CALL lbc_lnk( psx , 'T', 1. )
+      CALL lbc_lnk( psxx, 'T', 1. )
+      CALL lbc_lnk( psy , 'T', 1. )
+      CALL lbc_lnk( psyy, 'T', 1. )
+      CALL lbc_lnk( psxy, 'T', 1. )
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=psm  , clinfo1=' lim_adv_y: psm  :', tab2d_2=ps0 , clinfo2=' ps0  : ')
+         CALL prt_ctl(tab2d_1=psx  , clinfo1=' lim_adv_y: psx  :', tab2d_2=psxx, clinfo2=' psxx : ')
+         CALL prt_ctl(tab2d_1=psy  , clinfo1=' lim_adv_y: psy  :', tab2d_2=psyy, clinfo2=' psyy : ')
+         CALL prt_ctl(tab2d_1=psxy , clinfo1=' lim_adv_y: psxy :')
+      ENDIF
+
+   END SUBROUTINE lim_adv_y_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option            Dummy module     NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_adv_x_2         ! Empty routine
+   END SUBROUTINE lim_adv_x_2
+   SUBROUTINE lim_adv_y_2         ! Empty routine
+   END SUBROUTINE lim_adv_y_2
+
+#endif
+
+END MODULE limadv_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limdia_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limdia_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limdia_2.F90	(revision 823)
@@ -0,0 +1,288 @@
+MODULE limdia_2
+   !!======================================================================
+   !!                       ***  MODULE limdia_2   ***
+   !!                      diagnostics of ice model 
+   !!======================================================================
+   !! History :   8.0  !  97-06  (Louvain-La-Neuve)  Original code
+   !!             8.5  !  02-09  (C. Ethe , G. Madec )  F90: Free form and module
+   !!             9.0  !  06-08  (S. Masson)  change frequency output control
+   !!-------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_dia_2      : computation of the time evolution of keys var.
+   !!   lim_dia_init_2 : initialization and namelist read
+   !!----------------------------------------------------------------------
+   USE phycst          ! 
+   USE par_ice_2       ! ice parameters
+   USE ice_oce         ! ice variables
+   USE daymod          !
+   USE dom_ice_2       !
+   USE ice_2           !
+   USE limistate_2     !
+   USE in_out_manager  ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC               lim_dia_2          ! called by ice_step
+   INTEGER, PUBLIC ::   ntmoy   = 1 ,   &  !: instantaneous values of ice evolution or averaging ntmoy
+      &                 ninfo   = 1        !: frequency of ouputs on file ice_evolu in case of averaging
+
+   INTEGER, PARAMETER ::   &  ! Parameters for outputs to files "evolu"
+      jpinfmx = 100         ,    &  ! maximum number of key variables
+      jpchinf = 5           ,    &  ! ???
+      jpchsep = jpchinf + 2         ! ???
+
+   INTEGER ::   &
+      nfrinf  = 4 ,     &  ! number of variables written in one line 
+      nferme ,          &  ! last time step at which the var. are written on file
+      nvinfo ,          &  ! number of total variables 
+      nbvt   ,          &  ! number of time variables
+      naveg                ! number of step for accumulation before averaging
+
+   CHARACTER(len= 8) ::   fmtinf  = '1PE13.5 ' ! format of the output values  
+   CHARACTER(len=30) ::   fmtw  ,           &  ! formats
+      &                   fmtr  ,           &  ! ???
+      &                   fmtitr               ! ???
+   CHARACTER(len=jpchsep), DIMENSION(jpinfmx) ::   titvar               ! title of key variables
+ 
+   REAL(wp)                     ::   epsi06 = 1.e-06      ! ???
+   REAL(wp), DIMENSION(jpinfmx) ::   vinfom               ! temporary working space
+   REAL(wp), DIMENSION(jpi,jpj) ::   aire                 ! masked grid cell area
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/LIM_SRC/limdia.F90,v 1.9 2007/06/29 17:03:12 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_dia_2( kt )
+      !!--------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_dia_2  ***
+      !!   
+      !! ** Purpose : Computation and outputs on file ice.evolu 
+      !!      the temporal evolution of some key variables
+      !!-------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+      !!
+      INTEGER  ::   jv,ji, jj   ! dummy loop indices
+      INTEGER  ::   nv          ! indice of variable 
+      REAL(wp) ::   zarea    , zldarea  ,    &  ! sea-ice and leads area
+         &          zextent15, zextent85,    &  ! sea-ice extent (15% and 85%)
+         &          zicevol  , zsnwvol  ,    &  ! sea-ice and snow volume volume
+         &          zicespd                     ! sea-ice velocity
+      REAL(wp), DIMENSION(jpinfmx) ::   vinfor  ! temporary working space 
+      !!-------------------------------------------------------------------
+
+      IF( kt == nit000 )   CALL lim_dia_init_2  ! initialisation of ice_evolu file      
+
+      ! computation of key variables at each time step   
+
+      nv = 1 
+      vinfor(nv) = REAL( kt + nfice - 1 )
+      nv = nv + 1
+      vinfor(nv) = nyear
+ 
+      DO jv = nbvt + 1, nvinfo
+         vinfor(jv) = 0.e0
+      END DO
+
+      zextent15 = 0.e0
+      zextent85 = 0.e0
+      ! variables in northern Hemis
+      DO jj = njeq, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            IF( tms(ji,jj) == 1 ) THEN
+               zarea = ( 1.0 - frld(ji,jj) ) * aire(ji,jj)
+               IF (frld(ji,jj) <= 0.15 ) zextent15 = aire(ji,jj)    
+               IF (frld(ji,jj) <= 0.85 ) zextent85 = aire(ji,jj)   
+               zldarea = zarea   / MAX( ( 1 - frld(ji,jj) ) , epsi06 )
+               zicevol = zarea   * hicif(ji,jj)
+               zsnwvol = zarea   * hsnif(ji,jj)
+               zicespd = zicevol * ( u_ice(ji,jj) * u_ice(ji,jj)   &
+                  &                + v_ice(ji,jj) * v_ice(ji,jj) )
+               vinfor(nv+ 1) = vinfor(nv+ 1) + zarea
+               vinfor(nv+ 3) = vinfor(nv+ 3) + zextent15
+               vinfor(nv+ 5) = vinfor(nv+ 5) + zextent85
+               vinfor(nv+ 7) = vinfor(nv+ 7) + zldarea
+               vinfor(nv+ 9) = vinfor(nv+ 9) + zicevol
+               vinfor(nv+11) = vinfor(nv+11) + zsnwvol
+               vinfor(nv+13) = vinfor(nv+13) + zicespd
+            ENDIF
+         END DO
+      END DO
+      vinfor(nv+13) = SQRT( vinfor(nv+13) / MAX( vinfor(nv+9) , epsi06 ) )
+
+
+      ! variables in southern Hemis
+       nv = nv + 1
+       DO jj = 2, njeqm1
+          DO ji = fs_2, fs_jpim1   ! vector opt.
+             IF( tms(ji,jj) == 1 ) THEN
+                zarea = ( 1.0 - frld(ji,jj) ) * aire(ji,jj)
+                IF (frld(ji,jj) <= 0.15 ) zextent15 = aire(ji,jj)    
+                IF (frld(ji,jj) <= 0.85 ) zextent85 = aire(ji,jj)   
+                zldarea = zarea   / MAX( ( 1 - frld(ji,jj) ) , epsi06 )
+                zicevol = zarea   * hicif(ji,jj)
+                zsnwvol = zarea   * hsnif(ji,jj)
+                zicespd = zicevol * ( u_ice(ji,jj) * u_ice(ji,jj)   &
+                   &                + v_ice(ji,jj) * v_ice(ji,jj) )
+                vinfor(nv+ 1) = vinfor(nv+ 1) + zarea
+                vinfor(nv+ 3) = vinfor(nv+ 3) + zextent15
+                vinfor(nv+ 5) = vinfor(nv+ 5) + zextent85
+                vinfor(nv+ 7) = vinfor(nv+ 7) + zldarea
+                vinfor(nv+ 9) = vinfor(nv+ 9) + zicevol
+                vinfor(nv+11) = vinfor(nv+11) + zsnwvol
+                vinfor(nv+13) = vinfor(nv+13) + zicespd
+             ENDIF
+          END DO
+       END DO
+       vinfor(nv+13) = SQRT( vinfor(nv+13) / MAX( vinfor(nv+9) , epsi06 ) )    
+
+       !  Accumulation before averaging 
+       DO jv = 1, nvinfo
+          vinfom(jv) = vinfom(jv) + vinfor(jv)
+       END DO
+       naveg = naveg + 1  
+    
+       ! oututs on file ice_evolu    
+       IF( MOD( kt + nfice - 1, ninfo ) == 0 ) THEN
+          WRITE(numevo_ice,fmtw) ( titvar(jv), vinfom(jv)/naveg, jv = 1, nvinfo )
+          naveg = 0
+          DO jv = 1, nvinfo
+             vinfom(jv) = 0.e0
+          END DO
+       ENDIF
+       !
+    END SUBROUTINE lim_dia_2
+ 
+
+    SUBROUTINE lim_dia_init_2
+       !!-------------------------------------------------------------------
+       !!                  ***  ROUTINE lim_dia_init_2  ***
+       !!             
+       !! ** Purpose : Preparation of the file ice_evolu for the output of
+       !!      the temporal evolution of key variables
+       !!
+       !! ** input   : Namelist namicedia
+       !!-------------------------------------------------------------------
+       CHARACTER(len=jpchinf) ::   titinf
+       CHARACTER(len=50)      ::   clname 
+       INTEGER  ::   jv            ! dummy loop indice
+       INTEGER  ::   ntot , ndeb , irecl
+       INTEGER  ::   nv            ! indice of variable 
+       REAL(wp) ::   zxx0, zxx1    ! temporary scalars
+
+       NAMELIST/namicedia/fmtinf, nfrinf, ninfo, ntmoy
+       !!-------------------------------------------------------------------
+
+       ! Read Namelist namicedia
+       REWIND ( numnam_ice )
+       READ   ( numnam_ice  , namicedia )
+       
+       IF(lwp) THEN
+          WRITE(numout,*)
+          WRITE(numout,*) 'lim_dia_init_2 : ice parameters for ice diagnostics '
+          WRITE(numout,*) '~~~~~~~~~~~~~~'
+          WRITE(numout,*) '   format of the output values                                 fmtinf = ', fmtinf
+          WRITE(numout,*) '   number of variables written in one line                     nfrinf = ', nfrinf 
+          WRITE(numout,*) '   Instantaneous values of ice evolution or averaging          ntmoy  = ', ntmoy
+          WRITE(numout,*) '   frequency of ouputs on file ice_evolu in case of averaging  ninfo  = ', ninfo
+       ENDIF
+
+       ! masked grid cell area
+       aire(:,:) = area(:,:) * tms(:,:)
+
+       ! Titles of ice key variables :
+       nv = 1
+       titvar(nv) = 'NoIt'  ! iteration number
+       nv = nv + 1
+       titvar(nv) = 'T yr'  ! time step in years
+       
+       nbvt = nv - 1
+
+       nv = nv + 1   ;   titvar(nv) = 'AEFN' ! sea ice area in the northern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'AEFS' ! sea ice area in the southern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'A15N'  ! sea ice extent (15%) in the northern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'A15S'  ! sea ice extent (15%) in the southern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'A85N'  ! sea ice extent (85%) in the northern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'A85S'  ! sea ice extent (85%) in the southern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'ALEN'  ! leads area in the northern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'ALES'  ! leads area in the southern Hemisp.(10^12 km2)
+       nv = nv + 1   ;   titvar(nv) = 'VOLN'  ! sea ice volume in the northern Hemisp.(10^3 km3)
+       nv = nv + 1   ;   titvar(nv) = 'VOLS'  ! sea ice volume in the southern Hemisp.(10^3 km3)
+       nv = nv + 1   ;   titvar(nv) = 'VONN'  ! snow volume over sea ice in the northern Hemisp.(10^3 km3)
+       nv = nv + 1   ;   titvar(nv) = 'VONS'  ! snow volume over sea ice in the southern Hemisp.(10^3 km3)
+       nv = nv + 1   ;   titvar(nv) = 'ECGN'  ! mean sea ice velocity in the northern Hemisp.(m/s)
+       nv = nv + 1   ;   titvar(nv) = 'ECGS'  ! mean sea ice velocity in the southern Hemisp.(m/s)
+
+       nvinfo = nv
+
+       ! Definition et Ecriture de l'entete : nombre d'enregistrements 
+       ndeb   = ( nit000 - 1 + nfice - 1 ) / ninfo
+       IF( nit000 - 1 + nfice == 1 ) ndeb = -1
+
+       nferme = ( nitend + nfice - 1 ) / ninfo ! nit000 - 1 + nfice - 1 + nitend - nit000 + 1
+       ntot   = nferme - ndeb
+       ndeb   = ninfo * ( 1 + ndeb )
+       nferme = ninfo * nferme
+
+       ! definition of formats 
+       WRITE( fmtw  , '(A,I3,A2,I1,A)' )  '(', nfrinf, '(A', jpchsep, ','//fmtinf//'))'
+       WRITE( fmtr  , '(A,I3,A,I1,A)'  )  '(', nfrinf, '(', jpchsep, 'X,'//fmtinf//'))'
+       WRITE( fmtitr, '(A,I3,A,I1,A)'  )  '(', nvinfo, 'A', jpchinf, ')'
+
+       ! opening  "ice_evolu" file
+       clname = 'ice_evolu' 
+       irecl = ( jpchinf + 1 ) * nvinfo 
+       CALL ctlopn( numevo_ice, clname, 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL',   &
+          &           irecl, numout, lwp, 1 )
+
+       !- ecriture de 2 lignes d''entete :
+       WRITE(numevo_ice,1000) fmtr, fmtw, fmtitr, nvinfo, ntot, 0, nfrinf
+       zxx0 = 0.001 * REAL( ninfo )
+       zxx1 = 0.001 * REAL( ndeb  )
+       WRITE(numevo_ice,1111) REAL(jpchinf), 0., zxx1, zxx0, 0., 0., 0
+
+       !- ecriture de 2 lignes de titre :
+       WRITE(numevo_ice,'(A,I8,A,I8,A,I5)')                 &
+          'Evolution chronologique - Experience '//cexper   &
+          //'   de', ndeb, ' a', nferme, ' pas', ninfo
+       WRITE(numevo_ice,fmtitr) ( titvar(jv), jv = 1, nvinfo )
+
+
+       !--preparation de "titvar" pour l''ecriture parmi les valeurs numeriques :
+       DO  jv = 2 , nvinfo
+          titinf     = titvar(jv)(:jpchinf)
+          titvar(jv) = '  '//titinf
+       END DO
+
+       !--Initialisation of the arrays for the accumulation
+       DO  jv = 1, nvinfo
+          vinfom(jv) = 0.
+       END DO
+       naveg = 0
+
+1000   FORMAT( 3(A20),4(1x,I6) )
+1111   FORMAT( 3(F7.1,1X,F7.3,1X),I3,A )  
+      !
+    END SUBROUTINE lim_dia_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :                           NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_dia_2         ! Empty routine
+   END SUBROUTINE lim_dia_2
+#endif
+
+   !!======================================================================
+END MODULE limdia_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limdmp_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limdmp_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limdmp_2.F90	(revision 823)
@@ -0,0 +1,182 @@
+MODULE limdmp_2
+   !!======================================================================
+   !!                       ***  MODULE limdmp_2   ***
+   !!  Ice model : restoring Ice thickness and Fraction leads
+   !!======================================================================
+   !! History :   2.0  !  04-04 (S. Theetten) Original code
+   !!----------------------------------------------------------------------
+#if defined key_lim2   &&   defined key_tradmp
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'  AND                               LIM 2.0 sea-ice model
+   !!   'key_tradmp'                                                Damping
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_dmp_2      : ice model damping
+   !!----------------------------------------------------------------------
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+   USE ice_2
+   USE ice_oce
+   USE tradmp
+   USE dom_oce
+   USE oce
+   USE daymod          ! calendar
+   USE iom
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_dmp_2     ! called by ice_step_2
+   
+   INTEGER                        ::   nice1, nice2,  &  ! first and second record used
+      &                                inumice_dmp       ! logical unit for ice variables (damping)
+   REAL(wp), DIMENSION(jpi,jpj)   ::   hicif_dta  ,   &  ! ice thickness at a given time
+      &                                frld_dta          ! fraction lead at a given time
+   REAL(wp), DIMENSION(jpi,jpj,2) ::   hicif_data ,   &  ! ice thickness data at two consecutive times
+      &                                frld_data         ! fraction lead data at two consecutive times
+
+   !! * Substitution
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0 , UCL-LOCEAN-IPSL  (2006)
+   !! $Header$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_dmp_2(kt)
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_dmp_2 ***
+      !!
+      !! ** purpose : ice model damping : restoring ice thickness and 
+      !!              fraction leads
+      !!
+      !! ** method  : the key_tradmp must be used to compute resto(:,:) coef.
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !
+      INTEGER             ::   ji, jj         ! dummy loop indices
+      !!---------------------------------------------------------------------
+      !
+      CALL dta_lim_2( kt )
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            hicif(ji,jj) = hicif(ji,jj) - rdt_ice * resto(ji,jj,1) * ( hicif(ji,jj) - hicif_dta(ji,jj) )
+            frld(ji,jj)  = frld (ji,jj) - rdt_ice * resto(ji,jj,1) * ( frld(ji,jj)  - frld_dta (ji,jj) )  
+         END DO
+      END DO
+      !
+   END SUBROUTINE lim_dmp_2
+
+
+   SUBROUTINE dta_lim_2( kt ) 
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE dta_lim_2  ***
+      !!
+      !! ** Purpose :   Reads monthly ice thickness and fraction lead  data
+      !!
+      !! ** Method  :   Read on unit numicedt the interpolated ice variable
+      !!      onto the model grid.
+      !!      Data begin at january.
+      !!      The value is centered at the middle of month.
+      !!      In the opa model, kt=1 agree with january 1.
+      !!      At each time step, a linear interpolation is applied between
+      !!      two monthly values.
+      !!      
+      !! ** Action  :   define hicif_dta and frld_dta arrays at time-step kt
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !
+      INTEGER  ::   imois, iman, i15          ! temporary integers
+      REAL(wp) ::   zxy
+      !!----------------------------------------------------------------------
+
+      ! 0. Initialization
+      ! -----------------
+      iman  = INT( raamo )
+!!! better but change the results     i15 = INT( 2*FLOAT( nday ) / ( FLOAT( nobis(nmonth) ) + 0.5 ) )
+      i15   = nday / 16
+      imois = nmonth + i15 - 1
+      IF( imois == 0 ) imois = iman
+      
+      ! 1. First call kt=nit000: Initialization and Open
+      ! -----------------------
+      IF( kt == nit000 ) THEN
+         nice1 = 0
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dtalim : Ice thickness and lead fraction  monthly fields'
+         IF(lwp) WRITE(numout,*) '~~~~~~'
+         IF(lwp) WRITE(numout,*) '             NetCDF FORMAT'
+         IF(lwp) WRITE(numout,*)
+         ! open file
+         CALL iom_open( 'ice_damping_ATL4.nc', inumice_dmp )
+      ENDIF
+
+
+      ! 2. Read monthly file
+      ! --------------------
+      IF( ( kt == nit000 ) .OR. imois /= nice1 ) THEN
+         !
+         ! Calendar computation
+         nice1 = imois        ! first file record used 
+         nice2 = nice1 + 1    ! last  file record used
+         nice1 = MOD( nice1, iman )
+         nice2 = MOD( nice2, iman )
+         IF( nice1 == 0 )   nice1 = iman
+         IF( nice2 == 0 )   nice2 = iman
+         IF(lwp) WRITE(numout,*) 'first record file used nice1 ', nice1
+         IF(lwp) WRITE(numout,*) 'last  record file used nice2 ', nice2
+         
+         ! Read monthly ice thickness Levitus 
+         CALL iom_get( inumice_dmp, jpdom_data, 'iicethic', hicif_data(:,:,1), nice1 ) 
+         CALL iom_get( inumice_dmp, jpdom_data, 'iicethic', hicif_data(:,:,2), nice2 ) 
+         
+         ! Read monthly ice thickness Levitus 
+         CALL iom_get( inumice_dmp, jpdom_data, 'ileadfra', frld_data(:,:,1), nice1 ) 
+         CALL iom_get( inumice_dmp, jpdom_data, 'ileadfra', frld_data(:,:,2), nice2 ) 
+         
+         ! The fraction lead read in the file is in fact the 
+         ! ice concentration which is 1 - the fraction lead
+         frld_data = 1 - frld_data          
+         
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) ' Ice thickness month ', nice1,' and ', nice2
+            WRITE(numout,*)
+            WRITE(numout,*) ' Ice thickness month = ', nice1
+            CALL prihre( hicif_data(1,1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+            WRITE(numout,*)
+            WRITE(numout,*) ' Fraction lead months ', nice1,' and ', nice2
+            WRITE(numout,*)
+            WRITE(numout,*) ' Fraction lead month = ', nice1
+            CALL prihre( frld_data(1,1,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1., numout )
+         ENDIF
+
+         CALL FLUSH(numout)
+
+      ENDIF
+        
+      ! 3. At every time step compute ice thickness and fraction lead data
+      ! ------------------------------------------------------------------
+      zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
+      hicif_dta(:,:) = (1.-zxy) * hicif_data(:,:,1) + zxy * hicif_data(:,:,2)
+      frld_dta (:,:) = (1.-zxy) * frld_data (:,:,1) + zxy * frld_data (:,:,2)
+
+      IF( kt == nitend )   CALL iom_close( inumice_dmp )
+      !
+   END SUBROUTINE dta_lim_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty Module                  No ice damping
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_dmp_2( kt )        ! Dummy routine
+      WRITE(*,*) 'lim_dmp_2: You should not see this print! error? ', kt
+   END SUBROUTINE lim_dmp_2
+#endif
+
+   !!======================================================================
+END MODULE limdmp_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limdyn_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limdyn_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limdyn_2.F90	(revision 823)
@@ -0,0 +1,327 @@
+MODULE limdyn_2
+   !!======================================================================
+   !!                     ***  MODULE  limdyn_2  ***
+   !!   Sea-Ice dynamics :  
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!    lim_dyn_2      : computes ice velocities
+   !!    lim_dyn_init_2 : initialization and namelist read
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE in_out_manager  ! I/O manager
+   USE dom_ice_2
+   USE dom_oce         ! ocean space and time domain
+   USE ice_2
+   USE ice_oce
+   USE iceini_2
+   USE limistate_2
+   USE limrhg_2        ! ice rheology
+   USE lbclnk
+   USE lib_mpp
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC lim_dyn_2  ! routine called by ice_step
+
+   !! * Module variables
+   REAL(wp)  ::  rone    = 1.e0   ! constant value
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_dyn_2( kt )
+      !!-------------------------------------------------------------------
+      !!               ***  ROUTINE lim_dyn_2  ***
+      !!               
+      !! ** Purpose :   compute ice velocity and ocean-ice stress
+      !!                
+      !! ** Method  : 
+      !!
+      !! ** Action  : - Initialisation
+      !!              - Call of the dynamic routine for each hemisphere
+      !!              - computation of the stress at the ocean surface         
+      !!              - treatment of the case if no ice dynamic
+      !! History :
+      !!   1.0  !  01-04  (LIM)  Original code
+      !!   2.0  !  02-08  (C. Ethe, G. Madec)  F90, mpp
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+
+      INTEGER ::   ji, jj             ! dummy loop indices
+      INTEGER ::   i_j1, i_jpj        ! Starting/ending j-indices for rheology
+      REAL(wp) ::   &
+         ztairx, ztairy,           &  ! tempory scalars
+         zsang , zmod,             &
+         ztglx , ztgly ,           &
+         zt11, zt12, zt21, zt22 ,  &
+         zustm, zsfrld, zsfrldm4,  &
+         zu_ice, zv_ice, ztair2
+      REAL(wp),DIMENSION(jpj) ::   &
+         zind,                     &  ! i-averaged indicator of sea-ice
+         zmsk                         ! i-averaged of tmask
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000  )   CALL lim_dyn_init_2   ! Initialization (first time-step only)
+      
+      IF ( ln_limdyn ) THEN
+
+         ! Mean ice and snow thicknesses.          
+         hsnm(:,:)  = ( 1.0 - frld(:,:) ) * hsnif(:,:)
+         hicm(:,:)  = ( 1.0 - frld(:,:) ) * hicif(:,:)
+
+         u_oce(:,:)  = u_io(:,:) * tmu(:,:)
+         v_oce(:,:)  = v_io(:,:) * tmu(:,:)
+       
+         !                                         ! Rheology (ice dynamics)
+         !                                         ! ========
+         
+         !  Define the j-limits where ice rheology is computed
+         ! ---------------------------------------------------
+         
+         IF( lk_mpp .OR. nbit_cmp == 1 ) THEN                    ! mpp: compute over the whole domain
+            i_j1 = 1   
+            i_jpj = jpj
+            IF(ln_ctl)    THEN
+               CALL prt_ctl_info('lim_dyn  :    i_j1 = ', ivar1=i_j1, clinfo2=' ij_jpj = ', ivar2=i_jpj)
+            ENDIF
+            CALL lim_rhg_2( i_j1, i_jpj )
+
+         ELSE                                 ! optimization of the computational area
+
+            DO jj = 1, jpj
+               zind(jj) = SUM( frld (:,jj  ) )   ! = FLOAT(jpj) if ocean everywhere on a j-line
+               zmsk(jj) = SUM( tmask(:,jj,1) )   ! = 0          if land  everywhere on a j-line
+   !!i         write(numout,*) narea, 'limdyn' , jj, zind(jj), zmsk(jj)
+            END DO
+
+            IF( l_jeq ) THEN                     ! local domain include both hemisphere
+               !                                 ! Rheology is computed in each hemisphere
+               !                                 ! only over the ice cover latitude strip
+               ! Northern hemisphere
+               i_j1  = njeq
+               i_jpj = jpj
+               DO WHILE ( i_j1 <= jpj .AND. zind(i_j1) == FLOAT(jpi) .AND. zmsk(i_j1) /=0 )
+                  i_j1 = i_j1 + 1
+               END DO
+               i_j1 = MAX( 1, i_j1-1 )
+               IF(ln_ctl)   WRITE(numout,*) 'lim_dyn : NH i_j1 = ', i_j1, ' ij_jpj = ', i_jpj
+    
+               CALL lim_rhg_2( i_j1, i_jpj )
+    
+               ! Southern hemisphere
+               i_j1  =  1 
+               i_jpj = njeq
+               DO WHILE ( i_jpj >= 1 .AND. zind(i_jpj) == FLOAT(jpi) .AND. zmsk(i_jpj) /=0 )
+                  i_jpj = i_jpj - 1
+               END DO
+               i_jpj = MIN( jpj, i_jpj+2 )
+               IF(ln_ctl)   WRITE(numout,*) 'lim_dyn : SH i_j1 = ', i_j1, ' ij_jpj = ', i_jpj
+    
+               CALL lim_rhg_2( i_j1, i_jpj )
+    
+            ELSE                                 ! local domain extends over one hemisphere only
+               !                                 ! Rheology is computed only over the ice cover
+               !                                 ! latitude strip
+               i_j1  = 1
+               DO WHILE ( i_j1 <= jpj .AND. zind(i_j1) == FLOAT(jpi) .AND. zmsk(i_j1) /=0 )
+                  i_j1 = i_j1 + 1
+               END DO
+               i_j1 = MAX( 1, i_j1-1 )
+    
+               i_jpj  = jpj
+               DO WHILE ( i_jpj >= 1  .AND. zind(i_jpj) == FLOAT(jpi) .AND. zmsk(i_jpj) /=0 )
+                  i_jpj = i_jpj - 1
+               END DO
+               i_jpj = MIN( jpj, i_jpj+2)
+    
+               IF(ln_ctl)   WRITE(numout,*) 'lim_dyn : one hemisphere: i_j1 = ', i_j1, ' ij_jpj = ', i_jpj
+    
+               CALL lim_rhg_2( i_j1, i_jpj )
+
+            ENDIF
+
+         ENDIF
+
+         IF(ln_ctl)   THEN 
+            CALL prt_ctl(tab2d_1=u_oce , clinfo1=' lim_dyn  : u_oce :', tab2d_2=v_oce , clinfo2=' v_oce :')
+            CALL prt_ctl(tab2d_1=u_ice , clinfo1=' lim_dyn  : u_ice :', tab2d_2=v_ice , clinfo2=' v_ice :')
+         ENDIF
+         
+         !                                         ! Ice-Ocean stress
+         !                                         ! ================
+         DO jj = 2, jpjm1
+            zsang  = SIGN(1.e0, gphif(1,jj-1) ) * sangvg
+            DO ji = 2, jpim1
+               ! computation of wind stress over ocean in X and Y direction
+#if defined key_coupled && defined key_lim_cp1
+               ztairx =  frld(ji-1,jj  ) * gtaux(ji-1,jj  ) + frld(ji,jj  ) * gtaux(ji,jj  )      &
+                  &    + frld(ji-1,jj-1) * gtaux(ji-1,jj-1) + frld(ji,jj-1) * gtaux(ji,jj-1)
+
+               ztairy =  frld(ji-1,jj  ) * gtauy(ji-1,jj  ) + frld(ji,jj  ) * gtauy(ji,jj  )      &
+                  &    + frld(ji-1,jj-1) * gtauy(ji-1,jj-1) + frld(ji,jj-1) * gtauy(ji,jj-1)
+#else
+               zsfrld  = frld(ji,jj) + frld(ji-1,jj) + frld(ji-1,jj-1) + frld(ji,jj-1)
+               ztairx  = zsfrld * gtaux(ji,jj)
+               ztairy  = zsfrld * gtauy(ji,jj)
+#endif
+               zsfrldm4 = 4 - frld(ji,jj) - frld(ji-1,jj) - frld(ji-1,jj-1) - frld(ji,jj-1)
+               zu_ice   = u_ice(ji,jj) - u_oce(ji,jj)
+               zv_ice   = v_ice(ji,jj) - v_oce(ji,jj)
+               zmod     = SQRT( zu_ice * zu_ice + zv_ice * zv_ice ) 
+               ztglx   = zsfrldm4 * rhoco * zmod * ( cangvg * zu_ice - zsang * zv_ice ) 
+               ztgly   = zsfrldm4 * rhoco * zmod * ( cangvg * zv_ice + zsang * zu_ice ) 
+
+               tio_u(ji,jj) = - ( ztairx + 1.0 * ztglx ) / ( 4 * rau0 )
+               tio_v(ji,jj) = - ( ztairy + 1.0 * ztgly ) / ( 4 * rau0 )
+            END DO
+         END DO
+         
+         ! computation of friction velocity
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+
+               zu_ice   = u_ice(ji-1,jj-1) - u_oce(ji-1,jj-1)
+               zv_ice   = v_ice(ji-1,jj-1) - v_oce(ji-1,jj-1)
+               zt11  = rhoco * ( zu_ice * zu_ice + zv_ice * zv_ice )
+
+               zu_ice   = u_ice(ji-1,jj) - u_oce(ji-1,jj)
+               zv_ice   = v_ice(ji-1,jj) - v_oce(ji-1,jj)
+               zt12  = rhoco * ( zu_ice * zu_ice + zv_ice * zv_ice ) 
+
+               zu_ice   = u_ice(ji,jj-1) - u_oce(ji,jj-1)
+               zv_ice   = v_ice(ji,jj-1) - v_oce(ji,jj-1)
+               zt21  = rhoco * ( zu_ice * zu_ice + zv_ice * zv_ice ) 
+
+               zu_ice   = u_ice(ji,jj) - u_oce(ji,jj)
+               zv_ice   = v_ice(ji,jj) - v_oce(ji,jj)
+               zt22  = rhoco * ( zu_ice * zu_ice + zv_ice * zv_ice ) 
+
+               ztair2 = gtaux(ji,jj) * gtaux(ji,jj) + gtauy(ji,jj) * gtauy(ji,jj)
+
+               zustm =  ( 1 - frld(ji,jj) ) * 0.25 * ( zt11 + zt12 + zt21 + zt22 )        &
+                  &  +        frld(ji,jj)   * SQRT( ztair2 )
+
+               ust2s(ji,jj) = ( zustm / rau0 ) * ( rone + sdvt(ji,jj) ) * tms(ji,jj)
+            END DO
+         END DO
+
+       ELSE      ! no ice dynamics : transmit directly the atmospheric stress to the ocean
+                    
+          DO jj = 2, jpjm1
+             DO ji = 2, jpim1
+#if defined key_coupled && defined key_lim_cp1
+                tio_u(ji,jj) = - (  gtaux(ji  ,jj  ) + gtaux(ji-1,jj  )       &
+                   &              + gtaux(ji-1,jj-1) + gtaux(ji  ,jj-1) ) / ( 4 * rau0 )
+
+                tio_v(ji,jj) = - (  gtauy(ji  ,jj )  + gtauy(ji-1,jj  )       &
+                   &              + gtauy(ji-1,jj-1) + gtauy(ji  ,jj-1) ) / ( 4 * rau0 )
+#else
+                tio_u(ji,jj) = - gtaux(ji,jj) / rau0
+                tio_v(ji,jj) = - gtauy(ji,jj) / rau0 
+#endif
+                ztair2       = gtaux(ji,jj) * gtaux(ji,jj) + gtauy(ji,jj) * gtauy(ji,jj)
+                zustm        = SQRT( ztair2  )
+
+                ust2s(ji,jj) = ( zustm / rau0 ) * ( rone + sdvt(ji,jj) ) * tms(ji,jj)
+            END DO
+         END DO
+
+      ENDIF
+
+      CALL lbc_lnk( ust2s, 'T',  1. )   ! T-point
+      CALL lbc_lnk( tio_u, 'I', -1. )   ! I-point (i.e. ice U-V point)
+      CALL lbc_lnk( tio_v, 'I', -1. )   ! I-point (i.e. ice U-V point)
+
+      IF(ln_ctl) THEN 
+            CALL prt_ctl(tab2d_1=tio_u , clinfo1=' lim_dyn  : tio_u :', tab2d_2=tio_v , clinfo2=' tio_v :')
+            CALL prt_ctl(tab2d_1=ust2s , clinfo1=' lim_dyn  : ust2s :')
+      ENDIF
+
+   END SUBROUTINE lim_dyn_2
+
+
+   SUBROUTINE lim_dyn_init_2
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_dyn_init_2  ***
+      !!
+      !! ** Purpose : Physical constants and parameters linked to the ice
+      !!      dynamics
+      !!
+      !! ** Method  :  Read the namicedyn namelist and check the ice-dynamic
+      !!       parameter values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicedyn
+      !!
+      !! history :
+      !!  8.5  ! 03-08 (C. Ethe) original code
+      !!-------------------------------------------------------------------
+      NAMELIST/namicedyn/ epsd, alpha,     &
+         &                dm, nbiter, nbitdr, om, resl, cw, angvg, pstar,   &
+         &                c_rhg, etamn, creepl, ecc, ahi0
+      !!-------------------------------------------------------------------
+
+      ! Define the initial parameters
+      ! -------------------------
+
+      ! Read Namelist namicedyn
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice  , namicedyn )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_dyn_init_2: ice parameters for ice dynamics '
+         WRITE(numout,*) '~~~~~~~~~~~~~~'
+         WRITE(numout,*) '       tolerance parameter                              epsd   = ', epsd
+         WRITE(numout,*) '       coefficient for semi-implicit coriolis           alpha  = ', alpha
+         WRITE(numout,*) '       diffusion constant for dynamics                  dm     = ', dm
+         WRITE(numout,*) '       number of sub-time steps for relaxation          nbiter = ', nbiter
+         WRITE(numout,*) '       maximum number of iterations for relaxation      nbitdr = ', nbitdr
+         WRITE(numout,*) '       relaxation constant                              om     = ', om
+         WRITE(numout,*) '       maximum value for the residual of relaxation     resl   = ', resl
+         WRITE(numout,*) '       drag coefficient for oceanic stress              cw     = ', cw
+         WRITE(numout,*) '       turning angle for oceanic stress                 angvg  = ', angvg
+         WRITE(numout,*) '       first bulk-rheology parameter                    pstar  = ', pstar
+         WRITE(numout,*) '       second bulk-rhelogy parameter                    c_rhg  = ', c_rhg
+         WRITE(numout,*) '       minimun value for viscosity                      etamn  = ', etamn
+         WRITE(numout,*) '       creep limit                                      creepl = ', creepl
+         WRITE(numout,*) '       eccentricity of the elliptical yield curve       ecc    = ', ecc
+         WRITE(numout,*) '       horizontal diffusivity coeff. for sea-ice        ahi0   = ', ahi0
+      ENDIF
+
+      !  Initialization
+      usecc2 = 1.0 / ( ecc * ecc )
+      rhoco  = rau0 * cw
+      angvg  = angvg * rad
+      sangvg = SIN( angvg )
+      cangvg = COS( angvg )
+      pstarh = pstar / 2.0
+      sdvt(:,:) = 0.e0
+
+      !  Diffusion coefficients.
+      ahiu(:,:) = ahi0 * umask(:,:,1)
+      ahiv(:,:) = ahi0 * vmask(:,:,1)
+
+   END SUBROUTINE lim_dyn_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Empty module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_dyn_2         ! Empty routine
+   END SUBROUTINE lim_dyn_2
+#endif 
+
+   !!======================================================================
+END MODULE limdyn_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limflx_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limflx_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limflx_2.F90	(revision 823)
@@ -0,0 +1,219 @@
+MODULE limflx_2
+   !!======================================================================
+   !!                       ***  MODULE limflx_2   ***
+   !!           computation of the flux at the sea ice/ocean interface
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_flx_2  : flux at the ice / ocean interface
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE phycst           ! physical constants
+   USE ocfzpt           ! surface ocean freezing point
+   USE ice_oce          ! sea-ice variable
+   USE flx_oce          ! sea-ice/ocean forcings variables
+   USE ice_2             ! LIM sea-ice variables
+   USE flxblk_2           ! bulk formulea
+   USE lbclnk           ! ocean lateral boundary condition
+   USE in_out_manager   ! I/O manager
+   USE albedo_2         ! albedo parameters
+   USE prtctl           ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_flx_2     ! called by lim_step_2
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi16 = 1.e-16  ,  &
+      rzero  = 0.e0    ,  &
+      rone   = 1.e0
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE lim_flx_2
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE lim_flx_2 ***
+      !!  
+      !! ** Purpose : Computes the mass and heat fluxes to the ocean
+      !!         
+      !! ** Action  : - Initialisation of some variables
+      !!              - comput. of the fluxes at the sea ice/ocean interface
+      !!     
+      !! ** Outputs : - fsolar  : solar heat flux at sea ice/ocean interface
+      !!              - fnsolar : non solar heat flux 
+      !!              - fsalt   : salt flux at sea ice/ocean interface
+      !!              - fmass   : freshwater flux at sea ice/ocean interface
+      !!
+      !! ** References :
+      !!       H. Goosse et al. 1996, Bul. Soc. Roy. Sc. Liege, 65, 87-90
+      !!         original    : 00-01 (LIM)
+      !!         addition    : 02-07 (C. Ethe, G. Madec)
+      !!---------------------------------------------------------------------
+      !! * Local variables
+      INTEGER ::   ji, jj         ! dummy loop indices
+
+      INTEGER ::   &
+         ifvt, i1mfr, idfr ,   &  ! some switches
+         iflt, ial, iadv, ifral, ifrdv
+      
+      REAL(wp) ::   &
+         zinda  ,              &  ! switch for testing the values of ice concentration
+         z1mthcm                  ! 1 - thcm
+!!         zfcm1  ,              &  ! solar  heat fluxes
+!!         zfcm2  ,              &  !  non solar heat fluxes
+#if defined key_lim_fdd   
+      REAL(wp) ::   &
+         zfons,                &  ! salt exchanges at the ice/ocean interface
+         zpme                     ! freshwater exchanges at the ice/ocean interface
+#else
+      REAL(wp) ::   &
+         zprs  , zfons,        &  ! salt exchanges at the ice/ocean interface
+         zpmess                   ! freshwater exchanges at the ice/ocean interface
+#endif
+      REAL(wp), DIMENSION(jpi,jpj) ::  &
+         zfcm1  ,              &  ! solar  heat fluxes
+         zfcm2                    !  non solar heat fluxes      
+#if defined key_coupled    
+      REAL(wp), DIMENSION(jpi,jpj) ::  &
+         zalb  ,               &  ! albedo of ice under overcast sky
+         zalcn ,               &  ! albedo of ocean under overcast sky
+         zalbp ,               &  ! albedo of ice under clear sky
+         zaldum                   ! albedo of ocean under clear sky
+#endif
+      !!---------------------------------------------------------------------
+     
+      !---------------------------------!
+      !      Sea ice/ocean interface    !
+      !---------------------------------!
+       
+       
+      !      heat flux at the ocean surface
+      !-------------------------------------------------------
+       
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            zinda   = 1.0 - MAX( rzero , SIGN( rone , - ( 1.0 - pfrld(ji,jj) ) ) )
+            ifvt    = zinda  *  MAX( rzero , SIGN( rone, -phicif(ji,jj) ) )
+            i1mfr   = 1.0 - MAX( rzero , SIGN( rone ,  - ( 1.0 - frld(ji,jj) ) ) )
+            idfr    = 1.0 - MAX( rzero , SIGN( rone , frld(ji,jj) - pfrld(ji,jj) ) )
+            iflt    = zinda  * (1 - i1mfr) * (1 - ifvt )
+            ial     = ifvt   * i1mfr + ( 1 - ifvt ) * idfr
+            iadv    = ( 1  - i1mfr ) * zinda
+            ifral   = ( 1  - i1mfr * ( 1 - ial ) )   
+            ifrdv   = ( 1  - ifral * ( 1 - ial ) ) * iadv 
+            z1mthcm =   1. - thcm(ji,jj)       
+            !   computation the solar flux at ocean surface
+            zfcm1(ji,jj)   = pfrld(ji,jj) * qsr_oce(ji,jj)  + ( 1. - pfrld(ji,jj) ) * fstric(ji,jj)
+            !  computation the non solar heat flux at ocean surface
+            zfcm2(ji,jj) =  - z1mthcm * zfcm1(ji,jj)   &
+               &           + iflt    * ( fscmbq(ji,jj) + ffltbif(ji,jj) )                            &
+               &           + ifral   * ( ial * qcmif(ji,jj) + (1 - ial) * qldif(ji,jj) ) / rdt_ice   &
+               &           + ifrdv   * ( qfvbq(ji,jj) + qdtcn(ji,jj) ) / rdt_ice
+
+            fsbbq(ji,jj) = ( 1.0 - ( ifvt + iflt ) ) * fscmbq(ji,jj)     ! ???
+            
+            fsolar (ji,jj) = zfcm1(ji,jj)                                       ! solar heat flux 
+
+            fnsolar(ji,jj) = zfcm2(ji,jj) - fdtcn(ji,jj)                        ! non solar heat flux
+         END DO
+      END DO
+  
+       
+      !      mass flux at the ocean surface
+      !-------------------------------------------------------
+       
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+#if defined key_lim_fdd
+            !  case of realistic freshwater flux (Tartinville et al., 2001)
+            
+            !  computing freshwater exchanges at the ice/ocean interface
+            zpme = - evap(ji,jj) * frld(ji,jj)            &   !  evaporation over oceanic fraction
+               &   + tprecip(ji,jj)                            &   !  total precipitation
+               &   - sprecip(ji,jj) * ( 1. - pfrld(ji,jj) )  &   !  remov. snow precip over ice
+               &   - rdmsnif(ji,jj) / rdt_ice                   !  freshwaterflux due to snow melting 
+            
+            !  computing salt exchanges at the ice/ocean interface
+            zfons =  ( soce - sice ) * ( rdmicif(ji,jj) / rdt_ice ) 
+            
+            !  converting the salt flux from ice to a freshwater flux from ocean
+            fsalt(ji,jj) = zfons / ( sss_io(ji,jj) + epsi16 )
+            
+            !  freshwater masses
+            fmass(ji,jj) = - zpme 
+#else
+            !  case of freshwater flux equivalent as salt flux
+            !  dilution effect due to evaporation and precipitation
+            zprs  = ( tprecip(ji,jj) - sprecip(ji,jj) * ( 1. - pfrld(ji,jj) ) ) * soce  
+            !  freshwater flux
+            zfons = rdmicif(ji,jj) * ( soce - sice )  &  !  fwf : ice formation and melting
+               &   -  dmgwi(ji,jj) * sice             &  !  fwf : salt flx needed to bring the fresh snow to sea/ice salinity
+               &   + rdmsnif(ji,jj) * soce               !  fwf to ocean due to snow melting 
+            !  salt exchanges at the ice/ocean interface
+            zpmess         =  zprs - zfons / rdt_ice - evap(ji,jj) * soce * frld(ji,jj)
+            fsalt(ji,jj) =  - zpmess
+#endif
+         END DO
+      END DO
+
+
+      !-------------------------------------------------------------------!
+      !  computation of others transmitting variables from ice to ocean   !
+      !------------------------------------------ ------------------------!
+
+      !-----------------------------------------------!
+      !   Storing the transmitted variables           !
+      !-----------------------------------------------!
+
+      ftaux (:,:) = - tio_u(:,:) * rau0   ! taux ( ice: N/m2/rau0, ocean: N/m2 )
+      ftauy (:,:) = - tio_v(:,:) * rau0   ! tauy ( ice: N/m2/rau0, ocean: N/m2 )                
+      freeze(:,:) = 1.0 - frld(:,:)       ! Sea ice cover            
+      tn_ice(:,:) = sist(:,:)             ! Ice surface temperature                      
+
+#if defined key_coupled            
+      zalb  (:,:) = 0.e0
+      zalcn (:,:) = 0.e0
+      zalbp (:,:) = 0.e0
+      zaldum(:,:) = 0.e0
+
+      !------------------------------------------------!
+      !  2) Computation of snow/ice and ocean albedo   !
+      !------------------------------------------------!
+      CALL flx_blk_albedo_2( zalb, zalcn, zalbp, zaldum )
+
+      alb_ice(:,:) =  0.5 * zalbp(:,:) + 0.5 * zalb (:,:)   ! Ice albedo                       
+#endif
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=fsolar, clinfo1=' lim_flx: fsolar : ', tab2d_2=fnsolar, clinfo2=' fnsolar : ')
+         CALL prt_ctl(tab2d_1=fmass , clinfo1=' lim_flx: fmass  : ', tab2d_2=fsalt  , clinfo2=' fsalt   : ')
+         CALL prt_ctl(tab2d_1=ftaux , clinfo1=' lim_flx: ftaux  : ', tab2d_2=ftauy  , clinfo2=' ftauy   : ')
+         CALL prt_ctl(tab2d_1=freeze, clinfo1=' lim_flx: freeze : ', tab2d_2=tn_ice , clinfo2=' tn_ice  : ')
+      ENDIF 
+   
+    END SUBROUTINE lim_flx_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :        Dummy module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_flx_2       ! Dummy routine
+   END SUBROUTINE lim_flx_2
+#endif 
+
+   !!======================================================================
+END MODULE limflx_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limhdf_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limhdf_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limhdf_2.F90	(revision 823)
@@ -0,0 +1,185 @@
+MODULE limhdf_2
+   !!======================================================================
+   !!                    ***  MODULE limhdf_2   ***
+   !! LIM 2.0 ice model : horizontal diffusion of sea-ice quantities
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'  i                                 LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_hdf_2  : diffusion trend on sea-ice variable
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE dom_oce
+   USE ice_oce         ! ice variables
+   USE in_out_manager
+   USE ice_2
+   USE lbclnk
+   USE lib_mpp
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_hdf_2    ! called by lim_tra_2
+
+   !! * Module variables
+   LOGICAL  ::   linit = .TRUE.              ! ???
+   REAL(wp) ::   epsi04 = 1e-04              ! constant
+   REAL(wp), DIMENSION(jpi,jpj) ::   zfact   ! ???
+
+   !! * Substitution 
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_hdf_2( ptab )
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_hdf_2  ***
+      !!
+      !! ** purpose :   Compute and add the diffusive trend on sea-ice
+      !!      variables
+      !!
+      !! ** method  :   Second order diffusive operator evaluated using a
+      !!      Cranck-Nicholson time Scheme.
+      !!
+      !! ** Action  :    update ptab with the diffusive contribution
+      !!
+      !! History :
+      !!        !  00-01 (LIM) Original code
+      !!        !  01-05 (G. Madec, R. Hordoir) opa norm
+      !!        !  02-08 (C. Ethe)  F90, free form
+      !!-------------------------------------------------------------------
+      ! * Arguments
+      REAL(wp), DIMENSION(jpi,jpj), INTENT( inout ) ::   &
+         ptab                 ! Field on which the diffusion is applied  
+      REAL(wp), DIMENSION(jpi,jpj) ::   &
+         ptab0                ! ???
+
+      ! * Local variables
+      INTEGER ::  ji, jj      ! dummy loop indices
+      INTEGER ::  &
+         its, iter            ! temporary integers
+      CHARACTER (len=55) :: charout
+      REAL(wp) ::  &
+         zalfa, zrlxint, zconv, zeps   ! temporary scalars
+      REAL(wp), DIMENSION(jpi,jpj) ::  & 
+         zrlx, zflu, zflv, &  ! temporary workspaces
+         zdiv0, zdiv          !    "           "
+      !!-------------------------------------------------------------------
+
+      ! Initialisation
+      ! ---------------   
+      ! Time integration parameters
+      zalfa = 0.5       ! =1.0/0.5/0.0 = implicit/Cranck-Nicholson/explicit
+      its   = 100       ! Maximum number of iteration
+      zeps  =  2. * epsi04
+
+      ! Arrays initialization
+      ptab0 (:, : ) = ptab(:,:)
+!bug  zflu (:,jpj) = 0.e0
+!bug  zflv (:,jpj) = 0.e0
+      zdiv0(:, 1 ) = 0.e0
+      zdiv0(:,jpj) = 0.e0
+      IF( .NOT.lk_vopt_loop ) THEN
+         zflu (jpi,:) = 0.e0   
+         zflv (jpi,:) = 0.e0
+         zdiv0(1,  :) = 0.e0
+         zdiv0(jpi,:) = 0.e0
+      ENDIF
+
+      ! Metric coefficient (compute at the first call and saved in
+      IF( linit ) THEN
+         DO jj = 2, jpjm1  
+            DO ji = fs_2 , fs_jpim1   ! vector opt.
+               zfact(ji,jj) = ( e2u(ji,jj) + e2u(ji-1,jj  ) + e1v(ji,jj) + e1v(ji,jj-1) ) &
+                  &          / ( e1t(ji,jj) * e2t(ji,jj) )
+            END DO
+         END DO
+         linit = .FALSE.
+      ENDIF
+
+
+      ! Sub-time step loop
+      zconv = 1.e0
+      iter  = 0
+
+      !                                                   !===================
+      DO WHILE ( ( zconv > zeps ) .AND. (iter <= its) )   ! Sub-time step loop
+         !                                                !===================
+         ! incrementation of the sub-time step number
+         iter = iter + 1
+
+         ! diffusive fluxes in U- and V- direction
+         DO jj = 1, jpjm1
+            DO ji = 1 , fs_jpim1   ! vector opt.
+               zflu(ji,jj) = pahu(ji,jj) * e2u(ji,jj) / e1u(ji,jj) * ( ptab(ji+1,jj) - ptab(ji,jj) )
+               zflv(ji,jj) = pahv(ji,jj) * e1v(ji,jj) / e2v(ji,jj) * ( ptab(ji,jj+1) - ptab(ji,jj) )
+            END DO
+         END DO
+
+         ! diffusive trend : divergence of the fluxes
+         DO jj= 2, jpjm1
+            DO ji = fs_2 , fs_jpim1   ! vector opt. 
+               zdiv (ji,jj) = (  zflu(ji,jj) - zflu(ji-1,jj  )   &
+                  &            + zflv(ji,jj) - zflv(ji  ,jj-1)  ) / ( e1t (ji,jj) * e2t (ji,jj) )
+            END DO
+         END DO
+
+         ! save the first evaluation of the diffusive trend in zdiv0
+         IF( iter == 1 )   zdiv0(:,:) = zdiv(:,:)       
+
+         ! XXXX iterative evaluation?????
+         DO jj = 2, jpjm1
+            DO ji = fs_2 , fs_jpim1   ! vector opt.
+               zrlxint = (   ptab0(ji,jj)    &
+                  &       +  rdt_ice * (           zalfa   * ( zdiv(ji,jj) + zfact(ji,jj) * ptab(ji,jj) )   &
+                  &                      + ( 1.0 - zalfa ) *   zdiv0(ji,jj) )  )                             & 
+                  &    / ( 1.0 + zalfa * rdt_ice * zfact(ji,jj) )
+               zrlx(ji,jj) = ptab(ji,jj) + om * ( zrlxint - ptab(ji,jj) )
+            END DO
+         END DO
+
+         ! lateral boundary condition on ptab
+         CALL lbc_lnk( zrlx, 'T', 1. )
+
+         ! convergence test
+         zconv = 0.e0
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               zconv = MAX( zconv, ABS( zrlx(ji,jj) - ptab(ji,jj) )  )
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_max( zconv )   ! max over the global domain
+
+         ptab(:,:) = zrlx(:,:)
+
+         !                                         !==========================
+      END DO                                       ! end of sub-time step loop
+      !                                            !==========================
+
+      IF(ln_ctl)   THEN
+         zrlx(:,:) = ptab(:,:) - ptab0(:,:)
+         WRITE(charout,FMT="(' lim_hdf  : zconv =',D23.16, ' iter =',I4,2X)") zconv, iter
+         CALL prt_ctl(tab2d_1=zrlx, clinfo1=charout)
+      ENDIF
+
+   END SUBROUTINE lim_hdf_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Dummy module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_hdf_2       ! Empty routine
+   END SUBROUTINE lim_hdf_2
+#endif
+
+   !!======================================================================
+END MODULE limhdf_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limistate_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limistate_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limistate_2.F90	(revision 823)
@@ -0,0 +1,286 @@
+MODULE limistate_2
+   !!======================================================================
+   !!                     ***  MODULE  limistate_2  ***
+   !!              Initialisation of diagnostics ice variables
+   !!======================================================================
+   !! History :   2.0  !  01-04  (C. Ethe, G. Madec)  Original code
+   !!                  !  04-04  (S. Theetten) initialization from a file
+   !!                  !  06-07  (S. Masson)  IOM to read the restart
+   !!--------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_istate_2      :  Initialisation of diagnostics ice variables
+   !!   lim_istate_init_2 :  initialization of ice state and namelist read
+   !!----------------------------------------------------------------------
+   USE phycst
+   USE ocfzpt
+   USE oce             ! dynamics and tracers variables      !!gm used???
+   USE dom_oce                                                     !!gm used???
+   USE par_ice_2       ! ice parameters
+   USE ice_oce         ! ice variables
+   USE dom_ice_2
+   USE lbclnk
+   USE ice_2
+   USE iom
+   USE in_out_manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC lim_istate_2      ! routine called by lim_init_2.F90
+
+   REAL(wp) ::           &  !!! ** init namelist (namiceini) **
+      ttest  = 2.0  ,    &  ! threshold water temperature for initial sea ice
+      hninn  = 0.5  ,    &  ! initial snow thickness in the north
+      hginn  = 3.0  ,    &  ! initial ice thickness in the north
+      alinn  = 0.05 ,    &  ! initial leads area in the north
+      hnins  = 0.1  ,    &  ! initial snow thickness in the south
+      hgins  = 1.0  ,    &  ! initial ice thickness in the south
+      alins  = 0.1          ! initial leads area in the south
+
+   REAL(wp)  ::          &  ! constant values
+      zzero   = 0.e0  ,  &
+      zone    = 1.e0
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2006) 
+   !! $Header$ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_istate_2
+      !!-------------------------------------------------------------------
+      !!                    ***  ROUTINE lim_istate_2  ***
+      !!
+      !! ** Purpose :   defined the sea-ice initial state
+      !!
+      !! ** Method  :   restart from a state defined in a binary file
+      !!                or from arbitrary sea-ice conditions
+      !!--------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk                ! dummy loop indices
+      REAL(wp) ::   zidto, zs0, ztf, zbin     ! temporary scalar
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztn   ! workspace
+      !--------------------------------------------------------------------
+
+       CALL lim_istate_init_2   !  reading the initials parameters of the ice
+
+      !-- Initialisation of sst,sss,u,v do i=1,jpi
+      u_io(:,:)  = 0.e0       ! ice velocity in x direction
+      v_io(:,:)  = 0.e0       ! ice velocity in y direction
+
+      IF( ln_limini ) THEN    ! 
+        
+         ! Initialisation at tn if no ice or sst_ini if ice
+         ! Idem for salinity
+
+      !--- Criterion for presence (zidto=1.) or absence (zidto=0.) of ice
+         DO jj = 1 , jpj
+            DO ji = 1 , jpi
+               
+               zidto = MAX(zzero, - SIGN(1.,frld(ji,jj) - 1.))
+               
+               sst_io(ji,jj) = ( nfice - 1 ) * (zidto * sst_ini(ji,jj)  + &   ! use the ocean initial values
+                    &          (1.0 - zidto ) * ( tn(ji,jj,1) + rt0 ))        ! tricky trick *(nfice-1) !
+               sss_io(ji,jj) = ( nfice - 1 ) * (zidto * sss_ini(ji,jj) + &
+                    &          (1.0 - zidto ) *  sn(ji,jj,1) )
+
+               ! to avoid the the melting of ice, several layers (mixed layer) should be
+               ! set to sst_ini (sss_ini) if there is ice
+               ! example for one layer 
+               ! tn(ji,jj,1) = zidto * ( sst_ini(ji,jj) - rt0 )  + (1.0 - zidto ) *  tn(ji,jj,1)
+               ! sn(ji,jj,1) = zidto * sss_ini(ji,jj)  + (1.0 - zidto ) *  sn(ji,jj,1)
+               ! tb(ji,jj,1) = tn(ji,jj,1)
+               ! sb(ji,jj,1) = sn(ji,jj,1)
+            END DO
+         END DO
+         
+         
+         !  tfu: Melting point of sea water
+         tfu(:,:)  = ztf   
+         
+         tfu(:,:)  = ABS ( rt0 - 0.0575       * sss_ini(:,:)                               &
+              &                    + 1.710523e-03 * sss_ini(:,:) * SQRT( sss_ini(:,:) )    &
+              &                    - 2.154996e-04 * sss_ini(:,:) * sss_ini(:,:) )
+      ELSE                     !
+
+         
+         ! Initialisation at tn or -2 if ice
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zbin = MAX( 0., SIGN( 1., fzptn(ji,jj) - tn(ji,jj,1) ) )
+               ztn(ji,jj) = ( (1.-zbin) * tn(ji,jj,1) - 2. * zbin + rt0 ) * tmask(ji,jj,1)
+            END DO
+         END DO
+         
+         u_io  (:,:) = 0.e0
+         v_io  (:,:) = 0.e0
+         sst_io(:,:) = ( nfice - 1 ) * ( tn(:,:,1) + rt0 )   ! use the ocean initial values
+         sss_io(:,:) = ( nfice - 1 ) *   sn(:,:,1)           ! tricky trick *(nfice-1) !
+         
+         ! reference salinity 34psu
+         zs0 = 34.e0
+         ztf = ABS ( rt0 - 0.0575       * zs0                           &
+              &                    + 1.710523e-03 * zs0 * SQRT( zs0 )   &
+              &                    - 2.154996e-04 * zs0 *zs0          )
+         
+         !  tfu: Melting point of sea water
+         tfu(:,:)  = ztf   
+         
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               !--- Criterion for presence (zidto=1) or absence (zidto=0) of ice
+               zidto  = tms(ji,jj) * ( 1.0 - MAX(zzero, SIGN( zone, ztn(ji,jj) - tfu(ji,jj) - ttest) ) )
+               
+               IF( fcor(ji,jj) >= 0.e0 ) THEN     !--  Northern hemisphere.
+                  hicif(ji,jj)   = zidto * hginn
+                  frld(ji,jj)    = zidto * alinn + ( 1.0 - zidto ) * 1.0
+                  hsnif(ji,jj)   = zidto * hninn
+               ELSE                               !---  Southern hemisphere.
+                  hicif(ji,jj)   = zidto * hgins
+                  frld(ji,jj)    = zidto * alins + ( 1.0 - zidto ) * 1.0
+                  hsnif(ji,jj)   = zidto * hnins
+               ENDIF
+            END DO
+         END DO
+         
+         sist  (:,:)   = tfu(:,:)
+         tbif  (:,:,1) = tfu(:,:)
+         tbif  (:,:,2) = tfu(:,:)
+         tbif  (:,:,3) = tfu(:,:)
+      
+      ENDIF
+      fsbbq (:,:)   = 0.e0
+      qstoif(:,:)   = 0.e0
+      u_ice (:,:)   = 0.e0
+      v_ice (:,:)   = 0.e0
+# if defined key_coupled
+      albege(:,:)   = 0.8 * tms(:,:)
+# endif
+
+      !---  Moments for advection.             
+
+      sxice (:,:)  = 0.e0   ;   sxsn (:,:)  = 0.e0   ;   sxa  (:,:)  = 0.e0
+      syice (:,:)  = 0.e0   ;   sysn (:,:)  = 0.e0   ;   sya  (:,:)  = 0.e0
+      sxxice(:,:)  = 0.e0   ;   sxxsn(:,:)  = 0.e0   ;   sxxa (:,:)  = 0.e0
+      syyice(:,:)  = 0.e0   ;   syysn(:,:)  = 0.e0   ;   syya (:,:)  = 0.e0
+      sxyice(:,:)  = 0.e0   ;   sxysn(:,:)  = 0.e0   ;   sxya (:,:)  = 0.e0
+
+      sxc0  (:,:)  = 0.e0   ;   sxc1 (:,:)  = 0.e0   ;   sxc2 (:,:)  = 0.e0
+      syc0  (:,:)  = 0.e0   ;   syc1 (:,:)  = 0.e0   ;   syc2 (:,:)  = 0.e0
+      sxxc0 (:,:)  = 0.e0   ;   sxxc1(:,:)  = 0.e0   ;   sxxc2(:,:)  = 0.e0
+      syyc0 (:,:)  = 0.e0   ;   syyc1(:,:)  = 0.e0   ;   syyc2(:,:)  = 0.e0
+      sxyc0 (:,:)  = 0.e0   ;   sxyc1(:,:)  = 0.e0   ;   sxyc2(:,:)  = 0.e0
+
+      sxst  (:,:)  = 0.e0
+      syst  (:,:)  = 0.e0
+      sxxst (:,:)  = 0.e0
+      syyst (:,:)  = 0.e0
+      sxyst (:,:)  = 0.e0
+
+      !-- lateral boundary conditions
+      CALL lbc_lnk( hicif, 'T', 1. )
+      CALL lbc_lnk( frld , 'T', 1. )
+
+      ! C A U T I O N  frld = 1 over land and lbc_lnk put zero along 
+      ! *************  closed boundaries herefore we force to one over land
+      frld(:,:) = tms(:,:) * frld(:,:) + ( 1. - tms(:,:) )   
+
+      CALL lbc_lnk( hsnif, 'T', 1. )
+      CALL lbc_lnk( sist , 'T', 1. )
+      DO jk = 1, jplayersp1
+         CALL lbc_lnk(tbif(:,:,jk), 'T', 1. )
+      END DO
+      CALL lbc_lnk( fsbbq  , 'T', 1. )
+      CALL lbc_lnk( qstoif , 'T', 1. )
+      CALL lbc_lnk( sss_io , 'T', 1. )
+      !
+   END SUBROUTINE lim_istate_2
+
+   
+   SUBROUTINE lim_istate_init_2
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_istate_init_2  ***
+      !!        
+      !! ** Purpose :   Definition of initial state of the ice 
+      !!
+      !! ** Method  :   Read the namiceini namelist and check the parameter 
+      !!                values called at the first timestep (nit000)
+      !!                or
+      !!                Read 7 variables from a previous restart file
+      !!                sst, sst, hicif, hsnif, frld, ts & tbif
+      !!
+      !! ** input   :   Namelist namiceini
+      !!-------------------------------------------------------------------
+      INTEGER :: inum_ice
+      INTEGER :: ji,jj
+
+      NAMELIST/namiceini/ ln_limini, ttest, hninn, hginn, alinn, &
+         &                hnins, hgins, alins
+      !!-------------------------------------------------------------------
+      
+      ! Read Namelist namiceini 
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice , namiceini )
+      
+      IF(.NOT. ln_limini) THEN 
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'lim_istate_init : ice parameters inititialisation '
+            WRITE(numout,*) '~~~~~~~~~~~~~~~'
+            WRITE(numout,*) '         threshold water temp. for initial sea-ice    ttest      = ', ttest
+            WRITE(numout,*) '         initial snow thickness in the north          hninn      = ', hninn
+            WRITE(numout,*) '         initial ice thickness in the north           hginn      = ', hginn 
+            WRITE(numout,*) '         initial leads area in the north              alinn      = ', alinn            
+            WRITE(numout,*) '         initial snow thickness in the south          hnins      = ', hnins 
+            WRITE(numout,*) '         initial ice thickness in the south           hgins      = ', hgins
+            WRITE(numout,*) '         initial leads area in the south              alins      = ', alins
+         ENDIF
+      ENDIF
+
+      IF( ln_limini ) THEN                      ! Ice initialization using input file
+
+         CALL iom_open( 'Ice_initialization.nc', inum_ice )
+
+         IF( inum_ice > 0 ) THEN
+            IF(lwp) THEN
+               WRITE(numout,*) ' '
+               WRITE(numout,*) 'lim_istate_init : ice state initialization with : Ice_initialization.nc'
+               WRITE(numout,*) '~~~~~~~~~~~~~~~'
+               WRITE(numout,*) '         Ice state initialization using input file    ln_limini  = ', ln_limini
+               WRITE(numout,*) ' '
+            ENDIF
+            
+            CALL iom_get( inum_ice, jpdom_data, 'sst'  , sst_ini(:,:) )        
+            CALL iom_get( inum_ice, jpdom_data, 'sss'  , sss_ini(:,:) )       
+            CALL iom_get( inum_ice, jpdom_data, 'hicif', hicif  (:,:) )      
+            CALL iom_get( inum_ice, jpdom_data, 'hsnif', hsnif  (:,:) )      
+            CALL iom_get( inum_ice, jpdom_data, 'frld' , frld   (:,:) )     
+            CALL iom_get( inum_ice, jpdom_data, 'ts'   , sist   (:,:) )
+            CALL iom_get( inum_ice, jpdom_unknown, 'tbif', tbif(1:nlci,1:nlcj,:),   &
+                 &        kstart = (/ mig(1),mjg(1),1 /), kcount = (/ nlci,nlcj,jplayersp1 /) )
+            ! put some values in the extra-halo...
+            DO jj = nlcj+1, jpj   ;   tbif(1:nlci,jj,:) = tbif(1:nlci,nlej,:)   ;   END DO
+            DO ji = nlci+1, jpi   ;   tbif(ji    ,: ,:) = tbif(nlei  ,:   ,:)   ;   END DO
+
+            CALL iom_close( inum_ice)
+            
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE lim_istate_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :         Empty module      NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_istate_2        ! Empty routine
+   END SUBROUTINE lim_istate_2
+#endif
+
+   !!======================================================================
+END MODULE limistate_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limmsh_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limmsh_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limmsh_2.F90	(revision 823)
@@ -0,0 +1,259 @@
+MODULE limmsh_2
+   !!======================================================================
+   !!                     ***  MODULE  limmsh_2  ***
+   !! LIM 2.0 ice model :   definition of the ice mesh parameters
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                     LIM 2.0sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_msh_2   : definition of the ice mesh
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE dom_oce
+   USE dom_ice_2
+   USE lbclnk
+   USE in_out_manager
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Accessibility
+   PUBLIC lim_msh_2      ! routine called by ice_ini_2.F90
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_msh_2
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_msh_2  ***
+      !!              
+      !! ** Purpose : Definition of the charact. of the numerical grid
+      !!       
+      !! ** Action  : - Initialisation of some variables
+      !!              - Definition of some constants linked with the grid
+      !!              - Definition of the metric coef. for the sea/ice
+      !!              - Initialization of the ice masks (tmsk, umsk)
+      !! 
+      !! ** Refer.  : Deleersnijder et al. Ocean Modelling 100, 7-10 
+      !!
+      !! ** History :
+      !!         original    : 01-04 (LIM)
+      !!         addition    : 02-08 (C. Ethe, G. Madec)
+      !!--------------------------------------------------------------------- 
+      !! * Local variables
+      INTEGER :: ji, jj      ! dummy loop indices
+
+      REAL(wp), DIMENSION(jpi,jpj) ::  &
+         zd2d1 , zd1d2       ! Derivative of zh2 (resp. zh1) in the x direction
+         !                   ! (resp. y direction) (defined at the center)
+      REAL(wp) ::         &
+         zh1p  , zh2p   , &  ! Idem zh1, zh2 for the bottom left corner of the grid
+         zd2d1p, zd1d2p , &  ! Idem zd2d1, zd1d2 for the bottom left corner of the grid
+         zusden, zusden2     ! temporary scalars
+      !!---------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_msh_2 : LIM 2.0 sea-ice model, mesh initialization'
+         WRITE(numout,*) '~~~~~~~~~'
+      ENDIF
+      
+      !----------------------------------------------------------                          
+      !    Initialization of local and some global (common) variables 
+      !------------------------------------------------------------------ 
+      
+      njeq   = INT( jpj / 2 )   !i bug mpp potentiel
+      njeqm1 = njeq - 1 
+
+      fcor(:,:) = 2. * omega * SIN( gphit(:,:) * rad )   !  coriolis factor
+ 
+!i    DO jj = 1, jpj
+!i       zmsk(jj) = SUM( tmask(:,jj,:) )   ! = 0          if land  everywhere on a j-line
+!!ii     write(numout,*) jj, zind(jj)
+!i    END DO
+
+      IF( fcor(1,1) * fcor(1,nlcj) < 0.e0 ) THEN   ! local domain include both hemisphere
+         l_jeq = .TRUE.
+         njeq  = 1
+         DO WHILE ( njeq <= jpj .AND. fcor(1,njeq) < 0.e0 )
+            njeq = njeq + 1
+         END DO
+         IF(lwp ) WRITE(numout,*) '          the equator is inside the domain at about njeq = ', njeq
+      ELSEIF( fcor(1,1) < 0.e0 ) THEN
+         l_jeq = .FALSE.
+         njeq = jpj
+         IF(lwp ) WRITE(numout,*) '          the model domain is entirely in the southern hemisphere: njeq = ', njeq
+      ELSE
+         l_jeq = .FALSE.
+         njeq = 2
+         IF(lwp ) WRITE(numout,*) '          the model domain is entirely in the northern hemisphere: njeq = ', njeq
+      ENDIF
+
+      njeqm1 = njeq - 1
+
+
+      !   For each grid, definition of geometric tables 
+      !------------------------------------------------------------------
+      
+      !-------------------
+      ! Conventions :    !
+      !-------------------
+      !  indices 1 \ 2 <-> localisation in the 2 direction x \ y
+      !  3rd indice <-> localisation on the mesh :
+      !  0 = Centre ;  1 = corner W x(i-1/2) ; 2 = corner S y(j-1/2) ;
+      !  3 = corner SW x(i-1/2),y(j-1/2)
+      !-------------------
+!!ibug ???
+      akappa(:,:,:,:) = 0.e0
+      wght(:,:,:,:) = 0.e0
+      alambd(:,:,:,:,:,:) = 0.e0
+      tmu(:,:) = 0.e0
+!!i
+      
+      
+      ! metric coefficients for sea ice dynamic
+      !----------------------------------------
+      !                                                       ! akappa
+      DO jj = 2, jpj
+         zd1d2(:,jj) = e1v(:,jj) - e1v(:,jj-1)
+      END DO
+      CALL lbc_lnk( zd1d2, 'T', -1. )
+
+      DO ji = 2, jpi
+         zd2d1(ji,:) = e2u(ji,:) - e2u(ji-1,:)
+      END DO
+      CALL lbc_lnk( zd2d1, 'T', -1. )
+
+      akappa(:,:,1,1) =        1.0 / ( 2.0 * e1t(:,:) )
+      akappa(:,:,1,2) = zd1d2(:,:) / ( 4.0 * e1t(:,:) * e2t(:,:) )
+      akappa(:,:,2,1) = zd2d1(:,:) / ( 4.0 * e1t(:,:) * e2t(:,:) )
+      akappa(:,:,2,2) =        1.0 / ( 2.0 * e2t(:,:) )
+      
+      !                                                      ! weights (wght)
+      DO jj = 2, jpj
+         DO ji = 2, jpi
+            zusden = 1. / (  ( e1t(ji,jj) + e1t(ji-1,jj  ) )   &
+               &           * ( e2t(ji,jj) + e2t(ji  ,jj-1) ) )
+            wght(ji,jj,1,1) = zusden * e1t(ji  ,jj) * e2t(ji,jj  )
+            wght(ji,jj,1,2) = zusden * e1t(ji  ,jj) * e2t(ji,jj-1)
+            wght(ji,jj,2,1) = zusden * e1t(ji-1,jj) * e2t(ji,jj  )
+            wght(ji,jj,2,2) = zusden * e1t(ji-1,jj) * e2t(ji,jj-1)
+         END DO
+      END DO
+      CALL lbc_lnk( wght(:,:,1,1), 'I', 1. )      ! CAUTION: even with the lbc_lnk at ice U-V-point
+      CALL lbc_lnk( wght(:,:,1,2), 'I', 1. )      ! the value of wght at jpj is wrong
+      CALL lbc_lnk( wght(:,:,2,1), 'I', 1. )      ! but it is never used
+      CALL lbc_lnk( wght(:,:,2,2), 'I', 1. )
+    
+      ! Coefficients for divergence of the stress tensor
+      !-------------------------------------------------
+
+      DO jj = 2, jpj
+         DO ji = 2, jpi
+            zh1p  =  e1t(ji  ,jj  ) * wght(ji,jj,2,2)   &
+               &   + e1t(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &   + e1t(ji  ,jj-1) * wght(ji,jj,2,1)   &
+               &   + e1t(ji-1,jj-1) * wght(ji,jj,1,1)
+
+            zh2p  =  e2t(ji  ,jj  ) * wght(ji,jj,2,2)   &
+               &   + e2t(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &   + e2t(ji  ,jj-1) * wght(ji,jj,2,1)   &
+               &   + e2t(ji-1,jj-1) * wght(ji,jj,1,1)
+
+! better written but change the last digit and thus solver in less than 100 timestep
+!           zh1p  = e1t(ji-1,jj  ) * wght(ji,jj,1,2) + e1t(ji,jj  ) * wght(ji,jj,2,2)   &
+!              &  + e1t(ji-1,jj-1) * wght(ji,jj,1,1) + e1t(ji,jj-1) * wght(ji,jj,2,1) 
+
+!           zh2p  = e2t(ji-1,jj  ) * wght(ji,jj,1,2) + e2t(ji,jj  ) * wght(ji,jj,2,2)   &
+!              &  + e2t(ji-1,jj-1) * wght(ji,jj,1,1) + e2t(ji,jj-1) * wght(ji,jj,2,1)
+
+!!ibug =0   zusden = 1.0 / ( zh1p * zh2p * 4.e0 )
+            zusden = 1.0 / MAX( zh1p * zh2p * 4.e0 , 1.e-20 )
+            zusden2 = zusden * 2.0 
+
+            zd1d2p = zusden * 0.5 * ( -e1t(ji-1,jj-1) + e1t(ji-1,jj  ) - e1t(ji,jj-1) + e1t(ji  ,jj)   )
+            zd2d1p = zusden * 0.5 * (  e2t(ji  ,jj-1) - e2t(ji-1,jj-1) + e2t(ji,jj  ) - e2t(ji-1,jj)   )
+
+            alambd(ji,jj,2,2,2,1) = zusden2 * e2t(ji  ,jj-1)
+            alambd(ji,jj,2,2,2,2) = zusden2 * e2t(ji  ,jj  )
+            alambd(ji,jj,2,2,1,1) = zusden2 * e2t(ji-1,jj-1)
+            alambd(ji,jj,2,2,1,2) = zusden2 * e2t(ji-1,jj  )
+
+            alambd(ji,jj,1,1,2,1) = zusden2 * e1t(ji  ,jj-1)
+            alambd(ji,jj,1,1,2,2) = zusden2 * e1t(ji  ,jj  )
+            alambd(ji,jj,1,1,1,1) = zusden2 * e1t(ji-1,jj-1)
+            alambd(ji,jj,1,1,1,2) = zusden2 * e1t(ji-1,jj  )
+
+            alambd(ji,jj,1,2,2,1) = zd1d2p
+            alambd(ji,jj,1,2,2,2) = zd1d2p
+            alambd(ji,jj,1,2,1,1) = zd1d2p
+            alambd(ji,jj,1,2,1,2) = zd1d2p
+
+            alambd(ji,jj,2,1,2,1) = zd2d1p
+            alambd(ji,jj,2,1,2,2) = zd2d1p
+            alambd(ji,jj,2,1,1,1) = zd2d1p
+            alambd(ji,jj,2,1,1,2) = zd2d1p
+         END DO
+      END DO
+
+      CALL lbc_lnk( alambd(:,:,2,2,2,1), 'I', 1. )      ! CAUTION: even with the lbc_lnk at ice U-V point
+      CALL lbc_lnk( alambd(:,:,2,2,2,2), 'I', 1. )      ! the value of wght at jpj is wrong
+      CALL lbc_lnk( alambd(:,:,2,2,1,1), 'I', 1. )      ! but it is never used
+      CALL lbc_lnk( alambd(:,:,2,2,1,2), 'I', 1. )      ! 
+
+      CALL lbc_lnk( alambd(:,:,1,1,2,1), 'I', 1. )      ! CAUTION: idem
+      CALL lbc_lnk( alambd(:,:,1,1,2,2), 'I', 1. )      ! 
+      CALL lbc_lnk( alambd(:,:,1,1,1,1), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,1,1,1,2), 'I', 1. )      !
+
+      CALL lbc_lnk( alambd(:,:,1,2,2,1), 'I', 1. )      ! CAUTION: idem
+      CALL lbc_lnk( alambd(:,:,1,2,2,2), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,1,2,1,1), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,1,2,1,2), 'I', 1. )      !
+
+      CALL lbc_lnk( alambd(:,:,2,1,2,1), 'I', 1. )      ! CAUTION: idem
+      CALL lbc_lnk( alambd(:,:,2,1,2,2), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,2,1,1,1), 'I', 1. )      !
+      CALL lbc_lnk( alambd(:,:,2,1,1,2), 'I', 1. )      !
+            
+
+      ! Initialization of ice masks
+      !----------------------------
+      
+      tms(:,:) = tmask(:,:,1)      ! ice T-point  : use surface tmask
+
+!i here we can use umask with a i and j shift of -1,-1
+      tmu(:,1) = 0.e0
+      tmu(1,:) = 0.e0
+      DO jj = 2, jpj               ! ice U.V-point: computed from ice T-point mask
+         DO ji = 2, jpim1
+            tmu(ji,jj) =  tms(ji,jj) * tms(ji-1,jj) * tms(ji,jj-1) * tms(ji-1,jj-1)            
+         END DO
+      END DO
+      
+      !--lateral boundary conditions    
+      CALL lbc_lnk( tmu(:,:), 'I', 1. )
+      
+      ! unmasked and masked area of T-grid cell
+      area(:,:) = e1t(:,:) * e2t(:,:)
+      
+   END SUBROUTINE lim_msh_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option            Dummy Module         NO LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_msh_2           ! Dummy routine
+   END SUBROUTINE lim_msh_2
+#endif
+
+   !!======================================================================
+END MODULE limmsh_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limrhg_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 823)
@@ -0,0 +1,665 @@
+MODULE limrhg_2
+   !!======================================================================
+   !!                     ***  MODULE  limrhg_2  ***
+   !!   Ice rheology :  performs sea ice rheology
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_rhg_2   : computes ice velocities
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE par_oce
+   USE ice_oce         ! ice variables
+   USE dom_ice_2
+   USE ice_2
+   USE lbclnk
+   USE lib_mpp
+   USE in_out_manager  ! I/O manager
+   USE prtctl          ! Print control
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_rhg_2  ! routine called by lim_dyn_2
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      rzero   = 0.e0   ,  &
+      rone    = 1.e0
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_rhg_2( k_j1, k_jpj )
+      !!-------------------------------------------------------------------
+      !!                 ***  SUBROUTINR lim_rhg_2  ***
+      !!
+      !! ** purpose :   determines the velocity field of sea ice by using
+      !!  atmospheric (wind stress) and oceanic (water stress and surface
+      !!  tilt) forcings. Ice-ice interaction is described by a non-linear
+      !!  viscous-plastic law including shear strength and a bulk rheology.
+      !!
+      !! ** Action  : - compute u_ice, v_ice the sea-ice velocity
+      !!
+      !! History :
+      !!   0.0  !  93-12  (M.A. Morales Maqueda.)  Original code
+      !!   1.0  !  94-12  (H. Goosse) 
+      !!   2.0  !  03-12  (C. Ethe, G. Madec)  F90, mpp
+      !!-------------------------------------------------------------------
+      ! * Arguments
+      INTEGER, INTENT(in) ::   k_j1 ,  &  ! southern j-index for ice computation
+         &                     k_jpj      ! northern j-index for ice computation
+
+      ! * Local variables
+      INTEGER ::   ji, jj              ! dummy loop indices
+
+      INTEGER  :: &
+         iim1, ijm1, iip1 , ijp1   , & ! temporary integers
+         iter, jter                    !    "          "
+
+      CHARACTER (len=50) :: charout
+
+      REAL(wp) :: &
+         ze11  , ze12  , ze22  , ze21  ,   &  ! temporary scalars
+         zt11  , zt12  , zt21  , zt22  ,   &  !    "         "
+         zvis11, zvis21, zvis12, zvis22,   &  !    "         "
+         zgphsx, ztagnx, zusw  ,           &  !    "         "
+         zgphsy, ztagny                       !    "         "
+      REAL(wp) :: &
+         zresm, zunw, zvnw, zur, zvr, zmod, za, zac, &
+         zmpzas, zstms, zindu, zindu1, zusdtp, zmassdt, zcorlal,  &
+         ztrace2, zdeter, zdelta, zsang, zmask, zdgp, zdgi, zdiag
+      REAL(wp),DIMENSION(jpi,jpj) ::   &
+         zpresh, zfrld, zmass, zcorl,     &
+         zu0, zv0, zviszeta, zviseta,     &
+         zc1u, zc1v, zc2u, zc2v, za1ct, za2ct, za1, za2, zb1, zb2,  &
+         zc1, zc2, zd1, zd2, zden, zu_ice, zv_ice, zresr
+      REAL(wp),DIMENSION(jpi,jpj,2,2) :: &
+         zs11, zs12, zs22, zs21
+      !!-------------------------------------------------------------------
+      
+      !  Store initial velocities
+      !  ------------------------
+      zu0(:,:) = u_ice(:,:)
+      zv0(:,:) = v_ice(:,:)
+
+      ! Ice mass, ice strength, and wind stress at the center            |
+      ! of the grid squares.                                             |
+      !-------------------------------------------------------------------
+
+      DO jj = k_j1 , k_jpj-1
+         DO ji = 1 , jpi
+            za1(ji,jj)    = tms(ji,jj) * ( rhosn * hsnm(ji,jj) + rhoic * hicm(ji,jj) )
+            zpresh(ji,jj) = tms(ji,jj) *  pstarh * hicm(ji,jj) * EXP( -c_rhg * frld(ji,jj) )
+#if defined key_lim_cp1 && defined key_coupled
+            zb1(ji,jj)    = tms(ji,jj) * gtaux(ji,jj) * ( 1.0 - frld(ji,jj) )
+            zb2(ji,jj)    = tms(ji,jj) * gtauy(ji,jj) * ( 1.0 - frld(ji,jj) )
+#else
+            zb1(ji,jj)    = tms(ji,jj) * ( 1.0 - frld(ji,jj) )
+            zb2(ji,jj)    = tms(ji,jj) * ( 1.0 - frld(ji,jj) )
+#endif
+         END DO
+      END DO
+
+
+      !---------------------------------------------------------------------------
+      !  Wind stress, coriolis and mass terms at the corners of the grid squares |
+      !  Gradient of ice strenght.                                               |
+      !---------------------------------------------------------------------------
+         
+      DO jj = k_j1+1, k_jpj-1
+         DO ji = 2, jpi
+            zstms = tms(ji,jj  ) * wght(ji,jj,2,2) + tms(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &  + tms(ji,jj-1) * wght(ji,jj,2,1) + tms(ji-1,jj-1) * wght(ji,jj,1,1)
+            zusw  = 1.0 / MAX( zstms, epsd )
+
+            zt11 = tms(ji  ,jj  ) * frld(ji  ,jj  ) 
+            zt12 = tms(ji-1,jj  ) * frld(ji-1,jj  ) 
+            zt21 = tms(ji  ,jj-1) * frld(ji  ,jj-1) 
+            zt22 = tms(ji-1,jj-1) * frld(ji-1,jj-1)
+
+            ! Leads area.
+            zfrld(ji,jj) =  (  zt11 * wght(ji,jj,2,2) + zt12 * wght(ji,jj,1,2)   &
+               &             + zt21 * wght(ji,jj,2,1) + zt22 * wght(ji,jj,1,1) ) * zusw
+
+            ! Mass and coriolis coeff.
+            zmass(ji,jj) = ( za1(ji,jj  ) * wght(ji,jj,2,2) + za1(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &           + za1(ji,jj-1) * wght(ji,jj,2,1) + za1(ji-1,jj-1) * wght(ji,jj,1,1) ) * zusw
+            zcorl(ji,jj) = zmass(ji,jj) * fcor(ji,jj)
+
+            ! Wind stress.
+#if defined key_lim_cp1 && defined key_coupled
+            ztagnx = ( zb1(ji,jj  ) * wght(ji,jj,2,2) + zb1(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &     + zb1(ji,jj-1) * wght(ji,jj,2,1) + zb1(ji-1,jj-1) * wght(ji,jj,1,1) ) * zusw
+            ztagny = ( zb2(ji,jj  ) * wght(ji,jj,2,2) + zb2(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &     + zb2(ji,jj-1) * wght(ji,jj,2,1) + zb2(ji-1,jj-1) * wght(ji,jj,1,1) ) * zusw
+#else
+            ztagnx = ( zb1(ji,jj  ) * wght(ji,jj,2,2) + zb1(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &     + zb1(ji,jj-1) * wght(ji,jj,2,1) + zb1(ji-1,jj-1) * wght(ji,jj,1,1) ) * zusw * gtaux(ji,jj)
+            ztagny = ( zb2(ji,jj  ) * wght(ji,jj,2,2) + zb2(ji-1,jj  ) * wght(ji,jj,1,2)   &
+               &     + zb2(ji,jj-1) * wght(ji,jj,2,1) + zb2(ji-1,jj-1) * wght(ji,jj,1,1) ) * zusw * gtauy(ji,jj)
+#endif
+
+            ! Gradient of ice strength
+            zgphsx =   ( alambd(ji,jj,2,2,2,1) - alambd(ji,jj,2,1,2,1) ) * zpresh(ji  ,jj-1)   &
+               &     + ( alambd(ji,jj,2,2,2,2) - alambd(ji,jj,2,1,2,2) ) * zpresh(ji  ,jj  )   &
+               &     - ( alambd(ji,jj,2,2,1,1) + alambd(ji,jj,2,1,1,1) ) * zpresh(ji-1,jj-1)   &
+               &     - ( alambd(ji,jj,2,2,1,2) + alambd(ji,jj,2,1,1,2) ) * zpresh(ji-1,jj  )
+
+            zgphsy = - ( alambd(ji,jj,1,1,2,1) + alambd(ji,jj,1,2,2,1) ) * zpresh(ji  ,jj-1)   &
+               &     - ( alambd(ji,jj,1,1,1,1) + alambd(ji,jj,1,2,1,1) ) * zpresh(ji-1,jj-1)   &
+               &     + ( alambd(ji,jj,1,1,2,2) - alambd(ji,jj,1,2,2,2) ) * zpresh(ji  ,jj  )   &
+               &     + ( alambd(ji,jj,1,1,1,2) - alambd(ji,jj,1,2,1,2) ) * zpresh(ji-1,jj  )
+
+            ! Computation of the velocity field taking into account the ice-ice interaction.                                 
+            ! Terms that are independent of the velocity field.
+            za1ct(ji,jj) = ztagnx - zcorl(ji,jj) * v_oce(ji,jj) - zgphsx
+            za2ct(ji,jj) = ztagny + zcorl(ji,jj) * u_oce(ji,jj) - zgphsy
+         END DO
+      END DO
+
+!! inutile!!
+!!??    CALL lbc_lnk( za1ct, 'I', -1. )
+!!??    CALL lbc_lnk( za2ct, 'I', -1. )
+
+
+      ! SOLUTION OF THE MOMENTUM EQUATION.
+      !------------------------------------------
+      !                                                   ! ==================== !
+      DO iter = 1 , 2 * nbiter                            !    loop over iter    !
+         !                                                ! ==================== !        
+         zindu = MOD( iter , 2 )
+         zusdtp = ( zindu * 2.0 + ( 1.0 - zindu ) * 1.0 )  * REAL( nbiter ) / rdt_ice
+
+         ! Computation of free drift field for free slip boundary conditions.
+
+           DO jj = k_j1, k_jpj-1
+              DO ji = 1, jpim1
+                 !- Rate of strain tensor.
+                 zt11 =   akappa(ji,jj,1,1) * ( u_ice(ji+1,jj) + u_ice(ji+1,jj+1) - u_ice(ji,jj  ) - u_ice(ji  ,jj+1) )  &
+                    &   + akappa(ji,jj,1,2) * ( v_ice(ji+1,jj) + v_ice(ji+1,jj+1) + v_ice(ji,jj  ) + v_ice(ji  ,jj+1) )
+                 zt12 = - akappa(ji,jj,2,2) * ( u_ice(ji  ,jj) + u_ice(ji+1,jj  ) - u_ice(ji,jj+1) - u_ice(ji+1,jj+1) )  &
+                    &   - akappa(ji,jj,2,1) * ( v_ice(ji  ,jj) + v_ice(ji+1,jj  ) + v_ice(ji,jj+1) + v_ice(ji+1,jj+1) )
+                 zt22 = - akappa(ji,jj,2,2) * ( v_ice(ji  ,jj) + v_ice(ji+1,jj  ) - v_ice(ji,jj+1) - v_ice(ji+1,jj+1) )  &
+                    &   + akappa(ji,jj,2,1) * ( u_ice(ji  ,jj) + u_ice(ji+1,jj  ) + u_ice(ji,jj+1) + u_ice(ji+1,jj+1) )
+                 zt21 =   akappa(ji,jj,1,1) * ( v_ice(ji+1,jj) + v_ice(ji+1,jj+1) - v_ice(ji,jj  ) - v_ice(ji  ,jj+1) )  &
+                    &   - akappa(ji,jj,1,2) * ( u_ice(ji+1,jj) + u_ice(ji+1,jj+1) + u_ice(ji,jj  ) + u_ice(ji  ,jj+1) )
+
+                 !- Rate of strain tensor. 
+                 zdgp = zt11 + zt22
+                 zdgi = zt12 + zt21
+                 ztrace2 = zdgp * zdgp 
+                 zdeter  = zt11 * zt22 - 0.25 * zdgi * zdgi
+
+                 !  Creep limit depends on the size of the grid.
+                 zdelta = MAX( SQRT( ztrace2 + ( ztrace2 - 4.0 * zdeter ) * usecc2),  creepl)
+
+                 !-  Computation of viscosities.
+                 zviszeta(ji,jj) = MAX( zpresh(ji,jj) / zdelta, etamn )
+                 zviseta (ji,jj) = zviszeta(ji,jj) * usecc2
+              END DO
+           END DO
+!!??       CALL lbc_lnk( zviszeta, 'I', -1. )  ! or T point???   semble reellement inutile
+!!??       CALL lbc_lnk( zviseta , 'I', -1. )
+
+
+           !-  Determination of zc1u, zc2u, zc1v and zc2v.
+           DO jj = k_j1+1, k_jpj-1
+              DO ji = 2, jpim1
+                 ze11   =  akappa(ji-1,jj-1,1,1)
+                 ze12   = +akappa(ji-1,jj-1,2,2)
+                 ze22   =  akappa(ji-1,jj-1,2,1)
+                 ze21   = -akappa(ji-1,jj-1,1,2)
+                 zvis11 = 2.0 * zviseta (ji-1,jj-1) + dm
+                 zvis22 =       zviszeta(ji-1,jj-1) - zviseta(ji-1,jj-1)
+                 zvis12 =       zviseta (ji-1,jj-1) + dm
+                 zvis21 =       zviseta (ji-1,jj-1)
+
+                 zdiag = zvis22 * ( ze11 + ze22 )
+                 zs11(ji,jj,1,1) =  zvis11 * ze11 + zdiag
+                 zs12(ji,jj,1,1) =  zvis12 * ze12 + zvis21 * ze21
+                 zs22(ji,jj,1,1) =  zvis11 * ze22 + zdiag
+                 zs21(ji,jj,1,1) =  zvis12 * ze21 + zvis21 * ze12
+
+                 ze11   = -akappa(ji,jj-1,1,1)
+                 ze12   = +akappa(ji,jj-1,2,2)
+                 ze22   =  akappa(ji,jj-1,2,1)
+                 ze21   = -akappa(ji,jj-1,1,2)
+                 zvis11 = 2.0 * zviseta (ji,jj-1) + dm
+                 zvis22 =       zviszeta(ji,jj-1) - zviseta(ji,jj-1)
+                 zvis12 =       zviseta (ji,jj-1) + dm
+                 zvis21 =       zviseta (ji,jj-1)
+
+                 zdiag = zvis22 * ( ze11 + ze22 )
+                 zs11(ji,jj,2,1) =  zvis11 * ze11 + zdiag
+                 zs12(ji,jj,2,1) =  zvis12 * ze12 + zvis21 * ze21
+                 zs22(ji,jj,2,1) =  zvis11 * ze22 + zdiag
+                 zs21(ji,jj,2,1) =  zvis12 * ze21 + zvis21 * ze12
+
+                 ze11   =  akappa(ji-1,jj,1,1)
+                 ze12   = -akappa(ji-1,jj,2,2)
+                 ze22   =  akappa(ji-1,jj,2,1)
+                 ze21   = -akappa(ji-1,jj,1,2)
+                 zvis11 = 2.0 * zviseta (ji-1,jj) + dm
+                 zvis22 =       zviszeta(ji-1,jj) - zviseta(ji-1,jj)
+                 zvis12 =       zviseta (ji-1,jj) + dm
+                 zvis21 =       zviseta (ji-1,jj)
+
+                 zdiag = zvis22 * ( ze11 + ze22 ) 
+                 zs11(ji,jj,1,2) =  zvis11 * ze11 + zdiag
+                 zs12(ji,jj,1,2) =  zvis12 * ze12 + zvis21 * ze21
+                 zs22(ji,jj,1,2) =  zvis11 * ze22 + zdiag
+                 zs21(ji,jj,1,2) =  zvis12 * ze21 + zvis21 * ze12
+
+                 ze11   = -akappa(ji,jj,1,1)
+                 ze12   = -akappa(ji,jj,2,2)
+                 ze22   =  akappa(ji,jj,2,1)
+                 ze21   = -akappa(ji,jj,1,2)
+                 zvis11 = 2.0 * zviseta (ji,jj) + dm
+                 zvis22 =       zviszeta(ji,jj) - zviseta(ji,jj)
+                 zvis12 =       zviseta (ji,jj) + dm
+                 zvis21 =       zviseta (ji,jj)
+
+                 zdiag = zvis22 * ( ze11 + ze22 )
+                 zs11(ji,jj,2,2) =  zvis11 * ze11 + zdiag
+                 zs12(ji,jj,2,2) =  zvis12 * ze12 + zvis21 * ze21
+                 zs22(ji,jj,2,2) =  zvis11 * ze22 + zdiag 
+                 zs21(ji,jj,2,2) =  zvis12 * ze21 + zvis21 * ze12
+              END DO
+           END DO
+
+           DO jj = k_j1+1, k_jpj-1
+              DO ji = 2, jpim1
+                 zc1u(ji,jj) =   &
+                    + alambd(ji,jj,2,2,2,1) * zs11(ji,jj,2,1) + alambd(ji,jj,2,2,2,2) * zs11(ji,jj,2,2)   &
+                    - alambd(ji,jj,2,2,1,1) * zs11(ji,jj,1,1) - alambd(ji,jj,2,2,1,2) * zs11(ji,jj,1,2)   &
+                    - alambd(ji,jj,1,1,2,1) * zs12(ji,jj,2,1) - alambd(ji,jj,1,1,1,1) * zs12(ji,jj,1,1)   &
+                    + alambd(ji,jj,1,1,2,2) * zs12(ji,jj,2,2) + alambd(ji,jj,1,1,1,2) * zs12(ji,jj,1,2)   &
+                    + alambd(ji,jj,1,2,1,1) * zs21(ji,jj,1,1) + alambd(ji,jj,1,2,2,1) * zs21(ji,jj,2,1)   &
+                    + alambd(ji,jj,1,2,1,2) * zs21(ji,jj,1,2) + alambd(ji,jj,1,2,2,2) * zs21(ji,jj,2,2)   &
+                    - alambd(ji,jj,2,1,1,1) * zs22(ji,jj,1,1) - alambd(ji,jj,2,1,2,1) * zs22(ji,jj,2,1)   &
+                    - alambd(ji,jj,2,1,1,2) * zs22(ji,jj,1,2) - alambd(ji,jj,2,1,2,2) * zs22(ji,jj,2,2)
+                 
+                 zc2u(ji,jj) =   &
+                    + alambd(ji,jj,2,2,2,1) * zs21(ji,jj,2,1) + alambd(ji,jj,2,2,2,2) * zs21(ji,jj,2,2)   &
+                    - alambd(ji,jj,2,2,1,1) * zs21(ji,jj,1,1) - alambd(ji,jj,2,2,1,2) * zs21(ji,jj,1,2)   &
+                    - alambd(ji,jj,1,1,2,1) * zs22(ji,jj,2,1) - alambd(ji,jj,1,1,1,1) * zs22(ji,jj,1,1)   &
+                    + alambd(ji,jj,1,1,2,2) * zs22(ji,jj,2,2) + alambd(ji,jj,1,1,1,2) * zs22(ji,jj,1,2)   &
+                    - alambd(ji,jj,1,2,1,1) * zs11(ji,jj,1,1) - alambd(ji,jj,1,2,2,1) * zs11(ji,jj,2,1)   &
+                    - alambd(ji,jj,1,2,1,2) * zs11(ji,jj,1,2) - alambd(ji,jj,1,2,2,2) * zs11(ji,jj,2,2)   &
+                    + alambd(ji,jj,2,1,1,1) * zs12(ji,jj,1,1) + alambd(ji,jj,2,1,2,1) * zs12(ji,jj,2,1)   &
+                    + alambd(ji,jj,2,1,1,2) * zs12(ji,jj,1,2) + alambd(ji,jj,2,1,2,2) * zs12(ji,jj,2,2)
+             END DO
+           END DO
+
+           DO jj = k_j1+1, k_jpj-1
+              DO ji = 2, jpim1
+                 !  zc1v , zc2v.
+                 ze11   =  akappa(ji-1,jj-1,1,2)
+                 ze12   = -akappa(ji-1,jj-1,2,1)
+                 ze22   = +akappa(ji-1,jj-1,2,2)
+                 ze21   =  akappa(ji-1,jj-1,1,1)
+                 zvis11 = 2.0 * zviseta (ji-1,jj-1) + dm
+                 zvis22 =       zviszeta(ji-1,jj-1) - zviseta(ji-1,jj-1)
+                 zvis12 =       zviseta (ji-1,jj-1) + dm
+                 zvis21 =       zviseta (ji-1,jj-1)
+
+                 zdiag = zvis22 * ( ze11 + ze22 )
+                 zs11(ji,jj,1,1) =  zvis11 * ze11 + zdiag
+                 zs12(ji,jj,1,1) =  zvis12 * ze12 + zvis21 * ze21
+                 zs22(ji,jj,1,1) =  zvis11 * ze22 + zdiag
+                 zs21(ji,jj,1,1) =  zvis12 * ze21 + zvis21 * ze12
+ 
+                 ze11   =  akappa(ji,jj-1,1,2)
+                 ze12   = -akappa(ji,jj-1,2,1)
+                 ze22   = +akappa(ji,jj-1,2,2)
+                 ze21   = -akappa(ji,jj-1,1,1)
+                 zvis11 = 2.0 * zviseta (ji,jj-1) + dm
+                 zvis22 =       zviszeta(ji,jj-1) - zviseta(ji,jj-1)
+                 zvis12 =       zviseta (ji,jj-1) + dm
+                 zvis21 =       zviseta (ji,jj-1)
+
+                 zdiag = zvis22 * ( ze11 + ze22 )
+                 zs11(ji,jj,2,1) =  zvis11 * ze11 + zdiag
+                 zs12(ji,jj,2,1) =  zvis12 * ze12 + zvis21 * ze21
+                 zs22(ji,jj,2,1) =  zvis11 * ze22 + zdiag
+                 zs21(ji,jj,2,1) =  zvis12 * ze21 + zvis21 * ze12
+
+                 ze11   =  akappa(ji-1,jj,1,2)
+                 ze12   = -akappa(ji-1,jj,2,1)
+                 ze22   = -akappa(ji-1,jj,2,2)
+                 ze21   =  akappa(ji-1,jj,1,1)
+                 zvis11 = 2.0 * zviseta (ji-1,jj) + dm
+                 zvis22 =       zviszeta(ji-1,jj) - zviseta(ji-1,jj)
+                 zvis12 =       zviseta (ji-1,jj) + dm
+                 zvis21 =       zviseta (ji-1,jj)
+
+                 zdiag = zvis22 * ( ze11 + ze22 )
+                 zs11(ji,jj,1,2) =  zvis11 * ze11 + zdiag
+                 zs12(ji,jj,1,2) =  zvis12 * ze12 + zvis21 * ze21
+                 zs22(ji,jj,1,2) =  zvis11 * ze22 + zdiag
+                 zs21(ji,jj,1,2) =  zvis12 * ze21 + zvis21 * ze12
+
+                 ze11   =  akappa(ji,jj,1,2)
+                 ze12   = -akappa(ji,jj,2,1)
+                 ze22   = -akappa(ji,jj,2,2)
+                 ze21   = -akappa(ji,jj,1,1)
+                 zvis11 = 2.0 * zviseta (ji,jj) + dm
+                 zvis22 =       zviszeta(ji,jj) - zviseta(ji,jj)
+                 zvis12 =       zviseta (ji,jj) + dm
+                 zvis21 =       zviseta (ji,jj)
+
+                 zdiag = zvis22 * ( ze11 + ze22 )
+                 zs11(ji,jj,2,2) =  zvis11 * ze11 + zdiag
+                 zs12(ji,jj,2,2) =  zvis12 * ze12 + zvis21 * ze21
+                 zs22(ji,jj,2,2) =  zvis11 * ze22 + zdiag
+                 zs21(ji,jj,2,2) =  zvis12 * ze21 + zvis21 * ze12
+
+              END DO
+           END DO
+
+           DO jj = k_j1+1, k_jpj-1
+              DO ji = 2, jpim1
+                 zc1v(ji,jj) =   &
+                    + alambd(ji,jj,2,2,2,1) * zs11(ji,jj,2,1) + alambd(ji,jj,2,2,2,2) * zs11(ji,jj,2,2)   &
+                    - alambd(ji,jj,2,2,1,1) * zs11(ji,jj,1,1) - alambd(ji,jj,2,2,1,2) * zs11(ji,jj,1,2)   &
+                    - alambd(ji,jj,1,1,2,1) * zs12(ji,jj,2,1) - alambd(ji,jj,1,1,1,1) * zs12(ji,jj,1,1)   &
+                    + alambd(ji,jj,1,1,2,2) * zs12(ji,jj,2,2) + alambd(ji,jj,1,1,1,2) * zs12(ji,jj,1,2)   &
+                    + alambd(ji,jj,1,2,1,1) * zs21(ji,jj,1,1) + alambd(ji,jj,1,2,2,1) * zs21(ji,jj,2,1)   &
+                    + alambd(ji,jj,1,2,1,2) * zs21(ji,jj,1,2) + alambd(ji,jj,1,2,2,2) * zs21(ji,jj,2,2)   &
+                    - alambd(ji,jj,2,1,1,1) * zs22(ji,jj,1,1) - alambd(ji,jj,2,1,2,1) * zs22(ji,jj,2,1)   &
+                    - alambd(ji,jj,2,1,1,2) * zs22(ji,jj,1,2) - alambd(ji,jj,2,1,2,2) * zs22(ji,jj,2,2)
+                 zc2v(ji,jj) =   &
+                    + alambd(ji,jj,2,2,2,1) * zs21(ji,jj,2,1) + alambd(ji,jj,2,2,2,2) * zs21(ji,jj,2,2)   &
+                    - alambd(ji,jj,2,2,1,1) * zs21(ji,jj,1,1) - alambd(ji,jj,2,2,1,2) * zs21(ji,jj,1,2)   &
+                    - alambd(ji,jj,1,1,2,1) * zs22(ji,jj,2,1) - alambd(ji,jj,1,1,1,1) * zs22(ji,jj,1,1)   &
+                    + alambd(ji,jj,1,1,2,2) * zs22(ji,jj,2,2) + alambd(ji,jj,1,1,1,2) * zs22(ji,jj,1,2)   &
+                    - alambd(ji,jj,1,2,1,1) * zs11(ji,jj,1,1) - alambd(ji,jj,1,2,2,1) * zs11(ji,jj,2,1)   &
+                    - alambd(ji,jj,1,2,1,2) * zs11(ji,jj,1,2) - alambd(ji,jj,1,2,2,2) * zs11(ji,jj,2,2)   &
+                    + alambd(ji,jj,2,1,1,1) * zs12(ji,jj,1,1) + alambd(ji,jj,2,1,2,1) * zs12(ji,jj,2,1)   &
+                    + alambd(ji,jj,2,1,1,2) * zs12(ji,jj,1,2) + alambd(ji,jj,2,1,2,2) * zs12(ji,jj,2,2)
+              END DO
+           END DO
+
+         ! Relaxation.
+           
+iflag:   DO jter = 1 , nbitdr
+
+            !  Store previous drift field.   
+            DO jj = k_j1, k_jpj-1
+               zu_ice(:,jj) = u_ice(:,jj)
+               zv_ice(:,jj) = v_ice(:,jj)
+            END DO
+
+            DO jj = k_j1+1, k_jpj-1
+               zsang  = SIGN( 1.e0, fcor(1,jj) ) * sangvg   ! only the sinus changes its sign with the hemisphere
+               DO ji = 2, jpim1
+                 zur     = u_ice(ji,jj) - u_oce(ji,jj)
+                 zvr     = v_ice(ji,jj) - v_oce(ji,jj)
+                 zmod    = SQRT( zur * zur + zvr * zvr) * ( 1.0 - zfrld(ji,jj) )
+                 za      = rhoco * zmod
+                 zac     = za * cangvg
+                  zmpzas  = alpha * zcorl(ji,jj) + za * zsang
+                  zmassdt = zusdtp * zmass(ji,jj)
+                  zcorlal = ( 1.0 - alpha ) * zcorl(ji,jj)
+
+                  za1(ji,jj) =  zmassdt * zu0(ji,jj) + zcorlal * zv0(ji,jj) + za1ct(ji,jj)   &
+                     &        + za * ( cangvg * u_oce(ji,jj) - zsang * v_oce(ji,jj) )
+
+                  za2(ji,jj) =  zmassdt * zv0(ji,jj) - zcorlal * zu0(ji,jj) + za2ct(ji,jj)   &
+                     &        + za * ( cangvg * v_oce(ji,jj) + zsang * u_oce(ji,jj) )
+
+                  zb1(ji,jj)  = zmassdt + zac - zc1u(ji,jj)
+                  zb2(ji,jj)  = zmpzas  - zc2u(ji,jj)
+                  zc1(ji,jj)  = zmpzas  + zc1v(ji,jj)
+                  zc2(ji,jj)  = zmassdt + zac  - zc2v(ji,jj) 
+                  zdeter      = zc1(ji,jj) * zb2(ji,jj) + zc2(ji,jj) * zb1(ji,jj)
+                  zden(ji,jj) = SIGN( rone, zdeter) / MAX( epsd , ABS( zdeter ) )
+               END DO
+            END DO
+
+            ! The computation of ice interaction term is splitted into two parts
+            !-------------------------------------------------------------------------
+
+            ! Terms that do not involve already up-dated velocities.
+         
+            DO jj = k_j1+1, k_jpj-1
+               DO ji = 2, jpim1
+                  iim1 = ji
+                  ijm1 = jj - 1
+                  iip1 = ji + 1
+                  ijp1 = jj
+                  ze11 =   akappa(iim1,ijm1,1,1) * u_ice(iip1,ijp1) + akappa(iim1,ijm1,1,2) * v_ice(iip1,ijp1)
+                  ze12 = + akappa(iim1,ijm1,2,2) * u_ice(iip1,ijp1) - akappa(iim1,ijm1,2,1) * v_ice(iip1,ijp1)
+                  ze22 = + akappa(iim1,ijm1,2,2) * v_ice(iip1,ijp1) + akappa(iim1,ijm1,2,1) * u_ice(iip1,ijp1)
+                  ze21 =   akappa(iim1,ijm1,1,1) * v_ice(iip1,ijp1) - akappa(iim1,ijm1,1,2) * u_ice(iip1,ijp1)
+                  zvis11 = 2.0 * zviseta (iim1,ijm1) + dm
+                  zvis22 =       zviszeta(iim1,ijm1) - zviseta(iim1,ijm1)
+                  zvis12 =       zviseta (iim1,ijm1) + dm
+                  zvis21 =       zviseta (iim1,ijm1)
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11(ji,jj,2,1) =  zvis11 * ze11 + zdiag
+                  zs12(ji,jj,2,1) =  zvis12 * ze12 + zvis21 * ze21
+                  zs22(ji,jj,2,1) =  zvis11 * ze22 + zdiag
+                  zs21(ji,jj,2,1) =  zvis12 * ze21 + zvis21 * ze12
+
+
+                  iim1 = ji - 1
+                  ijm1 = jj
+                  iip1 = ji
+                  ijp1 = jj + 1                   
+                  ze11 =   akappa(iim1,ijm1,1,1) * ( u_ice(iip1,ijp1) - u_ice(iim1,ijp1) )   &
+                     &   + akappa(iim1,ijm1,1,2) * ( v_ice(iip1,ijp1) + v_ice(iim1,ijp1) )
+                  ze12 = + akappa(iim1,ijm1,2,2) * ( u_ice(iim1,ijp1) + u_ice(iip1,ijp1) )   &
+                     &   - akappa(iim1,ijm1,2,1) * ( v_ice(iim1,ijp1) + v_ice(iip1,ijp1) )
+                  ze22 = + akappa(iim1,ijm1,2,2) * ( v_ice(iim1,ijp1) + v_ice(iip1,ijp1) )   &
+                     &   + akappa(iim1,ijm1,2,1) * ( u_ice(iim1,ijp1) + u_ice(iip1,ijp1) )
+                  ze21 =   akappa(iim1,ijm1,1,1) * ( v_ice(iip1,ijp1) - v_ice(iim1,ijp1) )   &
+                     &   - akappa(iim1,ijm1,1,2) * ( u_ice(iip1,ijp1) + u_ice(iim1,ijp1) )
+                  zvis11 = 2.0 * zviseta (iim1,ijm1) + dm
+                  zvis22 =       zviszeta(iim1,ijm1) - zviseta(iim1,ijm1)
+                  zvis12 =       zviseta (iim1,ijm1) + dm
+                  zvis21 =       zviseta (iim1,ijm1)
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11(ji,jj,1,2) =  zvis11 * ze11 + zdiag
+                  zs12(ji,jj,1,2) =  zvis12 * ze12 + zvis21 * ze21
+                  zs22(ji,jj,1,2) =  zvis11 * ze22 + zdiag
+                  zs21(ji,jj,1,2) =  zvis12 * ze21 + zvis21 * ze12
+
+                  iim1 = ji
+                  ijm1 = jj
+                  iip1 = ji + 1
+                  ijp1 = jj + 1
+                  ze11 =   akappa(iim1,ijm1,1,1) * ( u_ice(iip1,ijm1) + u_ice(iip1,ijp1) - u_ice(iim1,ijp1) )   &
+                     &   + akappa(iim1,ijm1,1,2) * ( v_ice(iip1,ijm1) + v_ice(iip1,ijp1) + v_ice(iim1,ijp1) )
+                  ze12 = - akappa(iim1,ijm1,2,2) * ( u_ice(iip1,ijm1) - u_ice(iim1,ijp1) - u_ice(iip1,ijp1) )   &
+                     &   - akappa(iim1,ijm1,2,1) * ( v_ice(iip1,ijm1) + v_ice(iim1,ijp1) + v_ice(iip1,ijp1) )
+                  ze22 = - akappa(iim1,ijm1,2,2) * ( v_ice(iip1,ijm1) - v_ice(iim1,ijp1) - v_ice(iip1,ijp1) )   &
+                     &   + akappa(iim1,ijm1,2,1) * ( u_ice(iip1,ijm1) + u_ice(iim1,ijp1) + u_ice(iip1,ijp1) )
+                  ze21 =   akappa(iim1,ijm1,1,1) * ( v_ice(iip1,ijm1) + v_ice(iip1,ijp1) - v_ice(iim1,ijp1) )   &
+                     &   - akappa(iim1,ijm1,1,2) * ( u_ice(iip1,ijm1) + u_ice(iip1,ijp1) + u_ice(iim1,ijp1) ) 
+                  zvis11 = 2.0 * zviseta (iim1,ijm1) + dm
+                  zvis22 =       zviszeta(iim1,ijm1) - zviseta(iim1,ijm1)
+                  zvis12 =       zviseta (iim1,ijm1) + dm
+                  zvis21 =       zviseta (iim1,ijm1)
+
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11(ji,jj,2,2) =  zvis11 * ze11 + zdiag
+                  zs12(ji,jj,2,2) =  zvis12 * ze12 + zvis21 * ze21
+                  zs22(ji,jj,2,2) =  zvis11 * ze22 + zdiag
+                  zs21(ji,jj,2,2) =  zvis12 * ze21 + zvis21 * ze12
+
+               END DO
+            END DO
+
+            ! Terms involving already up-dated velocities.
+            !-Using the arrays zu_ice and zv_ice in the computation of the terms ze leads to JACOBI's method; 
+            ! Using arrays u and v in the computation of the terms ze leads to GAUSS-SEIDEL method.
+             
+            DO jj = k_j1+1, k_jpj-1
+               DO ji = 2, jpim1
+                  iim1 = ji - 1
+                  ijm1 = jj - 1
+                  iip1 = ji
+                  ijp1 = jj
+                  ze11 =   akappa(iim1,ijm1,1,1) * ( zu_ice(iip1,ijm1) - zu_ice(iim1,ijm1) - zu_ice(iim1,ijp1) )   &
+                     &   + akappa(iim1,ijm1,1,2) * ( zv_ice(iip1,ijm1) + zv_ice(iim1,ijm1) + zv_ice(iim1,ijp1) )
+                  ze12 = - akappa(iim1,ijm1,2,2) * ( zu_ice(iim1,ijm1) + zu_ice(iip1,ijm1) - zu_ice(iim1,ijp1) )   &
+                     &   - akappa(iim1,ijm1,2,1) * ( zv_ice(iim1,ijm1) + zv_ice(iip1,ijm1) + zv_ice(iim1,ijp1) )
+                  ze22 = - akappa(iim1,ijm1,2,2) * ( zv_ice(iim1,ijm1) + zv_ice(iip1,ijm1) - zv_ice(iim1,ijp1) )   &
+                     &   + akappa(iim1,ijm1,2,1) * ( zu_ice(iim1,ijm1) + zu_ice(iip1,ijm1) + zu_ice(iim1,ijp1) )
+                  ze21 =   akappa(iim1,ijm1,1,1) * ( zv_ice(iip1,ijm1) - zv_ice(iim1,ijm1) - zv_ice(iim1,ijp1) )   &
+                     &  -  akappa(iim1,ijm1,1,2) * ( zu_ice(iip1,ijm1) + zu_ice(iim1,ijm1) + zu_ice(iim1,ijp1) )
+                  zvis11 = 2.0 * zviseta (iim1,ijm1) + dm
+                  zvis22 =       zviszeta(iim1,ijm1) - zviseta(iim1,ijm1)
+                  zvis12 =       zviseta (iim1,ijm1) + dm
+                  zvis21 =       zviseta (iim1,ijm1)
+
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11(ji,jj,1,1) =  zvis11 * ze11 + zdiag
+                  zs12(ji,jj,1,1) =  zvis12 * ze12 + zvis21 * ze21
+                  zs22(ji,jj,1,1) =  zvis11 * ze22 + zdiag
+                  zs21(ji,jj,1,1) =  zvis12 * ze21 + zvis21 * ze12
+
+#if defined key_agrif
+             END DO
+          END DO
+
+          DO jj = k_j1+1, k_jpj-1
+             DO ji = 2, jpim1
+#endif
+
+                  iim1 = ji
+                  ijm1 = jj - 1
+                  iip1 = ji + 1
+                  ze11 =   akappa(iim1,ijm1,1,1) * ( zu_ice(iip1,ijm1) - zu_ice(iim1,ijm1) )   &
+                     &   + akappa(iim1,ijm1,1,2) * ( zv_ice(iip1,ijm1) + zv_ice(iim1,ijm1) )
+                  ze12 = - akappa(iim1,ijm1,2,2) * ( zu_ice(iim1,ijm1) + zu_ice(iip1,ijm1) )   &
+                     &   - akappa(iim1,ijm1,2,1) * ( zv_ice(iim1,ijm1) + zv_ice(iip1,ijm1) )
+                  ze22 = - akappa(iim1,ijm1,2,2) * ( zv_ice(iim1,ijm1) + zv_ice(iip1,ijm1) )   &
+                     &   + akappa(iim1,ijm1,2,1) * ( zu_ice(iim1,ijm1) + zu_ice(iip1,ijm1) )
+                  ze21 =   akappa(iim1,ijm1,1,1) * ( zv_ice(iip1,ijm1) - zv_ice(iim1,ijm1) )   &
+                     &   - akappa(iim1,ijm1,1,2) * ( zu_ice(iip1,ijm1) + zu_ice(iim1,ijm1) )
+                  zvis11 = 2.0 * zviseta (iim1,ijm1) + dm
+                  zvis22 =       zviszeta(iim1,ijm1) - zviseta(iim1,ijm1)
+                  zvis12 =       zviseta (iim1,ijm1) + dm
+                  zvis21 =       zviseta (iim1,ijm1)
+
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11(ji,jj,2,1) =  zs11(ji,jj,2,1) + zvis11 * ze11 + zdiag
+                  zs12(ji,jj,2,1) =  zs12(ji,jj,2,1) + zvis12 * ze12 + zvis21 * ze21
+                  zs22(ji,jj,2,1) =  zs22(ji,jj,2,1) + zvis11 * ze22 + zdiag
+                  zs21(ji,jj,2,1) =  zs21(ji,jj,2,1) + zvis12 * ze21 + zvis21 * ze12
+
+
+                  iim1 = ji - 1
+                  ijm1 = jj 
+                  ze11 = - akappa(iim1,ijm1,1,1) * zu_ice(iim1,ijm1) + akappa(iim1,ijm1,1,2) * zv_ice(iim1,ijm1)
+                  ze12 = - akappa(iim1,ijm1,2,2) * zu_ice(iim1,ijm1) - akappa(iim1,ijm1,2,1) * zv_ice(iim1,ijm1)
+                  ze22 = - akappa(iim1,ijm1,2,2) * zv_ice(iim1,ijm1) + akappa(iim1,ijm1,2,1) * zu_ice(iim1,ijm1)
+                  ze21 = - akappa(iim1,ijm1,1,1) * zv_ice(iim1,ijm1) - akappa(iim1,ijm1,1,2) * zu_ice(iim1,ijm1)
+                  zvis11 = 2.0 * zviseta (iim1,ijm1) + dm
+                  zvis22 =       zviszeta(iim1,ijm1) - zviseta(iim1,ijm1)
+                  zvis12 =       zviseta (iim1,ijm1) + dm
+                  zvis21 =       zviseta (iim1,ijm1)
+
+                  zdiag = zvis22 * ( ze11 + ze22 )
+                  zs11(ji,jj,1,2) =  zs11(ji,jj,1,2) + zvis11 * ze11 + zdiag 
+                  zs12(ji,jj,1,2) =  zs12(ji,jj,1,2) + zvis12 * ze12 + zvis21 * ze21
+                  zs22(ji,jj,1,2) =  zs22(ji,jj,1,2) + zvis11 * ze22 + zdiag
+                  zs21(ji,jj,1,2) =  zs21(ji,jj,1,2) + zvis12 * ze21 + zvis21 * ze12
+
+#if defined key_agrif
+             END DO
+          END DO
+
+          DO jj = k_j1+1, k_jpj-1
+             DO ji = 2, jpim1
+#endif
+                  zd1(ji,jj) =   &
+                     + alambd(ji,jj,2,2,2,1) * zs11(ji,jj,2,1) + alambd(ji,jj,2,2,2,2) * zs11(ji,jj,2,2)  &
+                     - alambd(ji,jj,2,2,1,1) * zs11(ji,jj,1,1) - alambd(ji,jj,2,2,1,2) * zs11(ji,jj,1,2)  &
+                     - alambd(ji,jj,1,1,2,1) * zs12(ji,jj,2,1) - alambd(ji,jj,1,1,1,1) * zs12(ji,jj,1,1)  &
+                     + alambd(ji,jj,1,1,2,2) * zs12(ji,jj,2,2) + alambd(ji,jj,1,1,1,2) * zs12(ji,jj,1,2)  &
+                     + alambd(ji,jj,1,2,1,1) * zs21(ji,jj,1,1) + alambd(ji,jj,1,2,2,1) * zs21(ji,jj,2,1)  &
+                     + alambd(ji,jj,1,2,1,2) * zs21(ji,jj,1,2) + alambd(ji,jj,1,2,2,2) * zs21(ji,jj,2,2)  &
+                     - alambd(ji,jj,2,1,1,1) * zs22(ji,jj,1,1) - alambd(ji,jj,2,1,2,1) * zs22(ji,jj,2,1)  &
+                     - alambd(ji,jj,2,1,1,2) * zs22(ji,jj,1,2) - alambd(ji,jj,2,1,2,2) * zs22(ji,jj,2,2)
+                  zd2(ji,jj) =   &
+                     + alambd(ji,jj,2,2,2,1) * zs21(ji,jj,2,1) + alambd(ji,jj,2,2,2,2) * zs21(ji,jj,2,2)  &
+                     - alambd(ji,jj,2,2,1,1) * zs21(ji,jj,1,1) - alambd(ji,jj,2,2,1,2) * zs21(ji,jj,1,2)  &
+                     - alambd(ji,jj,1,1,2,1) * zs22(ji,jj,2,1) - alambd(ji,jj,1,1,1,1) * zs22(ji,jj,1,1)  &
+                     + alambd(ji,jj,1,1,2,2) * zs22(ji,jj,2,2) + alambd(ji,jj,1,1,1,2) * zs22(ji,jj,1,2)  &
+                     - alambd(ji,jj,1,2,1,1) * zs11(ji,jj,1,1) - alambd(ji,jj,1,2,2,1) * zs11(ji,jj,2,1)  &
+                     - alambd(ji,jj,1,2,1,2) * zs11(ji,jj,1,2) - alambd(ji,jj,1,2,2,2) * zs11(ji,jj,2,2)  &
+                     + alambd(ji,jj,2,1,1,1) * zs12(ji,jj,1,1) + alambd(ji,jj,2,1,2,1) * zs12(ji,jj,2,1)  &
+                     + alambd(ji,jj,2,1,1,2) * zs12(ji,jj,1,2) + alambd(ji,jj,2,1,2,2) * zs12(ji,jj,2,2)
+               END DO
+            END DO
+
+            DO jj = k_j1+1, k_jpj-1
+               DO ji = 2, jpim1
+                  zunw = (  ( za1(ji,jj) + zd1(ji,jj) ) * zc2(ji,jj)        &
+                     &    + ( za2(ji,jj) + zd2(ji,jj) ) * zc1(ji,jj) ) * zden(ji,jj)
+
+                  zvnw = (  ( za2(ji,jj) + zd2(ji,jj) ) * zb1(ji,jj)        &
+                     &    - ( za1(ji,jj) + zd1(ji,jj) ) * zb2(ji,jj) ) * zden(ji,jj)
+
+                  zmask = ( 1.0 - MAX( rzero, SIGN( rone , 1.0 - zmass(ji,jj) ) ) ) * tmu(ji,jj)
+
+                  u_ice(ji,jj) = ( u_ice(ji,jj) + om * ( zunw - u_ice(ji,jj) ) * tmu(ji,jj) ) * zmask
+                  v_ice(ji,jj) = ( v_ice(ji,jj) + om * ( zvnw - v_ice(ji,jj) ) * tmu(ji,jj) ) * zmask
+               END DO
+            END DO
+
+            CALL lbc_lnk( u_ice, 'I', -1. )
+            CALL lbc_lnk( v_ice, 'I', -1. )
+
+            !---  5.2.5.4. Convergence test.
+            DO jj = k_j1+1 , k_jpj-1
+               zresr(:,jj) = MAX( ABS( u_ice(:,jj) - zu_ice(:,jj) ) , ABS( v_ice(:,jj) - zv_ice(:,jj) ) )
+            END DO
+            zresm = MAXVAL( zresr( 1:jpi , k_j1+1:k_jpj-1 ) )
+            IF( lk_mpp )   CALL mpp_max( zresm )   ! max over the global domain
+
+            IF ( zresm <= resl) EXIT iflag
+
+         END DO iflag
+
+         zindu1 = 1.0 - zindu
+         DO jj = k_j1 , k_jpj-1
+            zu0(:,jj) = zindu * zu0(:,jj) + zindu1 * u_ice(:,jj)
+            zv0(:,jj) = zindu * zv0(:,jj) + zindu1 * v_ice(:,jj)
+         END DO
+      !                                                   ! ==================== !
+      END DO                                              !  end loop over iter  !
+      !                                                   ! ==================== !
+
+      IF(ln_ctl) THEN
+         WRITE(charout,FMT="('lim_rhg  : res =',D23.16, ' iter =',I4)") zresm, jter
+         CALL prt_ctl_info(charout)
+         CALL prt_ctl(tab2d_1=u_ice, clinfo1=' lim_rhg  : u_ice :', tab2d_2=v_ice, clinfo2=' v_ice :')
+      ENDIF
+
+   END SUBROUTINE lim_rhg_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Dummy module       NO 2.0 LIM sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_rhg_2( k1 , k2 )       ! Dummy routine
+      WRITE(*,*) 'lim_rhg_2: You should not have seen this print! error?', k1, k2
+   END SUBROUTINE lim_rhg_2
+#endif
+
+   !!==============================================================================
+END MODULE limrhg_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limrst_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limrst_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limrst_2.F90	(revision 823)
@@ -0,0 +1,268 @@
+MODULE limrst_2
+   !!======================================================================
+   !!                     ***  MODULE  limrst_2  ***
+   !! Ice restart :  write the ice restart file
+   !!======================================================================
+   !! History :  2.0  !  01-04  (C. Ethe, G. Madec)  Original code
+   !!                 !  06-07  (S. Masson)  use IOM for restart read/write
+   !!----------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_rst_opn_2   : open ice restart file
+   !!   lim_rst_write_2 : write of the ice restart file 
+   !!   lim_rst_read_2  : read  the ice restart file 
+   !!----------------------------------------------------------------------
+   USE ice_2
+   USE dom_oce
+   USE ice_oce         ! ice variables
+   USE daymod
+
+   USE in_out_manager
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_rst_opn_2     ! routine called by ??? module
+   PUBLIC   lim_rst_write_2   ! routine called by ??? module
+   PUBLIC   lim_rst_read_2    ! routine called by ??? module
+
+   LOGICAL, PUBLIC ::   lrst_ice         !: logical to control the ice restart write 
+   INTEGER, PUBLIC ::   numrir, numriw   !: logical unit for ice restart (read and write)
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2006) 
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/LIM_SRC/limrst.F90,v 1.15 2007/06/29 14:54:06 opalod Exp $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_rst_opn_2( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  lim_rst_opn_2  ***
+      !!
+      !! ** purpose  :   output of sea-ice variable in a netcdf file
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt       ! number of iteration
+      !
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
+      CHARACTER(LEN=50)   ::   clname   ! ice output restart file name
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 )   lrst_ice = .FALSE.   ! default definition
+      
+      ! to get better performances with NetCDF format:
+      ! we open and define the ice restart file one ice time step before writing the data (-> at nitrst - 2*nfice + 1)
+      ! except if we write ice restart files every ice time step or if an ice restart file was writen at nitend - 2*nfice + 1
+      IF( kt == nitrst - 2*nfice + 1 .OR. nstock == nfice .OR. ( kt == nitend - nfice + 1 .AND. .NOT. lrst_ice ) ) THEN
+         ! beware of the format used to write kt (default is i8.8, that should be large enough...)
+         IF( nitrst > 99999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+         ELSE                           ;   WRITE(clkt, '(i8.8)') nitrst
+         ENDIF
+         ! create the file
+         clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_restart_ice"
+         IF(lwp) THEN
+            WRITE(numout,*)
+            SELECT CASE ( jprstlib )
+            CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ice restart binary file: '//clname
+            CASE DEFAULT         ;   WRITE(numout,*) '             open ice restart NetCDF file: '//clname
+            END SELECT
+            IF( kt == nitrst - 2*nfice + 1 ) THEN   
+               WRITE(numout,*)         '             kt = nitrst - 2*nfice + 1 = ', kt,' date= ', ndastp
+            ELSE   ;   WRITE(numout,*) '             kt = '                       , kt,' date= ', ndastp
+            ENDIF
+         ENDIF
+
+         CALL iom_open( clname, numriw, ldwrt = .TRUE., kiolib = jprstlib )
+         lrst_ice = .TRUE.
+      ENDIF
+      !
+   END SUBROUTINE lim_rst_opn_2
+
+   SUBROUTINE lim_rst_write_2( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  lim_rst_write_2  ***
+      !!
+      !! ** purpose  :   output of sea-ice variable in a netcdf file
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+      !!
+      INTEGER ::   iter     ! kt + nfice -1
+      !!----------------------------------------------------------------------
+
+      iter = kt + nfice - 1   ! ice restarts are written at kt == nitrst - nfice + 1
+
+      IF( iter == nitrst ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'lim_rst_write_2 : write ice restart file  kt =', kt
+         IF(lwp) WRITE(numout,*) '~~~~~~~'         
+      ENDIF
+
+      ! Write in numriw (if iter == nitrst)
+      ! ------------------ 
+      !                                                                     ! calendar control
+      CALL iom_rstput( iter, nitrst, numriw, 'nfice' , REAL( nfice, wp) )      ! time-step 
+      CALL iom_rstput( iter, nitrst, numriw, 'kt_ice', REAL( iter , wp) )      ! date
+      
+      CALL iom_rstput( iter, nitrst, numriw, 'hicif' , hicif (:,:)   )      ! prognostic variables 
+      CALL iom_rstput( iter, nitrst, numriw, 'hsnif' , hsnif (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'frld'  , frld  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sist'  , sist  (:,:)   )
+# if defined key_coupled
+      CALL iom_rstput( iter, nitrst, numriw, 'albege', albege(:,:) )
+# endif
+      CALL iom_rstput( iter, nitrst, numriw, 'tbif1' , tbif  (:,:,1) )
+      CALL iom_rstput( iter, nitrst, numriw, 'tbif2' , tbif  (:,:,2) )
+      CALL iom_rstput( iter, nitrst, numriw, 'tbif3' , tbif  (:,:,3) )
+      CALL iom_rstput( iter, nitrst, numriw, 'u_ice' , u_ice (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_ice' , v_ice (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'gtaux' , gtaux (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'gtauy' , gtauy (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'qstoif', qstoif(:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'fsbbq' , fsbbq (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxice' , sxice (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syice' , syice (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxice', sxxice(:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyice', syyice(:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyice', sxyice(:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxsn'  , sxsn  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sysn'  , sysn  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxsn' , sxxsn (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syysn' , syysn (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxysn' , sxysn (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxa'   , sxa   (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sya'   , sya   (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxa'  , sxxa  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syya'  , syya  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxya'  , sxya  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxc0'  , sxc0  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syc0'  , syc0  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxc0' , sxxc0 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyc0' , syyc0 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyc0' , sxyc0 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxc1'  , sxc1  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syc1'  , syc1  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxc1' , sxxc1 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyc1' , syyc1 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyc1' , sxyc1 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxc2'  , sxc2  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syc2'  , syc2  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxc2' , sxxc2 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyc2' , syyc2 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyc2' , sxyc2 (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxst'  , sxst  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syst'  , syst  (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxxst' , sxxst (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'syyst' , syyst (:,:)   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sxyst' , sxyst (:,:)   )
+      
+      IF( iter == nitrst ) THEN
+         CALL iom_close( numriw )                         ! close the restart file
+         lrst_ice = .FALSE.
+      ENDIF
+      !
+   END SUBROUTINE lim_rst_write_2
+
+
+   SUBROUTINE lim_rst_read_2
+      !!----------------------------------------------------------------------
+      !!                    ***  lim_rst_read_2  ***
+      !!
+      !! ** purpose  :   read of sea-ice variable restart in a netcdf file
+      !!----------------------------------------------------------------------
+      !
+      REAL(wp) ::   zfice, ziter
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_rst_read_2 : read ice NetCDF restart file'
+         WRITE(numout,*) '~~~~~~~~'
+      ENDIF
+
+      CALL iom_open ( 'restart_ice_in', numrir, kiolib = jprstlib )
+
+      CALL iom_get( numrir, 'nfice' , zfice )
+      CALL iom_get( numrir, 'kt_ice', ziter )    
+      IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', ziter
+      IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
+
+      !Control of date
+      
+      IF( ( nit000 - INT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
+         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nit000 in ice restart',  &
+         &                   '   verify the file or rerun with the value 0 for the',        &
+         &                   '   control of time parameter  nrstdt' )
+      IF( INT(zfice) /= nfice          .AND. ABS( nrstdt ) == 1 )   &
+         &     CALL ctl_stop( 'lim_rst_read ===>>>> : problem with nfice in ice restart',  &
+         &                   '   verify the file or rerun with the value 0 for the',        &
+         &                   '   control of time parameter  nrstdt' )
+
+      CALL iom_get( numrir, jpdom_autoglo, 'hicif' , hicif  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'hsnif' , hsnif  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'frld'  , frld   )    
+      CALL iom_get( numrir, jpdom_autoglo, 'sist'  , sist   )    
+# if defined key_coupled 
+      CALL iom_get( numrir, jpdom_autoglo, 'albege', albege )    
+# endif
+      CALL iom_get( numrir, jpdom_autoglo, 'tbif1' , tbif(:,:,1) )    
+      CALL iom_get( numrir, jpdom_autoglo, 'tbif2' , tbif(:,:,2) )    
+      CALL iom_get( numrir, jpdom_autoglo, 'tbif3' , tbif(:,:,3) )    
+      CALL iom_get( numrir, jpdom_autoglo, 'u_ice' , u_ice  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'v_ice' , v_ice  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'gtaux' , gtaux  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'gtauy' , gtauy  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'qstoif', qstoif )    
+      CALL iom_get( numrir, jpdom_autoglo, 'fsbbq' , fsbbq  )    
+      CALL iom_get( numrir, jpdom_autoglo, 'sxice' , sxice  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syice' , syice  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxice', sxxice )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyice', syyice )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyice', sxyice )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxsn'  , sxsn   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sysn'  , sysn   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxsn' , sxxsn  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syysn' , syysn  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxysn' , sxysn  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxa'   , sxa    )
+      CALL iom_get( numrir, jpdom_autoglo, 'sya'   , sya    )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxa'  , sxxa   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syya'  , syya   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxya'  , sxya   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxc0'  , sxc0   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syc0'  , syc0   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxc0' , sxxc0  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyc0' , syyc0  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyc0' , sxyc0  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxc1'  , sxc1   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syc1'  , syc1   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxc1' , sxxc1  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyc1' , syyc1  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyc1' , sxyc1  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxc2'  , sxc2   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syc2'  , syc2   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxc2' , sxxc2  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyc2' , syyc2  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyc2' , sxyc2  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxst'  , sxst   )
+      CALL iom_get( numrir, jpdom_autoglo, 'syst'  , syst   )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxxst' , sxxst  )
+      CALL iom_get( numrir, jpdom_autoglo, 'syyst' , syyst  )
+      CALL iom_get( numrir, jpdom_autoglo, 'sxyst' , sxyst  )
+      
+      CALL iom_close( numrir )
+      !
+   END SUBROUTINE lim_rst_read_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :       Empty module        NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+#endif
+
+   !!======================================================================
+END MODULE limrst_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limtab_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limtab_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limtab_2.F90	(revision 823)
@@ -0,0 +1,80 @@
+MODULE limtab_2
+   !!======================================================================
+   !!                       ***  MODULE limtab_2   ***
+   !!              transform 1D (2D) array to a 2D (1D) table
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   tab_2d_1d  : 2-D to 1-D
+   !!   tab_1d_2d  : 1-D to 2-D
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_kind
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC tab_2d_1d_2  ! called by lim_ther
+   PUBLIC tab_1d_2d_2  ! called by lim_ther
+
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tab_2d_1d_2 ( ndim1d, tab1d, tab2d, ndim2d_x, ndim2d_y, tab_ind )
+
+      INTEGER, INTENT(in) :: &
+         ndim1d, ndim2d_x, ndim2d_y
+
+      REAL(wp), DIMENSION (ndim2d_x, ndim2d_y), INTENT(in) ::  &
+         tab2d
+
+      INTEGER, DIMENSION ( ndim1d), INTENT ( in) :: &
+         tab_ind
+
+      REAL(wp), DIMENSION(ndim1d), INTENT ( out) ::  & 
+         tab1d
+
+      INTEGER ::  &
+         jn , jid, jjd
+        
+      DO jn = 1, ndim1d
+         jid        = MOD( tab_ind(jn) - 1, ndim2d_x ) + 1
+         jjd        = ( tab_ind(jn) - 1 ) / ndim2d_x + 1
+         tab1d( jn) = tab2d( jid, jjd)
+      END DO 
+
+   END SUBROUTINE tab_2d_1d_2
+
+
+   SUBROUTINE tab_1d_2d_2 ( ndim1d, tab2d, tab_ind, tab1d, ndim2d_x, ndim2d_y )
+
+      INTEGER, INTENT ( in) :: &
+         ndim1d, ndim2d_x, ndim2d_y
+
+      INTEGER, DIMENSION (ndim1d) , INTENT (in) :: &
+         tab_ind
+
+      REAL(wp), DIMENSION(ndim1d), INTENT (in) ::  &
+         tab1d  
+
+      REAL(wp), DIMENSION (ndim2d_x, ndim2d_y), INTENT ( out) :: &
+         tab2d
+
+      INTEGER :: &
+         jn, jid, jjd
+
+      DO jn = 1, ndim1d
+         jid             = MOD( tab_ind(jn) - 1, ndim2d_x) + 1
+         jjd             =    ( tab_ind(jn) - 1 ) / ndim2d_x  + 1
+         tab2d(jid, jjd) = tab1d( jn)
+      END DO
+
+   END SUBROUTINE tab_1d_2d_2
+
+#endif
+END MODULE limtab_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limthd_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limthd_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limthd_2.F90	(revision 823)
@@ -0,0 +1,480 @@
+MODULE limthd_2
+   !!======================================================================
+   !!                  ***  MODULE limthd_2   ***
+   !!              LIM thermo ice model : ice thermodynamic
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_thd_2      : thermodynamic of sea ice
+   !!   lim_thd_init_2 : initialisation of sea-ice thermodynamic
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst          ! physical constants
+   USE dom_oce         ! ocean space and time domain variables
+   USE lbclnk
+   USE in_out_manager  ! I/O manager
+   USE ice_2           ! LIM sea-ice variables
+   USE ice_oce         ! sea-ice/ocean variables
+   USE flx_oce         ! sea-ice/ocean forcings variables 
+   USE thd_ice_2       ! LIM thermodynamic sea-ice variables
+   USE dom_ice_2       ! LIM sea-ice domain
+   USE iceini_2
+   USE limthd_zdf_2
+   USE limthd_lac_2
+   USE limtab_2
+   USE prtctl          ! Print control
+      
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_thd_2       ! called by lim_step_2
+
+   !! * Module variables
+   REAL(wp)  ::            &  ! constant values
+      epsi20 = 1.e-20   ,  &
+      epsi16 = 1.e-16   ,  &
+      epsi04 = 1.e-04   ,  &
+      zzero  = 0.e0     ,  &
+      zone   = 1.e0
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!-------- -------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_thd_2( kt )
+      !!-------------------------------------------------------------------
+      !!                ***  ROUTINE lim_thd_2  ***       
+      !!  
+      !! ** Purpose : This routine manages the ice thermodynamic.
+      !!         
+      !! ** Action : - Initialisation of some variables
+      !!             - Some preliminary computation (oceanic heat flux
+      !!               at the ice base, snow acc.,heat budget of the leads)
+      !!             - selection of the icy points and put them in an array
+      !!             - call lim_vert_ther for vert ice thermodynamic
+      !!             - back to the geographic grid
+      !!             - selection of points for lateral accretion
+      !!             - call lim_lat_acc  for the ice accretion
+      !!             - back to the geographic grid
+      !!
+      !! ** References :
+      !!       H. Goosse et al. 1996, Bul. Soc. Roy. Sc. Liege, 65, 87-90
+      !!
+      !! History :
+      !!   1.0  !  00-01 (LIM)
+      !!   2.0  !  02-07 (C. Ethe, G. Madec) F90
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+
+      INTEGER  ::   ji, jj,    &   ! dummy loop indices
+         nbpb  ,               &   ! nb of icy pts for thermo. cal.
+         nbpac                     ! nb of pts for lateral accretion 
+      CHARACTER (len=22) :: charout
+      REAL(wp) ::  &
+         zfric_umin = 5e-03 ,  &   ! lower bound for the friction velocity
+         zfric_umax = 2e-02        ! upper bound for the friction velocity
+      REAL(wp) ::   &
+         zinda              ,  &   ! switch for test. the val. of concen.
+         zindb, zindg       ,  &   ! switches for test. the val of arg
+         za , zh, zthsnice  ,  &
+         zfric_u            ,  &   ! friction velocity 
+         zfnsol             ,  &   ! total non solar heat
+         zfontn             ,  &   ! heat flux from snow thickness
+         zfntlat, zpareff          ! test. the val. of lead heat budget
+      REAL(wp), DIMENSION(jpi,jpj) :: &
+         zhicifp            ,  &   ! ice thickness for outputs
+         zqlbsbq                   ! link with lead energy budget qldif
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: &
+         zmsk                      ! working array
+      !!-------------------------------------------------------------------
+
+      IF( kt == nit000  )   CALL lim_thd_init_2  ! Initialization (first time-step only)
+   
+      !-------------------------------------------!
+      !   Initilization of diagnostic variables   !
+      !-------------------------------------------!
+      
+!i est-ce utile?  oui au moins en partie
+      rdvosif(:,:) = 0.e0   ! variation of ice volume at surface
+      rdvobif(:,:) = 0.e0   ! variation of ice volume at bottom
+      fdvolif(:,:) = 0.e0   ! total variation of ice volume
+      rdvonif(:,:) = 0.e0   ! lateral variation of ice volume
+      fstric (:,:) = 0.e0   ! part of solar radiation absorbing inside the ice
+      fscmbq (:,:) = 0.e0   ! linked with fstric
+      ffltbif(:,:) = 0.e0   ! linked with fstric
+      qfvbq  (:,:) = 0.e0   ! linked with fstric
+      rdmsnif(:,:) = 0.e0   ! variation of snow mass per unit area
+      rdmicif(:,:) = 0.e0   ! variation of ice mass per unit area
+      hicifp (:,:) = 0.e0   ! daily thermodynamic ice production. 
+      zmsk (:,:,:) = 0.e0
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            hsnif(ji,jj)  = hsnif(ji,jj) *  MAX( zzero, SIGN( zone , hsnif(ji,jj) - epsi04 ) )
+         END DO
+      END DO
+
+      IF(ln_ctl)   CALL prt_ctl(tab2d_1=hsnif     , clinfo1=' lim_thd: hsnif   : ')
+      
+      !-----------------------------------!
+      !   Treatment of particular cases   !
+      !-----------------------------------!
+      
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            !  snow is transformed into ice if the original ice cover disappears.
+            zindg         = tms(ji,jj) *  MAX( zzero , SIGN( zone , -hicif(ji,jj) ) )
+            hicif(ji,jj)  = hicif(ji,jj) + zindg * rhosn * hsnif(ji,jj) / rau0
+            hsnif(ji,jj)  = ( zone - zindg ) * hsnif(ji,jj) + zindg * hicif(ji,jj) * ( rau0 - rhoic ) / rhosn
+            dmgwi(ji,jj)  = zindg * (1.0 - frld(ji,jj)) * rhoic * hicif(ji,jj)   ! snow/ice mass
+            
+            !  the lead fraction, frld, must be little than or equal to amax (ice ridging).
+            zthsnice      = hsnif(ji,jj) + hicif(ji,jj)
+            zindb         = tms(ji,jj) * ( 1.0 - MAX( zzero , SIGN( zone , - zthsnice ) ) ) 
+            za            = zindb * MIN( zone, ( 1.0 - frld(ji,jj) ) * uscomi )
+            hsnif (ji,jj) = hsnif(ji,jj)  * za
+            hicif (ji,jj) = hicif(ji,jj)  * za
+            qstoif(ji,jj) = qstoif(ji,jj) * za
+            frld  (ji,jj) = 1.0 - zindb * ( 1.0 - frld(ji,jj) ) / MAX( za , epsi20 )
+            
+            !  the in situ ice thickness, hicif, must be equal to or greater than hiclim.
+            zh            = MAX( zone , zindb * hiclim  / MAX( hicif(ji,jj) , epsi20 ) )
+            hsnif (ji,jj) = hsnif(ji,jj)  * zh
+            hicif (ji,jj) = hicif(ji,jj)  * zh
+            qstoif(ji,jj) = qstoif(ji,jj) * zh
+            frld  (ji,jj) = ( frld(ji,jj) + ( zh - 1.0 ) ) / zh
+         END DO
+      END DO
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=hicif  , clinfo1=' lim_thd: hicif   : ')
+         CALL prt_ctl(tab2d_1=hsnif  , clinfo1=' lim_thd: hsnif   : ')
+         CALL prt_ctl(tab2d_1=dmgwi  , clinfo1=' lim_thd: dmgwi   : ')
+         CALL prt_ctl(tab2d_1=qstoif , clinfo1=' lim_thd: qstoif  : ')
+         CALL prt_ctl(tab2d_1=frld   , clinfo1=' lim_thd: frld    : ')
+      ENDIF
+
+      
+      !-------------------------------!
+      !   Thermodynamics of sea ice   !
+      !-------------------------------!
+      
+      !      Partial computation of forcing for the thermodynamic sea ice model.
+      !--------------------------------------------------------------------------
+
+      !CDIR NOVERRCHK
+      DO jj = 1, jpj
+         !CDIR NOVERRCHK
+         DO ji = 1, jpi
+            zthsnice       = hsnif(ji,jj) + hicif(ji,jj)
+            zindb          = tms(ji,jj) * ( 1.0 - MAX( zzero , SIGN( zone , - zthsnice ) ) ) 
+            pfrld(ji,jj)   = frld(ji,jj)
+            zinda          = 1.0 - MAX( zzero , SIGN( zone , - ( 1.0 - pfrld(ji,jj) ) ) )
+            
+            !  solar irradiance transmission at the mixed layer bottom and used in the lead heat budget
+            thcm(ji,jj)    = 0.e0 
+            
+            !  net downward heat flux from the ice to the ocean, expressed as a function of ocean 
+            !  temperature and turbulent mixing (McPhee, 1992)
+            zfric_u        = MAX ( MIN( SQRT( ust2s(ji,jj) ) , zfric_umax ) , zfric_umin )  ! friction velocity
+            fdtcn(ji,jj)  = zindb * rau0 * rcp * 0.006  * zfric_u * ( sst_io(ji,jj) - tfu(ji,jj) ) 
+            qdtcn(ji,jj)  = zindb * fdtcn(ji,jj) * frld(ji,jj) * rdt_ice
+                        
+            !  partial computation of the lead energy budget (qldif)
+            zfontn         = ( sprecip(ji,jj) / rhosn ) * xlsn  !   energy for melting
+            zfnsol         = qnsr_oce(ji,jj)  !  total non solar flux
+            qldif(ji,jj)   = tms(ji,jj) * ( qsr_oce(ji,jj) * ( 1.0 - thcm(ji,jj) )   &
+               &                               + zfnsol + fdtcn(ji,jj) - zfontn     &
+               &                               + ( 1.0 - zindb ) * fsbbq(ji,jj) )   &
+               &                               * frld(ji,jj) * rdt_ice    
+            !  parlat : percentage of energy used for lateral ablation (0.0) 
+            zfntlat        = 1.0 - MAX( zzero , SIGN( zone ,  - qldif(ji,jj) ) )
+            zpareff        = 1.0 + ( parlat - 1.0 ) * zinda * zfntlat
+            zqlbsbq(ji,jj) = qldif(ji,jj) * ( 1.0 - zpareff ) / MAX( (1.0 - frld(ji,jj)) * rdt_ice , epsi16 )
+            qldif  (ji,jj) = zpareff *  qldif(ji,jj)
+            qdtcn  (ji,jj) = zpareff * qdtcn(ji,jj)
+            
+            !  energy needed to bring ocean surface layer until its freezing
+            qcmif  (ji,jj) =  rau0 * rcp * fse3t(ji,jj,1) * ( tfu(ji,jj) - sst_io(ji,jj) ) * ( 1 - zinda )
+            
+            !  calculate oceanic heat flux.
+            fbif   (ji,jj) = zindb * (  fsbbq(ji,jj) / MAX( (1.0 - frld(ji,jj)) , epsi20 ) + fdtcn(ji,jj) )
+            
+            ! computation of the daily thermodynamic ice production (only needed for output)
+            zhicifp(ji,jj) = hicif(ji,jj) * ( 1.0 - frld(ji,jj) )
+         END DO
+      END DO
+      
+      
+      !         Select icy points and fulfill arrays for the vectorial grid.
+      !----------------------------------------------------------------------
+      nbpb = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF ( frld(ji,jj) < 1.0 ) THEN     
+               nbpb      = nbpb + 1
+               npb(nbpb) = (jj - 1) * jpi + ji
+            ENDIF
+         END DO
+      END DO
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=pfrld, clinfo1=' lim_thd: pfrld   : ', tab2d_2=thcm   , clinfo2='  thcm    : ')
+         CALL prt_ctl(tab2d_1=fdtcn, clinfo1=' lim_thd: fdtcn   : ', tab2d_2=qdtcn  , clinfo2='  qdtcn   : ')
+         CALL prt_ctl(tab2d_1=qldif, clinfo1=' lim_thd: qldif   : ', tab2d_2=zqlbsbq, clinfo2='  zqlbsbq : ')
+         CALL prt_ctl(tab2d_1=qcmif, clinfo1=' lim_thd: qcmif   : ', tab2d_2=fbif   , clinfo2='  fbif    : ')
+         zmsk(:,:,1) = tms(:,:)
+         CALL prt_ctl(tab2d_1=qcmif  , clinfo1=' lim_thd: qcmif   : ', mask1=zmsk)
+         CALL prt_ctl(tab2d_1=zhicifp, clinfo1=' lim_thd: zhicifp : ')
+         WRITE(charout, FMT="('lim_thd: nbpb = ',I4)") nbpb
+         CALL prt_ctl_info(charout)
+      ENDIF
+      
+      
+      ! If there is no ice, do nothing. Otherwise, compute Top and Bottom accretion/ablation 
+      !------------------------------------------------------------------------------------ 
+
+      IF ( nbpb > 0) THEN
+         
+         !  put the variable in a 1-D array for thermodynamics process
+         CALL tab_2d_1d_2( nbpb, frld_1d    (1:nbpb)     , frld       , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, h_ice_1d   (1:nbpb)     , hicif      , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, h_snow_1d  (1:nbpb)     , hsnif      , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, sist_1d    (1:nbpb)     , sist       , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, tbif_1d    (1:nbpb , 1 ), tbif(:,:,1), jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, tbif_1d    (1:nbpb , 2 ), tbif(:,:,2), jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, tbif_1d    (1:nbpb , 3 ), tbif(:,:,3), jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, qsr_ice_1d (1:nbpb)     , qsr_ice    , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, fr1_i0_1d  (1:nbpb)     , fr1_i0     , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, fr2_i0_1d  (1:nbpb)     , fr2_i0     , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, qnsr_ice_1d(1:nbpb)     , qnsr_ice   , jpi, jpj, npb(1:nbpb) )
+#if ! defined key_coupled
+         CALL tab_2d_1d_2( nbpb, qla_ice_1d (1:nbpb)     , qla_ice    , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, dqla_ice_1d(1:nbpb)     , dqla_ice   , jpi, jpj, npb(1:nbpb) )
+#endif
+         CALL tab_2d_1d_2( nbpb, dqns_ice_1d(1:nbpb)     , dqns_ice   , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, tfu_1d     (1:nbpb)     , tfu        , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, sprecip_1d (1:nbpb)     , sprecip    , jpi, jpj, npb(1:nbpb) ) 
+         CALL tab_2d_1d_2( nbpb, fbif_1d    (1:nbpb)     , fbif       , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, thcm_1d    (1:nbpb)     , thcm       , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, qldif_1d   (1:nbpb)     , qldif      , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, qstbif_1d  (1:nbpb)     , qstoif     , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, rdmicif_1d (1:nbpb)     , rdmicif    , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, dmgwi_1d   (1:nbpb)     , dmgwi      , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d_2( nbpb, qlbbq_1d   (1:nbpb)     , zqlbsbq    , jpi, jpj, npb(1:nbpb) )
+ 
+         CALL lim_thd_zdf_2( 1, nbpb )       !  compute ice growth
+         
+         !  back to the geographic grid.
+         CALL tab_1d_2d_2( nbpb, frld       , npb, frld_1d   (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, hicif      , npb, h_ice_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, hsnif      , npb, h_snow_1d (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, sist       , npb, sist_1d   (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, tbif(:,:,1), npb, tbif_1d   (1:nbpb , 1 ), jpi, jpj )   
+         CALL tab_1d_2d_2( nbpb, tbif(:,:,2), npb, tbif_1d   (1:nbpb , 2 ), jpi, jpj )   
+         CALL tab_1d_2d_2( nbpb, tbif(:,:,3), npb, tbif_1d   (1:nbpb , 3 ), jpi, jpj )   
+         CALL tab_1d_2d_2( nbpb, fscmbq     , npb, fscbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, ffltbif    , npb, fltbif_1d (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, fstric     , npb, fstbif_1d (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, qldif      , npb, qldif_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, qfvbq      , npb, qfvbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, qstoif     , npb, qstbif_1d (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, rdmicif    , npb, rdmicif_1d(1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, dmgwi      , npb, dmgwi_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, rdmsnif    , npb, rdmsnif_1d(1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, rdvosif    , npb, dvsbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, rdvobif    , npb, dvbbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, fdvolif    , npb, dvlbq_1d  (1:nbpb)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpb, rdvonif    , npb, dvnbq_1d  (1:nbpb)     , jpi, jpj ) 
+
+ 
+      ENDIF
+
+      
+      !      Up-date sea ice thickness.
+      !---------------------------------
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            phicif(ji,jj) = hicif(ji,jj)  
+            hicif(ji,jj)  = hicif(ji,jj) *  ( zone -  MAX( zzero, SIGN( zone, - ( 1.0 - frld(ji,jj) ) ) ) )
+         END DO
+      END DO
+
+      
+      !      Tricky trick : add 2 to frld in the Southern Hemisphere.
+      !----------------------------------------------------------
+      IF( fcor(1,1) < 0.e0 ) THEN
+         DO jj = 1, njeqm1
+            DO ji = 1, jpi
+               frld(ji,jj) = frld(ji,jj) + 2.0
+            END DO
+         END DO
+      ENDIF
+      
+      
+      !     Select points for lateral accretion (this occurs when heat exchange
+      !     between ice and ocean is negative; ocean losing heat) 
+      !-----------------------------------------------------------------
+      nbpac = 0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+!i yes!     IF ( ( qcmif(ji,jj) - qldif(ji,jj) ) > 0.e0 ) THEN
+            IF ( tms(ji,jj) * ( qcmif(ji,jj) - qldif(ji,jj) ) > 0.e0 ) THEN
+               nbpac = nbpac + 1
+               npac( nbpac ) = (jj - 1) * jpi + ji
+            ENDIF
+         END DO
+      END DO
+      
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab2d_1=phicif, clinfo1=' lim_thd: phicif  : ', tab2d_2=hicif, clinfo2=' hicif : ')
+         WRITE(charout, FMT="('lim_thd: nbpac = ',I4)") nbpac
+         CALL prt_ctl_info(charout)
+      ENDIF
+
+      
+      !
+      !     If ocean gains heat do nothing ; otherwise, one performs lateral accretion
+      !--------------------------------------------------------------------------------
+
+      IF( nbpac > 0 ) THEN
+         
+         !...Put the variable in a 1-D array for lateral accretion
+         CALL tab_2d_1d_2( nbpac, frld_1d   (1:nbpac)     , frld       , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, h_snow_1d (1:nbpac)     , hsnif      , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, h_ice_1d  (1:nbpac)     , hicif      , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, tbif_1d   (1:nbpac , 1 ), tbif(:,:,1), jpi, jpj, npac(1:nbpac) )   
+         CALL tab_2d_1d_2( nbpac, tbif_1d   (1:nbpac , 2 ), tbif(:,:,2), jpi, jpj, npac(1:nbpac) )   
+         CALL tab_2d_1d_2( nbpac, tbif_1d   (1:nbpac , 3 ), tbif(:,:,3), jpi, jpj, npac(1:nbpac) )   
+         CALL tab_2d_1d_2( nbpac, qldif_1d  (1:nbpac)     , qldif      , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, qcmif_1d  (1:nbpac)     , qcmif      , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, qstbif_1d (1:nbpac)     , qstoif     , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, rdmicif_1d(1:nbpac)     , rdmicif    , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, dvlbq_1d  (1:nbpac)     , fdvolif    , jpi, jpj, npac(1:nbpac) )
+         CALL tab_2d_1d_2( nbpac, tfu_1d    (1:nbpac)     , tfu        , jpi, jpj, npac(1:nbpac) )
+        
+         !  call lateral accretion routine.
+         CALL lim_thd_lac_2( 1 , nbpac )
+         
+         !   back to the geographic grid
+         CALL tab_1d_2d_2( nbpac, frld       , npac(1:nbpac), frld_1d   (1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, hsnif      , npac(1:nbpac), h_snow_1d (1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, hicif      , npac(1:nbpac), h_ice_1d  (1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, tbif(:,:,1), npac(1:nbpac), tbif_1d   (1:nbpac , 1 ), jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, tbif(:,:,2), npac(1:nbpac), tbif_1d   (1:nbpac , 2 ), jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, tbif(:,:,3), npac(1:nbpac), tbif_1d   (1:nbpac , 3 ), jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, qstoif     , npac(1:nbpac), qstbif_1d (1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, rdmicif    , npac(1:nbpac), rdmicif_1d(1:nbpac)     , jpi, jpj )
+         CALL tab_1d_2d_2( nbpac, fdvolif    , npac(1:nbpac), dvlbq_1d  (1:nbpac)     , jpi, jpj )
+        
+      ENDIF
+       
+       
+      !      Recover frld values between 0 and 1 in the Southern Hemisphere (tricky trick)
+      !      Update daily thermodynamic ice production.    
+      !------------------------------------------------------------------------------
+       
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            frld  (ji,jj) = MIN( frld(ji,jj), ABS( frld(ji,jj) - 2.0 ) )
+            hicifp(ji,jj) =  hicif(ji,jj) * ( 1.0 - frld(ji,jj) ) - zhicifp(ji,jj) + hicifp(ji,jj)
+         END DO
+      END DO
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl_info(' lim_thd  end  ')
+         CALL prt_ctl(tab2d_1=hicif , clinfo1=' lim_thd: hicif   : ', tab2d_2=hsnif , clinfo2=' hsnif  : ')
+         CALL prt_ctl(tab2d_1=frld  , clinfo1=' lim_thd: frld    : ', tab2d_2=hicifp, clinfo2=' hicifp : ')
+         CALL prt_ctl(tab2d_1=phicif, clinfo1=' lim_thd: phicif  : ', tab2d_2=pfrld , clinfo2=' pfrld  : ')
+         CALL prt_ctl(tab2d_1=sist  , clinfo1=' lim_thd: sist    : ')
+         CALL prt_ctl(tab2d_1=tbif(:,:,1), clinfo1=' lim_thd: tbif 1  : ')
+         CALL prt_ctl(tab2d_1=tbif(:,:,2), clinfo1=' lim_thd: tbif 2  : ')
+         CALL prt_ctl(tab2d_1=tbif(:,:,3), clinfo1=' lim_thd: tbif 3  : ')
+         CALL prt_ctl(tab2d_1=fdtcn , clinfo1=' lim_thd: fdtcn   : ', tab2d_2=qdtcn , clinfo2=' qdtcn  : ')
+         CALL prt_ctl(tab2d_1=qstoif, clinfo1=' lim_thd: qstoif  : ', tab2d_2=fsbbq , clinfo2=' fsbbq  : ')
+      ENDIF
+
+    END SUBROUTINE lim_thd_2
+
+
+    SUBROUTINE lim_thd_init_2
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_thd_init_2 *** 
+      !!                 
+      !! ** Purpose :   Physical constants and parameters linked to the ice 
+      !!      thermodynamics
+      !!
+      !! ** Method  :   Read the namicethd namelist and check the ice-thermo
+      !!       parameter values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicether
+      !!
+      !! history :
+      !!  8.5  ! 03-08 (C. Ethe) original code
+      !!-------------------------------------------------------------------
+      NAMELIST/namicethd/ hmelt , hiccrit, hicmin, hiclim, amax  ,        &
+         &                swiqst, sbeta  , parlat, hakspl, hibspl, exld,  &
+         &                hakdif, hnzst  , thth  , parsub, alphs
+      !!-------------------------------------------------------------------
+      
+
+      ! Define the initial parameters
+      ! -------------------------
+      REWIND( numnam_ice )
+      READ  ( numnam_ice , namicethd )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*)'lim_thd_init_2: ice parameters for ice thermodynamic computation '
+         WRITE(numout,*)'~~~~~~~~~~~~~~'
+         WRITE(numout,*)'       maximum melting at the bottom                           hmelt        = ', hmelt
+         WRITE(numout,*)'       ice thick. for lateral accretion in NH (SH)             hiccrit(1/2) = ', hiccrit
+         WRITE(numout,*)'       ice thick. corr. to max. energy stored in brine pocket  hicmin       = ', hicmin  
+         WRITE(numout,*)'       minimum ice thickness                                   hiclim       = ', hiclim 
+         WRITE(numout,*)'       maximum lead fraction                                   amax         = ', amax 
+         WRITE(numout,*)'       energy stored in brine pocket (=1) or not (=0)	  swiqst       = ', swiqst 
+         WRITE(numout,*)'       numerical carac. of the scheme for diffusion in ice '
+         WRITE(numout,*)'       Cranck-Nicholson (=0.5), implicit (=1), explicit (=0)   sbeta        = ', sbeta
+         WRITE(numout,*)'       percentage of energy used for lateral ablation          parlat       = ', parlat
+         WRITE(numout,*)'       slope of distr. for Hakkinen-Mellor lateral melting     hakspl       = ', hakspl  
+         WRITE(numout,*)'       slope of distribution for Hibler lateral melting        hibspl       = ', hibspl
+         WRITE(numout,*)'       exponent for leads-closure rate                         exld         = ', exld
+         WRITE(numout,*)'       coefficient for diffusions of ice and snow              hakdif       = ', hakdif
+         WRITE(numout,*)'       threshold thick. for comp. of eq. thermal conductivity  zhth         = ', thth 
+         WRITE(numout,*)'       thickness of the surf. layer in temp. computation       hnzst        = ', hnzst
+         WRITE(numout,*)'       switch for snow sublimation  (=1) or not (=0)           parsub       = ', parsub  
+         WRITE(numout,*)'       coefficient for snow density when snow ice formation    alphs        = ', alphs
+      ENDIF
+            
+      uscomi = 1.0 / ( 1.0 - amax )   ! inverse of minimum lead fraction
+      rcdsn = hakdif * rcdsn 
+      rcdic = hakdif * rcdic
+      
+      IF ( ( hsndif > 100.e0 ) .OR. ( hicdif > 100.e0 ) ) THEN
+         cnscg = 0.e0
+      ELSE
+         cnscg = rcpsn / rcpic   ! ratio  rcpsn/rcpic
+      ENDIF
+ 
+   END SUBROUTINE lim_thd_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option          Dummy module       NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_thd_2         ! Dummy routine
+   END SUBROUTINE lim_thd_2
+#endif
+
+   !!======================================================================
+END MODULE limthd_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limthd_lac_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limthd_lac_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limthd_lac_2.F90	(revision 823)
@@ -0,0 +1,232 @@
+MODULE limthd_lac_2
+#if defined key_lim2
+   !!======================================================================
+   !!                       ***  MODULE limthd_lac_2   ***
+   !!                lateral thermodynamic growth of the ice 
+   !!======================================================================
+
+   !!----------------------------------------------------------------------
+   !!   lim_lat_acr_2    : lateral accretion of ice
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE phycst
+   USE ice_oce          ! ice variables
+   USE thd_ice_2
+   USE iceini_2
+   USE limistate_2 
+     
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_thd_lac_2   ! called by lim_thd_2
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1.e-20  ,  &
+      epsi13 = 1.e-13  ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+CONTAINS
+    
+   SUBROUTINE lim_thd_lac_2( kideb, kiut )
+      !!-------------------------------------------------------------------
+      !!               ***   ROUTINE lim_thd_lac_2  ***
+      !!  
+      !! ** Purpose : Computation of the evolution of the ice thickness and 
+      !!      concentration as a function of the heat balance in the leads.
+      !!      It is only used for lateral accretion
+      !!       
+      !! ** Method  : Ice is formed in the open water when ocean lose heat
+      !!      (heat budget of open water Bl is negative) .
+      !!      Computation of the increase of 1-A (ice concentration) fol-
+      !!      lowing the law :
+      !!      (dA/dt)acc = F[ (1-A)/(1-a) ] * [ Bl / (Li*h0) ]
+      !!       where - h0 is the thickness of ice created in the lead
+      !!             - a is a minimum fraction for leads
+      !!             - F is a monotonic non-increasing function defined as:
+      !!                  F(X)=( 1 - X**exld )**(1.0/exld)
+      !!             - exld is the exponent closure rate (=2 default val.)
+      !! 
+      !! ** Action : - Adjustment of snow and ice thicknesses and heat
+      !!                content in brine pockets
+      !!             - Updating ice internal temperature
+      !!             - Computation of variation of ice volume and mass
+      !!             - Computation of frldb after lateral accretion and 
+      !!               update h_snow_1d, h_ice_1d and tbif_1d(:,:)      
+      !! 
+      !! ** References :
+      !!      M. Maqueda, 1995, PhD Thesis, Univesidad Complutense Madrid
+      !!      Fichefet T. and M. Maqueda 1997, J. Geo. Res., 102(C6), 
+      !!                                                12609 -12646   
+      !! History :
+      !!   1.0  !  01-04 (LIM)  original code
+      !!   2.0  !  02-08 (C. Ethe, G. Madec)  F90, mpp
+      !!-------------------------------------------------------------------
+      !! * Arguments
+      INTEGER , INTENT(IN)::  &
+         kideb          ,   &  ! start point on which the the computation is applied
+         kiut                  ! end point on which the the computation is applied
+
+      !! * Local variables
+      INTEGER ::            &
+         ji             ,   &  !  dummy loop indices
+         iicefr         ,   &  !  1 = existing ice ; 0 = no ice
+         iiceform       ,   &  !  1 = ice formed   ; 0 = no ice formed
+         ihemis                !  dummy indice
+      REAL(wp), DIMENSION(jpij) :: &
+         zqbgow           ,  &  !  heat budget of the open water (negative)
+         zfrl_old         ,  &  !  previous sea/ice fraction
+         zhice_old        ,  &  !  previous ice thickness
+         zhice0           ,  &  !  thickness of newly formed ice in leads
+         zfrlmin          ,  &  !  minimum fraction for leads
+         zdhicbot               !  part of thickness of newly formed ice in leads which 
+                                !  has been already used in transport for example
+      REAL(wp)  ::  &
+         zhemis           ,  &  !  hemisphere (0 = North, 1 = South)
+         zhicenew         ,  &  !  new ice thickness
+         zholds2          ,  &  !  ratio of previous ice thickness and 2 
+         zhnews2          ,  &  !  ratio of new ice thickness and 2 
+         zfrlnew          ,  &  !  new sea/ice fraction
+         zfrld            ,  &  !  ratio of sea/ice fraction and minimum fraction for leads
+         zfrrate          ,  &  !  leads-closure rate
+         zdfrl                  !  sea-ice fraction increment
+      REAL(wp)  ::  &
+         zdh1 , zdh2 , zdh3 , zdh4, zdh5   , &   ! tempory scalars
+         ztint , zta1 , zta2 , zta3 , zta4 , &
+         zah, zalpha , zbeta
+      !!---------------------------------------------------------------------      
+                   
+      !--------------------------------------------------------------
+      !   Computation of the heat budget of the open water (negative)
+      !--------------------------------------------------------------
+      
+      DO ji = kideb , kiut      
+         zqbgow(ji) = qldif_1d(ji) - qcmif_1d(ji)
+      END DO
+      
+      !-----------------------------------------------------------------
+      !   Taking the appropriate values for the corresponding hemisphere
+      !-----------------------------------------------------------------
+      DO ji = kideb , kiut
+         zhemis       = MAX( zzero , SIGN( zone , frld_1d(ji) - 2.0 ) ) 
+         ihemis       = INT( 1 + zhemis )
+         zhice0  (ji) = hiccrit( ihemis ) 
+         zfrlmin (ji) = acrit  ( ihemis )   
+         frld_1d (ji) = frld_1d(ji) - 2.0 * zhemis
+         zfrl_old(ji) = frld_1d(ji)
+      END DO
+      
+      !-------------------------------------------------------------------
+      !     Lateral Accretion (modification of the fraction of open water)
+      !     The ice formed in the leads has always a thickness zhice0, but
+      !     only a fraction zfrrate of the ice formed contributes to the 
+      !     increase of the ice fraction. The remaining part (1-zfrrate)
+      !     is rather assumed to lead to an increase in the thickness of the
+      !     pre-existing ice (transport for example). 
+      !     Morales Maqueda, 1995 - Fichefet and Morales Maqueda, 1997
+      !---------------------------------------------------------------------
+      
+      !CDIR NOVERRCHK
+      DO ji = kideb , kiut
+         iicefr       = 1 - MAX( 0, INT( SIGN( 1.5 * zone , zfrl_old(ji) - 1.0 + epsi13 ) ) )
+         !---computation of the leads-closure rate
+         zfrld        = MIN( zone , ( 1.0 - frld_1d(ji) ) / ( 1.0 - zfrlmin(ji) ) )
+         zfrrate      = ( 1.0 - zfrld**exld )**( 1.0 / exld )
+         !--computation of the sea-ice fraction increment and the new fraction 
+         zdfrl        = ( zfrrate / zhice0(ji) )  * ( zqbgow(ji) / xlic )
+         zfrlnew      = zfrl_old(ji) + zdfrl
+         !--update the sea-ice fraction 
+         frld_1d   (ji) = MAX( zfrlnew , zfrlmin(ji) )
+         !--computation of the remaining part of ice thickness which has been already used
+         zdhicbot(ji) =  ( frld_1d(ji) - zfrlnew ) * zhice0(ji) / ( 1.0 - zfrlmin(ji) ) & 
+                      -  (  ( 1.0 - zfrrate ) / ( 1.0 - frld_1d(ji) ) )  * ( zqbgow(ji) / xlic ) 
+      END DO
+ 
+      !----------------------------------------------------------------------------------------
+      !      Ajustement of snow and ice thicknesses and updating the total heat stored in brine pockets  
+      !      The thickness of newly formed ice is averaged with that of the pre-existing
+      !         (1-Anew) * hinew = (1-Aold) * hiold + ((1-Anew)-(1-Aold)) * h0
+      !      Snow is distributed over the new ice-covered area 
+      !         (1-Anew) * hsnew = (1-Aold) * hsold            
+      !--------------------------------------------------------------------------------------------
+      
+      DO ji = kideb , kiut
+         iicefr       = 1 - MAX( 0, INT( SIGN( 1.5 * zone , zfrl_old(ji) - 1.0 + epsi13 ) ) )
+         zhice_old(ji) = h_ice_1d(ji)
+         zhicenew      = iicefr * zhice_old(ji) + ( 1 - iicefr ) * zhice0(ji)
+         zalpha        = ( 1. - zfrl_old(ji) ) / ( 1.- frld_1d(ji) )
+         h_snow_1d(ji) = zalpha * h_snow_1d(ji)
+         h_ice_1d (ji) = zalpha * zhicenew + ( 1.0 - zalpha ) * zhice0(ji)
+         qstbif_1d(ji) = zalpha * qstbif_1d(ji) 
+      END DO
+      
+      !-------------------------------------------------------
+      !   Ajustement of ice internal temperatures
+      !-------------------------------------------------------
+      
+      DO ji = kideb , kiut
+         iicefr      = 1 - MAX( 0, INT( SIGN( 1.5 * zone , zfrl_old(ji) - 1.0 + epsi13 ) ) )
+         iiceform    = 1 - MAX( 0 ,INT( SIGN( 1.5 * zone , zhice0(ji) - h_ice_1d(ji) ) ) )
+         zholds2     = zhice_old(ji)/ 2.
+         zhnews2     = h_ice_1d(ji) / 2.
+         zdh1        = MAX( zzero ,  zhice_old(ji)   - zhnews2 )
+         zdh2        = MAX( zzero , -zhice_old(ji)   + zhnews2 )
+         zdh3        = MAX( zzero ,  h_ice_1d(ji) - zholds2 )
+         zdh4        = MAX( zzero , -h_ice_1d(ji) + zholds2 )
+         zdh5        = MAX( zzero , zhice0(ji)      - zholds2 )
+         ztint       =       iiceform   * (  ( zholds2 - zdh3 ) * tbif_1d(ji,3) + zdh4 * tbif_1d(ji,2) )      &
+            &                           / MAX( epsi20 , h_ice_1d(ji) - zhice0(ji) )                           &
+            &                 + ( 1 - iiceform ) * tfu_1d(ji)
+         zta1        = iicefr * ( 1.  - zfrl_old(ji) ) * tbif_1d(ji,2) 
+         zta2        = iicefr * ( 1.  - zfrl_old(ji) ) * tbif_1d(ji,3)
+         zta3        = iicefr * ( 1.  - zfrl_old(ji) ) * ztint
+         zta4        = ( zfrl_old(ji) - frld_1d   (ji) ) * tfu_1d(ji)
+         zah         = ( 1. - frld_1d(ji) ) * zhnews2 
+
+         tbif_1d(ji,2) = (  MIN( zhnews2 , zholds2 )                                              * zta1   &
+            &          + ( 1 - iiceform ) * ( zholds2 - zdh1 )                                    * zta2   &
+            &          + ( iiceform * ( zhnews2 - zhice0(ji) + zdh5 ) + ( 1 - iiceform ) * zdh2 ) * zta3   & 
+            &          + MIN ( zhnews2 , zhice0(ji) )                                             * zta4   &
+            &          ) / zah
+         
+         tbif_1d(ji,3) =     (  iiceform * ( zhnews2 - zdh3 )                                          * zta1  &
+            &              + ( iiceform * zdh3 + ( 1 - iiceform ) * zdh1 )                             * zta2  &
+            &              + ( iiceform * ( zhnews2 - zdh5 ) + ( 1 - iiceform ) * ( zhnews2 - zdh1 ) ) * zta3  & 
+            &              + ( iiceform * zdh5 + ( 1 - iiceform ) * zhnews2 )                          * zta4  &
+            &            ) / zah
+         !---removing the remaining part of ice formed which has been already used
+         zbeta         = h_ice_1d(ji) / ( h_ice_1d(ji) + zdhicbot(ji) )
+         h_ice_1d(ji)  = h_ice_1d(ji) + zdhicbot(ji)
+         tbif_1d (ji,2)= zbeta * tbif_1d(ji,2) + ( 1.0 - zbeta ) * tbif_1d(ji,3)
+         tbif_1d (ji,3)= ( 2. * zbeta - 1.0 ) * tbif_1d(ji,3) + ( 2. * zdhicbot(ji) / h_ice_1d(ji) ) * tfu_1d(ji)
+         
+      END DO
+      
+      !-------------------------------------------------------------
+      !    Computation of variation of ice volume and ice mass 
+      !           Vold = (1-Aold) * hiold ; Vnew = (1-Anew) * hinew
+      !           dV = Vnew - Vold
+      !-------------------------------------------------------------
+      
+      DO ji = kideb , kiut
+         dvlbq_1d  (ji) = ( 1. - frld_1d(ji) ) * h_ice_1d(ji) - ( 1. - zfrl_old(ji) ) * zhice_old(ji)
+         rdmicif_1d(ji) = rdmicif_1d(ji) + rhoic * dvlbq_1d(ji)
+      END DO
+      
+   END SUBROUTINE lim_thd_lac_2
+#else
+   !!======================================================================
+   !!                       ***  MODULE limthd_lac_2   ***
+   !!                           no sea ice model
+   !!======================================================================
+CONTAINS
+   SUBROUTINE lim_thd_lac_2           ! Empty routine
+   END SUBROUTINE lim_thd_lac_2
+#endif
+END MODULE limthd_lac_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limthd_zdf_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limthd_zdf_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limthd_zdf_2.F90	(revision 823)
@@ -0,0 +1,814 @@
+MODULE limthd_zdf_2
+   !!======================================================================
+   !!                       ***  MODULE limthd_zdf_2 ***
+   !!                thermodynamic growth and decay of the ice 
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'                                    LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_thd_zdf_2 : vertical accr./abl. and lateral ablation of sea ice
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce          ! ocean parameters
+   USE phycst           ! ???
+   USE ice_oce          ! ice variables
+   USE thd_ice_2
+   USE iceini_2
+   USE limistate_2
+   USE in_out_manager
+      
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_thd_zdf_2      ! called by lim_thd_2
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi20 = 1.e-20  ,  &
+      epsi13 = 1.e-13  ,  &
+      zzero  = 0.e0    ,  &
+      zone   = 1.e0
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE lim_thd_zdf_2( kideb , kiut )
+      !!------------------------------------------------------------------
+      !!                ***  ROUTINE lim_thd_zdf_2  ***
+      !!              
+      !! ** Purpose : This routine determines the time evolution of snow 
+      !!      and sea-ice thicknesses, concentration and heat content 
+      !!      due to the vertical and lateral thermodynamic accretion-
+      !!      ablation processes. One only treats the case of lat. abl.
+      !!      For lateral accretion, see routine lim_lat_accr 
+      !! 
+      !! ** Method  : The representation of vertical growth and decay of 
+      !!      the sea-ice model is based upon the diffusion of heat 
+      !!      through the external and internal boundaries of a 
+      !!      three-layer system (two layers of ice and one layer and 
+      !!      one layer of snow, if present, on top of the ice).
+      !! 
+      !! ** Action  : - Calculation of some intermediates variables
+      !!              - Calculation of surface temperature
+      !!              - Calculation of available heat for surface ablation
+      !!              - Calculation of the changes in internal temperature 
+      !!                of the three-layer system, due to vertical diffusion 
+      !!                processes
+      !!              - Performs surface ablation and bottom accretion-ablation
+      !!              - Performs snow-ice formation
+      !!              - Performs lateral ablation
+      !!
+      !! References :
+      !!   Fichefet T. and M. Maqueda 1997, J. Geophys. Res., 102(C6), 12609-12646   
+      !!   Fichefet T. and M. Maqueda 1999, Clim. Dyn, 15(4), 251-268  
+      !!
+      !! History :
+      !!   original    : 01-04 (LIM)
+      !!   addition    : 02-08 (C. Ethe, G. Madec)
+      !!------------------------------------------------------------------
+      !! * Arguments
+      INTEGER , INTENT (in) ::  &
+         kideb ,  &  ! Start point on which the  the computation is applied
+         kiut        ! End point on which the  the computation is applied
+
+      !! * Local variables
+      INTEGER ::   ji       ! dummy loop indices
+
+      REAL(wp) , DIMENSION(jpij,2) ::  &
+         zqcmlt        ! energy due to surface( /1 ) and bottom melting( /2 )
+
+      REAL(wp), DIMENSION(jpij) ::  &
+         ztsmlt      &    ! snow/ice surface melting temperature
+         ,ztbif      &    ! int. temp. at the mid-point of the 1st layer of the snow/ice sys. 
+         ,zksn       &    ! effective conductivity of snow
+         ,zkic       &    ! effective conductivity of ice
+         ,zksndh     &    ! thermal cond. at the mid-point of the 1st layer of the snow/ice sys. 
+         , zfcsu     &    ! conductive heat flux at the surface of the snow/ice system 
+         , zfcsudt   &    ! = zfcsu * dt
+         , zi0       &    ! frac. of the net SW rad. which is not absorbed at the surface
+         , z1mi0     &    ! fraction of the net SW radiation absorbed at the surface
+         , zqmax     &    ! maximum energy stored in brine pockets
+         , zrcpdt    &    ! h_su*rho_su*cp_su/dt(h_su being the thick. of surf. layer)
+         , zts_old   &    ! previous surface temperature
+         , zidsn , z1midsn , zidsnic ! tempory variables
+
+      REAL(wp), DIMENSION(jpij) :: &
+          zfnet       &  ! net heat flux at the top surface( incl. conductive heat flux)
+          , zsprecip  &    ! snow accumulation
+          , zhsnw_old &    ! previous snow thickness
+          , zdhictop  &    ! change in ice thickness due to top surf ablation/accretion
+          , zdhicbot  &    ! change in ice thickness due to bottom surf abl/acc
+          , zqsup     &    ! energy transmitted to ocean (coming from top surf abl/acc)
+          , zqocea    &    ! energy transmitted to ocean (coming from bottom sur abl/acc)
+          , zfrl_old  &    ! previous sea/ice fraction
+          , zfrld_1d    &    ! new sea/ice fraction
+          , zep            ! internal temperature of the 2nd layer of the snow/ice system
+
+       REAL(wp), DIMENSION(3) :: & 
+          zplediag  &    ! principle diagonal, subdiag. and supdiag. of the 
+          , zsubdiag  &    ! tri-diagonal matrix coming from the computation
+          , zsupdiag  &    ! of the temperatures inside the snow-ice system
+          , zsmbr          ! second member
+
+       REAL(wp) :: & 
+          zhsu     &     ! thickness of surface layer
+          , zhe      &     ! effective thickness for compu. of equ. thermal conductivity
+          , zheshth  &     ! = zhe / thth
+          , zghe     &     ! correction factor of the thermal conductivity
+          , zumsb    &     ! parameter for numerical method to solve heat-diffusion eq.
+          , zkhsn    &     ! conductivity at the snow layer
+          , zkhic    &     ! conductivity at the ice layers
+          , zkint    &     ! equivalent conductivity at the snow-ice interface
+          , zkhsnint &     ! = zkint*dt / (hsn*rhosn*cpsn)  
+          , zkhicint &     ! = 2*zkint*dt / (hic*rhoic*cpic)
+          , zpiv1 , zpiv2  &       ! tempory scalars used to solve the tri-diagonal system
+          , zb2 , zd2 , zb3 , zd3 &
+          , ztint          ! equivalent temperature at the snow-ice interface
+
+       REAL(wp) :: & 
+          zexp      &     ! exponential function of the ice thickness
+          , zfsab     &     ! part of solar radiation stored in brine pockets
+          , zfts      &     ! value of energy balance function when the temp. equal surf. temp.
+          , zdfts     &     ! value of derivative of ztfs when the temp. equal surf. temp.
+          , zdts      &     ! surface temperature increment
+          , zqsnw_mlt &     ! energy needed to melt snow
+          , zdhsmlt   &     ! change in snow thickness due to melt
+          , zhsn      &     ! snow thickness (previous+accumulation-melt)
+          , zqsn_mlt_rem &  ! remaining heat coming from snow melting
+          , zqice_top_mlt & ! energy used to melt ice at top surface
+          , zdhssub      &  ! change in snow thick. due to sublimation or evaporation
+          , zdhisub      &  ! change in ice thick. due to sublimation or evaporation    
+          , zdhsn        &  ! snow ice thickness increment
+          , zdtsn        &  ! snow internal temp. increment
+          , zdtic        &  ! ice internal temp. increment
+          , zqnes          ! conductive energy due to ice melting in the first ice layer
+
+       REAL(wp) :: & 
+          ztbot     &      ! temperature at the bottom surface
+          , zfcbot    &      ! conductive heat flux at bottom surface
+          , zqice_bot &      ! energy used for bottom melting/growing
+          , zqice_bot_mlt &  ! energy used for bottom melting
+          , zqstbif_bot  &  ! part of energy stored in brine pockets used for bottom melting
+          , zqstbif_old  &  ! tempory var. for zqstbif_bot
+          , zdhicmlt      &  ! change in ice thickness due to bottom melting
+          , zdhicm        &  ! change in ice thickness var. 
+          , zdhsnm        &  ! change in snow thickness var. 
+          , zhsnfi        &  ! snow thickness var. 
+          , zc1, zpc1, zc2, zpc2, zp1, zp2 & ! tempory variables
+          , ztb2, ztb3
+
+       REAL(wp) :: & 
+          zdrmh         &   ! change in snow/ice thick. after snow-ice formation
+          , zhicnew       &   ! new ice thickness
+          , zhsnnew       &   ! new snow thickness
+          , zquot , ztneq &   ! tempory temp. variables
+          , zqice, zqicetot & ! total heat inside the snow/ice system
+          , zdfrl         &   ! change in ice concentration
+          , zdvsnvol      &   ! change in snow volume
+          , zdrfrl1, zdrfrl2 &  ! tempory scalars
+          , zihsn, zidhb, zihic, zihe, zihq, ziexp, ziqf, zihnf, zibmlt, ziqr, zihgnew, zind
+       !!----------------------------------------------------------------------
+
+       !-----------------------------------------------------------------------
+       !  1. Boundaries conditions for snow/ice system internal temperature
+       !       - If tbif_1d(ji,1) > rt0_snow, tbif_1d(ji,1) = rt0_snow 
+       !       - If tbif_1d(ji,2/3) > rt0_ice, tbif_1d(ji,2/3) = rt0_ice 
+       !     Computation of energies due to surface and bottom melting 
+       !-----------------------------------------------------------------------
+       
+       
+       DO ji = kideb , kiut
+          zihsn = MAX( zzero , SIGN( zone , hsndif - h_snow_1d(ji) ) )
+          zihic = MAX( zzero , SIGN( zone , hicdif - h_ice_1d(ji) ) )
+          !--computation of energy due to surface melting
+          zqcmlt(ji,1) = ( MAX ( zzero ,  &
+             &                   rcpsn * h_snow_1d(ji) * ( tbif_1d(ji,1) - rt0_snow ) ) ) * ( 1.0 - zihsn )
+          !--computation of energy due to bottom melting
+          zqcmlt(ji,2) = ( MAX( zzero , &
+             &                  rcpic * ( tbif_1d(ji,2) - rt0_ice ) * ( h_ice_1d(ji) / 2. ) ) &
+             &           + MAX( zzero , &
+             &                  rcpic * ( tbif_1d(ji,3) - rt0_ice ) * ( h_ice_1d(ji) / 2. ) ) &
+             &           ) * ( 1.0 - zihic  )
+          !--limitation of  snow/ice system internal temperature
+          tbif_1d(ji,1)   = MIN( rt0_snow, tbif_1d(ji,1) )
+          tbif_1d(ji,2)   = MIN( rt0_ice , tbif_1d(ji,2) )
+          tbif_1d(ji,3)   = MIN( rt0_ice , tbif_1d(ji,3) )
+       END DO
+
+
+       !-------------------------------------------
+       !  2. Calculate some intermediate variables.  
+       !-------------------------------------------
+       
+       ! initialisation of the thickness of surface layer
+       zhsu = hnzst  
+
+       DO ji = kideb , kiut
+          zind   = MAX( zzero , SIGN( zone , zhsu - h_snow_1d(ji) ) )
+          zihsn  = MAX( zzero , SIGN( zone , hsndif - h_snow_1d(ji) ) )
+          zihsn  = MAX( zihsn , zind )
+          zihic  = MAX( zzero , sign( zone , hicdif - h_ice_1d(ji) ) )
+          !     2.1. Computation of surface melting temperature
+          !----------------------------------------------------
+          zind  = MAX( zzero , SIGN( zone , -h_snow_1d(ji) ) )
+          ztsmlt(ji) = ( 1.0 - zind ) * rt0_snow + zind * rt0_ice
+          !
+          !     2.2. Effective conductivity of snow and ice
+          !-----------------------------------------------
+
+          !---computation of the correction factor on the thermal conductivity
+          !-- (Morales Maqueda, 1995 ; Fichefet and Morales Maqueda, 1997)
+          zhe      =  ( rcdsn / ( rcdsn + rcdic ) ) * h_ice_1d(ji)   &
+             &     + ( rcdic / ( rcdsn + rcdic ) ) * h_snow_1d(ji) 
+          zihe     = MAX( zzero , SIGN( zone , 2.0 * zhe - thth ) )
+          zheshth  = zhe / thth
+          zghe     = ( 1.0 - zihe ) * zheshth * ( 2.0 - zheshth )   &
+             &     +         zihe   * 0.5 * ( 1.5 + LOG( 2.0 * zheshth ) )
+#if defined key_lim_cp3
+          zghe = 1.0
+#endif 
+
+          !---effective conductivities 
+          zksn(ji)  = zghe * rcdsn  
+          zkic(ji)  = zghe * rcdic
+
+          !
+          !     2.3. Computation of the conductive heat flux from the snow/ice 
+          !          system interior toward the top surface
+          !------------------------------------------------------------------
+
+          !---Thermal conductivity at the mid-point of the first snow/ice system layer
+          zksndh(ji) =   ( ( 1.0 - zihsn ) * 2.0 * zksn(ji) + zihsn * 4.0 * zkic(ji) )   &
+             &         / ( ( 1.0 - zihsn ) *  h_snow_1d(ji)                              &
+             &           +        zihsn   *  ( ( 1.0 + 3.0 * zihic ) * h_ice_1d(ji)      &
+             &           + 4.0 * zkic(ji)/zksn(ji) * h_snow_1d(ji) ) )
+
+          !---internal temperature at the mid-point of the first snow/ice system layer
+          ztbif(ji)  = ( 1.0 - zihsn ) * tbif_1d(ji,1)                       &
+             &       +         zihsn   * ( ( 1.0 - zihic ) * tbif_1d(ji,2)   &
+             &       +         zihic   * tfu_1d(ji)   )
+          !---conductive heat flux 
+          zfcsu(ji) = zksndh(ji) * ( ztbif(ji) - sist_1d(ji) )
+
+       END DO
+
+       !--------------------------------------------------------------------
+       !  3. Calculate : 
+       !     - fstbif_1d, part of solar radiation absorbing inside the ice
+       !       assuming an exponential absorption (Grenfell and Maykut, 1977)
+       !     - zqmax,  maximum energy stored in brine pockets
+       !     - qstbif_1d, total energy stored in brine pockets (updating)
+       !-------------------------------------------------------------------
+
+
+       DO ji = kideb , kiut
+          zihsn  = MAX( zzero , SIGN (zone , -h_snow_1d(ji) ) )
+          zihic  = MAX( zzero , 1.0 - ( h_ice_1d(ji) / zhsu ) )     
+          zind   = MAX( zzero , SIGN (zone , hicdif - h_ice_1d(ji) ) )
+          !--Computation of the fraction of the net shortwave radiation which
+          !--penetrates inside the ice cover ( See Forcat)
+          zi0(ji)  = zihsn * ( fr1_i0_1d(ji) + zihic * fr2_i0_1d(ji) )
+          zexp     = MIN( zone , EXP( -1.5 * ( h_ice_1d(ji) - zhsu ) ) )
+          fstbif_1d(ji) = zi0(ji) * qsr_ice_1d(ji) * zexp
+          !--Computation of maximum energy stored in brine pockets zqmax and update
+          !--the total energy stored in brine pockets, if less than zqmax
+          zqmax(ji) = MAX( zzero , 0.5 * xlic * ( h_ice_1d(ji) - hicmin ) )
+          zfsab   = zi0(ji) * qsr_ice_1d(ji) * ( 1.0 - zexp )
+          zihq    = ( 1.0 - zind ) * MAX(zzero, SIGN( zone , qstbif_1d(ji) - zqmax(ji) ) ) &
+             &    +         zind   * zone
+          qstbif_1d(ji) = ( qstbif_1d(ji) + ( 1.0 - zihq ) * zfsab * rdt_ice ) * swiqst
+          !--fraction of shortwave radiation absorbed at surface
+          ziexp = zihq * zexp + ( 1.0 - zihq ) * ( swiqst + ( 1.0 - swiqst ) * zexp )
+          z1mi0(ji) = 1.0 - zi0(ji) * ziexp
+       END DO
+
+
+       !--------------------------------------------------------------------------------
+       !  4. Computation of the surface temperature : determined by considering the 
+       !     budget of a thin layer of thick. zhsu at the top surface (H. Grenier, 1995) 
+       !     and based on a surface energy balance : 
+       !     hsu * rcp * dT/dt = Fsr + Fnsr(T) + Fcs(T),
+       !     where - Fsr is the net absorbed solar radiation, 
+       !           - Fnsr is the total non solar radiation (incoming and outgoing long-wave,
+       !             sensible and latent heat fluxes)
+       !           - Fcs the conductive heat flux at the top of surface
+       !------------------------------------------------------------------------------
+
+       !     4.1. Computation of intermediate values
+       !---------------------------------------------
+       DO ji = kideb, kiut
+          zrcpdt(ji) = ( rcpsn * MIN( h_snow_1d(ji) , zhsu )    &
+             &       + rcpic * MAX( zhsu - h_snow_1d(ji) , zzero ) ) / rdt_ice
+          zts_old(ji) =  sist_1d(ji)
+       END DO
+
+       !     4.2. Computation of surface temperature by expanding the eq. of energy balance
+       !          with Ts = Tp + DT. One obtain , F(Tp) + DT * DF(Tp) = 0
+       !          where  - F(Tp) = Fsr + Fnsr(Tp) + Fcs(Tp) 
+       !                 - DF(Tp)= (dFnsr(Tp)/dT) + (dFcs(Tp)/dT) - hsu*rcp/dt
+       !---------------------------------------------------------------------------------
+
+       DO ji = kideb, kiut
+          !---computation of the derivative of energy balance function 
+#if defined key_coupled
+#   if defined key_lim_cp2
+          zdfts   =   zksndh(ji)   & ! contribution of the conductive heat flux
+             &      + zrcpdt(ji)   & ! contribution of hsu * rcp / dt
+             &      - dqns_ice_1d(ji)      ! contribution of the total non solar radiation 
+#   else
+          zdfts   =   zksndh(ji)   & ! contribution of the conductive heat flux
+             &      + zrcpdt(ji)    ! contribution of hsu * rcp / dt
+#   endif
+
+#else
+          zdfts    =  zksndh(ji)   & ! contribution of the conductive heat flux
+             &      + zrcpdt(ji)   & ! contribution of hsu * rcp / dt
+             &      - dqns_ice_1d (ji)     ! contribution of the total non solar radiation 
+#endif
+          !---computation of the energy balance function 
+          zfts    = - z1mi0 (ji) * qsr_ice_1d(ji)   & ! net absorbed solar radiation
+             &      - qnsr_ice_1d(ji)                & ! total non solar radiation
+             &      - zfcsu (ji)                  ! conductive heat flux from the surface
+          !---computation of surface temperature increment  
+          zdts    = -zfts / zdfts
+#if defined key_lim_cp3
+          zdts = zdts / 3.0
+#endif
+          !---computation of the new surface temperature 
+          sist_1d(ji) = sist_1d(ji) + zdts
+
+       END DO
+
+       !----------------------------------------------------------------------------
+       !  5. Boundary condition at the top surface
+       !--    IF Tsb < Tmelt, Fnet = Fcs (the net heat flux equal the conductive heat flux)
+       !      Otherwise Tsb = Tmelt and Qnet(Tmelt) > 0 
+       !      Fnet(Tmelt) is therefore the net surface flux needed for melting
+       !----------------------------------------------------------------------------
+       
+       
+       !     5.1.  Limitation of surface temperature and update total non solar fluxes,
+       !          latent heat flux and conductive flux at the top surface 
+       !----------------------------------------------------------------------  
+                     
+       DO ji = kideb, kiut
+          sist_1d(ji) = MIN( ztsmlt(ji) , sist_1d(ji) )
+#if ! defined key_coupled
+          qnsr_ice_1d(ji) = qnsr_ice_1d(ji) + dqns_ice_1d(ji) * ( sist_1d(ji) - zts_old(ji) )
+          qla_ice_1d (ji) = qla_ice_1d (ji) + dqla_ice_1d(ji) * ( sist_1d(ji) - zts_old(ji) )
+#endif
+          zfcsu(ji)  = zksndh(ji) * ( ztbif(ji) - sist_1d(ji) )
+       END DO
+
+     
+
+       !     5.2. Calculate available heat for surface ablation. 
+       !---------------------------------------------------------------------
+
+       DO ji = kideb, kiut
+          zfnet(ji) = qnsr_ice_1d(ji) + z1mi0(ji) * qsr_ice_1d(ji) + zfcsu(ji)          
+          zfnet(ji) = MAX( zzero , zfnet(ji) )
+          zfnet(ji) = zfnet(ji) * MAX( zzero , SIGN( zone , sist_1d(ji) - ztsmlt(ji) ) )
+       END DO
+
+       !-------------------------------------------------------------------------
+       !  6. Calculate changes in internal temperature due to vertical diffusion   
+       !     processes. The evolution of this temperature is governed by the one-
+       !     dimensionnal heat-diffusion equation. 
+       !     Given the temperature tbif(1/2/3), at time m we solve a set
+       !     of finite difference equations to obtain new tempe. Each tempe is coupled
+       !     to the temp. immediatly above and below by heat conduction terms. Thus 
+       !     we have a set of equations of the form A * T = B, where A is a tridiagonal
+       !     matrix, T a vector whose components are the unknown new temp.
+       !-------------------------------------------------------------------------
+       
+       !--parameter for the numerical methode use to solve the heat-diffusion equation
+       !- implicit, explicit or Crank-Nicholson
+       zumsb = 1.0 - sbeta  
+       DO ji = kideb, kiut
+          zidsn(ji)   = MAX ( zzero, SIGN( zone, hsndif - h_snow_1d(ji) ) ) 
+          z1midsn(ji) = 1.0 - zidsn(ji)
+          zihic       = MAX ( zzero, SIGN( zone, hicdif - h_ice_1d(ji) ) ) 
+          zidsnic(ji) = zidsn(ji) *  zihic 
+          zfcsudt(ji) = zfcsu(ji) * rdt_ice 
+       END DO 
+   
+       DO ji = kideb, kiut
+
+          !     6.1 Calculate intermediate variables.
+          !----------------------------------------
+
+          !--conductivity at the snow surface
+          zkhsn = 2.0 * zksn(ji) * rdt_ice / rcpsn
+          !--conductivity at the ice surface
+          zkhic = 4.0 * zkic(ji) * rdt_ice / MAX( h_ice_1d(ji) * h_ice_1d(ji) * rcpic , epsi20 )
+          !--conductivity at the snow/ice interface 
+          zkint = 4.0 * zksn(ji) * zkic(ji)  &
+             &        / ( zksn(ji) * h_ice_1d(ji) + 2.0 * zkic(ji) * h_snow_1d(ji) * z1midsn(ji)) 
+          zkhsnint = zkint * rdt_ice / rcpsn
+          zkhicint = zkint * 2.0 * rdt_ice / MAX( h_ice_1d(ji) * rcpic , epsi20 )
+          
+          !     6.2. Fulfill the linear system matrix.
+          !-----------------------------------------
+!$$$          zplediag(1) = 1 + sbeta * z1midsn(ji) * ( zkhsn + zkhsnint )       
+          zplediag(1) =   zidsn(ji) + z1midsn(ji) * h_snow_1d(ji)   &
+             &          + sbeta * z1midsn(ji) * zkhsnint 
+          zplediag(2) = 1 + sbeta * ( z1midsn(ji) * zkhicint + zkhic ) 
+          zplediag(3) = 1 + 3.0 * sbeta * zkhic   
+
+          zsubdiag(1) =  0.e0              
+          zsubdiag(2) = -1.e0 * z1midsn(ji) * sbeta * zkhicint
+          zsubdiag(3) = -1.e0 * sbeta * zkhic 
+
+          zsupdiag(1) = -1.e0 * z1midsn(ji) * sbeta * zkhsnint 
+          zsupdiag(2) = zsubdiag(3)
+          zsupdiag(3) =  0.e0
+          
+          !     6.3. Fulfill the idependent term vector.
+          !-------------------------------------------
+          
+!$$$          zsmbr(1) = zidsn(ji) * sist_1d(ji) + z1midsn(ji) *   &
+!$$$             &         ( tbif_1d(ji,1) + zkhsn * sist_1d(ji)
+!$$$             &         - zumsb * ( zkhsn * tbif_1d(ji,1)
+!$$$             &                   + zkhsnint * ( tbif_1d(ji,1) - tbif_1d(ji,2) ) ) )
+          zsmbr(1) = zidsn(ji) * sist_1d(ji) + z1midsn(ji) *    &
+             &       ( h_snow_1d(ji) * tbif_1d(ji,1) - ( zfcsudt(ji) / rcpsn )  &
+             &       - zumsb * zkhsnint * ( tbif_1d(ji,1) - tbif_1d(ji,2) ) )
+
+          zsmbr(2) =  tbif_1d(ji,2)  &
+             &      - zidsn(ji) * ( 1.0 - zidsnic(ji) ) &
+             &        * ( zfcsudt(ji) / MAX( h_ice_1d(ji) * rcpic , epsi20 ) ) &
+             &      + zumsb * ( zkhicint * ( tbif_1d(ji,1) - tbif_1d(ji,2) ) &
+             &                   - zkhic * ( tbif_1d(ji,2) - tbif_1d(ji,3) )  )
+
+          zsmbr(3) =  tbif_1d(ji,3)  &
+             &      + zkhic * ( 2.0 * tfu_1d(ji) &
+             &                + zumsb * ( tbif_1d(ji,2) - 3.0 * tbif_1d(ji,3) ) )
+          
+          !     6.4. Solve the system (Gauss elimination method).
+          !----------------------------------------------------
+          
+          zpiv1 = zsubdiag(2) / zplediag(1) 
+          zb2   = zplediag(2) - zpiv1 * zsupdiag(1)
+          zd2   = zsmbr(2) - zpiv1 * zsmbr(1)
+
+          zpiv2 = zsubdiag(3) / zb2
+          zb3   = zplediag(3) - zpiv2 * zsupdiag(2)
+          zd3   = zsmbr(3) - zpiv2 * zd2
+
+          tbif_1d(ji,3) = zd3 / zb3
+          tbif_1d(ji,2) = ( zd2 - zsupdiag(2) * tbif_1d(ji,3) ) / zb2
+          tbif_1d(ji,1) = ( zsmbr(1) - zsupdiag(1) * tbif_1d(ji,2) ) / zplediag(1)            
+
+          !--- taking into account the particular case of  zidsnic(ji) = 1
+          ztint =  (  zkic(ji) * h_snow_1d(ji) * tfu_1d (ji)    &
+             &      + zksn(ji) * h_ice_1d(ji) * sist_1d(ji) )   &
+             &   / ( zkic(ji) * h_snow_1d(ji) + zksn(ji) * h_ice_1d(ji) ) 
+
+          tbif_1d(ji,1) = ( 1.0 - zidsnic(ji) ) * tbif_1d(ji,1)   &
+             &                + zidsnic(ji)   * ( ztint + sist_1d(ji) ) / 2.0
+          tbif_1d(ji,2) = ( 1.0 - zidsnic(ji) ) * tbif_1d(ji,2)   &
+             &                + zidsnic(ji)   * ( 3.0 * ztint + tfu_1d(ji) ) / 4.0
+          tbif_1d(ji,3) = ( 1.0 - zidsnic(ji) ) * tbif_1d(ji,3)   &
+             &                + zidsnic(ji)   * ( ztint + 3.0 * tfu_1d(ji) ) / 4.0     
+       END DO
+ 
+       !----------------------------------------------------------------------
+       !  9. Take into account surface ablation and bottom accretion-ablation.|
+       !----------------------------------------------------------------------
+       
+       !---Snow accumulation in one thermodynamic time step
+       zsprecip(kideb:kiut) = sprecip_1d(kideb:kiut) * rdt_ice / rhosn
+
+
+       DO ji = kideb, kiut
+          
+          !      9.1. Surface ablation and update of snow thickness and qstbif_1d
+          !--------------------------------------------------------------------
+          
+          !--------------------------------------------------------------------------
+          !--      Melting snow processes :
+          !--      Melt at the upper surface is computed from the difference between 
+          !--      the net heat flux (including the conductive heat flux) at the upper 
+          !--      surface and the pre-existing energy due to surface melting
+          !------------------------------------------------------------------------------
+          
+          !-- store the snow thickness
+          zhsnw_old(ji) =  h_snow_1d(ji)
+          !--computation of the energy needed to melt snow
+          zqsnw_mlt  = zfnet(ji) * rdt_ice - zqcmlt(ji,1)
+          !--change in snow thickness due to melt
+          zdhsmlt = - zqsnw_mlt / xlsn
+          
+          !-- compute new snow thickness, taking into account the part of snow accumulation
+          !   (as snow precipitation) and the part of snow lost due to melt
+          zhsn =  h_snow_1d(ji) + zsprecip(ji) + zdhsmlt
+          h_snow_1d(ji) = MAX( zzero , zhsn )
+          !-- compute the volume of snow lost after surface melting and the associated mass
+          dvsbq_1d(ji) =  ( 1.0 - frld_1d(ji) ) * ( h_snow_1d(ji) - zhsnw_old(ji) - zsprecip(ji) )
+          dvsbq_1d(ji) =  MIN( zzero , dvsbq_1d(ji) )
+          rdmsnif_1d(ji) =  rhosn * dvsbq_1d(ji)
+          !-- If the snow is completely melted the remaining heat is used to melt ice
+          zqsn_mlt_rem  = MAX( zzero , -zhsn ) * xlsn
+          zqice_top_mlt = zqsn_mlt_rem 
+          zqstbif_old   = qstbif_1d(ji)
+
+          !--------------------------------------------------------------------------
+          !--      Melting ice processes at the top surface :
+          !--      The energy used to melt ice, zqice_top_mlt, is taken from the energy
+          !--      stored in brine pockets qstbif_1d and the remaining energy coming 
+          !--      from the melting snow process zqsn_mlt_rem.
+          !--      If qstbif_1d > zqsn_mlt_rem then, one uses only a zqsn_mlt_rem part
+          !--      of qstbif_1d to melt ice,
+          !--         zqice_top_mlt = zqice_top_mlt + zqsn_mlt_rem
+          !--         qstbif_1d = qstbif_1d - zqsn_mlt_rem
+          !--      Otherwise one uses all qstbif_1d to melt ice
+          !--         zqice_top_mlt = zqice_top_mlt + qstbif_1d
+          !--         qstbif_1d = 0
+          !------------------------------------------------------
+          
+          ziqf =  MAX ( zzero , SIGN( zone , qstbif_1d(ji) - zqsn_mlt_rem  ) )
+          zqice_top_mlt =         ziqf   * ( zqice_top_mlt + zqsn_mlt_rem )   &
+             &          + ( 1.0 - ziqf ) * ( zqice_top_mlt + qstbif_1d(ji)  )
+
+          qstbif_1d(ji) =         ziqf   * ( qstbif_1d(ji) - zqsn_mlt_rem )   &
+             &        + ( 1.0 - ziqf ) * ( qstbif_1d(ji) - qstbif_1d(ji)  )
+
+          !--    The contribution of the energy stored in brine pockets qstbif_1d to melt
+          !--    ice is taking into account only when qstbif_1d is less than zqmax. 
+          !--    Otherwise, only the remaining energy coming from the melting snow 
+          !--    process is used 
+          zihq =  MAX ( zzero , SIGN( zone , qstbif_1d(ji) - zqmax(ji) ) )
+
+          zqice_top_mlt =         zihq   * zqice_top_mlt   &
+             &          + ( 1.0 - zihq ) * zqsn_mlt_rem
+
+          qstbif_1d(ji) =         zihq   * qstbif_1d(ji)   &
+             &        + ( 1.0 - zihq ) * zqstbif_old
+
+          !--change in ice thickness due to melt at the top surface
+          zdhictop(ji) = -zqice_top_mlt / xlic
+          !--compute the volume formed after surface melting
+          dvsbq_1d(ji) =  zdhictop(ji) * ( 1.0 - frld_1d(ji) )
+
+          !-------------------------------------------------------------------------
+          !--      A small variation at the surface also occurs because of sublimation
+          !--      associated with the latent flux. If qla_ice_1d is negative, snow condensates at 
+          !        the surface. Otherwise, snow evaporates
+          !-----------------------------------------------------------------------
+          !----change in snow and ice thicknesses due to sublimation or evaporation
+          zdhssub  = parsub * ( qla_ice_1d(ji) / ( rhosn * xsn ) ) * rdt_ice 
+          zhsn     = h_snow_1d(ji) - zdhssub
+          zdhisub  = MAX( zzero , -zhsn ) * rhosn/rhoic
+          zdhictop(ji) =  zdhictop(ji) - zdhisub
+          h_snow_1d(ji)  =  MAX( zzero , zhsn )
+          !-------------------------------------------------
+          !--  Update Internal temperature and qstbif_1d.
+          !-------------------------------------------
+          zihsn  =  MAX( zzero , SIGN( zone, -h_snow_1d(ji) ) )
+          tbif_1d(ji,1) = ( 1.0 - zihsn ) * tbif_1d(ji,1) + zihsn   * tfu_1d(ji)
+          !--change in snow internal temperature if snow has increased
+          zihnf = MAX( zzero , SIGN( zone , h_snow_1d(ji) - zhsnw_old(ji) ) )
+          zdhsn = 1.0 - zhsnw_old(ji) / MAX( h_snow_1d(ji) , epsi20 )
+          zdtsn = zdhsn * ( sist_1d(ji) - tbif_1d(ji,1) )
+          tbif_1d(ji,1) = tbif_1d(ji,1) + z1midsn(ji) * zihnf * zdtsn
+          !--energy created due to ice melting in the first ice layer
+          zqnes  = ( rt0_ice - tbif_1d(ji,2) ) * rcpic * ( h_ice_1d(ji) / 2. )
+          !--change in first ice layer internal temperature
+          ziqr  = MAX( zzero , SIGN( zone , qstbif_1d(ji) - zqnes ) )
+          zdtic = qstbif_1d(ji) / ( rcpic * ( h_ice_1d(ji) / 2. ) )
+          tbif_1d(ji,2) =  ziqr * rt0_ice + ( 1 - ziqr ) * ( tbif_1d(ji,2) + zdtic )
+          !--update qstbif_1d
+          qstbif_1d(ji) = ziqr * ( qstbif_1d(ji) - zqnes ) * swiqst
+
+
+          !--      9.2. Calculate bottom accretion-ablation and update qstbif_1d.
+          !             Growth and melting at bottom ice surface are governed by  
+          !                 -xlic * Dh = (Fcb - Fbot ) * Dt 
+          !             where Fbot is the net downward heat flux from ice to the ocean
+          !            and Fcb is the conductive heat flux at the bottom surface
+          !---------------------------------------------------------------------------
+          ztbot = ( 1.0 - zidsnic(ji) ) * tbif_1d(ji,3) + zidsnic(ji) * sist_1d(ji)
+          !---computes conductive heat flux at bottom surface 
+          zfcbot =  4.0 * zkic(ji) * ( tfu_1d(ji) - ztbot )   &
+             &   / ( h_ice_1d(ji) + zidsnic(ji) * ( 3. * h_ice_1d(ji) &
+             &   + 4.0 * zkic(ji)/zksn(ji) * h_snow_1d(ji) ) )
+          !---computation of net energy needed for bottom melting/growing
+          zqice_bot = ( zfcbot - ( fbif_1d(ji) + qlbbq_1d(ji) ) ) * rdt_ice
+          zqstbif_bot = qstbif_1d(ji)
+          !---switch to know if bottom surface melts ( = 1 ) or grows ( = 0 )occurs
+          zibmlt = MAX( zzero , SIGN( zone , -zqice_bot ) )
+          !--particular case of melting (in the same way as the top surface)
+          zqice_bot_mlt = zqice_bot 
+          zqstbif_old = zqstbif_bot
+
+          ziqf =  MAX ( zzero , SIGN( zone , qstbif_1d(ji) + zqice_bot_mlt  ) )
+          zqice_bot_mlt =         ziqf   * ( zqice_bot_mlt + zqice_bot_mlt ) &
+             &          + ( 1.0 - ziqf ) * ( zqice_bot_mlt + qstbif_1d(ji)  )          
+          qstbif_1d(ji)   =         ziqf   * ( qstbif_1d(ji) + zqice_bot_mlt ) &
+             &          + ( 1.0 - ziqf ) * ( qstbif_1d(ji) - qstbif_1d(ji)  )
+          !--    The contribution of the energy stored in brine pockets qstbif_1d to melt
+          !--    ice is taking into account only when qstbif_1d is less than zqmax. 
+          zihq =  MAX ( zzero , SIGN( zone , qstbif_1d(ji) - zqmax(ji) ) )
+          zqice_bot_mlt =         zihq   * zqice_bot_mlt   &
+             &          + ( 1.0 - zihq ) * zqice_bot
+          qstbif_1d(ji)   =         zihq   * qstbif_1d(ji)   &
+             &             + ( 1.0 - zihq ) * zqstbif_old
+
+          !---treatment of the case of melting/growing
+          zqice_bot   =         zibmlt   * ( zqice_bot_mlt - zqcmlt(ji,2) )   &
+             &        + ( 1.0 - zibmlt ) * ( zqice_bot - zqcmlt(ji,2)  )
+          qstbif_1d(ji) =         zibmlt   * qstbif_1d(ji)   &
+             &           + ( 1.0 - zibmlt ) * zqstbif_bot
+
+          !--computes change in ice thickness due to melt or growth
+          zdhicbot(ji) = zqice_bot / xlic
+          !--limitation of bottom melting if so : hmelt maximum melting at bottom
+          zdhicmlt  = MAX( hmelt , zdhicbot(ji) ) 
+          !--energy after bottom melting/growing
+          zqsup(ji) = ( 1.0 - frld_1d(ji) ) * xlic * ( zdhicmlt - zdhicbot(ji) )
+          !-- compute the new thickness and the newly formed volume after bottom melting/growing
+          zdhicbot(ji)  = zdhicmlt
+          dvbbq_1d(ji) = ( 1.0 - frld_1d(ji) ) * zdhicbot(ji)
+
+
+          !        9.3.  Updating ice thickness after top surface ablation 
+          !              and bottom surface accretion/ablation
+          !---------------------------------------------------------------
+          zhicnew  = h_ice_1d(ji) + zdhictop(ji) + zdhicbot(ji)
+
+          !
+          !        9.4. Case of total ablation (ice is gone but snow may be left)
+          !-------------------------------------------------------------------
+          zhsn  = h_snow_1d(ji)
+          zihgnew = 1.0 - MAX( zzero , SIGN( zone , -zhicnew ) )
+          zihsn   = MAX( zzero , SIGN( zone , -zhsn ) )
+          !---convert 
+          zdhicm  = ( 1.0 - zihgnew ) * ( zhicnew - qstbif_1d(ji) / xlic )
+          zdhsnm  = ( 1.0 - zihsn ) * zdhicm * rhoic / rhosn
+          !---updating new ice thickness and computing the newly formed ice mass
+          zhicnew   =  zihgnew * zhicnew
+          rdmicif_1d(ji) =  rdmicif_1d(ji) + ( 1.0 - frld_1d(ji) ) * ( zhicnew - h_ice_1d(ji) ) * rhoic
+          !---updating new snow thickness and computing the newly formed snow mass
+          zhsnfi   = zhsn + zdhsnm
+          h_snow_1d(ji) = MAX( zzero , zhsnfi )
+          rdmsnif_1d(ji) =  rdmsnif_1d(ji) + ( 1.0 - frld_1d(ji) ) * ( h_snow_1d(ji) - zhsn ) * rhosn
+          !--remaining energy in case of total ablation
+          zqocea(ji) = - ( zihsn * xlic * zdhicm + xlsn * ( zhsnfi - h_snow_1d(ji) ) ) * ( 1.0 - frld_1d(ji) )
+          qstbif_1d(ji) = zihgnew * qstbif_1d(ji)
+
+          !
+          !        9.5. Update internal temperature and ice thickness.
+          !-------------------------------------------------------
+          !
+          sist_1d(ji) = zihgnew * sist_1d(ji) + ( 1.0 - zihgnew ) * tfu_1d(ji)
+          zidhb  = MAX( zzero , SIGN( zone , - zdhicbot(ji) ) )
+          zc1    = - zhicnew * 0.5
+          zpc1   = MIN( 0.5 * zone , - h_ice_1d(ji) * 0.5 - zdhictop(ji) )
+          zc2    = - zhicnew
+          zpc2   =  zidhb * zc2 + ( 1.0 - zidhb ) * ( - h_ice_1d(ji) - zdhictop(ji) )
+          zp1    =  MAX( zpc1 , zc1 )
+          zp2    =  MAX( zpc2 , zc1 )
+          zep(ji) =  tbif_1d(ji,2)
+          ztb2  = 2.0 * (         - zp1   * tbif_1d(ji,2)  &
+             &  + ( zp1 - zp2 ) * tbif_1d(ji,3)  &
+             &  + ( zp2 - zc1 ) * tfu_1d(ji) ) / MAX( zhicnew , epsi20 ) 
+          tbif_1d(ji,2) = zihgnew * ztb2 + ( 1.0 - zihgnew ) * tfu_1d(ji)
+          !---
+          zp1  =  MIN( zpc1 , zc1 )
+          zp2  =  MIN( zpc2 , zc1 )
+          zp1  =  MAX( zc2  , zp1 )
+          ztb3 =  2.0 * (   ( 1.0 - zidhb ) * (  ( zc1 - zp2 ) * tbif_1d(ji,3)  &
+             &                                 + ( zp2 - zc2 ) * tfu_1d(ji) )   &
+             &               +      zidhb   * (  ( zc1 - zp1 ) * zep(ji)      &
+             &                                 + ( zp1 - zc2 ) * tbif_1d(ji,3))  ) / MAX( zhicnew , epsi20 )
+          tbif_1d(ji,3) =  zihgnew * ztb3 + ( 1.0 - zihgnew ) * tfu_1d(ji)
+          h_ice_1d(ji)  =  zhicnew
+       END DO
+
+
+       !----------------------------------------------------------------------------
+       !  10. Surface accretion. 
+       !      The change of ice thickness after snow/ice formation is such that
+       !      the interface between snow and ice is located at the same height
+       !      as the ocean surface. It is given by (Fichefet and Morales Maqueda 1999)
+       !          D(h_ice) = (- D(hsn)/alph) =  [rhosn*hsn - (rau0 - rhoic)*hic]
+       !                                     / [alph*rhosn+rau0 - rhoic]
+       !----------------------------------------------------------------------------
+       !
+       DO ji = kideb , kiut
+
+          !--  Computation of the change of ice thickness after snow-ice formation
+          zdrmh =  ( rhosn * h_snow_1d(ji) + ( rhoic - rau0 ) * h_ice_1d(ji) )  &
+             &  / ( alphs * rhosn + rau0 - rhoic )
+          zdrmh = MAX( zzero , zdrmh )
+
+          !--New ice and snow thicknesses Fichefet and Morales Maqueda (1999)
+          zhicnew  = MAX( h_ice_1d(ji) , h_ice_1d(ji) + zdrmh )
+          zhsnnew  = MIN( h_snow_1d(ji) , h_snow_1d(ji) - alphs * zdrmh )
+          !---Compute new ice temperatures. snow temperature remains unchanged
+          !   Lepparanta (1983):
+          zihic = 1.0 - MAX( zzero , SIGN( zone , -zhicnew ) )
+          zquot  = ( 1.0 - zihic ) &
+             &   +         zihic * MIN( zone , h_ice_1d(ji) / MAX( zhicnew , epsi20 ) ) 
+          ztneq  =         alphs * cnscg * tbif_1d(ji,1)    &
+             &   + ( 1.0 - alphs * ( rhosn/rhoic ) ) * tfu_1d(ji)
+          zep(ji) = tbif_1d(ji,2)
+          tbif_1d(ji,2) = ztneq - zquot * zquot * ( ztneq - tbif_1d(ji,2) )
+          tbif_1d(ji,3) = 2.0 * ztneq &
+             &        + zquot * ( tbif_1d(ji,3) + zep(ji) - 2.0 * ztneq ) - tbif_1d(ji,2)
+
+          !---  Lepparanta (1983) (latent heat released during white ice formation
+          !     goes to the ocean -for lateral ablation-)
+          qldif_1d(ji)  = qldif_1d(ji) + zdrmh * ( 1.0 - alphs * ( rhosn/rhoic ) ) * xlic * ( 1.0 - frld_1d(ji) )
+          !--   Changes in ice volume and ice mass Lepparanta (1983):
+          dvnbq_1d(ji) = ( 1.0 - frld_1d(ji) ) * ( zhicnew - h_ice_1d(ji) )
+          dmgwi_1d(ji) = dmgwi_1d(ji) + ( 1.0 -frld_1d(ji) ) * ( h_snow_1d(ji) - zhsnnew ) * rhosn
+          !  case of natural freshwater flux
+#if defined key_lim_fdd  
+          rdmicif_1d(ji) = rdmicif_1d(ji) + ( 1.0 - frld_1d(ji) )   * ( zhicnew - h_ice_1d(ji) )  * rhoic
+          rdmsnif_1d(ji) = rdmsnif_1d(ji) + ( 1.0 - frld_1d(ji) )   * ( zhsnnew - h_snow_1d(ji) ) * rhosn
+
+#else
+          rdmicif_1d(ji) = rdmicif_1d(ji) + ( 1.0 - frld_1d(ji) ) * (  ( zhicnew - h_ice_1d(ji) ) * rhoic   &
+             &                                                    + ( zhsnnew - h_snow_1d(ji) ) * rhosn )
+#endif
+
+          !---  Actualize new snow and ice thickness.
+
+          h_snow_1d(ji)  = zhsnnew
+          h_ice_1d(ji)  = zhicnew
+
+       END DO
+
+       !----------------------------------------------------
+       !  11. Lateral ablation (Changes in sea/ice fraction) 
+       !----------------------------------------------------
+       DO ji = kideb , kiut
+          zfrl_old(ji)  = frld_1d(ji)
+          zihic   = 1.0 - MAX( zzero , SIGN( zone , -h_ice_1d(ji) ) )
+          zihsn   = 1.0 - MAX( zzero , SIGN( zone , -h_snow_1d(ji) ) )
+          !--In the case of total ablation (all the ice ice has melted) frld = 1
+          frld_1d(ji)  = ( 1.0 - zihic ) + zihic * zfrl_old(ji)
+          !--Part of solar radiation absorbing inside the ice and going
+          !--through the ocean
+          fscbq_1d(ji) = ( 1.0 - zfrl_old(ji) ) * ( 1.0 - thcm_1d(ji) ) * fstbif_1d(ji)
+          !--Total remaining energy after bottom melting/growing 
+          qfvbq_1d(ji) = zqsup(ji) + ( 1.0 - zihic ) * zqocea(ji)
+          !--Updating of total heat from the ocean
+          qldif_1d(ji)  = qldif_1d(ji) + qfvbq_1d(ji) + ( 1.0 - zihic ) * fscbq_1d(ji) * rdt_ice
+          !--Computation of total heat inside the snow/ice system
+          zqice  = h_snow_1d(ji) * xlsn + h_ice_1d(ji) * xlic
+          zqicetot  = ( 1.0 - frld_1d(ji) ) * zqice
+          !--The concentration of ice is reduced (frld increases) if the heat 
+          !--exchange between ice and ocean is positive
+          ziqf = MAX( zzero , SIGN( zone ,  zqicetot - qldif_1d(ji) ) )
+          zdfrl = qldif_1d(ji) / MAX( epsi20 , zqice ) 
+          frld_1d(ji)  = ( 1.0 - ziqf )    &
+             &       +         ziqf * ( frld_1d(ji) + MAX( zzero , zdfrl ) ) 
+          fltbif_1d(ji) = ( ( 1.0 - zfrl_old(ji) ) * qstbif_1d(ji) - zqicetot  ) / rdt_ice
+          !--  Opening of leads: Hakkinen & Mellor, 1992.
+          zdfrl = - ( zdhictop(ji) + zdhicbot(ji) ) * hakspl * ( 1.0 - zfrl_old(ji) ) &
+             &  / MAX( epsi13 , h_ice_1d(ji) + h_snow_1d(ji) * rhosn/rhoic ) 
+          zfrld_1d(ji) =  frld_1d(ji) + MAX( zzero , zdfrl )
+          !--Limitation of sea-ice fraction <= 1
+          zfrld_1d(ji) = ziqf * MIN( 0.99 * zone , zfrld_1d(ji) ) + ( 1 - ziqf )
+          !---Update surface and internal temperature and snow/ice thicknesses.
+          sist_1d(ji)   = sist_1d(ji)   + ( 1.0 - ziqf ) * ( tfu_1d(ji) - sist_1d(ji)   )
+          tbif_1d(ji,1) = tbif_1d(ji,1) + ( 1.0 - ziqf ) * ( tfu_1d(ji) - tbif_1d(ji,1) )
+          tbif_1d(ji,2) = tbif_1d(ji,2) + ( 1.0 - ziqf ) * ( tfu_1d(ji) - tbif_1d(ji,2) )
+          tbif_1d(ji,3) = tbif_1d(ji,3) + ( 1.0 - ziqf ) * ( tfu_1d(ji) - tbif_1d(ji,3) )
+          !--variation of ice volume and ice mass 
+          dvlbq_1d(ji)   = zihic * ( zfrl_old(ji) - frld_1d(ji) ) * h_ice_1d(ji)
+          rdmicif_1d(ji) = rdmicif_1d(ji) + dvlbq_1d(ji) * rhoic
+          !--variation of snow volume and snow mass 
+          zdvsnvol    = zihsn * ( zfrl_old(ji) - frld_1d(ji) ) * h_snow_1d(ji)
+          rdmsnif_1d(ji) = rdmsnif_1d(ji) + zdvsnvol * rhosn
+          h_snow_1d(ji)  = ziqf * h_snow_1d(ji)
+
+          zdrfrl1 = ziqf * ( 1.0 -  frld_1d(ji) ) / MAX( epsi20 , 1.0 - zfrld_1d(ji) )
+          zdrfrl2 = ziqf * ( 1.0 - zfrl_old(ji) ) / MAX( epsi20 , 1.0 - zfrld_1d(ji) )
+
+          h_snow_1d (ji) = zdrfrl1 * h_snow_1d(ji)
+          h_ice_1d  (ji) = zdrfrl1 * h_ice_1d(ji)
+          qstbif_1d(ji) = zdrfrl2 * qstbif_1d(ji)
+          frld_1d(ji)    = zfrld_1d(ji)
+
+       END DO
+       
+    END SUBROUTINE lim_thd_zdf_2
+#else
+   !!======================================================================
+   !!                       ***  MODULE limthd_zdf_2   ***
+   !!                              no sea ice model  
+   !!======================================================================
+CONTAINS
+   SUBROUTINE lim_thd_zdf_2          ! Empty routine
+   END SUBROUTINE lim_thd_zdf_2
+#endif
+ END MODULE limthd_zdf_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limtrp_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limtrp_2.F90	(revision 823)
@@ -0,0 +1,322 @@
+MODULE limtrp_2
+   !!======================================================================
+   !!                       ***  MODULE limtrp_2   ***
+   !! LIM 2.0 transport ice model : sea-ice advection/diffusion
+   !!======================================================================
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2' :                                  LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!   lim_trp_2      : advection/diffusion process of sea ice
+   !!   lim_trp_init_2 : initialization and namelist read
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE phycst
+   USE dom_oce
+   USE daymod
+   USE in_out_manager  ! I/O manager
+   USE ice_oce         ! ice variables
+   USE dom_ice_2
+   USE ice_2
+   USE iceini_2
+   USE limistate_2
+   USE limadv_2
+   USE limhdf_2
+   USE lbclnk
+   USE lib_mpp
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Routine accessibility
+   PUBLIC lim_trp_2     ! called by ice_step_2
+
+   !! * Shared module variables
+   REAL(wp), PUBLIC  ::   &  !:
+      bound  = 0.e0          !: boundary condit. (0.0 no-slip, 1.0 free-slip)
+
+   !! * Module variables
+   REAL(wp)  ::           &  ! constant values
+      epsi06 = 1.e-06  ,  &
+      epsi03 = 1.e-03  ,  &
+      epsi16 = 1.e-16  ,  &
+      rzero  = 0.e0    ,  &
+      rone   = 1.e0
+
+   !! * Substitution
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0,  UCL-LOCEAN-IPSL (2005) 
+   !! $Header$ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE lim_trp_2( kt )
+      !!-------------------------------------------------------------------
+      !!                   ***  ROUTINE lim_trp_2 ***
+      !!                    
+      !! ** purpose : advection/diffusion process of sea ice
+      !!
+      !! ** method  : variables included in the process are scalar,   
+      !!     other values are considered as second order. 
+      !!     For advection, a second order Prather scheme is used.  
+      !!
+      !! ** action :
+      !!
+      !! History :
+      !!   1.0  !  00-01 (LIM)  Original code
+      !!        !  01-05 (G. Madec, R. Hordoir) opa norm
+      !!   2.0  !  04-01 (G. Madec, C. Ethe)  F90, mpp
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+
+      INTEGER  ::   ji, jj, jk,   &  ! dummy loop indices
+         &          initad           ! number of sub-timestep for the advection
+
+      REAL(wp) ::  &                              
+         zindb  ,  &
+         zacrith, &
+         zindsn , &
+         zindic , &
+         zusvosn, &
+         zusvoic, &
+         zignm  , &
+         zindhe , &
+         zvbord , &
+         zcfl   , &
+         zusnit , &
+         zrtt, ztsn, ztic1, ztic2
+
+      REAL(wp), DIMENSION(jpi,jpj)  ::   &  ! temporary workspace
+         zui_u , zvi_v , zsm   ,         &
+         zs0ice, zs0sn , zs0a  ,         &
+         zs0c0 , zs0c1 , zs0c2 ,         &
+         zs0st
+      !---------------------------------------------------------------------
+
+      IF( kt == nit000  )   CALL lim_trp_init_2      ! Initialization (first time-step only)
+
+      zsm(:,:) = area(:,:)
+      
+      IF( ln_limdyn ) THEN
+         !-------------------------------------!
+         !   Advection of sea ice properties   !
+         !-------------------------------------!
+
+         ! ice velocities at ocean U- and V-points (zui_u,zvi_v)
+         ! ---------------------------------------
+         ! zvbord factor between 1 and 2 to take into account slip or no-slip boundary conditions.        
+         zvbord = 1.0 + ( 1.0 - bound )
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+               zui_u(ji,jj) = ( u_ice(ji+1,jj  ) + u_ice(ji+1,jj+1) ) / ( MAX( tmu(ji+1,jj  ) + tmu(ji+1,jj+1), zvbord ) )
+               zvi_v(ji,jj) = ( v_ice(ji  ,jj+1) + v_ice(ji+1,jj+1) ) / ( MAX( tmu(ji  ,jj+1) + tmu(ji+1,jj+1), zvbord ) )
+            END DO
+         END DO
+         ! Lateral boundary conditions on zui_u, zvi_v
+         CALL lbc_lnk( zui_u, 'U', -1. )
+         CALL lbc_lnk( zvi_v, 'V', -1. )
+
+         ! CFL test for stability
+         ! ----------------------
+         zcfl  = 0.e0
+         zcfl  = MAX( zcfl, MAXVAL( ABS( zui_u(1:jpim1, :     ) ) * rdt_ice / e1u(1:jpim1, :     ) ) )
+         zcfl  = MAX( zcfl, MAXVAL( ABS( zvi_v( :     ,1:jpjm1) ) * rdt_ice / e2v( :     ,1:jpjm1) ) )
+
+         IF (lk_mpp ) CALL mpp_max(zcfl)
+
+         IF ( zcfl > 0.5 .AND. lwp )   WRITE(numout,*) 'lim_trp : violation of cfl criterion the ',nday,'th day, cfl = ',zcfl
+
+         ! content of properties
+         ! ---------------------
+         zs0sn (:,:) =  hsnm(:,:) * area(:,:)                 ! Snow volume.
+         zs0ice(:,:) =  hicm (:,:) * area(:,:)                ! Ice volume.
+         zs0a  (:,:) =  ( 1.0 - frld(:,:) ) * area(:,:)       ! Surface covered by ice.
+         zs0c0 (:,:) =  tbif(:,:,1) / rt0_snow * zs0sn(:,:)   ! Heat content of the snow layer.
+         zs0c1 (:,:) =  tbif(:,:,2) / rt0_ice  * zs0ice(:,:)  ! Heat content of the first ice layer.
+         zs0c2 (:,:) =  tbif(:,:,3) / rt0_ice  * zs0ice(:,:)  ! Heat content of the second ice layer.
+         zs0st (:,:) =  qstoif(:,:) / xlic     * zs0a(:,:)    ! Heat reservoir for brine pockets.
+         
+ 
+         ! Advection 
+         ! ---------
+         ! If ice drift field is too fast, use an appropriate time step for advection.         
+         initad = 1 + INT( MAX( rzero, SIGN( rone, zcfl-0.5 ) ) )
+         zusnit = 1.0 / REAL( initad ) 
+         
+         IF ( MOD( nday , 2 ) == 0) THEN
+            DO jk = 1,initad
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_x_2( zusnit, zui_u, rone , zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rzero, zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+            END DO
+         ELSE
+            DO jk = 1, initad
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0ice, sxice, sxxice, syice, syyice, sxyice )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0sn , sxsn , sxxsn , sysn , syysn , sxysn  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0a  , sxa  , sxxa  , sya  , syya  , sxya   )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0c0 , sxc0 , sxxc0 , syc0 , syyc0 , sxyc0  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0c1 , sxc1 , sxxc1 , syc1 , syyc1 , sxyc1  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0c2 , sxc2 , sxxc2 , syc2 , syyc2 , sxyc2  )
+               CALL lim_adv_y_2( zusnit, zvi_v, rone , zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+               CALL lim_adv_x_2( zusnit, zui_u, rzero, zsm, zs0st , sxst , sxxst , syst , syyst , sxyst  )
+            END DO
+         ENDIF
+                        
+         ! recover the properties from their contents
+         ! ------------------------------------------
+         zs0ice(:,:) = zs0ice(:,:) / area(:,:)
+         zs0sn (:,:) = zs0sn (:,:) / area(:,:)
+         zs0a  (:,:) = zs0a  (:,:) / area(:,:)
+         zs0c0 (:,:) = zs0c0 (:,:) / area(:,:)
+         zs0c1 (:,:) = zs0c1 (:,:) / area(:,:)
+         zs0c2 (:,:) = zs0c2 (:,:) / area(:,:)
+         zs0st (:,:) = zs0st (:,:) / area(:,:)
+
+
+         !-------------------------------------!
+         !   Diffusion of sea ice properties   !
+         !-------------------------------------!
+
+         ! Masked eddy diffusivity coefficient at ocean U- and V-points
+         ! ------------------------------------------------------------
+         DO jj = 1, jpjm1          ! NB: has not to be defined on jpj line and jpi row
+            DO ji = 1 , fs_jpim1   ! vector opt.
+               pahu(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji  ,jj) ) ) )   &
+                  &        * ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji+1,jj) ) ) ) * ahiu(ji,jj)
+               pahv(ji,jj) = ( 1.0 - MAX( rzero, SIGN( rone, -zs0a(ji,jj  ) ) ) )   &
+                  &        * ( 1.0 - MAX( rzero, SIGN( rone,- zs0a(ji,jj+1) ) ) ) * ahiv(ji,jj)
+            END DO
+         END DO
+
+         ! diffusion
+         ! ---------
+         CALL lim_hdf_2( zs0ice )
+         CALL lim_hdf_2( zs0sn  )
+         CALL lim_hdf_2( zs0a   )
+         CALL lim_hdf_2( zs0c0  )
+         CALL lim_hdf_2( zs0c1  )
+         CALL lim_hdf_2( zs0c2  )
+         CALL lim_hdf_2( zs0st  )
+
+         zs0ice(:,:) = MAX( rzero, zs0ice(:,:) * area(:,:) )    !!bug:  est-ce utile
+         zs0sn (:,:) = MAX( rzero, zs0sn (:,:) * area(:,:) )    !!bug:  cf /area  juste apres
+         zs0a  (:,:) = MAX( rzero, zs0a  (:,:) * area(:,:) )    !! suppression des 2 change le resultat...
+         zs0c0 (:,:) = MAX( rzero, zs0c0 (:,:) * area(:,:) )
+         zs0c1 (:,:) = MAX( rzero, zs0c1 (:,:) * area(:,:) )
+         zs0c2 (:,:) = MAX( rzero, zs0c2 (:,:) * area(:,:) )
+         zs0st (:,:) = MAX( rzero, zs0st (:,:) * area(:,:) )
+
+
+         ! -------------------------------------------------------------------!
+         !   Up-dating and limitation of sea ice properties after transport   !
+         ! -------------------------------------------------------------------!
+
+         ! Up-dating and limitation of sea ice properties after transport.
+         DO jj = 1, jpj
+!!!iii      zindhe = REAL( MAX( 0, isign(1, jj - njeq ) ) )              !ibug mpp  !!bugmpp  njeq!
+            zindhe = MAX( 0.e0, SIGN( 1.e0, fcor(1,jj) ) )              ! = 0 for SH, =1 for NH
+            DO ji = 1, jpi
+
+               ! Recover mean values over the grid squares.
+               zs0sn (ji,jj) = MAX( rzero, zs0sn (ji,jj)/area(ji,jj) )
+               zs0ice(ji,jj) = MAX( rzero, zs0ice(ji,jj)/area(ji,jj) )
+               zs0a  (ji,jj) = MAX( rzero, zs0a  (ji,jj)/area(ji,jj) )
+               zs0c0 (ji,jj) = MAX( rzero, zs0c0 (ji,jj)/area(ji,jj) )
+               zs0c1 (ji,jj) = MAX( rzero, zs0c1 (ji,jj)/area(ji,jj) )
+               zs0c2 (ji,jj) = MAX( rzero, zs0c2 (ji,jj)/area(ji,jj) )
+               zs0st (ji,jj) = MAX( rzero, zs0st (ji,jj)/area(ji,jj) )
+
+               ! Recover in situ values.
+               zindb         = MAX( rzero, SIGN( rone, zs0a(ji,jj) - epsi06 ) )
+               zacrith       = 1.0 - ( zindhe * acrit(1) + ( 1.0 - zindhe ) * acrit(2) )
+               zs0a (ji,jj)  = zindb * MIN( zs0a(ji,jj), zacrith )
+               hsnif(ji,jj)  = zindb * ( zs0sn(ji,jj) /MAX( zs0a(ji,jj), epsi16 ) )
+               hicif(ji,jj)  = zindb * ( zs0ice(ji,jj)/MAX( zs0a(ji,jj), epsi16 ) )
+               zindsn        = MAX( rzero, SIGN( rone, hsnif(ji,jj) - epsi06 ) )
+               zindic        = MAX( rzero, SIGN( rone, hicif(ji,jj) - epsi03 ) )
+               zindb         = MAX( zindsn, zindic )
+               zs0a (ji,jj)  = zindb * zs0a(ji,jj)
+               frld (ji,jj)  = 1.0 - zs0a(ji,jj)
+               hsnif(ji,jj)  = zindsn * hsnif(ji,jj)
+               hicif(ji,jj)  = zindic * hicif(ji,jj)
+               zusvosn       = 1.0/MAX( hsnif(ji,jj) * zs0a(ji,jj), epsi16 )
+               zusvoic       = 1.0/MAX( hicif(ji,jj) * zs0a(ji,jj), epsi16 )
+               zignm         = MAX( rzero,  SIGN( rone, hsndif - hsnif(ji,jj) ) )
+               zrtt          = 173.15 * rone 
+               ztsn          =          zignm   * tbif(ji,jj,1)  &
+                              + ( 1.0 - zignm ) * MIN( MAX( zrtt, rt0_snow * zusvosn * zs0c0(ji,jj)) , tfu(ji,jj) ) 
+               ztic1          = MIN( MAX( zrtt, rt0_ice * zusvoic * zs0c1(ji,jj) ) , tfu(ji,jj) )
+               ztic2          = MIN( MAX( zrtt, rt0_ice * zusvoic * zs0c2(ji,jj) ) , tfu(ji,jj) )
+ 
+               tbif(ji,jj,1) = zindsn * ztsn  + ( 1.0 - zindsn ) * tfu(ji,jj)               
+               tbif(ji,jj,2) = zindic * ztic1 + ( 1.0 - zindic ) * tfu(ji,jj)
+               tbif(ji,jj,3) = zindic * ztic2 + ( 1.0 - zindic ) * tfu(ji,jj)
+               qstoif(ji,jj) = zindb  * xlic * zs0st(ji,jj) /  MAX( zs0a(ji,jj), epsi16 )
+            END DO
+         END DO
+         
+      ENDIF
+      
+   END SUBROUTINE lim_trp_2
+
+
+   SUBROUTINE lim_trp_init_2
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE lim_trp_init_2  ***
+      !!
+      !! ** Purpose :   initialization of ice advection parameters
+      !!
+      !! ** Method  : Read the namicetrp namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicetrp
+      !!
+      !! history :
+      !!   2.0  !  03-08 (C. Ethe)  Original code
+      !!-------------------------------------------------------------------
+      NAMELIST/namicetrp/ bound
+      !!-------------------------------------------------------------------
+
+      ! Read Namelist namicetrp
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice  , namicetrp )
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_trp_init_2 : Ice parameters for advection '
+         WRITE(numout,*) '~~~~~~~~~~~~~~'
+         WRITE(numout,*) '   boundary conditions (0. no-slip, 1. free-slip) bound  = ', bound
+      ENDIF
+            
+   END SUBROUTINE lim_trp_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option         Empty Module                No sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_trp_2        ! Empty routine
+   END SUBROUTINE lim_trp_2
+#endif
+
+   !!======================================================================
+END MODULE limtrp_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limwri_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limwri_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limwri_2.F90	(revision 823)
@@ -0,0 +1,292 @@
+MODULE limwri_2
+   !!======================================================================
+   !!                     ***  MODULE  limwri_2  ***
+   !!         Ice diagnostics :  write ice output files
+   !!======================================================================
+   !! history :  2.0  ! 03-08  (C. Ethe) original code
+   !!            2.0  ! 04-10  (C. Ethe )  1D configuration
+   !!-------------------------------------------------------------------
+#if defined key_lim2
+   !!----------------------------------------------------------------------
+   !!   'key_lim2'  i                                 LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   lim_wri_2      : write of the diagnostics variables in ouput file 
+   !!   lim_wri_init_2 : initialization and namelist read
+   !!----------------------------------------------------------------------
+   USE ioipsl
+   USE dianam    ! build name of file (routine)
+   USE phycst
+   USE dom_oce
+   USE daymod
+   USE in_out_manager
+   USE ice_oce         ! ice variables
+   USE flx_oce
+   USE dom_ice_2
+   USE ice_2
+   USE lbclnk
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   lim_wri_2        ! routine called by lim_step_2.F90
+
+   INTEGER, PARAMETER                       ::   jpnoumax = 40   ! maximum number of variable for ice output
+   INTEGER                                  ::   noumef          ! number of fields
+   REAL(wp)           , DIMENSION(jpnoumax) ::   cmulti ,     &  ! multiplicative constant
+      &                                          cadd            ! additive constant
+   CHARACTER(len = 35), DIMENSION(jpnoumax) ::   titn            ! title of the field
+   CHARACTER(len = 8 ), DIMENSION(jpnoumax) ::   nam             ! name of the field
+   CHARACTER(len = 8 ), DIMENSION(jpnoumax) ::   uni             ! unit of the field
+   INTEGER            , DIMENSION(jpnoumax) ::   nc              ! switch for saving field ( = 1 ) or not ( = 0 )
+
+   INTEGER ::   nice, nhorid, ndim, niter, ndepid       ! ????
+   INTEGER , DIMENSION( jpij ) ::   ndex51              ! ????
+
+   REAL(wp)  ::            &  ! constant values
+      epsi16 = 1.e-16   ,  &
+      zzero  = 0.e0     ,  &
+      zone   = 1.e0
+
+   !!----------------------------------------------------------------------
+   !!  LIM 2.0, UCL-LOCEAN-IPSL (2005)
+   !! $Header$
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+#if defined key_dimgout
+   !!----------------------------------------------------------------------
+   !!   'key_dimgout'                                    Direct Access file
+   !!----------------------------------------------------------------------
+# include "limwri_dimg_2.h90"
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option                                          NetCDF file
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE lim_wri_2( kt )
+      !!-------------------------------------------------------------------
+      !!                    ***   ROUTINE lim_wri_2  ***
+      !!                
+      !! ** Purpose :   write the sea-ice output file in NetCDF
+      !!
+      !! ** Method  :   computes the average of some variables and write
+      !!      it in the NetCDF ouput files
+      !!      CAUTION: the sea-ice time-step must be an integer fraction
+      !!      of a day
+      !!-------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! number of iteration
+
+      INTEGER  ::   ji, jj, jf                      ! dummy loop indices
+      CHARACTER(len = 40)  ::   clhstnam, clop
+      REAL(wp) ::   zsto, zsec, zjulian, zout,   &  ! temporary scalars
+         &          zindh, zinda, zindb, ztmu
+      REAL(wp), DIMENSION(1)                ::   zdept
+      REAL(wp), DIMENSION(jpi,jpj)          ::   zfield
+      REAL(wp), DIMENSION(jpi,jpj,jpnoumax) ::   zcmo
+      !!-------------------------------------------------------------------
+
+      !                                          !--------------------!
+      IF ( kt == nit000 ) THEN                !   Initialisation   !
+         !                                       !--------------------!
+         CALL lim_wri_init_2 
+                           
+         zsto     = rdt_ice
+!!Chris         clop     = "ave(only(x))"      !ibug  namelist parameter a ajouter
+         clop     = "ave(x)"
+         zout     = nwrite * rdt_ice / nfice
+         zsec     = 0.
+         niter    = 0
+         zdept(1) = 0.
+         
+         CALL ymds2ju ( nyear, nmonth, nday, zsec, zjulian )
+         CALL dia_nam ( clhstnam, nwrite, 'icemod' )
+         CALL histbeg ( clhstnam, jpi, glamt, jpj, gphit,    &
+            &           1, jpi, 1, jpj, 0, zjulian, rdt_ice, nhorid, nice , domain_id=nidom)
+         CALL histvert( nice, "deptht", "Vertical T levels", "m", 1, zdept, ndepid)
+         CALL wheneq  ( jpij , tmask(:,:,1), 1, 1., ndex51, ndim)
+         
+         DO jf = 1, noumef
+            IF ( nc(jf) == 1 )   CALL histdef( nice, nam(jf), titn(jf), uni(jf), jpi, jpj   &
+                  &                                , nhorid, 1, 1, 1, -99, 32, clop, zsto, zout )
+         END DO
+         CALL histend( nice )
+         
+      ENDIF
+      !                                          !--------------------!
+      !                                          !   Cumulate at kt   !
+      !                                          !--------------------!
+
+!!gm  change the print below to have it only at output time step or when nitend =< 100
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_wri_2 : write ice outputs in NetCDF files at time : ', nyear, nmonth, nday, kt + nfice - 1
+         WRITE(numout,*) '~~~~~~~~~ '
+      ENDIF
+
+      !-- calculs des valeurs instantanees
+      
+      zcmo(:,:, 1:jpnoumax ) = 0.e0 
+      DO jj = 2 , jpjm1
+         DO ji = 2 , jpim1
+            zindh  = MAX( zzero , SIGN( zone , hicif(ji,jj) * (1.0 - frld(ji,jj) ) - 0.10 ) )
+            zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
+            zindb  = zindh * zinda
+            ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) ) 
+            zcmo(ji,jj,1)  = hsnif (ji,jj)
+            zcmo(ji,jj,2)  = hicif (ji,jj)
+            zcmo(ji,jj,3)  = hicifp(ji,jj)
+            zcmo(ji,jj,4)  = frld  (ji,jj)
+            zcmo(ji,jj,5)  = sist  (ji,jj)
+            zcmo(ji,jj,6)  = fbif  (ji,jj)
+            zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                                      + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                                  / ztmu 
+
+            zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                                      + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                                  / ztmu
+            zcmo(ji,jj,9)  = sst_io(ji,jj)
+            zcmo(ji,jj,10) = sss_io(ji,jj)
+
+            zcmo(ji,jj,11) = fnsolar(ji,jj) + fsolar(ji,jj)
+            zcmo(ji,jj,12) = fsolar (ji,jj)
+            zcmo(ji,jj,13) = fnsolar(ji,jj)
+            ! See thersf for the coefficient
+            zcmo(ji,jj,14) = - fsalt(ji,jj) * rday * ( sss_io(ji,jj) + epsi16 ) / soce
+            zcmo(ji,jj,15) = gtaux(ji,jj)
+            zcmo(ji,jj,16) = gtauy(ji,jj)
+            zcmo(ji,jj,17) = ( 1.0 - frld(ji,jj) ) * qsr_ice (ji,jj) + frld(ji,jj) * qsr_oce (ji,jj)
+            zcmo(ji,jj,18) = ( 1.0 - frld(ji,jj) ) * qnsr_ice(ji,jj) + frld(ji,jj) * qnsr_oce(ji,jj)
+            zcmo(ji,jj,19) = sprecip(ji,jj)
+         END DO
+      END DO
+      !
+      ! Write the netcdf file
+      !
+      niter = niter + 1
+      DO jf = 1 , noumef
+         DO jj = 1 , jpj
+            DO ji = 1 , jpi
+               zfield(ji,jj) = zcmo(ji,jj,jf) * cmulti(jf) + cadd(jf)
+            END DO
+         END DO
+         
+         IF ( jf == 7  .OR. jf == 8  .OR. jf == 15 .OR. jf == 16 ) THEN 
+            CALL lbc_lnk( zfield, 'T', -1. )
+         ELSE 
+            CALL lbc_lnk( zfield, 'T',  1. )
+         ENDIF
+         
+         IF ( nc(jf) == 1 ) CALL histwrite( nice, nam(jf), niter, zfield, ndim, ndex51 )
+         
+      END DO
+      
+      IF ( ( nfice * niter + nit000 - 1 ) >= nitend ) THEN
+         CALL histclo( nice ) 
+      ENDIF
+      !
+   END SUBROUTINE lim_wri_2
+   
+#endif
+   
+   SUBROUTINE lim_wri_init_2
+      !!-------------------------------------------------------------------
+      !!                    ***   ROUTINE lim_wri_init_2  ***
+      !!                
+      !! ** Purpose :   intialisation of LIM sea-ice output
+      !!
+      !! ** Method  : Read the namicewri namelist and check the parameter 
+      !!       values called at the first timestep (nit000)
+      !!
+      !! ** input   :   Namelist namicewri
+      !!-------------------------------------------------------------------
+      INTEGER ::   nf      ! ???
+      TYPE FIELD 
+         CHARACTER(len = 35) :: ztitle 
+         CHARACTER(len = 8 ) :: zname          
+         CHARACTER(len = 8 ) :: zunit
+         INTEGER             :: znc   
+         REAL                :: zcmulti 
+         REAL                :: zcadd        
+      END TYPE FIELD
+      TYPE(FIELD) ::  &
+         field_1 , field_2 , field_3 , field_4 , field_5 , field_6 ,   &
+         field_7 , field_8 , field_9 , field_10, field_11, field_12,   &
+         field_13, field_14, field_15, field_16, field_17, field_18,   &
+         field_19
+      TYPE(FIELD) , DIMENSION(jpnoumax) :: zfield
+
+      NAMELIST/namiceout/ noumef, &
+         field_1 , field_2 , field_3 , field_4 , field_5 , field_6 ,   &
+         field_7 , field_8 , field_9 , field_10, field_11, field_12,   &
+         field_13, field_14, field_15, field_16, field_17, field_18,   &
+         field_19
+!!gm      NAMELIST/namiceout/ noumef, &
+!!           zfield( 1), zfield( 2), zfield( 3), zfield( 4), zfield( 5),   &
+!!           zfield( 6), zfield( 7), zfield( 8), zfield( 9), zfield(10),   &
+!!           zfield(11), zfield(12), zfield(13), zfield(14), zfield(15),   &
+!!gm         zfield(16), zfield(17), zfield(18), zfield(19)
+      !!-------------------------------------------------------------------
+
+      ! Read Namelist namicewri
+      REWIND ( numnam_ice )
+      READ   ( numnam_ice  , namiceout )
+      
+      zfield(1)  = field_1
+      zfield(2)  = field_2
+      zfield(3)  = field_3
+      zfield(4)  = field_4
+      zfield(5)  = field_5
+      zfield(6)  = field_6
+      zfield(7)  = field_7
+      zfield(8)  = field_8
+      zfield(9)  = field_9
+      zfield(10) = field_10
+      zfield(11) = field_11
+      zfield(12) = field_12
+      zfield(13) = field_13
+      zfield(14) = field_14
+      zfield(15) = field_15
+      zfield(16) = field_16
+      zfield(17) = field_17
+      zfield(18) = field_18
+      zfield(19) = field_19
+      
+      DO nf = 1, noumef
+         titn  (nf) = zfield(nf)%ztitle
+         nam   (nf) = zfield(nf)%zname
+         uni   (nf) = zfield(nf)%zunit
+         nc    (nf) = zfield(nf)%znc
+         cmulti(nf) = zfield(nf)%zcmulti
+         cadd  (nf) = zfield(nf)%zcadd
+      END DO
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'lim_wri_init_2 : Ice parameters for outputs'
+         WRITE(numout,*) '~~~~~~~~~~~~~~'
+         WRITE(numout,*) '    number of fields to be stored         noumef = ', noumef
+         WRITE(numout,*) '           title                            name     unit      Saving (1/0) ',   &
+            &            '    multiplicative constant       additive constant '
+         DO nf = 1 , noumef         
+            WRITE(numout,*) '   ', titn(nf), '   ', nam(nf),'      ', uni(nf),'  ', nc(nf),'        ', cmulti(nf),   &
+               '        ', cadd(nf)
+         END DO
+      ENDIF
+      !    
+   END SUBROUTINE lim_wri_init_2
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default option :         Empty module      NO LIM 2.0 sea-ice model
+   !!----------------------------------------------------------------------
+CONTAINS
+   SUBROUTINE lim_wri_2          ! Empty routine
+   END SUBROUTINE lim_wri_2
+#endif
+
+   !!======================================================================
+END MODULE limwri_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/limwri_dimg_2.h90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/limwri_dimg_2.h90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/limwri_dimg_2.h90	(revision 823)
@@ -0,0 +1,205 @@
+    SUBROUTINE lim_wri_2(kt)
+   !!----------------------------------------------------------------------
+   !!  LIM 2.0, UCL-LOCEAN-IPSL (2005)
+   !! $Header$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+    !!-------------------------------------------------------------------
+    !!  This routine computes the average of some variables and write it
+    !!  on the ouput files.
+    !!  ATTENTION cette routine n'est valable que si le pas de temps est
+    !!  egale a une fraction entiere de 1 jours.
+    !!  Diff 1-D 3-D : suppress common also included in etat
+    !!                 suppress cmoymo 11-18
+    !!  modif : 03/06/98
+    !!-------------------------------------------------------------------
+    USE  diadimg                ! use of dia_wri_dimg
+
+    INTEGER, INTENT(in) ::   kt     ! number of iteration
+
+    REAL(wp),DIMENSION(1) ::   zdept
+
+    REAL(wp) :: &
+         zsto, zsec, zjulian,zout, &
+         zindh,zinda,zindb,  &
+         ztmu
+    REAL(wp), DIMENSION(jpi,jpj,jpnoumax) :: &
+         zcmo
+    REAL(wp), DIMENSION(jpi,jpj) ::  &
+         zfield
+    INTEGER, SAVE :: nmoyice, &  !: counter for averaging
+         &             nwf         !: number of fields to write on disk
+    INTEGER, SAVE,DIMENSION (:), ALLOCATABLE  :: nsubindex   !: subindex to be saved
+    ! according to namelist
+
+    REAL(wp), SAVE, DIMENSION(jpi,jpj,jpnoumax) :: rcmoy
+#if ! defined key_diainstant
+    LOGICAL, PARAMETER :: ll_dia_inst=.false.      ! local logical variable 
+#else
+    LOGICAL, PARAMETER :: ll_dia_inst=.true.
+#endif
+    INTEGER ::  ji, jj, jf, ii   ! dummy loop indices and array index
+    INTEGER :: iyear, iday, imon ! 
+
+    CHARACTER(LEN=80) :: clname, cltext, clmode
+
+
+    INTEGER , SAVE ::      &
+         nice, nhorid, ndim, niter, ndepid
+    INTEGER , DIMENSION( jpij ) , SAVE ::  &
+         ndex51  
+    !!-------------------------------------------------------------------
+    IF ( kt == nit000 ) THEN 
+
+       CALL lim_wri_init_2 
+
+       nwf = 0 
+       ii  = 0
+
+       IF (lwp ) THEN
+          WRITE(numout,*) 'lim_wri_2 : Write ice outputs in dimg'
+          WRITE(numout,*) '~~~~~~~~'
+          WRITE(numout,*) '   According to namelist_ice, following fields saved:'
+          DO jf =1, noumef
+             IF (nc(jf) == 1 ) THEN
+                WRITE(numout,* ) '    -',titn(jf), nam(jf), uni(jf)
+             ENDIF
+          END DO
+       ENDIF
+
+       DO jf = 1, noumef
+          IF (nc(jf) == 1 ) nwf = nwf + 1
+       END DO
+
+       ALLOCATE( nsubindex (nwf) )
+
+       DO jf = 1, noumef
+          IF (nc(jf) == 1 ) THEN 
+             ii = ii +1 
+             nsubindex(ii) = jf
+          END IF
+       END DO
+
+       zsto     = rdt_ice
+       zout     = nwrite * rdt_ice / nfice
+       zsec     = 0.
+       niter    = 0
+       zdept(1) = 0.
+       nmoyice  = 0
+
+    ENDIF
+
+#if ! defined key_diainstant 
+    !-- calculs des valeurs instantanees
+
+    zcmo(:,:, 1:jpnoumax ) = 0.e0 
+    DO jj = 2 , jpjm1
+       DO ji = 2 , jpim1
+          zindh  = MAX( zzero , SIGN( zone , hicif(ji,jj) * (1.0 - frld(ji,jj) ) - 0.10 ) )
+          zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
+          zindb  = zindh * zinda
+          ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) ) 
+          zcmo(ji,jj,1)  = hsnif (ji,jj)
+          zcmo(ji,jj,2)  = hicif (ji,jj)
+          zcmo(ji,jj,3)  = hicifp(ji,jj)
+          zcmo(ji,jj,4)  = frld  (ji,jj)
+          zcmo(ji,jj,5)  = sist  (ji,jj)
+          zcmo(ji,jj,6)  = fbif  (ji,jj)
+          zcmo(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+               + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+               / ztmu 
+
+          zcmo(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+               + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+               / ztmu
+          zcmo(ji,jj,9)  = sst_io(ji,jj)
+          zcmo(ji,jj,10) = sss_io(ji,jj)
+
+          zcmo(ji,jj,11) = fnsolar(ji,jj) + fsolar(ji,jj)
+          zcmo(ji,jj,12) = fsolar (ji,jj)
+          zcmo(ji,jj,13) = fnsolar(ji,jj)
+          ! See thersf for the coefficient
+          zcmo(ji,jj,14) = - fsalt(ji,jj) * rday * ( sss_io(ji,jj) + epsi16 ) / soce
+          zcmo(ji,jj,15) = gtaux(ji,jj)
+          zcmo(ji,jj,16) = gtauy(ji,jj)
+          zcmo(ji,jj,17) = ( 1.0 - frld(ji,jj) ) * qsr_ice (ji,jj) + frld(ji,jj) * qsr_oce (ji,jj)
+          zcmo(ji,jj,18) = ( 1.0 - frld(ji,jj) ) * qnsr_ice(ji,jj) + frld(ji,jj) * qnsr_oce(ji,jj)
+          zcmo(ji,jj,19) = sprecip(ji,jj)
+       END DO
+    END DO
+    ! Cumulates values between outputs           
+    rcmoy(:,:,:)= rcmoy(:,:,:) + zcmo(:,:,:)
+    nmoyice = nmoyice + 1 
+    ! compute mean value if it is time to write on file
+    IF ( MOD(kt+nfice-1-nit000+1,nwrite) == 0 ) THEN
+       rcmoy(:,:,:) = rcmoy(:,:,:) / FLOAT(nmoyice)
+#else  
+       IF ( MOD(kt-nfice-1-nit000+1,nwrite) == 0 ) THEN 
+          !  case of instantaneaous output rcmoy(:,:, 1:jpnoumax ) = 0.e0
+          DO jj = 2 , jpjm1
+             DO ji = 2 , jpim1
+                zindh  = MAX( zzero , SIGN( zone , hicif(ji,jj) * (1.0 - frld(ji,jj) ) - 0.10 ) )
+                zinda  = MAX( zzero , SIGN( zone , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
+                zindb  = zindh * zinda
+                ztmu   = MAX( 0.5 * zone , ( tmu(ji,jj) + tmu(ji+1,jj) + tmu(ji,jj+1) + tmu(ji+1,jj+1) ) )
+                rcmoy(ji,jj,1)  = hsnif (ji,jj)
+                rcmoy(ji,jj,2)  = hicif (ji,jj)
+                rcmoy(ji,jj,3)  = hicifp(ji,jj)
+                rcmoy(ji,jj,4)  = frld  (ji,jj)
+                rcmoy(ji,jj,5)  = sist  (ji,jj)
+                rcmoy(ji,jj,6)  = fbif  (ji,jj)
+                rcmoy(ji,jj,7)  = zindb * (  u_ice(ji,jj  ) * tmu(ji,jj  ) + u_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                     + u_ice(ji,jj+1) * tmu(ji,jj+1) + u_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                     / ztmu
+
+                rcmoy(ji,jj,8)  = zindb * (  v_ice(ji,jj  ) * tmu(ji,jj  ) + v_ice(ji+1,jj  ) * tmu(ji+1,jj  )   &
+                     + v_ice(ji,jj+1) * tmu(ji,jj+1) + v_ice(ji+1,jj+1) * tmu(ji+1,jj+1) ) &
+                     / ztmu
+                rcmoy(ji,jj,9)  = sst_io(ji,jj)
+                rcmoy(ji,jj,10) = sss_io(ji,jj)
+
+                rcmoy(ji,jj,11) = fnsolar(ji,jj) + fsolar(ji,jj)
+                rcmoy(ji,jj,12) = fsolar (ji,jj)
+                rcmoy(ji,jj,13) = fnsolar(ji,jj)
+                ! See thersf for the coefficient
+                rcmoy(ji,jj,14) = - fsalt(ji,jj) * rday * ( sss_io(ji,jj) + epsi16 ) / soce
+                rcmoy(ji,jj,15) = gtaux(ji,jj)
+                rcmoy(ji,jj,16) = gtauy(ji,jj)
+                rcmoy(ji,jj,17) = ( 1.0 - frld(ji,jj) ) * qsr_ice (ji,jj) + frld(ji,jj) * qsr_oce (ji,jj)
+                rcmoy(ji,jj,18) = ( 1.0 - frld(ji,jj) ) * qnsr_ice(ji,jj) + frld(ji,jj) * qnsr_oce(ji,jj)
+                rcmoy(ji,jj,19) = sprecip(ji,jj)
+             END DO
+          END DO
+#endif
+
+          !
+          niter = niter + 1
+          DO jf = 1 , noumef
+             zfield(:,:) = (rcmoy(:,:,jf) * cmulti(jf) + cadd(jf)) * tmask(:,:,1)
+
+             IF ( jf == 7  .OR. jf == 8  .OR. jf == 15 .OR. jf == 16 ) THEN 
+                CALL lbc_lnk( zfield, 'T', -1. )
+             ELSE 
+                CALL lbc_lnk( zfield, 'T',  1. )
+             ENDIF
+             rcmoy(:,:,jf) = zfield(:,:)
+          END DO
+
+          IF (ll_dia_inst) THEN
+           clmode='instantaneous'
+          ELSE
+           WRITE(clmode,'(f5.1,a)' ) nwrite*rdt/86400.,' days average'
+          END IF
+          iyear = ndastp/10000
+          imon = (ndastp-iyear*10000)/100
+          iday = ndastp - imon*100 - iyear*10000
+          WRITE(clname,9000) TRIM(cexper),'ICEMOD',iyear,imon,iday
+          cltext=TRIM(cexper)//' ice modele output'//TRIM(clmode)
+          CALL dia_wri_dimg (clname, cltext, rcmoy, nwf , 'I', nsubindex)
+9000      FORMAT(a,"_",a,"_y",i4.4,"m",i2.2,"d",i2.2,".dimgproc")
+
+          rcmoy(:,:,:) = 0.0
+          nmoyice = 0 
+       END IF     !  MOD(kt+nfice-1-nit000+1, nwrite == 0 ) !
+
+     END SUBROUTINE lim_wri_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/par_ice_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/par_ice_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/par_ice_2.F90	(revision 823)
@@ -0,0 +1,28 @@
+MODULE par_ice_2
+#if defined key_lim2
+   !!======================================================================
+   !!                       ***  MODULE par_ice_2   ***
+   !! Sea-Ice model : definition of the parameters
+   !!======================================================================
+   !!----------------------------------------------------------------------
+   !!  LIM 2.0, UCL-LOCEAN-IPSL (2005)
+   !! $Header$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_oce
+
+   IMPLICIT NONE
+   PUBLIC               ! allows par_oce and par_kind to be known in ice modules
+
+   INTEGER, PUBLIC, PARAMETER ::   &  !:
+      jpkmax =  1    ,      &  !: ???
+      jpsmax =  2              !: ???
+
+   INTEGER, PUBLIC, PARAMETER ::   &  !: 
+      jplayers   = 2 ,           &  !: number of vertical ice layers
+      jplayersp1 = jplayers + 1     !: ???
+
+   !!======================================================================
+#endif
+END MODULE par_ice_2
Index: branches/dev_002_LIM/NEMO/LIM_SRC_2/thd_ice_2.F90
===================================================================
--- branches/dev_002_LIM/NEMO/LIM_SRC_2/thd_ice_2.F90	(revision 823)
+++ branches/dev_002_LIM/NEMO/LIM_SRC_2/thd_ice_2.F90	(revision 823)
@@ -0,0 +1,86 @@
+MODULE thd_ice_2
+#if defined key_lim2
+   !!======================================================================
+   !!                       ***  MODULE thd_ice_2  ***
+   !! LIM 2.0 sea-ice :   Ice thermodynamics in 1D
+   !!=====================================================================
+   !! History :
+   !!   2.0  !  02-11  (C. Ethe)  F90: Free form and module
+   !!----------------------------------------------------------------------
+   !!   LIM 2.0, UCL-LOCEAN-IPSL (2005)
+   !! $Header$
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+   !! * Modules used
+   USE par_ice_2
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! * Share Module variables
+   REAL(wp) , PUBLIC ::   & !!! ** ice-thermo namelist (namicethd) **
+      hmelt   = -0.15  ,  &  !: maximum melting at the bottom
+      hicmin  = 0.2    ,  &  !: ice th. corr. to max. ener. in brine pocket
+      hiclim  = 0.05   ,  &  !: minimum ice thickness
+      amax    = 0.999  ,  &  !: maximum lead fraction
+      swiqst  = 1.0    ,  &  !: energy stored in brine pocket (1) or not (0)
+      sbeta   = 1.0    ,  &  !: numerical scheme for diffusion in ice 
+      parlat  = 0.0    ,  &  !: percent. of energy used for lateral ablation
+      hakspl  = 0.5    ,  &  !: slope of distr. for Hakkinen-Mellro's lat. melt
+      hibspl  = 0.5    ,  &  !: slope of distribution for Hibler's lat. melt
+      exld    = 2.0    ,  &  !: exponent for leads-closure rate
+      hakdif  = 1.0    ,  &  !: coefficient for diffusions of ice and snow
+      thth    = 0.2    ,  &  !: thick. for comp. of eq. thermal conduct
+      hnzst   = 0.1    ,  &  !: thick. of the surf. layer in temp. comp.
+      parsub  = 1.0    ,  &  !: switch for snow sublimation or not
+      alphs   = 1.0          !: coef. for snow density when snow-ice formation
+
+   REAL(wp), PUBLIC, DIMENSION(2)  ::  &  !:   
+      hiccrit = (/0.3,0.3/)  !: ice th. for lateral accretion in the NH (SH) (m)
+
+   REAL(wp) , PUBLIC ::   &  !:
+      uscomi,             &  !: inverse of minimum lead fraction
+      cnscg                  !: ratio  rcpsn/rcpic
+
+   INTEGER , PUBLIC, DIMENSION(jpij) ::   &  !:
+      npb     ,   &   !: number of points where computations has to be done
+      npac            !: correspondance between the points
+
+   REAL(wp), PUBLIC, DIMENSION(jpij) ::   &  !: 
+      qldif_1d    ,     &  !: corresponding to the 2D var  qldif
+      qcmif_1d    ,     &  !: corresponding to the 2D var  qcmif
+      thcm_1d     ,     &  !:    "                  "      thcm
+      fstbif_1d   ,     &  !:    "                  "      fstric
+      fltbif_1d   ,     &  !:    "                  "      ffltbif
+      fscbq_1d    ,     &  !:    "                  "      fscmcbq
+      qsr_ice_1d  ,     &  !:    "                  "      qsr_ice
+      fr1_i0_1d   ,     &  !:    "                  "      fr1_i0
+      fr2_i0_1d   ,     &  !:    "                  "      fr2_i0
+      qnsr_ice_1d ,     &  !:    "                  "      qns_ice
+      qfvbq_1d    ,     &  !:    "                  "      qfvbq
+      sist_1d     ,     &  !:    "                  "      sist
+      tfu_1d      ,     &  !:    "                  "      tfu
+      sprecip_1d  ,     &  !:    "                  "      sprecip
+      h_snow_1d   ,     &  !:    "                  "      h_snow
+      h_ice_1d    ,     &  !:    "                  "      h_ice
+      frld_1d     ,     &  !:    "                  "      frld
+      qstbif_1d   ,     &  !:    "                  "      qstoif
+      fbif_1d     ,     &  !:    "                  "      fbif
+      rdmicif_1d  ,     &  !:    "                  "      rdmicif
+      rdmsnif_1d  ,     &  !:    "                  "      rdmsnif
+      qlbbq_1d    ,     &  !:    "                  "      qlbsbq
+      dmgwi_1d    ,     &  !:    "                  "      dmgwi
+      dvsbq_1d    ,     &  !:    "                  "      rdvosif
+      dvbbq_1d    ,     &  !:    "                  "      rdvobif
+      dvlbq_1d    ,     &  !:    "                  "      rdvolif
+      dvnbq_1d    ,     &  !:    "                  "      rdvolif
+      dqns_ice_1d ,     &  !:    "                  "      dqns_ice
+      qla_ice_1d  ,     &  !:    "                  "      qla_ice
+      dqla_ice_1d          !:    "                  "      dqla_ice
+
+   REAL(wp), PUBLIC, DIMENSION(jpij,jplayersp1) ::   &  !:
+      tbif_1d              !: corresponding to the 2D var  tbif
+
+   !!======================================================================
+#endif
+END MODULE thd_ice_2
