c
c $Header$
c
      IF (ok_mensuel) THEN
c
       zstophy = dtime
       zstomth = ecrit_mth                !valeurs mensuelles "instantannees"
       zstorad = dtime * FLOAT(radpas)    !variables stockees toutes les 2h
       zstohf = ecrit_hf                  !variables stockees toutes les 6h
       zout = ecrit_mth                   !frequence des sorties : 1 val. par mois
c
c     PRINT*,' La zstophy,zstorad,zstohf,zstomth,zout=',
c   . zstophy,zstorad,zstohf,zstomth,zout
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
c
cIM cf. AM 081204 BEG region
c         imin_histmth=1
c         imax_histmth=iim
c         jmin_histmth=1
c         jmax_histmth=jjmp1
c         do i=1,iim-1
c            if(zx_lon(i,1).lt.lonmin_histmth) imin_histmth=i
c            if(zx_lon(i,1).le.lonmax_histmth) imax_histmth=i+1
c         enddo
c         do j=1,jjmp1-1
c            if(zx_lat(1,j).ge.latmin_histmth) jmax_histmth=j
c            if(zx_lat(1,j).gt.latmax_histmth) jmin_histmth=j
c         enddo
c
c         print*,'On stoke le fichier instantanne sur, ',
c     s   imin_histmth,imax_histmth,jmin_histmth,jmax_histmth
c         print*,'On stoke le fichier instantanne sur, ',
c     s   zx_lon(imin_histmth,1),zx_lon(imax_histmth,1),
c     s   zx_lat(1,jmin_histmth),zx_lat(1,jmax_histmth)
cIM cf. AM 081204 END region
c
         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)
c
cIM cf. AM 081204 BEG region
c         CALL histbeg("histmth.nc", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
c     .                 imin_histmth,imax_histmth-imin_histmth+1
c     .                 ,jmin_histmth,jmax_histmth-jmin_histmth+1
c     .                 , itau_phy, zjulian, dtime,
c     .                 nhori, nid_mth)
cIM 081204 END
c
         CALL histvert(nid_mth, "presnivs", "Vertical levels", "mb",
     .                 klev, presnivs/100., nvert)
c
      IF(type_run.EQ."CLIM".OR.type_run.EQ."ENSP") THEN
c
      IF(lev_histmth.GE.1) THEN
