Index: LMDZ4/trunk/libf/phylmd/conema3.F
===================================================================
--- LMDZ4/trunk/libf/phylmd/conema3.F	(revision 524)
+++ LMDZ4/trunk/libf/phylmd/conema3.F	(revision 766)
@@ -9,4 +9,5 @@
      .             qcond_incld)
 
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -54,5 +55,5 @@
 c
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "conema3.h"
       INTEGER i, l,m,itra
@@ -84,22 +85,46 @@
       REAL qcond_incld(klon,klev)
 c
-      REAL em_t(klev)
-      REAL em_q(klev)
-      REAL em_qs(klev)
-      REAL em_u(klev), em_v(klev), em_tra(klev,ntrac)
-      REAL em_ph(klev+1), em_p(klev)
-      REAL em_work1(klev), em_work2(klev)
-      REAL em_precip, em_d_t(klev), em_d_q(klev)
-      REAL em_d_u(klev), em_d_v(klev), em_d_tra(klev,ntrac)
-      REAL em_upwd(klev), em_dnwd(klev), em_dnwdbis(klev)
+      LOGICAL,SAVE :: first=.true.
+c$OMP THREADPRIVATE(first)
+      
+cym      REAL em_t(klev)
+      REAL,ALLOCATABLE,SAVE :: em_t(:)
+c$OMP THREADPRIVATE(em_t)  
+cym      REAL em_q(klev)
+      REAL,ALLOCATABLE,SAVE :: em_q(:)
+c$OMP THREADPRIVATE(em_q) 
+cym      REAL em_qs(klev)
+      REAL,ALLOCATABLE,SAVE :: em_qs(:) 
+c$OMP THREADPRIVATE(em_qs)  
+cym      REAL em_u(klev), em_v(klev), em_tra(klev,ntrac)
+      REAL,ALLOCATABLE,SAVE :: em_u(:),em_v(:),em_tra(:,:)
+c$OMP THREADPRIVATE(em_u,em_v,em_tra)      
+cym      REAL em_ph(klev+1), em_p(klev)
+      REAL,ALLOCATABLE,SAVE ::em_ph(:),em_p(:)
+c$OMP THREADPRIVATE(em_ph,em_p)
+cym      REAL em_work1(klev), em_work2(klev)
+      REAL,ALLOCATABLE,SAVE ::em_work1(:),em_work2(:)
+c$OMP THREADPRIVATE(em_work1,em_work2)      
+cym      REAL em_precip, em_d_t(klev), em_d_q(klev)
+      REAL,SAVE :: em_precip
+c$OMP THREADPRIVATE(em_precip)      
+      REAL,ALLOCATABLE,SAVE :: em_d_t(:),em_d_q(:)
+c$OMP THREADPRIVATE(em_d_t,em_d_q)
+cym      REAL em_d_u(klev), em_d_v(klev), em_d_tra(klev,ntrac)
+      REAL,ALLOCATABLE,SAVE ::em_d_u(:),em_d_v(:),em_d_tra(:,:)
+c$OMP THREADPRIVATE(em_d_u,em_d_v,em_d_tra)      
+cym      REAL em_upwd(klev), em_dnwd(klev), em_dnwdbis(klev)
+      REAL,ALLOCATABLE,SAVE :: em_upwd(:),em_dnwd(:),em_dnwdbis(:)
+c$OMP THREADPRIVATE(em_upwd,em_dnwd,em_dnwdbis)
       REAL em_dtvpdt1(klev), em_dtvpdq1(klev)
       REAL em_dplcldt, em_dplcldr
-      SAVE em_t,em_q, em_qs, em_ph, em_p, em_work1, em_work2
-      SAVE em_u,em_v, em_tra
-      SAVE em_d_u,em_d_v, em_d_tra
-      SAVE em_precip, em_d_t, em_d_q, em_upwd, em_dnwd, em_dnwdbis
+cym      SAVE em_t,em_q, em_qs, em_ph, em_p, em_work1, em_work2
+cym      SAVE em_u,em_v, em_tra
+cym      SAVE em_d_u,em_d_v, em_d_tra
+cym      SAVE em_precip, em_d_t, em_d_q, em_upwd, em_dnwd, em_dnwdbis
+
       INTEGER em_bas, em_top
       SAVE em_bas, em_top
