Index: LMDZ.3.3/branches/rel-LF/libf/phylmd/cv3_routines.F
===================================================================
--- LMDZ.3.3/branches/rel-LF/libf/phylmd/cv3_routines.F	(revision 486)
+++ LMDZ.3.3/branches/rel-LF/libf/phylmd/cv3_routines.F	(revision 495)
@@ -804,16 +804,15 @@
  110  continue
 
-      do 121 j=1,ntra
-ccccc      do 111 k=1,nl+1
-      do 111 k=1,nd
-       nn=0
-      do 101 i=1,len
-      if(iflag1(i).eq.0)then
-       nn=nn+1
-       tra(nn,k,j)=tra1(i,k,j)
-      endif
- 101  continue
- 111  continue
- 121  continue
+c      do 121 j=1,ntra
+c      do 111 k=1,nd
+c       nn=0
+c      do 101 i=1,len
+c      if(iflag1(i).eq.0)then
+c       nn=nn+1
+c       tra(nn,k,j)=tra1(i,k,j)
+c      endif
+c 101  continue
+c 111  continue
+c 121  continue
 
       if (nn.ne.ncum) then
@@ -1493,13 +1492,13 @@
  400  continue
 
-      do k=1,ntra
-       do j=1,nd  ! instead nlp
-        do i=1,nd ! instead nlp
-         do il=1,ncum
-            traent(il,i,j,k)=tra(il,j,k)
-         enddo
-        enddo
-       enddo
-      enddo
+c      do k=1,ntra
+c       do j=1,nd  ! instead nlp
+c        do i=1,nd ! instead nlp
+c         do il=1,ncum
+c            traent(il,i,j,k)=tra(il,j,k)
+c         enddo
+c        enddo
+c       enddo
+c      enddo
       zm(:,:)=0.
 
@@ -1557,15 +1556,15 @@
  710  continue
 
-       do k=1,ntra
-        do j=minorig,nl
-         do il=1,ncum
-          if( (i.ge.icb(il)).and.(i.le.inb(il)).and.
-     :       (j.ge.(icb(il)-1)).and.(j.le.inb(il)))then
-            traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k)
-     :            +(1.-sij(il,i,j))*tra(il,nk(il),k)
-          endif
-         enddo
-        enddo
-       enddo
+c       do k=1,ntra
+c        do j=minorig,nl
+c         do il=1,ncum
+c          if( (i.ge.icb(il)).and.(i.le.inb(il)).and.
+c     :       (j.ge.(icb(il)-1)).and.(j.le.inb(il)))then
+c            traent(il,i,j,k)=sij(il,i,j)*tra(il,i,k)
+c     :            +(1.-sij(il,i,j))*tra(il,nk(il),k)
+c          endif
+c         enddo
+c        enddo
+c       enddo
 
 c
@@ -1590,13 +1589,13 @@
  750  continue
  
-      do j=1,ntra
-       do i=minorig+1,nl
-        do il=1,ncum
-         if (i.ge.icb(il) .and. i.le.inb(il) .and. nent(il,i).eq.0) then
-          traent(il,i,i,j)=tra(il,nk(il),j)
-         endif
-        enddo
-       enddo
-      enddo
+c      do j=1,ntra
+c       do i=minorig+1,nl
+c        do il=1,ncum
+c         if (i.ge.icb(il) .and. i.le.inb(il) .and. nent(il,i).eq.0) then
+c          traent(il,i,i,j)=tra(il,nk(il),j)
+c         endif
+c        enddo
+c       enddo
+c      enddo
 
       do 100 j=minorig,nl
@@ -1764,13 +1763,12 @@
       enddo ! il
 
-      do j=1,ntra
-       do il=1,ncum
-        if ( i.ge.icb(il) .and. i.le.inb(il) .and. lwork(il)
-     :     .and. csum(il,i).lt.m(il,i) ) then
-         traent(il,i,i,j)=tra(il,nk(il),j)
-        endif
-       enddo
-      enddo
-
+c      do j=1,ntra
+c       do il=1,ncum
+c        if ( i.ge.icb(il) .and. i.le.inb(il) .and. lwork(il)
+c     :     .and. csum(il,i).lt.m(il,i) ) then
+c         traent(il,i,i,j)=tra(il,nk(il),j)
+c        endif
+c       enddo
+c      enddo
 789   continue
 c      
