Index: LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/ini_histdayNMC.h
===================================================================
--- LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/ini_histdayNMC.h	(revision 1349)
+++ LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/ini_histdayNMC.h	(revision 1349)
@@ -0,0 +1,135 @@
+!
+! $Header$
+!
+c$OMP MASTER
+
+       zstophy = dtime
+       zstohf = ecrit_hf
+       zstomth = ecrit_mth
+       zout = freq_outNMC(2)
+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)=float(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_daynmc)
+
+         CALL histbeg_phy("histdayNMC",itau_phy, zjulian, dtime, 
+     .                 nhori, nid_daynmc)
+c
+        IF(lev_histdayNMC.EQ.nlevSTD) THEN 
+         CALL histvert(nid_daynmc, "plev", "pressure", "Pa",
+     .                 nlevSTD, rlevSTD, nvert)
+        ELSE IF(lev_histdayNMC.EQ.nlevSTD8) THEN 
+         CALL histvert(nid_daynmc, "plev", "pressure", "Pa",
+     .                 nlevSTD8, rlevSTD8, nvert)
+        ENDIF
+ccc
+ccc Champs 3D interpolles sur des niveaux de pression du NMC
+ccc
+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 freq_moyNMC secondes 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
+        IF(lev_histdayNMC.EQ.nlevSTD) THEN 
+          CALL histdef(nid_daynmc, "tnondef",
+     .                 "Valeurs non-definies","-",
+     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "ta",
+     .                 "Air temperature","K",
+     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+         CALL histdef(nid_daynmc, "zg",
+     .                "Geopotential height", "m",
+     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "hus",
+     .                 "Specific humidity","1",
+     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+         CALL histdef(nid_daynmc, "hur",
+     .                 "Relative humidity", "%",
+     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "ua",
+     .                 "Eastward wind","m s-1",
+     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "va",
+     .                 "Northward wind","m s-1",
+     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "wap",
+     .                 "Lagrangian tendency of air pressure","Pa s-1",
+     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+        ELSE IF(lev_histdayNMC.EQ.nlevSTD8) THEN 
+c
+          CALL histdef(nid_daynmc, "tnondef",
+     .                 "Valeurs non-definies","-",
+     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "ta",
+     .                 "Air temperature","K",
+     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+         CALL histdef(nid_daynmc, "zg",
+     .                "Geopotential height", "m",
+     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "hus",
+     .                 "Specific humidity","1",
+     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+         CALL histdef(nid_daynmc, "hur",
+     .                 "Relative humidity", "%",
+     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "ua",
+     .                 "Eastward wind","m s-1",
+     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "va",
+     .                 "Northward wind","m s-1",
+     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_daynmc, "wap",
+     .                 "Lagrangian tendency of air pressure","Pa s-1",
+     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+        ENDIF
+c
+         CALL histend(nid_daynmc)
+c
+c$OMP END MASTER
Index: LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/ini_histhfNMC.h
===================================================================
--- LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/ini_histhfNMC.h	(revision 1349)
+++ LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/ini_histhfNMC.h	(revision 1349)
@@ -0,0 +1,145 @@
+!
+! $Header$
+!
+c$OMP MASTER
+
+       zstophy = dtime
+       zstohf = ecrit_hf
+       zstomth = ecrit_mth
+c      zout = 6 * 3600.
+       zout = freq_outNMC(3)
+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)=float(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_hfnmc)
+
+         CALL histbeg_phy("histhfNMC",itau_phy, zjulian, dtime, 
+     .                 nhori, nid_hfnmc)
+c
+         CALL histvert(nid_hfnmc, "plev", "pressure", "Pa",
+     .                 nlevSTD3, rlevSTD3, nvert)
+ccc
+ccc Champs 3D interpolles sur des niveaux de pression du NMC
+ccc
+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 freq_moyNMC secondes 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_hfnmc, "tnondef",
+     .                 "Valeurs non-definies","-",
+     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "ta",
+     .                 "Air temperature","K",
+     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+         CALL histdef(nid_hfnmc, "zg",
+     .                "Geopotential height", "m",
+     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "hus",
+     .                 "Specific humidity","1",
+     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+         CALL histdef(nid_hfnmc, "hur",
+     .                 "Relative humidity", "%",
+     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "ua",
+     .                 "Eastward wind","m s-1",
+     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "va",
+     .                 "Northward wind","m s-1",
+     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "wap",
+     .                 "Lagrangian tendency of air pressure","Pa s-1",
+     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "psbg",
+     .         "Pressure sfce below ground","%",
+     .         iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "uv",
+     .         "uv ",
+     .         "m2/s2",iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "vq",
+     .         "vq ",
+     .         "m/s * (kg/kg)",iim,jj_nb,nhori, 
+     .          nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "vT",
+     .         "vT ", 
+     .         "mK/s",iim,jj_nb,nhori, 
+     .          nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "wq",
+     .         "wq ", 
+     .         "(Pa/s)*(kg/kg)",iim,jj_nb,nhori,
+     .          nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "vphi",
+     .         "vphi ", 
+     .         "m2/s",iim,jj_nb,nhori, 
+     .          nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "wT",
+     .         "wT ", 
+     .         "K*Pa/s",iim,jj_nb,nhori,
+     .          nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "uxu",
+     .         "u2 ", 
+     .         "m2/s2",iim,jj_nb,nhori,
+     .          nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "vxv",
+     .         "v2 ", 
+     .         "m2/s2",iim,jj_nb,nhori,
+     .          nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+          CALL histdef(nid_hfnmc, "TxT",
+     .         "T2 ", 
+     .         "K2",iim,jj_nb,nhori,
+     .          nlevSTD3,1,nlevSTD3, nvert, 32,
+     .         "inst(X)", zout,zout)
+c
+         CALL histend(nid_hfnmc)
+c
+c$OMP END MASTER
+
Index: LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/write_histdayNMC.h
===================================================================
--- LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/write_histdayNMC.h	(revision 1349)
+++ LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/write_histdayNMC.h	(revision 1349)
@@ -0,0 +1,42 @@
+!
+! $Header$
+!
+c     IF (ok_mensuel) THEN
+c
+       ndex3d = 0
+       itau_w = itau_phy + itap
+ccc
+c  Champs interpolles sur des niveaux de pression du NMC
+c
+c     PARAMETER(nout=3) 
+c nout=1 : in=pdtphys,    out=mth
+c nout=2 : in=pdtphys,    out=day
+c nout=3 : in=pdtphys,    out=hf
+ccc
+      IF(lev_histdayNMC.EQ.nlevSTD) THEN
+       CALL histwrite_phy(nid_daynmc,"tnondef",itau_w,tnondef(:,:,2))
+       CALL histwrite_phy(nid_daynmc,"ta",itau_w,twriteSTD(:,:,2))
+       CALL histwrite_phy(nid_daynmc,"zg",itau_w,phiwriteSTD(:,:,2))
+       CALL histwrite_phy(nid_daynmc,"hus",itau_w,qwriteSTD(:,:,2))
+       CALL histwrite_phy(nid_daynmc,"hur",itau_w,rhwriteSTD(:,:,2))
+       CALL histwrite_phy(nid_daynmc,"ua",itau_w,uwriteSTD(:,:,2))
+       CALL histwrite_phy(nid_daynmc,"va",itau_w,vwriteSTD(:,:,2))
+       CALL histwrite_phy(nid_daynmc,"wap",itau_w,wwriteSTD(:,:,2))
+      ELSE IF(lev_histdayNMC.EQ.nlevSTD8) THEN
+       CALL histwrite_phy(nid_daynmc,"tnondef",itau_w,tnondefSTD8)
+       CALL histwrite_phy(nid_daynmc,"ta",itau_w,twriteSTD8)
+       CALL histwrite_phy(nid_daynmc,"zg",itau_w,phiwriteSTD8)
+       CALL histwrite_phy(nid_daynmc,"hus",itau_w,qwriteSTD8)
+       CALL histwrite_phy(nid_daynmc,"hur",itau_w,rhwriteSTD8)
+       CALL histwrite_phy(nid_daynmc,"ua",itau_w,uwriteSTD8)
+       CALL histwrite_phy(nid_daynmc,"va",itau_w,vwriteSTD8)
+       CALL histwrite_phy(nid_daynmc,"wap",itau_w,wwriteSTD8)
+      ENDIF
+c
+      if (ok_sync) then
+c$OMP MASTER
+        call histsync(nid_daynmc)
+c$OMP END MASTER
+      endif
+
+c     ENDIF
Index: LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/write_histhfNMC.h
===================================================================
--- LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/write_histhfNMC.h	(revision 1349)
+++ LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/write_histhfNMC.h	(revision 1349)
@@ -0,0 +1,68 @@
+!
+! $Header$
+!
+       ndex3d = 0
+       itau_w = itau_phy + itap
+ccc
+c  Champs interpolles sur des niveaux de pression du NMC
+c
+c     PARAMETER(nout=3) 
+c nout=1 : in=pdtphys,    out=mth
+c nout=2 : in=pdtphys,    out=day
+c nout=3 : in=pdtphys,    out=hf
+ccc
+       CALL histwrite_phy(nid_hfnmc,"tnondef",itau_w,tnondef(:,:,3))
+c
+       CALL histwrite_phy(nid_hfnmc,"ta",itau_w,twriteSTD3)
+c
+       CALL histwrite_phy(nid_hfnmc,"zg",itau_w,phiwriteSTD3)
+c
+       CALL histwrite_phy(nid_hfnmc,"hus",itau_w,qwriteSTD3)
+c
+       CALL histwrite_phy(nid_hfnmc,"hur",itau_w,rhwriteSTD3)
+c
+       CALL histwrite_phy(nid_hfnmc,"ua",itau_w,uwriteSTD3)
+c
+       CALL histwrite_phy(nid_hfnmc,"va",itau_w,vwriteSTD3)
+c
+       CALL histwrite_phy(nid_hfnmc,"wap",itau_w,wwriteSTD3)
+c
+       DO k=1, nlevSTD
+        DO i=1, klon
+         IF(tnondef(i,k,3).NE.missing_val) THEN
+          zx_tmp_fiNC(i,k) = (100.*tnondef(i,k,3))/ecrit_hf2mth
+         ELSE
+          zx_tmp_fiNC(i,k) = missing_val
+         ENDIF
+        ENDDO
+       ENDDO !k=1, nlevSTD
+c
+       CALL histwrite_phy(nid_hfnmc,"psbg",itau_w,zx_tmp_fiNC)
+c
+       CALL histwrite_phy(nid_hfnmc,"uv",itau_w,uvsumSTD(:,:,3))
+c
+       CALL histwrite_phy(nid_hfnmc,"vq",itau_w,vqsumSTD(:,:,3))
+c
+       CALL histwrite_phy(nid_hfnmc,"vT",itau_w,vTsumSTD(:,:,3))
+c
+       CALL histwrite_phy(nid_hfnmc,"wq",itau_w,wqsumSTD(:,:,3))
+c
+       CALL histwrite_phy(nid_hfnmc,"vphi",itau_w,vphisumSTD(:,:,3))
+c
+       CALL histwrite_phy(nid_hfnmc,"wT",itau_w,wTsumSTD(:,:,3))
+c
+       CALL histwrite_phy(nid_hfnmc,"uxu",itau_w,u2sumSTD(:,:,3))
+c
+       CALL histwrite_phy(nid_hfnmc,"vxv",itau_w,v2sumSTD(:,:,3))
+c
+       CALL histwrite_phy(nid_hfnmc,"TxT",itau_w,T2sumSTD(:,:,3))
+c
+c     ENDIF !type_run
+c
+      if (ok_sync) then
+c$OMP MASTER
+        call histsync(nid_hfnmc)
+c$OMP END MASTER
+      endif
+
+c     ENDIF
