Index: branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90
===================================================================
--- branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 8326)
+++ branches/2017/dev_r8183_ICEMODEL/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 8327)
@@ -83,5 +83,5 @@
       !
       INTEGER  :: ji, jj, jk, jl   ! dummy loop indices
-      INTEGER  :: nbpb             ! nb of icy pts for vertical thermo calculations
+      INTEGER  :: nidx             ! nb of icy pts for vertical thermo calculations
       REAL(wp) :: zfric_u, zqld, zqfr, zqfr_neg
       REAL(wp) :: zvi_b, zsmv_b, zei_b, zfs_b, zfw_b, zft_b 
@@ -213,10 +213,10 @@
 
          ! select ice covered grid points
-         nbpb = 0
-         DO jj = 1, jpj
-            DO ji = 1, jpi
+         nidx = 0 ; idxice(:) = 0
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
                IF ( a_i(ji,jj,jl) > epsi10 ) THEN     
-                  nbpb      = nbpb  + 1
-                  npb(nbpb) = (jj - 1) * jpi + ji
+                  nidx         = nidx  + 1
+                  idxice(nidx) = (jj - 1) * jpi + ji
                ENDIF
             END DO
@@ -234,7 +234,7 @@
          ENDIF
 
-         IF( lk_mpp )         CALL mpp_ini_ice( nbpb , numout )
-
-         IF( nbpb > 0 ) THEN  ! If there is no ice, do nothing.
+         IF( lk_mpp )         CALL mpp_ini_ice( nidx , numout )
+
+         IF( nidx > 0 ) THEN  ! If there is no ice, do nothing.
             !                                                                
             s_i_new   (:) = 0._wp ; dh_s_tot (:) = 0._wp                     ! --- some init --- !
@@ -242,5 +242,5 @@
             dh_snowice(:) = 0._wp ; dh_i_sub (:) = 0._wp
 
-                              CALL lim_thd_1d2d( nbpb, jl, 1 )               ! --- Move to 1D arrays --- !
+                              CALL lim_thd_1d2d( nidx, jl, 1 )               ! --- Move to 1D arrays --- !
             !
             DO jk = 1, nlay_i                                                ! --- Change units from J/m2 to J/m3 --- !
@@ -251,17 +251,17 @@
             ENDDO
             !
-            IF( ln_limdH )    CALL lim_thd_dif( 1, nbpb )                    ! --- Ice/Snow Temperature profile --- !
-            !
-            IF( ln_limdH )    CALL lim_thd_dh( 1, nbpb )                     ! --- Ice/Snow thickness --- !    
-            !
-            IF( ln_limdH )    CALL lim_thd_ent( 1, nbpb, e_i_1d(1:nbpb,:) )  ! --- Ice enthalpy remapping --- !
-            !
-                              CALL lim_thd_sal( 1, nbpb )                    ! --- Ice salinity --- !    
-            !
-                              CALL lim_thd_temp( 1, nbpb )                   ! --- temperature update --- !
+            IF( ln_limdH )    CALL lim_thd_dif( 1, nidx )                    ! --- Ice/Snow Temperature profile --- !
+            !
+            IF( ln_limdH )    CALL lim_thd_dh( 1, nidx )                     ! --- Ice/Snow thickness --- !    
+            !
+            IF( ln_limdH )    CALL lim_thd_ent( 1, nidx, e_i_1d(1:nidx,:) )  ! --- Ice enthalpy remapping --- !
+            !
+                              CALL lim_thd_sal( 1, nidx )                    ! --- Ice salinity --- !    
+            !
+                              CALL lim_thd_temp( 1, nidx )                   ! --- temperature update --- !
             !
             IF( ln_limdH ) THEN
                IF ( ( nn_monocat == 1 .OR. nn_monocat == 4 ) .AND. jpl == 1 ) THEN
-                              CALL lim_thd_lam( 1, nbpb )                    ! --- extra lateral melting if monocat --- !
+                              CALL lim_thd_lam( 1, nidx )                    ! --- extra lateral melting if monocat --- !
                END IF
             END IF
@@ -274,5 +274,5 @@
             ENDDO
             !