c
         CALL histdef(nid_mth, "phis", 
     .                "Surface geop. height", "m2/s2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "once",  zstophy,zout)
c
         CALL histdef(nid_mth, "aire", "Grid area", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "once",  zstophy,zout)
c
         CALL histdef(nid_mth, "pourc_"//clnsurf(is_ter), 
     .         "% "//clnsurf(is_ter), "%",  
     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
     .         "once", zstophy,zout)
c
         CALL histdef(nid_mth, "fract_"//clnsurf(is_ter), 
     .         "Fraction "//clnsurf(is_ter), "1",  
     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
     .         "once", zstophy,zout)
c
c Champs 2D:
c
         CALL histdef(nid_mth, "slp", "Sea Level Pressure", "Pa",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "tsol", "Surface Temperature", "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "t2m", "Temperature 2m", "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
c ENSEMBLES BEG
         CALL histdef(nid_mth, "t2m_min", "Temp. 2m min.",
     .                "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                t2mincels, zstophy,zout)
c
         CALL histdef(nid_mth, "t2m_max", "Temp. 2m max.",
     .                "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                t2maxcels, zstophy,zout)
c
c        CALL histdef(nid_mth, "tsoil", "Sfce soil Temperature",
c    .                "K",
c    .                iim,jjmp1,nhori, 1,1,1, -99, 32,
c    .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "wind10m","10-m wind speed","m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "sicf", "Sea-ice fraction", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
c ENSEMBLES END
         CALL histdef(nid_mth, "q2m", "Specific humidity 2m", "kg/kg",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "u10m", "Vent zonal 10m", "m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "v10m", "Vent meridien 10m", "m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "psol", "Surface Pressure", "Pa",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "qsurf", "Surface Air humidity", "kg/kg",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
      if (.not. ok_veget) then
         CALL histdef(nid_mth, "qsol", "Soil watter content", "mm",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
      endif
c
         CALL histdef(nid_mth, "ndayrain", 
     .                "Number of day with rain (liq+sol)", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "inst(X)", zstomth,zout)
c
         CALL histdef(nid_mth, "precip", "Precipitation Totale liq+sol", 
     .                "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "plul", "Large-scale Precip.", 
     .   "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "pluc", "Convective Precip.", 
     .   "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "snow", "Snow fall", "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
c        CALL histdef(nid_mth, "snow_mass", "Snow Mass", "kg/m2",
c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
c    .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "evap", "Evaporation", "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "tops", "Solar rad. at TOA", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "tops0", "CS Solar rad. at TOA", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "topl", "IR rad. at TOA", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "topl0", "IR rad. at TOA", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWupTOA", "SWup at TOA","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWupTOAclr", 
     .                "SWup clear sky at TOA","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdnTOA", "SWdn at TOA","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdnTOAclr", 
     .                "SWdn clear sky at TOA","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWup200", "SWup at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWup200clr", 
     .                "SWup clear sky at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdn200", "SWdn at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdn200clr", 
     .                "SWdn clear sky at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "LWup200", "LWup at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "LWup200clr", 
     .                "LWup clear sky at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "LWdn200", "LWdn at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "LWdn200clr", 
     .                "LWdn clear sky at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "sols", "Solar rad. at surf.", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "sols0", "Solar rad. at surf.", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "soll", "IR rad. at surface", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "soll0", "IR rad. at surface", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWupSFC", "SWup at surface","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWupSFCclr", 
     .                "SWup clear sky at surface","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdnSFC", "SWdn at surface","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdnSFCclr", 
     .                "SWdn clear sky at surface","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"LWupSFC","Upwd. IR rad. at surface", 
     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"LWdnSFC","Down. IR rad. at surface", 
     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"LWupSFCclr",
     .                "CS Upwd. IR rad. at surface", 
     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"LWdnSFCclr",
     .                "Down. CS IR rad. at surface", 
     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "bils", "Surf. total heat flux", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "sens", "Sensible heat flux", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "fder", "Heat flux derivation", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
c          CALL histdef(nid_mth, "frtu", "Zonal wind stress", "Pa",
c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
c    .                "ave(X)", zstophy,zout)
c
c        CALL histdef(nid_mth, "frtv", "Meridional wind stress", "Pa",
c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
c    .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ffonte","Thermal flux for snow melting",
     .                "W/m2",iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "fqcalving","Ice Calving",
     .                "kg/m2/s",iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         DO nsrf = 1, nbsrf
           call histdef(nid_mth, "taux_"//clnsurf(nsrf), 
     $         "Zonal wind stress"//clnsurf(nsrf), "Pa",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)

           call histdef(nid_mth, "tauy_"//clnsurf(nsrf), 
     $         "Meridional wind stress "//clnsurf(nsrf), "Pa",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
         ENDDO
c
         DO nsrf = 1, nbsrf
C
          IF(nsrf.GT.2) THEN
           call histdef(nid_mth, "pourc_"//clnsurf(nsrf), 
     $         "% "//clnsurf(nsrf), "%",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
c
           call histdef(nid_mth, "fract_"//clnsurf(nsrf), 
     $         "Fraction "//clnsurf(nsrf), "1",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
          ENDIF !nsrf.GT.2
C
           call histdef(nid_mth, "tsol_"//clnsurf(nsrf), 
     $         "Temperature "//clnsurf(nsrf), "K",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,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)", zstophy,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)", zstophy,zout)
C
           call histdef(nid_mth, "flw_"//clnsurf(nsrf),
     $         "LW "//clnsurf(nsrf), "W/m2",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
c
           call histdef(nid_mth, "fsw_"//clnsurf(nsrf),
     $         "SW "//clnsurf(nsrf), "W/m2",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
C
           call histdef(nid_mth, "wbils_"//clnsurf(nsrf),
     $         "Bilan sol "//clnsurf(nsrf), "W/m2",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
C
cIM 250105 BEG
          IF(1.EQ.0) THEN
C
           call histdef(nid_mth, "evapour_"//clnsurf(nsrf),
     $         "Evap*pourc "//clnsurf(nsrf), "kg/(s*m2)",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
C
           call histdef(nid_mth, "prepour_"//clnsurf(nsrf),
     $         "Precip*pourc "//clnsurf(nsrf), "kg/(s*m2)",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
C
          ENDIF !(1.EQ.0) THEN
cIM 250105 END
C
         END DO
c
         CALL histdef(nid_mth, "cdrm", "Momentum drag coef.", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cdrh", "Heat drag coef.", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cldl", "Low-level cloudiness", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cldm", "Mid-level cloudiness", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cldh", "High-level cloudiness", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cldt", "Total cloudiness", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"cldq","Cloud liquid water path","kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"lwp","Cloud water path","kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"iwp","Cloud ice water path","kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ue", "Zonal energy transport", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ve", "Merid energy transport", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "uq", "Zonal humidity transport", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "vq", "Merid humidity transport", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,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)", zstophy,zout)
c
         CALL histdef(nid_mth, "pbase", "Cld base pressure", "mb",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ptop", "Cld top pressure", "mb",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "fbase", "Cld base mass flux", "kg/m2/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "prw", "Precipitable water", "kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
      ENDIF !iflag_con .GE. 3
c34EK
cIM cf. AM 081204 BEG
c34EK
c HBTM2
         CALL histdef(nid_mth, "s_pblh", "Boundary Layer Height", "m",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_pblt", "t at Boundary Layer Height",
     .                "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_lcl", "Condensation level", "m",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_capCL", "Conv avlbl pot ener 
     .                for ABL", "J/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_oliqCL", "Liq Water in BL", "kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_cteiCL", "Instability criteria 
     .                (ABL)", "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_therm", "Exces du thermique", "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_trmb1", "deep_cape(HBTM2)", "J/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_trmb2", "inhibition (HBTM2)", "J/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_trmb3", "Point Omega (HBTM2)", "m",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
cIM cf. AM 081204 END
c
c Champs interpolles sur des niveaux de pression
         DO k=1, nlevSTD
c
c        bb=clevSTD(k)
c
c        IF(k.GE.2) THEN
         IF(k.GE.2.AND.k.LE.12) bb2=clevSTD(k)
         IF(k.GE.13.AND.k.LE.17) bb3=clevSTD(k)
c         aa=clevSTD(k)
c         bb=aa(1:lnblnk1(aa))
c        ENDIF
c
      IF(bb2.EQ."850".OR.bb2.EQ."700".OR.
     $   bb2.EQ."500".OR.bb2.EQ."200") THEN
c
          CALL histdef(nid_mth, "u"//bb2,
     .                 "Zonal wind "//bb2//"mb","m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_mth, "v"//bb2,
     .                 "Meridional wind "//bb2//"mb","m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_mth, "w"//bb2,
     .                 "Vertical wind "//bb2//"mb","m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_mth, "phi"//bb2,
     .                 "Geopotential "//bb2//"mb","m",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "inst(X)", zout,zout)
c
        ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
       ENDDO
c
cIM diagnostiques flux ocean-atm ou ocean-glace de mer
cIM pour utilisation dans un modele de "slab" ocean
c
       CALL histdef(nid_mth, "fluxo",
     .              "Flux turbulents ocean-atmosphere", "W/m2",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
       CALL histdef(nid_mth, "fluxg",
     .              "Flux turbulents ocean-glace de mer","W/m2",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
       IF (OCEAN.EQ.'force ') THEN
c
        CALL histdef(nid_mth, "lmt_bils",
     .       "Bilan au sol atmosphere forcee", "W/m2",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
       ELSE IF (OCEAN.EQ.'slab  ') THEN
c
        CALL histdef(nid_mth, "slab_bils",
     .       "Bilan au sol Slab", "W/m2",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
        CALL histdef(nid_mth, "tslab", "Slab SST ", "K",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
        CALL histdef(nid_mth, "seaice", "Slab seaice", "kg/m2",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
        CALL histdef(nid_mth, "siceh", "Slab seaice height", "m",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
       ENDIF
c
      ENDIF !lev_histmth.GE.1
c
      IF(lev_histmth.GE.2) THEN
c
c Champs 3D:
c
c
         CALL histdef(nid_mth,"lwcon","Cloud liquid water content",
     .                "kg/kg",
     .                iim,jjmp1,nhori, klev,1,klev, nvert, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"iwcon","Cloud ice water content","kg/kg",
     .                iim,jjmp1,nhori, klev,1,klev, nvert, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "temp", "Air temperature", "K",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ovap", "Specific humidity", "kg/kg",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
c        CALL histdef(nid_mth,"wvap","Water vapor mixing ratio","kg/kg",
c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
c    .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "geop", "Geopotential height", "m2/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "vitu", "Zonal wind", "m/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "vitv", "Meridional wind", "m/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "vitw", "Vertical wind", "m/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "pres", "Air pressure", "Pa",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
        CALL histdef(nid_mth, "rneb", "Cloud fraction", "-",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "rnebcon", "Convective Cloud Fraction"
     .                , "-",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "rhum", "Relative humidity", "-",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ozone", "Ozone concentration", "ppmv",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "upwd", "saturated updraft", "kg/m2/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtphy", "Physics dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqphy", "Physics dQ", "(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
      ENDIF !lev_histmth.GE.2
c
      IF(lev_histmth.GE.3) THEN
c
        DO nsrf=1, nbsrf
c
           call histdef(nid_mth, "albe_"//clnsurf(nsrf), 
     $         "Albedo surf. "//clnsurf(nsrf), "-",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,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)", zstophy,zout)
c
         CALL histdef(nid_mth, "ages_"//clnsurf(nsrf), "Snow age","day",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
	 ENDDO !nsrf=1, nbsrf
c
         CALL histdef(nid_mth, "albs", "Surface albedo", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "albslw", "Surface albedo LW", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
      ENDIF !lev_histmth.GE.3
c
      IF(lev_histmth.GE.4) THEN
c
         CALL histdef(nid_mth, "clwcon", 
     .                "Convective Cloud Liquid water content"
     .                , "kg/kg",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"Ma","undilute adiab updraft","kg/m2/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dnwd", "saturated downdraft","kg/m2/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dnwd0", "unsat. downdraft", "kg/m2/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtdyn", "Dynamics dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqdyn", "Dynamics dQ", "(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtcon", "Convection dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
c        CALL histdef(nid_mth, "ducon", "Convection du", "m/s2",
c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
c    .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqcon", "Convection dQ", "(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtlsc", "Condensation dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtlschr",
     $       "Large-scale condensational heating rate", "K/s",iim,jjmp1
     $       ,nhori, klev,1,klev,nvert, 32,"ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqlsc", "Condensation dQ", "(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtvdf", "Boundary-layer dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqvdf","Boundary-layer dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dteva", "Reevaporation dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqeva","Reevaporation dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)

         CALL histdef(nid_mth, "ptconv", "POINTS CONVECTIFS"," ",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)

         CALL histdef(nid_mth, "ratqs", "RATQS"," ",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)

c
         CALL histdef(nid_mth, "dtajs", "Dry adjust. dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)

         CALL histdef(nid_mth,"dqajs","Dry adjust. dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtswr", "SW radiation dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtsw0", "CS SW radiation dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtlwr", "LW radiation dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"dtlw0","CS LW radiation dT","K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtec", "Cinetic dissip dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "duvdf", "Boundary-layer dU", "m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dvvdf", "Boundary-layer dV", "m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,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)", zstophy,zout)
c
         CALL histdef(nid_mth, "dvoro", "Orography dV", "m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,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)", zstophy,zout)
c
         CALL histdef(nid_mth, "dvlif", "Orography dV", "m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
         ENDIF
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)", zstophy,zout)
         ELSE
         PRINT*, "Trop de traceurs"
         CALL abort
         ENDIF
         ENDDO
         ENDIF
c
      ENDIF !lev_histmth.GE.4
c
      ELSE IF(type_run.EQ."AMIP".OR.type_run.EQ."CFMI") THEN
c
      IF(lev_histmth.GE.1) THEN
c
         CALL histdef(nid_mth, "phis", "Surface geop. height", "m",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "once",  zstophy,zout)
c
         CALL histdef(nid_mth, "aire", "Grid area", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "once",  zstophy,zout)
c
         CALL histdef(nid_mth, "pourc_"//clnsurf(is_ter), 
     .         "% "//clnsurf(is_ter), "%",  
     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
     .         "once", zstophy,zout)
c
         CALL histdef(nid_mth, "fract_"//clnsurf(is_ter), 
     .         "Fraction "//clnsurf(is_ter), "1",  
     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
     .         "once", zstophy,zout)
c
         CALL histdef(nid_mth, "pourc_"//clnsurf(is_lic), 
     .         "% "//clnsurf(is_lic), "%",  
     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
     .         "once", zstophy,zout)
c
         CALL histdef(nid_mth, "fract_"//clnsurf(is_lic), 
     .         "Fraction "//clnsurf(is_lic), "1",  
     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
     .         "once", zstophy,zout)
c
         CALL histdef(nid_mth, "pourc_"//clnsurf(is_sic),
     .         "% "//clnsurf(is_sic), "%",
     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "fract_"//clnsurf(is_sic),
     .         "Fraction "//clnsurf(is_sic), "1",
     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "flat", "Latent heat flux", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "bilTOA",
     .                "Net radiation at TOA", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
c
c        CALL histdef(nid_mth, "tops01",
c    .                "TOA reflected clear-sky shortwave 
c    .                radiation (method 1)", "W/m2",
c    .                iim,jjmp1,nhori, 1,1,1, -99, 32,
c    .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dtdia","dtdia","K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dtsw","dtsw","K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dtlw","dtlw","K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dtcon","dtcon","K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dtajs","dtajs","K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dtlsc","dtlsc","K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dqdia","dqdia","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "duoli",
     .         "duoli","m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dvoli",
     .         "dvoli","m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "ducon",
     .         "ducon","m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dvcon",
     .         "dvcon","m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dutot",
     .         "dutot","m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "dvtot",
     .         "dvtot","m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
c         CALL histdef(nid_mth, "cldtrue",
c    .         "TRUE Cloud fraction ","%",
c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
c    .         "inst(X)", zout,zout)
c
c         CALL histdef(nid_mth, "cldTOA",
c    .         "Cloud amount (satellite view)","%",
c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
c    .         "ave(X)", zstophy,zout)
c
c         CALL histdef(nid_mth, "cldSFC",
c    .         "Cloud amount (surface view)","%",
c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
c    .         "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "GWDtaux",
     .         "GWD induced Ewd wind stress","Pa",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .         "ave(X)", zstophy,zout)
c
          CALL histdef(nid_mth, "GWDtauy",
     .         "GWD induced Nwd wind stress","Pa",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .         "ave(X)", zstophy,zout)
c
c Champs 2D:
c
         CALL histdef(nid_mth, "slp", "Sea Level Pressure", "Pa",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstorad,zout)
c
         CALL histdef(nid_mth, "tsol", "Surface Temperature", "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "t2m", "Temperature 2m", "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstorad,zout)
c
         CALL histdef(nid_mth, "t2m_min", "Temp. 2m min.",
     .                "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                t2mincels, zstophy,zout)
c
         CALL histdef(nid_mth, "t2m_max", "Temp. 2m max.",
     .                "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                t2maxcels, zstophy,zout)
c
c        CALL histdef(nid_mth, "tsoil", "Sfce soil Temperature",
c    .                "K",
c    .                iim,jjmp1,nhori, 1,1,1, -99, 32,
c    .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "wind10m","10-m wind speed","m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstorad,zout)
c
         CALL histdef(nid_mth, "sicf", "Sea-ice fraction", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)

c
         CALL histdef(nid_mth, "q2m","Specific humidity 2m","kg/kg",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstorad,zout)
c
         CALL histdef(nid_mth, "u10m", "Vent zonal 10m", "m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstorad,zout)
c
         CALL histdef(nid_mth, "v10m", "Vent meridien 10m", "m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstorad,zout)
c
         CALL histdef(nid_mth, "psol", "Surface Pressure", "Pa",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstorad,zout)
c
         CALL histdef(nid_mth, "qsurf","Surface Air humidity","kg/kg",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
      if (.not. ok_veget) then
         CALL histdef(nid_mth, "qsol", "Soil watter content", "mm",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
      endif
c
         CALL histdef(nid_mth, "ndayrain", 
     .                "Number of day with rain (liq+sol)", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "inst(X)", zstomth,zout)
c
         CALL histdef(nid_mth, "precip", "Precipitation Totale liq+sol", 
     .                "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "plul", "Large-scale Precip.", 
     .   "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "pluc", "Convective Precip.", 
     .   "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "snowf", "Snow fall", "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
c        CALL histdef(nid_mth, "snow_mass", "Snow Mass", "kg/m2",
c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
c    .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "evap", 
     .                "Evaporation plus sublimation rate", "kg/(s*m2)",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "tops", "Solar rad. at TOA", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "tops0", "CS Solar rad. at TOA", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "topl", "IR rad. at TOA", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "topl0", "IR rad. at TOA", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWupTOA", "SWup at TOA","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWupTOAclr", 
     .                "SWup clear sky at TOA","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdnTOA", "SWdn at TOA","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdnTOAclr", 
     .                "SWdn clear sky at TOA","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWup200", "SWup at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWup200clr", 
     .                "SWup clear sky at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdn200", "SWdn at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdn200clr", 
     .                "SWdn clear sky at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "LWup200", "LWup at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "LWup200clr", 
     .                "LWup clear sky at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "LWdn200", "LWdn at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "LWdn200clr", 
     .                "LWdn clear sky at 200mb","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "sols", "Solar rad. at surf.", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "sols0", "Solar rad. at surf.", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "soll", "IR rad. at surface", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "soll0", "IR rad. at surface", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWupSFC", "SWup at surface","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWupSFCclr", 
     .                "SWup clear sky at surface","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdnSFC", "SWdn at surface","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "SWdnSFCclr", 
     .                "SWdn clear sky at surface","W/m2",
     .                iim,jjmp1,nhori, 1,1,1,-99,
     .                32, "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"LWupSFC","Upwd. IR rad. at surface", 
     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"LWdnSFC","Down. IR rad. at surface", 
     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"LWupSFCclr",
     .                "CS Upwd. IR rad. at surface", 
     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"LWdnSFCclr",
     .                "Down. CS IR rad. at surface", 
     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "bils", "Surf. total heat flux", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "sens", "Sensible heat flux", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "fder", "Heat flux derivation", "W/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
c          CALL histdef(nid_mth, "frtu", "Zonal wind stress", "Pa",
c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
c    .                "ave(X)", zstophy,zout)
c
c        CALL histdef(nid_mth, "frtv", "Meridional wind stress", "Pa",
c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
c    .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ffonte","Thermal flux for snow melting",
     .                "W/m2",iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "fqcalving","Ice Calving",
     .                "kg/m2/s",iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         DO nsrf = 1, nbsrf
           call histdef(nid_mth, "taux_"//clnsurf(nsrf), 
     $         "Zonal wind stress"//clnsurf(nsrf), "Pa",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)

           call histdef(nid_mth, "tauy_"//clnsurf(nsrf), 
     $         "Meridional wind stress "//clnsurf(nsrf), "Pa",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
         ENDDO
c
           call histdef(nid_mth, "pourc_"//clnsurf(is_oce), 
     $         "% "//clnsurf(is_oce), "%",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
c
           call histdef(nid_mth, "fract_"//clnsurf(is_oce), 
     $         "Fraction "//clnsurf(is_oce), "1",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
C
         DO nsrf = 1, nbsrf
C
           call histdef(nid_mth, "tsol_"//clnsurf(nsrf), 
     $         "Temperature "//clnsurf(nsrf), "K",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,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)", zstophy,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)", zstophy,zout)
C
           call histdef(nid_mth, "flw_"//clnsurf(nsrf),
     $         "LW "//clnsurf(nsrf), "W/m2",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
c
           call histdef(nid_mth, "fsw_"//clnsurf(nsrf),
     $         "SW "//clnsurf(nsrf), "W/m2",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
C
           call histdef(nid_mth, "wbils_"//clnsurf(nsrf),
     $         "Bilan sol "//clnsurf(nsrf), "W/m2",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
C
cIM 250105 BEG
          IF(1.EQ.0) THEN
C
           call histdef(nid_mth, "evapour_"//clnsurf(nsrf),
     $         "Evap*pourc "//clnsurf(nsrf), "kg/(s*m2)",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
C
           call histdef(nid_mth, "prepour_"//clnsurf(nsrf),
     $         "Precip*pourc "//clnsurf(nsrf), "kg/(s*m2)",
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
C
          ENDIF !(1.EQ.0) THEN
cIM 250105 END
C
         END DO
c
         CALL histdef(nid_mth, "cdrm", "Momentum drag coef.", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cdrh", "Heat drag coef.", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cldl", "Low-level cloudiness", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cldm", "Mid-level cloudiness", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cldh", "High-level cloudiness", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "cldt", "Total cloudiness", "%",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"cldq","Cloud liquid water path","kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"lwp","Cloud water path","kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"iwp","Cloud ice water path","kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ue", "Zonal energy transport", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ve", "Merid energy transport", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "uq", "Zonal humidity transport", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "vq", "Merid humidity transport", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,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)", zstophy,zout)
c
         CALL histdef(nid_mth, "pbase", "Cld base pressure", "mb",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ptop", "Cld top pressure", "mb",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "fbase", "Cld base mass flux", "kg/m2/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "prw", "Precipitable water", "kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "upwd", "saturated updraft", "kg/m2/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
      ENDIF !iflag_con .GE. 3
c34EK
cIM cf. AM 081204 BEG
c34EK
c HBTM2
         CALL histdef(nid_mth, "s_pblh", "Boundary Layer Height", "m",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_pblt", "T at Boundary Layer Height",
     .                "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_lcl", "Condensation level", "m",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth,"s_capCL","Conv avlbl pot ener for ABL",
     .                "J/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_oliqCL", "Liq Water in BL", "kg/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth,"s_cteiCL","Instability criteria (ABL)",
     .                "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_therm", "Exces du thermique", "K",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_trmb1", "deep_cape(HBTM2)", "J/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_trmb2", "inhibition (HBTM2)", "J/m2",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "s_trmb3", "Point Omega (HBTM2)", "m",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "ave(X)", zstophy,zout)
c
cIM cf. AM 081204 END
c
c Champs interpolles sur des niveaux de pression
         DO k=1, nlevSTD
c
c        bb=clevSTD(k)
c
c        IF(k.GE.2) THEN
         IF(k.GE.2.AND.k.LE.12) bb2=clevSTD(k)
         IF(k.GE.13.AND.k.LE.17) bb3=clevSTD(k)
c         aa=clevSTD(k)
c         bb=aa(1:lnblnk1(aa))
c        ENDIF
c
       IF(bb2.EQ."850".OR.bb2.EQ."700"
     $   .OR.bb2.EQ."500".OR.bb2.EQ."200") THEN
c
          CALL histdef(nid_mth, "u"//bb2,
     .                 "Zonal wind "//bb2//"mb","m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_mth, "v"//bb2,
     .                 "Meridional wind "//bb2//"mb","m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_mth, "w"//bb2,
     .                 "Vertical wind "//bb2//"mb","m/s",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_mth, "phi"//bb2,
     .                 "Geopotential "//bb2//"mb","m",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
     .                "inst(X)", zout,zout)
c
         ENDIF !(bb2.EQ."850".OR.bb2.EQ."700"
c
       ENDDO !nlevSTD
c
cIM diagnostiques flux ocean-atm ou ocean-glace de mer
cIM pour utilisation dans un modele de "slab" ocean
c
       CALL histdef(nid_mth, "fluxo",
     .              "Flux turbulents ocean-atmosphere", "W/m2",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
       CALL histdef(nid_mth, "fluxg",
     .              "Flux turbulents ocean-glace de mer","W/m2",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
       IF (OCEAN.EQ.'force ') THEN
c
        CALL histdef(nid_mth, "lmt_bils",
     .       "Bilan au sol atmosphere forcee", "W/m2",
     .       iim,jjmp1,nhori, 1,1,1, -99, 32,
     .       "ave(X)", zstophy,zout)
c
       ELSE IF (OCEAN.EQ.'slab  ') THEN
c
        CALL histdef(nid_mth, "slab_bils",
     .              "Bilan au sol Slab", "W/m2",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
        CALL histdef(nid_mth, "tslab", "Slab SST ", "K",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
        CALL histdef(nid_mth, "seaice", "Slab seaice", "kg/m2",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
        CALL histdef(nid_mth, "siceh", "Slab seaice height", "m",
     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
     .              "ave(X)", zstophy,zout)
c
       ENDIF !OCEAN.EQ.slab/force
c
      ENDIF !lev_histmth.GE.1
c
      IF(lev_histmth.GE.2) THEN
c
c Champs 3D:
c
c
         CALL histdef(nid_mth,"lwcon","Cloud liquid water content",
     .                "kg/kg",
     .                iim,jjmp1,nhori, klev,1,klev, nvert, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"iwcon","Cloud ice water content","kg/kg",
     .                iim,jjmp1,nhori, klev,1,klev, nvert, 32, 
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "temp", "Air temperature", "K",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ovap", "Specific humidity", "kg/kg",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
c        CALL histdef(nid_mth,"wvap","Water vapor mixing ratio","kg/kg",
c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
c    .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "geop", "Geopotential height", "m2/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "vitu", "Zonal wind", "m/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "vitv", "Meridional wind", "m/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "vitw", "Vertical wind", "m/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "pres", "Air pressure", "Pa",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
        CALL histdef(nid_mth, "rneb", "Cloud fraction", "%",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "rnebcon", "Convective Cloud Fraction"
     .                , "-",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "rhum", "Relative humidity", "-",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ozone", "Ozone concentration", "ppmv",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtphy", "Physics dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqphy","Physics dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
      ENDIF !lev_histmth.GE.2
c
      IF(lev_histmth.GE.3) THEN
c
        DO nsrf=1, nbsrf
c
           call histdef(nid_mth, "albe_"//clnsurf(nsrf), 
     $         "Albedo surf. "//clnsurf(nsrf), "-",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
c
           call histdef(nid_mth, "rugs_"//clnsurf(nsrf), 
     $         "Rugosite "//clnsurf(nsrf), "m",  
     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
     $         "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "ages_"//clnsurf(nsrf), "Snow age","day",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
	 ENDDO !nsrf=1, nbsrf
c
         CALL histdef(nid_mth, "albs", "Surface albedo", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
         CALL histdef(nid_mth, "albslw", "Surface albedo LW", "-",
     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
     .                "ave(X)", zstophy,zout)
c
      ENDIF !lev_histmth.GE.3
c
      IF(lev_histmth.GE.4) THEN
c
         CALL histdef(nid_mth, "clwcon", 
     .                "Convective Cloud Liquid water content"
     .                , "kg/kg",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"Ma","undilute adiab updraft","kg/m2/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dnwd", "saturated downdraft","kg/m2/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dnwd0", "unsat. downdraft", "kg/m2/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtdyn", "Dynamics dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqdyn","Dynamics dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqcon","Convection dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtlschr",
     $       "Large-scale condensational heating rate", "K/s",iim,jjmp1
     $       ,nhori, klev,1,klev,nvert, 32,"ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqlsc","Condensation dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtvdf", "Boundary-layer dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dqvdf","Boundary-layer dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dteva", "Reevaporation dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"dqeva","Reevaporation dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)

         CALL histdef(nid_mth, "ptconv", "POINTS CONVECTIFS"," ",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)

         CALL histdef(nid_mth, "ratqs", "RATQS"," ",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)

c
         CALL histdef(nid_mth, "dqajs","Dry adjust. dQ","(kg/kg)/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtswr", "SW radiation dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtsw0", "CS SW radiation dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtlwr", "LW radiation dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth,"dtlw0","CS LW radiation dT","K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dtec", "Cinetic dissip dT", "K/s",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "duvdf", "Boundary-layer dU", "m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
c
         CALL histdef(nid_mth, "dvvdf", "Boundary-layer dV", "m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,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)", zstophy,zout)
c
         CALL histdef(nid_mth, "dvoro", "Orography dV", "m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,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)", zstophy,zout)
c
         CALL histdef(nid_mth, "dvlif", "Orography dV", "m/s2",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
         ENDIF
C
         if (nqmax.GE.3) THEN
         DO iq=3,nqmax
         iiq=niadv(iq)
         CALL histdef(nid_mth, tnom(iq), ttext(iiq), "-",
     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
     .                "ave(X)", zstophy,zout)
         ENDDO
         ENDIF

      ENDIF !lev_histmth.GE.4
c
      ENDIF !type_run.EQ."CLIM".OR.type_run.EQ."ENSP")
c
         CALL histend(nid_mth)
c
         ndex2d = 0
         ndex3d = 0
c
      ENDIF ! fin de test sur ok_mensuel
