!
! $Id: ini_histmthNMC.h 1299 2010-01-20 14:27:21Z fairhead $
!
      IF (ok_mensuel) THEN
c
c$OMP MASTER

       zstophy = dtime
       zstohf = ecrit_hf
       zstomth = ecrit_mth
       zout = ecrit_mth
c
         idayref = day_ref
         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
c
cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
cym         DO i = 1, iim
cym            zx_lon(i,1) = rlon(i+1)
cym            zx_lon(i,jjmp1) = rlon(i+1)
cym         ENDDO
         DO ll=1,klev
            znivsig(ll)=REAL(ll)
         ENDDO
cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
cym         CALL histbeg("histNMC.nc", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
cym     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
cym     .                 nhori, nid_nmc)

         CALL histbeg_phy("histNMC",itau_phy, zjulian, dtime, 
     .                 nhori, nid_nmc)
c
         CALL histvert(nid_nmc, "presnivs", "Vertical levels", "mb",
     .                 nlevSTD, rlevSTD/100., nvert)
ccc
ccc Champs 3D interpolles sur des niveaux de pression du NMC
ccc
      IF(type_run.EQ."ENSP".OR.type_run.EQ."CLIM") THEN
c
          CALL histdef(nid_nmc, "temp",
     .                 "Temperature","K",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
         CALL histdef(nid_nmc, "phi",
     .                "Geopotential", "m",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "q",
     .                 "Specific humidity","kg/kg",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
         CALL histdef(nid_nmc, "rh",
     .                 "Relative humidity", "%",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "u",
     .                 "Zonal wind","m/s",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "v",
     .                 "Meridional wind","m/s",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
      ELSE IF(type_run.EQ."AMIP".OR.type_run.EQ."CFMI") THEN
c
c ATTENTION : pour AMIP2 on interpole t,u,v,wphi,q,rh
c             sur les niveaux du NMC et on somme & moyenne
c             toutes les 6 heures par des routines undefSTD et
c             moy_undefSTD pour eliminer les valeurs "undef"
c             de la moyenne mensuelle
c ======> le "inst(X)" ci-dessous est par consequence factice !
c
          CALL histdef(nid_nmc, "temp",
     .                 "Temperature","K",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
         CALL histdef(nid_nmc, "phi",
     .                "Geopotential ", "m",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "q",
     .                 "Specific humidity","kg/kg",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
         CALL histdef(nid_nmc, "rh",
     .                 "Relative humidity", "%",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "u",
     .                 "Zonal wind","m/s",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "v",
     .                 "Meridional wind","m/s",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "w",
     .                 "Vertical motion","Pa/s",
     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .                "inst(X)", zout,zout)
c
c ATTENTION : pour AMIP2 on interpole t,u,v,wphi,q,rh
c             sur les niveaux du NMC et on somme & moyenne
c             toutes les 6 heures par des routines undefSTD et
c             moy_undefSTD pour eliminer les valeurs "undef"
c             de la moyenne mensuelle
c ======> le "inst(X)" ci-dessus est par consequence factice !
c
c
          CALL histdef(nid_nmc, "psbg",
     .         "Pressure sfce below ground","%",
     .         iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "uv",
     .         "uv ",
     .         "m2/s2",iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "vq",
     .         "vq ",
     .         "m/s * (kg/kg)",iim,jj_nb,nhori, 
     .          nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "vT",
     .         "vT ", 
     .         "mK/s",iim,jj_nb,nhori, 
     .          nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "wq",
     .         "wq ", 
     .         "(Pa/s)*(kg/kg)",iim,jj_nb,nhori,
     .          nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "vphi",
     .         "vphi ", 
     .         "m2/s",iim,jj_nb,nhori, 
     .          nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "wT",
     .         "wT ", 
     .         "K*Pa/s",iim,jj_nb,nhori,
     .          nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "uxu",
     .         "u2 ", 
     .         "m2/s2",iim,jj_nb,nhori,
     .          nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "vxv",
     .         "v2 ", 
     .         "m2/s2",iim,jj_nb,nhori,
     .          nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
          CALL histdef(nid_nmc, "TxT",
     .         "T2 ", 
     .         "K2",iim,jj_nb,nhori,
     .          nlevSTD,1,nlevSTD, nvert, 32,
     .         "inst(X)", zout,zout)
c
      ENDIF !(type_run.EQ."AMIP")

         CALL histend(nid_nmc)
c
c$OMP END MASTER

      ENDIF ! fin de test sur ok_mensuel