@@ -1869,11 +1867,11 @@
         enddo
 
-        do k=1,ntra
-         do i=1,nd
-          do il=1,ncum
-           trap(il,i,k)=tra(il,i,k)
-          enddo
-         enddo
-        enddo
+c        do k=1,ntra
+c         do i=1,nd
+c          do il=1,ncum
+c           trap(il,i,k)=tra(il,i,k)
+c          enddo
+c         enddo
+c        enddo
 
 c
@@ -2103,10 +2101,10 @@
       vp(il,i)=vp(il,i)/mp(il,i)
 
-      do j=1,ntra
-      trap(il,i,j)=trap(il,i+1,j)*mp(il,i+1)
+c      do j=1,ntra
+c      trap(il,i,j)=trap(il,i+1,j)*mp(il,i+1)
 ctestmaf     :            +trap(il,i,j)*(mp(il,i)-mp(il,i+1))
-     :            +tra(il,i,j)*(mp(il,i)-mp(il,i+1))
-      trap(il,i,j)=trap(il,i,j)/mp(il,i)
-      end do
+c     :            +tra(il,i,j)*(mp(il,i)-mp(il,i+1))
+c      trap(il,i,j)=trap(il,i,j)/mp(il,i)
+c      end do
 
       else
@@ -2125,7 +2123,7 @@
        vp(il,i)=vp(il,i+1)
 
-       do j=1,ntra
-       trap(il,i,j)=trap(il,i+1,j)
-       end do
+c       do j=1,ntra
+c       trap(il,i,j)=trap(il,i+1,j)
+c       end do
 
        endif
@@ -2226,11 +2224,11 @@
       enddo
 
-      do j=1,ntra
-       do i=1,nd
-        do il=1,ncum
-          ftra(il,i,j)=0.0
-        enddo
-       enddo 
-      enddo
+c      do j=1,ntra
+c       do i=1,nd
+c        do il=1,ncum
+c          ftra(il,i,j)=0.0
+c        enddo
+c       enddo 
+c      enddo
 
       do i=1,nl
@@ -2330,17 +2328,17 @@
       enddo ! il
 
-      do j=1,ntra
-       do il=1,ncum
-        if (cvflag_grav) then
-         ftra(il,1,j)=ftra(il,1,j)+0.01*grav*work(il)
-     :                     *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))
-     :             +am(il)*(tra(il,2,j)-tra(il,1,j)))
-        else
-         ftra(il,1,j)=ftra(il,1,j)+0.1*work(il)
-     :                     *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))
-     :             +am(il)*(tra(il,2,j)-tra(il,1,j)))
-        endif
-       enddo
-      enddo
+c      do j=1,ntra
+c       do il=1,ncum
+c        if (cvflag_grav) then
+c         ftra(il,1,j)=ftra(il,1,j)+0.01*grav*work(il)
+c     :                     *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))
+c     :             +am(il)*(tra(il,2,j)-tra(il,1,j)))
+c        else
+c         ftra(il,1,j)=ftra(il,1,j)+0.1*work(il)
+c     :                     *(mp(il,2)*(trap(il,2,j)-tra(il,1,j))
+c     :             +am(il)*(tra(il,2,j)-tra(il,1,j)))
+c        endif
+c       enddo
+c      enddo
 
       do j=2,nl
@@ -2366,21 +2364,21 @@
       enddo
 
-      do k=1,ntra
-       do j=2,nl
-        do il=1,ncum
-         if (j.le.inb(il)) then
-
-          if (cvflag_grav) then
-           ftra(il,1,k)=ftra(il,1,k)+0.01*grav*work(il)*ment(il,j,1)
-     :                *(traent(il,j,1,k)-tra(il,1,k))
-          else
-           ftra(il,1,k)=ftra(il,1,k)+0.1*work(il)*ment(il,j,1)
-     :                *(traent(il,j,1,k)-tra(il,1,k))
-          endif
-
-         endif
-        enddo
-       enddo
-      enddo
+c      do k=1,ntra
+c       do j=2,nl
+c        do il=1,ncum
+c         if (j.le.inb(il)) then
+
+c          if (cvflag_grav) then
+c           ftra(il,1,k)=ftra(il,1,k)+0.01*grav*work(il)*ment(il,j,1)
+c     :                *(traent(il,j,1,k)-tra(il,1,k))
+c          else
+c           ftra(il,1,k)=ftra(il,1,k)+0.1*work(il)*ment(il,j,1)
+c     :                *(traent(il,j,1,k)-tra(il,1,k))
+c          endif
+
+c         endif
+c        enddo
+c       enddo
+c      enddo
 
 c
