Index: trunk/NEMO/LIM_SRC_3/limitd_me.F90
===================================================================
--- trunk/NEMO/LIM_SRC_3/limitd_me.F90	(revision 867)
+++ trunk/NEMO/LIM_SRC_3/limitd_me.F90	(revision 868)
@@ -977,19 +977,21 @@
       IF ( raftswi .EQ. 1 ) THEN
 
-      DO jl = 1, jpl
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               IF ( aridge(ji,jj,jl) + araft(ji,jj,jl) - athorn(ji,jj,jl) .GT. &
-               epsi11 ) THEN
-                  WRITE(numout,*) ' ALERTE 96 : wrong participation function ... '
-                  WRITE(numout,*) ' ji, jj, jl : ', ji, jj, jl
-                  WRITE(numout,*) ' lat, lon   : ', gphit(ji,jj), glamt(ji,jj)
-                  WRITE(numout,*) ' aridge     : ', aridge(ji,jj,1:jpl)
-                  WRITE(numout,*) ' araft      : ', araft(ji,jj,1:jpl)
-                  WRITE(numout,*) ' athorn     : ', athorn(ji,jj,1:jpl)
-               ENDIF
+      IF( MAXVAL(aridge + araft - athorn(:,:,1:jpl)) .GT. epsi11 ) THEN
+         DO jl = 1, jpl
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF ( aridge(ji,jj,jl) + araft(ji,jj,jl) - athorn(ji,jj,jl) .GT. &
+                  epsi11 ) THEN
+                     WRITE(numout,*) ' ALERTE 96 : wrong participation function ... '
+                     WRITE(numout,*) ' ji, jj, jl : ', ji, jj, jl
+                     WRITE(numout,*) ' lat, lon   : ', gphit(ji,jj), glamt(ji,jj)
+                     WRITE(numout,*) ' aridge     : ', aridge(ji,jj,1:jpl)
+                     WRITE(numout,*) ' araft      : ', araft(ji,jj,1:jpl)
+                     WRITE(numout,*) ' athorn     : ', athorn(ji,jj,1:jpl)
+                  ENDIF
+               END DO
             END DO
          END DO
-      END DO
+      ENDIF
 
       ENDIF
@@ -1238,5 +1240,4 @@
                vsnon_init(ji,jj,jl) = v_s(ji,jj,jl)
 
-               esnon_init(ji,jj,jl) = e_s(ji,jj,1,jl)
                smv_i_init(ji,jj,jl) = smv_i(ji,jj,jl)
                oa_i_init (ji,jj,jl) = oa_i(ji,jj,jl)
@@ -1244,4 +1245,6 @@
          END DO ! jj
       END DO !jl
+
+      esnon_init(:,:,:) = e_s(:,:,1,:)
             
       DO jl = 1, jpl  
@@ -1283,4 +1286,5 @@
          large_afrft = .false.
 
+!CDIR NODEP
          DO ij = 1, icells
             ji = indxi(ij)
@@ -1426,4 +1430,5 @@
       !--------------------------------------------------------------------
          DO jk = 1, nlay_i
+!CDIR NODEP
             DO ij = 1, icells
             ji = indxi(ij)
@@ -1468,4 +1473,5 @@
          IF ( con_i ) THEN
             DO jk = 1, nlay_i
+!CDIR NODEP
                DO ij = 1, icells
                   ji = indxi(ij)
@@ -1478,4 +1484,5 @@
 
          IF (large_afrac) THEN  ! there is a bug
+!CDIR NODEP
             DO ij = 1, icells
                ji = indxi(ij)
@@ -1490,4 +1497,5 @@
          ENDIF                  ! large_afrac
          IF (large_afrft) THEN  ! there is a bug
+!CDIR NODEP
             DO ij = 1, icells
                ji = indxi(ij)
@@ -1508,4 +1516,5 @@
          DO jl2  = ice_cat_bounds(1,1), ice_cat_bounds(1,2) 
          ! over categories to which ridged ice is transferred
+!CDIR NODEP
             DO ij = 1, icells
                ji = indxi(ij)
@@ -1542,4 +1551,5 @@
             ! Transfer ice energy to category jl2 by ridging
             DO jk = 1, nlay_i
+!CDIR NODEP
                DO ij = 1, icells
                   ji = indxi(ij)
@@ -1555,4 +1565,5 @@
          DO jl2  = ice_cat_bounds(1,1), ice_cat_bounds(1,2) 
 
+!CDIR NODEP
             DO ij = 1, icells
                ji = indxi(ij)
@@ -1579,4 +1590,5 @@
             ! Transfer rafted ice energy to category jl2 
             DO jk = 1, nlay_i
+!CDIR NODEP
                DO ij = 1, icells
                   ji = indxi(ij)
@@ -1729,10 +1741,13 @@
            jl,     & ! ice category index
            jk,     & ! ice layer index
-           icells, & ! number of cells with ice to zap
-           ij        ! combined i/j horizontal index
-
-      INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: &
-           indxi,  & ! compressed indices for i/j directions
-           indxj
+!           ij,     &   ! combined i/j horizontal index
+           icells      ! number of cells with ice to zap
+
+!      INTEGER, DIMENSION(1:(jpi+1)*(jpj+1)) :: &
+!           indxi,  & ! compressed indices for i/j directions
+!           indxj
+
+      INTEGER, DIMENSION(jpi,jpj) :: zmask
+
 
       REAL(wp) :: &
