Index: LMDZ6/branches/DYNAMICO-conv/libf/phylmd/calwake.F90
===================================================================
--- LMDZ6/branches/DYNAMICO-conv/libf/phylmd/calwake.F90	(revision 3024)
+++ LMDZ6/branches/DYNAMICO-conv/libf/phylmd/calwake.F90	(revision 3356)
@@ -4,7 +4,7 @@
 SUBROUTINE calwake(iflag_wake_tend, paprs, pplay, dtime, &
     t, q, omgb, &
-    dt_dwn, dq_dwn, m_dwn, m_up, dt_a, dq_a, &
-    sigd, &
-    wake_deltat, wake_deltaq, wake_s, wake_dens, &
+    dt_dwn, dq_dwn, m_dwn, m_up, dt_a, dq_a, wgen, &
+    sigd, Cin, &
+    wake_deltat, wake_deltaq, wake_s, awake_dens, wake_dens, &
     wake_dth, wake_h, &
     wake_pe, wake_fip, wake_gfl, &
@@ -14,5 +14,5 @@
     wake_omg, wake_dp_deltomg, &
     wake_spread, wake_cstar, wake_d_deltat_gw, &
-    wake_ddeltat, wake_ddeltaq, wake_ds, wake_ddens)
+    wake_ddeltat, wake_ddeltaq, wake_ds, awake_ddens, wake_ddens)
   ! **************************************************************
   ! *
@@ -45,10 +45,12 @@
   REAL, DIMENSION(klon, klev),   INTENT (IN)         :: m_up, m_dwn
   REAL, DIMENSION(klon, klev),   INTENT (IN)         :: dt_a, dq_a
+  REAL, DIMENSION(klon),         INTENT (IN)         :: wgen
   REAL, DIMENSION(klon),         INTENT (IN)         :: sigd
+  REAL, DIMENSION(klon),         INTENT (IN)         :: Cin
   ! Input/Output
   ! ------------
   REAL, DIMENSION(klon, klev),   INTENT (INOUT)      :: wake_deltat, wake_deltaq
   REAL, DIMENSION(klon),         INTENT (INOUT)      :: wake_s
-  REAL, DIMENSION(klon),         INTENT (INOUT)      :: wake_dens
+  REAL, DIMENSION(klon),         INTENT (INOUT)      :: awake_dens, wake_dens
   ! Output
   ! ------
@@ -67,5 +69,5 @@
   REAL, DIMENSION(klon),         INTENT (OUT)        :: wake_cstar
   REAL, DIMENSION(klon, klev),   INTENT (OUT)        :: wake_ddeltat, wake_ddeltaq
-  REAL, DIMENSION(klon),         INTENT (OUT)        :: wake_ds, wake_ddens
+  REAL, DIMENSION(klon),         INTENT (OUT)        :: wake_ds, awake_ddens, wake_ddens
 
 
@@ -88,5 +90,5 @@
   REAL, DIMENSION(klon, klev)                        :: tx, qx
   REAL, DIMENSION(klon)                              :: hw, wape, fip, gfl
-  REAL, DIMENSION(klon)                              :: sigmaw, wdens
+  REAL, DIMENSION(klon)                              :: sigmaw, awdens, wdens
   REAL, DIMENSION(klon, klev)                        :: omgbdth
   REAL, DIMENSION(klon, klev)                        :: dp_omgb
@@ -99,5 +101,5 @@
   REAL, DIMENSION(klon, klev)                        :: d_deltat_gw
   REAL, DIMENSION(klon, klev)                        :: d_deltatw, d_deltaqw
-  REAL, DIMENSION(klon)                              :: d_sigmaw, d_wdens
+  REAL, DIMENSION(klon)                              :: d_sigmaw, d_awdens, d_wdens
 
   REAL                                               :: rdcp
@@ -105,5 +107,5 @@
 
   IF (prt_level >= 10) THEN
-    print *, '-> calwake, wake_s input ', wake_s(1)
+    print *, '-> calwake, wake_s, wgen input ', wake_s(1), wgen(1)
   ENDIF
 
@@ -147,4 +149,5 @@
 d_deltaqw(:,:) = 0.
 d_sigmaw(:) = 0.
+d_awdens(:) = 0.
 d_wdens(:) = 0.
 !
@@ -179,4 +182,5 @@
 
   DO i = 1, klon
+    awdens(i) = max(0., awake_dens(i))
     wdens(i) = max(0., wake_dens(i))
   END DO
@@ -206,12 +210,12 @@
   CALL wake(znatsurf, p, ph, pi, dtime, &
     te, qe, omgbe, &
-    dtdwn, dqdwn, amdwn, amup, dta, dqa, &
-    sigd0, &
-    dtw, dqw, sigmaw, wdens, &                                   ! state variables
+    dtdwn, dqdwn, amdwn, amup, dta, dqa, wgen, &
+    sigd0, Cin, &
+    dtw, dqw, sigmaw, awdens, wdens, &                                   ! state variables
     dth, hw, wape, fip, gfl, &
     dtls, dqls, ktopw, omgbdth, dp_omgb, tx, qx, &
     dtke, dqke, omg, dp_deltomg, spread, cstar, &
     d_deltat_gw, &
-    d_deltatw, d_deltaqw, d_sigmaw, d_wdens)                     ! tendencies
+    d_deltatw, d_deltaqw, d_sigmaw, d_awdens, d_wdens)                     ! tendencies
 
 !
@@ -274,4 +278,5 @@
     IF (ktopw(i)>0) THEN
       wake_ds(i) = d_sigmaw(i)*dtime
+      awake_ddens(i) = d_awdens(i)*dtime
       wake_ddens(i) = d_wdens(i)*dtime
     ELSE
@@ -298,4 +303,5 @@
     DO i = 1, klon
       wake_s(i) = sigmaw(i)
+      awake_dens(i) = awdens(i)
       wake_dens(i) = wdens(i)
     END DO