@@ -2488,21 +2486,21 @@
 1350  continue
 
-      do k=1,ntra
-       do il=1,ncum
-        if (i.le.inb(il)) then
-         dpinv=1.0/(ph(il,i)-ph(il,i+1))
-         cpinv=1.0/cpn(il,i)
-         if (cvflag_grav) then
-           ftra(il,i,k)=ftra(il,i,k)+0.01*grav*dpinv
-     :         *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))
-     :           -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))
-         else
-           ftra(il,i,k)=ftra(il,i,k)+0.1*dpinv
-     :         *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))
-     :           -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))
-         endif
-        endif
-       enddo
-      enddo
+c      do k=1,ntra
+c       do il=1,ncum
+c        if (i.le.inb(il)) then
+c         dpinv=1.0/(ph(il,i)-ph(il,i+1))
+c         cpinv=1.0/cpn(il,i)
+c         if (cvflag_grav) then
+c           ftra(il,i,k)=ftra(il,i,k)+0.01*grav*dpinv
+c     :         *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))
+c     :           -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))
+c         else
+c           ftra(il,i,k)=ftra(il,i,k)+0.1*dpinv
+c     :         *(amp1(il)*(tra(il,i+1,k)-tra(il,i,k))
+c     :           -ad(il)*(tra(il,i,k)-tra(il,i-1,k)))
+c         endif
+c        endif
+c       enddo
+c      enddo
 
       do 480 k=1,i-1
@@ -2538,21 +2536,21 @@
 480   continue
 
-      do j=1,ntra
-       do k=1,i-1
-        do il=1,ncum
-         if (i.le.inb(il)) then
-          dpinv=1.0/(ph(il,i)-ph(il,i+1))
-          cpinv=1.0/cpn(il,i)
-          if (cvflag_grav) then
-           ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)
-     :        *(traent(il,k,i,j)-tra(il,i,j))
-          else
-           ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)
-     :        *(traent(il,k,i,j)-tra(il,i,j))
-          endif
-         endif
-        enddo
-       enddo
-      enddo
+c      do j=1,ntra
+c       do k=1,i-1
+c        do il=1,ncum
+c         if (i.le.inb(il)) then
+c          dpinv=1.0/(ph(il,i)-ph(il,i+1))
+c          cpinv=1.0/cpn(il,i)
+c          if (cvflag_grav) then
+c           ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)
+c     :        *(traent(il,k,i,j)-tra(il,i,j))
+c          else
+c           ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)
+c     :        *(traent(il,k,i,j)-tra(il,i,j))
+c          endif
+c         endif
+c        enddo
+c       enddo
+c      enddo
 
       do 490 k=i,nl+1
@@ -2581,21 +2579,21 @@
 490   continue
 
-      do j=1,ntra
-       do k=i,nl+1
-        do il=1,ncum
-         if (i.le.inb(il) .and. k.le.inb(il)) then
-          dpinv=1.0/(ph(il,i)-ph(il,i+1))
-          cpinv=1.0/cpn(il,i)
-          if (cvflag_grav) then
-           ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)
-     :         *(traent(il,k,i,j)-tra(il,i,j))
-          else
-           ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)
-     :             *(traent(il,k,i,j)-tra(il,i,j))
-          endif
-         endif ! i and k
-        enddo
-       enddo
-      enddo
+c      do j=1,ntra
+c       do k=i,nl+1
+c        do il=1,ncum
+c         if (i.le.inb(il) .and. k.le.inb(il)) then
+c          dpinv=1.0/(ph(il,i)-ph(il,i+1))
+c          cpinv=1.0/cpn(il,i)
+c          if (cvflag_grav) then
+c           ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv*ment(il,k,i)
+c     :         *(traent(il,k,i,j)-tra(il,i,j))
+c          else
+c           ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv*ment(il,k,i)
+c     :             *(traent(il,k,i,j)-tra(il,i,j))
+c          endif
+c         endif ! i and k
+c        enddo
+c       enddo
+c      enddo
 
       do 1400 il=1,ncum
@@ -2654,23 +2652,22 @@
       enddo
 