-
+c$OMP THREADPRIVATE(em_bas,em_top)
       REAL em_wd
       REAL em_qcond(klev)
@@ -113,12 +138,18 @@
 cccccccccccccccccccccccccccccccccccccccccccccccccc
  
-      REAL emmip(klev) !variation de flux ascnon dilue i et i+1
-      SAVE emmip
-      real emMke(klev)
-      save emMke
+cym      REAL emmip(klev) !variation de flux ascnon dilue i et i+1
+      REAL,ALLOCATABLE,SAVE ::emmip(:)
+c$OMP THREADPRIVATE(emmip)
+cym      SAVE emmip
+cym      real emMke(klev)
+      REAL,ALLOCATABLE,SAVE ::emMke(:)
+c$OMP THREADPRIVATE(emMke)
+cym      save emMke
       real top
       real bas
-      real emMa(klev)
-      save emMa
+cym      real emMa(klev)
+      REAL,ALLOCATABLE,SAVE ::emMa(:)
+c$OMP THREADPRIVATE(emMa)
+cym      save emMa
       real Ma(klon,klev)
       real Ment(klev,klev)
@@ -151,8 +182,26 @@
 #include "YOETHF.h"
 #include "FCTTRE.h"
- 
+     
+      if (first) then
+  
+        allocate(em_t(klev))
+        allocate(em_q(klev))
+        allocate(em_qs(klev))
+        allocate(em_u(klev), em_v(klev), em_tra(klev,ntrac))
+        allocate(em_ph(klev+1), em_p(klev))
+        allocate(em_work1(klev), em_work2(klev))
+        allocate(em_d_t(klev), em_d_q(klev))
+        allocate(em_d_u(klev), em_d_v(klev), em_d_tra(klev,ntrac))
+        allocate(em_upwd(klev), em_dnwd(klev), em_dnwdbis(klev))
+        allocate(emmip(klev)) 
+	allocate(emMke(klev))
+        allocate(emMa(klev))
+  
+        first=.false.
+      endif
+  
       qcond_incld(:,:) = 0.
 c
-c$$$      print*,'debut conema'
+c@$$      print*,'debut conema'
 
       DO 999 i = 1, klon
@@ -170,11 +219,11 @@
           em_tra(l,itra) = tra(i,l,itra)
          enddo
-c$$$      print*,'em_t',em_t
-c$$$      print*,'em_q',em_q
-c$$$      print*,'em_qs',em_qs
-c$$$      print*,'em_u',em_u
-c$$$      print*,'em_v',em_v
-c$$$      print*,'em_tra',em_tra
-c$$$      print*,'em_p',em_p
+c@$$      print*,'em_t',em_t
+c@$$      print*,'em_q',em_q
+c@$$      print*,'em_qs',em_qs
+c@$$      print*,'em_u',em_u
+c@$$      print*,'em_v',em_v
+c@$$      print*,'em_tra',em_tra
+c@$$      print*,'em_p',em_p
 
  
@@ -184,9 +233,9 @@
          zx_qs= r2es * FOEEW(zx_t,zdelta)/em_p(l)/100.0
          zx_qs=MIN(0.5,zx_qs)
-c$$$       print*,'zx_qs',zx_qs
+c@$$       print*,'zx_qs',zx_qs
          zcor=1./(1.-retv*zx_qs) 
          zx_qs=zx_qs*zcor
          em_qs(l) = zx_qs
-c$$$      print*,'em_qs',em_qs
+c@$$      print*,'em_qs',em_qs
 c
          em_work1(l) = work1(i,l)
@@ -219,5 +268,5 @@
 1793  format('w avant convect ',/,10(1X,E13.5))
  
-c$$$      print*,'avant convect' 
+c@$$      print*,'avant convect' 
 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 c 
