Index: /LMDZ5/trunk/libf/phylmd/cv3_routines.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/cv3_routines.F90	(revision 2457)
+++ /LMDZ5/trunk/libf/phylmd/cv3_routines.F90	(revision 2458)
@@ -75,4 +75,6 @@
     elcrit = 0.0003
     tlcrit = -55.0
+! CR+JYG: shedding coefficient (used when iflag_mix_adiab=1)
+    coef_peel = 0.25
 ! IM lu dans physiq.def via conf_phys.F90     epmax  = 0.993
 
@@ -121,4 +123,5 @@
     READ (99, *, END=9998) tau_stop
     READ (99, *, END=9998) ok_intermittent
+    READ (99, *, END=9998) coef_peel
 9998 CONTINUE
     CLOSE (99)
@@ -1951,16 +1954,26 @@
 ! ori      do 400 k=1,nlp
 ! ori       do 390 j=1,nlp
+!yor! commented original :
+!  DO j = 1, nl
+!    DO k = 1, nl
+!      DO i = 1, ncum
+!        qent(i, k, j) = rr(i, j)
+!        uent(i, k, j) = u(i, j)
+!        vent(i, k, j) = v(i, j)
+!        elij(i, k, j) = 0.0
+!!ym            ment(i,k,j)=0.0
+!!ym            sij(i,k,j)=0.0
+!      END DO
+!    END DO
+!  END DO
+!yor! optim :
   DO j = 1, nl
-    DO k = 1, nl
-      DO i = 1, ncum
-        qent(i, k, j) = rr(i, j)
-        uent(i, k, j) = u(i, j)
-        vent(i, k, j) = v(i, j)
-        elij(i, k, j) = 0.0
-!ym            ment(i,k,j)=0.0
-!ym            sij(i,k,j)=0.0
-      END DO
-    END DO
-  END DO
+     DO k = 1, nl
+        qent(1:ncum, k, j) = rr(1:ncum, j)
+        uent(1:ncum, k, j) = u(1:ncum, j)
+        vent(1:ncum, k, j) = v(1:ncum, j)
+     END DO
+  END DO
+  elij(1:ncum, 1:nl, 1:nl) = 0.
 
 !ym
@@ -2276,11 +2289,22 @@
 ! MAF: renormalisation de MENT
   CALL zilch(zm, nloc*na)
+
+!yor! commented orig
+!  DO jm = 1, nl
+!    DO im = 1, nl
+!      DO il = 1, ncum
+!        zm(il, im) = zm(il, im) + (1.-sij(il,im,jm))*ment(il, im, jm)
+!      END DO
+!    END DO
+!  END DO
+!yor! optim
   DO jm = 1, nl
-    DO im = 1, nl
-      DO il = 1, ncum
-        zm(il, im) = zm(il, im) + (1.-sij(il,im,jm))*ment(il, im, jm)
-      END DO
-    END DO
-  END DO
+     DO im = 1, nl
+        !DO il = 1, ncum
+        zm(1:ncum, im) = zm(1:ncum, im) + (1.-sij(1:ncum,im,jm))*ment(1:ncum, im, jm)
+        !END DO
+     END DO
+  END DO
+!!
 
   DO jm = 1, nl
@@ -2294,12 +2318,17 @@
   END DO
 
-  DO jm = 1, nl
-    DO im = 1, nl
-      DO il = 1, ncum
-        qents(il, im, jm) = qent(il, im, jm)
-        ments(il, im, jm) = ment(il, im, jm)
-      END DO
-    END DO
-  END DO
+
+!yor! commented original
+!  DO jm = 1, nl
+!    DO im = 1, nl
+!      DO il = 1, ncum
+!        qents(il, im, jm) = qent(il, im, jm)
+!        ments(il, im, jm) = ment(il, im, jm)
+!      END DO
+!    END DO
+!  END DO
+!yor! replaced
+  qents(1:ncum, 1:nl, 1:nl) = qent(1:ncum, 1:nl, 1:nl) !yor! ncum?=nloc , nd?=na  ??
+  ments(1:ncum, 1:nl, 1:nl) = ment(1:ncum, 1:nl, 1:nl) 
 
   RETURN
@@ -3298,12 +3327,14 @@
     END DO
 
-    DO k = 1, i
-      DO j = i + 1, nl + 1
-        DO il = 1, ncum
-          IF (i<=inb(il) .AND. j<=(inb(il)+1)) THEN
-            amp1(il) = amp1(il) + ment(il, k, j)
-          END IF
-        END DO
-      END DO
+    DO j = i + 1, nl + 1         
+       DO k = 1, i
+          !yor! reverted j and k loops 
+          DO il = 1, ncum
+!yor!        IF (i<=inb(il) .AND. j<=(inb(il)+1)) THEN ! the second condition implies the first !
+             IF (j<=(inb(il)+1)) THEN  
+                amp1(il) = amp1(il) + ment(il, k, j)
+             END IF
+          END DO
+       END DO
     END DO
 