-      do j=1,ntra
-       do il=1,ncum
-        if (i.le.inb(il)) then
-         dpinv=1.0/(ph(il,i)-ph(il,i+1))
-         cpinv=1.0/cpn(il,i)
-
-         if (cvflag_grav) then
-          ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv
-     :     *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j))
-     :     -mp(il,i)*(trap(il,i,j)-tra(il,i-1,j)))
-         else
-          ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv
-     :     *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j))
-     :     -mp(il,i)*(trap(il,i,j)-tra(il,i-1,j)))
-         endif
-        endif ! i
-       enddo
-      enddo 
-
+c      do j=1,ntra
+c       do il=1,ncum
+c        if (i.le.inb(il)) then
+c         dpinv=1.0/(ph(il,i)-ph(il,i+1))
+c         cpinv=1.0/cpn(il,i)
+
+c         if (cvflag_grav) then
+c          ftra(il,i,j)=ftra(il,i,j)+0.01*grav*dpinv
+c     :     *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j))
+c     :     -mp(il,i)*(trap(il,i,j)-tra(il,i-1,j)))
+c         else
+c          ftra(il,i,j)=ftra(il,i,j)+0.1*dpinv
+c     :     *(mp(il,i+1)*(trap(il,i+1,j)-tra(il,i,j))
+c     :     -mp(il,i)*(trap(il,i,j)-tra(il,i-1,j)))
+c         endif
+c        endif ! i
+c       enddo
+c      enddo 
 
 500   continue
@@ -2715,15 +2712,15 @@
 503   continue
 
-      do j=1,ntra
-       do il=1,ncum
-        ex=0.1*ment(il,inb(il),inb(il)) 
-     :      *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j))
-     :      /(ph(il,inb(il))-ph(il,inb(il)+1))
-        ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex
-        ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j)
-     :       +ex*(ph(il,inb(il))-ph(il,inb(il)+1))
-     :          /(ph(il,inb(il)-1)-ph(il,inb(il)))
-       enddo
-      enddo
+c      do j=1,ntra
+c       do il=1,ncum
+c        ex=0.1*ment(il,inb(il),inb(il)) 
+c     :      *(traent(il,inb(il),inb(il),j)-tra(il,inb(il),j))
+c     :      /(ph(il,inb(il))-ph(il,inb(il)+1))
+c        ftra(il,inb(il),j)=ftra(il,inb(il),j)-ex
+c        ftra(il,inb(il)-1,j)=ftra(il,inb(il)-1,j)
+c     :       +ex*(ph(il,inb(il))-ph(il,inb(il)+1))
+c     :          /(ph(il,inb(il)-1)-ph(il,inb(il)))
+c       enddo
+c      enddo
 
 c
@@ -2981,4 +2978,30 @@
         end
 
+      SUBROUTINE cv3_tracer(nloc,len,ncum,nd,na,
+     &                        ment,sij,da,phi)
+        implicit none
+c inputs:
+        integer ncum, nd, na, nloc,len
+        real ment(nloc,na,na),sij(nloc,na,na)
+c ouputs:
+        real da(nloc,na),phi(nloc,na,na)
+c local variables:
+        integer i,j,k
+c        
+        da(:,:)=0.
+c
+        do j=1,na
+          do k=1,na
+            do i=1,ncum
+            da(i,j)=da(i,j)+(1.-sij(i,k,j))*ment(i,k,j)
+            phi(i,j,k)=sij(i,k,j)*ment(i,k,j)
+c            print *,'da',j,k,da(i,j),sij(i,k,j),ment(i,k,j)
+            end do 
+          end do 
+        end do 
+    
+        return
+        end
+
 
       SUBROUTINE cv3_uncompress(nloc,len,ncum,nd,ntra,idcum
@@ -3051,11 +3074,11 @@
 
 
-        do 2100 j=1,ntra
-         do 2110 k=1,nd ! oct3
-          do 2120 i=1,ncum
-            ftra1(idcum(i),k,j)=ftra(i,k,j)
- 2120     continue
- 2110    continue
- 2100   continue
+c        do 2100 j=1,ntra
+c         do 2110 k=1,nd ! oct3
+c          do 2120 i=1,ncum
+c            ftra1(idcum(i),k,j)=ftra(i,k,j)
+c 2120     continue
+c 2110    continue
+c 2100   continue
 
         return
