Index: LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/traclmdz_mod.F90
===================================================================
--- LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/traclmdz_mod.F90	(revision 1292)
+++ LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/traclmdz_mod.F90	(revision 1376)
@@ -35,4 +35,13 @@
 !$OMP THREADPRIVATE(id_be)
 
+!IM ajout traceurs RR 
+  INTEGER,SAVE :: id_dry !traceur dry intrusions
+!$OMP THREADPRIVATE(id_dry)
+  INTEGER,SAVE :: id_pcsat, id_pcocsat, id_pcq ! traceurs pseudo-vapeur CL qsat, qsat_oc, q
+!$OMP THREADPRIVATE(id_pcsat, id_pcocsat, id_pcq)
+  INTEGER,SAVE :: id_pcs0, id_pcos0, id_pcq0 ! traceurs pseudo-vapeur CL qsat, qsat_oc, q
+!                                            ! qui ne sont pas transportes par la convection
+!$OMP THREADPRIVATE(id_pcs0, id_pcos0, id_pcq0)
+
   LOGICAL,SAVE :: rnpb=.TRUE. ! Presence du couple Rn222, Pb210
 !$OMP THREADPRIVATE(rnpb)
@@ -65,5 +74,5 @@
 
 
-  SUBROUTINE traclmdz_init(pctsrf, ftsol, tr_seri, aerosol, lessivage)
+  SUBROUTINE traclmdz_init(pctsrf, ftsol, tr_seri, t_seri, pplay, sh, aerosol, lessivage)
     ! This subroutine allocates and initialize module variables and control variables.
     USE dimphy
@@ -78,5 +87,9 @@
     REAL,DIMENSION(klon,nbsrf),INTENT(IN)     :: pctsrf ! Pourcentage de sol f(nature du sol)
     REAL,DIMENSION(klon,nbsrf),INTENT(IN)     :: ftsol  ! Temperature du sol (surf)(Kelvin)
-    REAL,DIMENSION(klon,klev,nbtr),INTENT(IN) :: tr_seri! Concentration Traceur [U/KgA]  
+!IM traceurs RR   REAL,DIMENSION(klon,klev,nbtr),INTENT(IN) :: tr_seri! Concentration Traceur [U/KgA]  
+    REAL,DIMENSION(klon,klev,nbtr),INTENT(INOUT) :: tr_seri! Concentration Traceur [U/KgA]  
+    REAL,DIMENSION(klon,klev),INTENT(IN)   :: t_seri  ! Temperature
+    REAL,DIMENSION(klon,klev),INTENT(IN)   :: pplay   ! pression pour le mileu de chaque couche (en Pa)
+    REAL,DIMENSION(klon,klev),INTENT(IN)   :: sh      ! humidite specifique
 
 ! Output variables
@@ -85,5 +98,6 @@
         
 ! Local variables    
-    INTEGER :: ierr, it, iiq
+    INTEGER :: ierr, it, iiq, i, k
+    REAL,DIMENSION(klon,klev)      :: qsat   ! pression de la vapeur a saturation
     
 ! --------------------------------------------
@@ -137,4 +151,62 @@
        END IF    
     END DO
+
+    id_dry=0
+
+    DO it=1,nbtr
+       iiq=niadv(it+2)
+       IF ( tname(iiq) == "dry" .OR. tname(iiq) == "Dry" ) THEN
+        id_dry=it
+       END IF    
+    END DO  
+
+    id_pcsat=0
+    DO it=1,nbtr
+       iiq=niadv(it+2)
+       IF ( tname(iiq) == "pcsat" .OR. tname(iiq) == "Pcsat" ) THEN
+        id_pcsat=it
+      END IF
+    END DO
+
+    id_pcocsat=0
+    DO it=1,nbtr
+       iiq=niadv(it+2)
+       IF ( tname(iiq) == "pcocsat" .OR. tname(iiq) == "Pcocsat" ) THEN
+        id_pcocsat=it
+       END IF
+    END DO
+
+    id_pcq=0
+    DO it=1,nbtr
+       iiq=niadv(it+2)
+       IF ( tname(iiq) == "pcq" .OR. tname(iiq) == "Pcq" ) THEN
+        id_pcq=it
+       END IF
+    END DO
+
+    id_pcs0=0
+    DO it=1,nbtr
+       iiq=niadv(it+2)
+       IF ( tname(iiq) == "pcs0" .OR. tname(iiq) == "Pcs0" ) THEN
+        id_pcs0=it
+      END IF
+    END DO
+
+    id_pcos0=0
+    DO it=1,nbtr
+       iiq=niadv(it+2)
+       IF ( tname(iiq) == "pcos0" .OR. tname(iiq) == "Pcos0" ) THEN
+        id_pcos0=it
+       END IF
+    END DO
+
+    id_pcq0=0
+    DO it=1,nbtr
+       iiq=niadv(it+2)
+       IF ( tname(iiq) == "pcq0" .OR. tname(iiq) == "Pcq0" ) THEN
+        id_pcq0=it
+       END IF
+    END DO
+
 !
 ! Valeurs specifiques pour les traceurs Rn222 et Pb210
@@ -159,4 +231,82 @@
     END IF
 