-                              CALL lim_thd_1d2d( nbpb, jl, 2 )               ! --- Move to 2D arrays --- !
+                              CALL lim_thd_1d2d( nidx, jl, 2 )               ! --- Move to 2D arrays --- !
             !
             IF( lk_mpp )      CALL mpp_comm_free( ncomm_ice ) !RB necessary ??
@@ -282,4 +282,6 @@
 
       IF( ln_limdA)           CALL lim_thd_da                                ! --- lateral melting --- !
+
+      at_i(:,:)    = SUM( a_i(:,:,:), dim=3 )
 
       ! Change thickness to volume
@@ -404,5 +406,5 @@
 
 
-   SUBROUTINE lim_thd_1d2d( nbpb, jl, kn )
+   SUBROUTINE lim_thd_1d2d( nidx, jl, kn )
       !!-----------------------------------------------------------------------
       !!                   ***  ROUTINE lim_thd_1d2d *** 
@@ -411,5 +413,5 @@
       !!-----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kn       ! 1= from 2D to 1D   ;   2= from 1D to 2D
-      INTEGER, INTENT(in) ::   nbpb     ! size of 1D arrays
+      INTEGER, INTENT(in) ::   nidx     ! size of 1D arrays
       INTEGER, INTENT(in) ::   jl       ! ice cat
       !
@@ -421,143 +423,141 @@
       CASE( 1 )            ! from 2D to 1D
          !
