Index: LMDZ.3.3/branches/rel-LF/libf/phylmd/physiq.F
===================================================================
--- LMDZ.3.3/branches/rel-LF/libf/phylmd/physiq.F	(revision 395)
+++ LMDZ.3.3/branches/rel-LF/libf/phylmd/physiq.F	(revision 411)
@@ -2,5 +2,5 @@
 c $Header$
 c
-      SUBROUTINE physiq (nlon,nlev,nqmax  ,
+      SUBROUTINE physiq (nlon,nlev,nqmax,
      .            debut,lafin,rjourvrai,rjour_ecri,gmtime,pdtphys,
      .            paprs,pplay,pphi,pphis,paire,presnivs,clesphy0,
@@ -67,4 +67,9 @@
 #include "control.h"
 #include "temps.h"
+c======================================================================
+      LOGICAL ok_cvl  ! pour activer le nouveau driver pour convection KE
+      PARAMETER (ok_cvl=.TRUE.)
+      LOGICAL ok_gust ! pour activer l'effet des gust sur flux surface
+      PARAMETER (ok_gust=.FALSE.)
 c======================================================================
       LOGICAL check ! Verifier la conservation du modele en eau
@@ -183,4 +188,31 @@
       REAL d_ps(klon)
 
+cccIM
+      INTEGER klevp1
+      PARAMETER(klevp1=klev+1)
+#include "raddim.h"
+      REAL*8 ZFSUP(KDLON,KFLEV+1)
+      REAL*8 ZFSDN(KDLON,KFLEV+1)
+      REAL*8 ZFSUP0(KDLON,KFLEV+1)
+      REAL*8 ZFSDN0(KDLON,KFLEV+1)
+
+cccIM cf. FH
+      real u850(klon),v850(klon),u200(klon),v200(klon)
+      real u500(klon),v500(klon),phi500(klon)
+
+      logical ok_hf
+      real ecrit_hf
+      integer nid_hf
+      save ok_hf, ecrit_hf, nid_hf        
+
+c  QUESTION : noms de variables ?
+
+#define histhf
+#ifdef histhf
+      data ok_hf,ecrit_hf/.true.,0.25/
+#else
+      data ok_hf/.false./
+#endif
+
       INTEGER        longcles
       PARAMETER    ( longcles = 20 )
@@ -308,7 +340,13 @@
       REAL Ma(klon,klev)        ! undilute upward mass flux
       SAVE Ma
+      REAL qcondc(klon,klev)    ! in-cld water content from convect
+      SAVE qcondc 
       REAL ema_work1(klon, klev), ema_work2(klon, klev)
       SAVE ema_work1, ema_work2
       REAL wdn(klon), tdn(klon), qdn(klon)
+
+      REAL wd(klon) ! sb
+      SAVE wd       ! sb
+
 c Variables locales pour la couche limite (al1):
 c
@@ -424,5 +462,5 @@
       REAL cldemi(klon,klev)  ! emissivite infrarouge
 c
-C§§§ PB 
+CXXX PB 
       REAL fluxq(klon,klev, nbsrf)   ! flux turbulent d'humidite
       REAL fluxt(klon,klev, nbsrf)   ! flux turbulent de chaleur
@@ -434,5 +472,5 @@
       REAL zxfluxu(klon, klev)
       REAL zxfluxv(klon, klev)
-C§§§
+CXXX
       REAL heat(klon,klev)    ! chauffage solaire
       REAL heat0(klon,klev)   ! chauffage solaire ciel clair
@@ -447,4 +485,7 @@
       SAVE  heat,cool,albpla,topsw,toplw,solsw,sollw,sollwdown
       SAVE  topsw0,toplw0,solsw0,sollw0, heat0, cool0
+cccIM
+      SAVE  ZFSUP,ZFSDN,ZFSUP0,ZFSDN0 
+
       INTEGER itaprad
       SAVE itaprad
@@ -621,6 +662,4 @@
       character*20 varunits
 C     Variables liees au bilan d'energie et d'enthalpi
-      INTEGER   if_ebil ! level for energy conserv. dignostics
-      SAVE      if_ebil
       REAL ztsol(klon)
       REAL      h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot
@@ -637,4 +676,16 @@
       SAVE      ip_ebil
       DATA      ip_ebil/2/
+      INTEGER   if_ebil ! level for energy conserv. dignostics
+      SAVE      if_ebil
+c+jld ec_conser
+      REAL d_t_ec(klon,klev)    ! tendance du a la conersion Ec -> E thermique
+      REAL ZRCPD
+c-jld ec_conser
+cIM
+      REAL t2m(klon,nbsrf), q2m(klon,nbsrf)
+      REAL u10m(klon,nbsrf), v10m(klon,nbsrf)
+      REAL zt2m(klon), zq2m(klon)
+      REAL zu10m(klon), zv10m(klon)
+      CHARACTER*40 t2mincels, t2maxcels 
 c
 c Declaration des constantes et des fonctions thermodynamiques
@@ -731,4 +782,5 @@
          ENDIF
          PRINT*, "Clef pour la convection, iflag_con=", iflag_con
+         PRINT*, "Clef pour le driver de la convection, ok_cvl=", ok_cvl
 c
 cKE43
@@ -778,6 +830,6 @@
 ccc         ecrit_ins = NINT(86400./dtime *0.5)  ! 2 fois par jour
 ccc         ecrit_ins = NINT(86400./dtime *0.25)  ! 4 fois par jour
+         ecrit_ins = NINT(86400./dtime/48.)  ! a chaque pas de temps ==> PB. dans time_counter pour 1mois
          ecrit_ins = NINT(86400./dtime/12.)  ! toutes les deux heures
-         ecrit_ins = NINT(86400./dtime/48.)  ! a chaque pas de temps
          IF (ok_instan) THEN
          PRINT*, 'La frequence de sortie instant. est de ', ecrit_ins
@@ -803,923 +855,22 @@
 c
 c
-c Gestion calendrier
-
-c
-      IF (ok_journe) THEN
-c
-         idayref = day_ref
-         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
-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
-         DO ll=1,klev
-            znivsig(ll)=float(ll)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
-         write(*,*)'zx_lon = ',zx_lon(:,1)
-         write(*,*)'zx_lat = ',zx_lat(1,:)
-         CALL histbeg("histday", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
-     .                 nhori, nid_day)
-         write(*,*)'Journee ', itau_phy, zjulian
-         CALL histvert(nid_day, "presnivs", "Vertical levels", "mb",
-     .                 klev, presnivs, nvert)
-c        call histvert(nid_day, 'sig_s', 'Niveaux sigma','-',
-c    .              klev, znivsig, nvert)
-c
-         zsto = dtime
-         zout = dtime * FLOAT(ecrit_day)
-C Essai writephys
-c        nom_fichier = 'histday1'
-c        call writephy_ini(fid_day,nom_fichier,klon,iim,jjmp1,klev,
-c    .                     rlon,rlat, presnivs,
-c    .                     zjulian, dtime)
-c        call writephy_def(prof2d_on, fid_day, "once", zsto, zout, 0)
-c        call writephy_def(prof3d_on, fid_day, "once", zsto, zout,
-c    .                                                         klev)
-c        call writephy_def(prof2d_av, fid_day, "ave(X)", zsto, zout, 0) 
-c        call writephy_def(prof3d_av, fid_day, "ave(X)", zsto, zout, 
-c    .                                                         klev)
- 
-c
-         CALL histdef(nid_day, "phis", "Surface geop. height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once", zsto,zout)
-c
-         CALL histdef(nid_day, "aire", "Grid area", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once", zsto,zout)
-c
-c Champs 2D:
-c
-         CALL histdef(nid_day, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "tter", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "tlic", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "toce", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "tsic", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "precip","Precipitation Totale liq+sol"
-     .                , "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "snow", "Snow fall", "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "snow_mass", "Snow Mass", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "evap", "Evaporation", "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "tops", "Solar rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "topl", "IR rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "sols", "Net Solar rad. at surf.", 
-     .                "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "soll", "Net IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "solldown", "Down. IR rad. at surface", 
-     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "bils", "Surf. total heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "sens", "Sensible heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "fder", "Heat flux derivation", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "frtu", "Zonal wind stress", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "frtv", "Meridional wind stress", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-C §§§ PB flux pour chauqe sous surface
-C
-         DO nsrf = 1, nbsrf
-C
-           call histdef(nid_day, "pourc_"//clnsurf(nsrf), 
-     $         "Fraction"//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-C
-           call histdef(nid_day, "tsol_"//clnsurf(nsrf), 
-     $         "Fraction"//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-C
-           call histdef(nid_day, "sens_"//clnsurf(nsrf), 
-     $         "Sensible heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-c
-           call histdef(nid_day, "lat_"//clnsurf(nsrf), 
-     $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-C
-           call histdef(nid_day, "taux_"//clnsurf(nsrf), 
-     $         "Zonal wind stress"//clnsurf(nsrf),"Pa",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-
-           call histdef(nid_day, "tauy_"//clnsurf(nsrf), 
-     $         "Meridional xind stress "//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-C
-           call histdef(nid_day, "albe_"//clnsurf(nsrf), 
-     $         "Albedo surf. "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-C
-           call histdef(nid_day, "rugs_"//clnsurf(nsrf), 
-     $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-
-C§§§
-         END DO 
-           
-         CALL histdef(nid_day, "sicf", "Sea-ice fraction", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "cldl", "Low-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "cldm", "Mid-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "cldh", "High-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "cldt", "Total cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "cldq", "Cloud liquid water path", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-c Champs 3D:
-c
-         CALL histdef(nid_day, "temp", "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "ovap", "Specific humidity", "Kg/Kg",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_day, "vitw", "Vertical wind", "m/s",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histend(nid_day)
-c
-         ndex2d = 0
-         ndex3d = 0
-c
-      ENDIF ! fin de test sur ok_journe
-c
-      IF (ok_mensuel) THEN
-c
-         idayref = day_ref
-         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
-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
-         DO ll=1,klev
-            znivsig(ll)=float(ll)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
-         CALL histbeg("histmth.nc", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
-     .                 nhori, nid_mth)
-         write(*,*)'Mensuel ', itau_phy, zjulian
-         CALL histvert(nid_mth, "presnivs", "Vertical levels", "mb",
-     .                 klev, presnivs, nvert)
-c        call histvert(nid_mth, 'sig_s', 'Niveaux sigma','-',
-c    .              klev, znivsig, nvert)
-c
-         zsto = dtime
-         zout = dtime * ecrit_mth
-c
-         CALL histdef(nid_mth, "phis", "Surface geop. height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once",  zsto,zout)
-c
-         CALL histdef(nid_mth, "aire", "Grid area", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once",  zsto,zout)
-c
-c Champs 2D:
-c
-         CALL histdef(nid_mth, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "qsol", "Surface humidity", "mm",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "precip", "Precipitation Totale liq+sol", 
-     .                "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "plul", "Large-scale Precip.", "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "pluc", "Convective Precip.", "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "snow", "Snow fall", "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "snow_mass", "Snow Mass", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "evap", "Evaporation", "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "tops", "Solar rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "topl", "IR rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "sols", "Solar rad. at surf.", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "soll", "IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "solldown", "Down. IR rad. at surface", 
-     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "tops0", "Solar rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "topl0", "IR rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "sols0", "Solar rad. at surf.", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "soll0", "IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "bils", "Surf. total heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "sens", "Sensible heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "fder", "Heat flux derivation", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "frtu", "Zonal wind stress", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "frtv", "Meridional wind stress", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         DO nsrf = 1, nbsrf
-C
-           call histdef(nid_mth, "pourc_"//clnsurf(nsrf), 
-     $         "Fraction "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-C
-           call histdef(nid_mth, "tsol_"//clnsurf(nsrf), 
-     $         "Fraction "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-C
-           call histdef(nid_mth, "sens_"//clnsurf(nsrf), 
-     $         "Sensible heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-c
-           call histdef(nid_mth, "lat_"//clnsurf(nsrf), 
-     $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-C
-           call histdef(nid_mth, "taux_"//clnsurf(nsrf), 
-     $         "Zonal wind stress"//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-
-           call histdef(nid_mth, "tauy_"//clnsurf(nsrf), 
-     $         "Meridional xind stress "//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-c
-           call histdef(nid_mth, "albe_"//clnsurf(nsrf), 
-     $         "Albedo surf. "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-c
-           call histdef(nid_mth, "rugs_"//clnsurf(nsrf), 
-     $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "ages_"//clnsurf(nsrf), "Snow age","day",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-
-         END DO
-C
-         CALL histdef(nid_mth, "sicf", "Sea-ice fraction", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "albs", "Surface albedo", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-         CALL histdef(nid_mth, "albslw", "Surface albedo LW", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "cdrm", "Momentum drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "cdrh", "Heat drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "cldl", "Low-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "cldm", "Mid-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "cldh", "High-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "cldt", "Total cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "cldq", "Cloud liquid water path", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "ue", "Zonal energy transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "ve", "Merid energy transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "uq", "Zonal humidity transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "vq", "Merid humidity transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zsto,zout)
-cKE43
-      IF (iflag_con .GE. 3) THEN ! sb
-c
-         CALL histdef(nid_mth, "cape", "Conv avlbl pot ener", "J/Kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "pbase", "Cld base pressure", "hPa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "ptop", "Cld top pressure", "hPa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "fbase", "Cld base mass flux", "Kg/m2/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zsto,zout)
-c
-c
-      ENDIF
-c34EK
-c
-c Champs 3D:
-c
-         CALL histdef(nid_mth, "temp", "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "ovap", "Specific humidity", "Kg/Kg",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "vitw", "Vertical wind", "m/s",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "rneb", "Cloud fraction", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "rhum", "Relative humidity", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "clwcon", "Cloud Liquid water content"
-     .                , "kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "oliq", "Liquid water content", "kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dtdyn", "Dynamics dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dqdyn", "Dynamics dQ", "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dtcon", "Convection dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "ducon", "Convection du", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dqcon", "Convection dQ", "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dtlsc", "Condensation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dqlsc", "Condensation dQ", "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dtvdf", "Boundary-layer dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dqvdf", "Boundary-layer dQ", "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dteva", "Reevaporation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dqeva", "Reevaporation dQ", "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-
-         CALL histdef(nid_mth, "ptconv", "POINTS CONVECTIFS"," ",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-
-         CALL histdef(nid_mth, "ratqs", "RATQS"," ",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-
-         CALL histdef(nid_mth, "dqajs", "Dry adjust. dQ", "Kg/Kg/s",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dtsw0", "SW radiation dT", "K/s",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dtlw0", "LW radiation dT", "K/s",
-     .                iim,jjmp1,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,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dvvdf", "Boundary-layer dV", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         IF (ok_orodr) THEN
-         CALL histdef(nid_mth, "duoro", "Orography dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dvoro", "Orography dV", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         ENDIF
-C
-         IF (ok_orolf) THEN
-         CALL histdef(nid_mth, "dulif", "Orography dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dvlif", "Orography dV", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-         ENDIF
-C
-         CALL histdef(nid_mth, "ozone", "Ozone concentration", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         if (nqmax.GE.3) THEN
-         DO iq=1,nqmax-2
-         IF (iq.LE.99) THEN
-         WRITE(str2,'(i2.2)') iq
-         CALL histdef(nid_mth, "trac"//str2, "Tracer No."//str2, "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-         ELSE
-         PRINT*, "Trop de traceurs"
-         CALL abort
-         ENDIF
-         ENDDO
-         ENDIF
-c
-cKE43
-      IF (iflag_con.GE.3) THEN ! (sb)
-c
-         CALL histdef(nid_mth, "upwd", "saturated updraft", "Kg/m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dnwd", "saturated downdraft","Kg/m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth, "dnwd0", "unsat. downdraft", "Kg/m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-         CALL histdef(nid_mth,"Ma","undilute adiab updraft","Kg/m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-c
-c
-      ENDIF
-c34EK
-         CALL histend(nid_mth)
-c
-         ndex2d = 0
-         ndex3d = 0
-c
-      ENDIF ! fin de test sur ok_mensuel
-c
-c
-      IF (ok_instan) THEN
-c
-         idayref = day_ref
-         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
-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
-         DO ll=1,klev
-            znivsig(ll)=float(ll)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
-         CALL histbeg("histins", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime,
-     .                 nhori, nid_ins)
-         write(*,*)'Inst ', itau_phy, zjulian
-         CALL histvert(nid_ins, "presnivs", "Vertical levels", "mb",
-     .                 klev, presnivs, nvert)
-c        call histvert(nid_ins, 'sig_s', 'Niveaux sigma','-',
-c    .              klev, znivsig, nvert)
-c
-c
-         zsto = dtime * ecrit_ins
-         zout = dtime * ecrit_ins
-C
-         CALL histdef(nid_ins, "phis", "Surface geop. height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zsto,zout)
-c
-         CALL histdef(nid_ins, "aire", "Grid area", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zsto,zout)
-c
-c Champs 2D:
-c
-        CALL histdef(nid_ins, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-        CALL histdef(nid_ins, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "plul", "Large-scale Precip.", "mm/day",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "pluc", "Convective Precip.", "mm/day",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-
-        CALL histdef(nid_ins, "qsol", "Surface humidity", "mm",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "cdrm", "Momentum drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "cdrh", "Heat drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "precip", "Precipitation Totale liq+sol", 
-     .                "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "snow", "Snow fall", "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "snow_mass", "Snow Mass", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "topl", "OLR", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "evap", "Evaporation", "kg/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "sols", "Solar rad. at surf.", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "soll", "IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "solldown", "Down. IR rad. at surface", 
-     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "bils", "Surf. total heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "sens", "Sensible heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "fder", "Heat flux derivation", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-      CALL histdef(nid_ins, "dtsvdfo", "Boundary-layer dTs(o)", "K/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-      CALL histdef(nid_ins, "dtsvdft", "Boundary-layer dTs(t)", "K/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-      CALL histdef(nid_ins, "dtsvdfg", "Boundary-layer dTs(g)", "K/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-      CALL histdef(nid_ins, "dtsvdfi", "Boundary-layer dTs(g)", "K/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-
-         DO nsrf = 1, nbsrf
-C
-           call histdef(nid_ins, "pourc_"//clnsurf(nsrf), 
-     $         "Fraction"//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "inst(X)", zsto,zout)
-
-           call histdef(nid_ins, "sens_"//clnsurf(nsrf), 
-     $         "Sensible heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "inst(X)", zsto,zout)
-c
-           call histdef(nid_ins, "tsol_"//clnsurf(nsrf), 
-     $         "Surface Temperature"//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "inst(X)", zsto,zout)
-c
-           call histdef(nid_ins, "lat_"//clnsurf(nsrf), 
-     $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "inst(X)", zsto,zout)
-C
-           call histdef(nid_ins, "taux_"//clnsurf(nsrf), 
-     $         "Zonal wind stress"//clnsurf(nsrf),"Pa",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "inst(X)", zsto,zout)
-
-           call histdef(nid_ins, "tauy_"//clnsurf(nsrf), 
-     $         "Meridional xind stress "//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "inst(X)", zsto,zout)
-c
-           call histdef(nid_ins, "albe_"//clnsurf(nsrf), 
-     $         "Albedo "//clnsurf(nsrf), "-",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "inst(X)", zsto,zout)
-c
-           call histdef(nid_ins, "rugs_"//clnsurf(nsrf), 
-     $         "rugosite "//clnsurf(nsrf), "-",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
-     $         "inst(X)", zsto,zout)
-C§§§
-         END DO 
-         CALL histdef(nid_ins, "rugs", "rugosity", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-
-c
-         CALL histdef(nid_ins, "albs", "Surface albedo", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-         CALL histdef(nid_ins, "albslw", "Surface albedo LW", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-c
-c Champs 3D:
-c
-         CALL histdef(nid_ins, "temp", "Temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "vitv", "Merid wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "geop", "Geopotential height", "m",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "pres", "Air pressure", "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "dtvdf", "Boundary-layer dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_ins, "dqvdf", "Boundary-layer dQ", "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
-     .                "inst(X)", zsto,zout)
-c
-
-         CALL histend(nid_ins)
-c
-         ndex2d = 0
-         ndex3d = 0
-c
-      ENDIF
-
-c$$$PB Positionner date0 pour initialisation de ORCHIDEE
+cccIM
+      t2mincels = 't_min(X)'
+      t2maxcels = 't_max(X)'
+
+cccIM cf. FH
+c
+c=============================================================
+c   Initialisation des sorties
+c=============================================================
+#ifdef histhf
+#include "ini_histhf.h"
+#endif
+
+#include "ini_histday.h"
+#include "ini_histmth.h"
+#include "ini_histins.h"
+
+cXXXPB Positionner date0 pour initialisation de ORCHIDEE
       date0 = zjulian
 C      date0 = day_ini
@@ -1880,5 +1031,5 @@
       IF (if_ebil.ge.2) THEN 
         ztit='after reevap'
-        CALL diagetpq(paire,ztit,ip_ebil,2,2,dtime
+        CALL diagetpq(paire,ztit,ip_ebil,2,1,dtime
      e      , t_seri,q_seri,ql_seri,qs_seri,u_seri,v_seri,paprs,pplay
      s      , d_h_vcol, d_qt, d_qw, d_ql, d_qs, d_ec)
@@ -1940,10 +1091,9 @@
      s            fluxt,fluxq,fluxu,fluxv,cdragh,cdragm,
      s            dsens, devap,
-     s            ycoefh,yu1,yv1) 
-
-c
-C§§§ PB
-C§§§ Incrementation des flux
-C§§
+     s            ycoefh,yu1,yv1, t2m, q2m, u10m, v10m) 
+c
+CXXX PB
+CXXX Incrementation des flux
+CXXX
       zxfluxt=0.
       zxfluxq=0.
@@ -1999,4 +1149,10 @@
          zxtsol(i) = 0.0
          zxfluxlat(i) = 0.0
+cccIM
+         zt2m(i) = 0.0
+         zq2m(i) = 0.0
+         zu10m(i) = 0.0
+         zv10m(i) = 0.0
+c
          IF ( abs( pctsrf(i, is_ter) + pctsrf(i, is_lic) + 
      $       pctsrf(i, is_oce) + pctsrf(i, is_sic)  - 1.) .GT. EPSFRA) 
@@ -2008,9 +1164,14 @@
       DO nsrf = 1, nbsrf
         DO i = 1, klon
-c$$$      IF (pctsrf(i,nsrf) .GE. EPSFRA) THEN 
+c        IF (pctsrf(i,nsrf) .GE. EPSFRA) THEN 
             ftsol(i,nsrf) = ftsol(i,nsrf) + d_ts(i,nsrf)
             zxtsol(i) = zxtsol(i) + ftsol(i,nsrf)*pctsrf(i,nsrf)
             zxfluxlat(i) = zxfluxlat(i) + fluxlat(i,nsrf)*pctsrf(i,nsrf)
-c$$$      ENDIF 
+cccIM
+            zt2m(i) = zt2m(i) + t2m(i,nsrf)*pctsrf(i,nsrf)
+            zq2m(i) = zq2m(i) + q2m(i,nsrf)*pctsrf(i,nsrf)
+            zu10m(i) = zu10m(i) + u10m(i,nsrf)*pctsrf(i,nsrf)
+            zv10m(i) = zv10m(i) + v10m(i,nsrf)*pctsrf(i,nsrf)
+c        ENDIF 
         ENDDO
       ENDDO
@@ -2022,18 +1183,23 @@
         DO i = 1, klon
           IF (pctsrf(i,nsrf) .LT. epsfra) ftsol(i,nsrf) = zxtsol(i)
+cccIM
+          IF (pctsrf(i,nsrf) .LT. epsfra) t2m(i,nsrf) = zt2m(i)
+          IF (pctsrf(i,nsrf) .LT. epsfra) q2m(i,nsrf) = zq2m(i)
+          IF (pctsrf(i,nsrf) .LT. epsfra) u10m(i,nsrf) = zu10m(i)
+          IF (pctsrf(i,nsrf) .LT. epsfra) v10m(i,nsrf) = zv10m(i)
         ENDDO
       ENDDO
-
+c
 c
 c Calculer la derive du flux infrarouge
 c
-c$$$      DO nsrf = 1, nbsrf
-      DO i = 1, klon
-c$$$        IF (pctsrf(i,nsrf) .GE. EPSFRA) THEN 
+cXXX      DO nsrf = 1, nbsrf
+      DO i = 1, klon
+cXXX        IF (pctsrf(i,nsrf) .GE. EPSFRA) THEN 
             dlw(i) = - 4.0*RSIGMA*zxtsol(i)**3 
-c$$$     .          *(ftsol(i,nsrf)-zxtsol(i))
-c$$$     .          *pctsrf(i,nsrf)
-c$$$        ENDIF 
-c$$$      ENDDO
+cXXX     .          *(ftsol(i,nsrf)-zxtsol(i))
+cXXX     .          *pctsrf(i,nsrf)
+cXXX        ENDIF 
+cXXX      ENDDO
       ENDDO
 c
@@ -2089,4 +1255,23 @@
               ntra = 1 
           endif
+c
+c sb, oct02:
+c Schema de convection modularise et vectorise:
+c (driver commun aux versions 3 et 4)
+c
+          IF (ok_cvl) THEN ! new driver for convectL
+
+          CALL concvl (iflag_con,
+     .        dtime,paprs,pplay,t_seri,q_seri,
+     .        u_seri,v_seri,tr_seri,nbtr,
+     .        ema_work1,ema_work2,
+     .        d_t_con,d_q_con,d_u_con,d_v_con,d_tr,
+     .        rain_con, snow_con, ibas_con, itop_con,
+     .        upwd,dnwd,dnwd0,
+     .        Ma,cape,tvp,iflagctrl,
+     .        pbase,bbase,dtvpdt1,dtvpdq1,dplcldt,dplcldr,qcondc,wd)
+
+          ELSE ! ok_cvl
+
           if (iflag_con.eq.4) then ! vectorise
           CALL conemav (dtime,paprs,pplay,t_seri,q_seri,
@@ -2099,4 +1284,11 @@
      .        Ma,cape,tvp,iflagctrl,
      .        pbase,bbase,dtvpdt1,dtvpdq1,dplcldt,dplcldr)
+
+           do i = 1, klon
+            wd(i)=0.0
+             do k = 1, klev
+               qcondc(i)=0.0
+             enddo
+           enddo
 
           else
@@ -2115,4 +1307,10 @@
      .        ,clwcon0)
           print*,'Apres conema3 '
+
+           IF (.NOT. ok_gust) THEN
+           do i = 1, klon
+            wd(i)=0.0
+           enddo
+           ENDIF
 
 c Calculer l'humidite relative pour diagnostique
@@ -2138,5 +1336,5 @@
       ENDDO
 
-c   calcul des propriétés des nuages convectifs
+c   calcul des proprietes des nuages convectifs
              clwcon0(:,:)=fact_cldcon*clwcon0(:,:)
              call clouds_gno
@@ -2144,4 +1342,7 @@
 
           endif
+
+          ENDIF ! ok_cvl
+
           DO i = 1, klon
             ema_pcb(i)  = pbase(i)
@@ -2479,5 +1680,7 @@
      s             topsw,toplw,solsw,sollw,
      s             sollwdown,
-     s             topsw0,toplw0,solsw0,sollw0)
+cccIMs             topsw0,toplw0,solsw0,sollw0)
+     s             topsw0,toplw0,solsw0,sollw0,
+     s             ZFSUP,ZFSDN,ZFSUP0,ZFSDN0)
       itaprad = 0
       ENDIF
@@ -2524,12 +1727,12 @@
 c Si une sous-fraction n'existe pas, elle prend la valeur moyenne
 c
-c$$$      DO nsrf = 1, nbsrf
-c$$$      DO i = 1, klon
-c$$$         IF (pctsrf(i,nsrf).LT.epsfra) THEN
-c$$$            fqsol(i,nsrf) = zxqsol(i)
-c$$$            fsnow(i,nsrf) = zxsnow(i)
-c$$$         ENDIF
-c$$$      ENDDO
-c$$$      ENDDO
+cXXX      DO nsrf = 1, nbsrf
+cXXX      DO i = 1, klon
+cXXX         IF (pctsrf(i,nsrf).LT.epsfra) THEN
+cXXX            fqsol(i,nsrf) = zxqsol(i)
+cXXX            fsnow(i,nsrf) = zxsnow(i)
+cXXX         ENDIF
+cXXX      ENDDO
+cXXX      ENDDO
 c
 c Calculer le bilan du sol et la derive de temperature (couplage)
@@ -2628,12 +1831,12 @@
       IF (iflag_con.GE.3) THEN
 c           on ajoute les tendances calculees par KE43
-c$$$ OM on onhibe la convection sur les traceurs
+cXXX OM on onhibe la convection sur les traceurs
         DO iq=1, nqmax-2 ! Sandrine a -3 ???
-c$$$ OM on inhibe la convection sur les traceur
-c$$$        DO k = 1, nlev
-c$$$        DO i = 1, klon
-c$$$          tr_seri(i,k,iq) = tr_seri(i,k,iq) + d_tr(i,k,iq)
-c$$$        ENDDO
-c$$$        ENDDO
+cXXX OM on inhibe la convection sur les traceur
+cXXX        DO k = 1, nlev
+cXXX        DO i = 1, klon
+cXXX          tr_seri(i,k,iq) = tr_seri(i,k,iq) + d_tr(i,k,iq)
+cXXX        ENDDO
+cXXX        ENDDO
         WRITE(iqn,'(i2.2)') iq
         CALL minmaxqfi(tr_seri(1,1,iq),0.,1.e33,'couche lim iq='//iqn)
@@ -2680,4 +1883,15 @@
 c
 c
+c+jld ec_conser
+      DO k = 1, klev
+      DO i = 1, klon
+        ZRCPD = RCPD*(1.0+RVTMP2*q_seri(i,k))
+        d_t_ec(i,k)=0.5/ZRCPD
+     $      *(u(i,k)**2+v(i,k)**2-u_seri(i,k)**2-v_seri(i,k)**2)
+        t_seri(i,k)=t_seri(i,k)+d_t_ec(i,k)
+        d_t_ec(i,k) = d_t_ec(i,k)/dtime
+       END DO 
+      END DO 
+c-jld ec_conser
       IF (if_ebil.ge.1) THEN 
         ztit='after physic'
@@ -2699,941 +1913,33 @@
       END IF 
 C
-      IF (ok_journe) THEN
-c
-      ndex2d = 0
-      ndex3d = 0
-c
-c Champs 2D:
-c
-         zsto = dtime
-         zout = dtime * FLOAT(ecrit_day)
-         itau_w = itau_phy + itap
-
-         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)
-         varname = 'phis'
-         vartitle= 'Surface geop. height'
-         varunits= '-'
-c        call writephy(fid_day,prof2d_on,varname,pphis,vartitle,
-c    .                                                    varunits)
-c
-         i = NINT(zout/zsto)
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,paire,zx_tmp_2d)
-       CALL histwrite(nid_day,"aire",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-         varname = 'aire'
-         vartitle= 'Grid area'
-         varunits= '-'
-c        call writephy(fid_day,prof2d_on,varname,paire,vartitle,
-c    .                                                    varunits)
-C
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
-      CALL histwrite(nid_day,"tsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'tsol',zxtsol,
-c    .              'Surface Temperature','K')
-c
-C
-      zx_tmp_fi2d(1 : klon) = ftsol(1 : klon, is_ter)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d ,zx_tmp_2d)
-      CALL histwrite(nid_day,"tter",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'tter',ftsol(1 : klon, is_ter),
-c    .              'Surface Temperature','K')
-C
-      zx_tmp_fi2d(1 : klon) = ftsol(1 : klon, is_lic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"tlic",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'tlic',ftsol(1 : klon, is_lic),
-c    .              'Surface Temperature','K')
-C
-      zx_tmp_fi2d(1 : klon) = ftsol(1 : klon, is_oce)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"toce",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'toce',ftsol(1 : klon, is_oce),
-c    .              'Surface Temperature','K')
-C
-      zx_tmp_fi2d(1 : klon) = ftsol(1 : klon, is_sic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"tsic",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'tsic',ftsol(1 : klon, is_sic),
-c    .              'Surface Temperature','K')
-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 Essai writephys
-      varname = 'psol'
-      vartitle= 'pression au sol'
-      varunits= 'hPa'
-c     call writephy(fid_day,prof2d_av,varname,zx_tmp_fi2d,vartitle,
-c    .                                                    varunits)
-c
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = (rain_fall(i) + snow_fall(i))
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"precip",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'rain',zx_tmp_fi2d,
-c    .              'Precipitation','mm/day')
-
-
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
-      CALL histwrite(nid_day,"snow",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'snow',snow_fall,
-c    .              'Snow','mm/day')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
-      CALL histwrite(nid_day,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c     call writephy(fid_day,prof2d_av,'snow_mass',zxsnow,
-c    .              'Snow cover','mm')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, evap,zx_tmp_2d)
-      CALL histwrite(nid_day,"evap",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'evap',evap,
-c    .              'Evaporation','mm/day')
-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 writephy(fid_day,prof2d_av,'tops',topsw,
-c    .              'Solar rad. at TOA','W/m2')
-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 writephy(fid_day,prof2d_av,'topl',toplw,
-c    .              'IR rad. at TOA','W/m2')
-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 writephy(fid_day,prof2d_av,'sols',solsw,
-c    .              'Solar rad. at surf.','W/m2')
-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 writephy(fid_day,prof2d_av,'soll',sollw,
-c    .              'IR rad. at surface','W/m2')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
-      CALL histwrite(nid_day,"solldown",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c     call writephy(fid_day,prof2d_av,'solldown',sollwdown,
-c    .              'Down. IR rad. at surface','W/m2')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, bils,zx_tmp_2d)
-      CALL histwrite(nid_day,"bils",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'bils',bils,
-c    .              'Surf. total heat flux','W/m2')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sens,zx_tmp_2d)
-      CALL histwrite(nid_day,"sens",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'sens',sens,
-c    .              'Sensible heat flux','W/m2')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
-      CALL histwrite(nid_day,"fder",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'fder',fder,
-c    .              'Heat flux derivation','W/m2')
-c
-c
-      DO nsrf = 1, nbsrf
-C§§§
-        zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"pourc_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c       call writephy(fid_day,prof2d_av,'pourc_'//clnsurf(nsrf),
-c    .                pctsrf( 1 : klon, nsrf),
-c    .                'Fraction'//clnsurf(nsrf),'-')
-C
-        zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"tsol_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c       call writephy(fid_day,prof2d_av,'tsol_'//clnsurf(nsrf),
-c    .                ftsol( 1 : klon, nsrf),
-c    .                'Surf. Temp'//clnsurf(nsrf),'K')
-C 
-        zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"sens_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c       call writephy(fid_day,prof2d_av,'sens_'//clnsurf(nsrf),
-c    .                fluxt( 1 : klon, 1, nsrf),
-c    .                'Sensible heat flux '//clnsurf(nsrf),'W/m2')
-C  
-        zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"lat_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c       call writephy(fid_day,prof2d_av,'lat_'//clnsurf(nsrf),
-c    .                fluxlat( 1 : klon, nsrf),
-c    .                'Latent heat flux '//clnsurf(nsrf),'W/m2')
-C
-        zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"taux_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c       call writephy(fid_day,prof2d_av,'taux_'//clnsurf(nsrf),
-c    .                fluxu( 1 : klon, 1, nsrf),
-c    .                'Zonal wind stress '//clnsurf(nsrf),'Pa')
-C      
-        zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"tauy_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c       call writephy(fid_day,prof2d_av,'tauy_'//clnsurf(nsrf),
-c    .                fluxv( 1 : klon, 1, nsrf),
-c    .                'Meridional wind stress '//clnsurf(nsrf),'Pa')
-C
-        zx_tmp_fi2d(1 : klon) = falbe( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"albe_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c       call writephy(fid_day,prof2d_av,'albe_'//clnsurf(nsrf),
-c    .                falbe( 1 : klon, nsrf),
-c    .                'Albedo surf. SW'//clnsurf(nsrf),'-')
-c       call writephy(fid_day,prof2d_av,'alblw_'//clnsurf(nsrf),
-c    .                falblw( 1 : klon, nsrf),
-c    .                'Albedo surf. LW'//clnsurf(nsrf),'-')
-C
-        zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"rugs_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-c       call writephy(fid_day,prof2d_av,'rugs_'//clnsurf(nsrf),
-c    .                frugs( 1 : klon, nsrf),
-c    .                'Rugosity '//clnsurf(nsrf),' - ')
-C 
-      END DO  
-C
-c$$$      DO i = 1, klon
-c$$$         zx_tmp_fi2d(i) = pctsrf(i,is_sic)
-c$$$      ENDDO
-c$$$      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-c$$$      CALL histwrite(nid_day,"sicf",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldl,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'cldl',cldl,
-c    .              'Low-level cloudiness','-')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldm,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'cldm',cldm,
-c    .              'Mid-level cloudiness','-')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldh,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'cldh',cldh,
-c    .              'High-level cloudiness','-')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldt",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'cldt',cldt,
-c    .              'Total cloudiness','-')
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldq,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldq",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     call writephy(fid_day,prof2d_av,'cldq',cldq,
-c    .              'Cloud liquid water path','-')
-c
-c Champs 3D:
-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 Essai writephys
-      varname = 'temp'
-      vartitle= 'temperature 3D'
-      varunits= 'K'
-c     call writephy(fid_day,prof3d_av,varname,t_seri,vartitle,varunits)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
-      CALL histwrite(nid_day,"ovap",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c     call writephy(fid_day,prof3d_av,'ovap',qx(1,1,ivap),
-c    .              'Specific humidity','Kg/Kg')
-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 writephy(fid_day,prof3d_av,'geop',zphi,
-c    .              'Geopotential height','m')
-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 writephy(fid_day,prof3d_av,'vitu',u_seri,
-c    .              'Zonal wind','m/s')
-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 writephy(fid_day,prof3d_av,'vitv',v_seri,
-c    .              'Meridional wind','m/s')
-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 writephy(fid_day,prof3d_av,'vitw',omega,
-c    .              'Vertical wind','m/s')
-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 writephy(fid_day,prof3d_av,'pres',pplay,
-c    .              'Air pressure','Pa')
-
-c
-      if (ok_sync) then
-c       call writephy_sync(fid_day)
-        call histsync(nid_day)
-      endif
-      ENDIF
-C
-      IF (ok_mensuel) THEN
-c
-      ndex2d = 0
-      ndex3d = 0
-c
-c Champs 2D:
-c
-         zsto = dtime
-         zout = dtime * ecrit_mth
-         itau_w = itau_phy + itap
-
-      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,paire,zx_tmp_2d)
-      CALL histwrite(nid_mth,"aire",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,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
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxqsol,zx_tmp_2d)
-      CALL histwrite(nid_mth,"qsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"precip",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"plul",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"pluc",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
-      CALL histwrite(nid_mth,"snow",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
-      CALL histwrite(nid_mth,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, evap,zx_tmp_2d)
-      CALL histwrite(nid_mth,"evap",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-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 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 gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
-      CALL histwrite(nid_mth,"solldown",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw0,zx_tmp_2d)
-      CALL histwrite(nid_mth,"tops0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw0,zx_tmp_2d)
-      CALL histwrite(nid_mth,"topl0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw0,zx_tmp_2d)
-      CALL histwrite(nid_mth,"sols0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw0,zx_tmp_2d)
-      CALL histwrite(nid_mth,"soll0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, bils,zx_tmp_2d)
-      CALL histwrite(nid_mth,"bils",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sens,zx_tmp_2d)
-      CALL histwrite(nid_mth,"sens",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
-      CALL histwrite(nid_mth,"fder",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c
-c      DO i = 1, klon
-c         zx_tmp_fi2d(i) = fluxu(i,1)
-c      ENDDO
-c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-c      CALL histwrite(nid_mth,"frtu",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c      DO i = 1, klon
-c         zx_tmp_fi2d(i) = fluxv(i,1)
-c      ENDDO
-c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-c      CALL histwrite(nid_mth,"frtv",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      DO nsrf = 1, nbsrf
-C§§§
-        zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"pourc_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C 
-        zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"tsol_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-C
-        zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"sens_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-C
-        zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"lat_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C
-        zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"taux_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C      
-        zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"tauy_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-C 
-        zx_tmp_fi2d(1 : klon) = falbe( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"albe_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-C
-        zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"rugs_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, agesno,zx_tmp_2d)
-      CALL histwrite(nid_mth,"ages_"//clnsurf(nsrf),itau_w
-     $    ,zx_tmp_2d,iim*jjmp1,ndex2d)
-
-      END DO  
-c$$$      DO i = 1, klon
-c$$$         zx_tmp_fi2d(i) = pctsrf(i,is_sic)
-c$$$      ENDDO
-c$$$      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-c$$$      CALL histwrite(nid_mth,"sicf",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsol,zx_tmp_2d)
-      CALL histwrite(nid_mth,"albs",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsollw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"albslw",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,"cdrm",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,"cdrh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldl,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldm,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldh,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldt",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldq,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldq",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ue,zx_tmp_2d)
-      CALL histwrite(nid_mth,"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_mth,"ve",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, uq,zx_tmp_2d)
-      CALL histwrite(nid_mth,"uq",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, vq,zx_tmp_2d)
-      CALL histwrite(nid_mth,"vq",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-cKE43
-      IF (iflag_con .GE. 3) THEN ! sb
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cape,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cape",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,pbase,zx_tmp_2d)
-      CALL histwrite(nid_mth,"pbase",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,ema_pct,zx_tmp_2d)
-      CALL histwrite(nid_mth,"ptop",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,ema_cbmf,zx_tmp_2d)
-      CALL histwrite(nid_mth,"fbase",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c
-      ENDIF
-c34EK
-c
-c Champs 3D:
-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, qx(1,1,ivap), zx_tmp_3d)
-      CALL histwrite(nid_mth,"ovap",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(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 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, cldfra, zx_tmp_3d)
-      CALL histwrite(nid_mth,"rneb",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zx_rh, zx_tmp_3d)
-      CALL histwrite(nid_mth,"rhum",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldliq, zx_tmp_3d)
-      CALL histwrite(nid_mth,"oliq",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, clwcon0, zx_tmp_3d)
-      CALL histwrite(nid_mth,"clwcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      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 gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_dyn, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_con, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_con, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_lsc, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtlsc",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_lsc, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqlsc",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      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 gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_vdf, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_eva, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dteva",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_eva, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqeva",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      zpt_conv = 0.
-      where (ptconv) zpt_conv = 1.
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zpt_conv, zx_tmp_3d)
-      CALL histwrite(nid_mth,"ptconv",itau_w,zx_tmp_3d,
-     .                                   iim*(jjmp1)*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, ratqs, zx_tmp_3d)
-      CALL histwrite(nid_mth,"ratqs",itau_w,zx_tmp_3d,
-     .                                   iim*(jjmp1)*klev,ndex3d)
-c
-      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 gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_ajs, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtswr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat0, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtsw0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtlwr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool0, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtlw0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      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
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dvvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      IF (ok_orodr) THEN
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oro, zx_tmp_3d)
-      CALL histwrite(nid_mth,"duoro",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_oro, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dvoro",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      ENDIF
-C
-      IF (ok_orolf) THEN
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_lif, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dulif",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_lif, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dvlif",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-      ENDIF
-C
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, wo, zx_tmp_3d)
-      CALL histwrite(nid_mth,"ozone",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-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_mth,"trac"//str2,itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-      ELSE
-         PRINT*, "Trop de traceurs"
-         CALL abort
-      ENDIF
-      ENDDO
-      ENDIF
-cKE43
-      IF (iflag_con.GE.3) THEN ! (sb)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, upwd, zx_tmp_3d)
-      CALL histwrite(nid_mth,"upwd",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, dnwd, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dnwd",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, dnwd0, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dnwd0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, Ma, zx_tmp_3d)
-      CALL histwrite(nid_mth,"Ma",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-c
-      ENDIF
-c34EK
-c
-      if (ok_sync) then
-        call histsync(nid_mth)
-      endif
-      ENDIF
-c
-      IF (ok_instan) THEN
-c
-      ndex2d = 0
-      ndex3d = 0
-c
-c Champs 2D:
-c
-         zsto = dtime * ecrit_ins
-         zout = dtime * ecrit_ins
-         itau_w = itau_phy + itap
-
-         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,paire,zx_tmp_2d)
-      CALL histwrite(nid_ins,"aire",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-
-      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
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_ins,"precip",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_ins,"plul",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
-      ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_ins,"pluc",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
-      CALL histwrite(nid_ins,"tsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
-      CALL histwrite(nid_ins,"snow",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
-      CALL histwrite(nid_ins,"cdrm",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,"cdrh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-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, evap,zx_tmp_2d)
-      CALL histwrite(nid_ins,"evap",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 gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
-      CALL histwrite(nid_ins,"solldown",itau_w,zx_tmp_2d,iim*jjmp1,
-     .                ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, bils,zx_tmp_2d)
-      CALL histwrite(nid_ins,"bils",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sens,zx_tmp_2d)
-      CALL histwrite(nid_ins,"sens",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
-      CALL histwrite(nid_ins,"fder",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_oce),zx_tmp_2d)
-      CALL histwrite(nid_ins,"dtsvdfo",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_ter),zx_tmp_2d)
-      CALL histwrite(nid_ins,"dtsvdft",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_lic),zx_tmp_2d)
-      CALL histwrite(nid_ins,"dtsvdfg",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_sic),zx_tmp_2d)
-      CALL histwrite(nid_ins,"dtsvdfi",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-
-      DO nsrf = 1, nbsrf
-C§§§
-        zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"pourc_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C 
-        zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"sens_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C
-        zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"lat_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C
-        zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"tsol_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C
-        zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"taux_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C      
-        zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"tauy_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-C
-        zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"rugs_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C
-        zx_tmp_fi2d(1 : klon) = falbe( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"albe_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
-C 
-      END DO  
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsol,zx_tmp_2d)
-      CALL histwrite(nid_ins,"albs",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsollw,zx_tmp_2d)
-      CALL histwrite(nid_ins,"albslw",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
-      CALL histwrite(nid_ins,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxrugs,zx_tmp_2d)
-      CALL histwrite(nid_ins,"rugs",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-c Champs 3D:
-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, 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(nid_ins,"vitv",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, 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, d_t_vdf, zx_tmp_3d)
-      CALL histwrite(nid_ins,"dtvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_vdf, zx_tmp_3d)
-      CALL histwrite(nid_ins,"dqvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-
-c
-      if (ok_sync) then
-        call histsync(nid_ins)
-      endif
-      ENDIF
-c
-c
-c Ecrire la bande regionale (binaire grads)
-      IF (ok_region .AND. mod(itap,ecrit_reg).eq.0) THEN
-         CALL ecriregs(84,zxtsol)
-         CALL ecriregs(84,paprs(1,1))
-         CALL ecriregs(84,topsw)
-         CALL ecriregs(84,toplw)
-         CALL ecriregs(84,solsw)
-         CALL ecriregs(84,sollw)
-         CALL ecriregs(84,rain_fall)
-         CALL ecriregs(84,snow_fall)
-         CALL ecriregs(84,evap)
-         CALL ecriregs(84,sens)
-         CALL ecriregs(84,bils)
-         CALL ecriregs(84,pctsrf(1,is_sic))
-         CALL ecriregs(84,zxfluxu(1,1))
-         CALL ecriregs(84,zxfluxv(1,1))
-         CALL ecriregs(84,ue)
-         CALL ecriregs(84,ve)
-         CALL ecriregs(84,uq)
-         CALL ecriregs(84,vq)
-c
-         CALL ecrirega(84,u_seri)
-         CALL ecrirega(84,v_seri)
-         CALL ecrirega(84,omega)
-         CALL ecrirega(84,t_seri)
-         CALL ecrirega(84,zphi)
-         CALL ecrirega(84,q_seri)
-         CALL ecrirega(84,cldfra)
-         CALL ecrirega(84,cldliq)
-         CALL ecrirega(84,pplay)
-
-
-cc         CALL ecrirega(84,d_t_dyn)
-cc         CALL ecrirega(84,d_q_dyn)
-cc         CALL ecrirega(84,heat)
-cc         CALL ecrirega(84,cool)
-cc         CALL ecrirega(84,d_t_con)
-cc         CALL ecrirega(84,d_q_con)
-cc         CALL ecrirega(84,d_t_lsc)
-cc         CALL ecrirega(84,d_q_lsc)
-      ENDIF
+cccIM cf. FH
+c=======================================================================
+c   SORTIES
+c=======================================================================
+
+c   Interpollation sur quelques niveaux de pression
+c   -----------------------------------------------
+
+      call plevel(klon,klev,.true. ,pplay,85000.,u_seri,u850)
+      call plevel(klon,klev,.false.,pplay,85000.,v_seri,v850)
+      call plevel(klon,klev,.true. ,pplay,50000.,u_seri,u500)
+      call plevel(klon,klev,.false.,pplay,50000.,v_seri,v500)
+      call plevel(klon,klev,.true. ,pplay,20000.,u_seri,u200)
+      call plevel(klon,klev,.false.,pplay,20000.,v_seri,v200)
+      call plevel(klon,klev,.true. ,pplay,50000.,zphi,phi500)
+
+c=============================================================
+c   Ecriture des sorties
+c=============================================================
+
+#ifdef histhf
+#include "write_histhf.h"
+#endif
+
+#include "write_histday.h"
+#include "write_histmth.h"
+#include "write_histins.h"
+
+c=============================================================
 c
 c Convertir les incrementations en tendances
