Index: branches/UKMO/dev_r5107_mld_zint/NEMOGCM/NEMO/LIM_SRC_3/limthd_dh.F90
===================================================================
--- branches/UKMO/dev_r5107_mld_zint/NEMOGCM/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 5450)
+++ branches/UKMO/dev_r5107_mld_zint/NEMOGCM/NEMO/LIM_SRC_3/limthd_dh.F90	(revision 5534)
@@ -30,5 +30,5 @@
 
    PUBLIC   lim_thd_dh      ! called by lim_thd
-   PUBLIC   lim_thd_snwblow ! called in sbcblk/sbccpl and here
+   PUBLIC   lim_thd_snwblow ! called in sbcblk/sbcclio/sbccpl and here
 
    INTERFACE lim_thd_snwblow
@@ -122,24 +122,20 @@
       END SELECT
 
-      CALL wrk_alloc( jpij, zqprec, zq_su, zq_bo, zf_tt, zq_rema )
-      CALL wrk_alloc( jpij, zdh_s_mel, zdh_s_pre, zdh_s_sub, zqh_i, zqh_s, zq_s, zsnw )
+      CALL wrk_alloc( jpij, zqprec, zq_su, zq_bo, zf_tt, zq_rema, zsnw )
+      CALL wrk_alloc( jpij, zdh_s_mel, zdh_s_pre, zdh_s_sub, zqh_i, zqh_s, zq_s )
       CALL wrk_alloc( jpij, nlay_i, zdeltah, zh_i )
       CALL wrk_alloc( jpij, nlay_i, icount )
-      
+       
       dh_i_surf  (:) = 0._wp ; dh_i_bott  (:) = 0._wp ; dh_snowice(:) = 0._wp
       dsm_i_se_1d(:) = 0._wp ; dsm_i_si_1d(:) = 0._wp   
- 
-      zqprec (:) = 0._wp ; zq_su  (:) = 0._wp ; zq_bo  (:) = 0._wp ; zf_tt  (:) = 0._wp
-      zq_rema(:) = 0._wp
-
-      zdh_s_pre(:) = 0._wp
-      zdh_s_mel(:) = 0._wp
-      zdh_s_sub(:) = 0._wp
-      zqh_s    (:) = 0._wp      
-      zqh_i    (:) = 0._wp   
-
-      zh_i      (:,:) = 0._wp       
-      zdeltah   (:,:) = 0._wp       
-      icount    (:,:) = 0
+
+      zqprec   (:) = 0._wp ; zq_su    (:) = 0._wp ; zq_bo    (:) = 0._wp ; zf_tt(:) = 0._wp
+      zq_rema  (:) = 0._wp ; zsnw     (:) = 0._wp
+      zdh_s_mel(:) = 0._wp ; zdh_s_pre(:) = 0._wp ; zdh_s_sub(:) = 0._wp ; zqh_i(:) = 0._wp
+      zqh_s    (:) = 0._wp ; zq_s     (:) = 0._wp     
+
+      zdeltah(:,:) = 0._wp ; zh_i(:,:) = 0._wp       
+      icount (:,:) = 0
+
 
       ! Initialize enthalpy at nlay_i+1
@@ -223,6 +219,7 @@
       ! Martin Vancoppenolle, December 2006
 
+      CALL lim_thd_snwblow( 1. - at_i_1d(kideb:kiut), zsnw(kideb:kiut) ) ! snow distribution over ice after wind blowing
+
       zdeltah(:,:) = 0._wp
-      CALL lim_thd_snwblow( 1. - at_i_1d, zsnw ) ! snow distribution over ice after wind blowing
       DO ji = kideb, kiut
          !-----------
@@ -689,6 +686,6 @@
       WHERE( ht_i_1d == 0._wp ) a_i_1d = 0._wp
       
-      CALL wrk_dealloc( jpij, zqprec, zq_su, zq_bo, zf_tt, zq_rema )
-      CALL wrk_dealloc( jpij, zdh_s_mel, zdh_s_pre, zdh_s_sub, zqh_i, zqh_s, zq_s, zsnw )
+      CALL wrk_dealloc( jpij, zqprec, zq_su, zq_bo, zf_tt, zq_rema, zsnw )
+      CALL wrk_dealloc( jpij, zdh_s_mel, zdh_s_pre, zdh_s_sub, zqh_i, zqh_s, zq_s )
       CALL wrk_dealloc( jpij, nlay_i, zdeltah, zh_i )
       CALL wrk_dealloc( jpij, nlay_i, icount )
@@ -703,12 +700,12 @@
    !!--------------------------------------------------------------------------
    SUBROUTINE lim_thd_snwblow_2d( pin, pout )
-      REAL(wp), DIMENSION(:,:), INTENT(in)  :: pin   ! previous fraction lead ( pfrld or (1. - a_i_b) )
-      REAL(wp), DIMENSION(:,:), INTENT(out) :: pout
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) :: pin   ! previous fraction lead ( pfrld or (1. - a_i_b) )
+      REAL(wp), DIMENSION(:,:), INTENT(inout) :: pout
       pout = ( 1._wp - ( pin )**rn_betas )
    END SUBROUTINE lim_thd_snwblow_2d
 
    SUBROUTINE lim_thd_snwblow_1d( pin, pout )