-         CALL tab_2d_1d( nbpb, at_i_1d     (1:nbpb), at_i            , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, a_i_1d      (1:nbpb), a_i(:,:,jl)     , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, ht_i_1d     (1:nbpb), ht_i(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, ht_s_1d     (1:nbpb), ht_s(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
-         !
-         CALL tab_2d_1d( nbpb, t_su_1d     (1:nbpb), t_su(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, sm_i_1d     (1:nbpb), sm_i(:,:,jl)    , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d( nidx, at_i_1d     (1:nidx), at_i            , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, a_i_1d      (1:nidx), a_i(:,:,jl)     , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, ht_i_1d     (1:nidx), ht_i(:,:,jl)    , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, ht_s_1d     (1:nidx), ht_s(:,:,jl)    , jpi, jpj, idxice(1:nidx) )
+         !
+         CALL tab_2d_1d( nidx, t_su_1d     (1:nidx), t_su(:,:,jl)    , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, sm_i_1d     (1:nidx), sm_i(:,:,jl)    , jpi, jpj, idxice(1:nidx) )
          DO jk = 1, nlay_s
-            CALL tab_2d_1d( nbpb, t_s_1d(1:nbpb,jk), t_s(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
-            CALL tab_2d_1d( nbpb, e_s_1d(1:nbpb,jk), e_s(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nidx, t_s_1d(1:nidx,jk), t_s(:,:,jk,jl)  , jpi, jpj, idxice(1:nidx) )
+            CALL tab_2d_1d( nidx, e_s_1d(1:nidx,jk), e_s(:,:,jk,jl)  , jpi, jpj, idxice(1:nidx) )
          END DO
          DO jk = 1, nlay_i
-            CALL tab_2d_1d( nbpb, t_i_1d(1:nbpb,jk), t_i(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
-            CALL tab_2d_1d( nbpb, e_i_1d(1:nbpb,jk), e_i(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
-            CALL tab_2d_1d( nbpb, s_i_1d(1:nbpb,jk), s_i(:,:,jk,jl)  , jpi, jpj, npb(1:nbpb) )
-         END DO
-         !
-         CALL tab_2d_1d( nbpb, qprec_ice_1d(1:nbpb), qprec_ice(:,:) , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, qevap_ice_1d(1:nbpb), qevap_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, qsr_ice_1d (1:nbpb), qsr_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, fr1_i0_1d  (1:nbpb), fr1_i0          , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, fr2_i0_1d  (1:nbpb), fr2_i0          , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, qns_ice_1d (1:nbpb), qns_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, ftr_ice_1d (1:nbpb), ftr_ice(:,:,jl) , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, evap_ice_1d (1:nbpb), evap_ice(:,:,jl), jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, dqns_ice_1d(1:nbpb), dqns_ice(:,:,jl), jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, t_bo_1d     (1:nbpb), t_bo            , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, sprecip_1d (1:nbpb), sprecip         , jpi, jpj, npb(1:nbpb) ) 
-         CALL tab_2d_1d( nbpb, fhtur_1d   (1:nbpb), fhtur           , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, qlead_1d   (1:nbpb), qlead           , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, fhld_1d    (1:nbpb), fhld            , jpi, jpj, npb(1:nbpb) )
-         !
-         CALL tab_2d_1d( nbpb, wfx_snw_1d (1:nbpb), wfx_snw         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_snw_sum_1d(1:nbpb), wfx_snw_sum  , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_sub_1d (1:nbpb), wfx_sub         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_snw_sub_1d(1:nbpb), wfx_snw_sub  , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_ice_sub_1d(1:nbpb), wfx_ice_sub  , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_err_sub_1d(1:nbpb), wfx_err_sub  , jpi, jpj, npb(1:nbpb) )
-         !
-         CALL tab_2d_1d( nbpb, wfx_bog_1d (1:nbpb), wfx_bog         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_bom_1d (1:nbpb), wfx_bom         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_sum_1d (1:nbpb), wfx_sum         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_sni_1d (1:nbpb), wfx_sni         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_res_1d (1:nbpb), wfx_res         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, wfx_spr_1d (1:nbpb), wfx_spr         , jpi, jpj, npb(1:nbpb) )
-         !
-         CALL tab_2d_1d( nbpb, sfx_bog_1d (1:nbpb), sfx_bog         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, sfx_bom_1d (1:nbpb), sfx_bom         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, sfx_sum_1d (1:nbpb), sfx_sum         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, sfx_sni_1d (1:nbpb), sfx_sni         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, sfx_bri_1d (1:nbpb), sfx_bri         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, sfx_res_1d (1:nbpb), sfx_res         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, sfx_sub_1d (1:nbpb), sfx_sub         , jpi, jpj,npb(1:nbpb) )
-         !
-         CALL tab_2d_1d( nbpb, hfx_thd_1d (1:nbpb), hfx_thd         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_spr_1d (1:nbpb), hfx_spr         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_sum_1d (1:nbpb), hfx_sum         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_bom_1d (1:nbpb), hfx_bom         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_bog_1d (1:nbpb), hfx_bog         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_dif_1d (1:nbpb), hfx_dif         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_opw_1d (1:nbpb), hfx_opw         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_snw_1d (1:nbpb), hfx_snw         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_sub_1d (1:nbpb), hfx_sub         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_err_1d (1:nbpb), hfx_err         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_res_1d (1:nbpb), hfx_res         , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_err_dif_1d (1:nbpb), hfx_err_dif , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_err_rem_1d (1:nbpb), hfx_err_rem , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, hfx_out_1d (1:nbpb), hfx_out         , jpi, jpj, npb(1:nbpb) )
+            CALL tab_2d_1d( nidx, t_i_1d(1:nidx,jk), t_i(:,:,jk,jl)  , jpi, jpj, idxice(1:nidx) )
+            CALL tab_2d_1d( nidx, e_i_1d(1:nidx,jk), e_i(:,:,jk,jl)  , jpi, jpj, idxice(1:nidx) )
+            CALL tab_2d_1d( nidx, s_i_1d(1:nidx,jk), s_i(:,:,jk,jl)  , jpi, jpj, idxice(1:nidx) )
+         END DO
+         !
+         CALL tab_2d_1d( nidx, qprec_ice_1d(1:nidx), qprec_ice(:,:) , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, qevap_ice_1d(1:nidx), qevap_ice(:,:,jl) , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, qsr_ice_1d (1:nidx), qsr_ice(:,:,jl) , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, fr1_i0_1d  (1:nidx), fr1_i0          , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, fr2_i0_1d  (1:nidx), fr2_i0          , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, qns_ice_1d (1:nidx), qns_ice(:,:,jl) , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, ftr_ice_1d (1:nidx), ftr_ice(:,:,jl) , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, evap_ice_1d (1:nidx), evap_ice(:,:,jl), jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, dqns_ice_1d(1:nidx), dqns_ice(:,:,jl), jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, t_bo_1d     (1:nidx), t_bo            , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, sprecip_1d (1:nidx), sprecip         , jpi, jpj, idxice(1:nidx) ) 
+         CALL tab_2d_1d( nidx, fhtur_1d   (1:nidx), fhtur           , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, fhld_1d    (1:nidx), fhld            , jpi, jpj, idxice(1:nidx) )
+         !
+         CALL tab_2d_1d( nidx, wfx_snw_1d (1:nidx), wfx_snw         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_snw_sum_1d(1:nidx), wfx_snw_sum  , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_sub_1d (1:nidx), wfx_sub         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_snw_sub_1d(1:nidx), wfx_snw_sub  , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_ice_sub_1d(1:nidx), wfx_ice_sub  , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_err_sub_1d(1:nidx), wfx_err_sub  , jpi, jpj, idxice(1:nidx) )
+         !
+         CALL tab_2d_1d( nidx, wfx_bog_1d (1:nidx), wfx_bog         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_bom_1d (1:nidx), wfx_bom         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_sum_1d (1:nidx), wfx_sum         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_sni_1d (1:nidx), wfx_sni         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_res_1d (1:nidx), wfx_res         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, wfx_spr_1d (1:nidx), wfx_spr         , jpi, jpj, idxice(1:nidx) )
+         !
+         CALL tab_2d_1d( nidx, sfx_bog_1d (1:nidx), sfx_bog         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, sfx_bom_1d (1:nidx), sfx_bom         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, sfx_sum_1d (1:nidx), sfx_sum         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, sfx_sni_1d (1:nidx), sfx_sni         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, sfx_bri_1d (1:nidx), sfx_bri         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, sfx_res_1d (1:nidx), sfx_res         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, sfx_sub_1d (1:nidx), sfx_sub         , jpi, jpj,idxice(1:nidx) )
+         !
+         CALL tab_2d_1d( nidx, hfx_thd_1d (1:nidx), hfx_thd         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_spr_1d (1:nidx), hfx_spr         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_sum_1d (1:nidx), hfx_sum         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_bom_1d (1:nidx), hfx_bom         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_bog_1d (1:nidx), hfx_bog         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_dif_1d (1:nidx), hfx_dif         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_opw_1d (1:nidx), hfx_opw         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_snw_1d (1:nidx), hfx_snw         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_sub_1d (1:nidx), hfx_sub         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_err_1d (1:nidx), hfx_err         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_res_1d (1:nidx), hfx_res         , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_err_dif_1d (1:nidx), hfx_err_dif , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_err_rem_1d (1:nidx), hfx_err_rem , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, hfx_out_1d (1:nidx), hfx_out         , jpi, jpj, idxice(1:nidx) )
          !
          ! SIMIP diagnostics
-         CALL tab_2d_1d( nbpb, diag_fc_bo_1d   (1:nbpb), diag_fc_bo  , jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, diag_fc_su_1d   (1:nbpb), diag_fc_su  , jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d( nidx, diag_fc_bo_1d   (1:nidx), diag_fc_bo  , jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, diag_fc_su_1d   (1:nidx), diag_fc_su  , jpi, jpj, idxice(1:nidx) )
          ! ocean surface fields
-         CALL tab_2d_1d( nbpb, sst_1d(1:nbpb), sst_m, jpi, jpj, npb(1:nbpb) )
-         CALL tab_2d_1d( nbpb, sss_1d(1:nbpb), sss_m, jpi, jpj, npb(1:nbpb) )
+         CALL tab_2d_1d( nidx, sst_1d(1:nidx), sst_m, jpi, jpj, idxice(1:nidx) )
+         CALL tab_2d_1d( nidx, sss_1d(1:nidx), sss_m, jpi, jpj, idxice(1:nidx) )
          !
       CASE( 2 )            ! from 1D to 2D
          !
-         CALL tab_1d_2d( nbpb, at_i          , npb, at_i_1d    (1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, ht_i(:,:,jl)  , npb, ht_i_1d    (1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, ht_s(:,:,jl)  , npb, ht_s_1d    (1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, a_i (:,:,jl)  , npb, a_i_1d     (1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, t_su(:,:,jl)  , npb, t_su_1d    (1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, sm_i(:,:,jl)  , npb, sm_i_1d    (1:nbpb)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, at_i          , idxice, at_i_1d    (1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, ht_i(:,:,jl)  , idxice, ht_i_1d    (1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, ht_s(:,:,jl)  , idxice, ht_s_1d    (1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, a_i (:,:,jl)  , idxice, a_i_1d     (1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, t_su(:,:,jl)  , idxice, t_su_1d    (1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, sm_i(:,:,jl)  , idxice, sm_i_1d    (1:nidx)   , jpi, jpj )
          DO jk = 1, nlay_s
-            CALL tab_1d_2d( nbpb, t_s(:,:,jk,jl), npb, t_s_1d     (1:nbpb,jk), jpi, jpj)
-            CALL tab_1d_2d( nbpb, e_s(:,:,jk,jl), npb, e_s_1d     (1:nbpb,jk), jpi, jpj)
+            CALL tab_1d_2d( nidx, t_s(:,:,jk,jl), idxice, t_s_1d     (1:nidx,jk), jpi, jpj)
+            CALL tab_1d_2d( nidx, e_s(:,:,jk,jl), idxice, e_s_1d     (1:nidx,jk), jpi, jpj)
          END DO
          DO jk = 1, nlay_i
-            CALL tab_1d_2d( nbpb, t_i(:,:,jk,jl), npb, t_i_1d     (1:nbpb,jk), jpi, jpj)
-            CALL tab_1d_2d( nbpb, e_i(:,:,jk,jl), npb, e_i_1d     (1:nbpb,jk), jpi, jpj)
-            CALL tab_1d_2d( nbpb, s_i(:,:,jk,jl), npb, s_i_1d     (1:nbpb,jk), jpi, jpj)
-         END DO
-         CALL tab_1d_2d( nbpb, qlead         , npb, qlead_1d  (1:nbpb)   , jpi, jpj )
-         !
-         CALL tab_1d_2d( nbpb, wfx_snw       , npb, wfx_snw_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_snw_sum   , npb, wfx_snw_sum_1d(1:nbpb),jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_sub       , npb, wfx_sub_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_snw_sub   , npb, wfx_snw_sub_1d(1:nbpb), jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_ice_sub   , npb, wfx_ice_sub_1d(1:nbpb), jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_err_sub   , npb, wfx_err_sub_1d(1:nbpb), jpi, jpj )
-         !
-         CALL tab_1d_2d( nbpb, wfx_bog       , npb, wfx_bog_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_bom       , npb, wfx_bom_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_sum       , npb, wfx_sum_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_sni       , npb, wfx_sni_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_res       , npb, wfx_res_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, wfx_spr       , npb, wfx_spr_1d(1:nbpb)   , jpi, jpj )
-         !
-         CALL tab_1d_2d( nbpb, sfx_bog       , npb, sfx_bog_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, sfx_bom       , npb, sfx_bom_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, sfx_sum       , npb, sfx_sum_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, sfx_sni       , npb, sfx_sni_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, sfx_res       , npb, sfx_res_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, sfx_bri       , npb, sfx_bri_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, sfx_sub       , npb, sfx_sub_1d(1:nbpb)   , jpi, jpj )        
-         !
-         CALL tab_1d_2d( nbpb, hfx_thd       , npb, hfx_thd_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_spr       , npb, hfx_spr_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_sum       , npb, hfx_sum_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_bom       , npb, hfx_bom_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_bog       , npb, hfx_bog_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_dif       , npb, hfx_dif_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_opw       , npb, hfx_opw_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_snw       , npb, hfx_snw_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_sub       , npb, hfx_sub_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_err       , npb, hfx_err_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_res       , npb, hfx_res_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_err_rem   , npb, hfx_err_rem_1d(1:nbpb), jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_err_dif   , npb, hfx_err_dif_1d(1:nbpb), jpi, jpj )
-         CALL tab_1d_2d( nbpb, hfx_out       , npb, hfx_out_1d(1:nbpb)   , jpi, jpj )
-         !
-         CALL tab_1d_2d( nbpb, qns_ice(:,:,jl), npb, qns_ice_1d(1:nbpb) , jpi, jpj)
-         CALL tab_1d_2d( nbpb, ftr_ice(:,:,jl), npb, ftr_ice_1d(1:nbpb) , jpi, jpj )
+            CALL tab_1d_2d( nidx, t_i(:,:,jk,jl), idxice, t_i_1d     (1:nidx,jk), jpi, jpj)
+            CALL tab_1d_2d( nidx, e_i(:,:,jk,jl), idxice, e_i_1d     (1:nidx,jk), jpi, jpj)
+            CALL tab_1d_2d( nidx, s_i(:,:,jk,jl), idxice, s_i_1d     (1:nidx,jk), jpi, jpj)
+         END DO
+         !
+         CALL tab_1d_2d( nidx, wfx_snw       , idxice, wfx_snw_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_snw_sum   , idxice, wfx_snw_sum_1d(1:nidx),jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_sub       , idxice, wfx_sub_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_snw_sub   , idxice, wfx_snw_sub_1d(1:nidx), jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_ice_sub   , idxice, wfx_ice_sub_1d(1:nidx), jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_err_sub   , idxice, wfx_err_sub_1d(1:nidx), jpi, jpj )
+         !
+         CALL tab_1d_2d( nidx, wfx_bog       , idxice, wfx_bog_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_bom       , idxice, wfx_bom_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_sum       , idxice, wfx_sum_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_sni       , idxice, wfx_sni_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_res       , idxice, wfx_res_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, wfx_spr       , idxice, wfx_spr_1d(1:nidx)   , jpi, jpj )
+         !
+         CALL tab_1d_2d( nidx, sfx_bog       , idxice, sfx_bog_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, sfx_bom       , idxice, sfx_bom_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, sfx_sum       , idxice, sfx_sum_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, sfx_sni       , idxice, sfx_sni_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, sfx_res       , idxice, sfx_res_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, sfx_bri       , idxice, sfx_bri_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, sfx_sub       , idxice, sfx_sub_1d(1:nidx)   , jpi, jpj )        
+         !
+         CALL tab_1d_2d( nidx, hfx_thd       , idxice, hfx_thd_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_spr       , idxice, hfx_spr_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_sum       , idxice, hfx_sum_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_bom       , idxice, hfx_bom_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_bog       , idxice, hfx_bog_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_dif       , idxice, hfx_dif_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_opw       , idxice, hfx_opw_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_snw       , idxice, hfx_snw_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_sub       , idxice, hfx_sub_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_err       , idxice, hfx_err_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_res       , idxice, hfx_res_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_err_rem   , idxice, hfx_err_rem_1d(1:nidx), jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_err_dif   , idxice, hfx_err_dif_1d(1:nidx), jpi, jpj )
+         CALL tab_1d_2d( nidx, hfx_out       , idxice, hfx_out_1d(1:nidx)   , jpi, jpj )
+         !
+         CALL tab_1d_2d( nidx, qns_ice(:,:,jl), idxice, qns_ice_1d(1:nidx) , jpi, jpj)
+         CALL tab_1d_2d( nidx, ftr_ice(:,:,jl), idxice, ftr_ice_1d(1:nidx) , jpi, jpj )
          !
          ! SIMIP diagnostics         
-         CALL tab_1d_2d( nbpb, t_si(:,:,jl)   , npb, t_si_1d    (1:nbpb)     , jpi, jpj )
-         CALL tab_1d_2d( nbpb, diag_fc_bo     , npb, diag_fc_bo_1d(1:nbpb)   , jpi, jpj )
-         CALL tab_1d_2d( nbpb, diag_fc_su     , npb, diag_fc_su_1d(1:nbpb)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, t_si(:,:,jl)   , idxice, t_si_1d    (1:nidx)     , jpi, jpj )
+         CALL tab_1d_2d( nidx, diag_fc_bo     , idxice, diag_fc_bo_1d(1:nidx)   , jpi, jpj )
+         CALL tab_1d_2d( nidx, diag_fc_su     , idxice, diag_fc_su_1d(1:nidx)   , jpi, jpj )
       END SELECT
       !