@@ -1745,13 +1760,21 @@
       ! Abort model in case of negative area.
       !-----------------------------------------------------------------
-
-         icells = 0
-         DO jj = 1, jpj
+         IF( MAXVAL(a_i(:,:,jl)) .LT. -epsi11 ) THEN
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  IF ( a_i(ji,jj,jl) .LT. -epsi11 ) THEN
+                     WRITE (numout,*) ' ALERTE 98 ' 
+                     WRITE (numout,*) ' Negative ice area: ji, jj, jl: ', ji, jj,jl
+                     WRITE (numout,*) ' a_i    ', a_i(ji,jj,jl)
+                  ENDIF
+               END DO
+            END DO 
+         ENDIF
+ 
+       icells = 0
+       zmask = 0.e0
+       DO jj = 1, jpj
          DO ji = 1, jpi
-            IF ( a_i(ji,jj,jl) .LT. -1.0e-11 ) THEN 
-               WRITE (numout,*) ' ALERTE 98 '
-               WRITE (numout,*) ' Negative ice area: ji, jj, jl: ', ji, jj,jl 
-               WRITE (numout,*) ' a_i    ', a_i(ji,jj,jl)
-            ELSEIF ( ( a_i(ji,jj,jl) .GE. -epsi11 .AND. a_i(ji,jj,jl) .LT. 0.0)       &
+            IF ( ( a_i(ji,jj,jl) .GE. -epsi11 .AND. a_i(ji,jj,jl) .LT. 0.0)       &
                                          .OR.                                         &
                      ( a_i(ji,jj,jl) .GT. 0.0     .AND. a_i(ji,jj,jl) .LE. 1.0e-11 )  &
@@ -1761,11 +1784,9 @@
                                          .OR.                                         &
                      ( v_i(ji,jj,jl) .GT. 0.0     .AND. v_i(ji,jj,jl) .LT. 1.e-12 ) ) THEN
-               icells = icells + 1
-               indxi(icells) = ji
-               indxj(icells) = jj
+                zmask(ji,jj) = 1
             ENDIF
          END DO
          END DO
-         WRITE(numout,*) icells, ' cells of ice zapped in the ocean '
+         WRITE(numout,*) SUM(zmask), ' cells of ice zapped in the ocean '
 
       !-----------------------------------------------------------------
@@ -1774,19 +1795,17 @@
 
          DO jk = 1, nlay_i
-            DO ij = 1, icells
-               ji = indxi(ij)
-               jj = indxj(ij)
+            DO jj = 1 , jpj
+               DO ji = 1 , jpi
 
                xtmp = e_i(ji,jj,jk,jl) / area(ji,jj) / rdt_ice
                xtmp = xtmp * unit_fac
 !              fheat_res(ji,jj) = fheat_res(ji,jj) - xtmp
-               e_i(ji,jj,jk,jl) = 0.0
-
-            END DO           ! ij
+               e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * ( 1 - zmask(ji,jj) )
+               END DO           ! ji
+            END DO           ! jj
          END DO           ! jk
 
-         DO ij = 1, icells
-            ji = indxi(ij)
-            jj = indxj(ij)
+         DO jj = 1 , jpj
+            DO ji = 1 , jpi
 
       !-----------------------------------------------------------------
@@ -1803,5 +1822,7 @@
 !           fheat_res(ji,jj) = fheat_res(ji,jj) - xtmp
 
-            t_s(ji,jj,1,jl) = rtt
+            xtmp = ( rhosn*cpic*( rtt-t_s(ji,jj,1,jl) ) + rhosn*lfus ) / rdt_ice !RB   ???????
+
+            t_s(ji,jj,1,jl) = rtt * zmask(ji,jj) + t_s(ji,jj,1,jl) * ( 1 - zmask(ji,jj) )
 
       !-----------------------------------------------------------------
@@ -1822,13 +1843,14 @@
 !           fsalt_hist(i,j) = fsalt_hist(i,j) + xtmp
 
-            ato_i(ji,jj)   = ato_i(ji,jj) + a_i(ji,jj,jl)
-            a_i(ji,jj,jl)  = 0.0
-            v_i(ji,jj,jl)  = 0.0
-            v_s(ji,jj,jl)  = 0.0
-            t_su(ji,jj,jl) = t_bo(ji,jj)
-            oa_i(ji,jj,jl)  = 0.0
-            smv_i(ji,jj,jl) = 0.0
-
-         END DO                 ! ij
+            ato_i(ji,jj)   = a_i(ji,jj,jl)  * zmask(ji,jj) + ato_i(ji,jj)
+            a_i(ji,jj,jl)  = a_i(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+            v_i(ji,jj,jl)  = v_i(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+            v_s(ji,jj,jl)  = v_s(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+            t_su(ji,jj,jl) = t_su(ji,jj,jl) * (1 -zmask(ji,jj) ) + t_bo(ji,jj) * zmask(ji,jj)
+            oa_i(ji,jj,jl) = oa_i(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+            smv_i(ji,jj,jl) = smv_i(ji,jj,jl) * ( 1 - zmask(ji,jj) )
+
+            END DO                 ! ji
+         END DO                 ! jj
 
       END DO                 ! jl 