@@ -3311,5 +3342,6 @@
       DO j = i, nl + 1 ! newvecto: nl au lieu nl+1?
         DO il = 1, ncum
-          IF (i<=inb(il) .AND. j<=inb(il)) THEN
+!yor!        IF (i<=inb(il) .AND. j<=inb(il)) THEN ! the second condition implies the 1st !
+             IF (j<=inb(il)) THEN   
             ad(il) = ad(il) + ment(il, j, k)
           END IF
@@ -3767,6 +3799,6 @@
     END DO
   END DO
-  DO i = 1, nl
-    DO j = 1, nl
+  DO j = 1, nl !yor! inverted i and j loops
+     DO i = 1, nl
       DO il = 1, ncum
         IF (iflag(il)<=1) THEN
@@ -3839,11 +3871,24 @@
   END DO
 
+!yor! commented original
+!  DO i = 1, nl
+!    DO k = i, nl
+!      DO n = 1, i - 1
+!        DO il = 1, ncum
+!          IF (i>=icb(il) .AND. i<=inb(il) .AND. k<=inb(il)) THEN
+!            up1(il, k, i) = up1(il, k, i) + ment(il, n, k)
+!            dn1(il, k, i) = dn1(il, k, i) - ment(il, k, n)
+!          END IF
+!        END DO
+!      END DO
+!    END DO
+!  END DO
+!yor! replaced with
   DO i = 1, nl
     DO k = i, nl
       DO n = 1, i - 1
         DO il = 1, ncum
-          IF (i>=icb(il) .AND. i<=inb(il) .AND. k<=inb(il)) THEN
-            up1(il, k, i) = up1(il, k, i) + ment(il, n, k)
-            dn1(il, k, i) = dn1(il, k, i) - ment(il, k, n)
+          IF (i>=icb(il) .AND. k<=inb(il)) THEN ! yor ! as i always <= k
+             up1(il, k, i) = up1(il, k, i) + ment(il, n, k)
           END IF
         END DO
@@ -3851,4 +3896,16 @@
     END DO
   END DO
+  DO i = 1, nl
+    DO n = 1, i - 1
+      DO k = i, nl
+        DO il = 1, ncum
+          IF (i>=icb(il) .AND. k<=inb(il)) THEN ! yor !  i always <= k
+             dn1(il, k, i) = dn1(il, k, i) - ment(il, k, n)
+          END IF
+        END DO
+      END DO
+    END DO
+  END DO
+!yor! end replace 
 
   DO i = 1, nl
Index: /LMDZ5/trunk/libf/phylmd/cv3p1_closure.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/cv3p1_closure.F90	(revision 2457)
+++ /LMDZ5/trunk/libf/phylmd/cv3p1_closure.F90	(revision 2458)
@@ -82,6 +82,9 @@
   REAL mad(nloc, nd), me(nloc, nd), betalim(nloc, nd), beta_coef(nloc, nd)
   REAL med(nloc, nd), md(nloc,nd)
-  REAL coef_peel
-  PARAMETER (coef_peel=0.25)
+!jyg<
+! coef_peel is now in the common cv3_param 
+!!  REAL coef_peel
+!!  PARAMETER (coef_peel=0.25)
+!>jyg
 
   REAL sigmax
Index: /LMDZ5/trunk/libf/phylmd/cv3p2_closure.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/cv3p2_closure.F90	(revision 2457)
+++ /LMDZ5/trunk/libf/phylmd/cv3p2_closure.F90	(revision 2458)
@@ -89,6 +89,9 @@
   REAL, DIMENSION (nloc, nd)                         :: mad, me, betalim, beta_coef
   REAL, DIMENSION (nloc, nd)                         :: med, md
-  REAL                                               :: coef_peel
-  PARAMETER (coef_peel=0.25)
+!jyg<
+! coef_peel is now in the common cv3_param 
+!!  REAL                                               :: coef_peel
+!!  PARAMETER (coef_peel=0.25)
+!>jyg
 
   REAL                                               :: sigmax
Index: /LMDZ5/trunk/libf/phylmd/cv3param.h
===================================================================
--- /LMDZ5/trunk/libf/phylmd/cv3param.h	(revision 2457)
+++ /LMDZ5/trunk/libf/phylmd/cv3param.h	(revision 2458)
@@ -14,4 +14,5 @@
       real pbcrit, ptcrit
       real elcrit, tlcrit
+      real coef_peel
       real omtrain
       real dtovsh, dpbase, dttrig
@@ -25,4 +26,5 @@
                       ,pbcrit, ptcrit &
                       ,elcrit, tlcrit &
+                      ,coef_peel &
                       ,omtrain &
                       ,dtovsh, dpbase, dttrig &
