Index: trunk/LMDZ.VENUS/libf/phyvenus/ajsec.cpcst
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ajsec.cpcst	(revision 888)
+++ 	(revision )
@@ -1,166 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/ajsec.F,v 1.1.1.1 2004/05/19 12:53:08 lmdzadmin Exp $
-!
-      SUBROUTINE ajsec(paprs, pplay, t, d_t)
-      IMPLICIT none
-c======================================================================
-c inspiree de la base ecrite par:
-c Auteur(s): Z.X. Li (LMD/CNRS) date: 19930818
-c Objet: ajustement sec (adaptation du GCM du LMD)
-c
-c Reecriture par S. Lebonnois en Novembre 2006
-c pour prise en compte Cp variable dans atm de VENUS
-c======================================================================
-c Arguments:
-c t-------input-R- Temperature
-c
-c d_t-----output-R-Incrementation de la temperature
-c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
-#include "YOMCST.h"
-      REAL paprs(klon,klev+1), pplay(klon,klev)
-      REAL t(klon,klev), d_t(klon,klev)
-c
-      INTEGER limbas, limhau ! les couches a ajuster
-ccc      PARAMETER (limbas=klev-3, limhau=klev)
-      PARAMETER (limbas=1, limhau=klev)
-c
-      REAL zt(klev),t_inter(klev),zh(klev)
-      REAL zdp(klev),zdplay(klev)
-      REAL alpha(klev),beta(klev)
-      real somh,somhm1
-      LOGICAL down
-      INTEGER i, k, k1, k2
-
-      real cpco2,cpstar(klev),cpdyn(klev)
-      external cpco2
-      save cpstar,cpdyn
-
-      logical firstcall
-      data    firstcall/.true./
-      save    firstcall
-c
-c Initialisation:
-c
-      DO k = 1, klev
-      DO i = 1, klon
-         d_t(i,k) = 0.0
-      ENDDO
-      ENDDO
-
-      DO i = 1, klon
-c - - boucle sur les points de grille - - - - - -      
-
-c------ initialisation des variables necessaires au calcul
-
-        do k = 1, klev
-	  zt(k)  = t(i,k)
-	  zdp(k) = paprs(i,k)-paprs(i,k+1)
-
-        if (firstcall) then
-c CP considere: etre cohérent avec la dynamique ! (conservation...)
-          cpdyn(k) = RCPD
-c         cpdyn(k) = cpco2(t(i,k))
-        endif
-
-c enthalpie dans la couche k: c'est la grandeur qu'on mélange
-	  zh(k)  = t(i,k)*zdp(k)*cpdyn(k)
-	enddo
-	
-        do k = 2, klev
-	  zdplay(k)  = pplay(i,k-1)-pplay(i,k)
-	  t_inter(k) = (t(i,k-1)+t(i,k))/2.
-        if (firstcall) then
-          cpstar(k)  = cpco2(t_inter(k))
-c----
-c TEST si cp constant:
-          cpstar(k)  = RCPD
-          print*,"ATTENTION!! CP CONSTANT DANS AJSEC",cpstar
-c----
-c         print*,cpstar
-        endif
-	  beta(k)    = RD*zdplay(k)/(2.*cpstar(k)*paprs(i,k))
-c       print*,beta(k),((zt(k-1)-zt(k))/(zt(k-1)+zt(k)))
-	  alpha(k)   = (1.-beta(k))/(1.+beta(k))*(zdp(k)/zdp(k-1))
-	enddo
-c------------------------------------- correction des instabilites
-c on part du bas:
-          k2 = limbas
-
- 8000     CONTINUE
-c on cherche une zone de convection
-            k2 = k2 + 1
-	    somh   = 0.
-	    somhm1 = 0.
-            IF (k2 .GT. limhau) goto 8001
-	    
-c test instabilite initiale pour une zone
-            IF (((zt(k2-1)-zt(k2))/(zt(k2-1)+zt(k2))).GT.beta(k2)) THEN
-              k1 = k2 - 1
-	      somh   = zh(k1)+zh(k2)
-	      somhm1 = zh(k1)
-              down = .FALSE.
-
- 8020         CONTINUE
-c calculs nouvelles temperatures entre k1 et k2 par recurrence
-                if (down) then
-                   zt(k1) = somh /( cpdyn(k1)*zdp(k1)*
-     .      (1+somhm1/(cpdyn(k1+1)*zt(k1+1)*zdp(k1+1))*alpha(k1+1)) )
-                   do k = k1+1, k2
-		     zt(k) = zt(k-1)*(1-beta(k))/(1+beta(k))
-		   enddo
-		else
-                   zt(k2) = somh /( cpdyn(k2)*zdp(k2)*
-     .      (1+somhm1/(cpdyn(k2-1)*zt(k2-1)*zdp(k2-1))/alpha(k2)) )
-                   do k = k2-1, k1, -1
-		     zt(k) = zt(k+1)*(1+beta(k+1))/(1-beta(k+1))
-		   enddo
-		endif
-
-                down = .FALSE.
-                IF (k1 .ne. limbas) THEN
-c test instabilite vers le bas
-                 IF (((zt(k1-1)-zt(k1))/(zt(k1-1)+zt(k1))).GT.beta(k1))
-     .                     down = .TRUE.
-                ENDIF
-                IF (down) THEN
-                  k1 = k1 - 1
-		  somhm1 = somh
-		  somh   = somh + zh(k1)
-                ELSE
-                  IF ((k2 .EQ. limhau)) GOTO 8021
-c test instabilite vers le haut
-           IF (((zt(k2)-zt(k2+1))/(zt(k2)+zt(k2+1))).LE.beta(k2+1))
-c                  (si vrai, stable)
-     .                     GOTO 8021
-                  k2 = k2 + 1
-		  somhm1 = somh
-		  somh   = somh + zh(k2)
-                ENDIF
-c on a etendu la zone, on recalcule:
-              GOTO 8020
-
-c sortie zone => on continue au-dessus pour chercher autre zone
- 8021         CONTINUE
-              k2 = k2 + 1
-            ENDIF
-          GOTO 8000
-
-c sortie de la colonne:
- 8001     CONTINUE
-
-c ------------------------------------- tendances temperature
-
-        DO k = 1,klev
-         d_t(i,k) = zt(k) - t(i,k)
-c        if(d_t(i,k).gt.0.) print*,zt(k),t(i,k)
-        ENDDO
-
-c - - fin boucle sur les points de grille - - - -      
-      ENDDO
-
-      firstcall  = .false.
-
-      RETURN
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/ajsec.cpvariable
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ajsec.cpvariable	(revision 888)
+++ 	(revision )
@@ -1,166 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/ajsec.F,v 1.1.1.1 2004/05/19 12:53:08 lmdzadmin Exp $
-!
-      SUBROUTINE ajsec(paprs, pplay, t, d_t)
-      IMPLICIT none
-c======================================================================
-c inspiree de la base ecrite par:
-c Auteur(s): Z.X. Li (LMD/CNRS) date: 19930818
-c Objet: ajustement sec (adaptation du GCM du LMD)
-c
-c Reecriture par S. Lebonnois en Novembre 2006
-c pour prise en compte Cp variable dans atm de VENUS
-c======================================================================
-c Arguments:
-c t-------input-R- Temperature
-c
-c d_t-----output-R-Incrementation de la temperature
-c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
-#include "YOMCST.h"
-      REAL paprs(klon,klev+1), pplay(klon,klev)
-      REAL t(klon,klev), d_t(klon,klev)
-c
-      INTEGER limbas, limhau ! les couches a ajuster
-ccc      PARAMETER (limbas=klev-3, limhau=klev)
-      PARAMETER (limbas=1, limhau=klev)
-c
-      REAL zt(klev),t_inter(klev),zh(klev)
-      REAL zdp(klev),zdplay(klev)
-      REAL alpha(klev),beta(klev)
-      real somh,somhm1
-      LOGICAL down
-      INTEGER i, k, k1, k2
-
-      real cpco2,cpstar(klev),cpdyn(klev)
-      external cpco2
-      save cpstar,cpdyn
-
-      logical firstcall
-      data    firstcall/.true./
-      save    firstcall
-c
-c Initialisation:
-c
-      DO k = 1, klev
-      DO i = 1, klon
-         d_t(i,k) = 0.0
-      ENDDO
-      ENDDO
-
-      DO i = 1, klon
-c - - boucle sur les points de grille - - - - - -      
-
-c------ initialisation des variables necessaires au calcul
-
-        do k = 1, klev
-	  zt(k)  = t(i,k)
-	  zdp(k) = paprs(i,k)-paprs(i,k+1)
-
-        if (firstcall) then
-c CP considere: etre cohérent avec la dynamique ! (conservation...)
-          cpdyn(k) = RCPD
-c         cpdyn(k) = cpco2(t(i,k))
-        endif
-
-c enthalpie dans la couche k: c'est la grandeur qu'on mélange
-	  zh(k)  = t(i,k)*zdp(k)*cpdyn(k)
-	enddo
-	
-        do k = 2, klev
-	  zdplay(k)  = pplay(i,k-1)-pplay(i,k)
-	  t_inter(k) = (t(i,k-1)+t(i,k))/2.
-        if (firstcall) then
-          cpstar(k)  = cpco2(t_inter(k))
-c----
-c TEST si cp constant:
-c         cpstar(k)  = RCPD
-c         print*,"ATTENTION!! CP CONSTANT DANS AJSEC",cpstar
-c----
-c         print*,cpstar
-        endif
-	  beta(k)    = RD*zdplay(k)/(2.*cpstar(k)*paprs(i,k))
-c       print*,beta(k),((zt(k-1)-zt(k))/(zt(k-1)+zt(k)))
-	  alpha(k)   = (1.-beta(k))/(1.+beta(k))*(zdp(k)/zdp(k-1))
-	enddo
-c------------------------------------- correction des instabilites
-c on part du bas:
-          k2 = limbas
-
- 8000     CONTINUE
-c on cherche une zone de convection
-            k2 = k2 + 1
-	    somh   = 0.
-	    somhm1 = 0.
-            IF (k2 .GT. limhau) goto 8001
-	    
-c test instabilite initiale pour une zone
-            IF (((zt(k2-1)-zt(k2))/(zt(k2-1)+zt(k2))).GT.beta(k2)) THEN
-              k1 = k2 - 1
-	      somh   = zh(k1)+zh(k2)
-	      somhm1 = zh(k1)
-              down = .FALSE.
-
- 8020         CONTINUE
-c calculs nouvelles temperatures entre k1 et k2 par recurrence
-                if (down) then
-                   zt(k1) = somh /( cpdyn(k1)*zdp(k1)*
-     .      (1+somhm1/(cpdyn(k1+1)*zt(k1+1)*zdp(k1+1))*alpha(k1+1)) )
-                   do k = k1+1, k2
-		     zt(k) = zt(k-1)*(1-beta(k))/(1+beta(k))
-		   enddo
-		else
-                   zt(k2) = somh /( cpdyn(k2)*zdp(k2)*
-     .      (1+somhm1/(cpdyn(k2-1)*zt(k2-1)*zdp(k2-1))/alpha(k2)) )
-                   do k = k2-1, k1, -1
-		     zt(k) = zt(k+1)*(1+beta(k+1))/(1-beta(k+1))
-		   enddo
-		endif
-
-                down = .FALSE.
-                IF (k1 .ne. limbas) THEN
-c test instabilite vers le bas
-                 IF (((zt(k1-1)-zt(k1))/(zt(k1-1)+zt(k1))).GT.beta(k1))
-     .                     down = .TRUE.
-                ENDIF
-                IF (down) THEN
-                  k1 = k1 - 1
-		  somhm1 = somh
-		  somh   = somh + zh(k1)
-                ELSE
-                  IF ((k2 .EQ. limhau)) GOTO 8021
-c test instabilite vers le haut
-           IF (((zt(k2)-zt(k2+1))/(zt(k2)+zt(k2+1))).LE.beta(k2+1))
-c                  (si vrai, stable)
-     .                     GOTO 8021
-                  k2 = k2 + 1
-		  somhm1 = somh
-		  somh   = somh + zh(k2)
-                ENDIF
-c on a etendu la zone, on recalcule:
-              GOTO 8020
-
-c sortie zone => on continue au-dessus pour chercher autre zone
- 8021         CONTINUE
-              k2 = k2 + 1
-            ENDIF
-          GOTO 8000
-
-c sortie de la colonne:
- 8001     CONTINUE
-
-c ------------------------------------- tendances temperature
-
-        DO k = 1,klev
-         d_t(i,k) = zt(k) - t(i,k)
-c        if(d_t(i,k).gt.0.) print*,zt(k),t(i,k)
-        ENDDO
-
-c - - fin boucle sur les points de grille - - - -      
-      ENDDO
-
-      firstcall  = .false.
-
-      RETURN
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/ajsec.rcpd
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ajsec.rcpd	(revision 888)
+++ 	(revision )
@@ -1,229 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/ajsec.F,v 1.1.1.1 2004/05/19 12:53:08 lmdzadmin Exp $
-!
-      SUBROUTINE ajsec(paprs, pplay, t, d_t)
-      IMPLICIT none
-c======================================================================
-c Auteur(s): Z.X. Li (LMD/CNRS) date: 19930818
-c Objet: ajustement sec (adaptation du GCM du LMD)
-c======================================================================
-c Arguments:
-c t-------input-R- Temperature
-c
-c d_t-----output-R-Incrementation de la temperature
-c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
-#include "YOMCST.h"
-      REAL paprs(klon,klev+1), pplay(klon,klev)
-      REAL t(klon,klev), d_t(klon,klev)
-c
-      INTEGER limbas, limhau ! les couches a ajuster
-ccc      PARAMETER (limbas=klev-3, limhau=klev)
-      PARAMETER (limbas=1, limhau=klev)
-c
-      REAL zh(klon,klev)
-      REAL zpk(klon,klev)
-      REAL zpkdp(klon,klev)
-      REAL hm, sm
-      LOGICAL modif(klon), down
-      INTEGER i, k, k1, k2
-c
-c Initialisation:
-c
-      DO k = 1, klev
-      DO i = 1, klon
-         d_t(i,k) = 0.0
-      ENDDO
-      ENDDO
-c------------------------------------- detection des profils a modifier
-      DO k = limbas, limhau
-      DO i = 1, klon
-         zpk(i,k) = pplay(i,k)**RKAPPA
-         zh(i,k) = RCPD * t(i,k)/ zpk(i,k)
-      ENDDO
-      ENDDO
-c
-      DO k = limbas, limhau
-      DO i = 1, klon
-         zpkdp(i,k) = zpk(i,k) * (paprs(i,k)-paprs(i,k+1))
-      ENDDO
-      ENDDO
-c
-      DO i = 1, klon
-         modif(i) = .FALSE.
-      ENDDO
-      DO k = limbas+1, limhau
-      DO i = 1, klon
-      IF (.NOT.modif(i)) THEN
-         IF ( zh(i,k).LT.zh(i,k-1) ) modif(i) = .TRUE.
-      ENDIF
-      ENDDO
-      ENDDO
-c------------------------------------- correction des profils instables
-      DO 1080 i = 1, klon
-      IF (modif(i)) THEN
-          k2 = limbas
- 8000     CONTINUE
-            k2 = k2 + 1
-            IF (k2 .GT. limhau) goto 8001
-            IF (zh(i,k2) .LT. zh(i,k2-1)) THEN
-              k1 = k2 - 1
-              k = k1
-              sm = zpkdp(i,k2)
-              hm = zh(i,k2)
- 8020         CONTINUE
-                sm = sm +zpkdp(i,k)
-                hm = hm +zpkdp(i,k) * (zh(i,k)-hm) / sm
-                down = .FALSE.
-                IF (k1 .ne. limbas) THEN
-                  IF (hm .LT. zh(i,k1-1)) down = .TRUE.
-                ENDIF
-                IF (down) THEN
-                  k1 = k1 - 1
-                  k = k1
-                ELSE
-                  IF ((k2 .EQ. limhau)) GOTO 8021
-                  IF ((zh(i,k2+1).GE.hm)) GOTO 8021
-                  k2 = k2 + 1
-                  k = k2
-                ENDIF
-              GOTO 8020
- 8021         CONTINUE
-c------------ nouveau profil : constant (valeur moyenne)
-              DO k = k1, k2
-                zh(i,k) = hm
-              ENDDO
-              k2 = k2 + 1
-            ENDIF
-          GOTO 8000
- 8001     CONTINUE
-      ENDIF
- 1080 CONTINUE
-c
-      DO k = limbas, limhau
-      DO i = 1, klon
-         d_t(i,k) = zh(i,k)*zpk(i,k)/RCPD - t(i,k)
-      ENDDO
-      ENDDO
-c
-      IF (limbas.GT.1) THEN
-      DO k = 1, limbas-1
-      DO i = 1, klon
-         d_t(i,k) = 0.0
-      ENDDO
-      ENDDO
-      ENDIF
-c
-      IF (limhau.LT.klev) THEN
-      DO k = limhau+1, klev
-      DO i = 1, klon
-         d_t(i,k) = 0.0
-      ENDDO
-      ENDDO
-      ENDIF
-c
-      RETURN
-      END
-
-c======================================================================
-c======================================================================
-c======================================================================
-c======================================================================
-c======================================================================
-c======================================================================
-
-      SUBROUTINE ajsec_old(paprs, pplay, t, d_t)
-      IMPLICIT none
-c======================================================================
-c Auteur(s): Z.X. Li (LMD/CNRS) date: 19930818
-c Objet: ajustement sec (adaptation du GCM du LMD)
-c======================================================================
-c Arguments:
-c t-------input-R- Temperature
-c
-c d_t-----output-R-Incrementation de la temperature
-c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
-#include "YOMCST.h"
-      REAL paprs(klon,klev+1), pplay(klon,klev)
-      REAL t(klon,klev)
-      REAL d_t(klon,klev)
-c
-      REAL local_h(klon,klev)
-      REAL hm, sm
-      LOGICAL modif(klon), down
-      INTEGER i, l, l1, l2
-c------------------------------------- detection des profils a modifier
-      DO i = 1, klon
-         modif(i)   = .false.
-      ENDDO
-c
-      DO l = 1, klev
-      DO i = 1, klon
-         local_h(i,l) = RCPD * t(i,l)/ (pplay(i,l)**RKAPPA)
-      ENDDO
-      ENDDO
-c
-      DO l = 2, klev
-      DO i = 1, klon
-         IF ( local_h(i,l).lt.local_h(i,l-1) ) THEN
-            modif(i) = .true.
-         ELSE
-            modif(i) = modif(i)
-         ENDIF
-      ENDDO
-      ENDDO
-c------------------------------------- correction des profils instables
-      do 1080 i = 1, klon
-        if (modif(i)) then
-          l2 = 1
- 8000     continue
-            l2 = l2 + 1
-            if (l2 .gt. klev) goto 8001
-            if (local_h(i, l2) .lt. local_h(i, l2-1)) then
-              l1 = l2 - 1
-              l  = l1
-              sm = pplay(i,l2)**RKAPPA * (paprs(i,l2)-paprs(i,l2+1))
-              hm = local_h(i, l2)
- 8020         continue
-                sm = sm +pplay(i,l)**RKAPPA*(paprs(i,l)-paprs(i,l+1))
-                hm = hm +pplay(i,l)**RKAPPA*(paprs(i,l)-paprs(i,l+1))
-     .                         * (local_h(i, l) - hm) / sm
-                down = .false.
-                if (l1 .ne. 1) then
-                  if (hm .lt. local_h(i, l1-1)) then
-                    down = .true.
-                  end if
-                end if
-                if (down) then
-                  l1 = l1 - 1
-                  l  = l1
-                else
-                  if ((l2 .eq. klev)) GOTO 8021
-                  IF ((local_h(i, l2+1).ge.hm)) goto 8021
-                  l2 = l2 + 1
-                  l  = l2
-                end if
-              go to 8020
- 8021         continue
-c------------ nouveau profil : constant (valeur moyenne)
-              do 1100 l = l1, l2
-                local_h(i, l) = hm
- 1100         continue
-              l2 = l2 + 1
-            end if
-          go to 8000
- 8001     continue
-        end if
- 1080 continue
-c
-      DO l = 1, klev
-      DO i = 1, klon
-         d_t(i,l) = local_h(i,l)*(pplay(i,l)**RKAPPA)/RCPD - t(i,l)
-      ENDDO
-      ENDDO
-c
-      RETURN
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/clmain.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/clmain.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/clmain.F	(revision 892)
@@ -823,5 +823,5 @@
          zx_alf2(i) = 1.0 - zx_alf1(i)
          zx_coef(i,1) = coef(i,1)
-     .                 * (1.0+SQRT(u1lay(i)**2+v1lay(i)**2))
+     .                 * SQRT(u1lay(i)**2+v1lay(i)**2)
      .                 * pplay(i,1)/(RD*t(i,1))
          zx_coef(i,1) = zx_coef(i,1) * dtime*RG
Index: trunk/LMDZ.VENUS/libf/phyvenus/clmain.classic
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/clmain.classic	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/clmain.classic	(revision 892)
@@ -822,5 +822,5 @@
          zx_alf2(i) = 1.0 - zx_alf1(i)
          zx_coef(i,1) = coef(i,1)
-     .                 * (1.0+SQRT(u1lay(i)**2+v1lay(i)**2))
+     .                 * SQRT(u1lay(i)**2+v1lay(i)**2)
      .                 * pplay(i,1)/(RD*t(i,1))
          zx_coef(i,1) = zx_coef(i,1) * dtime*RG
Index: trunk/LMDZ.VENUS/libf/phyvenus/clmain.old
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/clmain.old	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/clmain.old	(revision 892)
@@ -803,5 +803,5 @@
          zx_alf2(i) = 1.0 - zx_alf1(i)
          zx_coef(i,1) = coef(i,1)
-     .                 * (1.0+SQRT(u1lay(i)**2+v1lay(i)**2))
+     .                 * SQRT(u1lay(i)**2+v1lay(i)**2)
      .                 * pplay(i,1)/(RD*t(i,1))
          zx_coef(i,1) = zx_coef(i,1) * dtime*RG
Index: trunk/LMDZ.VENUS/libf/phyvenus/clmain.simple
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/clmain.simple	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/clmain.simple	(revision 892)
@@ -693,5 +693,5 @@
          zx_alf2(i) = 1.0 - zx_alf1(i)
          zx_coef(i,1) = coef(i,1)
-     .                 * (1.0+SQRT(u1lay(i)**2+v1lay(i)**2))
+     .                 * SQRT(u1lay(i)**2+v1lay(i)**2)
      .                 * pplay(i,1)/(RD*t(i,1))
          zx_coef(i,1) = zx_coef(i,1) * dtime*RG
Index: trunk/LMDZ.VENUS/libf/phyvenus/comcstVE.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/comcstVE.h	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/comcstVE.h	(revision 892)
@@ -1,4 +1,4 @@
-c-----------------------------------------------------------------------
-c INCLUDE comcstVE.h
+!-----------------------------------------------------------------------
+! INCLUDE comcstVE.h
 
         integer nnuve,nbztopve,nbpsve,nbmat
@@ -15,3 +15,3 @@
 
 
-c-----------------------------------------------------------------------
+!-----------------------------------------------------------------------
Index: trunk/LMDZ.VENUS/libf/phyvenus/comcstfi.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/comcstfi.h	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/comcstfi.h	(revision 892)
@@ -1,11 +1,10 @@
-c-----------------------------------------------------------------------
-c INCLUDE comcstfi.h
+!-----------------------------------------------------------------------
+! INCLUDE comcstfi.h
 
-      COMMON/comcstfi/
-     * pi,rad,g,r,cpp,rcp,dtphys,daysec,mugaz,omeg
+      COMMON/comcstfi/rad,g,r,cpp,rcp,dtphys,daysec,mugaz,omeg
 
-      REAL pi,rad,g,r,cpp,rcp,dtphys,daysec,mugaz,omeg
+      REAL rad,g,r,cpp,rcp,dtphys,daysec,mugaz,omeg
       real cpdet
       external cpdet
 
-c-----------------------------------------------------------------------
+!-----------------------------------------------------------------------
Index: trunk/LMDZ.VENUS/libf/phyvenus/comg1d.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/comg1d.h	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/comg1d.h	(revision 892)
@@ -1,27 +1,27 @@
-c.......................................................................
-c  le COMMON pour GRADS-1D
-c  (Utilise pour les sorties format Grads dans la version 1D du modele)
-c
-c  on peut se dire : "on ne sauvera pas plus de 1000 variables ... hein ?"
-c
+!.......................................................................
+!  le COMMON pour GRADS-1D
+!  (Utilise pour les sorties format Grads dans la version 1D du modele)
+!
+!  on peut se dire : "on ne sauvera pas plus de 1000 variables ... hein ?"
+!
       INTEGER g1d_nvarmx
       PARAMETER(g1d_nvarmx=1000)
-c
-c         * g1d_nlayer     ---> nombre de couches verticales
-c         * g1d_nomfich    ---> nom du fichier grads
-c         * g1d_unitfich   ---> code du fichier grads
-c         * g1d_nomctl     ---> nom du fichier ctl
-c         * g1d_unitctl    ---> code du fichier ctl
-c         * g1d_premier    ---> variable logique pour dire si le fichier
-c                               est deja ouvert
-c         * g1d_irec       ---> indice de derniere ecriture
-c         * g1d_nvar       ---> nombre de variables deja definies a la
-c                               derniere ecriture
-c         * g1d_nomvar     ---> noms des vecteurs existants
-c         * g1d_dimvar     ---> taille des vecteurs
-c         * g1d_titrevar   ---> titres des vecteurs
-c         * g1d_tmp1       ---> caractere 
-c         * g1d_tmp2       ---> caractere 
-c
+
+!         * g1d_nlayer     ---> nombre de couches verticales
+!         * g1d_nomfich    ---> nom du fichier grads
+!         * g1d_unitfich   ---> code du fichier grads
+!         * g1d_nomctl     ---> nom du fichier ctl
+!         * g1d_unitctl    ---> code du fichier ctl
+!         * g1d_premier    ---> variable logique pour dire si le fichier
+!                               est deja ouvert
+!         * g1d_irec       ---> indice de derniere ecriture
+!         * g1d_nvar       ---> nombre de variables deja definies a la
+!                               derniere ecriture
+!         * g1d_nomvar     ---> noms des vecteurs existants
+!         * g1d_dimvar     ---> taille des vecteurs
+!         * g1d_titrevar   ---> titres des vecteurs
+!         * g1d_tmp1       ---> caractere 
+!         * g1d_tmp2       ---> caractere 
+
       INTEGER g1d_nlayer
       CHARACTER*100 g1d_nomfich
@@ -40,24 +40,23 @@
       CHARACTER*100 g1d_tmp1,g1d_tmp2
 c
-      COMMON/COMG1DI/g1d_nlayer
-     &             ,g1d_unitfich
-     &             ,g1d_unitctl
-     &             ,g1d_irec
-     &             ,g2d_irec
-     &             ,g2d_appel
+      COMMON/COMG1DI/g1d_nlayer                                         &
+     &             ,g1d_unitfich                                        &
+     &             ,g1d_unitctl                                         &
+     &             ,g1d_irec                                            &
+     &             ,g2d_irec                                            &
+     &             ,g2d_appel                                           &
      &             ,g1d_nvar
-      COMMON/COMG1DC/g1d_dimvar(0:g1d_nvarmx)
-     &             ,g1d_nomfich
-     &             ,g1d_nomctl
-     &             ,g1d_nomvar(0:g1d_nvarmx)
-     &             ,g1d_titrevar(0:g1d_nvarmx)
-     &             ,g1d_tmp1
+      COMMON/COMG1DC/g1d_dimvar(0:g1d_nvarmx)                           &
+     &             ,g1d_nomfich                                         &
+     &             ,g1d_nomctl                                          &
+     &             ,g1d_nomvar(0:g1d_nvarmx)                            &
+     &             ,g1d_titrevar(0:g1d_nvarmx)                          &
+     &             ,g1d_tmp1                                            &
      &             ,g1d_tmp2
-      COMMON/COMG1DL/g1d_premier
+      COMMON/COMG1DL/g1d_premier                                        &
      &             ,g2d_premier
-c
 
       integer nbphypers
       common/rythme/nbphypers
-c.......................................................................
+!.......................................................................
 
Index: trunk/LMDZ.VENUS/libf/phyvenus/comgeomphy.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/comgeomphy.F90	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/comgeomphy.F90	(revision 892)
@@ -9,13 +9,13 @@
   
   subroutine initcomgeomphy
-  use dimphy
+  USE mod_phys_lmdz_para
   implicit none
     
  
-    allocate(airephy(klon))
-    allocate(cuphy(klon))
-    allocate(cvphy(klon))
-    allocate(rlatd(klon))
-    allocate(rlond(klon))
+    allocate(airephy(klon_omp))
+    allocate(cuphy(klon_omp))
+    allocate(cvphy(klon_omp))
+    allocate(rlatd(klon_omp))
+    allocate(rlond(klon_omp))
 
   end subroutine initcomgeomphy
Index: trunk/LMDZ.VENUS/libf/phyvenus/cpco2.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/cpco2.F	(revision 888)
+++ 	(revision )
@@ -1,14 +1,0 @@
-      function CPCO2(T)
-
-      implicit none
-      
-      real CPCO2,T
-
-c       Computes specific heat of CO2 using a fit to
-c       data from www.engineeringtoolbox.com
-
-        CPCO2 = 100.*(4.79 + 1.4416E-2*T - 7.2933E-6*T*T) !MKS
-c
-      return
-      end
-       
Index: trunk/LMDZ.VENUS/libf/phyvenus/dimphy.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/dimphy.F90	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/dimphy.F90	(revision 892)
@@ -8,9 +8,6 @@
   INTEGER,SAVE :: klevp1
   INTEGER,SAVE :: klevm1
-  INTEGER,SAVE :: kflev
 
 !$OMP THREADPRIVATE(klon,kfdia,kidia,kdlon)
-  REAL,save,allocatable,dimension(:) :: zmasq
-!$OMP THREADPRIVATE(zmasq)   
 
 CONTAINS
@@ -31,7 +28,5 @@
     klevp1=klev+1
     klevm1=klev-1
-    kflev=klev
 !$OMP END MASTER    
-    ALLOCATE(zmasq(klon))    
     
   END SUBROUTINE init_dimphy
Index: trunk/LMDZ.VENUS/libf/phyvenus/ini_histday.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ini_histday.h	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/ini_histday.h	(revision 892)
@@ -3,27 +3,17 @@
 !
       IF (ok_journe) THEN
-c
+
          zsto = dtime
          zout = dtime * REAL(ecrit_day)
          zsto1= dtime * REAL(ecrit_day)
-c
+
          idayref = day_ref
          CALL ymds2ju(annee_ref, 1, idayref, zero, zjulian)
-c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlond,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlond(i+jjmp1-jjm)
-            zx_lon(i,jjmp1) = rlond(i+jjmp1-jjm)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlatd,zx_lat)
-
-c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-c    d'ou le -1.* devant zx_lon et zx_lat	 
-         CALL histbeg("histday.nc", iim,-1.*zx_lon(:,1), jjmp1,
-     .                 -1.*zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, zsto, 
-     .                 nhori, nid_day)
-         write(*,*)'Journee ', itau_phy, zjulian
-         CALL histvert(nid_day, "presnivs", "Vertical levels", "mb",
+
+         call histbeg_phy("histday.nc",itau_phy,
+     .                    zjulian,zsto,nhori,nid_day)
+
+!$OMP MASTER
+         CALL histvert(nid_day, "presnivs", "Vertical levels", "Pa",
      .                 klev, presnivs, nvert)
 
@@ -34,25 +24,25 @@
 c
          CALL histdef(nid_day, "phis", "Surface geop. height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "once",  zsto,zout)
 c
          CALL histdef(nid_day, "aire", "Grid area", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "once",  zsto,zout)
 c
          CALL histdef(nid_day, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "ue", "Zonal energy transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "ve", "Merid energy transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
@@ -65,25 +55,25 @@
 c
          CALL histdef(nid_day, "temp", "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "pres", "Air pressure", "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "geop", "Geopotential height", "m",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "vitv", "Meridional wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "vitw", "Vertical wind", "Pa/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -98,17 +88,17 @@
 c
          CALL histdef(nid_day, "tops", "Solar rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto1,zout)
 c
          CALL histdef(nid_day, "topl", "IR rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto1,zout)
 c
          CALL histdef(nid_day, "sols", "Solar rad. at surf.", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto1,zout)
 c
          CALL histdef(nid_day, "soll", "IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto1,zout)
 c
@@ -116,9 +106,9 @@
 c
          CALL histdef(nid_day, "SWnet", "Net SW flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ave(X)", zsto1,zout)
 c
          CALL histdef(nid_day, "LWnet", "Net LW flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ave(X)", zsto1,zout)
 c
@@ -129,53 +119,53 @@
 c
          CALL histdef(nid_day, "dtdyn", "Dynamics dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
 c         CALL histdef(nid_day, "dtphy", "Physics dT", "K/s",
-c     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c     .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "dtvdf", "Boundary-layer dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "dtajs", "Dry adjust. dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "dtswr", "SW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "dtlwr", "LW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
 c         CALL histdef(nid_day, "dtec", "Cinetic dissip dT", "K/s",
-c     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c     .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dudyn", "Dynamics dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "duvdf", "Boundary-layer dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "duajs", "Dry convection dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dugwo", "GW oro dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dugwno", "GW non-oro dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "dvvdf", "Boundary-layer dV", "m/s2",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ave(X)", zsto,zout)
 c
@@ -190,5 +180,5 @@
          WRITE(str2,'(i2.2)') iq
          CALL histdef(nid_day, "trac"//str2, "Tracer No."//str2, "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
             ELSE
@@ -201,27 +191,25 @@
 c        call histdef(nid_day, "taux", 
 c    $         "Zonal wind stress", "Pa",  
-c    $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+c    $         iim,jj_nb,nhori, 1,1,1, nvert, 32,
 c    $         "ave(X)", zsto,zout)
 c
 c        call histdef(nid_day, "tauy", 
 c    $         "Meridional xind stress", "Pa",  
-c    $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+c    $         iim,jj_nb,nhori, 1,1,1, nvert, 32,
 c    $         "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_day, "cdrm", "Momentum drag coef.", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_day, "cdrh", "Heat drag coef.", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ave(X)", zsto,zout)
 c
       ENDIF !lev_histday.GE.5
 c-------------------------------------------------------
-c
+
          CALL histend(nid_day)
-c
-         ndex2d = 0
-         ndex3d = 0
-c
+!$OMP END MASTER
+
       ENDIF ! fin de test sur ok_journe
Index: trunk/LMDZ.VENUS/libf/phyvenus/ini_histhf.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ini_histhf.h	(revision 888)
+++ 	(revision )
@@ -1,203 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/ini_histhf.h,v 1.2 2005/02/07 16:41:35 fairhead Exp $
-!
-
-      IF (ok_hf) THEN
-c
-        zout = dtime * REAL(NINT(86400./dtime*ecrit_hf))
-        zsto = zout
-        zsto1 = dtime
-        PRINT*, 'La frequence de sortie instant. est de ', ecrit_hf
-c
-         idayref = day_ref
-	 z4julian = zjulian
-         CALL ymds2ju(annee_ref, 1, idayref, zero, z4julian)
-
-c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlon(i+1)
-            zx_lon(i,jjmp1) = rlon(i+1)
-         ENDDO
-
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
-
-	 z4_lon = zx_lon
-	 z4_lat = zx_lat
-	 zpresnivs=presnivs
-         CALL histbeg("histhf", iim,z4_lon(:,1), jjmp1,z4_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, z4julian, zsto1, 
-     .                 nhori, nid_hf)
-
-         CALL histvert(nid_hf, "presnivs", "Vertical levels", "mb",
-     .                 klev, zpresnivs, nvert)
-c
-
-      IF(lev_histhf.GE.1) THEN
-c
-c        CALL histdef(nid_hf, "phis", "Surface geop. height", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-c    .                "once", zsto,zout)
-c
-c        CALL histdef(nid_hf, "aire", "Grid area", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-c    .                "once", zsto,zout)
-c
-         CALL histdef(nid_hf, "aireTER","Grid area CONT","-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zsto,zout)
-c
-         CALL histdef(nid_hf, "contfracATM","% sfce ter+lic ","-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zsto,zout)
-c
-         CALL histdef(nid_hf, "contfracOR","% sfce terre OR", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zsto,zout)
-c
-c Champs 2D:
-c
-         CALL histdef(nid_hf, "t2m", "Temperature 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_hf, "q2m", "Specific humidity", "kg/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_hf, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         print*,'ATTENTION METTRE AVE(X) POUR LES PRECIPS'
-
-         CALL histdef(nid_hf, "rain", "Precipitation", "kg/m^2s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto1,zout)
-c
-cIM ENSEMBLES BEG
-c
-         CALL histdef(nid_hf, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_hf, "slp", "Sea Level Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-c
-         CALL histdef(nid_hf, "u10m", "Vent zonal 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_hf, "v10m", "Vent meridien 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_hf, "wind10m","10-m wind speed","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         DO k=1, nlevENS 
-          IF(clev(k).EQ."500") THEN
-          CALL histdef(nid_hf, "phi"//clev(k),
-     .                "Geopotential"//clev(k)//"mb", "m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-          ENDIF !clev(k).EQ."500"
-         ENDDO !k=1, nlevENS
-c
-      ENDIF !lev_histhf.GE.1
-c
-      IF(lev_histhf.GE.2) THEN
-c
-         CALL histdef(nid_hf, "cldt", "Total cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto1,zout)
-c
-c -- LOOP
-         CALL histdef(nid_hf, "SWdownOR",
-     .                "Sfce incident SW down radiation OR", "W/m^2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto1,zout)
-c
-         CALL histdef(nid_hf, "SWnetOR",
-     .                "Sfce incident SW net radiation OR", "W/m^2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto1,zout)
-c -- LOOP
-c
-         CALL histdef(nid_hf, "LWdownOR",
-     .                "Sfce incident LW radiation OR", "W/m^2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto1,zout)
-      ENDIF !lev_histhf.GE.2
-c
-cIM ENSEMBLES END
-c
-      IF(lev_histhf.GE.3) THEN
-c
-         DO k=1, nlevENS
-c
-          CALL histdef(nid_hf, "t"//clev(k),
-     .                 "Temperature"//clev(k)//"mb","K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-          IF(clev(k).NE."500") THEN
-          CALL histdef(nid_hf, "phi"//clev(k), 
-     .                "Geopotential"//clev(k)//"mb", "m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-          ENDIF
-c
-          CALL histdef(nid_hf, "q"//clev(k),
-     .                 "Specific humidity"//clev(k)//"mb","kg/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         IF(1.EQ.0) THEN
-         CALL histdef(nid_hf, "rh"//clev(k),
-     .                 "Relative humidity"//clev(k)//"mb", "%",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-         ENDIF
-c
-          CALL histdef(nid_hf, "u"//clev(k),
-     .                 "Zonal wind"//clev(k)//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-          CALL histdef(nid_hf, "v"//clev(k),
-     .                 "Meridional wind"//clev(k)//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         ENDDO !nlevENS
-         IF(1.EQ.0) THEN
-         CALL histdef(nid_hf, "cdrm", " Momentum drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_hf, "cdrh", "Heat drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-         ENDIF !(1.EQ.0) THEN
-c
-      ENDIF !lev_histhf.GE.3
-c
-      IF(lev_histhf.GE.4) THEN
-#define histhf3d
-#ifdef histhf3d
-#include "ini_histhf3d.h"
-#endif
-      ENDIF !lev_histhf.GE.4
-c
-c#define histhf3d
-c#ifdef histhf3d
-c#include "ini_histhf3d.h"
-c#endif
-c
-         CALL histend(nid_hf)
-c
-      endif ! ok_hf
Index: trunk/LMDZ.VENUS/libf/phyvenus/ini_histhf3d.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ini_histhf3d.h	(revision 888)
+++ 	(revision )
@@ -1,61 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/ini_histhf3d.h,v 1.1.1.1 2004/05/19 12:53:08 lmdzadmin Exp $
-!
-
-c     IF (ok_hf) THEN
-c
-        zout = dtime * REAL(NINT(86400./dtime*ecrit_hf))
-        zsto = zout
-        zsto1 = dtime
-        PRINT*, 'La frequence de sortie instant. est de ', ecrit_hf
-c
-cIM cf LF
-         idayref = day_ref
-	 z4julian = zjulian
-         CALL ymds2ju(annee_ref, 1, idayref, zero, z4julian)
-
-c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlon(i+1)
-            zx_lon(i,jjmp1) = rlon(i+1)
-         ENDDO
-
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
-
-	 z4_lon = zx_lon
-	 z4_lat = zx_lat
-	 zpresnivs=presnivs
-         CALL histbeg("histhf3d", iim,z4_lon(:,1), jjmp1,z4_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, z4julian, zsto1, 
-     .                 nhori, nid_hf3d)
-
-         CALL histvert(nid_hf3d, "presnivs", "Vertical levels", "mb",
-     .                 klev, zpresnivs, nvert)
-c
-
-c     IF(lev_histhf.GE.4) THEN
-c
-c Champs 3D:
-c
-         CALL histdef(nid_hf3d, "temp", "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_hf3d, "ovap", "Specific humidity", "kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_hf3d, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_hf3d, "vitv", "Meridional wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-c     ENDIF
-c
-         CALL histend(nid_hf3d)
-c
-c     endif ! ok_hf
Index: trunk/LMDZ.VENUS/libf/phyvenus/ini_histins.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ini_histins.h	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/ini_histins.h	(revision 892)
@@ -3,27 +3,17 @@
 !
       IF (ok_instan) THEN
-c
+
           zsto1= dtime
           zsto = dtime * ecrit_ins
           zout = dtime * ecrit_ins
-c
+
          idayref = day_ref
          CALL ymds2ju(annee_ref, 1, idayref, zero, zjulian)
-c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlond,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlond(i+jjmp1-jjm)
-            zx_lon(i,jjmp1) = rlond(i+jjmp1-jjm)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlatd,zx_lat)
-	 
-c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-c    d'ou le -1.* devant zx_lon et zx_lat	 
-         CALL histbeg("histins.nc", iim,-1.*zx_lon(:,1), jjmp1,
-     .                 -1.*zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, zsto1,
-     .                 nhori, nid_ins)
-         write(*,*)'Inst ', itau_phy, zjulian
-         CALL histvert(nid_ins, "presnivs", "Vertical levels", "mb",
+
+         call histbeg_phy("histins.nc",itau_phy,
+     .                    zjulian,zsto,nhori,nid_ins)
+
+!$OMP MASTER
+         CALL histvert(nid_ins, "presnivs", "Vertical levels", "Pa",
      .                 klev, presnivs, nvert)
 
@@ -34,33 +24,33 @@
 c
          CALL histdef(nid_ins, "phis", "Surface geop. height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "once",  zsto,zout)
 c
          CALL histdef(nid_ins, "aire", "Grid area", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "once",  zsto,zout)
 c
          CALL histdef(nid_ins, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ins(X)", zsto,zout)
 c
 c        CALL histdef(nid_ins, "ue", "Zonal energy transport", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ins(X)", zsto,zout)
 c
 c        CALL histdef(nid_ins, "ve", "Merid energy transport", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "cdragh", "Drag coef on T", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "cdragm", "Drag coef on U", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ins(X)", zsto,zout)
 c
@@ -73,41 +63,41 @@
 c
          CALL histdef(nid_ins, "temp", "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "pres", "Air pressure", "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "geop", "Geopotential height", "m",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "vitv", "Meridional wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "vitw", "Vertical wind", "Pa/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "dudyn", "Dynamics dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "duvdf", "Boundary-layer dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
 c        CALL histdef(nid_ins, "mang", "Angular momentum", "kg m2/s",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "Kz", "vertical diffusion coef", "m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
@@ -118,5 +108,5 @@
           WRITE(str2,'(i2.2)') iq
           CALL histdef(nid_ins, tname(iq), ttext(iq), "ppm",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
              ELSE
@@ -128,5 +118,5 @@
 c
          CALL histdef(nid_ins, "tops", "Solar rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ins(X)", zsto,zout)
 c
@@ -141,13 +131,13 @@
 c
          CALL histdef(nid_ins, "topl", "IR rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "sols", "Solar rad. at surf.", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "soll", "IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ins(X)", zsto,zout)
 c
@@ -155,25 +145,25 @@
 c
          CALL histdef(nid_ins, "SWnet", "Net SW flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "LWnet", "Net LW flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "fluxvdf", "PBL net flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "fluxdyn", "Dyn. net flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "fluxajs", "Dry adj. net flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ins(X)", zsto,zout)
 c
 c        CALL histdef(nid_ins, "fluxec", "Cin. net flux","W/m2",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert,
 c    .                32, "ins(X)", zsto,zout)
 c
@@ -184,45 +174,45 @@
 c
          CALL histdef(nid_ins, "dtdyn", "Dynamics dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
 c        CALL histdef(nid_ins, "dtphy", "Physics dT", "K/s",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "dtvdf", "Boundary-layer dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "dtajs", "Dry adjust. dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "dtswr", "SW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "dtlwr", "LW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
 c        CALL histdef(nid_ins, "dtec", "Cinetic dissip dT", "K/s",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "duajs", "Dry convection dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "dugwo", "GW oro dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "dugwno", "GW non-oro dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ins(X)", zsto,zout)
 c
 c        CALL histdef(nid_ins, "dvvdf", "Boundary-layer dV", "m/s2",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ins(X)", zsto,zout)
 c
@@ -234,18 +224,18 @@
 c        call histdef(nid_ins, "taux", 
 c    $         "Zonal wind stress", "Pa",  
-c    $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+c    $         iim,jj_nb,nhori, 1,1,1, nvert, 32,
 c    $         "ins(X)", zsto,zout)
 c
 c        call histdef(nid_ins, "tauy", 
 c    $         "Meridional xind stress", "Pa",  
-c    $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+c    $         iim,jj_nb,nhori, 1,1,1, nvert, 32,
 c    $         "ins(X)", zsto,zout)
 c
 c        CALL histdef(nid_ins, "cdrm", "Momentum drag coef.", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ins(X)", zsto,zout)
 c
 c        CALL histdef(nid_ins, "cdrh", "Heat drag coef.", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ins(X)", zsto,zout)
 c
@@ -254,7 +244,5 @@
 c
          CALL histend(nid_ins)
-c
-         ndex2d = 0
-         ndex3d = 0
-c
+!$OMP END MASTER
+
       ENDIF
Index: trunk/LMDZ.VENUS/libf/phyvenus/ini_histmth.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ini_histmth.h	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/ini_histmth.h	(revision 892)
@@ -3,8 +3,8 @@
 !
       IF (ok_mensuel) THEN
-c
+
          zsto = dtime
          zout = dtime * ecrit_mth
-c
+
 c zsto1: pour des valeurs "instantanees" mensuelles
          zsto1 = dtime * ecrit_mth
@@ -12,23 +12,13 @@
          zsto2 = dtime * radpas
          PRINT*,' zsto,zsto1,zsto2,zout=',zsto, zsto1, zsto2,zout
-c
+
          idayref = day_ref
          CALL ymds2ju(annee_ref, 1, idayref, zero, zjulian)
-c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlond,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlond(i+jjmp1-jjm)
-            zx_lon(i,jjmp1) = rlond(i+jjmp1-jjm)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlatd,zx_lat)
-	 
-c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-c    d'ou le -1.* devant zx_lon et zx_lat	 
-         CALL histbeg("histmth.nc", iim,-1.*zx_lon(:,1), jjmp1,
-     .                 -1.*zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, zsto, 
-     .                 nhori, nid_mth)
-         write(*,*)'Mensuel ', itau_phy, zjulian
-         CALL histvert(nid_mth, "presnivs", "Vertical levels", "mb",
+
+         call histbeg_phy("histmth.nc",itau_phy,
+     .                    zjulian,zsto,nhori,nid_mth)
+
+!$OMP MASTER
+         CALL histvert(nid_mth, "presnivs", "Vertical levels", "Pa",
      .                 klev, presnivs, nvert)
 
@@ -39,33 +29,33 @@
 c
          CALL histdef(nid_mth, "phis", "Surface geop. height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "once",  zsto,zout)
 c
          CALL histdef(nid_mth, "aire", "Grid area", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "once",  zsto,zout)
 c
          CALL histdef(nid_mth, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "ue", "Zonal energy transport", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "ve", "Merid energy transport", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "cdragh", "Drag coef on T", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "cdragm", "Drag coef on U", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
@@ -78,41 +68,41 @@
 c
          CALL histdef(nid_mth, "temp", "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "pres", "Air pressure", "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "geop", "Geopotential height", "m",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "vitv", "Meridional wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "vitw", "Vertical wind", "Pa/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dudyn", "Dynamics dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "duvdf", "Boundary-layer dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "mang", "Angular momentum", "kg m2/s",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "Kz", "vertical diffusion coef", "m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -123,5 +113,5 @@
           WRITE(str2,'(i2.2)') iq
           CALL histdef(nid_mth, tname(iq), ttext(iq), "ppm",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
              ELSE
@@ -133,5 +123,5 @@
 c
          CALL histdef(nid_mth, "tops", "Solar rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto2,zout)
 c
@@ -146,13 +136,13 @@
 c
          CALL histdef(nid_mth, "topl", "IR rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "sols", "Solar rad. at surf.", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "soll", "IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
      .                "ave(X)", zsto2,zout)
 c
@@ -160,25 +150,25 @@
 c
          CALL histdef(nid_mth, "SWnet", "Net SW flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "LWnet", "Net LW flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "fluxvdf", "PBL net flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "fluxdyn", "Dyn. net flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "fluxajs", "Dry adj. net flux","W/m2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert,
      .                32, "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "fluxec", "Cin. net flux","W/m2",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert,
 c    .                32, "ave(X)", zsto,zout)
 c
@@ -189,45 +179,45 @@
 c
          CALL histdef(nid_mth, "dtdyn", "Dynamics dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "dtphy", "Physics dT", "K/s",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtvdf", "Boundary-layer dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtajs", "Dry adjust. dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtswr", "SW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtlwr", "LW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "dtec", "Cinetic dissip dT", "K/s",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "duajs", "Dry convection dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dugwo", "GW oro dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dugwno", "GW non-oro dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "dvvdf", "Boundary-layer dV", "m/s2",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jj_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ave(X)", zsto,zout)
 c
@@ -239,27 +229,25 @@
 c        call histdef(nid_mth, "taux", 
 c    $         "Zonal wind stress", "Pa",  
-c    $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+c    $         iim,jj_nb,nhori, 1,1,1, nvert, 32,
 c    $         "ave(X)", zsto,zout)
 c
 c        call histdef(nid_mth, "tauy", 
 c    $         "Meridional xind stress", "Pa",  
-c    $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+c    $         iim,jj_nb,nhori, 1,1,1, nvert, 32,
 c    $         "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "cdrm", "Momentum drag coef.", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "cdrh", "Heat drag coef.", "-",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jj_nb,nhori, 1,1,1, nvert, 32, 
 c    .                "ave(X)", zsto,zout)
 c
       ENDIF !lev_histmth.GE.5
 c-------------------------------------------------------
-c
+
          CALL histend(nid_mth)
-c
-         ndex2d = 0
-         ndex3d = 0
-c
+!$OMP END MASTER
+
       ENDIF ! fin de test sur ok_mensuel
Index: trunk/LMDZ.VENUS/libf/phyvenus/ini_histrac.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ini_histrac.h	(revision 888)
+++ 	(revision )
@@ -1,36 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/ini_histrac.h,v 1.2 2004/10/18 15:42:20 lmdzadmin Exp $
-!
-         zsto = pdtphys
-	 z4julian = zjulian
-         CALL ymds2ju(annee_ref, 1, idayref, zero, z4julian)
-c
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,xlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = xlon(i+1)
-            zx_lon(i,jjm+1) = xlon(i+1)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,xlat,zx_lat)
-	 z4_lon = zx_lon
-	 z4_lat = zx_lat
-	 zpresnivs=presnivs
-         CALL histbeg("histrac", iim,z4_lon(:,1), jjm+1,z4_lat(1,:),
-     .                 1,iim,1,jjm+1, itau_phy, z4julian, zsto,
-     .                 nhori, nid_tra)
-         CALL histvert(nid_tra, "presnivs", "Vertical levels", "mb",
-     .                 klev, zpresnivs, nvert)
-
-         zout = pdtphys * REAL(ecrit_tra)
-c
-         CALL histdef(nid_tra, "phis", "Surface geop. height", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "once",  zsto,zout)
-c
-         CALL histdef(nid_tra, "aire", "Grid area", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "once",  zsto,zout)
-c
-         CALL histend(nid_tra)
-         ndex2d = 0
-         ndex3d = 0
-         ndex = 0
Index: trunk/LMDZ.VENUS/libf/phyvenus/inifis.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/inifis.F	(revision 888)
+++ 	(revision )
@@ -1,73 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/inifis.F,v 1.1.1.1 2004/05/19 12:53:08 lmdzadmin Exp $
-!
-      SUBROUTINE inifis(ngrid,nlayer,
-     $           punjours,
-     $           pdayref,ptimestep,
-     $           plat,plon,parea,
-     $           prad,pg,pr,pcpp)
-
-      use dimphy
-      IMPLICIT NONE
-c
-c=======================================================================
-c
-c   subject:
-c   --------
-c
-c   Initialisation for the physical parametrisations of the LMD 
-c   martian atmospheric general circulation modele.
-c
-c   author: Frederic Hourdin 15 / 10 /93
-c   -------
-c
-c   arguments:
-c   ----------
-c
-c   input:
-c   ------
-c
-c    ngrid                 Size of the horizontal grid.
-c                          All internal loops are performed on that grid.
-c    nlayer                Number of vertical layers.
-c    pdayref               Day of reference for the simulation
-c    firstcall             True at the first call
-c    lastcall              True at the last call
-c    pday                  Number of days counted from the North. Spring
-c                          equinoxe.
-c
-c=======================================================================
-c
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
- 
-#include "dimensions.h"
-
-      REAL prad,pg,pr,pcpp,punjours
- 
-      INTEGER ngrid,nlayer
-      REAL plat(ngrid),plon(ngrid),parea(klon)
-      INTEGER pdayref
- 
-      REAL ptimestep
- 
-      IF (nlayer.NE.klev) THEN
-         PRINT*,'STOP in inifis'
-         PRINT*,'Probleme de dimensions :'
-         PRINT*,'nlayer     = ',nlayer
-         PRINT*,'klev   = ',klev
-         STOP
-      ENDIF
-
-      IF (ngrid.NE.klon) THEN
-         PRINT*,'STOP in inifis'
-         PRINT*,'Probleme de dimensions :'
-         PRINT*,'ngrid     = ',ngrid
-         PRINT*,'klon   = ',klon
-         STOP
-      ENDIF
-
-      RETURN
-9999  STOP'Cette version demande les fichier rnatur.dat et surf.def'
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/iniphysiq.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/iniphysiq.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/iniphysiq.F	(revision 892)
@@ -43,43 +43,86 @@
 c   -------------
  
-      use dimphy
-      USE comgeomphy
+      USE dimphy, only : klev
+      USE mod_grid_phy_lmdz, only : klon_glo
+      USE mod_phys_lmdz_para, only : klon_omp,klon_omp_begin,
+     &                               klon_omp_end,klon_mpi_begin
+      USE comgeomphy, only : airephy,cuphy,cvphy,rlond,rlatd
       IMPLICIT NONE
-#include "dimensions.h"
+#include "iniprint.h"
 
-      REAL prad,pg,pr,pcpp,punjours
+      REAL,INTENT(IN) :: prad ! radius of the planet (m)
+      REAL,INTENT(IN) :: pg ! gravitational acceleration (m/s2)
+      REAL,INTENT(IN) :: pr ! ! reduced gas constant R/mu
+      REAL,INTENT(IN) :: pcpp ! specific heat Cp
+      REAL,INTENT(IN) :: punjours ! length (in s) of a standard day
+      INTEGER,INTENT(IN) :: ngrid ! number of horizontal grid points in the physics
+      INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
+      REAL,INTENT(IN) :: plat(ngrid) ! latitudes of the physics grid
+      REAL,INTENT(IN) :: plon(ngrid) ! longitudes of the physics grid
+      REAL,INTENT(IN) :: parea(klon_glo) ! area (m2)
+      REAL,INTENT(IN) :: pcu(klon_glo) ! cu coeff. (u_covariant = cu * u)
+      REAL,INTENT(IN) :: pcv(klon_glo) ! cv coeff. (v_covariant = cv * v)
+      INTEGER,INTENT(IN) :: pdayref ! reference day of for the simulation
+      REAL,INTENT(IN) :: ptimestep !physics time step (s)
       INTEGER,INTENT(IN) :: iflag_phys ! type of physics to be called
-      INTEGER ngrid,nlayer
-      REAL plat(ngrid),plon(ngrid),parea(klon),pcu(klon),pcv(klon)
-      INTEGER pdayref
- 
-      REAL ptimestep
+
+      INTEGER :: ibegin,iend,offset
+      CHARACTER (LEN=20) :: modname='iniphysiq'
+      CHARACTER (LEN=80) :: abort_message
  
       IF (nlayer.NE.klev) THEN
-         PRINT*,'STOP in inifis'
-         PRINT*,'Probleme de dimensions :'
-         PRINT*,'nlayer     = ',nlayer
-         PRINT*,'klev   = ',klev
-         STOP
+         write(lunout,*) 'STOP in ',trim(modname)
+         write(lunout,*) 'Problem with dimensions :'
+         write(lunout,*) 'nlayer     = ',nlayer
+         write(lunout,*) 'klev   = ',klev
+         abort_message = ''
+         CALL abort_gcm (modname,abort_message,1)
       ENDIF
 
-      IF (ngrid.NE.klon) THEN
-         PRINT*,'STOP in inifis'
-         PRINT*,'Probleme de dimensions :'
-         PRINT*,'ngrid     = ',ngrid
-         PRINT*,'klon   = ',klon
-         STOP
+      IF (ngrid.NE.klon_glo) THEN
+         write(lunout,*) 'STOP in ',trim(modname)
+         write(lunout,*) 'Problem with dimensions :'
+         write(lunout,*) 'ngrid     = ',ngrid
+         write(lunout,*) 'klon   = ',klon_glo
+         abort_message = ''
+         CALL abort_gcm (modname,abort_message,1)
       ENDIF
 
-      airephy=parea
-      cuphy=pcu
-      cvphy=pcv
-      rlond = plon
-      rlatd = plat
+c$OMP PARALLEL PRIVATE(ibegin,iend) 
+c$OMP+         SHARED(parea,pcu,pcv,plon,plat)
+      
+      offset=klon_mpi_begin-1
+      airephy(1:klon_omp)=parea(offset+klon_omp_begin:
+     &                          offset+klon_omp_end)
+      cuphy(1:klon_omp)=pcu(offset+klon_omp_begin:offset+klon_omp_end)
+      cvphy(1:klon_omp)=pcv(offset+klon_omp_begin:offset+klon_omp_end)
+      rlond(1:klon_omp)=plon(offset+klon_omp_begin:offset+klon_omp_end)
+      rlatd(1:klon_omp)=plat(offset+klon_omp_begin:offset+klon_omp_end)
 
       call suphec
+
+c$OMP END PARALLEL
+
 c     print*,'ATTENTION !!! TRAVAILLER SUR INIPHYSIQ'
 c     print*,'CONTROLE DES LATITUDES, LONGITUDES, PARAMETRES ...'
 
+c      print*,'agagagagagagagagaga'
+c      print*,'klon_mpi_begin =', klon_mpi_begin
+c      print*,'klon_mpi_end =', klon_mpi_end
+c      print*,'klon_mpi =', klon_mpi
+c      print*,'klon_mpi_para_nb =', klon_mpi_para_nb
+c      print*,'klon_mpi_para_begin =', klon_mpi_para_begin
+c      print*,'klon_mpi_para_end  =', klon_mpi_para_end
+c      print*,'mpi_rank =', mpi_rank
+c      print*,'mpi_size =', mpi_size
+c      print*,'mpi_root =', mpi_root
+c      print*,'klon_glo =', klon_glo
+c      print*,'is_mpi_root =',is_mpi_root
+c      print*,'is_omp_root =',is_omp_root
+
+! pas d'inifis ici... 
+! est-ce que cursor est utile ? Voir avec Aymeric
+!      cursor = klon_mpi_begin
+!      print*, "CURSOR !!!!", mpi_rank, cursor
 
       RETURN
Index: trunk/LMDZ.VENUS/libf/phyvenus/init_phys_lmdz.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/init_phys_lmdz.F90	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/init_phys_lmdz.F90	(revision 892)
@@ -3,6 +3,9 @@
 !
 SUBROUTINE init_phys_lmdz(iim,jjp1,llm,nb_proc,distrib)
+  USE mod_phys_lmdz_para
   USE mod_grid_phy_lmdz
-  USE dimphy
+  USE dimphy, ONLY : init_dimphy
+  USE infotrac, ONLY : type_trac
+
   IMPLICIT NONE
   
@@ -15,5 +18,8 @@
 
     CALL init_grid_phy_lmdz(iim,jjp1,llm)
-    CALL init_dimphy(klon_glo,nbp_lev)
+    CALL init_phys_lmdz_para(iim,jjp1,nb_proc,distrib)
+!$OMP PARALLEL
+    CALL init_dimphy(klon_omp,nbp_lev)
+!$OMP END PARALLEL
  
 END SUBROUTINE init_phys_lmdz  
Index: trunk/LMDZ.VENUS/libf/phyvenus/interface_surf.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/interface_surf.F90	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/interface_surf.F90	(revision 892)
@@ -256,5 +256,5 @@
 
     zx_coef(i) = coef1lay(i) &
-     & * (1.0+SQRT(u1lay(i)**2+v1lay(i)**2)) &
+     & * SQRT(u1lay(i)**2+v1lay(i)**2) &
      & * p1lay(i)/(RD*t1lay(i))
 
Index: trunk/LMDZ.VENUS/libf/phyvenus/iophy.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/iophy.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/iophy.F90	(revision 892)
@@ -0,0 +1,448 @@
+!
+! $Header$
+!
+module iophy
+  
+! abd  REAL,private,allocatable,dimension(:),save :: io_lat
+! abd  REAL,private,allocatable,dimension(:),save :: io_lon
+  REAL,allocatable,dimension(:),save :: io_lat
+  REAL,allocatable,dimension(:),save :: io_lon
+  INTEGER, save :: phys_domain_id
+  INTEGER, save :: npstn
+  INTEGER, allocatable, dimension(:), save :: nptabij
+  
+  INTERFACE histwrite_phy
+    MODULE PROCEDURE histwrite2d_phy,histwrite3d_phy
+  END INTERFACE
+
+  INTERFACE histbeg_phy_all
+    MODULE PROCEDURE histbeg_phy,histbeg_phy_points
+  END INTERFACE
+
+
+contains
+
+  subroutine init_iophy_new(rlat,rlon)
+  USE dimphy
+  USE mod_phys_lmdz_para
+  USE mod_grid_phy_lmdz
+  USE ioipsl
+  implicit none
+  include 'dimensions.h'   
+    real,dimension(klon),intent(in) :: rlon
+    real,dimension(klon),intent(in) :: rlat
+
+    REAL,dimension(klon_glo)        :: rlat_glo
+    REAL,dimension(klon_glo)        :: rlon_glo
+    
+    INTEGER,DIMENSION(2) :: ddid
+    INTEGER,DIMENSION(2) :: dsg
+    INTEGER,DIMENSION(2) :: dsl
+    INTEGER,DIMENSION(2) :: dpf
+    INTEGER,DIMENSION(2) :: dpl
+    INTEGER,DIMENSION(2) :: dhs
+    INTEGER,DIMENSION(2) :: dhe 
+    INTEGER :: i    
+
+    CALL gather(rlat,rlat_glo)
+    CALL bcast(rlat_glo)
+    CALL gather(rlon,rlon_glo)
+    CALL bcast(rlon_glo)
+    
+!$OMP MASTER  
+    ALLOCATE(io_lat(jjm+1-1/(iim*jjm)))
+    io_lat(1)=rlat_glo(1)
+    io_lat(jjm+1-1/(iim*jjm))=rlat_glo(klon_glo)
+    IF ((iim*jjm) > 1) then
+      DO i=2,jjm
+        io_lat(i)=rlat_glo(2+(i-2)*iim)
+      ENDDO
+    ENDIF
+
+    ALLOCATE(io_lon(iim))
+    io_lon(:)=rlon_glo(2-1/(iim*jjm):iim+1-1/(iim*jjm))
+
+! POUR VENUS, LA CARTE EST A L ENVERS !!
+    io_lat = -1.*io_lat
+    io_lon = -1.*io_lon
+
+    ddid=(/ 1,2 /)
+    dsg=(/ iim, jjm+1-1/(iim*jjm) /)
+    dsl=(/ iim, jj_nb /)
+    dpf=(/ 1,jj_begin /)
+    dpl=(/ iim, jj_end /)
+    dhs=(/ ii_begin-1,0 /)
+    if (mpi_rank==mpi_size-1) then
+      dhe=(/0,0/)
+    else
+      dhe=(/ iim-ii_end,0 /)  
+    endif
+    
+    call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
+                      'APPLE',phys_domain_id)
+
+!$OMP END MASTER
+      
+  end subroutine init_iophy_new
+
+  subroutine init_iophy(lat,lon)
+  USE dimphy
+  USE mod_phys_lmdz_para
+  use ioipsl
+  implicit none
+  include 'dimensions.h'   
+    real,dimension(iim),intent(in) :: lon
+    real,dimension(jjm+1-1/(iim*jjm)),intent(in) :: lat
+
+    INTEGER,DIMENSION(2) :: ddid
+    INTEGER,DIMENSION(2) :: dsg
+    INTEGER,DIMENSION(2) :: dsl
+    INTEGER,DIMENSION(2) :: dpf
+    INTEGER,DIMENSION(2) :: dpl
+    INTEGER,DIMENSION(2) :: dhs
+    INTEGER,DIMENSION(2) :: dhe 
+
+!$OMP MASTER  
+    allocate(io_lat(jjm+1-1/(iim*jjm)))
+    io_lat(:)=lat(:)
+    allocate(io_lon(iim))
+    io_lon(:)=lon(:)
+   
+    ddid=(/ 1,2 /)
+    dsg=(/ iim, jjm+1-1/(iim*jjm) /)
+    dsl=(/ iim, jj_nb /)
+    dpf=(/ 1,jj_begin /)
+    dpl=(/ iim, jj_end /)
+    dhs=(/ ii_begin-1,0 /)
+    if (mpi_rank==mpi_size-1) then
+      dhe=(/0,0/)
+    else
+      dhe=(/ iim-ii_end,0 /)  
+    endif
+    
+    call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
+                      'APPLE',phys_domain_id)
+
+!$OMP END MASTER
+      
+  end subroutine init_iophy
+  
+  subroutine histbeg_phy(name,itau0,zjulian,dtime,nhori,nid_day)
+  USE dimphy
+  USE mod_phys_lmdz_para
+  use ioipsl
+  use write_field
+  implicit none
+  include 'dimensions.h'
+    
+    character*(*), intent(IN) :: name
+    integer, intent(in) :: itau0
+    real,intent(in) :: zjulian
+    real,intent(in) :: dtime
+    integer,intent(out) :: nhori
+    integer,intent(out) :: nid_day
+
+!$OMP MASTER    
+    if (is_sequential) then
+      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
+                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day)
+    else
+      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
+                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
+    endif
+!$OMP END MASTER
+  
+  end subroutine histbeg_phy
+
+  subroutine histbeg_phy_points(rlon,rlat,pim,tabij,ipt,jpt, &
+             plon,plat,plon_bounds,plat_bounds, &
+             nname,itau0,zjulian,dtime,nnhori,nnid_day)
+  USE dimphy
+  USE mod_phys_lmdz_para
+  USE mod_grid_phy_lmdz
+  use ioipsl
+  use write_field
+  implicit none
+  include 'dimensions.h' 
+
+    real,dimension(klon),intent(in) :: rlon
+    real,dimension(klon),intent(in) :: rlat
+    integer, intent(in) :: itau0
+    real,intent(in) :: zjulian
+    real,intent(in) :: dtime
+    integer, intent(in) :: pim
+    integer, intent(out) :: nnhori
+    character(len=20), intent(in) :: nname
+    INTEGER, intent(out) :: nnid_day
+    integer :: i
+    REAL,dimension(klon_glo)        :: rlat_glo
+    REAL,dimension(klon_glo)        :: rlon_glo
+    INTEGER, DIMENSION(pim), intent(in)  :: tabij
+    REAL,dimension(pim), intent(in) :: plat, plon
+    INTEGER,dimension(pim), intent(in) :: ipt, jpt
+    REAL,dimension(pim,2), intent(out) :: plat_bounds, plon_bounds
+
+    INTEGER, SAVE :: tabprocbeg, tabprocend
+!$OMP THREADPRIVATE(tabprocbeg, tabprocend)
+    INTEGER :: ip
+    INTEGER, PARAMETER :: nip=1
+    INTEGER :: npproc
+    REAL, allocatable, dimension(:) :: npplat, npplon
+    REAL, allocatable, dimension(:,:) :: npplat_bounds, npplon_bounds
+    INTEGER, PARAMETER :: jjmp1=jjm+1-1/jjm
+    REAL, dimension(iim,jjmp1) :: zx_lon, zx_lat
+
+    CALL gather(rlat,rlat_glo)
+    CALL bcast(rlat_glo)
+    CALL gather(rlon,rlon_glo)
+    CALL bcast(rlon_glo)
+
+!$OMP MASTER
+    DO i=1,pim
+
+!    print*,'CFMIP_iophy i tabij lon lat',i,tabij(i),plon(i),plat(i)
+
+     plon_bounds(i,1)=rlon_glo(tabij(i)-1)
+     plon_bounds(i,2)=rlon_glo(tabij(i)+1)
+     if(plon_bounds(i,2).LE.0..AND.plon_bounds(i,1).GE.0.) THEN
+      if(rlon_glo(tabij(i)).GE.0.) THEN
+       plon_bounds(i,2)=-1*plon_bounds(i,2)
+      endif
+     endif
+     if(plon_bounds(i,2).GE.0..AND.plon_bounds(i,1).LE.0.) THEN
+      if(rlon_glo(tabij(i)).LE.0.) THEN
+       plon_bounds(i,2)=-1*plon_bounds(i,2)
+      endif
+     endif
+!
+     IF ( tabij(i).LE.iim) THEN
+      plat_bounds(i,1)=rlat_glo(tabij(i))
+     ELSE
+      plat_bounds(i,1)=rlat_glo(tabij(i)-iim)
+     ENDIF
+     plat_bounds(i,2)=rlat_glo(tabij(i)+iim)
+!
+!    print*,'CFMIP_iophy point i lon lon_bds',i,plon_bounds(i,1),rlon_glo(tabij(i)),plon_bounds(i,2) 
+!    print*,'CFMIP_iophy point i lat lat_bds',i,plat_bounds(i,1),rlat_glo(tabij(i)),plat_bounds(i,2) 
+!
+    ENDDO
+    if (is_sequential) then
+
+     npstn=pim
+     IF(.NOT. ALLOCATED(nptabij)) THEN
+      ALLOCATE(nptabij(pim))
+     ENDIF 
+     DO i=1,pim
+      nptabij(i)=tabij(i)
+     ENDDO
+
+       CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon_glo,zx_lon)
+       if ((iim*jjm).gt.1) then
+       DO i = 1, iim
+         zx_lon(i,1) = rlon_glo(i+1)
+         zx_lon(i,jjmp1) = rlon_glo(i+1)
+       ENDDO
+       endif
+       CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat_glo,zx_lat)
+
+    DO i=1,pim
+!    print*,'CFMIP_iophy i tabij lon lat',i,tabij(i),plon(i),plat(i)
+
+     plon_bounds(i,1)=zx_lon(ipt(i)-1,jpt(i))
+     plon_bounds(i,2)=zx_lon(ipt(i)+1,jpt(i))
+
+     if (ipt(i).EQ.1) then
+      plon_bounds(i,1)=zx_lon(iim,jpt(i))
+      plon_bounds(i,2)=360.+zx_lon(ipt(i)+1,jpt(i))
+     endif
+ 
+     if (ipt(i).EQ.iim) then
+      plon_bounds(i,2)=360.+zx_lon(1,jpt(i))
+     endif
+
+     plat_bounds(i,1)=zx_lat(ipt(i),jpt(i)-1)
+     plat_bounds(i,2)=zx_lat(ipt(i),jpt(i)+1)
+
+     if (jpt(i).EQ.1) then
+      plat_bounds(i,1)=zx_lat(ipt(i),1)+0.001
+      plat_bounds(i,2)=zx_lat(ipt(i),1)-0.001
+     endif
+ 
+     if (jpt(i).EQ.jjmp1) then
+      plat_bounds(i,1)=zx_lat(ipt(i),jjmp1)+0.001
+      plat_bounds(i,2)=zx_lat(ipt(i),jjmp1)-0.001
+     endif
+!
+!    print*,'CFMIP_iophy point i lon lon_bds',i,plon_bounds(i,1),rlon(tabij(i)),plon_bounds(i,2) 
+!    print*,'CFMIP_iophy point i lat lat_bds',i,plat_bounds(i,1),rlat(tabij(i)),plat_bounds(i,2) 
+!
+    ENDDO
+!    print*,'iophy is_sequential nname, nnhori, nnid_day=',trim(nname),nnhori,nnid_day
+     call histbeg(nname,pim,plon,plon_bounds, & 
+                           plat,plat_bounds, &
+                           itau0, zjulian, dtime, nnhori, nnid_day)
+    else
+     npproc=0
+     DO ip=1, pim
+      tabprocbeg=klon_mpi_begin
+      tabprocend=klon_mpi_end
+      IF(tabij(ip).GE.tabprocbeg.AND.tabij(ip).LE.tabprocend) THEN
+       npproc=npproc+1
+       npstn=npproc
+      ENDIF 
+     ENDDO
+!    print*,'CFMIP_iophy mpi_rank npstn',mpi_rank,npstn
+     IF(.NOT. ALLOCATED(nptabij)) THEN
+      ALLOCATE(nptabij(npstn))
+      ALLOCATE(npplon(npstn), npplat(npstn))
+      ALLOCATE(npplon_bounds(npstn,2), npplat_bounds(npstn,2))
+     ENDIF
+     npproc=0
+     DO ip=1, pim
+      IF(tabij(ip).GE.tabprocbeg.AND.tabij(ip).LE.tabprocend) THEN
+       npproc=npproc+1
+       nptabij(npproc)=tabij(ip)
+!      print*,'mpi_rank npproc ip plon plat tabij=',mpi_rank,npproc,ip, &
+!      plon(ip),plat(ip),tabij(ip)
+       npplon(npproc)=plon(ip)
+       npplat(npproc)=plat(ip)
+       npplon_bounds(npproc,1)=plon_bounds(ip,1)
+       npplon_bounds(npproc,2)=plon_bounds(ip,2)
+       npplat_bounds(npproc,1)=plat_bounds(ip,1)
+       npplat_bounds(npproc,2)=plat_bounds(ip,2)
+!!!
+!!! print qui sert a reordonner les points stations selon l'ordre CFMIP
+!!! ne pas enlever
+        print*,'iophy_mpi rank ip lon lat',mpi_rank,ip,plon(ip),plat(ip)
+!!!
+      ENDIF
+     ENDDO
+     call histbeg(nname,npstn,npplon,npplon_bounds, &
+                            npplat,npplat_bounds, &
+                            itau0,zjulian,dtime,nnhori,nnid_day,phys_domain_id)
+    endif
+!$OMP END MASTER
+
+  end subroutine histbeg_phy_points
+ 
+  subroutine histwrite2d_phy(nid,lpoint,name,itau,field)
+  USE dimphy
+  USE mod_phys_lmdz_para
+  USE ioipsl
+  implicit none
+  include 'dimensions.h'
+    
+    integer,intent(in) :: nid
+    logical,intent(in) :: lpoint 
+    character*(*), intent(IN) :: name
+    integer, intent(in) :: itau
+    real,dimension(:),intent(in) :: field
+    REAL,dimension(klon_mpi) :: buffer_omp
+    INTEGER, allocatable, dimension(:) :: index2d
+    REAL :: Field2d(iim,jj_nb)
+
+    integer :: ip
+    real,allocatable,dimension(:) :: fieldok
+
+    IF (size(field)/=klon) CALL abort_gcm('iophy::histwrite2d','Field first dimension not equal to klon',1)
+    
+    CALL Gather_omp(field,buffer_omp)    
+!$OMP MASTER
+    CALL grid1Dto2D_mpi(buffer_omp,Field2d)
+    if(.NOT.lpoint) THEN
+     ALLOCATE(index2d(iim*jj_nb))
+     ALLOCATE(fieldok(iim*jj_nb))
+     CALL histwrite(nid,name,itau,Field2d,iim*jj_nb,index2d)
+    else
+     ALLOCATE(fieldok(npstn))
+     ALLOCATE(index2d(npstn))
+
+     if(is_sequential) then
+!     klon_mpi_begin=1
+!     klon_mpi_end=klon
+      DO ip=1, npstn
+       fieldok(ip)=buffer_omp(nptabij(ip))
+      ENDDO
+     else
+      DO ip=1, npstn
+!     print*,'histwrite2d is_sequential npstn ip name nptabij',npstn,ip,name,nptabij(ip)
+       IF(nptabij(ip).GE.klon_mpi_begin.AND. &
+          nptabij(ip).LE.klon_mpi_end) THEN
+         fieldok(ip)=buffer_omp(nptabij(ip)-klon_mpi_begin+1)
+       ENDIF
+      ENDDO
+     endif
+     CALL histwrite(nid,name,itau,fieldok,npstn,index2d)
+!
+    endif
+    deallocate(index2d)
+    deallocate(fieldok)
+!$OMP END MASTER    
+  end subroutine histwrite2d_phy
+
+  subroutine histwrite3d_phy(nid,lpoint,name,itau,field)
+  USE dimphy
+  USE mod_phys_lmdz_para
+
+  use ioipsl
+  implicit none
+  include 'dimensions.h'
+    
+    integer,intent(in) :: nid
+    logical,intent(in) :: lpoint
+    character*(*), intent(IN) :: name
+    integer, intent(in) :: itau
+    real,dimension(:,:),intent(in) :: field  ! --> field(klon,:)
+    REAL,dimension(klon_mpi,size(field,2)) :: buffer_omp
+    REAL :: Field3d(iim,jj_nb,size(field,2))
+    INTEGER :: ip, n, nlev
+    INTEGER, ALLOCATABLE, dimension(:) :: index3d
+    real,allocatable, dimension(:,:) :: fieldok
+
+    IF (size(field,1)/=klon) CALL abort_gcm('iophy::histwrite3d','Field first dimension not equal to klon',1)
+    nlev=size(field,2)
+
+!   print*,'hist3d_phy mpi_rank npstn=',mpi_rank,npstn
+
+!   DO ip=1, npstn
+!    print*,'hist3d_phy mpi_rank nptabij',mpi_rank,nptabij(ip)
+!   ENDDO
+
+    CALL Gather_omp(field,buffer_omp)
+!$OMP MASTER
+    CALL grid1Dto2D_mpi(buffer_omp,field3d)
+    if(.NOT.lpoint) THEN
+     ALLOCATE(index3d(iim*jj_nb*nlev))
+     ALLOCATE(fieldok(iim*jj_nb,nlev))
+     CALL histwrite(nid,name,itau,Field3d,iim*jj_nb*nlev,index3d)
+    else
+      nlev=size(field,2)
+      ALLOCATE(index3d(npstn*nlev))
+      ALLOCATE(fieldok(npstn,nlev))
+
+      if(is_sequential) then
+!      klon_mpi_begin=1
+!      klon_mpi_end=klon
+       DO n=1, nlev
+       DO ip=1, npstn
+        fieldok(ip,n)=buffer_omp(nptabij(ip),n)
+       ENDDO
+       ENDDO
+      else
+       DO n=1, nlev
+       DO ip=1, npstn
+        IF(nptabij(ip).GE.klon_mpi_begin.AND. &
+         nptabij(ip).LE.klon_mpi_end) THEN
+         fieldok(ip,n)=buffer_omp(nptabij(ip)-klon_mpi_begin+1,n)
+        ENDIF
+       ENDDO
+       ENDDO
+      endif
+      CALL histwrite(nid,name,itau,fieldok,npstn*nlev,index3d)
+    endif 
+  deallocate(index3d)
+  deallocate(fieldok)
+!$OMP END MASTER    
+  end subroutine histwrite3d_phy
+  
+end module iophy
Index: trunk/LMDZ.VENUS/libf/phyvenus/iostart.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/iostart.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/iostart.F90	(revision 892)
@@ -0,0 +1,508 @@
+MODULE iostart
+
+PRIVATE
+    INTEGER,SAVE :: nid_start 
+    INTEGER,SAVE :: nid_restart
+    
+    INTEGER,SAVE :: idim1,idim2,idim3,idim4
+    INTEGER,PARAMETER :: length=100
+    
+    INTERFACE get_field
+      MODULE PROCEDURE Get_field_r1,Get_field_r2,Get_field_r3
+    END INTERFACE get_field
+    
+    INTERFACE get_var
+      MODULE PROCEDURE get_var_r0,Get_var_r1,Get_var_r2,Get_var_r3
+    END INTERFACE get_var
+
+    INTERFACE put_field
+      MODULE PROCEDURE put_field_r1,put_field_r2,put_field_r3
+    END INTERFACE put_field
+
+    INTERFACE put_var
+      MODULE PROCEDURE put_var_r0,put_var_r1,put_var_r2,put_var_r3
+    END INTERFACE put_var
+
+    PUBLIC get_field,get_var,put_field,put_var
+    PUBLIC Open_startphy,close_startphy,open_restartphy,close_restartphy
+    
+CONTAINS
+
+  SUBROUTINE Open_startphy(filename)
+  USE netcdf
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: filename
+    INTEGER          :: ierr
+
+    IF (is_mpi_root .AND. is_omp_root) THEN
+      ierr = NF90_OPEN (filename, NF90_NOWRITE,nid_start)
+      IF (ierr.NE.NF90_NOERR) THEN
+        write(6,*)' Pb d''ouverture du fichier '//filename
+        write(6,*)' ierr = ', ierr
+        CALL ABORT
+      ENDIF
+    ENDIF
+   
+  END SUBROUTINE Open_startphy
+
+  SUBROUTINE Close_startphy
+  USE netcdf
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    INTEGER          :: ierr
+
+    IF (is_mpi_root .AND. is_omp_root) THEN
+        ierr = NF90_CLOSE (nid_start)
+    ENDIF
+
+  END SUBROUTINE close_startphy
+
+
+  FUNCTION Inquire_Field(Field_name)
+  USE netcdf
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: Field_name
+    LOGICAL :: inquire_field
+    INTEGER :: varid
+    INTEGER :: ierr
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+      ierr=NF90_INQ_VARID(nid_start,Field_name,varid)
+      IF (ierr==NF90_NOERR) THEN
+        Inquire_field=.TRUE.
+      ELSE
+        Inquire_field=.FALSE.
+      ENDIF
+    ENDIF
+
+    CALL bcast(Inquire_field)
+
+  END FUNCTION Inquire_Field
+  
+ 
+  SUBROUTINE Get_Field_r1(field_name,field,found)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN)    :: Field_name
+    REAL,INTENT(INOUT)               :: Field(:)
+    LOGICAL,INTENT(OUT),OPTIONAL   :: found 
+
+    IF (PRESENT(found)) THEN
+      CALL Get_field_rgen(field_name,field,1,found)
+    ELSE
+      CALL Get_field_rgen(field_name,field,1)
+    ENDIF
+      
+  END SUBROUTINE Get_Field_r1
+  
+  SUBROUTINE Get_Field_r2(field_name,field,found)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN)    :: Field_name
+    REAL,INTENT(INOUT)               :: Field(:,:)
+    LOGICAL,INTENT(OUT),OPTIONAL   :: found 
+
+    IF (PRESENT(found)) THEN
+      CALL Get_field_rgen(field_name,field,size(field,2),found)
+    ELSE
+      CALL Get_field_rgen(field_name,field,size(field,2))
+    ENDIF
+
+      
+  END SUBROUTINE Get_Field_r2
+  
+  SUBROUTINE Get_Field_r3(field_name,field,found)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN)    :: Field_name
+    REAL,INTENT(INOUT)               :: Field(:,:,:)
+    LOGICAL,INTENT(OUT),OPTIONAL   :: found 
+
+    IF (PRESENT(found)) THEN
+      CALL Get_field_rgen(field_name,field,size(field,2)*size(field,3),found)
+    ELSE
+      CALL Get_field_rgen(field_name,field,size(field,2)*size(field,3))
+    ENDIF
+      
+  END SUBROUTINE Get_Field_r3
+  
+  SUBROUTINE Get_field_rgen(field_name,field,field_size,found)
+  USE netcdf
+  USE dimphy
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: Field_name
+    INTEGER          :: field_size
+    REAL             :: field(klon,field_size)
+    LOGICAL,OPTIONAL :: found
+    
+    REAL    :: field_glo(klon_glo,field_size)
+    LOGICAL :: tmp_found
+    INTEGER :: varid
+    INTEGER :: ierr
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+  
+      ierr=NF90_INQ_VARID(nid_start,Field_name,varid)
+      
+      IF (ierr==NF90_NOERR) THEN
+        CALL body(field_glo)
+        tmp_found=.TRUE.
+      ELSE
+        tmp_found=.FALSE.
+      ENDIF
+    
+    ENDIF
+    
+    CALL bcast(tmp_found)
+
+    IF (tmp_found) THEN
+      CALL scatter(field_glo,field)
+    ENDIF
+    
+    IF (PRESENT(found)) THEN
+      found=tmp_found
+    ELSE
+      IF (.NOT. tmp_found) THEN
+        PRINT*, 'phyetat0: Le champ <'//field_name//'> est absent'
+        CALL abort
+      ENDIF
+    ENDIF
+ 
+    
+    CONTAINS
+     
+     SUBROUTINE body(field_glo)
+       REAL :: field_glo(klon_glo*field_size)
+         ierr=NF90_GET_VAR(nid_start,varid,field_glo)
+         IF (ierr/=NF90_NOERR) THEN
+           ! La variable exist dans le fichier mais la lecture a echouee. 
+           PRINT*, 'phyetat0: Lecture echouee pour <'//field_name//'>'
+
+           IF (field_name=='CLWCON' .OR. field_name=='RNEBCON' .OR. field_name=='RATQS') THEN
+              ! Essaye de lire le variable sur surface uniqument, comme fait avant
+              field_glo(:)=0.
+              ierr=NF90_GET_VAR(nid_start,varid,field_glo(1:klon_glo))
+              IF (ierr/=NF90_NOERR) THEN
+                 PRINT*, 'phyetat0: Lecture echouee aussi en 2D pour <'//field_name//'>'
+                 CALL abort
+              ELSE
+                 PRINT*, 'phyetat0: La variable <'//field_name//'> lu sur surface seulement'!, selon ancien format, le reste mis a zero'
+              END IF
+           ELSE
+              CALL abort
+           ENDIF
+         ENDIF
+
+     END SUBROUTINE body
+
+  END SUBROUTINE Get_field_rgen
+  
+
+  SUBROUTINE get_var_r0(var_name,var,found)
+  IMPLICIT NONE  
+    CHARACTER(LEN=*),INTENT(IN)  :: var_name
+    REAL,INTENT(INOUT)             :: var
+    LOGICAL,OPTIONAL,INTENT(OUT) :: found
+
+    REAL                         :: varout(1)
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_var_rgen(var_name,varout,size(varout),found)
+    ELSE
+      CALL Get_var_rgen(var_name,varout,size(varout))
+    ENDIF
+    var=varout(1)
+ 
+  END SUBROUTINE get_var_r0
+
+  SUBROUTINE get_var_r1(var_name,var,found)
+  IMPLICIT NONE  
+    CHARACTER(LEN=*),INTENT(IN)  :: var_name
+    REAL,INTENT(INOUT)             :: var(:)
+    LOGICAL,OPTIONAL,INTENT(OUT) :: found
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_var_rgen(var_name,var,size(var),found)
+    ELSE
+      CALL Get_var_rgen(var_name,var,size(var))
+    ENDIF
+  
+  END SUBROUTINE get_var_r1
+
+  SUBROUTINE get_var_r2(var_name,var,found)
+  IMPLICIT NONE  
+    CHARACTER(LEN=*),INTENT(IN)  :: var_name
+    REAL,INTENT(OUT)             :: var(:,:)
+    LOGICAL,OPTIONAL,INTENT(OUT) :: found
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_var_rgen(var_name,var,size(var),found)
+    ELSE
+      CALL Get_var_rgen(var_name,var,size(var))
+    ENDIF
+  
+  END SUBROUTINE get_var_r2
+
+  SUBROUTINE get_var_r3(var_name,var,found)
+  IMPLICIT NONE  
+    CHARACTER(LEN=*),INTENT(IN)  :: var_name
+    REAL,INTENT(INOUT)             :: var(:,:,:)
+    LOGICAL,OPTIONAL,INTENT(OUT) :: found
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_var_rgen(var_name,var,size(var),found)
+    ELSE
+      CALL Get_var_rgen(var_name,var,size(var))
+    ENDIF
+  
+  END SUBROUTINE get_var_r3
+
+  SUBROUTINE Get_var_rgen(var_name,var,var_size,found)
+  USE netcdf
+  USE dimphy
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: var_name
+    INTEGER          :: var_size
+    REAL             :: var(var_size)
+    LOGICAL,OPTIONAL :: found
+    
+    LOGICAL :: tmp_found
+    INTEGER :: varid
+    INTEGER :: ierr
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+  
+      ierr=NF90_INQ_VARID(nid_start,var_name,varid)
+      
+      IF (ierr==NF90_NOERR) THEN
+        ierr=NF90_GET_VAR(nid_start,varid,var)
+        IF (ierr/=NF90_NOERR) THEN
+          PRINT*, 'phyetat0: Lecture echouee pour <'//var_name//'>'
+          CALL abort
+        ENDIF
+        tmp_found=.TRUE.
+      ELSE
+        tmp_found=.FALSE.
+      ENDIF
+    
+    ENDIF
+    
+    CALL bcast(tmp_found)
+
+    IF (tmp_found) THEN
+      CALL bcast(var)
+    ENDIF
+    
+    IF (PRESENT(found)) THEN
+      found=tmp_found
+    ELSE
+      IF (.NOT. tmp_found) THEN
+        PRINT*, 'phyetat0: La variable champ <'//var_name//'> est absente'
+        CALL abort
+      ENDIF
+    ENDIF
+
+  END SUBROUTINE Get_var_rgen
+
+
+  SUBROUTINE open_restartphy(filename)
+  USE netcdf
+  USE mod_phys_lmdz_para
+  USE mod_grid_phy_lmdz
+  USE dimphy
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN) :: filename
+    INTEGER                     :: ierr
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+      ierr = NF90_CREATE(filename, NF90_CLOBBER, nid_restart)
+      IF (ierr/=NF90_NOERR) THEN
+        write(6,*)' Pb d''ouverture du fichier '//filename
+        write(6,*)' ierr = ', ierr
+        CALL ABORT
+      ENDIF
+
+      ierr = NF90_PUT_ATT (nid_restart, NF90_GLOBAL, "title","Fichier redemmarage physique")
+
+      ierr = NF90_DEF_DIM (nid_restart, "index", length, idim1)
+      ierr = NF90_DEF_DIM (nid_restart, "points_physiques", klon_glo, idim2)
+      ierr = NF90_DEF_DIM (nid_restart, "horizon_vertical", klon_glo*klev, idim3)
+      ierr = NF90_DEF_DIM (nid_restart, "horizon_klevp1", klon_glo*klevp1, idim4)
+
+      ierr = NF90_ENDDEF(nid_restart)
+    ENDIF
+
+  END SUBROUTINE open_restartphy
+  
+  SUBROUTINE close_restartphy
+  USE netcdf
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    INTEGER          :: ierr
+
+    IF (is_mpi_root .AND. is_omp_root) THEN
+      ierr = NF90_CLOSE (nid_restart)
+    ENDIF
+ 
+  END SUBROUTINE close_restartphy
+
+  
+  SUBROUTINE put_field_r1(field_name,title,field)
+  IMPLICIT NONE
+  CHARACTER(LEN=*),INTENT(IN)    :: field_name
+  CHARACTER(LEN=*),INTENT(IN)    :: title
+  REAL,INTENT(IN)                :: field(:)
+  
+    CALL put_field_rgen(field_name,title,field,1)
+  
+  END SUBROUTINE put_field_r1
+
+  SUBROUTINE put_field_r2(field_name,title,field)
+  IMPLICIT NONE
+  CHARACTER(LEN=*),INTENT(IN)    :: field_name
+  CHARACTER(LEN=*),INTENT(IN)    :: title
+  REAL,INTENT(IN)                :: field(:,:)
+  
+    CALL put_field_rgen(field_name,title,field,size(field,2))
+  
+  END SUBROUTINE put_field_r2
+
+  SUBROUTINE put_field_r3(field_name,title,field)
+  IMPLICIT NONE
+  CHARACTER(LEN=*),INTENT(IN)    :: field_name
+  CHARACTER(LEN=*),INTENT(IN)    :: title
+  REAL,INTENT(IN)                :: field(:,:,:)
+  
+    CALL put_field_rgen(field_name,title,field,size(field,2)*size(field,3))
+  
+  END SUBROUTINE put_field_r3
+  
+  SUBROUTINE put_field_rgen(field_name,title,field,field_size)
+  USE netcdf
+  USE dimphy
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+  CHARACTER(LEN=*),INTENT(IN)    :: field_name
+  CHARACTER(LEN=*),INTENT(IN)    :: title
+  INTEGER,INTENT(IN)             :: field_size
+  REAL,INTENT(IN)                :: field(klon,field_size)
+  
+  REAL                           :: field_glo(klon_glo,field_size)
+  INTEGER                        :: ierr
+  INTEGER                        :: nvarid
+  INTEGER                        :: idim
+   
+   
+    CALL gather(field,field_glo)
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+
+      IF (field_size==1) THEN
+        idim=idim2
+      ELSE IF (field_size==klev) THEN
+        idim=idim3
+      ELSE IF (field_size==klevp1) THEN
+        idim=idim4
+      ELSE
+        PRINT *, "erreur phyredem : probleme de dimension"
+        CALL ABORT
+      ENDIF
+         
+      ierr = NF90_REDEF (nid_restart)
+#ifdef NC_DOUBLE
+      ierr = NF90_DEF_VAR (nid_restart, field_name, NF90_DOUBLE,(/ idim /),nvarid)
+#else
+      ierr = NF90_DEF_VAR (nid_restart, field_name, NF90_FLOAT,(/ idim /),nvarid)
+#endif
+      IF (LEN_TRIM(title) > 0) ierr = NF90_PUT_ATT (nid_restart,nvarid,"title", title)
+      ierr = NF90_ENDDEF(nid_restart)
+      ierr = NF90_PUT_VAR(nid_restart,nvarid,RESHAPE(field_glo,(/klon_glo*field_size/)))
+    ENDIF
+    
+   END SUBROUTINE put_field_rgen  
+  
+   SUBROUTINE put_var_r0(var_name,title,var)
+   IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     REAL,INTENT(IN)             :: var
+     REAL                        :: varin(1)
+     
+     varin(1)=var
+     
+     CALL put_var_rgen(var_name,title,varin,size(varin))
+
+  END SUBROUTINE put_var_r0
+
+
+   SUBROUTINE put_var_r1(var_name,title,var)
+   IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     REAL,INTENT(IN)             :: var(:)
+     
+     CALL put_var_rgen(var_name,title,var,size(var))
+
+  END SUBROUTINE put_var_r1
+ 
+  SUBROUTINE put_var_r2(var_name,title,var)
+   IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     REAL,INTENT(IN)             :: var(:,:)
+     
+     CALL put_var_rgen(var_name,title,var,size(var))
+
+  END SUBROUTINE put_var_r2     
+  
+  SUBROUTINE put_var_r3(var_name,title,var)
+   IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     REAL,INTENT(IN)             :: var(:,:,:)
+     
+     CALL put_var_rgen(var_name,title,var,size(var))
+
+  END SUBROUTINE put_var_r3
+
+  SUBROUTINE put_var_rgen(var_name,title,var,var_size)
+  USE netcdf
+  USE dimphy
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     INTEGER,INTENT(IN)          :: var_size
+     REAL,INTENT(IN)             :: var(var_size)
+     
+     INTEGER :: ierr
+     INTEGER :: nvarid
+         
+    IF (is_mpi_root .AND. is_omp_root) THEN
+
+      IF (var_size/=length) THEN
+        PRINT *, "erreur phyredem : probleme de dimension"
+        CALL abort
+      ENDIF
+      
+      ierr = NF90_REDEF (nid_restart)
+
+#ifdef NC_DOUBLE
+      ierr = NF90_DEF_VAR (nid_restart, var_name, NF90_DOUBLE,(/ idim1 /),nvarid)
+#else
+      ierr = NF90_DEF_VAR (nid_restart, var_name, NF90_FLOAT,(/ idim1 /),nvarid)
+#endif
+      IF (LEN_TRIM(title)>0) ierr = NF90_PUT_ATT (nid_restart,nvarid,"title", title)
+      ierr = NF90_ENDDEF(nid_restart)
+     
+      ierr = NF90_PUT_VAR(nid_restart,nvarid,var)
+
+    ENDIF
+    
+  END SUBROUTINE put_var_rgen     
+    
+END MODULE iostart
Index: trunk/LMDZ.VENUS/libf/phyvenus/lnblnk1.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/lnblnk1.F	(revision 888)
+++ 	(revision )
@@ -1,47 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/lnblnk1.F,v 1.1.1.1 2004/05/19 12:53:08 lmdzadmin Exp $
-!
-      INTEGER FUNCTION lnblnk1 (letter)
-
-C--------------------------------------------------------
-C Fonction qui determine la longeur d'un string sans les
-C blancs qui suivent. Le critere pour determiner la fin du
-C string est, trois blancs de suite
-C---------------------------------------------------------
-C     ARGUMENTS
-C     +++++++++
-C     letter: CHARACTER*xxx (xxx < imax)
-C             le string dont on determine la longuer
-C     lnblnk1: INTEGER
-C             le nombre de characteres
-C
-C     PARAMETER
-C     +++++++++
-C     imax : INTEGER
-C            le nombre maximale de character que peut contenir le string
-C            a traiter
-
-      IMPLICIT NONE
-      INTEGER i,imax
-      PARAMETER (imax = 256)
-c     CHARACTER*256 letter
-      CHARACTER*4 letter
-
-      i=0
-
-10    i=i+1
-c     IF (letter(i:i+1) . EQ . ' ') THEN
-      IF (letter(i:i) . EQ . ' ') THEN
-c      print*,'i=',i,'letter(i:i+1)=',letter(i:i+1)
-c      print*,'i=',i
-       GOTO 20
-      ELSE
-       GOTO 10
-      ENDIF
-
-20    lnblnk1=i-1
-c     PRINT*,'lnblnk1=',lnblnk1
-
-      RETURN
-      END
-
Index: trunk/LMDZ.VENUS/libf/phyvenus/load_ksi.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/load_ksi.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/load_ksi.F	(revision 892)
@@ -32,5 +32,5 @@
       real   ztop(klon)            ! Altitude of the top of cloud deck (km)
 c outputs
-      real   ksive(0:kflev+1,0:kflev+1,nnuve,nbmat)  ! ksi matrixes in Vincent's file
+      real   ksive(0:klev+1,0:klev+1,nnuve,nbmat)  ! ksi matrixes in Vincent's file
 
 c local variables
@@ -44,5 +44,5 @@
       real   dlambda                  ! cm-1  
 
-      nlve = kflev
+      nlve = klev
 
 c ------------------------
Index: trunk/LMDZ.VENUS/libf/phyvenus/load_psi.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/load_psi.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/load_psi.F	(revision 892)
@@ -38,9 +38,9 @@
       real   psurf(klon)           ! Surface pressure
       real   ztop(klon)            ! Altitude of the top of cloud deck (km)
-      real   ksive(0:kflev+1,0:kflev+1,nnuve,nbmat)  ! ksi matrixes in Vincent's file
-      real   temp(klon,0:kflev+1)  ! Temperature in layer (K)
+      real   ksive(0:klev+1,0:klev+1,nnuve,nbmat)  ! ksi matrixes in Vincent's file
+      real   temp(klon,0:klev+1)  ! Temperature in layer (K)
 c outputs
-      real   psimap(0:kflev+1,0:kflev+1,klon)
-      real   deltapsimap(0:kflev+1,0:kflev+1,klon)
+      real   psimap(0:klev+1,0:klev+1,klon)
+      real   deltapsimap(0:klev+1,0:klev+1,klon)
 
 c local variables
@@ -48,11 +48,11 @@
       integer mat,m,mat0
       character*100 file
-      real   bplck(0:kflev+1,nnuve)    ! Planck luminances in table layers
-      real   y(0:kflev,nnuve)          ! intermediaire Planck
-      real   zdblay(0:kflev+1,nnuve)   ! gradient en temperature de planck
+      real   bplck(0:klev+1,nnuve)    ! Planck luminances in table layers
+      real   y(0:klev,nnuve)          ! intermediaire Planck
+      real   zdblay(0:klev+1,nnuve)   ! gradient en temperature de planck
       real   ksi
       real   factp,factz
 
-      nlve = kflev  ! (doit correspondre, pour bplck, y et zdblay)
+      nlve = klev  ! (doit correspondre, pour bplck, y et zdblay)
 
 c -----------------------
Index: trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.1mat
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.1mat	(revision 888)
+++ 	(revision )
@@ -1,280 +1,0 @@
-      SUBROUTINE LW_venus_ve( 
-     S              PPB, PT, PTSURF,
-     S              PCOOL, 
-     S              PTOPLW,PSOLLW,PSOLLWDN,
-     S              ZFLNET)
-      
-      IMPLICIT none
-
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
-#include "YOMCST.h"
-C
-C     ------------------------------------------------------------------
-C
-C     PURPOSE.
-C     --------
-C
-c     This routine loads the longwave matrix of factors Ksi,
-c     used to build the Net Exchange Rates matrix Psi.
-c     Psi(i,j,nu) = Ksi(i,j,nu) * ( B(i,nu)-B(j,nu) )
-c     
-c     This Ksi matrix has been computed by Vincent Eymet
-C
-c     The NER matrix is then integrated in frequency, and the output
-c     are calculated.
-c
-C     AUTHOR.
-C     -------
-C        Sebastien Lebonnois
-C
-C     MODIFICATIONS.
-C     --------------
-C        ORIGINAL : 27/07/2005
-C     ------------------------------------------------------------------
-C
-C* ARGUMENTS:
-C
-c inputs
-
-      REAL   PPB(KFLEV+1)  ! inter-couches PRESSURE (bar)
-      REAL   PT(KFLEV)     ! Temperature in layer (K)
-      REAL   PTSURF        ! Surface temperature
-C
-c output
-
-      REAL   PCOOL(KFLEV) ! LONGWAVE COOLING (K/VENUSDAY) within each layer
-      REAL   PTOPLW       ! LONGWAVE FLUX AT T.O.A. (net, + vers le haut)
-      REAL   PSOLLW       ! LONGWAVE FLUX AT SURFACE (net, + vers le haut)
-      REAL   PSOLLWDN     ! LONGWAVE FLUX AT SURFACE (down, + vers le bas)
-      REAL   ZFLNET(KFLEV+1) ! net thermal flux at ppb levels (+ vers le haut)
-
-C
-C* LOCAL VARIABLES:
-C
-      integer nlve,nnuve
-      parameter (nlve=kflev) ! fichiers Vincent: same grid than GCM
-      parameter (nnuve=68)   ! fichiers Vincent et Bullock
-      real    dureejour
-      parameter (dureejour=10.087e6)
-      
-      integer i,j,p,nl0,nnu0,band
-      real   lambda(nnuve)    ! wavelenght in table (mu->m, middle of interval)
-      real   ksive(0:nlve+1,0:nlve+1,nnuve) ! ksi factors
-      real   bplck(0:nlve+1,nnuve)          ! Planck luminances in table layers
-      real   al(nnuve),bl(nnuve)            ! for Planck luminances calculations
-      real   psive(0:nlve+1,0:nlve+1,nnuve) ! NER in W/m**2 per wavelength band
-      real   psi_1(0:nlve+1,0:nlve+1)       ! NER in W/m**2 (sum on lambda)
-
-      real   ztemp(0:nlve)    ! GCM temperature in table layers
-      real   zlnet(nlve+1)    ! net thermal flux (W/m**2)
-      real   dzlnet(0:nlve)   ! Radiative budget (W/m**2)
-      character*22 nullchar
-      real   lambdamin,lambdamax ! in microns
-      real   dlambda             ! cm-1  
-
-      real   y(0:nlve,nnuve)    ! intermediaire Planck
-      real   pdp(nlve)          ! epaisseur de la couche en pression (Pa)
-      real   zdblay(nlve,nnuve)     ! gradient en temperature de planck
-      
-      logical firstcall
-      data    firstcall/.true./
-
-      save   lambda,ksive,al,bl,firstcall
-      
-c ------------------------
-c Loading the files
-c ------------------------
-
-      if (firstcall) then
-
-c Matrice Ksi
-c------------
-      open(13,file='ksi_gccr.txt')
-      read(13,*) nl0,nnu0
-      if (nl0.ne.nlve) then
-         print*,'Probleme de dimension entre ksi.txt et lw'
-         print*,'N levels = ',nl0,nlve
-         stop
-      endif
-      if (nnu0.ne.nnuve) then
-         print*,'Probleme de dimension entre ksi.txt et lw'
-         print*,'N freq = ',nnu0,nnuve
-         stop
-      endif
-      do band=1,nnuve
-         read(13,*) lambdamin,lambdamax                ! en microns
-         lambda(band)=(lambdamin+lambdamax)/2.*1.e-6   ! en m
-         dlambda     =(1./lambdamin-1./lambdamax)*1.e4 ! en cm-1
-c        print*,band,lambdamin,dlambda,lambdamax
-         do i=0,nlve+1
-           read(13,'(52e17.9)') (ksive(i,j,band),j=0,nlve+1)
-c ecart-type MC sur les ksi: pas utilise
-c          read(13,'(52e17.9)') (psive(i,j,band),j=0,nlve+1) 
-c changement de convention (signe) pour ksi,
-c et prise en compte de la largeur de bande (en cm-1):
-           do j=0,nlve+1
-              ksive(i,j,band) = -ksive(i,j,band)*dlambda
-           enddo
-         enddo
-c calcul des coeff al et bl pour luminance Planck 
-         al(band) = 2.*RHPLA*RCLUM*RCLUM/(lambda(band))**5.
-c cette luminance doit etre en W/m²/sr/µm pour correspondre au calcul
-c des ksi. Ici, elle est en W/m²/sr/m donc il faut mettre un facteur 1.e-6
-     .                * 1.e-6
-         bl(band) = RHPLA*RCLUM/(RKBOL*lambda(band))
-      enddo
-      close(13)
-
-      endif  ! firstcall
-
-c --------------------------------------
-c Calculation of the Psi matrix
-c --------------------------------------
-
-c temperature in the table layers
-c -------------------------------
-      
-      do j=1,nlve
-        ztemp(j) = PT(j)
-      enddo
-
-      ztemp(0) = PTSURF
-
-c Planck function
-c ---------------
-
-      do band=1,nnuve
-        y(0,band) = exp(bl(band)/ztemp(0))-1.
-        bplck(0,band) = al(band)/(y(0,band))
-       do j=1,nlve
-c Developpement en polynomes ?
-c       bplck(j,band) =            xp(1,band)
-c    .                  +ztemp(j)*(xp(2,band)
-c    .                  +ztemp(j)*(xp(3,band)
-c    .                  +ztemp(j)*(xp(4,band)
-c    .                  +ztemp(j)*(xp(5,band)
-c    .                  +ztemp(j)*(xp(6,band) )))))
-
-c B(T,l) = al/(exp(bl/T)-1)
-        y(j,band) = exp(bl(band)/ztemp(j))-1.
-        bplck(j,band) = al(band)/(y(j,band))
-        zdblay(j,band) = al(band)*bl(band)*exp(bl(band)/ztemp(j))/
-     .                  ((ztemp(j)**2)*(y(j,band)**2))
-       enddo
-       bplck(nlve+1,band) = 0.0
-      enddo
-
-c Calculation of Psi
-c ------------------
-
-      do band=1,nnuve
-       do j=0,nlve+1
-        do i=0,nlve+1
-         psive(i,j,band)=ksive(i,j,band)*(bplck(i,band)-bplck(j,band))
-        enddo
-       enddo
-      enddo
-
-      do j=0,nlve+1
-       do i=0,nlve+1
-        psi_1(i,j) = 0.0  ! positif quand nrj de i->j 
-       enddo
-      enddo
-      
-      do band=1,nnuve
-       do j=0,nlve+1
-        do i=0,nlve+1
-         psi_1(i,j) = psi_1(i,j)+psive(i,j,band)
-        enddo
-       enddo
-      enddo
-
-c Verif...-----------------------
-c     open(11,file="psi.dat")
-c     do i=0,nlve+1
-c       write(11,'(I3,83E17.9)') i,(psi_1(j,i),j=0,nlve+1)
-c     enddo
-c     close(11)
-c     stop
-c -------------------------------
-
-c --------------------------
-c Calculation of the fluxes
-c --------------------------
-
-c flux aux intercouches:
-c zlnet(i+1) est le flux net traversant le plafond de la couche i (+ vers le haut)
-      do p=0,nlve ! numero de la couche
-        zlnet(p+1) = 0.0
-        do j=p+1,nlve+1
-         do i=0,p
-           zlnet(p+1) = zlnet(p+1)+psi_1(i,j)
-         enddo
-        enddo
-      enddo
-
-c flux net au sol, + vers le haut:
-      PSOLLW = zlnet(1)
-c flux vers le bas au sol, + vers le bas:
-      PSOLLWDN = 0.0
-      do i=1,nlve+1
-        PSOLLWDN = PSOLLWDN+max(psi_1(i,0),0.0)
-      enddo
-
-c dfluxnet = radiative budget (W m-2)
-      do p=0,nlve ! numero de la couche
-        dzlnet(p) = 0.0
-        do j=0,nlve+1
-           dzlnet(p) = dzlnet(p)+psi_1(p,j)
-        enddo
-      enddo
-
-      
-c --------------------------------------
-c Interpolation in the GCM vertical grid
-c --------------------------------------
-
-c Flux net
-c --------
-      
-      do j=1,kflev+1
-        ZFLNET(j) =  zlnet(j)
-      enddo
-
-      PTOPLW   = ZFLNET(kflev+1)
-      
-c Heating rates
-c -------------
-
-c  cool (K/s) = dfluxnet (W/m2)    ! positif quand nrj sort de la couche
-c              *g        (m/s2)
-c              /(-dp)  (epaisseur couche, en Pa=kg/m/s2)
-c              /cp  (J/kg/K) 
-      
-
-      do j=1,kflev
-        pdp(j)=(PPB(j)-PPB(j+1))*1.e5
-      enddo
-
-c calcul direct OU calcul par schema implicit
-      if (1.eq.0) then 
-        do j=1,kflev
-         PCOOL(j) = dzlnet(j) *RG/RCPD / pdp(j)
-        enddo
-      else
-        call lwi(nlve,nnuve,dzlnet,zdblay,pdp,ksive,PCOOL)
-      endif
-c     print*,dzlnet
-c     print*,pdp
-c     print*,PCOOL
-
-      do j=1,kflev
-        PCOOL(j) = PCOOL(j)*dureejour ! K/Venusday
-      enddo
-
-      firstcall = .false.
-      return
-      end
-
Index: trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.F	(revision 892)
@@ -35,16 +35,16 @@
 c inputs
 
-      REAL    PPB(KFLEV+1)  ! inter-couches PRESSURE (bar)
-      REAL    pt(kflev)     ! mid-layer temperature
-      real    psi(0:kflev+1,0:kflev+1)      ! NER in W/m**2
-      real    deltapsi(0:kflev+1,0:kflev+1) ! D NER / DT in W/m**2/K
+      REAL    PPB(klev+1)  ! inter-couches PRESSURE (bar)
+      REAL    pt(klev)     ! mid-layer temperature
+      real    psi(0:klev+1,0:klev+1)      ! NER in W/m**2
+      real    deltapsi(0:klev+1,0:klev+1) ! D NER / DT in W/m**2/K
 C
 c output
 
-      REAL   PCOOL(KFLEV) ! LONGWAVE COOLING (K/VENUSDAY) within each layer
+      REAL   PCOOL(klev) ! LONGWAVE COOLING (K/VENUSDAY) within each layer
       REAL   PTOPLW       ! LONGWAVE FLUX AT T.O.A. (net, + vers le haut)
       REAL   PSOLLW       ! LONGWAVE FLUX AT SURFACE (net, + vers le haut)
       REAL   PSOLLWDN     ! LONGWAVE FLUX AT SURFACE (down, + vers le bas)
-      REAL   ZFLNET(KFLEV+1) ! net thermal flux at ppb levels (+ vers le haut)
+      REAL   ZFLNET(klev+1) ! net thermal flux at ppb levels (+ vers le haut)
 
 C
@@ -55,7 +55,7 @@
       
       integer i,j,p
-      real   zlnet(kflev+1)    ! net thermal flux (W/m**2)
-      real   dzlnet(0:kflev)   ! Radiative budget (W/m**2)
-      real   pdp(kflev)        ! epaisseur de la couche en pression (Pa)
+      real   zlnet(klev+1)    ! net thermal flux (W/m**2)
+      real   dzlnet(0:klev)   ! Radiative budget (W/m**2)
+      real   pdp(klev)        ! epaisseur de la couche en pression (Pa)
 
 c --------------------------
@@ -65,7 +65,7 @@
 c flux aux intercouches:
 c zlnet(i+1) est le flux net traversant le plafond de la couche i (+ vers le haut)
-      do p=0,kflev ! numero de la couche
+      do p=0,klev ! numero de la couche
         zlnet(p+1) = 0.0
-        do j=p+1,kflev+1
+        do j=p+1,klev+1
          do i=0,p
            zlnet(p+1) = zlnet(p+1)+ psi(i,j)
@@ -78,12 +78,12 @@
 c flux vers le bas au sol, + vers le bas:
       PSOLLWDN = 0.0
-      do i=1,kflev+1
+      do i=1,klev+1
         PSOLLWDN = PSOLLWDN+max(psi(i,0),0.0)
       enddo
 
 c dfluxnet = radiative budget (W m-2)
-      do p=0,kflev ! numero de la couche
+      do p=0,klev ! numero de la couche
         dzlnet(p) = 0.0
-        do j=0,kflev+1
+        do j=0,klev+1
            dzlnet(p) = dzlnet(p)+psi(p,j)
         enddo
@@ -97,8 +97,8 @@
 c --------
       
-      do j=1,kflev+1
+      do j=1,klev+1
         ZFLNET(j) =  zlnet(j)
       enddo
-      PTOPLW   = ZFLNET(kflev+1)
+      PTOPLW   = ZFLNET(klev+1)
       
 c Heating rates
@@ -110,5 +110,5 @@
 c              /cp  (J/kg/K) 
       
-      do j=1,kflev
+      do j=1,klev
         pdp(j)=(PPB(j)-PPB(j+1))*1.e5
       enddo
@@ -116,10 +116,10 @@
 c calcul direct OU calcul par schema implicit
       if (1.eq.1) then 
-        do j=1,kflev
+        do j=1,klev
 ! ADAPTATION GCM POUR CP(T)
          PCOOL(j) = dzlnet(j) *RG/cpdet(pt(j)) / pdp(j)
         enddo
       else
-        call lwi(kflev,dzlnet,deltapsi,pdp,pt,PCOOL)
+        call lwi(klev,dzlnet,deltapsi,pdp,pt,PCOOL)
       endif
 c     print*,dzlnet
@@ -127,5 +127,5 @@
 c     print*,PCOOL
 
-      do j=1,kflev
+      do j=1,klev
         PCOOL(j) = PCOOL(j)*dureejour ! K/Venusday
       enddo
Index: trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.interp
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.interp	(revision 888)
+++ 	(revision )
@@ -1,419 +1,0 @@
-      SUBROUTINE LW_venus_ve( 
-     S              PPB, PT, PTSURF,
-     S              PCOOL, 
-     S              PTOPLW,PSOLLW,PSOLLWDN,
-     S              ZFLNET)
-      
-      IMPLICIT none
-
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
-#include "YOMCST.h"
-C
-C     ------------------------------------------------------------------
-C
-C     PURPOSE.
-C     --------
-C
-c     This routine loads the longwave matrix of factors Ksi,
-c     used to build the Net Exchange Rates matrix Psi.
-c     Psi(i,j,nu) = Ksi(i,j,nu) * ( B(i,nu)-B(j,nu) )
-c     
-c     This Ksi matrix has been computed by Vincent Eymet
-C
-c     The NER matrix is then integrated in frequency, and the output
-c     are calculated.
-c
-C     AUTHOR.
-C     -------
-C        Sebastien Lebonnois
-C
-C     MODIFICATIONS.
-C     --------------
-C        ORIGINAL : 27/07/2005
-C     ------------------------------------------------------------------
-C
-C* ARGUMENTS:
-C
-c inputs
-
-      REAL   PPB(KFLEV+1)  ! inter-couches PRESSURE (bar)
-      REAL   PT(KFLEV)     ! Temperature in layer (K)
-      REAL   PTSURF        ! Surface temperature
-C
-c output
-
-      REAL   PCOOL(KFLEV) ! LONGWAVE COOLING (K/VENUSDAY) within each layer
-      REAL   PTOPLW       ! LONGWAVE FLUX AT T.O.A. (net, + vers le haut)
-      REAL   PSOLLW       ! LONGWAVE FLUX AT SURFACE (net, + vers le haut)
-      REAL   PSOLLWDN     ! LONGWAVE FLUX AT SURFACE (down, + vers le bas)
-      REAL   ZFLNET(KFLEV+1) ! net thermal flux at ppb levels (+ vers le haut)
-
-C
-C* LOCAL VARIABLES:
-C
-      integer nlve,nnuve
-      parameter (nlve=81)    ! fichiers Vincent
-      parameter (nnuve=68)   ! fichiers Vincent et Bullock
-      real    dureejour
-      parameter (dureejour=10.087e6)
-      
-      integer i,j,p,nl0,nnu0,band,k,l
-      real   presve(nlve+1)   ! pressure levels in table (Pa->bar) 
-      real   tempve(nlve+1)   ! temperature in table (K) (middle of layer)
-      real   altve(nlve+1)    ! altitude in table (km)
-      real   lambda(nnuve)    ! wavelenght in table (mu->m, middle of interval)
-      real   ksive(0:nlve+1,0:nlve+1,nnuve) ! ksi factors
-      real   bplck(0:nlve+1,nnuve)          ! Planck luminances in table layers
-      real   al(nnuve),bl(nnuve)            ! for Planck luminances calculations
-      real   psive(0:nlve+1,0:nlve+1,nnuve) ! NER in W/m**2 per wavelength band
-      real   psi_1(0:nlve+1,0:nlve+1)       ! NER in W/m**2 (sum on lambda)
-
-      real   ztemp(0:nlve)    ! GCM temperature in table layers
-      real   zlnet(nlve+1)    ! net thermal flux (W/m**2)
-      real   dzlnet(0:nlve)   ! Radiative budget (W/m**2)
-      real   radbudget(kflev) ! Radiative budget on GCM grid
-      real   coolrate(nlve)   ! cooling rates (K/s) on table grid
-      character*22 nullchar
-      real   lambdamin,lambdamax ! in microns
-      real   dlambda             ! cm-1  
-
-      real   y(0:nlve,nnuve)    ! intermediaire Planck
-      real   pdp(kflev)         ! delta pression (Pa), grille GCM
-      real   pdpve(nlve)        ! delta pression (Pa), grille table
-      real   zdblay(nlve,nnuve) ! gradient en temperature de planck
-      
-      real   factflux
-      real   facttemp,prT(kflev),prTve(nlve)
-
-      logical firstcall
-      data    firstcall/.true./
-
-      save   lambda,ksive,al,bl,firstcall
-      
-c ------------------------
-c Loading the files
-c ------------------------
-
-      if (firstcall) then
-
-      print*,"PREMIER APPEL RADIATIF"
-
-c Grilles alt et press
-c---------------------
-      open(11,file='mesh.txt')
-      read(11,*) nl0,nnu0,i
-      read(11,*) nullchar
-      read(11,'(82(2x,F15.9))') altve
-      read(11,'(82(2x,F15.9))') presve
-      read(11,'(81(2x,F15.9))') tempve
-      tempve(nlve+1)=tempve(nlve)
-      close(11)
-      if (nl0.ne.nlve) then
-         print*,'Probleme de dimension entre mesh.txt et lw'
-         print*,'N levels = ',nl0,nlve
-         stop
-      endif
-      if (nnu0.ne.nnuve) then
-         print*,'Probleme de dimension entre mesh.txt et lw'
-         print*,'N freq = ',nnu0,nnuve
-         stop
-      endif
-      do i=1,nlve+1
-        presve(i) = presve(i)*1.e-5     ! convert to bar
-      enddo
-
-c Verifs...
-c     print*, altve
-c     print*, presve
-      
-c Matrice Ksi
-c------------
-      open(13,file='ksi_gccr.txt')
-      read(13,*) nl0,nnu0
-      if (nl0.ne.nlve) then
-         print*,'Probleme de dimension entre ksi.txt et lw'
-         print*,'N levels = ',nl0,nlve
-         stop
-      endif
-      if (nnu0.ne.nnuve) then
-         print*,'Probleme de dimension entre ksi.txt et lw'
-         print*,'N freq = ',nnu0,nnuve
-         stop
-      endif
-      do band=1,nnuve
-         read(13,*) lambdamin,lambdamax                ! en microns
-         lambda(band)=(lambdamin+lambdamax)/2.*1.e-6   ! en m
-         dlambda     =(1./lambdamin-1./lambdamax)*1.e4 ! en cm-1
-c        print*,band,lambdamin,dlambda,lambdamax
-         do i=0,nlve+1
-           read(13,'(83e17.9)') (ksive(i,j,band),j=0,nlve+1)
-c ecart-type MC sur les ksi: pas utilise
-c          read(13,'(83e17.9)') (psive(i,j,band),j=0,nlve+1) 
-c changement de convention (signe) pour ksi,
-c et prise en compte de la largeur de bande (en cm-1):
-           do j=0,nlve+1
-              ksive(i,j,band) = -ksive(i,j,band)*dlambda
-           enddo
-         enddo
-c calcul des coeff al et bl pour luminance Planck 
-         al(band) = 2.*RHPLA*RCLUM*RCLUM/(lambda(band))**5.
-c cette luminance doit etre en W/m²/sr/µm pour correspondre au calcul
-c des ksi. Ici, elle est en W/m²/sr/m donc il faut mettre un facteur 1.e-6
-     .                * 1.e-6
-         bl(band) = RHPLA*RCLUM/(RKBOL*lambda(band))
-      enddo
-      close(13)
-
-      endif  ! firstcall
-
-c --------------------------------------
-c Calculation of the Psi matrix
-c --------------------------------------
-
-c temperature in the table layers
-c -------------------------------
-      
-      do i=1,kflev
-           prT(i) = (PPB(i)+PPB(i+1))/2.
-c          prT(i) = 10.**((log10(PPB(i))+log10(PPB(i+1)))/2.)
-      enddo
-
-      do j=1,nlve
-           prTve(j) = (presve(j)+presve(j+1))/2.
-c       prTve(j) = max(10.**((log10(presve(j))+log10(presve(j+1)))/2.)
-c     .            ,1.e-5)
-      enddo
-      
-      do j=1,nlve
-        nl0 = 2
-        do i=1,kflev-1
-           if (prT(i).ge.prTve(j)) then
-                nl0 = i+1
-           endif
-        enddo
-        
-        facttemp = (log10(prTve(j))-log10(prT(nl0-1)))
-     .            /(log10(prT(nl0))-log10(prT(nl0-1)))
-        ztemp(j) =   facttemp   *PT(nl0)
-     .           + (1.-facttemp)*PT(nl0-1)
-
-c       write(100,*) prTve(j),ztemp(j)
-      enddo
-
-      ztemp(0) = PTSURF
-
-c     do j=1,kflev
-c       write(101,*) prT(j),PT(j)
-c     enddo
-
-c     print*,'VERIF TEMP'
-c     print*,PTSURF,PT
-c     print*,ztemp
-c     print*,tempve
-
-c Planck function
-c ---------------
-
-      do band=1,nnuve
-        y(0,band) = exp(bl(band)/ztemp(0))-1.
-        bplck(0,band) = al(band)/(y(0,band))
-       do j=1,nlve
-c Developpement en polynomes ?
-c       bplck(j,band) =            xp(1,band)
-c    .                  +ztemp(j)*(xp(2,band)
-c    .                  +ztemp(j)*(xp(3,band)
-c    .                  +ztemp(j)*(xp(4,band)
-c    .                  +ztemp(j)*(xp(5,band)
-c    .                  +ztemp(j)*(xp(6,band) )))))
-
-c B(T,l) = al/(exp(bl/T)-1)
-        y(j,band) = exp(bl(band)/ztemp(j))-1.
-        bplck(j,band) = al(band)/(y(j,band))
-        zdblay(j,band) = al(band)*bl(band)*exp(bl(band)/ztemp(j))/
-     .                  ((ztemp(j)**2)*(y(j,band)**2))
-       enddo
-       bplck(nlve+1,band) = 0.0
-      enddo
-
-c Calculation of Psi
-c ------------------
-
-      do band=1,nnuve
-       do j=0,nlve+1
-        do i=0,nlve+1
-         psive(i,j,band)=ksive(i,j,band)*(bplck(i,band)-bplck(j,band))
-        enddo
-       enddo
-      enddo
-
-      do j=0,nlve+1
-       do i=0,nlve+1
-        psi_1(i,j) = 0.0  ! positif quand nrj de i->j 
-       enddo
-      enddo
-      
-      do band=1,nnuve
-       do j=0,nlve+1
-        do i=0,nlve+1
-         psi_1(i,j) = psi_1(i,j)+psive(i,j,band)
-        enddo
-       enddo
-      enddo
-
-c Verif...-----------------------
-c     open(11,file="psi.dat")
-c     do i=0,nlve+1
-c       write(11,'(I3,83E17.9)') i,(psi_1(j,i),j=0,nlve+1)
-c     enddo
-c     close(11)
-c     stop
-c -------------------------------
-
-c --------------------------
-c Calculation of the fluxes
-c --------------------------
-
-c flux aux intercouches:
-c zlnet(i+1) est le flux net traversant le plafond de la couche i (+ vers le haut)
-      do p=0,nlve ! numero de la couche
-        zlnet(p+1) = 0.0
-        do j=p+1,nlve+1
-         do i=0,p
-           zlnet(p+1) = zlnet(p+1)+psi_1(i,j)
-         enddo
-        enddo
-      enddo
-
-c     do p=1,nlve
-c       write(102,*) presve(p),zlnet(p),
-c    .     (zlnet(p+1)-zlnet(p))/(presve(p)-presve(p+1))
-c     enddo
-
-c flux net au sol, + vers le haut:
-      PSOLLW = zlnet(1)
-c flux vers le bas au sol, + vers le bas:
-      PSOLLWDN = 0.0
-      do i=1,nlve+1
-        PSOLLWDN = PSOLLWDN+max(psi_1(i,0),0.0)
-      enddo
-
-c dfluxnet = radiative budget (W m-2)
-      do p=0,nlve ! numero de la couche
-        dzlnet(p) = 0.0
-        do j=0,nlve+1
-           dzlnet(p) = dzlnet(p)+psi_1(p,j)
-        enddo
-      enddo
-
-      
-c --------------------------------------
-c Interpolation in the GCM vertical grid
-c --------------------------------------
-
-c Flux net
-c --------
-      
-      do j=1,kflev+1
-        nl0 = 2
-        do i=1,nlve
-           if (presve(i).ge.PPB(j)) then
-                nl0 = i+1
-           endif
-        enddo
-        
-        factflux = (log10(max(PPB(j),presve(nlve+1)))
-     .                          -log10(presve(nl0-1)))
-     .            /(log10(presve(nl0))-log10(presve(nl0-1)))
-          ZFLNET(j) =  factflux   *zlnet(nl0)
-     .             + (1.-factflux)*zlnet(nl0-1)
-        
-      enddo
-
-      PTOPLW   = ZFLNET(kflev+1)
-      
-c Heating rates
-c -------------
-
-c  cool (K/s) = dfluxnet (W/m2)    ! positif quand nrj sort de la couche
-c              *g        (m/s2)
-c              /(-dp)  (epaisseur couche, en Pa=kg/m/s2)
-c              /cp  (J/kg/K) 
-
-c layers thickness on each pressure grid (in Pa)
-
-      do j=1,kflev
-        pdp(j)=(PPB(j)-PPB(j+1))*1.e5
-      enddo
-
-      do j=1,nlve
-        pdpve(j)=(presve(j)-presve(j+1))*1.e5
-      enddo
-
-c CHOIX CALCUL DIRECT OU IMPLICIT
-
-c Ici, le budget radiatif est en calcul direct. 
-c On ne fait rien. Si on veut l'implicit, on autorise le test suivant:
-
-      if (1.eq.0) then 
-
-c Pour calcul par schema implicite, on obtient en sortie de lwi le coolrate.
-c Donc on actualise le dzlnet par dzlnet=coolrate*(cp/g)*pdpve
-
-        call lwi(nlve,nnuve,dzlnet,zdblay,pdpve,ksive,coolrate)
-	do j=1,nlve
-	   dzlnet(j) = coolrate(j) *RCPD/RG *pdpve(j)
-	enddo
-
-      endif
-
-c Interpolation on GCM grid of radiative budgets (dzlnet)
-
-c on divise l'energie deposee dans la couche par l'epaisseur
-c on moyenne ensuite ces valeurs (creneaux sur grille VE) 
-c entre les niveaux de la grille GCM, et on multiplie ensuite par
-c l'epaisseur (nouvelle grille) pour avoir l'energie deposee dans les
-c couches GCM.
-
-      i=1
-      do j=1,kflev
-        if (PPB(j+1).ge.presve(i+1)) then
-          radbudget(j) = dzlnet(i)/(log10(presve(i+1))-log10(presve(i)))
-     .                            *(log10(PPB(j+1))-log10(PPB(j)))
-	else
-          l=i+1
-	  do while ((PPB(j+1).lt.presve(l+1)).and.(l.ne.nlve))
-	     l=l+1
-	  enddo
-	radbudget(j) = dzlnet(i)/(log10(presve(i+1))-log10(presve(i)))*
-     .                    (log10(presve(i+1))-log10(PPB(j)))
-     .                +dzlnet(l)/(log10(presve(l+1))-log10(presve(l)))*
-     .                    (log10(PPB(j+1))-log10(presve(l)))
-	  do k=i+2,l
-	radbudget(j) = radbudget(j)+dzlnet(k-1)
-	  enddo
-          i=l
-        endif
-      enddo
-
-c     do i=1,kflev
-c      print*,radbudget(i),prT(i)
-c     enddo
-c     do i=1,nlve
-c      print*,dzlnet(i),prTve(i)
-c     enddo
-c     stop
-
-c On obtient le coolrate en calculant: PCOOL = radbudget*(g/cp)/pdp
-
-      do j=1,kflev
-         PCOOL(j) = radbudget(j) *RG/RCPD / pdp(j)
-         PCOOL(j) = PCOOL(j)*dureejour ! K/Venusday
-      enddo
-      
-c     print*,PCOOL
-
-      firstcall = .false.
-      return
-      end
Index: trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.multimat
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.multimat	(revision 888)
+++ 	(revision )
@@ -1,138 +1,0 @@
-      SUBROUTINE LW_venus_ve( 
-     S              PPB, pt, psi, deltapsi,
-     S              PCOOL, 
-     S              PTOPLW,PSOLLW,PSOLLWDN,
-     S              ZFLNET)
-      
-      IMPLICIT none
-
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
-#include "YOMCST.h"
-C
-C     ------------------------------------------------------------------
-C
-C     PURPOSE.
-C     --------
-C
-c     This routine uses the NER matrix
-c     (computed for a given cell and temp profile in radlwsw, 
-c      from the initial matrixes computed in load_psi)
-c     to compute cooling rates and radiative fluxes.
-c
-C     AUTHOR.
-C     -------
-C        Sebastien Lebonnois
-C
-C     MODIFICATIONS.
-C     --------------
-C        ORIGINAL : 27/07/2005
-C        version multimatrice (topographie, sommet nuages): 20/12/2006
-C     ------------------------------------------------------------------
-C
-C* ARGUMENTS:
-C
-c inputs
-
-      REAL    PPB(KFLEV+1)  ! inter-couches PRESSURE (bar)
-      REAL    pt(kflev)     ! mid-layer temperature
-      real    psi(0:kflev+1,0:kflev+1)      ! NER in W/m**2
-      real    deltapsi(0:kflev+1,0:kflev+1) ! D NER / DT in W/m**2/K
-C
-c output
-
-      REAL   PCOOL(KFLEV) ! LONGWAVE COOLING (K/VENUSDAY) within each layer
-      REAL   PTOPLW       ! LONGWAVE FLUX AT T.O.A. (net, + vers le haut)
-      REAL   PSOLLW       ! LONGWAVE FLUX AT SURFACE (net, + vers le haut)
-      REAL   PSOLLWDN     ! LONGWAVE FLUX AT SURFACE (down, + vers le bas)
-      REAL   ZFLNET(KFLEV+1) ! net thermal flux at ppb levels (+ vers le haut)
-
-C
-C* LOCAL VARIABLES:
-C
-      real    dureejour
-      parameter (dureejour=10.087e6)
-      
-      integer i,j,p
-      real   zlnet(kflev+1)    ! net thermal flux (W/m**2)
-      real   dzlnet(0:kflev)   ! Radiative budget (W/m**2)
-      real   pdp(kflev)        ! epaisseur de la couche en pression (Pa)
-
-c --------------------------
-c Calculation of the fluxes
-c --------------------------
-
-c flux aux intercouches:
-c zlnet(i+1) est le flux net traversant le plafond de la couche i (+ vers le haut)
-      do p=0,kflev ! numero de la couche
-        zlnet(p+1) = 0.0
-        do j=p+1,kflev+1
-         do i=0,p
-           zlnet(p+1) = zlnet(p+1)+ psi(i,j)
-         enddo
-        enddo
-      enddo
-
-c flux net au sol, + vers le haut:
-      PSOLLW = zlnet(1)
-c flux vers le bas au sol, + vers le bas:
-      PSOLLWDN = 0.0
-      do i=1,kflev+1
-        PSOLLWDN = PSOLLWDN+max(psi(i,0),0.0)
-      enddo
-
-c dfluxnet = radiative budget (W m-2)
-      do p=0,kflev ! numero de la couche
-        dzlnet(p) = 0.0
-        do j=0,kflev+1
-           dzlnet(p) = dzlnet(p)+psi(p,j)
-        enddo
-      enddo
-
-      
-c --------------------------------------
-c Interpolation in the GCM vertical grid
-c --------------------------------------
-
-c Flux net
-c --------
-      
-      do j=1,kflev+1
-        ZFLNET(j) =  zlnet(j)
-      enddo
-
-      PTOPLW   = ZFLNET(kflev+1)
-      
-c Heating rates
-c -------------
-
-c  cool (K/s) = dfluxnet (W/m2)    ! positif quand nrj sort de la couche
-c              *g        (m/s2)
-c              /(-dp)  (epaisseur couche, en Pa=kg/m/s2)
-c              /cp  (J/kg/K) 
-      
-      do j=1,kflev
-        pdp(j)=(PPB(j)-PPB(j+1))*1.e5
-      enddo
-
-c calcul direct OU calcul par schema implicit
-      if (1.eq.0) then 
-        do j=1,kflev
-! ADAPTATION GCM POUR CP(T)
-         PCOOL(j) = dzlnet(j) *RG/cpdet(pt(j)) / pdp(j)
-        enddo
-      else
-        call lwi(kflev,dzlnet,deltapsi,pdp,PCOOL)
-      endif
-c     print*,dzlnet
-c     print*,pdp
-c     print*,PCOOL
-
-      do j=1,kflev
-        PCOOL(j) = PCOOL(j)*dureejour ! K/Venusday
-      enddo
-
-      return
-      end
-
Index: trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.nointerp
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/lw_venus_ve.nointerp	(revision 888)
+++ 	(revision )
@@ -1,280 +1,0 @@
-      SUBROUTINE LW_venus_ve( 
-     S              PPB, PT, PTSURF,
-     S              PCOOL, 
-     S              PTOPLW,PSOLLW,PSOLLWDN,
-     S              ZFLNET)
-      
-      IMPLICIT none
-
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
-#include "YOMCST.h"
-C
-C     ------------------------------------------------------------------
-C
-C     PURPOSE.
-C     --------
-C
-c     This routine loads the longwave matrix of factors Ksi,
-c     used to build the Net Exchange Rates matrix Psi.
-c     Psi(i,j,nu) = Ksi(i,j,nu) * ( B(i,nu)-B(j,nu) )
-c     
-c     This Ksi matrix has been computed by Vincent Eymet
-C
-c     The NER matrix is then integrated in frequency, and the output
-c     are calculated.
-c
-C     AUTHOR.
-C     -------
-C        Sebastien Lebonnois
-C
-C     MODIFICATIONS.
-C     --------------
-C        ORIGINAL : 27/07/2005
-C     ------------------------------------------------------------------
-C
-C* ARGUMENTS:
-C
-c inputs
-
-      REAL   PPB(KFLEV+1)  ! inter-couches PRESSURE (bar)
-      REAL   PT(KFLEV)     ! Temperature in layer (K)
-      REAL   PTSURF        ! Surface temperature
-C
-c output
-
-      REAL   PCOOL(KFLEV) ! LONGWAVE COOLING (K/VENUSDAY) within each layer
-      REAL   PTOPLW       ! LONGWAVE FLUX AT T.O.A. (net, + vers le haut)
-      REAL   PSOLLW       ! LONGWAVE FLUX AT SURFACE (net, + vers le haut)
-      REAL   PSOLLWDN     ! LONGWAVE FLUX AT SURFACE (down, + vers le bas)
-      REAL   ZFLNET(KFLEV+1) ! net thermal flux at ppb levels (+ vers le haut)
-
-C
-C* LOCAL VARIABLES:
-C
-      integer nlve,nnuve
-      parameter (nlve=kflev) ! fichiers Vincent: same grid than GCM
-      parameter (nnuve=68)   ! fichiers Vincent et Bullock
-      real    dureejour
-      parameter (dureejour=10.087e6)
-      
-      integer i,j,p,nl0,nnu0,band
-      real   lambda(nnuve)    ! wavelenght in table (mu->m, middle of interval)
-      real   ksive(0:nlve+1,0:nlve+1,nnuve) ! ksi factors
-      real   bplck(0:nlve+1,nnuve)          ! Planck luminances in table layers
-      real   al(nnuve),bl(nnuve)            ! for Planck luminances calculations
-      real   psive(0:nlve+1,0:nlve+1,nnuve) ! NER in W/m**2 per wavelength band
-      real   psi_1(0:nlve+1,0:nlve+1)       ! NER in W/m**2 (sum on lambda)
-
-      real   ztemp(0:nlve)    ! GCM temperature in table layers
-      real   zlnet(nlve+1)    ! net thermal flux (W/m**2)
-      real   dzlnet(0:nlve)   ! Radiative budget (W/m**2)
-      character*22 nullchar
-      real   lambdamin,lambdamax ! in microns
-      real   dlambda             ! cm-1  
-
-      real   y(0:nlve,nnuve)    ! intermediaire Planck
-      real   pdp(nlve)          ! epaisseur de la couche en pression (Pa)
-      real   zdblay(nlve,nnuve)     ! gradient en temperature de planck
-      
-      logical firstcall
-      data    firstcall/.true./
-
-      save   lambda,ksive,al,bl,firstcall
-      
-c ------------------------
-c Loading the files
-c ------------------------
-
-      if (firstcall) then
-
-c Matrice Ksi
-c------------
-      open(13,file='ksi_gccr.txt')
-      read(13,*) nl0,nnu0
-      if (nl0.ne.nlve) then
-         print*,'Probleme de dimension entre ksi.txt et lw'
-         print*,'N levels = ',nl0,nlve
-         stop
-      endif
-      if (nnu0.ne.nnuve) then
-         print*,'Probleme de dimension entre ksi.txt et lw'
-         print*,'N freq = ',nnu0,nnuve
-         stop
-      endif
-      do band=1,nnuve
-         read(13,*) lambdamin,lambdamax                ! en microns
-         lambda(band)=(lambdamin+lambdamax)/2.*1.e-6   ! en m
-         dlambda     =(1./lambdamin-1./lambdamax)*1.e4 ! en cm-1
-c        print*,band,lambdamin,dlambda,lambdamax
-         do i=0,nlve+1
-           read(13,'(52e17.9)') (ksive(i,j,band),j=0,nlve+1)
-c ecart-type MC sur les ksi: pas utilise
-c          read(13,'(52e17.9)') (psive(i,j,band),j=0,nlve+1) 
-c changement de convention (signe) pour ksi,
-c et prise en compte de la largeur de bande (en cm-1):
-           do j=0,nlve+1
-              ksive(i,j,band) = -ksive(i,j,band)*dlambda
-           enddo
-         enddo
-c calcul des coeff al et bl pour luminance Planck 
-         al(band) = 2.*RHPLA*RCLUM*RCLUM/(lambda(band))**5.
-c cette luminance doit etre en W/m²/sr/µm pour correspondre au calcul
-c des ksi. Ici, elle est en W/m²/sr/m donc il faut mettre un facteur 1.e-6
-     .                * 1.e-6
-         bl(band) = RHPLA*RCLUM/(RKBOL*lambda(band))
-      enddo
-      close(13)
-
-      endif  ! firstcall
-
-c --------------------------------------
-c Calculation of the Psi matrix
-c --------------------------------------
-
-c temperature in the table layers
-c -------------------------------
-      
-      do j=1,nlve
-        ztemp(j) = PT(j)
-      enddo
-
-      ztemp(0) = PTSURF
-
-c Planck function
-c ---------------
-
-      do band=1,nnuve
-        y(0,band) = exp(bl(band)/ztemp(0))-1.
-        bplck(0,band) = al(band)/(y(0,band))
-       do j=1,nlve
-c Developpement en polynomes ?
-c       bplck(j,band) =            xp(1,band)
-c    .                  +ztemp(j)*(xp(2,band)
-c    .                  +ztemp(j)*(xp(3,band)
-c    .                  +ztemp(j)*(xp(4,band)
-c    .                  +ztemp(j)*(xp(5,band)
-c    .                  +ztemp(j)*(xp(6,band) )))))
-
-c B(T,l) = al/(exp(bl/T)-1)
-        y(j,band) = exp(bl(band)/ztemp(j))-1.
-        bplck(j,band) = al(band)/(y(j,band))
-        zdblay(j,band) = al(band)*bl(band)*exp(bl(band)/ztemp(j))/
-     .                  ((ztemp(j)**2)*(y(j,band)**2))
-       enddo
-       bplck(nlve+1,band) = 0.0
-      enddo
-
-c Calculation of Psi
-c ------------------
-
-      do band=1,nnuve
-       do j=0,nlve+1
-        do i=0,nlve+1
-         psive(i,j,band)=ksive(i,j,band)*(bplck(i,band)-bplck(j,band))
-        enddo
-       enddo
-      enddo
-
-      do j=0,nlve+1
-       do i=0,nlve+1
-        psi_1(i,j) = 0.0  ! positif quand nrj de i->j 
-       enddo
-      enddo
-      
-      do band=1,nnuve
-       do j=0,nlve+1
-        do i=0,nlve+1
-         psi_1(i,j) = psi_1(i,j)+psive(i,j,band)
-        enddo
-       enddo
-      enddo
-
-c Verif...-----------------------
-c     open(11,file="psi.dat")
-c     do i=0,nlve+1
-c       write(11,'(I3,83E17.9)') i,(psi_1(j,i),j=0,nlve+1)
-c     enddo
-c     close(11)
-c     stop
-c -------------------------------
-
-c --------------------------
-c Calculation of the fluxes
-c --------------------------
-
-c flux aux intercouches:
-c zlnet(i+1) est le flux net traversant le plafond de la couche i (+ vers le haut)
-      do p=0,nlve ! numero de la couche
-        zlnet(p+1) = 0.0
-        do j=p+1,nlve+1
-         do i=0,p
-           zlnet(p+1) = zlnet(p+1)+psi_1(i,j)
-         enddo
-        enddo
-      enddo
-
-c flux net au sol, + vers le haut:
-      PSOLLW = zlnet(1)
-c flux vers le bas au sol, + vers le bas:
-      PSOLLWDN = 0.0
-      do i=1,nlve+1
-        PSOLLWDN = PSOLLWDN+max(psi_1(i,0),0.0)
-      enddo
-
-c dfluxnet = radiative budget (W m-2)
-      do p=0,nlve ! numero de la couche
-        dzlnet(p) = 0.0
-        do j=0,nlve+1
-           dzlnet(p) = dzlnet(p)+psi_1(p,j)
-        enddo
-      enddo
-
-      
-c --------------------------------------
-c Interpolation in the GCM vertical grid
-c --------------------------------------
-
-c Flux net
-c --------
-      
-      do j=1,kflev+1
-        ZFLNET(j) =  zlnet(j)
-      enddo
-
-      PTOPLW   = ZFLNET(kflev+1)
-      
-c Heating rates
-c -------------
-
-c  cool (K/s) = dfluxnet (W/m2)    ! positif quand nrj sort de la couche
-c              *g        (m/s2)
-c              /(-dp)  (epaisseur couche, en Pa=kg/m/s2)
-c              /cp  (J/kg/K) 
-      
-
-      do j=1,kflev
-        pdp(j)=(PPB(j)-PPB(j+1))*1.e5
-      enddo
-
-c calcul direct OU calcul par schema implicit
-      if (1.eq.0) then 
-        do j=1,kflev
-         PCOOL(j) = dzlnet(j) *RG/RCPD / pdp(j)
-        enddo
-      else
-        call lwi(nlve,nnuve,dzlnet,zdblay,pdp,ksive,PCOOL)
-      endif
-c     print*,dzlnet
-c     print*,pdp
-c     print*,PCOOL
-
-      do j=1,kflev
-        PCOOL(j) = PCOOL(j)*dureejour ! K/Venusday
-      enddo
-
-      firstcall = .false.
-      return
-      end
-
Index: trunk/LMDZ.VENUS/libf/phyvenus/lwi.1mat
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/lwi.1mat	(revision 888)
+++ 	(revision )
@@ -1,199 +1,0 @@
-      subroutine lwi(nl,nnu,netrad,deltab,deltap,ksi,coolrate)
-
-
-      implicit none
-
-
-#include "dimensions.h"
-#include "dimphy.h"
-#include "comg1d.h"  !pour grads 1D
-#include "YOMCST.h"
-#include "timerad.h"
-      
-CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
-C
-C                             -   lwi    -    
-C
-C     PURPOSE:       Schema semi - implicite 
-C
-C
-CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
-
-
-c************************************************************************
-c
-c        0.    Declarations
-c              ------------
-c
-c-------------------------------------------------------------------------
-c        0.1   Arguments
-c              ---------
-c Inputs
-c.......
-
-      integer nl,nnu
-      real    ksi(0:nl+1,0:nl+1,nnu) !ksi factors  
-      real    netrad(0:nl)     ! radiative budget (W/m**2)
-      real    deltab(nl,nnu) !gradient de fonction de Planck
-      real    deltap(nl) !epaisseur de la couche en pression (Pa) 
-      
-c Outputs
-c........
-
-      real    coolrate(nl)
-      
-c-------------------------------------------------------------------------
-c        0.2   local arrays
-c              ------------
-c
-      real    di(nl) 
-     .      , spec(nl) 
-     .      , hi(nl) 
-     .      , bi(nl) 
-
-      real    ci(nl) 
-     .      , ai(nl) 
-
-      real    deltat
-
-      real    semi,semit,denom
-
-      integer i,jl,band
-
-c************************************************************************
-c
-c        1.    Initialisations
-c              ---------------
-c
-c-----------------------------------------------------------------------
-        deltat = dtimerad
-c       print*,'SEMI = ',semi, '(expl:0  semi-implicite:0.5  impl:1)'
-c        semi  = 0.5
-        semi = 0.5
-c       semi = 1.
-        semit = semi * deltat
-
-c       print*,'dtimerad,deltat,semit:',dtimerad,deltat,semit
-
-c************************************************************************
-c
-c        2.    
-c              ---------------
-c
-c-------------------------------------------------------------------------
-c        2.1   Calcul des di
-c              -------------
-c
-
-      do i = 1 , nl-1
-        spec(i) = 0.0e0
-        do band = 1, nnu
-          spec(i) = spec(i) + 
-     .      ( ksi(i,nl+1,band)
-     .      + ksi(i,i+1,band)
-     .      + ksi(i,i-1,band) ) * deltab(i,band)
-        enddo
-      
-        di(i) =  1. + semit * (RG / deltap(i) / RCPD) * spec(i)
-c     print*,i,' di(i)=',di(i)
-      enddo
-         
-
-c couche nl
-c ------------
-c      , on enleve i,i+1 sinon on a 2 fois le cooling2space
- 
-        spec(nl) = 0.0e0
-        do band = 1, nnu
-          spec(nl) = spec(nl) +
-     .      ( ksi(nl,nl+1,band)
-     .      + ksi(nl,nl-1,band) ) * deltab(nl,band)
-        enddo
-     
-        di(nl) =  1. + semit * (RG / deltap(nl) / RCPD) * spec(nl)
-
-c-------------------------------------------------------------------------
-c        2.2   Calcul des hi
-c              -------------
-c
-
-      do i = 1 , nl-1
-      
-        spec(i) = 0.0e0
-        do band = 1, nnu
-          spec(i) = spec(i) + ksi(i,i+1,band) * deltab(i+1,band)
-        enddo
-
-        hi(i) =  - semit * (RG / deltap(i) / RCPD) * spec(i)
-
-      enddo
-                        
-c     print*,'hi(i)',hi(i)
-
-c-------------------------------------------------------------------------
-c        2.3   Calcul des bi
-c              -------------
-c
-
-
-      do i = 2 , nl
-      
-        spec(i) = 0.0e0
-        do band = 1, nnu
-          spec(i) = spec(i) + ksi(i,i-1,band) * deltab(i-1,band)
-        enddo
-       
-        bi(i) =   - semit * (RG / deltap(i) / RCPD) * spec(i)
-        
-      enddo
-
-c     print*,'bi(i)',bi(i)
-
-c couche 1
-c --------
-c  tant qu'on a pas un calcul propre de deltab(0) qui tienne compte de 
-c    la discontinuite de temperature au sol , on met  b1 = 0
-
-      
-        bi(1) = 0 
-
-c-------------------------------------------------------------------------
-c        2.4   
-c              -------------
-c
-
-c couche nl
-c ------------
-
-c     ci(nl) = ((RG/RCPD) * netrad(nl) / deltap(nl))
-c    .                   / di(nl)
-      ci(nl) = netrad(nl) *RG/RCPD / deltap(nl)
-
-      ai(nl) = - bi(nl) / di(nl)
-
-      do i = nl-1 , 1 , -1
-        denom = di(i) + hi(i) * ai(i+1)
-
-c       ci(i) = (  (RG/RCPD) * netrad(i) / deltap(i)
-c    .               - hi(i) * ci(i+1)  )  / denom
-        ci(i) = netrad(i) *RG/RCPD / deltap(i)
- 
-        ai(i) = -bi(i) / denom
-      enddo
-
-c-------------------------------------------------------------------------
-c        2.5   
-c              -------------
-c
-
-      coolrate(1) = ci(1)
-
-      do i = 2 , nl
-           coolrate(i) = ci(i) + ai(i) * coolrate(i-1)
-c       print*,i,' coolrate(i)=',coolrate(i)
-      enddo
-
-c-------------------------------------------------------------------------
-
-      RETURN
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/lwi.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/lwi.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/lwi.F	(revision 892)
@@ -10,5 +10,4 @@
 
 #include "dimensions.h"
-#include "comg1d.h"  !pour grads 1D
 #include "YOMCST.h"
 #include "timerad.h"
Index: trunk/LMDZ.VENUS/libf/phyvenus/lwi.multimat
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/lwi.multimat	(revision 888)
+++ 	(revision )
@@ -1,189 +1,0 @@
-      subroutine lwi(nl,netrad,deltapsi,deltap,coolrate)
-
-c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-c §§§§!!!  VERSION utilisable avec load_psi,  
-c          differente des versions *.1mat  
-c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      implicit none
-
-
-#include "dimensions.h"
-#include "dimphy.h"
-#include "comg1d.h"  !pour grads 1D
-#include "YOMCST.h"
-#include "timerad.h"
-      
-CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
-C
-C                             -   lwi    -    
-C
-C     PURPOSE:       Schema semi - implicite 
-C
-C
-CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
-
-
-c************************************************************************
-c
-c        0.    Declarations
-c              ------------
-c
-c-------------------------------------------------------------------------
-c        0.1   Arguments
-c              ---------
-c Inputs
-c.......
-
-      integer nl
-      real    deltapsi(0:nl+1,0:nl+1) ! Dpsi/DT = sum(nu)[ksi DB/DT] 
-      real    netrad(0:nl)     ! radiative budget (W/m**2)
-      real    deltap(nl) !epaisseur de la couche en pression (Pa) 
-      
-c Outputs
-c........
-
-      real    coolrate(nl)
-      
-c-------------------------------------------------------------------------
-c        0.2   local arrays
-c              ------------
-c
-      real    di(nl) 
-     .      , spec(nl) 
-     .      , hi(nl) 
-     .      , bi(nl) 
-
-      real    ci(nl) 
-     .      , ai(nl) 
-
-      real    deltat
-
-      real    semi,semit,denom
-
-      integer i,jl,band
-
-c************************************************************************
-c
-c        1.    Initialisations
-c              ---------------
-c
-c-----------------------------------------------------------------------
-        deltat = dtimerad
-c       print*,'SEMI = ',semi, '(expl:0  semi-implicite:0.5  impl:1)'
-c        semi  = 0.5
-c       semi = 0.5
-        semi = 1.
-        semit = semi * deltat
-
-c       print*,'dtimerad,deltat,semit:',dtimerad,deltat,semit
-
-c************************************************************************
-c
-c        2.    
-c              ---------------
-c
-c-------------------------------------------------------------------------
-c        2.1   Calcul des di
-c              -------------
-c
-
-      do i = 1 , nl-1
-        spec(i) = 
-     .      ( deltapsi(i,nl+1)
-     .      + deltapsi(i,i+1)
-     .      + deltapsi(i,i-1) )
-      
-        di(i) =  1. + semit * (RG / deltap(i) / RCPD) * spec(i)
-c     print*,i,' di(i)=',di(i)
-      enddo
-         
-
-c couche nl
-c ------------
-c      , on enleve i,i+1 sinon on a 2 fois le cooling2space
- 
-        spec(nl) = 
-     .      ( deltapsi(nl,nl+1)
-     .      + deltapsi(nl,nl-1) )
-     
-        di(nl) =  1. + semit * (RG / deltap(nl) / RCPD) * spec(nl)
-
-c-------------------------------------------------------------------------
-c        2.2   Calcul des hi
-c              -------------
-c
-
-      do i = 1 , nl-1
-      
-        spec(i) = deltapsi(i+1,i)
-
-        hi(i) = - semit * (RG / deltap(i) / RCPD) * spec(i)
-
-      enddo
-                        
-c     print*,'hi(i)',hi(i)
-
-c-------------------------------------------------------------------------
-c        2.3   Calcul des bi
-c              -------------
-c
-
-
-      do i = 2 , nl
-      
-        spec(i) = deltapsi(i-1,i)
-       
-        bi(i) = - semit * (RG / deltap(i) / RCPD) * spec(i)
-        
-      enddo
-
-c     print*,'bi(i)',bi(i)
-
-c couche 1
-c --------
-c  tant qu'on a pas un calcul propre de deltab(0) qui tienne compte de 
-c    la discontinuite de temperature au sol , on met  b1 = 0
-
-      
-        bi(1) = 0 
-
-c-------------------------------------------------------------------------
-c        2.4   
-c              -------------
-c
-
-c couche nl
-c ------------
-
-c     ci(nl) = ((RG/RCPD) * netrad(nl) / deltap(nl))
-c    .                   / di(nl)
-      ci(nl) = netrad(nl) *RG/RCPD / deltap(nl)
-
-      ai(nl) = - bi(nl) / di(nl)
-
-      do i = nl-1 , 1 , -1
-        denom = di(i) + hi(i) * ai(i+1)
-
-c       ci(i) = (  (RG/RCPD) * netrad(i) / deltap(i)
-c    .               - hi(i) * ci(i+1)  )  / denom
-        ci(i) = netrad(i) *RG/RCPD / deltap(i)
- 
-        ai(i) = -bi(i) / denom
-      enddo
-
-c-------------------------------------------------------------------------
-c        2.5   
-c              -------------
-c
-
-      coolrate(1) = ci(1)
-
-      do i = 2 , nl
-           coolrate(i) = ci(i) + ai(i) * coolrate(i-1)
-c       print*,i,' coolrate(i)=',coolrate(i)
-      enddo
-
-c-------------------------------------------------------------------------
-
-      RETURN
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/minmaxqfi.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/minmaxqfi.F	(revision 888)
+++ 	(revision )
@@ -1,34 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/minmaxqfi.F,v 1.1.1.1 2004/05/19 12:53:09 lmdzadmin Exp $
-!
-      SUBROUTINE minmaxqfi(zq,qmin,qmax,comment)
-
-      use dimphy
-      IMPLICIT none
-
-#include "dimensions.h"
-
-      CHARACTER*(*) comment
-      real qmin,qmax
-      real zq(klon,klev)
-
-      INTEGER jadrs(klon), jbad, k, i
-
-      DO k = 1, klev
-         jbad = 0
-         DO i = 1, klon
-         IF (zq(i,k).GT.qmax .OR. zq(i,k).LT.qmin) THEN
-            jbad = jbad + 1
-            jadrs(jbad) = i
-         ENDIF
-         ENDDO
-         IF (jbad.GT.0) THEN
-         PRINT*, comment
-         DO i = 1, jbad
-            PRINT*, "i,k,q=", jadrs(i),k,zq(jadrs(i),k)
-         ENDDO
-         ENDIF
-      ENDDO
-
-      return
-      end
Index: trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_mpi_data.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_mpi_data.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_mpi_data.F90	(revision 892)
@@ -0,0 +1,203 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_mpi_data
+  USE mod_const_mpi
+  
+  INTEGER,SAVE :: ii_begin
+  INTEGER,SAVE :: ii_end
+  INTEGER,SAVE :: jj_begin
+  INTEGER,SAVE :: jj_end
+  INTEGER,SAVE :: jj_nb
+  INTEGER,SAVE :: ij_begin
+  INTEGER,SAVE :: ij_end
+  INTEGER,SAVE :: ij_nb
+  INTEGER,SAVE :: klon_mpi_begin
+  INTEGER,SAVE :: klon_mpi_end
+  INTEGER,SAVE :: klon_mpi
+  
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_nb
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_begin
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_end
+
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_begin
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_end
+
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_nb
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_begin
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_end
+
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_nb
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_begin
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_end 
+
+  
+  INTEGER,SAVE :: mpi_rank
+  INTEGER,SAVE :: mpi_size
+  INTEGER,SAVE :: mpi_root
+  LOGICAL,SAVE :: is_mpi_root
+  LOGICAL,SAVE :: is_using_mpi
+  
+  
+  LOGICAL,SAVE :: is_north_pole
+  LOGICAL,SAVE :: is_south_pole
+  INTEGER,SAVE :: COMM_LMDZ_PHY
+
+CONTAINS
+  
+  SUBROUTINE init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib)
+  USE mod_const_mpi, ONLY : COMM_LMDZ
+  IMPLICIT NONE
+    INTEGER,INTENT(in) :: iim
+    INTEGER,INTENT(in) :: jjp1
+    INTEGER,INTENT(in) :: nb_proc
+    INTEGER,INTENT(in) :: distrib(0:nb_proc-1)
+    
+    INTEGER :: ierr
+    INTEGER :: klon_glo
+    INTEGER :: i
+    
+#ifdef CPP_MPI
+    is_using_mpi=.TRUE.
+#else
+    is_using_mpi=.FALSE.
+#endif
+    
+    if (iim.eq.1) then
+       klon_glo=1
+    else
+       klon_glo=iim*(jjp1-2)+2
+    endif
+    
+    COMM_LMDZ_PHY=COMM_LMDZ
+
+    IF (is_using_mpi) THEN    
+#ifdef CPP_MPI
+      CALL MPI_COMM_SIZE(COMM_LMDZ_PHY,mpi_size,ierr)    
+      CALL MPI_COMM_RANK(COMM_LMDZ_PHY,mpi_rank,ierr)
+#endif
+    ELSE
+      mpi_size=1
+      mpi_rank=0
+    ENDIF
+    
+    IF (mpi_rank == 0) THEN
+      mpi_root = 0
+      is_mpi_root = .true.
+    ENDIF
+    
+    IF (mpi_rank == 0) THEN 
+      is_north_pole = .TRUE.
+    ELSE
+      is_north_pole = .FALSE.
+    ENDIF
+    
+    IF (mpi_rank == mpi_size-1) THEN
+      is_south_pole = .TRUE.
+    ELSE
+      is_south_pole = .FALSE.
+    ENDIF
+    
+    ALLOCATE(jj_para_nb(0:mpi_size-1))
+    ALLOCATE(jj_para_begin(0:mpi_size-1))
+    ALLOCATE(jj_para_end(0:mpi_size-1))
+    
+    ALLOCATE(ij_para_nb(0:mpi_size-1))
+    ALLOCATE(ij_para_begin(0:mpi_size-1))
+    ALLOCATE(ij_para_end(0:mpi_size-1))
+    
+    ALLOCATE(ii_para_begin(0:mpi_size-1))
+    ALLOCATE(ii_para_end(0:mpi_size-1))
+
+    ALLOCATE(klon_mpi_para_nb(0:mpi_size-1))
+    ALLOCATE(klon_mpi_para_begin(0:mpi_size-1))
+    ALLOCATE(klon_mpi_para_end(0:mpi_size-1))
+  
+      
+    klon_mpi_para_nb(0:mpi_size-1)=distrib(0:nb_proc-1)
+
+    DO i=0,mpi_size-1
+      IF (i==0) THEN 
+        klon_mpi_para_begin(i)=1
+      ELSE 
+        klon_mpi_para_begin(i)=klon_mpi_para_end(i-1)+1
+      ENDIF
+        klon_mpi_para_end(i)=klon_mpi_para_begin(i)+klon_mpi_para_nb(i)-1
+    ENDDO
+
+
+    DO i=0,mpi_size-1
+      
+      IF (i==0) THEN
+        ij_para_begin(i) = 1
+      ELSE
+        ij_para_begin(i) = klon_mpi_para_begin(i)+iim-1
+      ENDIF
+
+      jj_para_begin(i) = (ij_para_begin(i)-1)/iim + 1
+      ii_para_begin(i) = MOD(ij_para_begin(i)-1,iim) + 1
+
+      
+      ij_para_end(i) = klon_mpi_para_end(i)+iim-1
+      jj_para_end(i) = (ij_para_end(i)-1)/iim + 1
+      ii_para_end(i) = MOD(ij_para_end(i)-1,iim) + 1
+
+
+      ij_para_nb(i) = ij_para_end(i)-ij_para_begin(i)+1
+      jj_para_nb(i) = jj_para_end(i)-jj_para_begin(i)+1
+         
+    ENDDO
+  
+    ii_begin = ii_para_begin(mpi_rank)
+    ii_end   = ii_para_end(mpi_rank)
+    jj_begin = jj_para_begin(mpi_rank)
+    jj_end   = jj_para_end(mpi_rank)
+    jj_nb    = jj_para_nb(mpi_rank)
+    ij_begin = ij_para_begin(mpi_rank)
+    ij_end   = ij_para_end(mpi_rank)
+    ij_nb    = ij_para_nb(mpi_rank)
+    klon_mpi_begin = klon_mpi_para_begin(mpi_rank)
+    klon_mpi_end   = klon_mpi_para_end(mpi_rank)
+    klon_mpi       = klon_mpi_para_nb(mpi_rank)
+   
+    CALL print_module_data
+    
+  END SUBROUTINE init_phys_lmdz_mpi_data
+
+  SUBROUTINE print_module_data
+  IMPLICIT NONE
+  INCLUDE "iniprint.h" 
+  
+    WRITE(lunout,*) 'ii_begin =', ii_begin
+    WRITE(lunout,*) 'ii_end =', ii_end
+    WRITE(lunout,*) 'jj_begin =',jj_begin
+    WRITE(lunout,*) 'jj_end =', jj_end
+    WRITE(lunout,*) 'jj_nb =', jj_nb
+    WRITE(lunout,*) 'ij_begin =', ij_begin
+    WRITE(lunout,*) 'ij_end =', ij_end
+    WRITE(lunout,*) 'ij_nb =', ij_nb
+    WRITE(lunout,*) 'klon_mpi_begin =', klon_mpi_begin
+    WRITE(lunout,*) 'klon_mpi_end =', klon_mpi_end
+    WRITE(lunout,*) 'klon_mpi =', klon_mpi
+    WRITE(lunout,*) 'jj_para_nb =', jj_para_nb
+    WRITE(lunout,*) 'jj_para_begin =', jj_para_begin
+    WRITE(lunout,*) 'jj_para_end =', jj_para_end
+    WRITE(lunout,*) 'ii_para_begin =', ii_para_begin
+    WRITE(lunout,*) 'ii_para_end =', ii_para_end
+    WRITE(lunout,*) 'ij_para_nb =', ij_para_nb
+    WRITE(lunout,*) 'ij_para_begin =', ij_para_begin
+    WRITE(lunout,*) 'ij_para_end =', ij_para_end
+    WRITE(lunout,*) 'klon_mpi_para_nb =', klon_mpi_para_nb
+    WRITE(lunout,*) 'klon_mpi_para_begin =', klon_mpi_para_begin
+    WRITE(lunout,*) 'klon_mpi_para_end  =', klon_mpi_para_end 
+    WRITE(lunout,*) 'mpi_rank =', mpi_rank
+    WRITE(lunout,*) 'mpi_size =', mpi_size
+    WRITE(lunout,*) 'mpi_root =', mpi_root
+    WRITE(lunout,*) 'is_mpi_root =', is_mpi_root
+    WRITE(lunout,*) 'is_north_pole =', is_north_pole
+    WRITE(lunout,*) 'is_south_pole =', is_south_pole
+    WRITE(lunout,*) 'COMM_LMDZ_PHY =', COMM_LMDZ_PHY
+  
+  END SUBROUTINE print_module_data
+  
+END MODULE mod_phys_lmdz_mpi_data
Index: trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_mpi_transfert.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_mpi_transfert.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_mpi_transfert.F90	(revision 892)
@@ -0,0 +1,1902 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_mpi_transfert
+
+
+  INTERFACE bcast_mpi
+    MODULE PROCEDURE bcast_mpi_c,                                                     &
+                     bcast_mpi_i,bcast_mpi_i1,bcast_mpi_i2,bcast_mpi_i3,bcast_mpi_i4, &
+                     bcast_mpi_r,bcast_mpi_r1,bcast_mpi_r2,bcast_mpi_r3,bcast_mpi_r4, &
+		     bcast_mpi_l,bcast_mpi_l1,bcast_mpi_l2,bcast_mpi_l3,bcast_mpi_l4
+  END INTERFACE
+
+  INTERFACE scatter_mpi
+    MODULE PROCEDURE scatter_mpi_i,scatter_mpi_i1,scatter_mpi_i2,scatter_mpi_i3, &
+                     scatter_mpi_r,scatter_mpi_r1,scatter_mpi_r2,scatter_mpi_r3, &
+		     scatter_mpi_l,scatter_mpi_l1,scatter_mpi_l2,scatter_mpi_l3
+  END INTERFACE
+
+  
+  INTERFACE gather_mpi
+    MODULE PROCEDURE gather_mpi_i,gather_mpi_i1,gather_mpi_i2,gather_mpi_i3, &
+                     gather_mpi_r,gather_mpi_r1,gather_mpi_r2,gather_mpi_r3, &
+		     gather_mpi_l,gather_mpi_l1,gather_mpi_l2,gather_mpi_l3  
+  END INTERFACE
+  
+  INTERFACE scatter2D_mpi
+    MODULE PROCEDURE scatter2D_mpi_i,scatter2D_mpi_i1,scatter2D_mpi_i2,scatter2D_mpi_i3, &
+                     scatter2D_mpi_r,scatter2D_mpi_r1,scatter2D_mpi_r2,scatter2D_mpi_r3, &
+		     scatter2D_mpi_l,scatter2D_mpi_l1,scatter2D_mpi_l2,scatter2D_mpi_l3
+  END INTERFACE
+
+  INTERFACE gather2D_mpi
+    MODULE PROCEDURE gather2D_mpi_i,gather2D_mpi_i1,gather2D_mpi_i2,gather2D_mpi_i3, &
+                     gather2D_mpi_r,gather2D_mpi_r1,gather2D_mpi_r2,gather2D_mpi_r3, &
+		     gather2D_mpi_l,gather2D_mpi_l1,gather2D_mpi_l2,gather2D_mpi_l3
+  END INTERFACE 
+  
+  INTERFACE reduce_sum_mpi
+    MODULE PROCEDURE reduce_sum_mpi_i,reduce_sum_mpi_i1,reduce_sum_mpi_i2,reduce_sum_mpi_i3,reduce_sum_mpi_i4, &
+                     reduce_sum_mpi_r,reduce_sum_mpi_r1,reduce_sum_mpi_r2,reduce_sum_mpi_r3,reduce_sum_mpi_r4
+  END INTERFACE 
+
+ INTERFACE grid1dTo2d_mpi
+    MODULE PROCEDURE grid1dTo2d_mpi_i,grid1dTo2d_mpi_i1,grid1dTo2d_mpi_i2,grid1dTo2d_mpi_i3, &
+                     grid1dTo2d_mpi_r,grid1dTo2d_mpi_r1,grid1dTo2d_mpi_r2,grid1dTo2d_mpi_r3, &
+		     grid1dTo2d_mpi_l,grid1dTo2d_mpi_l1,grid1dTo2d_mpi_l2,grid1dTo2d_mpi_l3
+ END INTERFACE 
+
+ INTERFACE grid2dTo1d_mpi
+    MODULE PROCEDURE grid2dTo1d_mpi_i,grid2dTo1d_mpi_i1,grid2dTo1d_mpi_i2,grid2dTo1d_mpi_i3, &
+                     grid2dTo1d_mpi_r,grid2dTo1d_mpi_r1,grid2dTo1d_mpi_r2,grid2dTo1d_mpi_r3, &
+		     grid2dTo1d_mpi_l,grid2dTo1d_mpi_l1,grid2dTo1d_mpi_l2,grid2dTo1d_mpi_l3
+ END INTERFACE 
+    
+CONTAINS
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Broadcast --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!! -- Les chaine de charactère -- !!
+
+  SUBROUTINE bcast_mpi_c(var1)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var1
+   
+    CALL bcast_mpi_cgen(Var1,len(Var1))
+
+  END SUBROUTINE bcast_mpi_c
+
+!! -- Les entiers -- !!
+  
+  SUBROUTINE bcast_mpi_i(var)
+  USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var
+    
+    INTEGER               :: var_tmp(1)
+    
+    IF (is_mpi_root) var_tmp(1)=var
+    CALL bcast_mpi_igen(Var_tmp,1)
+    var=var_tmp(1)
+    
+  END SUBROUTINE bcast_mpi_i
+
+  SUBROUTINE bcast_mpi_i1(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:)
+
+    CALL bcast_mpi_igen(Var,size(Var))
+    
+  END SUBROUTINE bcast_mpi_i1
+
+  SUBROUTINE bcast_mpi_i2(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:)
+   
+    CALL bcast_mpi_igen(Var,size(Var))
+  
+  END SUBROUTINE bcast_mpi_i2
+
+  SUBROUTINE bcast_mpi_i3(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:)
+   
+    CALL bcast_mpi_igen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_i3
+
+  SUBROUTINE bcast_mpi_i4(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL bcast_mpi_igen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_i4
+
+
+!! -- Les reels -- !!
+
+  SUBROUTINE bcast_mpi_r(var)
+  USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var
+    REAL               :: var_tmp(1)
+    
+    IF (is_mpi_root) var_tmp(1)=var
+    CALL bcast_mpi_rgen(Var_tmp,1)
+    var=var_tmp(1)   
+
+  END SUBROUTINE bcast_mpi_r
+
+  SUBROUTINE bcast_mpi_r1(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:)
+   
+    CALL bcast_mpi_rgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_r1
+
+  SUBROUTINE bcast_mpi_r2(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:)
+   
+    CALL bcast_mpi_rgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_r2
+
+  SUBROUTINE bcast_mpi_r3(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:)
+   
+    CALL bcast_mpi_rgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_r3
+
+  SUBROUTINE bcast_mpi_r4(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL bcast_mpi_rgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_r4
+  
+!! -- Les booleans -- !!
+
+  SUBROUTINE bcast_mpi_l(var)
+  USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var
+    LOGICAL               :: var_tmp(1)
+    
+    IF (is_mpi_root) var_tmp(1)=var
+    CALL bcast_mpi_lgen(Var_tmp,1)
+    var=var_tmp(1)   
+
+  END SUBROUTINE bcast_mpi_l
+
+  SUBROUTINE bcast_mpi_l1(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:)
+   
+    CALL bcast_mpi_lgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_l1
+
+  SUBROUTINE bcast_mpi_l2(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:)
+   
+    CALL bcast_mpi_lgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_l2
+
+  SUBROUTINE bcast_mpi_l3(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:)
+   
+    CALL bcast_mpi_lgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_l3
+
+  SUBROUTINE bcast_mpi_l4(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL bcast_mpi_lgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_l4
+  
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE scatter_mpi_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL scatter_mpi_igen(VarIn,Varout,1)
+    
+  END SUBROUTINE scatter_mpi_i
+
+  SUBROUTINE scatter_mpi_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL scatter_mpi_igen(VarIn,Varout,Size(VarOut,2))
+    
+  END SUBROUTINE scatter_mpi_i1
+  
+  SUBROUTINE scatter_mpi_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL scatter_mpi_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3))
+
+  END SUBROUTINE scatter_mpi_i2
+
+  SUBROUTINE scatter_mpi_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL scatter_mpi_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4))
+  
+  END SUBROUTINE scatter_mpi_i3
+
+
+  SUBROUTINE scatter_mpi_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL scatter_mpi_rgen(VarIn,Varout,1)
+  
+  END SUBROUTINE scatter_mpi_r
+
+  SUBROUTINE scatter_mpi_r1(VarIn, VarOut)
+  USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+  IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL scatter_mpi_rgen(VarIn,Varout,Size(VarOut,2))
+  
+  END SUBROUTINE scatter_mpi_r1
+  
+  SUBROUTINE scatter_mpi_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL scatter_mpi_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3))
+  
+  END SUBROUTINE scatter_mpi_r2
+
+  SUBROUTINE scatter_mpi_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+      CALL scatter_mpi_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4))
+  
+  END SUBROUTINE scatter_mpi_r3
+
+
+  SUBROUTINE scatter_mpi_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL scatter_mpi_lgen(VarIn,Varout,1)
+    
+  END SUBROUTINE scatter_mpi_l
+
+  SUBROUTINE scatter_mpi_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL scatter_mpi_lgen(VarIn,Varout,Size(VarOut,2))
+  
+  END SUBROUTINE scatter_mpi_l1
+  
+  SUBROUTINE scatter_mpi_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL scatter_mpi_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3))
+  
+  END SUBROUTINE scatter_mpi_l2
+
+  SUBROUTINE scatter_mpi_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+      CALL scatter_mpi_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4))
+  
+  END SUBROUTINE scatter_mpi_l3  
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Gather   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ 
+!!!!! --> Les entiers
+
+  SUBROUTINE gather_mpi_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL gather_mpi_igen(VarIn,VarOut,1)
+  
+  END SUBROUTINE gather_mpi_i
+  
+
+!!!!!
+
+  SUBROUTINE gather_mpi_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL gather_mpi_igen(VarIn,VarOut,Size(VarIn,2))
+  
+  END SUBROUTINE gather_mpi_i1
+
+!!!!!
+  
+  SUBROUTINE gather_mpi_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL gather_mpi_igen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3))
+  
+  END SUBROUTINE gather_mpi_i2
+
+!!!!!
+
+  SUBROUTINE gather_mpi_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+      CALL gather_mpi_igen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
+  
+  END SUBROUTINE gather_mpi_i3
+
+!!!!! --> Les reels
+
+  SUBROUTINE gather_mpi_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL gather_mpi_rgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE gather_mpi_r
+
+!!!!!
+
+  SUBROUTINE gather_mpi_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL gather_mpi_rgen(VarIn,VarOut,Size(VarIn,2))
+  
+  END SUBROUTINE gather_mpi_r1
+
+!!!!!
+  
+  SUBROUTINE gather_mpi_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL gather_mpi_rgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3))
+  
+  END SUBROUTINE gather_mpi_r2
+
+!!!!!
+
+  SUBROUTINE gather_mpi_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+      CALL gather_mpi_rgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
+  
+  END SUBROUTINE gather_mpi_r3
+
+!!!!! --> Les booleen
+
+  SUBROUTINE gather_mpi_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL gather_mpi_lgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE gather_mpi_l
+
+!!!!!
+
+  SUBROUTINE gather_mpi_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL gather_mpi_lgen(VarIn,VarOut,Size(VarIn,2))
+  
+  END SUBROUTINE gather_mpi_l1
+
+!!!!!
+  
+  SUBROUTINE gather_mpi_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL gather_mpi_lgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3))
+  
+  END SUBROUTINE gather_mpi_l2
+
+!!!!!
+
+  SUBROUTINE gather_mpi_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL gather_mpi_lgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
+  
+  END SUBROUTINE gather_mpi_l3
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter2D   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE scatter2D_mpi_i(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    INTEGER,DIMENSION(klon_glo) :: Var_tmp    
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_i
+
+  SUBROUTINE scatter2D_mpi_i1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    INTEGER,DIMENSION(klon_glo,size(VarOut,2)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_i1
+
+  SUBROUTINE scatter2D_mpi_i2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_i2
+  
+  SUBROUTINE scatter2D_mpi_i3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    INTEGER,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3),size(VarOut,4)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+    
+  END SUBROUTINE scatter2D_mpi_i3
+
+
+
+  SUBROUTINE scatter2D_mpi_r(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    REAL,DIMENSION(klon_glo) :: Var_tmp    
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_R
+
+
+  SUBROUTINE scatter2D_mpi_r1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,2)) :: Var_tmp
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_r1
+
+
+  SUBROUTINE scatter2D_mpi_r2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    REAL,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3)) :: Var_tmp
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_r2
+  
+  SUBROUTINE scatter2D_mpi_r3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3),size(VarOut,4)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+ 
+  END SUBROUTINE scatter2D_mpi_r3
+  
+  
+  SUBROUTINE scatter2D_mpi_l(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_glo) :: Var_tmp    
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_l
+
+
+  SUBROUTINE scatter2D_mpi_l1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,2)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+  
+  END SUBROUTINE scatter2D_mpi_l1
+
+
+  SUBROUTINE scatter2D_mpi_l2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3)) :: Var_tmp
+  
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_l2
+  
+  SUBROUTINE scatter2D_mpi_l3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3),size(VarOut,4)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+ 
+  END SUBROUTINE scatter2D_mpi_l3
+  
+  
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Gather2D   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE gather2D_mpi_i(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_glo) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_i
+
+  SUBROUTINE gather2D_mpi_i1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_glo,size(VarOut,3)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_i1
+
+  SUBROUTINE gather2D_mpi_i2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4)) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_i2
+  
+  SUBROUTINE gather2D_mpi_i3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+ 
+    INTEGER,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4),SIZE(VarOut,5)) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_i3
+
+
+
+  SUBROUTINE gather2D_mpi_r(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_r
+
+  SUBROUTINE gather2D_mpi_r1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,3)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_r1
+
+  SUBROUTINE gather2D_mpi_r2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_r2
+  
+  SUBROUTINE gather2D_mpi_r3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4),SIZE(VarOut,5)) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_r3
+
+  
+  
+  SUBROUTINE gather2D_mpi_l(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_l
+
+  SUBROUTINE gather2D_mpi_l1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,3)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_l1
+
+  SUBROUTINE gather2D_mpi_l2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_l2
+  
+  SUBROUTINE gather2D_mpi_l3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4),SIZE(VarOut,5)) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_l3
+  
+  
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des reduce_sum   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE reduce_sum_mpi_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN)  :: VarIn
+    INTEGER,INTENT(OUT) :: VarOut
+    INTEGER             :: VarIn_tmp(1)
+    INTEGER             :: VarOut_tmp(1)
+    
+    VarIn_tmp(1)=VarIn    
+    CALL reduce_sum_mpi_igen(VarIn_tmp,Varout_tmp,1)
+    VarOut=VarOut_tmp(1)
+    
+  END SUBROUTINE reduce_sum_mpi_i
+
+  SUBROUTINE reduce_sum_mpi_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_i1
+
+  SUBROUTINE reduce_sum_mpi_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_i2
+
+  SUBROUTINE reduce_sum_mpi_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_i3
+
+  SUBROUTINE reduce_sum_mpi_i4(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_i4                  
+  
+  
+  SUBROUTINE reduce_sum_mpi_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN)  :: VarIn
+    REAL,INTENT(OUT) :: VarOut
+    REAL             :: VarIn_tmp(1)
+    REAL             :: VarOut_tmp(1)
+    
+    VarIn_tmp(1)=VarIn    
+    CALL reduce_sum_mpi_rgen(VarIn_tmp,Varout_tmp,1)
+    VarOut=VarOut_tmp(1)
+  
+  END SUBROUTINE reduce_sum_mpi_r
+
+  SUBROUTINE reduce_sum_mpi_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
+     
+  END SUBROUTINE reduce_sum_mpi_r1
+
+  SUBROUTINE reduce_sum_mpi_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_r2
+
+  SUBROUTINE reduce_sum_mpi_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_r3
+
+  SUBROUTINE reduce_sum_mpi_r4(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_r4 
+  
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! SUBROUTINE grid1dTo2d  !!  
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+  SUBROUTINE grid1dTo2d_mpi_i(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid1dTo2d_mpi_i
+  
+
+  SUBROUTINE grid1dTo2d_mpi_i1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,size(VarIn,2))
+  
+  END SUBROUTINE grid1dTo2d_mpi_i1
+
+  SUBROUTINE grid1dTo2d_mpi_i2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
+  
+  END SUBROUTINE grid1dTo2d_mpi_i2
+  
+  SUBROUTINE grid1dTo2d_mpi_i3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid1dTo2d_mpi_i3
+
+
+  SUBROUTINE grid1dTo2d_mpi_r(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid1dTo2d_mpi_r
+  
+
+  SUBROUTINE grid1dTo2d_mpi_r1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,size(VarIn,2))
+  
+  END SUBROUTINE grid1dTo2d_mpi_r1
+
+  SUBROUTINE grid1dTo2d_mpi_r2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
+  
+  END SUBROUTINE grid1dTo2d_mpi_r2
+  
+  SUBROUTINE grid1dTo2d_mpi_r3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid1dTo2d_mpi_r3
+  
+  
+  
+  SUBROUTINE grid1dTo2d_mpi_l(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid1dTo2d_mpi_l
+  
+
+  SUBROUTINE grid1dTo2d_mpi_l1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,size(VarIn,2))
+  
+  END SUBROUTINE grid1dTo2d_mpi_l1
+
+  SUBROUTINE grid1dTo2d_mpi_l2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
+  
+  END SUBROUTINE grid1dTo2d_mpi_l2
+  
+  SUBROUTINE grid1dTo2d_mpi_l3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid1dTo2d_mpi_l3
+
+
+  SUBROUTINE grid2dTo1d_mpi_i(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid2dTo1d_mpi_i
+  
+
+  SUBROUTINE grid2dTo1d_mpi_i1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,size(VarIn,3))
+  
+  END SUBROUTINE grid2dTo1d_mpi_i1
+
+  SUBROUTINE grid2dTo1d_mpi_i2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid2dTo1d_mpi_i2
+  
+  SUBROUTINE grid2dTo1d_mpi_i3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
+  
+  END SUBROUTINE grid2dTo1d_mpi_i3
+ 
+
+
+
+  SUBROUTINE grid2dTo1d_mpi_r(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid2dTo1d_mpi_r
+  
+
+  SUBROUTINE grid2dTo1d_mpi_r1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,size(VarIn,3))
+  
+  END SUBROUTINE grid2dTo1d_mpi_r1
+
+  SUBROUTINE grid2dTo1d_mpi_r2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid2dTo1d_mpi_r2
+  
+  SUBROUTINE grid2dTo1d_mpi_r3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
+  
+  END SUBROUTINE grid2dTo1d_mpi_r3
+
+
+
+  SUBROUTINE grid2dTo1d_mpi_l(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid2dTo1d_mpi_l
+  
+
+  SUBROUTINE grid2dTo1d_mpi_l1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,size(VarIn,3))
+  
+  END SUBROUTINE grid2dTo1d_mpi_l1
+
+
+
+  SUBROUTINE grid2dTo1d_mpi_l2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid2dTo1d_mpi_l2
+
+  
+  SUBROUTINE grid2dTo1d_mpi_l3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
+  
+  END SUBROUTINE grid2dTo1d_mpi_l3
+
+               
+
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! DEFINITION DES FONCTIONS DE TRANSFERT GENERIQUES !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE bcast_mpi_cgen(var,nb)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    IMPLICIT NONE
+    
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var
+    INTEGER,INTENT(IN) :: nb
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) RETURN
+    
+#ifdef CPP_MPI
+    CALL MPI_BCAST(Var,nb,MPI_CHARACTER,mpi_root_x,COMM_LMDZ_PHY,ierr)
+#endif
+        
+  END SUBROUTINE bcast_mpi_cgen
+
+
+      
+  SUBROUTINE bcast_mpi_igen(var,nb)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    IMPLICIT NONE
+    
+    INTEGER,DIMENSION(nb),INTENT(INOUT) :: Var
+    INTEGER,INTENT(IN) :: nb
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) RETURN
+
+#ifdef CPP_MPI
+    CALL MPI_BCAST(Var,nb,MPI_INTEGER,mpi_root_x,COMM_LMDZ_PHY,ierr)
+#endif
+        
+  END SUBROUTINE bcast_mpi_igen
+
+
+
+  
+  SUBROUTINE bcast_mpi_rgen(var,nb)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    IMPLICIT NONE
+    
+    REAL,DIMENSION(nb),INTENT(INOUT) :: Var
+    INTEGER,INTENT(IN) :: nb
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) RETURN
+
+#ifdef CPP_MPI
+    CALL MPI_BCAST(Var,nb,MPI_REAL_LMDZ,mpi_root_x,COMM_LMDZ_PHY,ierr)
+#endif
+    
+  END SUBROUTINE bcast_mpi_rgen
+  
+
+
+
+  SUBROUTINE bcast_mpi_lgen(var,nb)
+    USE mod_phys_lmdz_mpi_data ,  mpi_root_x=>mpi_root
+    IMPLICIT NONE
+    
+    LOGICAL,DIMENSION(nb),INTENT(INOUT) :: Var
+    INTEGER,INTENT(IN) :: nb
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) RETURN
+
+#ifdef CPP_MPI
+    CALL MPI_BCAST(Var,nb,MPI_LOGICAL,mpi_root_x,COMM_LMDZ_PHY,ierr)
+#endif
+
+  END SUBROUTINE bcast_mpi_lgen
+
+  
+
+  SUBROUTINE scatter_mpi_igen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    INTEGER,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+
+    
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+        DO i=1,dimsize
+          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
+          Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+      
+#ifdef CPP_MPI 
+    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_INTEGER,VarOut,klon_mpi*dimsize,   &
+                      MPI_INTEGER,mpi_root_x, COMM_LMDZ_PHY,ierr)
+#endif
+
+  END SUBROUTINE scatter_mpi_igen
+
+  SUBROUTINE scatter_mpi_rgen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    REAL,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+    
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+        DO i=1,dimsize
+          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
+          Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+      
+#ifdef CPP_MPI 
+    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_REAL_LMDZ,VarOut,klon_mpi*dimsize,   &
+                      MPI_REAL_LMDZ,mpi_root_x, COMM_LMDZ_PHY,ierr)
+
+#endif
+
+  END SUBROUTINE scatter_mpi_rgen
+
+  
+  SUBROUTINE scatter_mpi_lgen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    LOGICAL,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+    
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+        DO i=1,dimsize
+          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
+          Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+      
+#ifdef CPP_MPI
+    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_LOGICAL,VarOut,klon_mpi*dimsize,   &
+                      MPI_LOGICAL,mpi_root_x, COMM_LMDZ_PHY,ierr)
+#endif
+
+  END SUBROUTINE scatter_mpi_lgen  
+
+
+
+
+  SUBROUTINE gather_mpi_igen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
+  
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    INTEGER,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+	Index=Index+nb*dimsize
+      ENDDO
+     
+    ENDIF
+    
+#ifdef CPP_MPI
+    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_INTEGER,VarTmp,counts,displs,   &
+                     MPI_INTEGER,mpi_root_x, COMM_LMDZ_PHY,ierr)
+#endif
+
+		          
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        DO i=1,dimsize
+          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
+	  Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+
+  END SUBROUTINE gather_mpi_igen  
+
+  SUBROUTINE gather_mpi_rgen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
+  
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    REAL,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+	Index=Index+nb*dimsize
+      ENDDO
+    ENDIF
+    
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+
+#ifdef CPP_MPI
+    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_REAL_LMDZ,VarTmp,counts,displs,   &
+                      MPI_REAL_LMDZ,mpi_root_x, COMM_LMDZ_PHY,ierr)
+#endif
+		          
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        DO i=1,dimsize
+          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
+	  Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+
+  END SUBROUTINE gather_mpi_rgen  
+
+  SUBROUTINE gather_mpi_lgen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    LOGICAL,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+    
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+	Index=Index+nb*dimsize
+      ENDDO
+    ENDIF
+    
+
+#ifdef CPP_MPI
+    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_LOGICAL,VarTmp,counts,displs,   &
+                      MPI_LOGICAL,mpi_root_x, COMM_LMDZ_PHY,ierr)
+#endif
+		          
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        DO i=1,dimsize
+          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
+	  Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+
+  END SUBROUTINE gather_mpi_lgen
+  
+
+
+  SUBROUTINE reduce_sum_mpi_igen(VarIn,VarOut,nb)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+   
+    INTEGER,DIMENSION(nb),INTENT(IN) :: VarIn
+    INTEGER,DIMENSION(nb),INTENT(OUT) :: VarOut    
+    INTEGER,INTENT(IN) :: nb
+    INTEGER :: ierr
+   
+    IF (.not.is_using_mpi) THEN
+      VarOut(:)=VarIn(:)
+      RETURN
+    ENDIF
+
+
+#ifdef CPP_MPI
+    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_INTEGER,MPI_SUM,mpi_root_x,COMM_LMDZ_PHY,ierr)
+#endif
+            
+  END SUBROUTINE reduce_sum_mpi_igen
+  
+  SUBROUTINE reduce_sum_mpi_rgen(VarIn,VarOut,nb)
+    USE mod_phys_lmdz_mpi_data , mpi_root_x=>mpi_root
+    USE mod_grid_phy_lmdz
+
+    IMPLICIT NONE
+
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    
+    REAL,DIMENSION(nb),INTENT(IN) :: VarIn
+    REAL,DIMENSION(nb),INTENT(OUT) :: VarOut    
+    INTEGER,INTENT(IN) :: nb
+    INTEGER :: ierr
+ 
+    IF (.not.is_using_mpi) THEN
+      VarOut(:)=VarIn(:)
+      RETURN
+    ENDIF
+   
+#ifdef CPP_MPI
+    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_REAL_LMDZ,MPI_SUM,mpi_root_x,COMM_LMDZ_PHY,ierr)
+#endif
+        
+  END SUBROUTINE reduce_sum_mpi_rgen
+
+
+
+  SUBROUTINE grid1dTo2d_mpi_igen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
+    INTEGER :: i,ij,Offset
+
+    
+    VarOut(1:nbp_lon,:)=0
+    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=0
+    
+    offset=ii_begin
+    IF (is_north_pole) Offset=nbp_lon
+    
+    
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij+offset-1,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+    
+    
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        DO ij=1,nbp_lon
+         VarOut(ij,i)=VarIn(1,i)
+	ENDDO
+      ENDDO
+    ENDIF
+    
+    IF (is_south_pole) THEN 
+      DO i=1,dimsize
+        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
+         VarOut(ij,i)=VarIn(klon_mpi,i)
+	ENDDO
+      ENDDO
+    ENDIF
+
+  END SUBROUTINE grid1dTo2d_mpi_igen   
+
+
+  SUBROUTINE grid1dTo2d_mpi_rgen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
+    REAL,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
+    INTEGER :: i,ij,Offset
+
+    
+    VarOut(1:nbp_lon,:)=0
+    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=0
+    
+    offset=ii_begin
+    IF (is_north_pole) Offset=nbp_lon
+    
+    
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij+offset-1,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+    
+    
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        DO ij=1,nbp_lon
+         VarOut(ij,i)=VarIn(1,i)
+	ENDDO
+      ENDDO
+    ENDIF
+    
+    IF (is_south_pole) THEN 
+      DO i=1,dimsize
+        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
+         VarOut(ij,i)=VarIn(klon_mpi,i)
+	ENDDO
+      ENDDO
+    ENDIF
+
+   END SUBROUTINE grid1dTo2d_mpi_rgen   
+
+
+
+  SUBROUTINE grid1dTo2d_mpi_lgen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
+    INTEGER :: i,ij,Offset
+
+    
+    VarOut(1:nbp_lon,:)=.FALSE.
+    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=.FALSE.
+    
+    offset=ii_begin
+    IF (is_north_pole) Offset=nbp_lon
+    
+    
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij+offset-1,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+    
+    
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        DO ij=1,nbp_lon
+         VarOut(ij,i)=VarIn(1,i)
+	ENDDO
+      ENDDO
+    ENDIF
+    
+    IF (is_south_pole) THEN 
+      DO i=1,dimsize
+        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
+         VarOut(ij,i)=VarIn(klon_mpi,i)
+	ENDDO
+      ENDDO
+    ENDIF
+
+   END SUBROUTINE grid1dTo2d_mpi_lgen   
+
+  
+
+
+  SUBROUTINE grid2dTo1d_mpi_igen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
+    INTEGER :: i,ij,offset
+
+    offset=ii_begin
+    IF (is_north_pole) offset=nbp_lon
+
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=VarIn(ij+offset-1,i)
+      ENDDO
+    ENDDO
+
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        VarOut(1,i)=VarIn(1,i)
+      ENDDO
+    ENDIF
+    
+    
+  END SUBROUTINE grid2dTo1d_mpi_igen   
+
+
+
+  SUBROUTINE grid2dTo1d_mpi_rgen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
+    INTEGER :: i,ij,offset
+
+    offset=ii_begin
+    IF (is_north_pole) offset=nbp_lon
+
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=VarIn(ij+offset-1,i)
+      ENDDO
+    ENDDO
+
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+         VarOut(1,i)=VarIn(1,i)
+      ENDDO
+    ENDIF
+    
+    
+  END SUBROUTINE grid2dTo1d_mpi_rgen   
+  
+
+  SUBROUTINE grid2dTo1d_mpi_lgen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
+    INTEGER :: i,ij,offset
+
+    offset=ii_begin
+    IF (is_north_pole) offset=nbp_lon
+
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=VarIn(ij+offset-1,i)
+      ENDDO
+    ENDDO
+
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        VarOut(1,i)=VarIn(1,i)
+      ENDDO
+    ENDIF
+    
+    
+  END SUBROUTINE grid2dTo1d_mpi_lgen   
+
+END MODULE mod_phys_lmdz_mpi_transfert
Index: trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_omp_data.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_omp_data.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_omp_data.F90	(revision 892)
@@ -0,0 +1,109 @@
+!
+!$Id: mod_phys_lmdz_omp_data.F90 1575 2011-09-21 13:57:48Z jghattas $
+!
+MODULE mod_phys_lmdz_omp_data
+
+  INTEGER,SAVE :: omp_size
+  INTEGER,SAVE :: omp_rank
+  LOGICAL,SAVE :: is_omp_root
+  LOGICAL,SAVE :: is_using_omp
+  
+  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_nb
+  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_begin
+  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_end    
+  
+  INTEGER,SAVE :: klon_omp
+  INTEGER,SAVE :: klon_omp_begin
+  INTEGER,SAVE :: klon_omp_end
+!$OMP  THREADPRIVATE(omp_rank,klon_omp,is_omp_root,klon_omp_begin,klon_omp_end)
+
+CONTAINS
+  
+  SUBROUTINE init_phys_lmdz_omp_data(klon_mpi)
+    USE dimphy
+    IMPLICIT NONE
+    INTEGER, INTENT(in) :: klon_mpi
+
+    INTEGER :: i
+
+    CHARACTER (LEN=20) :: modname='Init_phys_lmdz_omp_data'
+    CHARACTER (LEN=80) :: abort_message
+
+
+#ifdef CPP_OMP    
+    INTEGER :: OMP_GET_NUM_THREADS
+    EXTERNAL OMP_GET_NUM_THREADS
+    INTEGER :: OMP_GET_THREAD_NUM
+    EXTERNAL OMP_GET_THREAD_NUM
+#endif  
+
+#ifdef CPP_OMP
+!$OMP MASTER
+        is_using_omp=.TRUE.
+        omp_size=OMP_GET_NUM_THREADS()
+!$OMP END MASTER
+        omp_rank=OMP_GET_THREAD_NUM()    
+#else    
+    is_using_omp=.FALSE.
+    omp_size=1
+    omp_rank=0
+#endif
+
+   is_omp_root=.FALSE.
+!$OMP MASTER
+   IF (omp_rank==0) THEN
+     is_omp_root=.TRUE.
+   ELSE
+     abort_message = 'ANORMAL : OMP_MASTER /= 0'
+     CALL abort_gcm (modname,abort_message,1)
+   ENDIF
+!$OMP END MASTER
+
+
+!$OMP MASTER 
+    ALLOCATE(klon_omp_para_nb(0:omp_size-1))
+    ALLOCATE(klon_omp_para_begin(0:omp_size-1))
+    ALLOCATE(klon_omp_para_end(0:omp_size-1))
+    
+    DO i=0,omp_size-1
+      klon_omp_para_nb(i)=klon_mpi/omp_size
+      IF (i<MOD(klon_mpi,omp_size)) klon_omp_para_nb(i)=klon_omp_para_nb(i)+1
+    ENDDO
+    
+    klon_omp_para_begin(0) = 1
+    klon_omp_para_end(0) = klon_omp_para_nb(0)
+    
+    DO i=1,omp_size-1
+      klon_omp_para_begin(i)=klon_omp_para_end(i-1)+1
+      klon_omp_para_end(i)=klon_omp_para_begin(i)+klon_omp_para_nb(i)-1
+    ENDDO
+!$OMP END MASTER
+!$OMP BARRIER
+   
+    klon_omp=klon_omp_para_nb(omp_rank)
+    klon_omp_begin=klon_omp_para_begin(omp_rank)
+    klon_omp_end=klon_omp_para_end(omp_rank)
+    
+    CALL print_module_data
+    
+  END SUBROUTINE init_phys_lmdz_omp_data
+
+  SUBROUTINE print_module_data
+  IMPLICIT NONE
+  INCLUDE "iniprint.h"
+
+!$OMP CRITICAL  
+  WRITE(lunout,*)'--------> TASK ',omp_rank
+  WRITE(lunout,*)'omp_size =',omp_size
+  WRITE(lunout,*)'omp_rank =',omp_rank
+  WRITE(lunout,*)'is_omp_root =',is_omp_root
+  WRITE(lunout,*)'klon_omp_para_nb =',klon_omp_para_nb
+  WRITE(lunout,*)'klon_omp_para_begin =',klon_omp_para_begin
+  WRITE(lunout,*)'klon_omp_para_end =',klon_omp_para_end    
+  WRITE(lunout,*)'klon_omp =',klon_omp
+  WRITE(lunout,*)'klon_omp_begin =',klon_omp_begin
+  WRITE(lunout,*)'klon_omp_end =',klon_omp_end    
+!$OMP END CRITICAL
+
+  END SUBROUTINE print_module_data
+END MODULE mod_phys_lmdz_omp_data
Index: trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_omp_transfert.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_omp_transfert.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_omp_transfert.F90	(revision 892)
@@ -0,0 +1,1057 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_omp_transfert
+
+  PRIVATE
+  
+  INTEGER,PARAMETER :: grow_factor=1.5
+  INTEGER,PARAMETER :: size_min=1024
+  
+  CHARACTER(LEN=size_min),SAVE            :: buffer_c
+!  INTEGER,SAVE                            :: size_c=0
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:)   :: buffer_i
+  INTEGER,SAVE                            :: size_i=0
+  REAL,SAVE,ALLOCATABLE,DIMENSION(:)      :: buffer_r
+  INTEGER,SAVE                            :: size_r=0
+  LOGICAL,SAVE,ALLOCATABLE,DIMENSION(:)   :: buffer_l
+  INTEGER,SAVE                            :: size_l=0
+
+
+  
+  
+  INTERFACE bcast_omp
+    MODULE PROCEDURE bcast_omp_c,                                                     &
+                     bcast_omp_i,bcast_omp_i1,bcast_omp_i2,bcast_omp_i3,bcast_omp_i4, &
+                     bcast_omp_r,bcast_omp_r1,bcast_omp_r2,bcast_omp_r3,bcast_omp_r4, &
+		     bcast_omp_l,bcast_omp_l1,bcast_omp_l2,bcast_omp_l3,bcast_omp_l4
+  END INTERFACE
+
+  INTERFACE scatter_omp
+    MODULE PROCEDURE scatter_omp_i,scatter_omp_i1,scatter_omp_i2,scatter_omp_i3, &
+                     scatter_omp_r,scatter_omp_r1,scatter_omp_r2,scatter_omp_r3, &
+		     scatter_omp_l,scatter_omp_l1,scatter_omp_l2,scatter_omp_l3
+  END INTERFACE
+
+  
+  INTERFACE gather_omp
+    MODULE PROCEDURE gather_omp_i,gather_omp_i1,gather_omp_i2,gather_omp_i3, &
+                     gather_omp_r,gather_omp_r1,gather_omp_r2,gather_omp_r3, &
+		     gather_omp_l,gather_omp_l1,gather_omp_l2,gather_omp_l3  
+  END INTERFACE
+  
+  
+  INTERFACE reduce_sum_omp
+    MODULE PROCEDURE reduce_sum_omp_i,reduce_sum_omp_i1,reduce_sum_omp_i2,reduce_sum_omp_i3,reduce_sum_omp_i4, &
+                     reduce_sum_omp_r,reduce_sum_omp_r1,reduce_sum_omp_r2,reduce_sum_omp_r3,reduce_sum_omp_r4
+  END INTERFACE 
+
+
+  PUBLIC bcast_omp,scatter_omp,gather_omp,reduce_sum_omp
+
+CONTAINS
+
+  SUBROUTINE check_buffer_i(buff_size)
+  IMPLICIT NONE
+  INTEGER :: buff_size
+
+!$OMP BARRIER
+!$OMP MASTER
+    IF (buff_size>size_i) THEN
+      IF (ALLOCATED(buffer_i)) DEALLOCATE(buffer_i)
+      size_i=MAX(size_min,INT(grow_factor*buff_size))
+      ALLOCATE(buffer_i(size_i))
+    ENDIF
+!$OMP END MASTER
+!$OMP BARRIER
+  
+  END SUBROUTINE check_buffer_i
+  
+  SUBROUTINE check_buffer_r(buff_size)
+  IMPLICIT NONE
+  INTEGER :: buff_size
+
+!$OMP BARRIER
+!$OMP MASTER
+    IF (buff_size>size_r) THEN
+      IF (ALLOCATED(buffer_r)) DEALLOCATE(buffer_r)
+      size_r=MAX(size_min,INT(grow_factor*buff_size))
+      ALLOCATE(buffer_r(size_r))
+    ENDIF
+!$OMP END MASTER
+!$OMP BARRIER
+  
+  END SUBROUTINE check_buffer_r
+  
+  SUBROUTINE check_buffer_l(buff_size)
+  IMPLICIT NONE
+  INTEGER :: buff_size
+
+!$OMP BARRIER
+!$OMP MASTER
+    IF (buff_size>size_l) THEN
+      IF (ALLOCATED(buffer_l)) DEALLOCATE(buffer_l)
+      size_l=MAX(size_min,INT(grow_factor*buff_size))
+      ALLOCATE(buffer_l(size_l))
+    ENDIF
+!$OMP END MASTER
+!$OMP BARRIER
+  
+  END SUBROUTINE check_buffer_l
+    
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Broadcast --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!! -- Les chaine de charactère -- !!
+
+  SUBROUTINE bcast_omp_c(var)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var
+    
+    CALL bcast_omp_cgen(Var,len(Var),buffer_c)
+    
+  END SUBROUTINE bcast_omp_c
+
+!! -- Les entiers -- !!
+  
+  SUBROUTINE bcast_omp_i(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var
+    INTEGER :: Var_tmp(1)
+    
+    Var_tmp(1)=Var
+    CALL check_buffer_i(1)
+    CALL bcast_omp_igen(Var_tmp,1,buffer_i)
+    Var=Var_tmp(1)
+
+  END SUBROUTINE bcast_omp_i
+
+
+  SUBROUTINE bcast_omp_i1(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:)
+   
+    CALL check_buffer_i(size(Var))
+    CALL bcast_omp_igen(Var,size(Var),buffer_i)
+
+  END SUBROUTINE bcast_omp_i1
+
+
+  SUBROUTINE bcast_omp_i2(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:)
+   
+    CALL check_buffer_i(size(Var))
+    CALL bcast_omp_igen(Var,size(Var),buffer_i)
+
+  END SUBROUTINE bcast_omp_i2
+
+
+  SUBROUTINE bcast_omp_i3(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:)
+
+    CALL check_buffer_i(size(Var))
+    CALL bcast_omp_igen(Var,size(Var),buffer_i)
+
+  END SUBROUTINE bcast_omp_i3
+
+
+  SUBROUTINE bcast_omp_i4(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL check_buffer_i(size(Var))
+    CALL bcast_omp_igen(Var,size(Var),buffer_i)
+
+  END SUBROUTINE bcast_omp_i4
+
+
+!! -- Les reels -- !!
+
+  SUBROUTINE bcast_omp_r(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var
+    REAL :: Var_tmp(1)
+    
+    Var_tmp(1)=Var
+    CALL check_buffer_r(1)
+    CALL bcast_omp_rgen(Var_tmp,1,buffer_r)
+    Var=Var_tmp(1)
+
+  END SUBROUTINE bcast_omp_r
+
+
+  SUBROUTINE bcast_omp_r1(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:)
+   
+    CALL check_buffer_r(size(Var))
+    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
+
+  END SUBROUTINE bcast_omp_r1
+
+
+  SUBROUTINE bcast_omp_r2(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:)
+   
+    CALL check_buffer_r(size(Var))
+    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
+
+  END SUBROUTINE bcast_omp_r2
+
+
+  SUBROUTINE bcast_omp_r3(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:)
+
+    CALL check_buffer_r(size(Var))
+    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
+
+  END SUBROUTINE bcast_omp_r3
+
+
+  SUBROUTINE bcast_omp_r4(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL check_buffer_r(size(Var))
+    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
+
+  END SUBROUTINE bcast_omp_r4
+
+  
+!! -- Les booleans -- !!
+
+  SUBROUTINE bcast_omp_l(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var
+    LOGICAL :: Var_tmp(1)
+    
+    Var_tmp(1)=Var
+    CALL check_buffer_l(1)
+    CALL bcast_omp_lgen(Var_tmp,1,buffer_l)
+    Var=Var_tmp(1)
+
+  END SUBROUTINE bcast_omp_l
+
+
+  SUBROUTINE bcast_omp_l1(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:)
+   
+    CALL check_buffer_l(size(Var))
+    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
+
+  END SUBROUTINE bcast_omp_l1
+
+
+  SUBROUTINE bcast_omp_l2(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:)
+   
+    CALL check_buffer_l(size(Var))
+    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
+
+  END SUBROUTINE bcast_omp_l2
+
+
+  SUBROUTINE bcast_omp_l3(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:)
+
+    CALL check_buffer_l(size(Var))
+    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
+
+  END SUBROUTINE bcast_omp_l3
+
+
+  SUBROUTINE bcast_omp_l4(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL check_buffer_l(size(Var))
+    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
+
+  END SUBROUTINE bcast_omp_l4
+
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE scatter_omp_i(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_i(size(VarIn))   
+    CALL scatter_omp_igen(VarIn,Varout,1,buffer_i)
+    
+  END SUBROUTINE scatter_omp_i
+
+
+  SUBROUTINE scatter_omp_i1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    CALL Check_buffer_i(size(VarIn))   
+    CALL scatter_omp_igen(VarIn,Varout,Size(VarOut,2),buffer_i)
+    
+  END SUBROUTINE scatter_omp_i1
+  
+  
+  SUBROUTINE scatter_omp_i2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarIn))   
+    CALL scatter_omp_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3),buffer_i)
+
+  END SUBROUTINE scatter_omp_i2
+
+
+  SUBROUTINE scatter_omp_i3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarIn))   
+    CALL scatter_omp_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4),buffer_i)
+  
+  END SUBROUTINE scatter_omp_i3
+
+
+
+
+  SUBROUTINE scatter_omp_r(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_r(size(VarIn))   
+    CALL scatter_omp_rgen(VarIn,Varout,1,buffer_r)
+    
+  END SUBROUTINE scatter_omp_r
+
+
+  SUBROUTINE scatter_omp_r1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL scatter_omp_rgen(VarIn,Varout,Size(VarOut,2),buffer_r)
+        
+  END SUBROUTINE scatter_omp_r1
+  
+  
+  SUBROUTINE scatter_omp_r2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL scatter_omp_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3),buffer_r)
+
+  END SUBROUTINE scatter_omp_r2
+
+
+  SUBROUTINE scatter_omp_r3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL scatter_omp_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4),buffer_r)
+  
+  END SUBROUTINE scatter_omp_r3
+  
+
+
+  SUBROUTINE scatter_omp_l(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_l(size(VarIn))   
+    CALL scatter_omp_lgen(VarIn,Varout,1,buffer_l)
+    
+  END SUBROUTINE scatter_omp_l
+
+
+  SUBROUTINE scatter_omp_l1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarIn))   
+    CALL scatter_omp_lgen(VarIn,Varout,Size(VarOut,2),buffer_l)
+    
+  END SUBROUTINE scatter_omp_l1
+  
+  
+  SUBROUTINE scatter_omp_l2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarIn))   
+    CALL scatter_omp_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3),buffer_l)
+
+  END SUBROUTINE scatter_omp_l2
+
+
+  SUBROUTINE scatter_omp_l3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarIn))   
+    CALL scatter_omp_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4),buffer_l)
+  
+  END SUBROUTINE scatter_omp_l3  
+  
+
+  SUBROUTINE gather_omp_i(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_i(size(VarOut))   
+    CALL gather_omp_igen(VarIn,Varout,1,buffer_i)
+    
+  END SUBROUTINE gather_omp_i
+
+
+  SUBROUTINE gather_omp_i1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarOut))   
+    CALL gather_omp_igen(VarIn,Varout,Size(VarIn,2),buffer_i)
+    
+  END SUBROUTINE gather_omp_i1
+
+
+  SUBROUTINE gather_omp_i2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarOut))   
+    CALL gather_omp_igen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_i)
+          
+  END SUBROUTINE gather_omp_i2
+  
+
+  SUBROUTINE gather_omp_i3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarOut))   
+    CALL gather_omp_igen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_i)
+    
+  END SUBROUTINE gather_omp_i3
+
+
+
+  SUBROUTINE gather_omp_r(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_r(size(VarOut))   
+    CALL gather_omp_rgen(VarIn,Varout,1,buffer_r)
+    
+  END SUBROUTINE gather_omp_r
+
+
+  SUBROUTINE gather_omp_r1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    CALL Check_buffer_r(size(VarOut))   
+    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2),buffer_r)
+        
+  END SUBROUTINE gather_omp_r1
+
+
+  SUBROUTINE gather_omp_r2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarOut))   
+    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_r)
+    
+  END SUBROUTINE gather_omp_r2
+  
+
+  SUBROUTINE gather_omp_r3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    CALL Check_buffer_r(size(VarOut))       
+    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_r)
+    
+  END SUBROUTINE gather_omp_r3
+
+
+  SUBROUTINE gather_omp_l(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_l(size(VarOut))   
+    CALL gather_omp_lgen(VarIn,Varout,1,buffer_l)
+    
+  END SUBROUTINE gather_omp_l
+
+
+  SUBROUTINE gather_omp_l1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarOut))   
+    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2),buffer_l)
+    
+  END SUBROUTINE gather_omp_l1
+
+
+  SUBROUTINE gather_omp_l2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarOut))   
+    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_l)
+    
+  END SUBROUTINE gather_omp_l2
+  
+
+  SUBROUTINE gather_omp_l3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarOut))   
+    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_l)
+    
+  END SUBROUTINE gather_omp_l3
+
+
+
+
+  SUBROUTINE reduce_sum_omp_i(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN)  :: VarIn
+    INTEGER,INTENT(OUT) :: VarOut
+    INTEGER             :: VarIn_tmp(1)
+    INTEGER             :: VarOut_tmp(1)
+    
+    VarIn_tmp(1)=VarIn
+    CALL Check_buffer_i(1)   
+    CALL reduce_sum_omp_igen(VarIn_tmp,Varout_tmp,1,buffer_i)
+    VarOut=VarOut_tmp(1)
+    
+  END SUBROUTINE reduce_sum_omp_i
+
+  SUBROUTINE reduce_sum_omp_i1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarIn))   
+    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
+   
+  END SUBROUTINE reduce_sum_omp_i1
+  
+  
+  SUBROUTINE reduce_sum_omp_i2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    CALL Check_buffer_i(size(VarIn))   
+    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
+  
+  END SUBROUTINE reduce_sum_omp_i2
+
+
+  SUBROUTINE reduce_sum_omp_i3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarIn))   
+    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
+  
+  END SUBROUTINE reduce_sum_omp_i3
+
+
+  SUBROUTINE reduce_sum_omp_i4(VarIn, VarOut)
+    IMPLICIT NONE
+
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+  
+    CALL Check_buffer_i(size(VarIn))   
+    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
+  
+  END SUBROUTINE reduce_sum_omp_i4
+
+
+  SUBROUTINE reduce_sum_omp_r(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN)  :: VarIn
+    REAL,INTENT(OUT) :: VarOut
+    REAL             :: VarIn_tmp(1)
+    REAL             :: VarOut_tmp(1)
+    
+    VarIn_tmp(1)=VarIn
+    CALL Check_buffer_r(1)   
+    CALL reduce_sum_omp_rgen(VarIn_tmp,Varout_tmp,1,buffer_r)
+    VarOut=VarOut_tmp(1)
+  
+  END SUBROUTINE reduce_sum_omp_r
+
+  SUBROUTINE reduce_sum_omp_r1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
+   
+  END SUBROUTINE reduce_sum_omp_r1
+  
+  
+  SUBROUTINE reduce_sum_omp_r2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
+  
+  END SUBROUTINE reduce_sum_omp_r2
+
+
+  SUBROUTINE reduce_sum_omp_r3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
+  
+  END SUBROUTINE reduce_sum_omp_r3
+
+
+  SUBROUTINE reduce_sum_omp_r4(VarIn, VarOut)
+    IMPLICIT NONE
+
+    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+  
+    CALL Check_buffer_r(size(VarIn))   
+    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
+  
+  END SUBROUTINE reduce_sum_omp_r4
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!    LES ROUTINES GENERIQUES    !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE bcast_omp_cgen(Var,Nb,Buff)
+  IMPLICIT NONE
+    
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var
+    CHARACTER(LEN=*),INTENT(INOUT) :: Buff
+    INTEGER,INTENT(IN) :: Nb
+    
+    INTEGER :: i
+  
+  !$OMP MASTER
+      Buff=Var
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,Nb
+      Var=Buff
+    ENDDO
+  !$OMP BARRIER      
+  
+  END SUBROUTINE bcast_omp_cgen
+
+
+      
+  SUBROUTINE bcast_omp_igen(Var,Nb,Buff)
+  IMPLICIT NONE
+    
+    INTEGER,DIMENSION(Nb),INTENT(INOUT) :: Var
+    INTEGER,DIMENSION(Nb),INTENT(INOUT) :: Buff
+    INTEGER,INTENT(IN) :: Nb
+
+    INTEGER :: i
+    
+  !$OMP MASTER
+    DO i=1,Nb
+      Buff(i)=Var(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,Nb
+      Var(i)=Buff(i)
+    ENDDO
+  !$OMP BARRIER        
+
+  END SUBROUTINE bcast_omp_igen
+
+
+  SUBROUTINE bcast_omp_rgen(Var,Nb,Buff)
+  IMPLICIT NONE
+    
+    REAL,DIMENSION(Nb),INTENT(INOUT) :: Var
+    REAL,DIMENSION(Nb),INTENT(INOUT) :: Buff
+    INTEGER,INTENT(IN) :: Nb
+
+    INTEGER :: i
+    
+  !$OMP MASTER
+    DO i=1,Nb
+      Buff(i)=Var(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,Nb
+      Var(i)=Buff(i)
+    ENDDO
+  !$OMP BARRIER        
+
+  END SUBROUTINE bcast_omp_rgen
+
+  SUBROUTINE bcast_omp_lgen(Var,Nb,Buff)
+  IMPLICIT NONE
+    
+    LOGICAL,DIMENSION(Nb),INTENT(INOUT) :: Var
+    LOGICAL,DIMENSION(Nb),INTENT(INOUT) :: Buff
+    INTEGER,INTENT(IN) :: Nb
+  
+    INTEGER :: i
+    
+  !$OMP MASTER
+    DO i=1,Nb
+      Buff(i)=Var(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,Nb
+      Var(i)=Buff(i)
+    ENDDO
+  !$OMP BARRIER        
+
+  END SUBROUTINE bcast_omp_lgen
+
+
+  SUBROUTINE scatter_omp_igen(VarIn,VarOut,dimsize,Buff)
+    USE mod_phys_lmdz_omp_data
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+    IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
+    INTEGER,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        Buff(ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+ 
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+ 
+  END SUBROUTINE scatter_omp_igen
+
+
+  SUBROUTINE scatter_omp_rgen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
+    REAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        Buff(ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+
+  END SUBROUTINE scatter_omp_rgen
+
+
+  SUBROUTINE scatter_omp_lgen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
+    LOGICAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+ !$OMP MASTER 
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        Buff(ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+
+  END SUBROUTINE scatter_omp_lgen
+
+
+
+
+
+  SUBROUTINE gather_omp_igen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+    INTEGER,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+  
+  
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=Buff(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+  END SUBROUTINE gather_omp_igen
+
+
+  SUBROUTINE gather_omp_rgen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+    REAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+
+
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=Buff(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+  END SUBROUTINE gather_omp_rgen
+
+
+  SUBROUTINE gather_omp_lgen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+    LOGICAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+
+
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=Buff(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+  END SUBROUTINE gather_omp_lgen
+
+
+  SUBROUTINE reduce_sum_omp_igen(VarIn,VarOut,dimsize,Buff)
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(dimsize) :: VarOut
+    INTEGER,INTENT(INOUT),DIMENSION(dimsize) :: Buff
+
+    INTEGER :: i
+
+  !$OMP MASTER
+    Buff(:)=0
+  !$OMP END MASTER
+  !$OMP BARRIER
+  
+  !$OMP CRITICAL     
+    DO i=1,dimsize
+      Buff(i)=Buff(i)+VarIn(i)
+    ENDDO
+  !$OMP END CRITICAL
+  !$OMP BARRIER  
+  
+  !$OMP MASTER
+    DO i=1,dimsize
+      VarOut(i)=Buff(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+  
+  END SUBROUTINE reduce_sum_omp_igen
+
+  SUBROUTINE reduce_sum_omp_rgen(VarIn,VarOut,dimsize,Buff)
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(dimsize) :: VarOut
+    REAL,INTENT(INOUT),DIMENSION(dimsize) :: Buff
+
+    INTEGER :: i
+
+  !$OMP MASTER
+    Buff(:)=0
+  !$OMP END MASTER
+  !$OMP BARRIER
+  
+  !$OMP CRITICAL     
+    DO i=1,dimsize
+      Buff(i)=Buff(i)+VarIn(i)
+    ENDDO
+  !$OMP END CRITICAL
+  !$OMP BARRIER  
+  
+  !$OMP MASTER
+    DO i=1,dimsize
+      VarOut(i)=Buff(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+  
+  END SUBROUTINE reduce_sum_omp_rgen
+
+END MODULE mod_phys_lmdz_omp_transfert
Index: trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_para.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_para.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_para.F90	(revision 892)
@@ -0,0 +1,113 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_para
+  USE mod_phys_lmdz_transfert_para
+  USE mod_phys_lmdz_mpi_data
+  USE mod_phys_lmdz_omp_data
+    
+  INTEGER,SAVE :: klon_loc
+  LOGICAL,SAVE :: is_sequential
+  LOGICAL,SAVE :: is_parallel
+  LOGICAL,SAVE :: is_master
+  
+!$OMP THREADPRIVATE(klon_loc,is_master)
+  
+CONTAINS
+
+  SUBROUTINE init_phys_lmdz_para(iim,jjp1,nb_proc,distrib)
+  IMPLICIT NONE
+    INTEGER,INTENT(in) :: iim
+    INTEGER,INTENT(in) :: jjp1
+    INTEGER,INTENT(in) :: nb_proc
+    INTEGER,INTENT(in) :: distrib(0:nb_proc-1)
+
+    CALL init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib)
+!$OMP PARALLEL
+    CALL init_phys_lmdz_omp_data(klon_mpi)
+    klon_loc=klon_omp
+    IF (is_mpi_root .AND. is_omp_root) THEN 
+       is_master=.TRUE.
+     ELSE
+       is_master=.FALSE.
+     ENDIF
+    CALL test_transfert
+!$OMP END PARALLEL    
+     IF (is_using_mpi .OR. is_using_omp) THEN
+       is_sequential=.FALSE.
+       is_parallel=.TRUE.
+     ELSE
+       is_sequential=.TRUE.
+       is_parallel=.FALSE.
+     ENDIF
+      
+  END SUBROUTINE init_phys_lmdz_para
+
+  SUBROUTINE test_transfert
+  USE mod_grid_phy_lmdz
+  IMPLICIT NONE
+    INCLUDE "iniprint.h"
+ 
+    REAL :: Test_Field1d_glo(klon_glo,nbp_lev)
+    REAL :: tmp1d_glo(klon_glo,nbp_lev)
+    REAL :: Test_Field2d_glo(nbp_lon,nbp_lat,nbp_lev)
+    REAL :: tmp2d_glo(nbp_lon,nbp_lat,nbp_lev)
+    REAL :: Test_Field1d_loc(klon_loc,nbp_lev)
+    REAL :: Test_Field2d_loc(nbp_lon,jj_nb,nbp_lev)
+    REAL :: CheckSum
+    
+    INTEGER :: i,l
+  
+    Test_Field1d_glo = 0.
+    Test_Field2d_glo = 0.
+    Test_Field1d_loc = 0.
+    Test_Field2d_loc = 0.
+  
+    IF (is_mpi_root) THEN
+!$OMP MASTER
+      DO l=1,nbp_lev
+        DO i=1,klon_glo
+!          Test_Field1d_glo(i,l)=MOD(i,10)+10*(l-1)
+           Test_Field1d_glo(i,l)=1
+        ENDDO
+      ENDDO
+!$OMP END MASTER  
+    ENDIF
+  
+    CALL Scatter(Test_Field1d_glo,Test_Field1d_loc)
+    CALL Gather(Test_Field1d_loc,tmp1d_glo)
+  
+    IF (is_mpi_root) THEN
+!$OMP MASTER  
+      Checksum=sum(Test_Field1d_glo-tmp1d_glo)
+      WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0"
+!$OMP END MASTER
+    ENDIF
+    
+    CALL grid1dTo2d_glo(Test_Field1d_glo,Test_Field2d_glo)
+    CALL scatter2D(Test_Field2d_glo,Test_Field1d_loc)
+    CALL gather2d(Test_Field1d_loc,Test_Field2d_glo)
+    CALL grid2dTo1d_glo(Test_Field2d_glo,tmp1d_glo)
+
+    IF (is_mpi_root) THEN
+!$OMP MASTER  
+      Checksum=sum(Test_Field1d_glo-tmp1d_glo)
+      WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0"
+!$OMP END MASTER
+    ENDIF
+
+    CALL bcast(Test_Field1d_glo)
+    CALL reduce_sum(Test_Field1d_glo,tmp1d_glo)
+
+    IF (is_mpi_root) THEN
+!$OMP MASTER  
+      Checksum=sum(Test_Field1d_glo*omp_size*mpi_size-tmp1d_glo)
+      WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0"
+!$OMP END MASTER
+    ENDIF
+    
+     
+   END SUBROUTINE test_transfert
+  
+END MODULE mod_phys_lmdz_para
+    
Index: trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_transfert_para.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_transfert_para.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/mod_phys_lmdz_transfert_para.F90	(revision 892)
@@ -0,0 +1,1275 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_transfert_para
+
+  USE mod_phys_lmdz_mpi_transfert
+  USE mod_phys_lmdz_omp_transfert 
+
+
+
+  INTERFACE bcast
+    MODULE PROCEDURE bcast_c,                                     &
+                     bcast_i,bcast_i1,bcast_i2,bcast_i3,bcast_i4, &
+                     bcast_r,bcast_r1,bcast_r2,bcast_r3,bcast_r4, &
+		     bcast_l,bcast_l1,bcast_l2,bcast_l3,bcast_l4
+  END INTERFACE
+
+  INTERFACE scatter
+    MODULE PROCEDURE scatter_i,scatter_i1,scatter_i2,scatter_i3, &
+                     scatter_r,scatter_r1,scatter_r2,scatter_r3, &
+		     scatter_l,scatter_l1,scatter_l2,scatter_l3
+  END INTERFACE
+
+  
+  INTERFACE gather
+    MODULE PROCEDURE gather_i,gather_i1,gather_i2,gather_i3, &
+                     gather_r,gather_r1,gather_r2,gather_r3, &
+		     gather_l,gather_l1,gather_l2,gather_l3  
+  END INTERFACE
+  
+  INTERFACE scatter2D
+    MODULE PROCEDURE scatter2D_i,scatter2D_i1,scatter2D_i2,scatter2D_i3, &
+                     scatter2D_r,scatter2D_r1,scatter2D_r2,scatter2D_r3, &
+		     scatter2D_l,scatter2D_l1,scatter2D_l2,scatter2D_l3
+  END INTERFACE
+
+  INTERFACE gather2D
+    MODULE PROCEDURE gather2D_i,gather2D_i1,gather2D_i2,gather2D_i3, &
+                     gather2D_r,gather2D_r1,gather2D_r2,gather2D_r3, &
+		     gather2D_l,gather2D_l1,gather2D_l2,gather2D_l3
+  END INTERFACE 
+  
+  INTERFACE reduce_sum
+    MODULE PROCEDURE reduce_sum_i,reduce_sum_i1,reduce_sum_i2,reduce_sum_i3,reduce_sum_i4, &
+                     reduce_sum_r,reduce_sum_r1,reduce_sum_r2,reduce_sum_r3,reduce_sum_r4
+  END INTERFACE 
+
+   
+CONTAINS
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Broadcast --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!! -- Les chaine de charactère -- !!
+
+  SUBROUTINE bcast_c(var)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_c
+
+!! -- Les entiers -- !!
+  
+  SUBROUTINE bcast_i(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i
+
+  SUBROUTINE bcast_i1(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i1
+
+
+  SUBROUTINE bcast_i2(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i2
+
+
+  SUBROUTINE bcast_i3(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i3
+
+
+  SUBROUTINE bcast_i4(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i4
+
+ 
+!! -- Les reels -- !!
+  
+  SUBROUTINE bcast_r(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var
+
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r
+
+  SUBROUTINE bcast_r1(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r1
+
+
+  SUBROUTINE bcast_r2(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r2
+
+
+  SUBROUTINE bcast_r3(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r3
+
+
+  SUBROUTINE bcast_r4(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r4 
+
+
+!! -- Les booleens -- !!
+  
+  SUBROUTINE bcast_l(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l
+
+  SUBROUTINE bcast_l1(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l1
+
+
+  SUBROUTINE bcast_l2(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l2
+
+
+  SUBROUTINE bcast_l3(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l3
+
+
+  SUBROUTINE bcast_l4(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l4
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE scatter_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi) :: Var_tmp
+    
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_i
+
+
+  SUBROUTINE scatter_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(Varout,2)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_i1
+
+
+  SUBROUTINE scatter_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_i2
+
+
+  SUBROUTINE scatter_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,4)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,VarOut)
+    
+  END SUBROUTINE scatter_i3
+
+
+  SUBROUTINE scatter_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi) :: Var_tmp
+    
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_r
+
+
+  SUBROUTINE scatter_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(Varout,2)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_r1
+
+
+  SUBROUTINE scatter_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_r2
+
+
+  SUBROUTINE scatter_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,4)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,VarOut)
+    
+  END SUBROUTINE scatter_r3
+  
+  
+
+  SUBROUTINE scatter_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi) :: Var_tmp
+    
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_l
+
+
+  SUBROUTINE scatter_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(Varout,2)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_l1
+
+
+  SUBROUTINE scatter_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_l2
+
+
+  SUBROUTINE scatter_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,4)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,VarOut)
+    
+  END SUBROUTINE scatter_l3
+
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Gather   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ 
+!!!!! --> Les entiers
+
+  SUBROUTINE gather_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    INTEGER, DIMENSION(klon_mpi) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,Varout)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_i
+
+
+  SUBROUTINE gather_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    INTEGER, DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,Varout)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_i1
+
+
+  SUBROUTINE gather_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    INTEGER, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_i2
+
+
+  SUBROUTINE gather_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    INTEGER, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_i3
+
+
+!!!!! --> Les reels
+
+  SUBROUTINE gather_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    REAL, DIMENSION(klon_mpi) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_r
+
+
+  SUBROUTINE gather_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL, DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_r1
+
+
+  SUBROUTINE gather_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_r2
+
+
+  SUBROUTINE gather_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_r3
+
+
+!!!!! --> Les booleens
+
+  SUBROUTINE gather_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_mpi) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_l
+
+
+  SUBROUTINE gather_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_l1
+
+
+  SUBROUTINE gather_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_l2
+
+
+  SUBROUTINE gather_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_l3
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter2D   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+!!!!! --> Les entiers
+
+  SUBROUTINE scatter2D_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_i
+
+
+  SUBROUTINE scatter2D_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarOut,2)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_i1
+  
+
+  SUBROUTINE scatter2D_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_i2  
+
+
+  SUBROUTINE scatter2D_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_i3
+  
+
+!!!!! --> Les reels
+
+  SUBROUTINE scatter2D_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_r
+
+
+  SUBROUTINE scatter2D_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(VarOut,2)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_r1
+  
+
+  SUBROUTINE scatter2D_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_r2  
+
+
+  SUBROUTINE scatter2D_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_r3
+    
+    
+!!!!! --> Les booleens
+
+
+  SUBROUTINE scatter2D_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_l
+
+
+  SUBROUTINE scatter2D_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarOut,2)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_l1
+  
+
+  SUBROUTINE scatter2D_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_l2  
+
+
+  SUBROUTINE scatter2D_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_l3
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Gather2D   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!!!!! --> Les entiers
+
+  SUBROUTINE gather2D_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_i
+  
+
+  SUBROUTINE gather2D_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_i1
+
+  
+  SUBROUTINE gather2D_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_i2
+
+
+  SUBROUTINE gather2D_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_i3
+
+
+!!!!! --> Les reels
+
+  SUBROUTINE gather2D_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_r
+  
+
+  SUBROUTINE gather2D_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_r1
+
+  
+  SUBROUTINE gather2D_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_r2
+
+
+  SUBROUTINE gather2D_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_r3
+  
+
+!!!!! --> Les booleens
+
+  SUBROUTINE gather2D_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_l
+  
+
+  SUBROUTINE gather2D_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_l1
+
+  
+  SUBROUTINE gather2D_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_l2
+
+
+  SUBROUTINE gather2D_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_l3
+  
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des reduce_sum   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+! Les entiers
+
+  SUBROUTINE reduce_sum_i(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN)  :: VarIn
+    INTEGER,INTENT(OUT) :: VarOut
+    
+    INTEGER             :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i  
+
+
+  SUBROUTINE reduce_sum_i1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    INTEGER,DIMENSION(SIZE(VarIn))   :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i1  
+
+
+  SUBROUTINE reduce_sum_i2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    INTEGER,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2)) :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i2  
+  
+
+  SUBROUTINE reduce_sum_i3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i3  
+
+
+  SUBROUTINE reduce_sum_i4(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i4  
+
+
+! Les reels
+
+  SUBROUTINE reduce_sum_r(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN)  :: VarIn
+    REAL,INTENT(OUT) :: VarOut
+    
+    REAL             :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r  
+
+
+  SUBROUTINE reduce_sum_r1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    REAL,DIMENSION(SIZE(VarIn))   :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r1  
+
+
+  SUBROUTINE reduce_sum_r2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2)) :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r2  
+  
+
+  SUBROUTINE reduce_sum_r3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r3  
+
+
+  SUBROUTINE reduce_sum_r4(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r4  
+
+   
+END MODULE mod_phys_lmdz_transfert_para
+
Index: trunk/LMDZ.VENUS/libf/phyvenus/phyetat0.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/phyetat0.F	(revision 888)
+++ 	(revision )
@@ -1,523 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/phyetat0.F,v 1.2 2004/06/22 11:45:33 lmdzadmin Exp $
-!
-c
-c
-      SUBROUTINE phyetat0 (fichnom,
-     .            rlat,rlon, tsol,tsoil,
-     .           albe, solsw, sollw,
-     .           fder,radsol,
-     .    zmea, zstd, zsig, zgam, zthe, zpic, zval,  
-     .           t_ancien,ancien_ok)
-
-      use dimphy
-      use control_mod
-      IMPLICIT none
-c======================================================================
-c Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
-c Objet: Lecture de l'etat initial pour la physique
-c======================================================================
-#include "dimensions.h"
-#include "netcdf.inc"
-#include "dimsoil.h"
-#include "clesphys.h"
-#include "tabcontrol.h"
-#include "temps.h"
-c======================================================================
-      CHARACTER*(*) fichnom
-      REAL rlat(klon), rlon(klon)
-      REAL tsol(klon)
-      REAL tsoil(klon,nsoilmx)
-      REAL albe(klon)
-cIM BEG alblw
-      REAL alblw(klon)
-cIM END alblw
-      REAL radsol(klon)
-      REAL sollw(klon)
-      real solsw(klon)
-      real fder(klon)
-      REAL zmea(klon), zstd(klon)
-      REAL zsig(klon), zgam(klon), zthe(klon)
-      REAL zpic(klon), zval(klon)
-
-      REAL t_ancien(klon,klev)
-      LOGICAL ancien_ok
-
-      REAL xmin, xmax
-c
-      INTEGER nid, nvarid
-      INTEGER ierr, i, nsrf, isoil 
-      REAL tab_cntrl(length)
-      CHARACTER*2 str2
-c
-c Ouvrir le fichier contenant l'etat initial:
-c
-      print*,'fichnom',fichnom
-      ierr = NF_OPEN (fichnom, NF_NOWRITE,nid)
-      IF (ierr.NE.NF_NOERR) THEN
-        write(6,*)' Pb d''ouverture du fichier '//fichnom
-        write(6,*)' ierr = ', ierr
-        CALL ABORT
-      ENDIF
-c
-c Lecture des parametres de controle:
-c
-      ierr = NF_INQ_VARID (nid, "controle", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <controle> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <controle>'
-         CALL abort
-      ELSE
-c
-         DO i = 1, length
-           tabcntr0( i ) = tab_cntrl( i )
-         ENDDO
-c
-
-         dtime        = tab_cntrl(1)
-         radpas       = tab_cntrl(2)
-
-      ENDIF
-
-      itau_phy = tab_cntrl(15)
-
-c Attention si raz_date est active :
-c il faut remettre a zero itau_phy apres phyetat0 !
-      IF (raz_date.eq.1) THEN
-        itau_phy=0
-      ENDIF
-
-c
-c Lecture des latitudes (coordonnees):
-c
-      ierr = NF_INQ_VARID (nid, "latitude", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <latitude> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlat)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, rlat)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <latitude>'
-         CALL abort
-      ENDIF
-c
-c Lecture des longitudes (coordonnees):
-c
-      ierr = NF_INQ_VARID (nid, "longitude", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <longitude> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlon)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, rlon)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <latitude>'
-         CALL abort
-      ENDIF
-C
-c Lecture des temperatures du sol:
-c
-      ierr = NF_INQ_VARID (nid, "TS", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <TS> est absent'
-         PRINT*, "phyetat0: Lecture echouee pour <TS>"
-         CALL abort
-      ELSE
-         PRINT*, 'phyetat0: Le champ <TS> est present'
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tsol(1))
-#else
-         ierr = NF_GET_VAR_REAL(nid, nvarid, tsol(1))
-#endif
-         IF (ierr.NE.NF_NOERR) THEN
-            PRINT*, "phyetat0: Lecture echouee pour <TS>"
-            CALL abort
-         ENDIF
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(tsol(i),xmin)
-            xmax = MAX(tsol(i),xmax)
-         ENDDO
-         PRINT*,'Temperature du sol <TS>', xmin, xmax
-      ENDIF
-c
-c Lecture des temperatures du sol profond:
-c
-      DO isoil=1, nsoilmx
-      IF (isoil.GT.99) THEN
-         PRINT*, "Trop de couches"
-         CALL abort
-      ENDIF
-      WRITE(str2,'(i2.2)') isoil
-      ierr = NF_INQ_VARID (nid, 'Tsoil'//str2, nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, "phyetat0: Le champ <Tsoil"//str2//"> est absent"
-         PRINT*, "          Il prend donc la valeur de surface"
-         DO i=1, klon
-             tsoil(i,isoil)=tsol(i)
-         ENDDO
-      ELSE
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tsoil(1,isoil))
-#else
-         ierr = NF_GET_VAR_REAL(nid, nvarid, tsoil(1,isoil))
-#endif
-         IF (ierr.NE.NF_NOERR) THEN
-            PRINT*, "Lecture echouee pour <Tsoil"//str2//">"
-            CALL abort
-         ENDIF
-      ENDIF
-      ENDDO
-c
-c Lecture de albedo au sol:
-c
-      ierr = NF_INQ_VARID (nid, "ALBE", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <ALBE> est absent'
-         PRINT*, "phyetat0: Lecture echouee pour <ALBE>"
-         CALL abort
-      ELSE
-         PRINT*, 'phyetat0: Le champ <ALBE> est present'
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid, nvarid, albe(1))
-#else
-         ierr = NF_GET_VAR_REAL(nid, nvarid, albe(1))
-#endif
-         IF (ierr.NE.NF_NOERR) THEN
-            PRINT*, "phyetat0: Lecture echouee pour <ALBE>"
-            CALL abort
-         ENDIF
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(albe(i),xmin)
-            xmax = MAX(albe(i),xmax)
-         ENDDO
-         PRINT*,'Albedo du sol <ALBE>', xmin, xmax
-      ENDIF
-
-c
-c Lecture rayonnement solaire au sol:
-c
-      ierr = NF_INQ_VARID (nid, "solsw", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <solsw> est absent'
-         PRINT*, 'mis a zero'
-         solsw = 0.
-      ELSE
-#ifdef NC_DOUBLE
-        ierr = NF_GET_VAR_DOUBLE(nid, nvarid, solsw)
-#else
-        ierr = NF_GET_VAR_REAL(nid, nvarid, solsw)
-#endif
-        IF (ierr.NE.NF_NOERR) THEN
-          PRINT*, 'phyetat0: Lecture echouee pour <solsw>'
-          CALL abort
-        ENDIF
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(solsw(i),xmin)
-         xmax = MAX(solsw(i),xmax)
-      ENDDO
-      PRINT*,'Rayonnement solaire au sol solsw:', xmin, xmax
-c
-c Lecture rayonnement IF au sol:
-c
-      ierr = NF_INQ_VARID (nid, "sollw", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <sollw> est absent'
-         PRINT*, 'mis a zero'
-         sollw = 0.
-      ELSE
-#ifdef NC_DOUBLE
-        ierr = NF_GET_VAR_DOUBLE(nid, nvarid, sollw)
-#else
-        ierr = NF_GET_VAR_REAL(nid, nvarid, sollw)
-#endif
-        IF (ierr.NE.NF_NOERR) THEN
-          PRINT*, 'phyetat0: Lecture echouee pour <sollw>'
-          CALL abort
-        ENDIF
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(sollw(i),xmin)
-         xmax = MAX(sollw(i),xmax)
-      ENDDO
-      PRINT*,'Rayonnement IF au sol sollw:', xmin, xmax
-
-c
-c Lecture derive des flux:
-c
-      ierr = NF_INQ_VARID (nid, "fder", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <fder> est absent'
-         PRINT*, 'mis a zero'
-         fder = 0.
-      ELSE
-#ifdef NC_DOUBLE
-        ierr = NF_GET_VAR_DOUBLE(nid, nvarid, fder)
-#else
-        ierr = NF_GET_VAR_REAL(nid, nvarid, fder)
-#endif
-        IF (ierr.NE.NF_NOERR) THEN
-          PRINT*, 'phyetat0: Lecture echouee pour <fder>'
-          CALL abort
-        ENDIF
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(fder(i),xmin)
-         xmax = MAX(fder(i),xmax)
-      ENDDO
-      PRINT*,'Derive des flux fder:', xmin, xmax
-
-c
-c Lecture du rayonnement net au sol:
-c
-      ierr = NF_INQ_VARID (nid, "RADS", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <RADS> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, radsol)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, radsol)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <RADS>'
-         CALL abort
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(radsol(i),xmin)
-         xmax = MAX(radsol(i),xmax)
-      ENDDO
-      PRINT*,'Rayonnement net au sol radsol:', xmin, xmax
-c
-
-c
-c Lecture de l'orographie sous-maille si ok_orodr:
-c
-      if(ok_orodr) then
-     
-      ierr = NF_INQ_VARID (nid, "ZMEA", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <ZMEA> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zmea)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, zmea)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <ZMEA>'
-         CALL abort
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zmea(i),xmin)
-         xmax = MAX(zmea(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zmea:', xmin, xmax
-c
-c
-      ierr = NF_INQ_VARID (nid, "ZSTD", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <ZSTD> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zstd)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, zstd)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <ZSTD>'
-         CALL abort
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zstd(i),xmin)
-         xmax = MAX(zstd(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zstd:', xmin, xmax
-c
-c
-      ierr = NF_INQ_VARID (nid, "ZSIG", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <ZSIG> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zsig)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, zsig)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <ZSIG>'
-         CALL abort
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zsig(i),xmin)
-         xmax = MAX(zsig(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zsig:', xmin, xmax
-c
-c
-      ierr = NF_INQ_VARID (nid, "ZGAM", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <ZGAM> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zgam)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, zgam)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <ZGAM>'
-         CALL abort
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zgam(i),xmin)
-         xmax = MAX(zgam(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zgam:', xmin, xmax
-c
-c
-      ierr = NF_INQ_VARID (nid, "ZTHE", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <ZTHE> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zthe)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, zthe)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <ZTHE>'
-         CALL abort
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zthe(i),xmin)
-         xmax = MAX(zthe(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zthe:', xmin, xmax
-c
-c
-      ierr = NF_INQ_VARID (nid, "ZPIC", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <ZPIC> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zpic)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, zpic)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <ZPIC>'
-         CALL abort
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zpic(i),xmin)
-         xmax = MAX(zpic(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zpic:', xmin, xmax
-c
-      ierr = NF_INQ_VARID (nid, "ZVAL", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Le champ <ZVAL> est absent'
-         CALL abort
-      ENDIF
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zval)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, zval)
-#endif
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, 'phyetat0: Lecture echouee pour <ZVAL>'
-         CALL abort
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zval(i),xmin)
-         xmax = MAX(zval(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zval:', xmin, xmax
-
-      else 
-         zmea = 0.
-         zstd = 0.
-         zsig = 0.
-         zgam = 0.
-         zthe = 0.
-         zpic = 0.
-         zval = 0.
-
-      endif   ! fin test sur ok_orodr
-
-c
-c Lecture de TANCIEN:
-c
-      ancien_ok = .TRUE.
-c
-      ierr = NF_INQ_VARID (nid, "TANCIEN", nvarid)
-      IF (ierr.NE.NF_NOERR) THEN
-         PRINT*, "phyetat0: Le champ <TANCIEN> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         ancien_ok = .FALSE.
-      ELSE
-#ifdef NC_DOUBLE
-         ierr = NF_GET_VAR_DOUBLE(nid, nvarid, t_ancien)
-#else
-         ierr = NF_GET_VAR_REAL(nid, nvarid, t_ancien)
-#endif
-         IF (ierr.NE.NF_NOERR) THEN
-            PRINT*, "phyetat0: Lecture echouee pour <TANCIEN>"
-            CALL abort
-         ENDIF
-      ENDIF
-c
-c Fermer le fichier:
-c
-      ierr = NF_CLOSE(nid)
-c
-      RETURN
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/phyetat0.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/phyetat0.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/phyetat0.F90	(revision 892)
@@ -0,0 +1,324 @@
+!
+! $Id $
+!
+subroutine phyetat0(fichnom)
+! Load initial state for the physics
+! and do some resulting initializations
+
+      USE dimphy
+      USE mod_grid_phy_lmdz
+      USE mod_phys_lmdz_para
+      USE iophy
+      USE phys_state_var_mod
+      USE iostart
+      USE infotrac
+      USE comgeomphy,  only: rlatd,rlond
+      USE control_mod, only: raz_date
+
+implicit none
+!======================================================================
+! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
+! Objet: Lecture de l'etat initial pour la physique
+!======================================================================
+#include "dimensions.h"
+#include "netcdf.inc"
+#include "dimsoil.h"
+#include "clesphys.h"
+#include "tabcontrol.h"
+#include "temps.h"
+!======================================================================
+
+character(len=*),intent(in) :: fichnom ! input file name
+REAL    :: xmin, xmax
+LOGICAL :: found
+REAL    :: tab_cntrl(length)
+integer :: i,isoil
+CHARACTER(len=2) :: str2
+
+! les variables globales lues dans le fichier restart
+
+! open physics initial state file:
+call open_startphy(fichnom)
+
+!
+! Lecture des parametres de controle:
+!
+      CALL get_var("controle",tab_cntrl,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <controle> est absent'
+         CALL abort
+      ENDIF
+       
+      DO i = 1, length
+           tabcntr0( i ) = tab_cntrl( i )
+      ENDDO
+
+
+      dtime        = tab_cntrl(1)
+      radpas       = tab_cntrl(2)
+
+      itau_phy = tab_cntrl(15)
+
+! Attention si raz_date est active :
+! il faut remettre a zero itau_phy apres phyetat0 !
+      IF (raz_date.eq.1) THEN
+        itau_phy=0
+      ENDIF
+
+! read latitudes
+call get_field("latitude",rlatd,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <latitude> est absent'
+         CALL abort
+      ENDIF
+
+! read longitudes
+call get_field("longitude",rlond,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <longitude> est absent'
+         CALL abort
+      ENDIF
+
+! read in other variables here ...
+
+! Lecture des temperatures du sol:
+
+       CALL get_field("TS",ftsol(:),found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <TS> est absent'
+         PRINT*, "phyetat0: Lecture echouee pour <TS>"
+         CALL abort
+      ELSE
+         PRINT*, 'phyetat0: Le champ <TS> est present'
+         xmin = 1.0E+20
+         xmax = -1.0E+20
+         DO i = 1, klon
+            xmin = MIN(ftsol(i),xmin)
+            xmax = MAX(ftsol(i),xmax)
+         ENDDO
+         PRINT*,'Temperature du sol <TS>', xmin, xmax
+      ENDIF
+
+
+! Lecture des temperatures du sol profond:
+
+      DO isoil=1, nsoilmx
+      IF (isoil.GT.99) THEN
+         PRINT*, "Trop de couches"
+         CALL abort
+      ENDIF
+      WRITE(str2,'(i2.2)') isoil
+      CALL get_field('Tsoil'//str2,ftsoil(:,isoil),found)
+      IF (.not.found) THEN
+         PRINT*, "phyetat0: Le champ <Tsoil"//str2//"> est absent"
+         PRINT*, "          Il prend donc la valeur de surface"
+         DO i=1, klon
+             ftsoil(i,isoil)=ftsol(i)
+         ENDDO
+      ENDIF
+      ENDDO
+
+! Lecture de albedo au sol:
+
+      CALL get_field("ALBE", falbe,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <ALBE> est absent'
+         PRINT*, "phyetat0: Lecture echouee pour <ALBE>"
+         CALL abort
+      ELSE
+         xmin = 1.0E+20
+         xmax = -1.0E+20
+         DO i = 1, klon
+            xmin = MIN(falbe(i),xmin)
+            xmax = MAX(falbe(i),xmax)
+         ENDDO
+         PRINT*,'Albedo du sol <ALBE>', xmin, xmax
+      ENDIF
+
+! Lecture rayonnement solaire au sol:
+
+      CALL get_field("solsw",solsw,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <solsw> est absent'
+         PRINT*, 'mis a zero'
+         solsw = 0.
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(solsw(i),xmin)
+         xmax = MAX(solsw(i),xmax)
+      ENDDO
+      PRINT*,'Rayonnement solaire au sol solsw:', xmin, xmax
+
+! Lecture rayonnement IF au sol:
+
+      CALL get_field("sollw",sollw,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <sollw> est absent'
+         PRINT*, 'mis a zero'
+         sollw = 0.
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(sollw(i),xmin)
+         xmax = MAX(sollw(i),xmax)
+      ENDDO
+      PRINT*,'Rayonnement IF au sol sollw:', xmin, xmax
+
+! Lecture derive des flux:
+
+      CALL get_field("fder",fder,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <fder> est absent'
+         PRINT*, 'mis a zero'
+         fder = 0.
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(fder(i),xmin)
+         xmax = MAX(fder(i),xmax)
+      ENDDO
+      PRINT*,'Derive des flux fder:', xmin, xmax
+
+! Lecture du rayonnement net au sol:
+
+      CALL get_field("RADS",radsol,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <RADS> est absent'
+         CALL abort
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(radsol(i),xmin)
+         xmax = MAX(radsol(i),xmax)
+      ENDDO
+      PRINT*,'Rayonnement net au sol radsol:', xmin, xmax
+
+! Lecture de l'orographie sous-maille si ok_orodr:
+
+      if(ok_orodr) then
+     
+      CALL get_field("ZMEA",zmea,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <ZMEA> est absent'
+         CALL abort
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(zmea(i),xmin)
+         xmax = MAX(zmea(i),xmax)
+      ENDDO
+      PRINT*,'OROGRAPHIE SOUS-MAILLE zmea:', xmin, xmax
+
+      CALL get_field("ZSTD",zstd,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <ZSTD> est absent'
+         CALL abort
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(zstd(i),xmin)
+         xmax = MAX(zstd(i),xmax)
+      ENDDO
+      PRINT*,'OROGRAPHIE SOUS-MAILLE zstd:', xmin, xmax
+
+      CALL get_field("ZSIG",zsig,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <ZSIG> est absent'
+         CALL abort
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(zsig(i),xmin)
+         xmax = MAX(zsig(i),xmax)
+      ENDDO
+      PRINT*,'OROGRAPHIE SOUS-MAILLE zsig:', xmin, xmax
+
+      CALL get_field("ZGAM",zgam,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <ZGAM> est absent'
+         CALL abort
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(zgam(i),xmin)
+         xmax = MAX(zgam(i),xmax)
+      ENDDO
+      PRINT*,'OROGRAPHIE SOUS-MAILLE zgam:', xmin, xmax
+
+      CALL get_field("ZTHE",zthe,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <ZTHE> est absent'
+         CALL abort
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(zthe(i),xmin)
+         xmax = MAX(zthe(i),xmax)
+      ENDDO
+      PRINT*,'OROGRAPHIE SOUS-MAILLE zthe:', xmin, xmax
+
+      CALL get_field("ZPIC",zpic,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <ZPIC> est absent'
+         CALL abort
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(zpic(i),xmin)
+         xmax = MAX(zpic(i),xmax)
+      ENDDO
+      PRINT*,'OROGRAPHIE SOUS-MAILLE zpic:', xmin, xmax
+
+      CALL get_field("ZVAL",zval,found)
+      IF (.not.found) THEN
+         PRINT*, 'phyetat0: Le champ <ZVAL> est absent'
+         CALL abort
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, klon
+         xmin = MIN(zval(i),xmin)
+         xmax = MAX(zval(i),xmax)
+      ENDDO
+      PRINT*,'OROGRAPHIE SOUS-MAILLE zval:', xmin, xmax
+
+      else 
+         zmea = 0.
+         zstd = 0.
+         zsig = 0.
+         zgam = 0.
+         zthe = 0.
+         zpic = 0.
+         zval = 0.
+
+      endif   ! fin test sur ok_orodr
+
+! Lecture de TANCIEN:
+
+      ancien_ok = .TRUE.
+
+      CALL get_field("TANCIEN",t_ancien,found)
+      IF (.not.found) THEN
+         PRINT*, "phyetat0: Le champ <TANCIEN> est absent"
+         PRINT*, "Depart legerement fausse. Mais je continue"
+         ancien_ok = .FALSE.
+      ENDIF
+
+! close file
+call close_startphy
+
+! do some more initializations
+call init_iophy_new(rlatd,rlond)
+
+end subroutine phyetat0
Index: trunk/LMDZ.VENUS/libf/phyvenus/phyredem.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/phyredem.F	(revision 888)
+++ 	(revision )
@@ -1,359 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/phyredem.F,v 1.2 2004/06/22 11:45:34 lmdzadmin Exp $
-!
-c
-      SUBROUTINE phyredem (fichnom,
-     .           rlat,rlon, tsol,tsoil,
-     .           albedo, 
-     .           solsw, sollw,fder,
-     .           radsol,
-     .    zmea, zstd, zsig, zgam, zthe, zpic, zval, 
-     .           t_ancien)
-
-      USE control_mod
-      use dimphy
-      IMPLICIT none
-c======================================================================
-c Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
-c Objet: Ecriture de l'etat de redemarrage pour la physique
-c======================================================================
-#include "dimensions.h"
-#include "netcdf.inc"
-#include "dimsoil.h"
-#include "clesphys.h"
-#include "tabcontrol.h"
-#include "temps.h"
-c======================================================================
-      CHARACTER*13 fichnom
-      REAL rlat(klon), rlon(klon)
-      REAL tsol(klon)
-      REAL tsoil(klon,nsoilmx)
-      REAL albedo(klon)
-      real solsw(klon)
-      real sollw(klon)
-      real fder(klon)
-      REAL radsol(klon)
-      REAL zmea(klon), zstd(klon)
-      REAL zsig(klon), zgam(klon), zthe(klon)
-      REAL zpic(klon), zval(klon)
-      REAL t_ancien(klon,klev)
-c
-      INTEGER nid, nvarid, idim1, idim2, idim3
-      INTEGER ierr
-      REAL tab_cntrl(length)
-c
-      INTEGER isoil
-      CHARACTER*2 str2
-c
-c     print*,'fichnom',fichnom
-      ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
-      IF (ierr.NE.NF_NOERR) THEN
-        write(6,*)' Pb d''ouverture du fichier '//fichnom
-        write(6,*)' ierr = ', ierr
-        CALL ABORT
-      ENDIF
-c
-      ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 28,
-     .                       "Fichier redemarrage physique")
-c
-      ierr = NF_DEF_DIM (nid, "index", length, idim1)
-      ierr = NF_DEF_DIM (nid, "points_physiques", klon, idim2)
-      ierr = NF_DEF_DIM (nid, "horizon_vertical", klon*klev, idim3)
-c
-      ierr = NF_ENDDEF(nid)
-c
-      DO ierr = 1, length
-         tab_cntrl(ierr) = 0.0
-      ENDDO
-      tab_cntrl(1) = dtime
-      tab_cntrl(2) = radpas
-      tab_cntrl(3) = 0.0
-      tab_cntrl(4) = solaire
-      tab_cntrl(5) = 0
-      tab_cntrl(6) = nbapp_rad
-
-      IF( cycle_diurne ) tab_cntrl( 7 ) = 1.
-      IF(   soil_model ) tab_cntrl( 8 ) = 1.
-      IF(     ok_orodr ) tab_cntrl(10 ) = 1.
-      IF(     ok_orolf ) tab_cntrl(11 ) = 1.
-      IF( ok_gw_nonoro ) tab_cntrl(12 ) = 1.
-
-      tab_cntrl(13) = day_end
-      tab_cntrl(14) = annee_ref
-      tab_cntrl(15) = itau_phy
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1, idim1,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1, idim1,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 22,
-     .                        "Parametres de controle")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
-#endif
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "longitude", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "longitude", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 32,
-     .                        "Longitudes de la grille physique")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlon)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlon)
-#endif
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "latitude", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 31,
-     .                        "Latitudes de la grille physique")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlat)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlat)
-#endif
-c
-        ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-        ierr = NF_DEF_VAR (nid, "TS", NF_DOUBLE, 1, idim2,nvarid)
-#else
-        ierr = NF_DEF_VAR (nid, "TS", NF_FLOAT, 1, idim2,nvarid)
-#endif
-        ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 22,
-     .                        "Temperature de surface")
-        ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tsol(1))
-#else
-        ierr = NF_PUT_VAR_REAL (nid,nvarid,tsol(1))
-#endif
-c
-      DO isoil=1, nsoilmx
-        IF (isoil.LE.99) THEN
-        WRITE(str2,'(i2.2)') isoil
-        ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-        ierr = NF_DEF_VAR (nid, "Tsoil"//str2,NF_DOUBLE,1,idim2,nvarid)
-#else
-        ierr = NF_DEF_VAR (nid, "Tsoil"//str2,NF_FLOAT,1,idim2,nvarid)
-#endif
-        ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 24,
-     .                        "Temperature du sol No."//str2)
-        ierr = NF_ENDDEF(nid)
-        ELSE
-        PRINT*, "Trop de couches"
-        CALL abort
-        ENDIF
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tsoil(1,isoil))
-#else
-        ierr = NF_PUT_VAR_REAL (nid,nvarid,tsoil(1,isoil))
-#endif
-      ENDDO
-c
-        ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-        ierr = NF_DEF_VAR (nid,"ALBE",NF_DOUBLE,1,idim2,nvarid)
-#else
-        ierr = NF_DEF_VAR (nid,"ALBE",NF_FLOAT,1,idim2,nvarid)
-#endif
-        ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18,
-     .                        "albedo de surface")
-        ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,albedo(1))
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,albedo(1))
-#endif
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "solsw", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "solsw", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 32,
-     .                        "Rayonnement solaire a la surface")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,solsw)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,solsw)
-#endif
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "sollw", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "sollw", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 27,
-     .                        "Rayonnement IF a la surface")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,sollw)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,sollw)
-#endif
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "fder", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "fder", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 14,
-     .                        "Derive de flux")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,fder)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,fder)
-#endif
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "RADS", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "RADS", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 28,
-     .                        "Rayonnement net a la surface")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,radsol)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,radsol)
-#endif
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "ZMEA", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "ZMEA", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 27,
-     .                        "zmea Orographie sous-maille")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zmea)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,zmea)
-#endif
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "ZSTD", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "ZSTD", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 27,
-     .                        "zstd Orographie sous-maille")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zstd)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,zstd)
-#endif
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "ZSIG", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "ZSIG", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 27,
-     .                        "zsig Orographie sous-maille")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zsig)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,zsig)
-#endif
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "ZGAM", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "ZGAM", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 27,
-     .                        "zgam Orographie sous-maille")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zgam)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,zgam)
-#endif
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "ZTHE", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "ZTHE", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 27,
-     .                        "zthe Orographie sous-maille")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zthe)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,zthe)
-#endif
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "ZPIC", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "ZPIC", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 27,
-     .                        "zpic Orographie sous-maille")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zpic)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,zpic)
-#endif
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "ZVAL", NF_DOUBLE, 1, idim2,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "ZVAL", NF_FLOAT, 1, idim2,nvarid)
-#endif
-      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 27,
-     .                        "zval Orographie sous-maille")
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zval)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,zval)
-#endif
-c
-      ierr = NF_REDEF (nid)
-#ifdef NC_DOUBLE
-      ierr = NF_DEF_VAR (nid, "TANCIEN", NF_DOUBLE, 1, idim3,nvarid)
-#else
-      ierr = NF_DEF_VAR (nid, "TANCIEN", NF_FLOAT, 1, idim3,nvarid)
-#endif
-      ierr = NF_ENDDEF(nid)
-#ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,t_ancien)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,t_ancien)
-#endif
-c
-      ierr = NF_CLOSE(nid)
-c
-      RETURN
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/phyredem.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/phyredem.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/phyredem.F90	(revision 892)
@@ -0,0 +1,105 @@
+!
+! $Id: $
+!
+      SUBROUTINE phyredem (fichnom)
+
+      USE dimphy
+      USE mod_grid_phy_lmdz
+      USE mod_phys_lmdz_para
+      USE iophy
+      USE phys_state_var_mod
+      USE iostart, only : open_restartphy,close_restartphy, & 
+                          put_var,put_field
+      USE infotrac
+      USE comgeomphy,  only: rlatd,rlond
+      USE control_mod, only: raz_date
+
+      implicit none
+!======================================================================
+! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
+! Objet: Lecture de l'etat initial pour la physique
+!======================================================================
+#include "dimensions.h"
+#include "netcdf.inc"
+#include "dimsoil.h"
+#include "clesphys.h"
+#include "tabcontrol.h"
+#include "temps.h"
+!======================================================================
+
+character(len=*),intent(in) :: fichnom
+REAL    :: tab_cntrl(length)
+integer :: isoil
+CHARACTER(len=2) :: str2
+
+
+! open file
+
+      CALL open_restartphy(fichnom)
+
+! tab_cntrl() contains run parameters
+
+      tab_cntrl(:)=0.0
+ 
+      tab_cntrl(1) = dtime
+      tab_cntrl(2) = radpas
+      tab_cntrl(3) = 0.0
+      tab_cntrl(4) = solaire
+      tab_cntrl(5) = 0
+      tab_cntrl(6) = nbapp_rad
+
+      IF( cycle_diurne ) tab_cntrl( 7 ) = 1.
+      IF(   soil_model ) tab_cntrl( 8 ) = 1.
+      IF(     ok_orodr ) tab_cntrl(10 ) = 1.
+      IF(     ok_orolf ) tab_cntrl(11 ) = 1.
+      IF( ok_gw_nonoro ) tab_cntrl(12 ) = 1.
+
+      tab_cntrl(13) = day_end
+      tab_cntrl(14) = annee_ref
+      tab_cntrl(15) = itau_phy
+
+      CALL put_var("controle","Parametres de controle",tab_cntrl)
+
+! coordinates
+
+      CALL put_field("longitude", &
+                     "Longitudes de la grille physique",rlond)
+     
+      CALL put_field("latitude","Latitudes de la grille physique",rlatd)
+
+! variables
+
+      CALL put_field("TS","Temperature de surface",ftsol)
+
+      DO isoil=1, nsoilmx
+        IF (isoil.LE.99) THEN
+        WRITE(str2,'(i2.2)') isoil
+        CALL put_field("Tsoil"//str2, &
+                       "Temperature du sol No."//str2,ftsoil(:,isoil))
+        ELSE
+        PRINT*, "Trop de couches"
+        CALL abort
+        ENDIF
+      ENDDO
+
+      CALL put_field("ALBE","albedo de surface",falbe)
+      CALL put_field("solsw","Rayonnement solaire a la surface",solsw)
+      CALL put_field("sollw","Rayonnement IR a la surface",sollw)
+      CALL put_field("fder","Derive de flux",fder)
+      CALL put_field("RADS","Rayonnement net a la surface",radsol)
+      CALL put_field("ZMEA","zmea Orographie sous-maille",zmea)
+      CALL put_field("ZSTD","zstd Orographie sous-maille",zstd)
+      CALL put_field("ZSIG","zsig Orographie sous-maille",zsig)
+      CALL put_field("ZGAM","zgam Orographie sous-maille",zgam)
+      CALL put_field("ZTHE","zthe Orographie sous-maille",zthe)
+      CALL put_field("ZPIC","zpic Orographie sous-maille",zpic)
+      CALL put_field("ZVAL","zval Orographie sous-maille",zval)
+
+      CALL put_field("TANCIEN","T Previous iteration",t_ancien)
+
+! close file
+
+      CALL close_restartphy
+!$OMP BARRIER
+
+      END SUBROUTINE phyredem
Index: trunk/LMDZ.VENUS/libf/phyvenus/phys_state_var_mod.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/phys_state_var_mod.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/phys_state_var_mod.F90	(revision 892)
@@ -0,0 +1,158 @@
+!
+! $Id: phys_state_var_mod.F90 1670 2012-10-17 08:42:04Z idelkadi $
+!
+      MODULE phys_state_var_mod
+! Variables sauvegardees pour le startphy.nc
+!======================================================================
+!
+!
+!======================================================================
+! Declaration des variables
+      USE dimphy
+!      INTEGER, SAVE :: radpas
+!!$OMP THREADPRIVATE(radpas)
+!      REAL, SAVE :: dtime
+!!$OMP THREADPRIVATE(dtime)
+
+      REAL, ALLOCATABLE, SAVE :: ftsol(:)
+!$OMP THREADPRIVATE(ftsol)
+      REAL, ALLOCATABLE, SAVE :: ftsoil(:,:)
+!$OMP THREADPRIVATE(ftsoil)
+      REAL, ALLOCATABLE, SAVE :: falbe(:)
+!$OMP THREADPRIVATE(falbe)
+
+!clesphy0 param physiq
+!
+! Parametres de l'Orographie a l'Echelle Sous-Maille (OESM):
+!
+      REAL, ALLOCATABLE, SAVE :: zmea(:), zstd(:), zsig(:), zgam(:)
+!$OMP THREADPRIVATE(zmea, zstd, zsig, zgam)
+      REAL, ALLOCATABLE, SAVE :: zthe(:), zpic(:), zval(:)
+!$OMP THREADPRIVATE(zthe, zpic, zval)
+!     REAL tabcntr0(100)
+      REAL, ALLOCATABLE, SAVE :: rugoro(:)
+!$OMP THREADPRIVATE(rugoro)
+      REAL, ALLOCATABLE, SAVE :: t_ancien(:,:), q_ancien(:,:)
+!$OMP THREADPRIVATE(t_ancien, q_ancien)
+      REAL, ALLOCATABLE, SAVE :: u_ancien(:,:), v_ancien(:,:)
+!$OMP THREADPRIVATE(u_ancien, v_ancien)
+      LOGICAL, SAVE :: ancien_ok
+!$OMP THREADPRIVATE(ancien_ok)
+! pressure level
+      REAL,ALLOCATABLE,SAVE :: zuthe(:),zvthe(:)
+!$OMP THREADPRIVATE(zuthe,zvthe)
+!
+! heat : chauffage solaire
+! heat0: chauffage solaire ciel clair
+! cool : refroidissement infrarouge
+! cool0 : refroidissement infrarouge ciel clair
+! sollwdown : downward LW flux at surface
+! sollwdownclr : downward CS LW flux at surface
+! toplwdown : downward CS LW flux at TOA
+! toplwdownclr : downward CS LW flux at TOA
+      REAL,ALLOCATABLE,SAVE :: swnet(:,:)   
+!$OMP THREADPRIVATE(swnet)
+      REAL,ALLOCATABLE,SAVE :: lwnet(:,:)   
+!$OMP THREADPRIVATE(lwnet)
+      REAL,ALLOCATABLE,SAVE :: heat(:,:)   
+!$OMP THREADPRIVATE(heat)
+      REAL,ALLOCATABLE,SAVE :: heat0(:,:)
+!$OMP THREADPRIVATE(heat0)
+      REAL,ALLOCATABLE,SAVE :: cool(:,:)
+!$OMP THREADPRIVATE(cool)
+      REAL,ALLOCATABLE,SAVE :: cool0(:,:)
+!$OMP THREADPRIVATE(cool0)
+      REAL,ALLOCATABLE,SAVE :: dtrad(:,:)   
+!$OMP THREADPRIVATE(dtrad)
+      REAL,ALLOCATABLE,SAVE :: topsw(:), toplw(:)
+!$OMP THREADPRIVATE(topsw,toplw)
+      REAL, ALLOCATABLE, SAVE :: solsw(:), sollw(:)
+!$OMP THREADPRIVATE(solsw, sollw)
+      REAL, ALLOCATABLE, SAVE :: radsol(:)
+!$OMP THREADPRIVATE(radsol)
+      REAL,ALLOCATABLE,SAVE :: sollwdown(:)
+!$OMP THREADPRIVATE(sollwdown)
+      REAL,ALLOCATABLE,SAVE :: sollwdownclr(:)
+!$OMP THREADPRIVATE(sollwdownclr)
+      REAL,ALLOCATABLE,SAVE :: toplwdown(:)
+!$OMP THREADPRIVATE(toplwdown)
+      REAL,ALLOCATABLE,SAVE :: toplwdownclr(:)
+!$OMP THREADPRIVATE(toplwdownclr)
+      REAL,ALLOCATABLE,SAVE :: topsw0(:),toplw0(:),solsw0(:),sollw0(:)
+!$OMP THREADPRIVATE(topsw0,toplw0,solsw0,sollw0)
+      REAL,save,allocatable :: dlw(:)  ! derivee infra rouge
+      REAL,save,allocatable :: fder(:) ! Derive de flux (sensible et latente) 
+!$OMP THREADPRIVATE(dlw,fder)
+
+CONTAINS
+
+!======================================================================
+SUBROUTINE phys_state_var_init
+use dimphy
+USE control_mod
+IMPLICIT NONE
+#include "dimsoil.h"
+
+      ALLOCATE(ftsol(klon))            ! temperature de surface
+      ALLOCATE(ftsoil(klon,nsoilmx))   ! temperature dans le sol
+      ALLOCATE(falbe(klon))            ! albedo
+
+!  Parametres de l'Orographie a l'Echelle Sous-Maille (OESM):
+!
+!zmea(:)   ! orographie moyenne
+!zstd(:)   ! deviation standard de l'OESM
+!zsig(:)   ! pente de l'OESM
+!zgam(:)   ! anisotropie de l'OESM
+!zthe(:)   ! orientation de l'OESM
+!zpic(:)   ! Maximum de l'OESM
+!zval(:)   ! Minimum de l'OESM
+!rugoro(:) ! longueur de rugosite de l'OESM
+      ALLOCATE(zmea(klon), zstd(klon), zsig(klon), zgam(klon))
+      ALLOCATE(zthe(klon), zpic(klon), zval(klon))
+      ALLOCATE(rugoro(klon))
+
+      ALLOCATE(t_ancien(klon,klev), q_ancien(klon,klev))
+      ALLOCATE(u_ancien(klon,klev), v_ancien(klon,klev))
+
+      ALLOCATE(zuthe(klon),zvthe(klon))
+!
+      ALLOCATE(swnet(klon,klev), lwnet(klon,klev)) 
+      ALLOCATE(heat(klon,klev), heat0(klon,klev)) 
+      ALLOCATE(cool(klon,klev), cool0(klon,klev))
+      ALLOCATE(dtrad(klon,klev))
+      ALLOCATE(topsw(klon), toplw(klon))
+      ALLOCATE(solsw(klon), sollw(klon))
+      ALLOCATE(radsol(klon))  ! bilan radiatif au sol calcule par code radiatif
+      ALLOCATE(sollwdown(klon), sollwdownclr(klon))
+      ALLOCATE(toplwdown(klon), toplwdownclr(klon))
+      ALLOCATE(topsw0(klon),toplw0(klon),solsw0(klon),sollw0(klon))
+      ALLOCATE(dlw(klon), fder(klon))
+      
+END SUBROUTINE phys_state_var_init
+
+!======================================================================
+SUBROUTINE phys_state_var_end
+use dimphy
+use control_mod
+IMPLICIT NONE
+
+      deallocate(ftsol, falbe)
+      deallocate(zmea, zstd, zsig, zgam)
+      deallocate(zthe, zpic, zval)
+      deallocate(rugoro, t_ancien, q_ancien)
+      deallocate(        u_ancien, v_ancien)
+      deallocate(zuthe, zvthe)
+      deallocate(swnet, lwnet) 
+      deallocate(heat, heat0) 
+      deallocate(cool, cool0)
+      deallocate(dtrad)
+      deallocate(solsw, sollw, radsol)
+      deallocate(topsw, toplw)
+      deallocate(sollwdown, sollwdownclr)
+      deallocate(toplwdown, toplwdownclr)
+      deallocate(topsw0,toplw0,solsw0,sollw0)
+      deallocate(dlw, fder)
+
+END SUBROUTINE phys_state_var_end
+
+      END MODULE phys_state_var_mod
Index: trunk/LMDZ.VENUS/libf/phyvenus/physiq.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/physiq.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/physiq.F	(revision 892)
@@ -60,4 +60,7 @@
       use dimphy
       USE comgeomphy
+      USE mod_phys_lmdz_para, only : is_parallel,jj_nb
+      USE phys_state_var_mod ! Variables sauvegardees de la physique
+      USE iophy
       IMPLICIT none
 c======================================================================
@@ -117,9 +120,4 @@
       REAL qx(klon,klev,nqmax)
 
-      REAL,save,allocatable :: t_ancien(:,:)
-      REAL,save,allocatable :: u_ancien(:,:)
-      LOGICAL ancien_ok
-      SAVE ancien_ok
-
       REAL d_u_dyn(klon,klev)
       REAL d_t_dyn(klon,klev)
@@ -133,7 +131,4 @@
       REAL d_ps(klon)
 
-      REAL,save,allocatable :: swnet(:,:)
-      REAL,save,allocatable :: lwnet(:,:)
-c
       logical ok_hf
       real ecrit_hf
@@ -149,25 +144,8 @@
 c Variables propres a la physique
 c
-      REAL,save,allocatable :: radsol(:) ! bilan radiatif au sol calcule par code radiatif
       REAL,save,allocatable :: rlev(:,:) ! altitude a chaque niveau (interface inferieure de la couche) 
       INTEGER,save :: itap        ! compteur pour la physique
-      REAL,save,allocatable :: ftsol(:)    ! temperature du sol
-      REAL,save,allocatable :: ftsoil(:,:) ! temperature dans le sol
-      REAL,save,allocatable :: falbe(:)    ! albedo 
       REAL delp(klon,klev)        ! epaisseur d'une couche
       
-CMODDEB FLOTT
-c
-c  Parametres de l'Orographie a l'Echelle Sous-Maille (OESM):
-c
-      REAL,save,allocatable :: zmea(:)   ! orographie moyenne
-      REAL,save,allocatable :: zstd(:)   ! deviation standard de l'OESM
-      REAL,save,allocatable :: zsig(:)   ! pente de l'OESM
-      REAL,save,allocatable :: zgam(:)   ! anisotropie de l'OESM
-      REAL,save,allocatable :: zthe(:)   ! orientation de l'OESM
-      REAL,save,allocatable :: zpic(:)   ! Maximum de l'OESM
-      REAL,save,allocatable :: zval(:)   ! Minimum de l'OESM
-      REAL,save,allocatable :: rugoro(:) ! longueur de rugosite de l'OESM
-
       INTEGER igwd,idx(klon),itest(klon)
 c
@@ -198,5 +176,4 @@
 
       REAL zustrph(klon),zvstrph(klon) 
-      REAL,save,allocatable :: zuthe(:),zvthe(:)
 
 c Variables locales:
@@ -213,6 +190,4 @@
 
       REAL sens(klon), dsens(klon) ! chaleur sensible et sa derivee
-      REAL,save,allocatable :: dlw(:)  ! derivee infra rouge
-      REAL,save,allocatable :: fder(:) ! Derive de flux (sensible et latente) 
       REAL ve(klon) ! integr. verticale du transport meri. de l'energie
       REAL vq(klon) ! integr. verticale du transport meri. de l'eau
@@ -234,7 +209,4 @@
       EXTERNAL suphec    ! initialiser certaines constantes
       EXTERNAL transp    ! transport total de l'eau et de l'energie
-      INTEGER  lnblnk1
-      EXTERNAL lnblnk1   !enleve les blancs a la fin d'une variable de type
-                         !caracter
       EXTERNAL abort_gcm
       EXTERNAL printflag
@@ -257,12 +229,4 @@
       REAL flux_ec(klon,klev)   ! flux de chaleur Ec
 c
-c Le rayonnement n'est pas calcule tous les pas, il faut donc
-c                      sauvegarder les sorties du rayonnement
-      REAL,save,allocatable :: heat(:,:)    ! chauffage solaire
-      REAL,save,allocatable :: cool(:,:)    ! refroidissement infrarouge
-      REAL,save,allocatable :: dtrad(:,:)   ! K s-1 
-      REAL,save,allocatable :: topsw(:), toplw(:)
-      REAL,save,allocatable :: solsw(:), sollw(:)
-      REAL,save,allocatable :: sollwdown(:) ! downward LW flux at surface
       REAL tmpout(klon,klev)  ! K s-1 
 
@@ -321,13 +285,6 @@
 c
 c pour ioipsl
-      INTEGER ndex2d(iim*jjmp1),ndex3d(iim*jjmp1*klev)
-      REAL zx_tmp_fi2d(klon)      ! variable temporaire grille physique
-      REAL zx_tmp_fi3d(klon,klev) ! variable temporaire pour champs 3D 
-      REAL zx_tmp_2d(iim,jjmp1),zx_tmp_3d(iim,jjmp1,klev)
-      REAL zx_lon(iim,jjmp1), zx_lat(iim,jjmp1)
-
       INTEGER nid_day, nid_mth, nid_ins
       SAVE nid_day, nid_mth, nid_ins
-c
       INTEGER nhori, nvert, idayref
       REAL zsto, zout, zsto1, zsto2, zero
@@ -383,4 +340,9 @@
       bilansmc = 0
       ballons  = 0
+! NE FONCTIONNENT PAS ENCORE EN PARALLELE !!!
+      if (is_parallel) then
+        bilansmc = 0
+        ballons  = 0
+      endif
 
       IF (if_ebil.ge.1) THEN
@@ -398,14 +360,5 @@
 c========================
       IF (debut) THEN
-         allocate(t_ancien(klon,klev),u_ancien(klon,klev))
-         allocate(swnet(klon,klevp1),lwnet(klon,klevp1))
-         allocate(radsol(klon),ftsol(klon),falbe(klon))
-         allocate(rlev(klon,klevp1),ftsoil(klon,nsoilmx))
-         allocate(zmea(klon),zstd(klon),zsig(klon),zgam(klon))
-         allocate(zthe(klon),zpic(klon),zval(klon),rugoro(klon))
-         allocate(zuthe(klon),zvthe(klon),dlw(klon),fder(klon))
-         allocate(heat(klon,klev),cool(klon,klev))
-         allocate(dtrad(klon,klev),topsw(klon),toplw(klon))
-         allocate(solsw(klon),sollw(klon),sollwdown(klon))
+         allocate(rlev(klon,klevp1))
          allocate(source(klon,nqmax))
 
@@ -420,4 +373,5 @@
      .                  if_ebil)
 
+         call phys_state_var_init
 c
 c Initialiser les compteurs:
@@ -428,11 +382,5 @@
 c Lecture startphy.nc :
 c
-c REMETTRE TOUS LES PARAMETRES POUR OROGW...
-         CALL phyetat0 ("startphy.nc",
-     .       rlatd,rlond,ftsol,ftsoil,
-     .       falbe, solsw, sollw,
-     .       dlw,radsol,
-     .      zmea,zstd,zsig,zgam,zthe,zpic,zval,
-     .       t_ancien, ancien_ok)
+         CALL phyetat0 ("startphy.nc")
 
 c dtime est defini dans tabcontrol.h et lu dans startphy
@@ -1308,12 +1256,5 @@
       IF (lafin) THEN
          itau_phy = itau_phy + itap
-c REMETTRE TOUS LES PARAMETRES POUR OROGW...
-         CALL phyredem ("restartphy.nc",
-     .      rlatd, rlond, ftsol, ftsoil,
-     .      falbe,
-     .      solsw, sollw,dlw,
-     .      radsol,
-     .      zmea,zstd,zsig,zgam,zthe,zpic,zval,
-     .      t_ancien)
+         CALL phyredem ("restartphy.nc")
      
 c--------------FLOTT
Index: trunk/LMDZ.VENUS/libf/phyvenus/phytrac.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/phytrac.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/phytrac.F	(revision 892)
@@ -86,29 +86,4 @@
 cAA
 
-      CHARACTER*2 itn
-C maf ioipsl
-      CHARACTER*2 str2
-      INTEGER nhori, nvert
-      REAL zsto, zout, zjulian
-      INTEGER nid_tra
-      SAVE nid_tra
-      INTEGER nid_tra2,nid_tra3
-      SAVE nid_tra2,nid_tra3
-      INTEGER ndex(1)
-      INTEGER ndex2d(iim*(jjm+1)),ndex3d(iim*(jjm+1)*klev)
-      REAL zx_tmp_2d(iim,jjm+1), zx_tmp_3d(iim,jjm+1,klev)
-      REAL zx_lon(iim,jjm+1), zx_lat(iim,jjm+1)
-c
-      integer itau_w   ! pas de temps ecriture = nstep + itau_phy
-c
-
-C
-C Variables liees a l'ecriture de la bande histoire : phytrac.nc
-c
-c      INTEGER ecrit_tra
-c      SAVE ecrit_tra   
-      logical ok_sync
-      parameter (ok_sync = .true.)
-C
 C les traceurs
 C
Index: trunk/LMDZ.VENUS/libf/phyvenus/phytrac.old
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/phytrac.old	(revision 888)
+++ 	(revision )
@@ -1,867 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/phytrac.F,v 1.16 2006/03/24 15:06:23 lmdzadmin Exp $
-!
-c
-c
-      SUBROUTINE phytrac (nstep,
-     I                    gmtime,
-     I                    debutphy,
-     I                    lafin,
-     I                    nqmax,
-     I                    nlon,
-     I                    nlev, 
-     I                    pdtphys,
-     I                    u,
-     I                    v,
-     I                    t_seri,
-     I                    paprs,
-     I                    pplay,
-     I                    coefh,
-     I                    yu1,
-     I                    yv1,
-     I                    ftsol,
-     I                    xlat,
-     I                    xlon,
-     I                    zlev, 
-     I                    presnivs,
-     I                    pphis,
-     I                    pphi,
-     I                    albsol,
-     O                    tr_seri)
-
-      USE ioipsl
-
-      IMPLICIT none
-c======================================================================
-c Auteur(s) FH
-c Objet: Moniteur general des tendances traceurs
-c
-cAA Remarques en vrac:
-cAA--------------------
-cAA 1/ le call phytrac se fait avec nqmax 
-c======================================================================
-#include "YOMCST.h"
-#include "dimensions.h"
-#include "dimphy.h"
-#include "clesphys.h" !///utile?
-#include "temps.h"
-#include "paramet.h"
-#include "control.h"
-#include "comgeomphy.h"
-#include "advtrac.h"
-c======================================================================
-
-c Arguments:
-c
-c   EN ENTREE:
-c   ==========
-c
-c   divers:
-c   -------
-c
-      integer nlon  ! nombre de points horizontaux
-      integer nlev  ! nombre de couches verticales
-      integer nqmax ! nombre de traceurs auxquels on applique la physique
-      integer nstep  ! appel physique
-      integer nseuil ! numero du premier traceur non CV
-c      integer julien !jour julien
-c      integer itop_con(nlon)
-c      integer ibas_con(nlon)
-      real gmtime
-      real pdtphys  ! pas d'integration pour la physique (seconde)
-      real t_seri(nlon,nlev) ! temperature
-      real tr_seri(nlon,nlev,nqmax) ! traceur  
-      real u(nlon,nlev)
-      real v(nlon,nlev)
-      real albsol(nlon)  ! albedo surface
-      real paprs(nlon,nlev+1)  ! pression pour chaque inter-couche (en Pa)
-      real ps(nlon)  ! pression surface
-      real pplay(nlon,nlev)  ! pression pour le mileu de chaque couche (en Pa)
-      real pphi(nlon,nlev) ! geopotentiel
-      real pphis(nlon)
-      REAL presnivs(nlev)
-      logical debutphy       ! le flag de l'initialisation de la physique
-      logical lafin          ! le flag de la fin de la physique
-c      REAL flxmass_w(nlon,nlev)
-
-cAA Rem : nqmax : nombre de vrais traceurs est defini dans dimphy.h
-c
-c   convection:
-c   -----------
-c
-      REAL pmfu(nlon,nlev)  ! flux de masse dans le panache montant
-      REAL pmfd(nlon,nlev)  ! flux de masse dans le panache descendant
-      REAL pen_u(nlon,nlev) ! flux entraine dans le panache montant
-
-c
-c   Couche limite:
-c   --------------
-c
-      REAL coefh(nlon,nlev) ! coeff melange CL
-      REAL yu1(nlon)        ! vents au premier niveau
-      REAL yv1(nlon)        ! vents au premier niveau
-      REAL xlat(nlon)       ! latitudes pour chaque point 
-      REAL xlon(nlon)       ! longitudes pour chaque point 
-      REAL zlev(nlon,nlev+1) ! altitude a chaque niveau (interface inferieure de la couche) 
-cAA
-cAA Arguments necessaires pour les sources et puits de traceur:
-cAA ----------------
-cAA
-      real ftsol(nlon)  ! Temperature du sol (surf)(Kelvin)
-
-cAA ----------------------------
-cAA  VARIABLES LOCALES TRACEURS
-cAA ----------------------------
-cAA
-
-      CHARACTER*2 itn
-C maf ioipsl
-      CHARACTER*2 str2
-      INTEGER nhori, nvert
-      REAL zsto, zout, zjulian
-      INTEGER nid_tra
-      SAVE nid_tra
-      INTEGER nid_tra2,nid_tra3
-      SAVE nid_tra2,nid_tra3
-      INTEGER ndex(1)
-      INTEGER ndex2d(iim*(jjm+1)),ndex3d(iim*(jjm+1)*klev)
-      REAL zx_tmp_2d(iim,jjm+1), zx_tmp_3d(iim,jjm+1,klev)
-      REAL zx_lon(iim,jjm+1), zx_lat(iim,jjm+1)
-c
-      integer itau_w   ! pas de temps ecriture = nstep + itau_phy
-c
-
-C
-C Variables liees a l'ecriture de la bande histoire : phytrac.nc
-c
-c      INTEGER ecrit_tra
-c      SAVE ecrit_tra   
-      logical ok_sync
-      parameter (ok_sync = .true.)
-C
-C les traceurs
-C
-c===================
-c it--------indice de traceur
-c k,i---------indices long, vert
-c===================
-c Variables deja declarees dont on a besoin pour traceurs   
-c   k,i,it,tr_seri(klon,klev,nqmax),pplay(nlon,nlev), 
-      real zprof(klon,klev,nqmx)
-c      real pzero,gamma
-c      parameter (pzero=85000.)
-c      parameter (gamma=5000.)
-      REAL alpha
-      real deltatr(klon,klev,nqmx) ! ecart au profil de ref zprof
-      real tau(klev,nqmx)          ! temps de relaxation vers le profil (s)
-      save zprof,tau
-c======================================================================
-c
-c Declaration des procedures appelees
-c
-c--modif convection tiedtke
-      INTEGER i, k, it
-      INTEGER iq, iiq
-      REAL delp(klon,klev)
-c--end modif
-c
-c Variables liees a l'ecriture de la bande histoire physique
-c
-c Variables locales pour effectuer les appels en serie
-c----------------------------------------------------
-c
-      REAL d_tr(klon,klev), d_trs(klon) ! tendances de traceurs 
-      REAL d_tr_cl(klon,klev,nqmax) ! tendance de traceurs  couche limite
-      REAL d_tr_cv(klon,klev,nqmax) ! tendance de traceurs  conv pour chq traceur
-C
-      character*80 abort_message
-c
-c   Controles
-c-------------
-      logical first,couchelimite,convection
-      save first,couchelimite,convection
-c Olivia
-       data first,couchelimite,convection
-     s     /.true.,.false.,.false./
-
-c======================================================================
-         ps(:)=paprs(:,1)
-c---------
-c debutphy
-c---------
-         if (debutphy) then
-                 print*,"DEBUT PHYTRAC"
-C         
-c=============================================================
-c   Initialisation des traceurs
-c=============================================================
-c
-c===========
-c definition de traceurs idealises
-c==========
-c
-c I) Declaration directe du traceur a altitude fixee
-c
-c a) traceur en carre OK
-c
-c         do i=1,klon
-c         tr_seri(i,:,1)=0.
-c        if ((xlat(i)>=0.).and.(xlat(i)<=-30.)) then
-c          if ((xlon(i)>=0.).and.(xlon(i)<=40.)) then
-c              tr_seri(i,10,1)=1.
-c          endif
-c        endif
-c      end do 
-c
-c a bis) 2 traceurs en carre lat/alt, uniforme en longitude OK 
-c
-C entre 45-55 km
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,1)=0.
-c           if ((xlat(i)>=60.).and.(xlat(i)<=80.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=5.e4).and.(pplay(klon/2,k)<=4.e5)) then
-c               tr_seri(i,k,1)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,1)=0.
-c         end do 
-c         end do
-cc
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,2)=0.
-c           if ((xlat(i)>=-60.).and.(xlat(i)<=-80.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=5.e4).and.(pplay(klon/2,k)<=4.e5)) then
-c               tr_seri(i,k,2)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,2)=0.
-c         end do 
-c         end do
-cc
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,3)=0.
-c           if ((xlat(i)>=40.).and.(xlat(i)<=60.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=5.e4).and.(pplay(klon/2,k)<=4.e5)) then
-c               tr_seri(i,k,3)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,3)=0.
-c         end do 
-c         end do
-cc
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,4)=0.
-c           if ((xlat(i)>=-40.).and.(xlat(i)<=-60.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=5.e4).and.(pplay(klon/2,k)<=4.e5)) then
-c               tr_seri(i,k,4)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,4)=0.
-c         end do 
-c         end do
-cc
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,5)=0.
-c           if ((xlat(i)>=-20.).and.(xlat(i)<=20.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=5.e4).and.(pplay(klon/2,k)<=4.e5)) then
-c              tr_seri(i,k,5)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,5)=0.
-c         end do 
-c         end do
-c
-c entre 35-45 km
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,6)=0.
-c           if ((xlat(i)>=60.).and.(xlat(i)<=80.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=4.e5).and.(pplay(klon/2,k)<=8.e6)) then
-c               tr_seri(i,k,6)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,6)=0.
-c         end do 
-c         end do
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,7)=0.
-c           if ((xlat(i)>=-60.).and.(xlat(i)<=-80.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=4.e5).and.(pplay(klon/2,k)<=8.e6)) then
-c               tr_seri(i,k,7)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,7)=0.
-c         end do 
-c         end do
-c
-C entre 50-60 km
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,8)=0.
-c           if ((xlat(i)>=60.).and.(xlat(i)<=80.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=1.e5)) then
-c               tr_seri(i,k,8)=1.
-c           endif
-c           endif
-c          endif
-c         else
-c            tr_seri(i,k,8)=0.
-c         end do 
-c         end do
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,9)=0.
-c           if ((xlat(i)>=-80.).and.(xlat(i)<=-60.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=1.e5)) then
-c               tr_seri(i,k,9)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,9)=0.
-c         end do 
-c         end do
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,10)=0.
-c           if ((xlat(i)>=40.).and.(xlat(i)<=60.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=1.e5)) then
-c               tr_seri(i,k,10)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,10)=0.
-c         end do 
-c         end do
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,11)=0.
-c           if ((xlat(i)>=-60.).and.(xlat(i)<=-40.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=1.e5)) then
-c               tr_seri(i,k,11)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,11)=0.
-c         end do 
-c         end do
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,12)=0.
-c           if ((xlat(i)>=-20.).and.(xlat(i)<=20.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=1.e5)) then
-c               tr_seri(i,k,12)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,12)=0.
-c         end do 
-c         end do
-c
-c entre 20-30 km
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,13)=0.
-c           if ((xlat(i)>=60.).and.(xlat(i)<=80.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e6).and.(pplay(klon/2,k)<=2.e6)) then
-c               tr_seri(i,k,13)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,13)=0.
-c         end do 
-c         end do
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,14)=0.
-c           if ((xlat(i)>=-80.).and.(xlat(i)<=-60.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e6).and.(pplay(klon/2,k)<=2.e6)) then
-c               tr_seri(i,k,14)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,14)=0.
-c         end do 
-c         end do
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,15)=0.
-c           if ((xlat(i)>=-20.).and.(xlat(i)<=20.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e6).and.(pplay(klon/2,k)<=2.e6)) then
-c               tr_seri(i,k,15)=1.
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,15)=0.
-c         end do 
-c         end do
-c
-c entre 55-65 km
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,16)=0.
-c           if ((xlat(i)>=60.).and.(xlat(i)<=80.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=5.e4)) then
-c               tr_seri(i,k,16)=1.
-c           endif
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,16)=0.
-c         end do 
-c         end do
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,17)=0.
-c           if ((xlat(i)>=-80.).and.(xlat(i)<=-60.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=5.e4)) then
-c               tr_seri(i,k,17)=1.
-c          endif
-c          endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,17)=0.
-c         end do 
-c         end do
-c
-c         do i=1,klon
-c         do k=1,klev+1
-cc         tr_seri(i,k,18)=0.
-c           if ((xlat(i)>=-20.).and.(xlat(i)<=20.)) then
-c           if ((xlon(i)>=-180.).and.(xlon(i)<=180.)) then
-c           if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=5.e4)) then
-c               tr_seri(i,k,18)=1.
-c           endif
-c           endif
-c           endif
-c           endif
-c         else
-c            tr_seri(i,k,18)=0.
-c         end do 
-c         end do
-c
-c b) traceur a une bande en latitudeOK
-c
-c a 65km
-c
-c        do i=1,klon
-c         tr_seri(i,:,1)=0.
-c        if ((xlat(i)>=60.).and.(xlat(i)<=80.)) then
-c              tr_seri(i,20,1)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,2)=0.
-c        if ((xlat(i)>=40.).and.(xlat(i)<=60.)) then
-c              tr_seri(i,20,2)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,3)=0.
-c        if ((xlat(i)>=20.).and.(xlat(i)<=40.)) then
-c              tr_seri(i,20,3)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,4)=0.
-c        if ((xlat(i)>=0.).and.(xlat(i)<=20.)) then
-c              tr_seri(i,20,4)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,5)=0.
-c        if ((xlat(i)>=-20.).and.(xlat(i)<=0.)) then
-c              tr_seri(i,20,5)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,6)=0.
-c        if ((xlat(i)>=-40.).and.(xlat(i)<=-20.)) then
-c              tr_seri(i,20,6)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,7)=0.
-c        if ((xlat(i)>=-60.).and.(xlat(i)<=-40.)) then
-c              tr_seri(i,20,7)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,8)=0.
-c        if ((xlat(i)>=-80.).and.(xlat(i)<=-60.)) then
-c              tr_seri(i,20,8)=1.
-c        endif
-c      end do  
-c
-c a 50km
-c
-c        do i=1,klon
-c        tr_seri(i,:,1)=0.
-c        if ((xlat(i)>=40.).and.(xlat(i)<=60.)) then
-c              tr_seri(i,27,1)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,2)=0.
-c        if ((xlat(i)>=60.).and.(xlat(i)<=80.)) then
-c              tr_seri(i,27,2)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,3)=0.
-c        if ((xlat(i)>=20.).and.(xlat(i)<=40.)) then
-c              tr_seri(i,27,3)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:4)=0.
-c        if ((xlat(i)>=0.).and.(xlat(i)<=20.)) then
-c              tr_seri(i,27,4)=1.
-c       endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,5)=0.
-c        if ((xlat(i)>=-20.).and.(xlat(i)<=0.)) then
-c              tr_seri(i,27,5)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,6)=0.
-c        if ((xlat(i)>=-40.).and.(xlat(i)<=-20.)) then
-c              tr_seri(i,27,6)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,7)=0.
-c        if ((xlat(i)>=-60.).and.(xlat(i)<=-40.)) then
-c              tr_seri(i,27,7)=1.
-c        endif
-c      end do  
-c
-c        do i=1,klon
-c         tr_seri(i,:,8)=0.
-c        if ((xlat(i)>=-80.).and.(xlat(i)<=-60.)) then
-c              tr_seri(i,27,8)=1.
-c        endif
-c      end do  
-c
-c c) traceur a plusieurs bandes en latitude OK
-c
-c         do i=1,klon
-c        tr_seri(i,:,2)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,10,2)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,10,2)=1.
-c        endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,10,2)=1. 
-c        endif         
-c      end do 
-c
-c d) traceur a une bande en altitude OK
-c
-c       do k=1,klev+1
-c         tr_seri(:,k,1)=0.
-c         if ((pplay(klon/2,k)>=1.e5).and.(pplay(klon/2,k)<=1.e6)) then
-c             tr_seri(:,k,1)=1.
-c         endif
-c       end do 
-c
-c dbis) plusieurs traceurs a une bande en altitude OK
-c
-c bande tres basse tropo
-c      do k=1,klev
-c        tr_seri(:,k,1)=0.
-c        if ((pplay(klon/2,k)>=5.e5).and.(pplay(klon/2,k)<=5.e6)) then
-c            tr_seri(:,k,1)=1.
-c        endif
-c      end do 
-c bande dans les nuages et un peu en-dessous    
-c      do k=1,klev
-c         tr_seri(:,k,2)=0.
-c         if ((pplay(klon/2,k)>=5.e4).and.(pplay(klon/2,k)<=5.e5)) then
-c             tr_seri(:,k,2)=1.
-c         endif
-c       end do 
-cune grosse epaisseur: inclue toute la circulation meridienne
-c      do k=1,klev
-c        tr_seri(:,k,1)=0.
-c        if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=1.e6)) then
-c            tr_seri(:,k,1)=1.
-c        endif
-c      end do
-cune grosse epaisseur: inclue la mesosphere
-c      do k=1,klev
-c         tr_seri(:,k,2)=0.
-c         if ((pplay(klon/2,k)>=2.e2).and.(pplay(klon/2,k)<=1.e4)) then
-c             tr_seri(:,k,2)=1.
-c         endif
-c       end do 
-c
-c      do k=1,klev
-c        tr_seri(:,k,3)=0.
-c        if ((pplay(klon/2,k)>=5.e1).and.(pplay(klon/2,k)<=5.e2)) then
-c            tr_seri(:,k,3)=1.
-c        endif
-c      end do 
-c
-c e) plusieurs couches verticales de traceurs, a plusieurs bandes en latitude???
-c       
-c au sol
-c         do i=1,klon
-c        tr_seri(i,:,1)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,5,1)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,5,1)=1.
-c        endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,5,1)=1. 
-c        endif         
-c      end do 
-c 
-c         do i=1,klon
-c        tr_seri(i,:,2)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,10,2)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,10,2)=1.
-c      endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,10,2)=1. 
-c        endif         
-c      end do 
-c
-c         do i=1,klon
-c        tr_seri(i,:,3)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,30,3)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,30,3)=1.
-c        endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,30,3)=1. 
-c        endif         
-c      end do 
-c        
-c        do i=1,klon
-c        tr_seri(i,:,4)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,45,4)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,45,4)=1.
-c        endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,45,4)=1. 
-c        endif         
-c      end do 
-c      
-
-c II) Declaration d'un profil vertical de traceur OK
-c 
-c tr_seri = profil initial
-c zprof   = profil de rappel 
-c           (identiques a l'initialisation)
-c
-c 1 -> CO ; 2 -> OCS 
-c def des profils en log(a) = a * log(P) + b par morceaux, cf. pollack et al
-c tr_seri en ppm
-
-c Constantes de rappel:
-
-       do k=1,klev
-         tau(k,1)=1.e6
-         tau(k,2)=1.e7
-         tau(k,3)=1.e8
-         tau(k,4)=1.e6
-         tau(k,5)=1.e7
-         tau(k,6)=1.e8
-       enddo
-
-c CO
-
-      do it=1,3 
-       do k=1,klev
-         tr_seri(:,k,it)=0.
-c pour l'instant, tau fixe, mais possibilite de le faire varier avec z
-        if (pplay(klon/2,k) >= 1.9e6) then
-           tr_seri(:,k,it)=20.
-        endif
-        if ((pplay(klon/2,k)<=1.9e6).and.(pplay(klon/2,k)>=2.73e5)) then
-           alpha=(log(pplay(klon/2,k))-log(2.73e5))/
-     .     (log(1.9e6)-log(2.73e5))
-           tr_seri(:,k,it)=30.*(20./30.)**alpha
-        endif
-        if ((pplay(klon/2,k)<=2.73e5).and.(pplay(klon/2,k)>=1.1e4)) then
-           alpha=(log(pplay(klon/2,k))-log(1.1e4))/
-     .     (log(2.73e5)-log(1.1e4))
-           tr_seri(:,k,it)=50.*(30./50.)**alpha
-        endif
-        if ((pplay(klon/2,k)<=1.1e4).and.(pplay(klon/2,k)>=1.3e3)) then
-           alpha=(log(pplay(klon/2,k))-log(1.3e3))/
-     .     (log(1.1e4)-log(1.3e3))
-           tr_seri(:,k,it)=2.*(50./2.)**alpha
-        endif
-        if ((pplay(klon/2,k)<=1.3e3).and.(pplay(klon/2,k)>=2.4)) then
-           alpha=(log(pplay(klon/2,k))-log(2.4))/
-     .     (log(1.3e3)-log(2.4))
-           tr_seri(:,k,it)=1000.*(2./1000.)**alpha
-        endif
-        if (pplay(klon/2,k) <= 2.4) then
-           tr_seri(:,k,it)=1000.
-        endif
-       enddo 
- 
-c OCS
-       do k=1,klev
-         tr_seri(:,k,it+3)=0.
-         if (pplay(klon/2,k) >= 9.45e5) then
-           tr_seri(:,k,it+3)=16.
-         endif
-         if ((pplay(klon/2,k)<=9.45e5).and.(pplay(klon/2,k)>=4.724e5))
-     *   then
-           alpha=(log(pplay(klon/2,k))-log(4.724e5))/
-     *     (log(9.45e5)-log(4.724e5))
-           tr_seri(:,k,it+3)=0.5*(16/0.5)**alpha
-         endif
-         if ((pplay(klon/2,k)<=4.724e5).and.(pplay(klon/2,k)>=1.1e4))
-     *   then
-           alpha=(log(pplay(klon/2,k))-log(1.1e4))/
-     *     (log(4.724e5)-log(1.1e4))
-           tr_seri(:,k,it+3)=0.005*(0.5/0.005)**alpha
-         endif
-         if (pplay(klon/2,k)<=1.1e4) then
-           tr_seri(:,k,it+3)=0.
-         endif
-       end do
-      enddo 
-
-       do it=1,nqmax
-         do k=1,klev
-           do i=1,klon
-             zprof(i,k,it) = tr_seri(i,k,it)
-           enddo
-         enddo
-       enddo
-
-c-------------
-c fin debutphy
-c-------------
-      ENDIF  ! fin debutphy 
-
-c======================================================================
-c Rappel vers un profil
-c======================================================================
-         do it=1,nqmax
-           do k=1,klev
-             do i=1,klon
-c VERIF
-           if (tr_seri(i,k,it).lt.0) then
-             print*,"Traceur negatif AVANT rappel:",i,k,it
-             stop
-           endif
-c FIN VERIF
-
-           deltatr(i,k,it) = (-tr_seri(i,k,it)+zprof(i,k,it))/tau(k,it)
-           tr_seri(i,k,it) =  tr_seri(i,k,it) + deltatr(i,k,it)*pdtphys
-
-c VERIF
-           if (tr_seri(i,k,it).lt.0) then
-             print*,"APRES rappel:",i,k,it,
-     .  deltatr(i,k,it),zprof(i,k,it),tr_seri(i,k,it),pdtphys/tau(k,it)
-             stop
-           endif
-c FIN VERIF
-             enddo
-           enddo
-         enddo
-
-c======================================================================
-c   Calcul de l'effet de la couche limite remis directement dans physiq
-c======================================================================
-
-
-      RETURN
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/phytrac.older
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/phytrac.older	(revision 888)
+++ 	(revision )
@@ -1,435 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/phytrac.F,v 1.16 2006/03/24 15:06:23 lmdzadmin Exp $
-!
-c
-c
-      SUBROUTINE phytrac (nstep,
-     I                    gmtime,
-     I                    debutphy,
-     I                    lafin,
-     I                    nqmax,
-     I                    nlon,
-     I                    nlev, 
-     I                    pdtphys,
-     I                    u,
-     I                    v,
-     I                    t_seri,
-     I                    paprs,
-     I                    pplay,
-     I                    coefh,
-     I                    yu1,
-     I                    yv1,
-     I                    ftsol,
-     I                    xlat,
-     I                    xlon,
-     I                    zlev, 
-     I                    presnivs,
-     I                    pphis,
-     I                    pphi,
-     I                    albsol,
-     O                    tr_seri)
-
-      USE ioipsl
-
-      IMPLICIT none
-c======================================================================
-c Auteur(s) FH
-c Objet: Moniteur general des tendances traceurs
-c
-cAA Remarques en vrac:
-cAA--------------------
-cAA 1/ le call phytrac se fait avec nqmax 
-c======================================================================
-#include "YOMCST.h"
-#include "dimensions.h"
-#include "dimphy.h"
-#include "clesphys.h" !///utile?
-#include "temps.h"
-#include "paramet.h"
-#include "control.h"
-#include "comgeomphy.h"
-#include "advtrac.h"
-c======================================================================
-
-c Arguments:
-c
-c   EN ENTREE:
-c   ==========
-c
-c   divers:
-c   -------
-c
-      integer nlon  ! nombre de points horizontaux
-      integer nlev  ! nombre de couches verticales
-      integer nqmax ! nombre de traceurs auxquels on applique la physique
-      integer nstep  ! appel physique
-      integer nseuil ! numero du premier traceur non CV
-c      integer julien !jour julien
-c      integer itop_con(nlon)
-c      integer ibas_con(nlon)
-      real gmtime
-      real pdtphys  ! pas d'integration pour la physique (seconde)
-      real t_seri(nlon,nlev) ! temperature
-      real tr_seri(nlon,nlev,nqmax) ! traceur  
-      real u(nlon,nlev)
-      real v(nlon,nlev)
-      real albsol(nlon)  ! albedo surface
-      real paprs(nlon,nlev+1)  ! pression pour chaque inter-couche (en Pa)
-      real ps(nlon)  ! pression surface
-      real pplay(nlon,nlev)  ! pression pour le mileu de chaque couche (en Pa)
-      real pphi(nlon,nlev) ! geopotentiel
-      real pphis(nlon)
-      REAL presnivs(nlev)
-      logical debutphy       ! le flag de l'initialisation de la physique
-      logical lafin          ! le flag de la fin de la physique
-c      REAL flxmass_w(nlon,nlev)
-
-cAA Rem : nqmax : nombre de vrais traceurs est defini dans dimphy.h
-c
-c   convection:
-c   -----------
-c
-      REAL pmfu(nlon,nlev)  ! flux de masse dans le panache montant
-      REAL pmfd(nlon,nlev)  ! flux de masse dans le panache descendant
-      REAL pen_u(nlon,nlev) ! flux entraine dans le panache montant
-
-c
-c   Couche limite:
-c   --------------
-c
-      REAL coefh(nlon,nlev) ! coeff melange CL
-      REAL yu1(nlon)        ! vents au premier niveau
-      REAL yv1(nlon)        ! vents au premier niveau
-      REAL xlat(nlon)       ! latitudes pour chaque point 
-      REAL xlon(nlon)       ! longitudes pour chaque point 
-      REAL zlev(nlon,nlev+1) ! altitude a chaque niveau (interface inferieure de la couche) 
-cAA
-cAA Arguments necessaires pour les sources et puits de traceur:
-cAA ----------------
-cAA
-      real ftsol(nlon)  ! Temperature du sol (surf)(Kelvin)
-
-cAA ----------------------------
-cAA  VARIABLES LOCALES TRACEURS
-cAA ----------------------------
-cAA
-cAA Sources et puits des traceurs:
-cAA ------------------------------
-cAA
-      REAL source(klon)       ! a voir lorsque le flux est prescrit 
-
-      CHARACTER*2 itn
-C maf ioipsl
-      CHARACTER*2 str2
-      INTEGER nhori, nvert
-      REAL zsto, zout, zjulian
-      INTEGER nid_tra
-      SAVE nid_tra
-      INTEGER nid_tra2,nid_tra3
-      SAVE nid_tra2,nid_tra3
-      INTEGER ndex(1)
-      INTEGER ndex2d(iim*(jjm+1)),ndex3d(iim*(jjm+1)*klev)
-      REAL zx_tmp_2d(iim,jjm+1), zx_tmp_3d(iim,jjm+1,klev)
-      REAL zx_lon(iim,jjm+1), zx_lat(iim,jjm+1)
-c
-      integer itau_w   ! pas de temps ecriture = nstep + itau_phy
-c
-
-C
-C Variables liees a l'ecriture de la bande histoire : phytrac.nc
-c
-c      INTEGER ecrit_tra
-c      SAVE ecrit_tra   
-      logical ok_sync
-      parameter (ok_sync = .true.)
-C
-C nature du traceur
-c
-      logical aerosol(nqmx)  ! Nature du traceur
-c                            ! aerosol(it) = true  => aerosol 
-c                            ! aerosol(it) = false => gaz 
-c                            ! nat_trac(it) = 1. aerosol
-      logical clsol(nqmx)    ! clsol(it) = true => CL sol calculee
-      save aerosol,clsol
-C
-C les traceurs
-C
-c===================
-c it--------indice de traceur
-c k,i---------indices long, vert
-c===================
-c Variables deja declarees dont on a besoin pour traceurs   
-c   k,i,it,tr_seri(klon,klev,nqmax),pplay(nlon,nlev), 
-      real zprof(klon,klev)
-c      real pzero,gamma
-c      parameter (pzero=85000.)
-c      parameter (gamma=5000.)
-      real deltatr(klon,klev,nqmax) ! ecart au profil de ref zprof
-      real tau             ! temps de relaxation vers le profil
-c tau pourra dependre de it      
-      parameter (tau=1.) ! duree de vie du compose en secondes 3.e10
-c======================================================================
-c
-c Declaration des procedures appelees
-c
-c--modif convection tiedtke
-      INTEGER i, k, it
-      INTEGER iq, iiq
-      REAL delp(klon,klev)
-c--end modif
-c
-c Variables liees a l'ecriture de la bande histoire physique
-c
-c Variables locales pour effectuer les appels en serie
-c----------------------------------------------------
-c
-      REAL d_tr(klon,klev), d_trs(klon) ! tendances de traceurs 
-      REAL d_tr_cl(klon,klev,nqmax) ! tendance de traceurs  couche limite
-      REAL d_tr_cv(klon,klev,nqmax) ! tendance de traceurs  conv pour chq traceur
-C
-      character*80 abort_message
-c
-c   Controles
-c-------------
-      logical first,couchelimite,convection
-      save first,couchelimite,convection
-c Olivia
-       data first,couchelimite,convection
-     s     /.true.,.false.,.false./
-
-c======================================================================
-         ps(:)=paprs(:,1)
-c---------
-c debutphy
-c---------
-         if (debutphy) then
-                 print*,"DEBUT PHYTRAC"
-C         
-c=============================================================
-c   Initialisation des traceurs
-c=============================================================
-c
-c Initialisation de la nature des traceurs
-c
-         DO it = 1, nqmax
-            aerosol(it) = .FALSE.  ! Tous les traceurs sont des gaz par defaut
-            clsol(it) = .FALSE.  ! Par defaut couche limite avec flux prescrit
-         ENDDO
-c
-c===========
-c definition de traceurs idealises
-c==========
-c
-c I) Declaration directe du traceur a altitude fixee
-c
-c a) traceur en carre OK
-c
-c         do i=1,klon
-c         tr_seri(i,:,1)=0.
-c        if ((xlat(i)>=0.).and.(xlat(i)<=-30.)) then
-c          if ((xlon(i)>=0.).and.(xlon(i)<=40.)) then
-c              tr_seri(i,10,1)=1.
-c          endif
-c        endif
-c      end do 
-c
-c b) traceur a une bande en latitudeOK
-c
-c        do i=1,klon
-c         tr_seri(i,:,1)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=60.)) then
-c              tr_seri(i,25,1)=1.
-c        endif
-c      end do  
-c
-c c) traceur a plusieurs bandes en latitude OK
-c
-c         do i=1,klon
-c        tr_seri(i,:,2)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,10,2)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,10,2)=1.
-c        endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,10,2)=1. 
-c        endif         
-c      end do 
-c
-c d) traceur a une bande en altitude OK
-c
-c       do k=1,klev+1
-c         tr_seri(:,k,1)=0.
-c         if ((pplay(klon/2,k)>=1.e5).and.(pplay(klon/2,k)<=1.e6)) then
-c             tr_seri(:,k,1)=1.
-c         endif
-c       end do 
-c
-c dbis) plusieurs traceurs a une bande en altitude OK
-c
-       do k=1,klev
-         tr_seri(:,k,1)=0.
-         if ((pplay(klon/2,k)>=9.e5).and.(pplay(klon/2,k)<=9.e6)) then
-             tr_seri(:,k,1)=1.
-         endif
-       end do 
-
-       do k=1,klev
-         tr_seri(:,k,2)=0.
-         if ((pplay(klon/2,k)>=1.e4).and.(pplay(klon/2,k)<=1.e5)) then
-             tr_seri(:,k,2)=1.
-         endif
-       end do 
-
-c      do k=1,klev
-c        tr_seri(:,k,3)=0.
-c        if ((pplay(klon/2,k)>=5.e1).and.(pplay(klon/2,k)<=5.e2)) then
-c            tr_seri(:,k,3)=1.
-c        endif
-c      end do 
-c       
-c e) plusieurs couches verticales de traceurs, a plusieurs bandes en latitude???
-c       
-c au sol
-c         do i=1,klon
-c        tr_seri(i,:,1)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,5,1)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,5,1)=1.
-c        endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,5,1)=1. 
-c        endif         
-c      end do 
-c 
-c         do i=1,klon
-c        tr_seri(i,:,2)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,10,2)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,10,2)=1.
-c      endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,10,2)=1. 
-c        endif         
-c      end do 
-c
-c         do i=1,klon
-c        tr_seri(i,:,3)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,30,3)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,30,3)=1.
-c        endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,30,3)=1. 
-c        endif         
-c      end do 
-c        
-c        do i=1,klon
-c        tr_seri(i,:,4)=0.
-c        if ((xlat(i)>=50.).and.(xlat(i)<=70.)) then
-c             tr_seri(i,45,4)=1.
-c        endif
-c        if ((xlat(i)>=-10.).and.(xlat(i)<=10.)) then
-c              tr_seri(i,45,4)=1.
-c        endif
-c
-c        if ((xlat(i)>=-70.).and.(xlat(i)<=-50.)) then
-c              tr_seri(i,45,4)=1. 
-c        endif         
-c      end do 
-c      
-c II) Declaration d'un profil vertical de traceur OK
-c 
-c      do i=1,klon
-c       do k=1,klev 
-c         zprof(i,k)=0.5*(1.+tanh((pplay(i,k)-pzero)/gamma))
-c--------x=alog10P+b
-c        zprof(i,k)=-8.79e-6*(log10(pplay(i,k)))+7.6e-5
-c        zprof(i,k)=8.79e-6*(log10(pplay(i,k)))-7.6e-5
-c--------alog10x=alog10P+b        
-c        zprof(i,k)=-0.31*(log10(pplay(i,k)))+5.2
-c        zprof(i,k)=-0.31*(log10(pplay(i,k)))-2.68
-c       enddo  
-c      enddo
-c
-c      do i=1,klon
-c       do k=1,klev 
-c         zprof(i,k)=0.5*(1.+tanh((pplay(i,k)-pzero)/gamma))
-c       enddo 
-c      enddo 
-c-------------
-c fin debutphy
-c-------------
-      ENDIF  ! fin debutphy 
-
-c======================================================================
-c Rappel vers un profil
-c======================================================================
-c         do it=1,nqmax-2
-c           do k=1,klev
-c            do i=1,klon
-c             deltatr(i,k,1) = 0.
-c             tr_seri(i,k,1) = 0.
-c             deltatr(i,k,1) = (-tr_seri(i,k,1)+zprof(i,k))/tau
-c             tr_seri(i,k,1) =  tr_seri(i,k,1) + deltatr(i,k,1)
-c            enddo
-c            enddo
-c         enddo
-
-c======================================================================
-c   Calcul de l'effet de la couche limite
-c======================================================================
-
-      if (couchelimite) then
-
-      DO k = 1, klev
-      DO i = 1, klon
-         delp(i,k) = paprs(i,k)-paprs(i,k+1)
-      ENDDO
-      ENDDO
-
-C maf modif pour tenir compte du cas rnpb + traceur
-      DO it=1, nqmax
-
-c     print *,'it',it,clsol(it)
-      if (clsol(it)) then  ! couche limite avec quantite dans le sol calculee
-
-      else ! couche limite avec flux prescrit
-
-Cmaf provisoire source / traceur a creer
-        DO i=1, klon
-          source(i) = 0.0 ! pas de source, pour l'instant
-        ENDDO
-C
-
-          CALL cltrac(pdtphys, coefh,t_seri,
-     s               tr_seri(1,1,it), source,
-     e               paprs, pplay, delp,
-     s               d_tr_cl(1,1,it))
-            DO k = 1, nlev
-               DO i = 1, klon
-                  tr_seri(i,k,it) = tr_seri(i,k,it) + d_tr_cl(i,k,it)
-               ENDDO
-            ENDDO
-Cmaf          WRITE(itn,'(i1)') it
-cmaf          CALL minmaxqfi(tr_seri(1,1,it),0.,1.e33,'cltracn it='//itn)
-      endif
-      ENDDO
-c
-      endif ! couche limite
-
-c=============================================================
-
-      RETURN
-      END
Index: trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.1mat
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.1mat	(revision 888)
+++ 	(revision )
@@ -1,189 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/radlwsw.F,v 1.2 2004/10/27 10:14:46 lmdzadmin Exp $
-!
-      SUBROUTINE radlwsw(dist, rmu0, fract, 
-     .                  paprs, pplay,tsol, t,
-     .                  heat,cool,radsol,
-     .                  topsw,toplw,solsw,sollw,
-     .                  sollwdown,
-     .                  lwnet, swnet)
-c      
-c======================================================================
-c Auteur(s): Z.X. Li (LMD/CNRS) date: 19960719
-c Objet: interface entre le modele et les rayonnements
-c Arguments:
-c dist-----input-R- distance astronomique terre-soleil
-c rmu0-----input-R- cosinus de l'angle zenithal
-c fract----input-R- duree d'ensoleillement normalisee
-c solaire--input-R- constante solaire (W/m**2) (dans clesphys.h)
-c paprs----input-R- pression a inter-couche (Pa)
-c pplay----input-R- pression au milieu de couche (Pa)
-c tsol-----input-R- temperature du sol (en K)
-c t--------input-R- temperature (K)
-c heat-----output-R- echauffement atmospherique (visible) (K/jour)
-c cool-----output-R- refroidissement dans l'IR (K/jour)
-c radsol---output-R- bilan radiatif net au sol (W/m**2) (+ vers le bas)
-c topsw----output-R- flux solaire net au sommet de l'atm. (+ vers le bas)
-c toplw----output-R- ray. IR net au sommet de l'atmosphere (+ vers le haut)
-c solsw----output-R- flux solaire net a la surface (+ vers le bas)
-c sollw----output-R- ray. IR net a la surface (+ vers le bas)
-c sollwdown-output-R- ray. IR descendant a la surface (+ vers le bas)
-c lwnet____output-R- flux IR net (+ vers le haut)
-c swnet____output-R- flux solaire net (+ vers le bas)
-c
-      
-c======================================================================
-      use dimphy
-      IMPLICIT none
-#include "dimensions.h"
-c
-      real rmu0(klon), fract(klon), dist
-#include "clesphys.h" 
-c
-      real paprs(klon,klev+1), pplay(klon,klev)
-      real tsol(klon)
-      real t(klon,klev)
-      real heat(klon,klev), cool(klon,klev)
-      real radsol(klon), topsw(klon), toplw(klon)
-      real solsw(klon), sollw(klon)
-      real sollwdown(klon)
-      REAL swnet(klon,kflev+1),lwnet(klon,kflev+1)
-c
-#include "YOMCST.h"
-c
-      INTEGER k, kk, i, j, nb_gr
-c
-      REAL   PSCT
-c
-      REAL   PDT0
-      REAL   PPSOL
-      REAL   PTL(kflev+1), PPB(kflev+1)
-      REAL   PTAVE(kflev)
-c
-      REAL   zfract, zrmu0, zdist
-c
-      REAL   zheat(kflev), zcool(kflev)
-      REAL   ZFSNET(KFLEV+1),ZFLNET(KFLEV+1)
-      REAL   ztopsw, ztoplw
-      REAL   zsolsw, zsollw
-cIM BEG
-      REAL   zsollwdown
-cIM END
-      REAL   zznormcp
-c
-      REAL   zx_alpha1, zx_alpha2
-c
-c-------------------------------------------
-      nb_gr = klon
-c-------------------------------------------
-c  Initialisations
-c-----------------
-      DO k = 1, klev
-      DO i = 1, klon
-         heat(i,k)=0.
-         cool(i,k)=0.
-      ENDDO
-      ENDDO
-c
-      zdist = dist
-c
-c     PRINT*,'IMradlwsw : solaire= ', solaire
-c     PSCT = solaire/zdist/zdist
-c
-c+++++++ BOUCLE SUR LA GRILLE +++++++++++++++++++++++++
-      DO 99999 j = 1, nb_gr
- 
-       DO k = 1, klev
-        zheat(k) = 0.0
-        zcool(k) = 0.0
-       ENDDO
-       DO k = 1, klev+1
-        ZFLNET(k) = 0.0
-        ZFSNET(k) = 0.0
-       ENDDO
-       ztopsw = 0.0
-       ztoplw = 0.0
-       zsolsw = 0.0
-       zsollw = 0.0
-       zsollwdown = 0.0
-      
-         zfract = fract(j)
-         zrmu0 = rmu0(j)
-         PPSOL = paprs(j,1)
-         zx_alpha1 = (paprs(j,1)-pplay(j,2)) 
-     .             / (pplay(j,1)-pplay(j,2))
-         zx_alpha2 = 1.0 - zx_alpha1
-         PTL(1) = t(j,1) * zx_alpha1 + t(j,2) * zx_alpha2
-         PTL(klev+1) = t(j,klev)
-         PDT0 = tsol(j) - PTL(1)
-      DO k = 2, kflev
-         PTL(k) = (t(j,k)+t(j,k-1))*0.5
-      ENDDO
-      DO k = 1, kflev
-         PTAVE(k) = t(j,k)
-      ENDDO
-c
-      DO k = 1, kflev
-         PPB(k) = paprs(j,k)/1.e5
-      ENDDO
-c     PPB(kflev+1) = pplay(j,kflev)/2.e5 ! pour eviter le 0. (=paprs(j,kflev+1))
-      PPB(kflev+1) = paprs(j,kflev)/1.e9 ! pour eviter le 0. (=paprs(j,kflev+1))
-c
-c======================================================================
-c LW call
-c---------
-      CALL LW_venus_ve(
-     .        PPB, PTAVE, tsol(j),
-     .        zcool,
-     .        ztoplw,zsollw,
-     .        zsollwdown,ZFLNET)
-
-c---------
-c SW call
-c---------
-      CALL SW_venus_dc(zrmu0, zfract,
-     S        PPB, 
-     S        zheat, 
-     S        ztopsw,zsolsw,ZFSNET)
-      
-c======================================================================
-         radsol(j) = zsolsw - zsollw  ! + vers bas
-         topsw(j) = ztopsw            ! + vers bas
-         toplw(j) = ztoplw            ! + vers haut
-         solsw(j) = zsolsw            ! + vers bas
-         sollw(j) = -zsollw           ! + vers bas
-         sollwdown(j) = zsollwdown    ! + vers bas
-
-         DO k = 1, kflev+1
-         lwnet  (j,k)   = ZFLNET(k)
-         swnet  (j,k)   = ZFSNET(k)
-         ENDDO
-
-      DO k = 1, kflev
-C        scale factor to take into account the difference between
-C        dry air and watter vapour scpecific heat capacity
-         zznormcp=1.0
-         heat (j,k) = zheat(k)/zznormcp
-         cool (j,k) = zcool(k)/zznormcp
-      ENDDO
-c
-99999 CONTINUE
-c+++++++ FIN BOUCLE SUR LA GRILLE +++++++++++++++++++++++++
-
-c tests
-
-c     j = klon/2
-c     j = 1
-c     print*,'mu0=',rmu0(j)
-c     print*,'   net flux vis   HEAT(K/day)'
-c     do k=1,kflev
-c     print*,k,ZFSNET(k),heat(j,k)*8.56548e-3
-c     enddo
-c     print*,'   net flux IR    COOL(K/day)'
-c     do k=1,kflev
-c     print*,k,ZFLNET(k),cool(j,k)*8.56548e-3
-c     enddo
-      
-      RETURN
-      END
-
Index: trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.F	(revision 892)
@@ -55,14 +55,14 @@
       real solsw(klon), sollw(klon)
       real sollwdown(klon)
-      REAL swnet(klon,kflev+1),lwnet(klon,kflev+1)
+      REAL swnet(klon,klev+1),lwnet(klon,klev+1)
 c
       INTEGER k, kk, i, j, nb_gr
 c
-      REAL   PPB(kflev+1)
+      REAL   PPB(klev+1)
 c
       REAL   zfract, zrmu0
 c
-      REAL   zheat(kflev), zcool(kflev)
-      REAL   ZFSNET(KFLEV+1),ZFLNET(KFLEV+1)
+      REAL   zheat(klev), zcool(klev)
+      REAL   ZFSNET(klev+1),ZFLNET(klev+1)
       REAL   ztopsw, ztoplw
       REAL   zsolsw, zsollw
@@ -71,10 +71,10 @@
 cIM END
       real,save,allocatable :: ksive(:,:,:,:) ! ksi matrixes in Vincent's file
-      real    psimap(0:kflev+1,0:kflev+1,klon)
-      real    deltapsimap(0:kflev+1,0:kflev+1,klon)
-      real    psi(0:kflev+1,0:kflev+1)
-      real    deltapsi(0:kflev+1,0:kflev+1)
+      real    psimap(0:klev+1,0:klev+1,klon)
+      real    deltapsimap(0:klev+1,0:klev+1,klon)
+      real    psi(0:klev+1,0:klev+1)
+      real    deltapsi(0:klev+1,0:klev+1)
       real    latdeg
-      real    pt0(klon,0:kflev+1)
+      real    pt0(klon,0:klev+1)
       real,save,allocatable :: ztop(:) ! in km
 
@@ -92,5 +92,5 @@
 
 c ---------- ksive --------------
-        allocate(ksive(0:kflev+1,0:kflev+1,nnuve,nbmat))
+        allocate(ksive(0:klev+1,0:klev+1,nnuve,nbmat))
         call load_ksi(ksive)
 c ---------- ztop --------------
@@ -122,5 +122,5 @@
             pt0(i,k) = t(i,k)
           ENDDO
-          pt0(i,kflev+1) = 0.
+          pt0(i,klev+1) = 0.
       ENDDO !i
 
@@ -154,10 +154,10 @@
          zrmu0 = rmu0(j)
  
-      DO k = 1, kflev+1
+      DO k = 1, klev+1
          PPB(k) = paprs(j,k)/1.e5
       ENDDO
  
-      DO k = 0,kflev+1
-      DO i = 0,kflev+1
+      DO k = 0,klev+1
+      DO i = 0,klev+1
         psi(i,k) = psimap(i,k,j) 
         deltapsi(i,k) = deltapsimap(i,k,j) 
@@ -190,10 +190,10 @@
          sollwdown(j) = zsollwdown    ! + vers bas
 
-         DO k = 1, kflev+1
+         DO k = 1, klev+1
          lwnet  (j,k)   = ZFLNET(k)
          swnet  (j,k)   = ZFSNET(k)
          ENDDO
 
-      DO k = 1, kflev
+      DO k = 1, klev
          heat (j,k) = zheat(k)
          cool (j,k) = zcool(k)
@@ -209,9 +209,9 @@
 c     print*,'mu0=',rmu0(j)
 c     print*,'   net flux vis   HEAT(K/day)'
-c     do k=1,kflev
+c     do k=1,klev
 c     print*,k,ZFSNET(k),heat(j,k)*8.56548e-3
 c     enddo
 c     print*,'   net flux IR    COOL(K/day)'
-c     do k=1,kflev
+c     do k=1,klev
 c     print*,k,ZFLNET(k),cool(j,k)*8.56548e-3
 c     enddo
Index: trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.NewtonCool
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.NewtonCool	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.NewtonCool	(revision 892)
@@ -53,5 +53,5 @@
       real solsw(klon), sollw(klon)
       real sollwdown(klon)
-      REAL swnet(klon,kflev+1),lwnet(klon,kflev+1)
+      REAL swnet(klon,klev+1),lwnet(klon,klev+1)
 c
       INTEGER i,j,k
@@ -138,10 +138,10 @@
          sollwdown(j) = 0.        ! + vers bas
 
-        DO k = 1, kflev+1
+        DO k = 1, klev+1
          lwnet  (j,k)   = 0.
          swnet  (j,k)   = 0.
         ENDDO
 
-        DO k = 1, kflev
+        DO k = 1, klev
          heat (j,k) = dTsdt(k)*dureejour ! K/Venusday
          cool (j,k) = 0.
Index: trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.multimat
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.multimat	(revision 888)
+++ 	(revision )
@@ -1,221 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/radlwsw.F,v 1.2 2004/10/27 10:14:46 lmdzadmin Exp $
-!
-      SUBROUTINE radlwsw(dist, rmu0, fract, 
-     .                  paprs, pplay,tsol, t,
-     .                  heat,cool,radsol,
-     .                  topsw,toplw,solsw,sollw,
-     .                  sollwdown,
-     .                  lwnet, swnet)
-c      
-c======================================================================
-c Auteur(s): Z.X. Li (LMD/CNRS) date: 19960719
-c Objet: interface entre le modele et les rayonnements
-c Arguments:
-c dist-----input-R- distance astronomique terre-soleil
-c rmu0-----input-R- cosinus de l'angle zenithal
-c fract----input-R- duree d'ensoleillement normalisee
-c solaire--input-R- constante solaire (W/m**2) (dans clesphys.h)
-c paprs----input-R- pression a inter-couche (Pa)
-c pplay----input-R- pression au milieu de couche (Pa)
-c tsol-----input-R- temperature du sol (en K)
-c t--------input-R- temperature (K)
-c heat-----output-R- echauffement atmospherique (visible) (K/jour)
-c cool-----output-R- refroidissement dans l'IR (K/jour)
-c radsol---output-R- bilan radiatif net au sol (W/m**2) (+ vers le bas)
-c topsw----output-R- flux solaire net au sommet de l'atm. (+ vers le bas)
-c toplw----output-R- ray. IR net au sommet de l'atmosphere (+ vers le haut)
-c solsw----output-R- flux solaire net a la surface (+ vers le bas)
-c sollw----output-R- ray. IR net a la surface (+ vers le bas)
-c sollwdown-output-R- ray. IR descendant a la surface (+ vers le bas)
-c lwnet____output-R- flux IR net (+ vers le haut)
-c swnet____output-R- flux solaire net (+ vers le bas)
-c
-      
-c MODIFS pour multimatrices ksi SPECIFIQUE VENUS
-c   S. Lebonnois    20/12/2006
-c   corrections     13/07/2007
-
-c======================================================================
-      use dimphy
-      USE comgeomphy
-      IMPLICIT none
-#include "dimensions.h"
-#include "YOMCST.h"
-#include "clesphys.h" 
-#include "comcstVE.h"
-c
-      real rmu0(klon), fract(klon), dist
-c
-      real paprs(klon,klev+1), pplay(klon,klev)
-      real tsol(klon)
-      real t(klon,klev)
-      real heat(klon,klev), cool(klon,klev)
-      real radsol(klon), topsw(klon), toplw(klon)
-      real solsw(klon), sollw(klon)
-      real sollwdown(klon)
-      REAL swnet(klon,kflev+1),lwnet(klon,kflev+1)
-c
-      INTEGER k, kk, i, j, nb_gr
-c
-      REAL   PPB(kflev+1)
-c
-      REAL   zfract, zrmu0
-c
-      REAL   zheat(kflev), zcool(kflev)
-      REAL   ZFSNET(KFLEV+1),ZFLNET(KFLEV+1)
-      REAL   ztopsw, ztoplw
-      REAL   zsolsw, zsollw
-cIM BEG
-      REAL   zsollwdown
-cIM END
-      real   ksive(0:kflev+1,0:kflev+1,nnuve,nbmat)  ! ksi matrixes in Vincent's file
-      real    psimap(0:kflev+1,0:kflev+1,klon)
-      real    deltapsimap(0:kflev+1,0:kflev+1,klon)
-      real    psi(0:kflev+1,0:kflev+1)
-      real    deltapsi(0:kflev+1,0:kflev+1)
-      real    latdeg,ztop(klon) ! in km
-      real    pt0(klon,0:kflev+1)
-
-      save    ksive,ztop
-
-      logical firstcall
-      data    firstcall/.true./
-      save    firstcall
-      
-c-------------------------------------------
-      nb_gr = klon
-c-------------------------------------------
-c  Initialisations
-c-----------------
-
-      if (firstcall) then
-        call load_ksi(ksive)
-
-c ---------- ztop --------------
-        DO i = 1, klon
-             ztop(i) = 70.
-        ENDDO !i
-
-c ztop: d'apres fit à figure 16 du papier Zavosa et al (tmp) traitant des
-c       donnees Venera
-c       DO i = 1, klon
-c         latdeg = abs(rlatd(i))
-c         if (latdeg.lt.15) then
-c            ztop(i) = 70.
-c         elseif (latdeg.lt.50) then
-c            ztop(i) = 63.95+6*cos((latdeg-15)*RPI/2./50.)
-c         else 
-c            ztop(i) = min(63.95+6*cos((latdeg-15)*RPI/2./50.),
-c    .                     63.95-5.9*sin((latdeg-60)*RPI/2/30))
-c         endif 
-c       print*,'lat(',i,')=',latdeg,'  ztop=',ztop(i)
-c       ENDDO !i
-c ---------- ztop --------------
-
-      endif ! firstcall
-
-      DO i = 1, klon
-          pt0(i,0)  = tsol(i)
-          DO k = 1, klev
-            pt0(i,k) = t(i,k)
-          ENDDO
-          pt0(i,kflev+1) = 0.
-      ENDDO !i
-
-      call load_psi(paprs(:,1),ztop,ksive,pt0,psimap,deltapsimap)
-
-      DO k = 1, klev
-      DO i = 1, klon
-         heat(i,k)=0.
-         cool(i,k)=0.
-      ENDDO
-      ENDDO
-c
-c+++++++ BOUCLE SUR LA GRILLE +++++++++++++++++++++++++
-      DO 99999 j = 1, nb_gr
- 
-       DO k = 1, klev
-        zheat(k) = 0.0
-        zcool(k) = 0.0
-       ENDDO
-       DO k = 1, klev+1
-        ZFLNET(k) = 0.0
-        ZFSNET(k) = 0.0
-       ENDDO
-       ztopsw = 0.0
-       ztoplw = 0.0
-       zsolsw = 0.0
-       zsollw = 0.0
-       zsollwdown = 0.0
-      
-         zfract = fract(j)
-         zrmu0 = rmu0(j)
- 
-      DO k = 1, kflev+1
-         PPB(k) = paprs(j,k)/1.e5
-      ENDDO
- 
-      DO k = 0,kflev+1
-      DO i = 0,kflev+1
-        psi(i,k) = psimap(i,k,j) 
-        deltapsi(i,k) = deltapsimap(i,k,j) 
-      ENDDO
-      ENDDO
-       
-c======================================================================
-c LW call
-c---------
-      CALL LW_venus_ve(
-     .        PPB,t(j,:),psi,deltapsi,
-     .        zcool,
-     .        ztoplw,zsollw,
-     .        zsollwdown,ZFLNET)
-
-c---------
-c SW call
-c---------
-      CALL SW_venus_dc(zrmu0, zfract,
-     S        PPB,t(j,:), 
-     S        zheat, 
-     S        ztopsw,zsolsw,ZFSNET)
-      
-c======================================================================
-         radsol(j) = zsolsw - zsollw  ! + vers bas
-         topsw(j) = ztopsw            ! + vers bas
-         toplw(j) = ztoplw            ! + vers haut
-         solsw(j) = zsolsw            ! + vers bas
-         sollw(j) = -zsollw           ! + vers bas
-         sollwdown(j) = zsollwdown    ! + vers bas
-
-         DO k = 1, kflev+1
-         lwnet  (j,k)   = ZFLNET(k)
-         swnet  (j,k)   = ZFSNET(k)
-         ENDDO
-
-      DO k = 1, kflev
-         heat (j,k) = zheat(k)
-         cool (j,k) = zcool(k)
-      ENDDO
-c
-99999 CONTINUE
-c+++++++ FIN BOUCLE SUR LA GRILLE +++++++++++++++++++++++++
-
-c tests
-
-c     j = klon/2
-c     j = 1
-c     print*,'mu0=',rmu0(j)
-c     print*,'   net flux vis   HEAT(K/day)'
-c     do k=1,kflev
-c     print*,k,ZFSNET(k),heat(j,k)*8.56548e-3
-c     enddo
-c     print*,'   net flux IR    COOL(K/day)'
-c     do k=1,kflev
-c     print*,k,ZFLNET(k),cool(j,k)*8.56548e-3
-c     enddo
-
-      firstcall = .false.
-      RETURN
-      END
-
Index: trunk/LMDZ.VENUS/libf/phyvenus/sw_venus_dc.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/sw_venus_dc.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/sw_venus_dc.F	(revision 892)
@@ -34,13 +34,13 @@
       REAL   PRMU0  ! COSINE OF ZENITHAL ANGLE
       REAL   PFRAC  ! fraction de la journee
-      REAL   PPB(KFLEV+1)  ! inter-couches PRESSURE (bar)
-      REAL   pt(kflev)     ! mid-layer temperature
+      REAL   PPB(klev+1)  ! inter-couches PRESSURE (bar)
+      REAL   pt(klev)     ! mid-layer temperature
 C
 c output
 
-      REAL   PHEAT(KFLEV) ! SHORTWAVE HEATING (K/VENUSDAY) within each layer
+      REAL   PHEAT(klev) ! SHORTWAVE HEATING (K/VENUSDAY) within each layer
       REAL   PTOPSW       ! SHORTWAVE FLUX AT T.O.A. (net)
       REAL   PSOLSW       ! SHORTWAVE FLUX AT SURFACE (net)
-      REAL   ZFSNET(KFLEV+1) ! net solar flux at ppb levels
+      REAL   ZFSNET(klev+1) ! net solar flux at ppb levels
 
 C
@@ -114,5 +114,5 @@
 c      read(12,*) nullchar
 c
-c       do j=1,kflev+1
+c       do j=1,klev+1
 c          read(12,*) zlup,zldn,zsolVE(j)
 c       enddo
@@ -182,5 +182,5 @@
 c ---------------
 
-      do j=1,kflev+1
+      do j=1,klev+1
         nl0 = 2
         do i=1,nldc
@@ -212,5 +212,5 @@
 c      Fichiers de Vincent
 c -----------------------------
-c     do j=1,kflev+1
+c     do j=1,klev+1
 c       ZFSNET(j)=zsolVE(j)
 c     enddo
@@ -218,5 +218,5 @@
 c --------  FIN TEST ----------
 
-      PTOPSW = ZFSNET(kflev+1)
+      PTOPSW = ZFSNET(klev+1)
       PSOLSW = ZFSNET(1) 
       
@@ -229,5 +229,5 @@
 c              /cp  (J/kg/K) 
 
-      do j=1,kflev
+      do j=1,klev
 ! ADAPTATION GCM POUR CP(T)
         PHEAT(j) = (ZFSNET(j+1)-ZFSNET(j))
Index: trunk/LMDZ.VENUS/libf/phyvenus/ustarhb.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/ustarhb.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/ustarhb.F	(revision 892)
@@ -41,5 +41,5 @@
         zxu = u(i,1)*zx_alf1+u(i,2)*zx_alf2
         zxv = v(i,1)*zx_alf1+v(i,2)*zx_alf2
-        zxmod = 1.0+SQRT(zxu**2+zxv**2)
+        zxmod = SQRT(zxu**2+zxv**2)
         taux = zxu *zxmod*cd_m(i)
         tauy = zxv *zxmod*cd_m(i)
Index: trunk/LMDZ.VENUS/libf/phyvenus/write_field_phy.F90
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/write_field_phy.F90	(revision 892)
+++ trunk/LMDZ.VENUS/libf/phyvenus/write_field_phy.F90	(revision 892)
@@ -0,0 +1,36 @@
+!
+! $Header$
+!
+MODULE write_field_phy
+
+  CONTAINS 
+ 
+    SUBROUTINE WriteField_phy(name,Field,ll)
+    USE dimphy
+    USE mod_phys_lmdz_para
+    USE mod_grid_phy_lmdz
+    USE Write_Field
+    
+    IMPLICIT NONE
+    include 'dimensions.h'
+    include 'paramet.h'
+
+    character(len=*)   :: name
+    INTEGER :: ll
+    real, dimension(klon_omp,ll) :: Field
+    real,save,allocatable :: Field_tmp(:,:)
+    real, dimension(klon_glo,ll):: New_Field
+    real, dimension(iim,jjp1,ll):: Field_2d
+
+    CALL Gather(Field,New_Field)
+!$OMP MASTER
+    IF (is_mpi_root) THEN	
+      CALL Grid1Dto2D_glo(New_Field,Field_2D)
+      CALL WriteField(name,Field_2d)
+    ENDIF
+!$OMP END MASTER
+
+  
+   END SUBROUTINE WriteField_phy
+ 
+ END MODULE write_field_phy
Index: trunk/LMDZ.VENUS/libf/phyvenus/write_histday.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/write_histday.h	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/write_histday.h	(revision 892)
@@ -3,77 +3,54 @@
 !
       IF (ok_journe) THEN
-c
-      ndex2d = 0
-      ndex3d = 0
-      zx_tmp_2d = 0.
-      zx_tmp_3d = 0.
-      zx_tmp_fi2d=0.
-      zx_tmp_fi3d=0.
 
-c
          zsto = dtime
          zout = dtime * REAL(ecrit_day)
          itau_w = itau_phy + itap
 
-c
 c-------------------------------------------------------
       IF(lev_histday.GE.1) THEN
-c
+
 ccccccccccccc 2D fields, basics
-c
-      i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
-      CALL histwrite(nid_day,"phis",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-C
-      i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,airephy,zx_tmp_2d)
-      CALL histwrite(nid_day,"aire",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ftsol,zx_tmp_2d)
-      CALL histwrite(nid_day,"tsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = paprs(i,1)
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"psol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ue,zx_tmp_2d)
-      CALL histwrite(nid_day,"ue",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ve,zx_tmp_2d)
-      CALL histwrite(nid_day,"ve",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+
+      call histwrite_phy(nid_day,.false.,"phis",itau_w,pphis)
+      call histwrite_phy(nid_day,.false.,"aire",itau_w,airephy)
+      call histwrite_phy(nid_day,.false.,"tsol",itau_w,ftsol)
+      call histwrite_phy(nid_day,.false.,"psol",itau_w,paprs(:,1))
+c     call histwrite_phy(nid_day,.false.,"ue",itau_w,ue)
+c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
+c     call histwrite_phy(nid_day,.false.,"ve",itau_w,-1.*ve)
+c     call histwrite_phy(nid_day,.false.,"cdragh",itau_w,cdragh)
+c     call histwrite_phy(nid_day,.false.,"cdragm",itau_w,cdragm)
+
       ENDIF !lev_histday.GE.1
-c
+
 c-------------------------------------------------------
       IF(lev_histday.GE.2) THEN
-c
+
 ccccccccccccc 3D fields, basics
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      CALL histwrite(nid_day,"temp",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
-      CALL histwrite(nid_day,"pres",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
-      CALL histwrite(nid_day,"geop",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      CALL histwrite(nid_day,"vitu",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
-      CALL histwrite(nid_day,"vitv",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
-      CALL histwrite(nid_day,"vitw",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+
+      call histwrite_phy(nid_day,.false.,"temp",itau_w,t_seri)
+      call histwrite_phy(nid_day,.false.,"pres",itau_w,pplay)
+      call histwrite_phy(nid_day,.false.,"geop",itau_w,zphi)
+      call histwrite_phy(nid_day,.false.,"vitu",itau_w,u_seri)
+c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
+      call histwrite_phy(nid_day,.false.,"vitv",itau_w,-1.*v_seri)
+      call histwrite_phy(nid_day,.false.,"vitw",itau_w,omega)
+c en (m/s)/s      
+      call histwrite_phy(nid_day,.false.,"dudyn",itau_w,d_u_dyn)
+c en (m/s)/s      
+      call histwrite_phy(nid_day,.false.,"duvdf",itau_w,d_u_vdf)
+c     call histwrite_phy(nid_day,.false.,"mang",itau_w,mang)
+c     call histwrite_phy(nid_day,.false.,"Kz",itau_w,ycoefh)
+
+c plusieurs traceurs
+       IF (iflag_trac.eq.1) THEN
+         DO iq=1,nqmax
+       call histwrite_phy(nid_day,.false.,tname(iq),itau_w,qx(:,:,iq))
+         ENDDO
+       ENDIF
+
+      call histwrite_phy(nid_day,.false.,"tops",itau_w,topsw)
+
       ENDIF !lev_histday.GE.2
 c
@@ -82,138 +59,59 @@
 c
 cccccccccccccccccc  Radiative transfer
-c
+
 c 2D
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw,zx_tmp_2d)
-      CALL histwrite(nid_day,"tops",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
-      CALL histwrite(nid_day,"topl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
-      CALL histwrite(nid_day,"sols",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
-      CALL histwrite(nid_day,"soll",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+
+      call histwrite_phy(nid_day,.false.,"topl",itau_w,toplw)
+      call histwrite_phy(nid_day,.false.,"sols",itau_w,solsw)
+      call histwrite_phy(nid_day,.false.,"soll",itau_w,sollw)
+
 c 3D
-c
-      zx_tmp_fi3d(1:klon,1:klev)=swnet(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_day,"SWnet",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zx_tmp_fi3d(1:klon,1:klev)=lwnet(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_day,"LWnet",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+
+      call histwrite_phy(nid_day,.false.,"SWnet",itau_w,swnet)
+      call histwrite_phy(nid_day,.false.,"LWnet",itau_w,lwnet)
+c     call histwrite_phy(nid_day,.false.,"fluxvdf",itau_w,fluxt)
+c     call histwrite_phy(nid_day,.false.,"fluxdyn",itau_w,flux_dyn)
+c     call histwrite_phy(nid_day,.false.,"fluxajs",itau_w,flux_ajs)
+c     call histwrite_phy(nid_day,.false.,"fluxec",itau_w,flux_ec)
+
       ENDIF !lev_histday.GE.3
 c
 c-------------------------------------------------------
       IF(lev_histday.GE.4) THEN
-c
+
 c en K/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_dyn, zx_tmp_3d)
-      CALL histwrite(nid_day,"dtdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_day,.false.,"dtdyn",itau_w,d_t_dyn)
 c en K/s      
-c      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t, zx_tmp_3d)
-c      CALL histwrite(nid_day,"dtphy",itau_w,zx_tmp_3d,
-c     .                                   iim*jjmp1*klev,ndex3d)
-c
+c     call histwrite_phy(nid_day,.false.,"dtphy",itau_w,d_t)
 c en K/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,d_t_vdf,zx_tmp_3d)
-      CALL histwrite(nid_day,"dtvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_day,.false.,"dtvdf",itau_w,d_t_vdf)
 c en K/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,d_t_ajs,zx_tmp_3d)
-      CALL histwrite(nid_day,"dtajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_day,.false.,"dtajs",itau_w,d_t_ajs)
 c K/day ==> K/s
-      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY 
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_day,"dtswr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_day,.false.,"dtswr",itau_w,heat/RDAY)
 c K/day ==> K/s      
-      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_day,"dtlwr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+      call histwrite_phy(nid_day,.false.,"dtlwr",itau_w,-1.*cool/RDAY)
 c en K/s      
-c     zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-c     CALL histwrite(nid_day,"dtec",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+c     call histwrite_phy(nid_day,.false.,"dtec",itau_w,d_t_ec)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_dyn, zx_tmp_3d)
-      CALL histwrite(nid_day,"dudyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_day,.false.,"duajs",itau_w,d_u_ajs)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_vdf, zx_tmp_3d)
-      CALL histwrite(nid_day,"duvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_day,.false.,"dugwo",itau_w,d_u_oro)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_ajs, zx_tmp_3d)
-      CALL histwrite(nid_day,"duajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_day,.false.,"dugwno",itau_w,d_u_hin)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oro, zx_tmp_3d)
-      CALL histwrite(nid_day,"dugwo",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_hin, zx_tmp_3d)
-      CALL histwrite(nid_day,"dugwno",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-c en (m/s)/s      
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
 c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-c     zx_tmp_3d=-1.*zx_tmp_3d
-c     CALL histwrite(nid_day,"dvvdf",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+c     call histwrite_phy(nid_day,.false.,"dvvdf",itau_w,-1.*d_v_vdf)
+
       ENDIF !lev_histday.GE.4
 c
 c-------------------------------------------------------
       IF(lev_histday.GE.5) THEN
-c
-      IF (nqmax.GE.3) THEN
-        DO iq=1,nqmax-2
-         IF (iq.LE.99) THEN
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,iq+2), zx_tmp_3d)
-      WRITE(str2,'(i2.2)') iq
-      CALL histwrite(nid_day,"trac"//str2,itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-         ELSE
-      PRINT*, "Trop de traceurs"
-      CALL abort
-         ENDIF
-        ENDDO
-      ENDIF
-c
-c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fluxu , zx_tmp_2d)
-c      CALL histwrite(nid_day,"taux_",itau_w,
-c    $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c      
-c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fluxv , zx_tmp_2d)
-c      CALL histwrite(nid_day,"tauy_",itau_w,
-c    $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
-c     CALL histwrite(nid_day,"cdrm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
-c     CALL histwrite(nid_day,"cdrh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+
+c     call histwrite_phy(nid_day,.false.,"taux_",itau_w,fluxu)
+c     call histwrite_phy(nid_day,.false.,"tauy_",itau_w,fluxv)
+c     call histwrite_phy(nid_day,.false.,"cdrm",itau_w,cdragm)
+c     call histwrite_phy(nid_day,.false.,"cdrh",itau_w,cdragh)
+
       ENDIF !lev_histday.GE.5
 c-------------------------------------------------------
Index: trunk/LMDZ.VENUS/libf/phyvenus/write_histhf.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/write_histhf.h	(revision 888)
+++ 	(revision )
@@ -1,23 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/write_histhf.h,v 1.3 2005/02/24 09:58:18 fairhead Exp $
-!
-      if (ok_hf) then
-
-c   Comprendre comment marche el i=nint(zout/zsto)
-c
-c     print*,'ACRITURE HF !!! ACRITURE HF !!! ACRITURE HF !!! '
-      ndex2d = 0
-      ndex3d = 0
-c
-      zsto = dtime
-      zout = dtime * ecrit_hf
-      itau_w = itau_phy + itap
-c
-      IF(lev_histhf.GE.1) THEN
-c
-      i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
-      z4_tmp_2d=zx_tmp_2d
-      CALL histwrite(nid_hf,"phis",i,z4_tmp_2d,iim*jjmp1,ndex2d)
- 
-      endif
Index: trunk/LMDZ.VENUS/libf/phyvenus/write_histhf3d.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/write_histhf3d.h	(revision 888)
+++ 	(revision )
@@ -1,46 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/write_histhf3d.h,v 1.1.1.1 2004/05/19 12:53:08 lmdzadmin Exp $
-!
-c     if (ok_hf) then
-
-c   Comprendre comment marche el i=nint(zout/zsto)
-c
-c     print*,'ACRITURE HF !!! ACRITURE HF !!! ACRITURE HF !!! '
-      ndex2d = 0
-      ndex3d = 0
-c
-      zsto = dtime
-      zout = dtime * ecrit_hf
-      itau_w = itau_phy + itap
-c
-c     IF(lev_histhf.GE.1) THEN
-c
-c Champs 3D:
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      z4_tmp_3d=zx_tmp_3d
-      CALL histwrite(nid_hf3d,"temp",itau_w,z4_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
-      z4_tmp_3d=zx_tmp_3d
-      CALL histwrite(nid_hf3d,"ovap",itau_w,z4_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      z4_tmp_3d=zx_tmp_3d
-      CALL histwrite(nid_hf3d,"vitu",itau_w,z4_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
-      z4_tmp_3d=zx_tmp_3d
-      CALL histwrite(nid_hf3d,"vitv",itau_w,z4_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-c     ENDIF !lev_histhf.GE.1
-c
-      if (ok_sync) then
-        call histsync(nid_hf3d)
-      endif
-
-c     endif
Index: trunk/LMDZ.VENUS/libf/phyvenus/write_histins.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/write_histins.h	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/write_histins.h	(revision 892)
@@ -3,261 +3,121 @@
 !
       IF (ok_instan) THEN
-c
-      ndex2d = 0
-      ndex3d = 0
-      zx_tmp_2d = 0.
-      zx_tmp_3d = 0.
-      zx_tmp_fi2d=0.
-      zx_tmp_fi3d=0.
-c
+
          zsto = dtime * ecrit_ins
          zout = dtime * ecrit_ins
          itau_w = itau_phy + itap
 
-c
 c-------------------------------------------------------
       IF(lev_histday.GE.1) THEN
-c
+
 ccccccccccccc 2D fields, basics
-c
-      i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
-      CALL histwrite(nid_ins,"phis",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-C
-      i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,airephy,zx_tmp_2d)
-      CALL histwrite(nid_ins,"aire",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ftsol,zx_tmp_2d)
-      CALL histwrite(nid_ins,"tsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = paprs(i,1)
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_ins,"psol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, ue,zx_tmp_2d)
-c     CALL histwrite(nid_ins,"ue",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, ve,zx_tmp_2d)
+
+      call histwrite_phy(nid_ins,.false.,"phis",itau_w,pphis)
+      call histwrite_phy(nid_ins,.false.,"aire",itau_w,airephy)
+      call histwrite_phy(nid_ins,.false.,"tsol",itau_w,ftsol)
+      call histwrite_phy(nid_ins,.false.,"psol",itau_w,paprs(:,1))
+c     call histwrite_phy(nid_ins,.false.,"ue",itau_w,ue)
 c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-c     zx_tmp_2d=-1.*zx_tmp_2d
-c     CALL histwrite(nid_ins,"ve",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
-      CALL histwrite(nid_ins,"cdragh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
-      CALL histwrite(nid_ins,"cdragm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+c     call histwrite_phy(nid_ins,.false.,"ve",itau_w,-1.*ve)
+c     call histwrite_phy(nid_ins,.false.,"cdragh",itau_w,cdragh)
+c     call histwrite_phy(nid_ins,.false.,"cdragm",itau_w,cdragm)
+
       ENDIF !lev_histday.GE.1
-c
+
 c-------------------------------------------------------
       IF(lev_histday.GE.2) THEN
-c
+
 ccccccccccccc 3D fields, basics
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      CALL histwrite(nid_ins,"temp",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
-      CALL histwrite(nid_ins,"pres",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
-      CALL histwrite(nid_ins,"geop",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      CALL histwrite(nid_ins,"vitu",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
+
+      call histwrite_phy(nid_ins,.false.,"temp",itau_w,t_seri)
+      call histwrite_phy(nid_ins,.false.,"pres",itau_w,pplay)
+      call histwrite_phy(nid_ins,.false.,"geop",itau_w,zphi)
+      call histwrite_phy(nid_ins,.false.,"vitu",itau_w,u_seri)
 c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-      zx_tmp_3d=-1.*zx_tmp_3d
-      CALL histwrite(nid_ins,"vitv",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
-      CALL histwrite(nid_ins,"vitw",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"vitv",itau_w,-1.*v_seri)
+      call histwrite_phy(nid_ins,.false.,"vitw",itau_w,omega)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_dyn, zx_tmp_3d)
-      CALL histwrite(nid_ins,"dudyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"dudyn",itau_w,d_u_dyn)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_vdf, zx_tmp_3d)
-      CALL histwrite(nid_ins,"duvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, mang, zx_tmp_3d)
-c     CALL histwrite(nid_ins,"mang",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, ycoefh, zx_tmp_3d)
-      CALL histwrite(nid_ins,"Kz",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"duvdf",itau_w,d_u_vdf)
+c     call histwrite_phy(nid_ins,.false.,"mang",itau_w,mang)
+c     call histwrite_phy(nid_ins,.false.,"Kz",itau_w,ycoefh)
+
 c plusieurs traceurs
        IF (iflag_trac.eq.1) THEN
          DO iq=1,nqmax
-          IF (iq.LE.99) THEN
-       CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,iq), zx_tmp_3d)
-       WRITE(str2,'(i2.2)') iq
-       CALL histwrite(nid_ins,tname(iq),itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-          ELSE
-       PRINT*, "Trop de traceurs"
-       CALL abort
-          ENDIF
+       call histwrite_phy(nid_ins,.false.,tname(iq),itau_w,qx(:,:,iq))
          ENDDO
        ENDIF
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw,zx_tmp_2d)
-      CALL histwrite(nid_ins,"tops",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+
+      call histwrite_phy(nid_ins,.false.,"tops",itau_w,topsw)
+
       ENDIF !lev_histday.GE.2
-c
+
 c-------------------------------------------------------
       IF(lev_histday.GE.3) THEN
-c
+
 cccccccccccccccccc  Radiative transfer
-c
+
 c 2D
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
-      CALL histwrite(nid_ins,"topl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
-      CALL histwrite(nid_ins,"sols",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
-      CALL histwrite(nid_ins,"soll",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+
+      call histwrite_phy(nid_ins,.false.,"topl",itau_w,toplw)
+      call histwrite_phy(nid_ins,.false.,"sols",itau_w,solsw)
+      call histwrite_phy(nid_ins,.false.,"soll",itau_w,sollw)
+
 c 3D
-c
-      zx_tmp_fi3d(1:klon,1:klev)=swnet(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_ins,"SWnet",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zx_tmp_fi3d(1:klon,1:klev)=lwnet(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_ins,"LWnet",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zx_tmp_fi3d(1:klon,1:klev)=fluxt(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_ins,"fluxvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zx_tmp_fi3d(1:klon,1:klev)=flux_dyn(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_ins,"fluxdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zx_tmp_fi3d(1:klon,1:klev)=flux_ajs(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_ins,"fluxajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-c     zx_tmp_fi3d(1:klon,1:klev)=flux_ec(1:klon,1:klev)
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-c     CALL histwrite(nid_ins,"fluxec",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+
+      call histwrite_phy(nid_ins,.false.,"SWnet",itau_w,swnet)
+      call histwrite_phy(nid_ins,.false.,"LWnet",itau_w,lwnet)
+c     call histwrite_phy(nid_ins,.false.,"fluxvdf",itau_w,fluxt)
+c     call histwrite_phy(nid_ins,.false.,"fluxdyn",itau_w,flux_dyn)
+c     call histwrite_phy(nid_ins,.false.,"fluxajs",itau_w,flux_ajs)
+c     call histwrite_phy(nid_ins,.false.,"fluxec",itau_w,flux_ec)
+
       ENDIF !lev_histday.GE.3
-c
+
 c-------------------------------------------------------
       IF(lev_histday.GE.4) THEN
-c
+
 c en K/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_dyn, zx_tmp_3d)
-      CALL histwrite(nid_ins,"dtdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"dtdyn",itau_w,d_t_dyn)
 c en K/s      
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t, zx_tmp_3d)
-c     CALL histwrite(nid_ins,"dtphy",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+c     call histwrite_phy(nid_ins,.false.,"dtphy",itau_w,d_t)
 c en K/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,d_t_vdf,zx_tmp_3d)
-      CALL histwrite(nid_ins,"dtvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"dtvdf",itau_w,d_t_vdf)
 c en K/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,d_t_ajs,zx_tmp_3d)
-      CALL histwrite(nid_ins,"dtajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"dtajs",itau_w,d_t_ajs)
 c K/day ==> K/s
-      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY 
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_ins,"dtswr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"dtswr",itau_w,heat/RDAY)
 c K/day ==> K/s      
-      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_ins,"dtlwr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+      call histwrite_phy(nid_ins,.false.,"dtlwr",itau_w,-1.*cool/RDAY)
 c en K/s      
-c     zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-c     CALL histwrite(nid_ins,"dtec",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+c     call histwrite_phy(nid_ins,.false.,"dtec",itau_w,d_t_ec)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_ajs, zx_tmp_3d)
-      CALL histwrite(nid_ins,"duajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"duajs",itau_w,d_u_ajs)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oro, zx_tmp_3d)
-      CALL histwrite(nid_ins,"dugwo",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"dugwo",itau_w,d_u_oro)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_hin, zx_tmp_3d)
-      CALL histwrite(nid_ins,"dugwno",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_ins,.false.,"dugwno",itau_w,d_u_hin)
 c en (m/s)/s      
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
 c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-c     zx_tmp_3d=-1.*zx_tmp_3d
-c     CALL histwrite(nid_ins,"dvvdf",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+c     call histwrite_phy(nid_ins,.false.,"dvvdf",itau_w,-1.*d_v_vdf)
+
       ENDIF !lev_histday.GE.4
-c
+
 c-------------------------------------------------------
        IF(lev_histday.GE.5) THEN
-c
-c
-c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fluxu , zx_tmp_2d)
-c      CALL histwrite(nid_ins,"taux_",itau_w,
-c    $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c      
-c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fluxv , zx_tmp_2d)
-c      CALL histwrite(nid_ins,"tauy_",itau_w,
-c    $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
-c     CALL histwrite(nid_ins,"cdrm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
-c     CALL histwrite(nid_ins,"cdrh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+
+c     call histwrite_phy(nid_ins,.false.,"taux_",itau_w,fluxu)
+c     call histwrite_phy(nid_ins,.false.,"tauy_",itau_w,fluxv)
+c     call histwrite_phy(nid_ins,.false.,"cdrm",itau_w,cdragm)
+c     call histwrite_phy(nid_ins,.false.,"cdrh",itau_w,cdragh)
+
       ENDIF !lev_histday.GE.5
 c-------------------------------------------------------
-c
+
       if (ok_sync) then
         call histsync(nid_ins)
       endif
+
       ENDIF
Index: trunk/LMDZ.VENUS/libf/phyvenus/write_histmth.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/write_histmth.h	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/write_histmth.h	(revision 892)
@@ -3,11 +3,4 @@
 !
       IF (ok_mensuel) THEN
-c
-      ndex2d = 0
-      ndex3d = 0
-      zx_tmp_2d = 0.
-      zx_tmp_3d = 0.
-      zx_tmp_fi2d=0.
-      zx_tmp_fi3d=0.
 
          zsto = dtime
@@ -15,244 +8,110 @@
          itau_w = itau_phy + itap
 
-c
 c-------------------------------------------------------
       IF(lev_histmth.GE.1) THEN
-c
+
 ccccccccccccc 2D fields, basics
-c
-      i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
-      CALL histwrite(nid_mth,"phis",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-C
-      i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,airephy,zx_tmp_2d)
-      CALL histwrite(nid_mth,"aire",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ftsol,zx_tmp_2d)
-      CALL histwrite(nid_mth,"tsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = paprs(i,1)
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"psol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, ue,zx_tmp_2d)
-c     CALL histwrite(nid_mth,"ue",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, ve,zx_tmp_2d)
+
+      call histwrite_phy(nid_mth,.false.,"phis",itau_w,pphis)
+      call histwrite_phy(nid_mth,.false.,"aire",itau_w,airephy)
+      call histwrite_phy(nid_mth,.false.,"tsol",itau_w,ftsol)
+      call histwrite_phy(nid_mth,.false.,"psol",itau_w,paprs(:,1))
+c     call histwrite_phy(nid_mth,.false.,"ue",itau_w,ue)
 c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-c     zx_tmp_2d=-1.*zx_tmp_2d
-c     CALL histwrite(nid_mth,"ve",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cdragh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cdragm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+c     call histwrite_phy(nid_mth,.false.,"ve",itau_w,-1.*ve)
+c     call histwrite_phy(nid_mth,.false.,"cdragh",itau_w,cdragh)
+c     call histwrite_phy(nid_mth,.false.,"cdragm",itau_w,cdragm)
+
       ENDIF !lev_histmth.GE.1
-c
+
 c-------------------------------------------------------
       IF(lev_histmth.GE.2) THEN
-c
+
 ccccccccccccc 3D fields, basics
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      CALL histwrite(nid_mth,"temp",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
-      CALL histwrite(nid_mth,"pres",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
-      CALL histwrite(nid_mth,"geop",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      CALL histwrite(nid_mth,"vitu",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
+
+      call histwrite_phy(nid_mth,.false.,"temp",itau_w,t_seri)
+      call histwrite_phy(nid_mth,.false.,"pres",itau_w,pplay)
+      call histwrite_phy(nid_mth,.false.,"geop",itau_w,zphi)
+      call histwrite_phy(nid_mth,.false.,"vitu",itau_w,u_seri)
 c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-      zx_tmp_3d=-1.*zx_tmp_3d
-      CALL histwrite(nid_mth,"vitv",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
-      CALL histwrite(nid_mth,"vitw",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"vitv",itau_w,-1.*v_seri)
+      call histwrite_phy(nid_mth,.false.,"vitw",itau_w,omega)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_dyn, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dudyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"dudyn",itau_w,d_u_dyn)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_vdf, zx_tmp_3d)
-      CALL histwrite(nid_mth,"duvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, mang, zx_tmp_3d)
-c     CALL histwrite(nid_mth,"mang",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, ycoefh, zx_tmp_3d)
-      CALL histwrite(nid_mth,"Kz",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"duvdf",itau_w,d_u_vdf)
+c     call histwrite_phy(nid_mth,.false.,"mang",itau_w,mang)
+c     call histwrite_phy(nid_mth,.false.,"Kz",itau_w,ycoefh)
+
 c plusieurs traceurs
        IF (iflag_trac.eq.1) THEN
          DO iq=1,nqmax
-          IF (iq.LE.99) THEN
-       CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,iq), zx_tmp_3d)
-       WRITE(str2,'(i2.2)') iq
-       CALL histwrite(nid_mth,tname(iq),itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-          ELSE
-       PRINT*, "Trop de traceurs"
-       CALL abort
-          ENDIF
+       call histwrite_phy(nid_mth,.false.,tname(iq),itau_w,qx(:,:,iq))
          ENDDO
        ENDIF
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"tops",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+
+      call histwrite_phy(nid_mth,.false.,"tops",itau_w,topsw)
+
       ENDIF !lev_histmth.GE.2
-c
+
 c-------------------------------------------------------
       IF(lev_histmth.GE.3) THEN
-c
+
 cccccccccccccccccc  Radiative transfer
-c
+
 c 2D
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"topl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"sols",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"soll",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+
+      call histwrite_phy(nid_mth,.false.,"topl",itau_w,toplw)
+      call histwrite_phy(nid_mth,.false.,"sols",itau_w,solsw)
+      call histwrite_phy(nid_mth,.false.,"soll",itau_w,sollw)
+
 c 3D
-c
-      zx_tmp_fi3d(1:klon,1:klev)=swnet(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"SWnet",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zx_tmp_fi3d(1:klon,1:klev)=lwnet(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"LWnet",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zx_tmp_fi3d(1:klon,1:klev)=fluxt(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"fluxvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zx_tmp_fi3d(1:klon,1:klev)=flux_dyn(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"fluxdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zx_tmp_fi3d(1:klon,1:klev)=flux_ajs(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"fluxajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-c     zx_tmp_fi3d(1:klon,1:klev)=flux_ec(1:klon,1:klev)
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-c     CALL histwrite(nid_mth,"fluxec",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+
+      call histwrite_phy(nid_mth,.false.,"SWnet",itau_w,swnet)
+      call histwrite_phy(nid_mth,.false.,"LWnet",itau_w,lwnet)
+c     call histwrite_phy(nid_mth,.false.,"fluxvdf",itau_w,fluxt)
+c     call histwrite_phy(nid_mth,.false.,"fluxdyn",itau_w,flux_dyn)
+c     call histwrite_phy(nid_mth,.false.,"fluxajs",itau_w,flux_ajs)
+c     call histwrite_phy(nid_mth,.false.,"fluxec",itau_w,flux_ec)
+
       ENDIF !lev_histmth.GE.3
-c
+
 c-------------------------------------------------------
       IF(lev_histmth.GE.4) THEN
-c
+
 c en K/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_dyn, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"dtdyn",itau_w,d_t_dyn)
 c en K/s      
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t, zx_tmp_3d)
-c     CALL histwrite(nid_mth,"dtphy",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+c     call histwrite_phy(nid_mth,.false.,"dtphy",itau_w,d_t)
 c en K/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,d_t_vdf,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"dtvdf",itau_w,d_t_vdf)
 c en K/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,d_t_ajs,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"dtajs",itau_w,d_t_ajs)
 c K/day ==> K/s
-      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY 
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtswr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"dtswr",itau_w,heat/RDAY)
 c K/day ==> K/s      
-      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtlwr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+      call histwrite_phy(nid_mth,.false.,"dtlwr",itau_w,-1.*cool/RDAY)
 c en K/s      
-c     zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-c     CALL histwrite(nid_mth,"dtec",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+c     call histwrite_phy(nid_mth,.false.,"dtec",itau_w,d_t_ec)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_ajs, zx_tmp_3d)
-      CALL histwrite(nid_mth,"duajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"duajs",itau_w,d_u_ajs)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oro, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dugwo",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"dugwo",itau_w,d_u_oro)
 c en (m/s)/s      
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_hin, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dugwno",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
+      call histwrite_phy(nid_mth,.false.,"dugwno",itau_w,d_u_hin)
 c en (m/s)/s      
-c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
 c VENUS: regardee a l'envers!!!!!!!!!!!!!!!
-c     zx_tmp_3d=-1.*zx_tmp_3d
-c     CALL histwrite(nid_mth,"dvvdf",itau_w,zx_tmp_3d,
-c    .                                   iim*jjmp1*klev,ndex3d)
-c
+c     call histwrite_phy(nid_mth,.false.,"dvvdf",itau_w,-1.*d_v_vdf)
+
       ENDIF !lev_histmth.GE.4
 c
 c-------------------------------------------------------
        IF(lev_histmth.GE.5) THEN
-c
-c
-c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fluxu , zx_tmp_2d)
-c      CALL histwrite(nid_mth,"taux_",itau_w,
-c    $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c      
-c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fluxv , zx_tmp_2d)
-c      CALL histwrite(nid_mth,"tauy_",itau_w,
-c    $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
-c     CALL histwrite(nid_mth,"cdrm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
-c     CALL histwrite(nid_mth,"cdrh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
+
+c     call histwrite_phy(nid_mth,.false.,"taux_",itau_w,fluxu)
+c     call histwrite_phy(nid_mth,.false.,"tauy_",itau_w,fluxv)
+c     call histwrite_phy(nid_mth,.false.,"cdrm",itau_w,cdragm)
+c     call histwrite_phy(nid_mth,.false.,"cdrh",itau_w,cdragh)
+
       ENDIF !lev_histmth.GE.5
 c-------------------------------------------------------
@@ -261,3 +120,4 @@
         call histsync(nid_mth)
       endif
+
       ENDIF
Index: trunk/LMDZ.VENUS/libf/phyvenus/write_histrac.h
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/write_histrac.h	(revision 888)
+++ 	(revision )
@@ -1,23 +1,0 @@
-!
-! $Header: /home/cvsroot/LMDZ4/libf/phylmd/write_histrac.h,v 1.2 2004/06/22 11:45:36 lmdzadmin Exp $
-!
-      ndex = 0
-      ndex2d = 0
-      ndex3d = 0
-c
-      zsto = pdtphys
-      zout = pdtphys * REAL(ecrit_tra)
-      itau_w = itau_phy + nstep
-
-      
-      i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
-      z4_tmp_2d=zx_tmp_2d
-      CALL histwrite(nid_tra,"phis",itau_w,z4_tmp_2d,iim*(jjm+1),ndex2d)
-C
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,airephy,zx_tmp_2d)      
-      z4_tmp_2d=zx_tmp_2d
-      CALL histwrite(nid_tra,"aire",itau_w,z4_tmp_2d,iim*(jjm+1),ndex2d)
-
-
-
Index: trunk/LMDZ.VENUS/libf/phyvenus/zenang.F
===================================================================
--- trunk/LMDZ.VENUS/libf/phyvenus/zenang.F	(revision 888)
+++ trunk/LMDZ.VENUS/libf/phyvenus/zenang.F	(revision 892)
@@ -34,5 +34,5 @@
       integer i
       real gmtime1, gmtime2
-      real pi_local, deux_pi_local, incl
+      real incl
       real omega1, omega2, omega
 c omega1, omega2 : temps 1 et 2 exprime en radian avec 0 a midi.
@@ -46,9 +46,7 @@
 c================================================================
 c
-      pi_local = 4.0 * ATAN(1.0)
-      deux_pi_local = 2.0 * pi_local
-      incl=R_incl * pi_local / 180.
+      incl=R_incl * RPI / 180.
 c
-      lon_sun = longi * pi_local / 180.0
+      lon_sun = longi * RPI / 180.0
       lat_sun = ASIN (SIN(lon_sun)*SIN(incl) )
 c
@@ -58,5 +56,5 @@
       DO i = 1, klon
 c
-      latr = lat(i) * pi_local / 180.
+      latr = lat(i) * RPI / 180.
 c
 c--pose probleme quand lat=+/-90 degres
@@ -64,11 +62,11 @@
 c      omega = -TAN(latr)*TAN(lat_sun)
 c      omega = ACOS(omega)
-c      IF (latr.GE.(pi_local/2.+lat_sun)
-c     .    .OR. latr.LE.(-pi_local/2.+lat_sun)) THEN
+c      IF (latr.GE.(RPI/2.+lat_sun)
+c     .    .OR. latr.LE.(-RPI/2.+lat_sun)) THEN
 c         omega = 0.0       ! nuit polaire
 c      ENDIF
-c      IF (latr.GE.(pi_local/2.-lat_sun)
-c     .          .OR. latr.LE.(-pi_local/2.-lat_sun)) THEN
-c         omega = pi_local  ! journee polaire
+c      IF (latr.GE.(RPI/2.-lat_sun)
+c     .          .OR. latr.LE.(-RPI/2.-lat_sun)) THEN
+c         omega = RPI  ! journee polaire
 c      ENDIF
 c
@@ -76,12 +74,12 @@
 c
       omega=0.0  !--nuit polaire
-      IF (latr.GE.(pi_local/2.-lat_sun)
-     .          .OR. latr.LE.(-pi_local/2.-lat_sun)) THEN
-         omega = pi_local  ! journee polaire
+      IF (latr.GE.(RPI/2.-lat_sun)
+     .          .OR. latr.LE.(-RPI/2.-lat_sun)) THEN
+         omega = RPI  ! journee polaire
       ENDIF
-      IF (latr.LT.(pi_local/2.+lat_sun).AND.
-     .    latr.GT.(-pi_local/2.+lat_sun).AND.
-     .    latr.LT.(pi_local/2.-lat_sun).AND.
-     .    latr.GT.(-pi_local/2.-lat_sun)) THEN
+      IF (latr.LT.(RPI/2.+lat_sun).AND.
+     .    latr.GT.(-RPI/2.+lat_sun).AND.
+     .    latr.LT.(RPI/2.-lat_sun).AND.
+     .    latr.GT.(-RPI/2.-lat_sun)) THEN
       omega = -TAN(latr)*TAN(lat_sun)
       omega = ACOS(omega)
@@ -89,12 +87,12 @@
 c
          omega1 = gmtime1 + long(i)*RDAY/360.0
-         omega1 = omega1 / RDAY*deux_pi_local
-         omega1 = MOD (omega1+deux_pi_local, deux_pi_local)
-         omega1 = omega1 - pi_local
+         omega1 = omega1*2*RPI / RDAY
+         omega1 = MOD (omega1+2*RPI, 2*RPI)
+         omega1 = omega1 - RPI
 c
          omega2 = gmtime2 + long(i)*RDAY/360.0
-         omega2 = omega2 / RDAY*deux_pi_local
-         omega2 = MOD (omega2+deux_pi_local, deux_pi_local)
-         omega2 = omega2 - pi_local
+         omega2 = omega2*2*RPI / RDAY
+         omega2 = MOD (omega2+2*RPI, 2*RPI)
+         omega2 = omega2 - RPI
 c
       IF (omega1.LE.omega2) THEN  !--on est dans la meme journee locale
@@ -144,5 +142,5 @@
       ENDIF
 c-----------------------moyenne 
-      frac(i)=(zfrac1+zfrac2)/(omega2+deux_pi_local-omega1)
+      frac(i)=(zfrac1+zfrac2)/(omega2+2*RPI-omega1)
       pmu0(i)=(zfrac1*z1_mu+zfrac2*z2_mu)/MAX(zfrac1+zfrac2,1.E-10)
 c