+!IM initialisation traceurs pseudo-vapeurs
+    call q_sat(klon*klev,t_seri,pplay,qsat)
+    IF ( id_pcsat /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        tr_seri(i,k,id_pcsat) = qsat(i,k)
+       ELSE
+        tr_seri(i,k,id_pcsat) = 100.
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcocsat /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        IF ( pctsrf (i, is_oce) > 0. ) THEN
+         tr_seri(i,k,id_pcocsat) = qsat(i,k)
+        ELSE
+         tr_seri(i,k,id_pcocsat) = 100.
+        END IF
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcq /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        tr_seri(i,k,id_pcq) = sh(i,k)
+       ELSE
+        tr_seri(i,k,id_pcq) = 100.
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcs0 /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        tr_seri(i,k,id_pcs0) = qsat(i,k)
+       ELSE
+        tr_seri(i,k,id_pcs0) = 100.
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcos0 /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        IF ( pctsrf (i, is_oce) > 0. ) THEN
+         tr_seri(i,k,id_pcos0) = qsat(i,k)
+        ELSE
+         tr_seri(i,k,id_pcos0) = 100.
+        END IF
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcq0 /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        tr_seri(i,k,id_pcq0) = sh(i,k)
+       ELSE
+        tr_seri(i,k,id_pcq0) = 100.
+       END IF
+      END DO
+     END DO
+    END IF
+ 
   END SUBROUTINE traclmdz_init
 
@@ -165,5 +315,5 @@
        paprs,    pplay,        cdragh,  coefh,   &
        yu1,      yv1,          ftsol,   pctsrf,  &
-       xlat,     couchelimite,                   &
+       xlat,     couchelimite, sh,               &
        tr_seri,  source,       solsym,  d_tr_cl)
     
@@ -204,4 +354,6 @@
     REAL,DIMENSION(klon),INTENT(IN)      :: yv1        ! vents au premier niveau
     LOGICAL,INTENT(IN)                   :: couchelimite
+!IM traceurs RR
+    REAL,DIMENSION(klon,klev),INTENT(IN)   :: sh      ! humidite specifique
 
 ! Arguments necessaires pour les sources et puits de traceur:
@@ -230,5 +382,7 @@
     REAL                           :: zrho      ! Masse Volumique de l'air KgA/m3
 
-!
+!IM traceurs RR
+    REAL,DIMENSION(klon,klev)      :: qsat   ! pression de la vapeur a saturation
+    REAL :: amn, amx
 !
 !=================================================================
@@ -245,4 +399,70 @@
     END IF
   
+!IM ajout traceurs RR
+    call q_sat(klon*klev,t_seri,pplay,qsat)
+    
+    IF ( id_pcsat /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        tr_seri(i,k,id_pcsat) = qsat(i,k)
+       END IF
+      END DO 
+     END DO
+    END IF
+
+    IF ( id_pcocsat /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        IF ( pctsrf (i, is_oce) > 0. ) THEN
+         tr_seri(i,k,id_pcocsat) = qsat(i,k)
+        END IF
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcq /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        tr_seri(i,k,id_pcq) = sh(i,k)
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcs0 /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        tr_seri(i,k,id_pcs0) = qsat(i,k)
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcos0 /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        IF ( pctsrf (i, is_oce) > 0. ) THEN
+         tr_seri(i,k,id_pcos0) = qsat(i,k)
+        END IF
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcq0 /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).GE.85000.) THEN
+        tr_seri(i,k,id_pcq0) = sh(i,k)
+       END IF
+      END DO
+     END DO
+    END IF
 
     DO it=1,nbtr
@@ -294,5 +514,65 @@
        END IF
     END DO
-           
+          
+!IM traceurs RR
+    IF ( id_pcsat /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).LT.85000.) THEN
+        tr_seri(i,k,id_pcsat) = MIN (qsat(i,k), tr_seri(i,k,id_pcsat))
+       END IF 
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcocsat /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).LT.85000.) THEN
+        tr_seri(i,k,id_pcocsat) = MIN (qsat(i,k), tr_seri(i,k,id_pcocsat))
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcq /= 0 ) THEN
+     DO k = 1, klev 
+      DO i = 1, klon 
+       IF ( pplay(i,k).LT.85000.) THEN
+        tr_seri(i,k,id_pcq) = MIN (qsat(i,k), tr_seri(i,k,id_pcq))
+       END IF
+      END DO  
+     END DO  
+    END IF  
+
+    IF ( id_pcs0 /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).LT.85000.) THEN
+        tr_seri(i,k,id_pcs0) = MIN (qsat(i,k), tr_seri(i,k,id_pcs0))
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcos0 /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).LT.85000.) THEN
+        tr_seri(i,k,id_pcos0) = MIN (qsat(i,k), tr_seri(i,k,id_pcos0))
+       END IF
+      END DO
+     END DO
+    END IF
+
+    IF ( id_pcq0 /= 0 ) THEN
+     DO k = 1, klev
+      DO i = 1, klon
+       IF ( pplay(i,k).LT.85000.) THEN
+        tr_seri(i,k,id_pcq0) = MIN (qsat(i,k), tr_seri(i,k,id_pcq0))
+       END IF
+      END DO
+     END DO
+    END IF
 !======================================================================
 !   Calcul de l'effet du puits radioactif