-      REAL(wp), DIMENSION(:), INTENT(in)  :: pin
-      REAL(wp), DIMENSION(:), INTENT(out) :: pout
+      REAL(wp), DIMENSION(:), INTENT(in   ) :: pin
+      REAL(wp), DIMENSION(:), INTENT(inout) :: pout
       pout = ( 1._wp - ( pin )**rn_betas )
    END SUBROUTINE lim_thd_snwblow_1d
Index: branches/UKMO/dev_r5107_mld_zint/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90
===================================================================
--- branches/UKMO/dev_r5107_mld_zint/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90	(revision 5450)
+++ branches/UKMO/dev_r5107_mld_zint/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90	(revision 5534)
@@ -756,5 +756,9 @@
 
       ! --- diagnose the change in non-solar flux due to surface temperature change --- !
-      IF ( ln_it_qnsice ) hfx_err_dif_1d(:) = hfx_err_dif_1d(:) - ( qns_ice_1d(:)  - zqns_ice_b(:) ) * a_i_1d(:) 
+      IF ( ln_it_qnsice ) THEN
+         DO ji = kideb, kiut
+            hfx_err_dif_1d(ji) = hfx_err_dif_1d(ji) - ( qns_ice_1d(ji)  - zqns_ice_b(ji) ) * a_i_1d(ji) 
+         END DO
+      END IF
 
       ! --- diag conservation imbalance on heat diffusion - PART 2 --- !
@@ -790,5 +794,5 @@
       CALL wrk_dealloc( jpij, numeqmin, numeqmax )
       CALL wrk_dealloc( jpij, isnow, ztsub, ztsubit, zh_i, zh_s, zfsw )
-      CALL wrk_dealloc( jpij, zf, dzf, zerrit, zdifcase, zftrice, zihic, zghe )
+      CALL wrk_dealloc( jpij, zf, dzf, zqns_ice_b, zerrit, zdifcase, zftrice, zihic, zghe )
       CALL wrk_dealloc( jpij,nlay_i+1, ztcond_i, zradtr_i, zradab_i, zkappa_i, ztib, zeta_i, ztitemp, z_i, zspeche_i, kjstart = 0 )
       CALL wrk_dealloc( jpij,nlay_s+1,           zradtr_s, zradab_s, zkappa_s, ztsb, zeta_s, ztstemp, z_s, kjstart = 0 )
Index: branches/UKMO/dev_r5107_mld_zint/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90
===================================================================
--- branches/UKMO/dev_r5107_mld_zint/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 5450)
+++ branches/UKMO/dev_r5107_mld_zint/NEMOGCM/NEMO/LIM_SRC_3/limwri.F90	(revision 5534)
@@ -60,5 +60,5 @@
       REAL(wp) ::  z1_365
       REAL(wp) ::  ztmp
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zoi, zei
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zoi, zei, zt_i, zt_s
       REAL(wp), POINTER, DIMENSION(:,:)   ::  z2d, z2da, z2db, zswi    ! 2D workspace
       !!-------------------------------------------------------------------
@@ -66,5 +66,5 @@
       IF( nn_timing == 1 )  CALL timing_start('limwri')
 
-      CALL wrk_alloc( jpi, jpj, jpl, zoi, zei )
+      CALL wrk_alloc( jpi, jpj, jpl, zoi, zei, zt_i, zt_s )
       CALL wrk_alloc( jpi, jpj     , z2d, z2da, z2db, zswi )
 
@@ -243,4 +243,16 @@
       CALL iom_put( "snowthic_cat"     , ht_s        )        ! snow depth for categories
       CALL iom_put( "salinity_cat"     , sm_i        )        ! salinity for categories
+
+      ! ice temperature
+      IF ( iom_use( "icetemp_cat" ) ) THEN 
+         zt_i(:,:,:) = SUM( t_i(:,:,:,:), dim=3 ) * r1_nlay_i
+         CALL iom_put( "icetemp_cat"   , zt_i - rt0  )
+      ENDIF
+      
+      ! snow temperature
+      IF ( iom_use( "snwtemp_cat" ) ) THEN 
+         zt_s(:,:,:) = SUM( t_s(:,:,:,:), dim=3 ) * r1_nlay_s
+         CALL iom_put( "snwtemp_cat"   , zt_s - rt0  )
+      ENDIF
 
       ! Compute ice age
@@ -280,5 +292,5 @@
       !     not yet implemented
       
-      CALL wrk_dealloc( jpi, jpj, jpl, zoi, zei )
+      CALL wrk_dealloc( jpi, jpj, jpl, zoi, zei, zt_i, zt_s )
       CALL wrk_dealloc( jpi, jpj     , z2d, zswi, z2da, z2db )
 
