Index: /LMDZ4/trunk/libf/phylmd/calcul_STDlev.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/calcul_STDlev.h	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/calcul_STDlev.h	(revision 1352)
@@ -3,56 +3,10 @@
 c
 c
-cIM on initialise les champs en debut du jour ou du mois 
+cIM on initialise les variables 
 c
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,tsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,usumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,vsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,wsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,phisumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,qsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,rhsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,uvsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,vqsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,vTsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,wqsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,vphisumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,wTsumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,u2sumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,v2sumSTD)
-        CALL ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $                    tnondef,T2sumSTD)
+        CALL ini_undefSTD(itap,freq_outNMC)
 c
-cIM on interpole sur les niveaux STD de pression a chaque pas de temps de la physique
+cIM on interpole les champs sur les niveaux STD de pression 
+cIM a chaque pas de temps de la physique
 c
 c-------------------------------------------------------c
@@ -163,154 +117,16 @@
 
 c
-cIM on somme les valeurs definies a chaque pas de temps de la physique ou 
-cIM toutes les 6 heures
+cIM on somme les valeurs toutes les freq_calNMC secondes
 c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.TRUE.
-       CALL undefSTD(nlevSTD,itap,tlevSTD,
-     $               dtime,ecrit_hf,
-     $               oknondef,tnondef,tsumSTD)
+       CALL undefSTD(itap,freq_calNMC)
 c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,ulevSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,usumSTD)
+cIM on moyenne a la fin du mois ou du jour (toutes les freq_outNMC secondes)
 c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,vlevSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,vsumSTD)
+       CALL moy_undefSTD(itap,freq_outNMC,freq_moyNMC)
 c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,wlevSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,wsumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,philevSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,phisumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,qlevSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,qsumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,rhlevSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,rhsumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,uvSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,uvsumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,vqSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,vqsumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,vTSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,vTsumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,wqSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,wqsumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,vphiSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,vphisumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,wTSTD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,wTsumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,u2STD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,u2sumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,v2STD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,v2sumSTD)
-c
-       oknondef(1:klon,1:nlevSTD,1:nout)=.FALSE.
-       CALL undefSTD(nlevSTD,itap,T2STD,
-     $           dtime,ecrit_hf,
-     $               oknondef,tnondef,T2sumSTD)
-c
-cIM on moyenne a la fin du jour ou du mois 
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,tsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,usumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,vsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,wsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,phisumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,qsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,rhsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,uvsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,vqsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,vTsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,wqsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,vphisumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,wTsumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,u2sumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,v2sumSTD)
-c
-       CALL moy_undefSTD(nlevSTD,itap,
-     $      dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $                   tnondef,T2sumSTD)
-c
-cIM interpolation a chaque pas de temps du SWup(clr) et SWdn(clr) a 200 hPa
+       CALL plevel(klon,klev,.true.,pplay,50000.,
+     &              zphi/RG,geo500)
+
+cIM on interpole a chaque pas de temps le SWup(clr) et SWdn(clr) a 200 hPa
 c
       CALL plevel(klon,klevp1,.true.,paprs,20000.,
Index: /LMDZ4/trunk/libf/phylmd/clesphys.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/clesphys.h	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/clesphys.h	(revision 1352)
@@ -43,6 +43,14 @@
 !IM lev_histday : niveau sorties journalieres
 !IM lev_histmth : niveau sorties mensuelles
+!IM lev_histdayNMC : on peut sortir soit sur 8 (comme AR5) ou bien 
+!                    sur 17 niveaux de pression
        INTEGER lev_histhf, lev_histday, lev_histmth
+       INTEGER lev_histdayNMC
        Integer lev_histins, lev_histLES  
+!IM freq_outNMC : frequences de sortie fichiers niveaux de pression (histmthNMC, histdayNMC, histhfNMC)
+!IM freq_calNMC : frequences de calcul fis. hist*NMC.nc
+!IM pasphys : pas de temps de physique (secondes)
+       REAL pasphys
+       REAL freq_outNMC(3) , freq_calNMC(3)
        CHARACTER(len=4) type_run
 ! aer_type: pour utiliser un fichier constant dans readaerosol 
@@ -68,5 +76,6 @@
      &     , f_cdrag_ter,f_cdrag_oce,f_rugoro                           &
      &     , lev_histhf, lev_histday, lev_histmth                       &
-     &     , lev_histins, lev_histLES                                   &
+     &     , lev_histins, lev_histLES, lev_histdayNMC                   &
+     &     , pasphys, freq_outNMC, freq_calNMC                          &
      &     , type_run, ok_isccp, ok_regdyn, ok_cosp                     &
      &     , lonmin_ins, lonmax_ins, latmin_ins, latmax_ins             &
Index: /LMDZ4/trunk/libf/phylmd/conf_phys.F90
===================================================================
--- /LMDZ4/trunk/libf/phylmd/conf_phys.F90	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/conf_phys.F90	(revision 1352)
@@ -136,5 +136,7 @@
   REAL, SAVE ::  fmagic_omp, pmagic_omp
   INTEGER,SAVE :: iflag_pbl_omp,lev_histhf_omp,lev_histday_omp,lev_histmth_omp
-  Integer,save :: lev_histins_omp, lev_histLES_omp 
+  Integer, save :: lev_histins_omp, lev_histLES_omp 
+  INTEGER, SAVE :: lev_histdayNMC_omp
+  REAL, SAVE :: freq_outNMC_omp(3), freq_calNMC_omp(3)
   CHARACTER*4, SAVE :: type_run_omp
   LOGICAL,SAVE :: ok_isccp_omp
@@ -1075,5 +1077,38 @@
   lev_histLES_omp = 1
   call getin('lev_histLES',lev_histLES_omp)
-  !
+!
+!Config Key  = lev_histdayNMC
+!Config Desc =
+!Config Def  = 8
+!Config Help =
+!
+  lev_histdayNMC_omp = 8
+  call getin('lev_histdayNMC',lev_histdayNMC_omp)
+!
+!histNMC BEG
+!Config Key  = freq_outNMC
+!Config Desc = freq_outNMC(1) = frequence de sortie fichiers histmthNMC
+!Config Desc = freq_outNMC(2) = frequence de sortie fichiers histdayNMC
+!Config Desc = freq_outNMC(3) = frequence de sortie fichiers histhfNMC
+!Config Def  = 2592000., 86400., 21600.
+!Config Help =
+!
+  freq_outNMC_omp(1) = 2592000.
+  freq_outNMC_omp(2) = 86400.
+  freq_outNMC_omp(3) = 21600.
+  call getin('freq_outNMC',freq_outNMC_omp)
+!
+!Config Key  = freq_calNMC
+!Config Desc = freq_calNMC(1) = frequence de calcul fichiers histmthNMC
+!Config Desc = freq_calNMC(2) = frequence de calcul fichiers histdayNMC
+!Config Desc = freq_calNMC(3) = frequence de calcul fichiers histhfNMC
+!Config Def  = pasphys
+!Config Help =
+!
+  freq_calNMC_omp(1) = pasphys
+  freq_calNMC_omp(2) = pasphys
+  freq_calNMC_omp(3) = pasphys
+  call getin('freq_calNMC',freq_calNMC_omp)
+!
 !Config Key  = type_run
 !Config Desc =
@@ -1410,4 +1445,7 @@
     lev_histins = lev_histins_omp
     lev_histLES = lev_histLES_omp
+    lev_histdayNMC = lev_histdayNMC_omp
+    freq_outNMC(:) = freq_outNMC_omp(:)
+    freq_calNMC(:) = freq_calNMC_omp(:)
 
     type_ocean = type_ocean_omp
@@ -1591,4 +1629,7 @@
   write(numout,*)' lev_histins = ',lev_histins
   write(numout,*)' lev_histLES = ',lev_histLES
+  write(numout,*)' lev_histdayNMC = ',lev_histdayNMC
+  write(numout,*)' freq_outNMC = ',freq_outNMC
+  write(numout,*)' freq_calNMC = ',freq_calNMC
   write(numout,*)' iflag_pbl = ', iflag_pbl
   write(numout,*)' iflag_thermals = ', iflag_thermals
Index: /LMDZ4/trunk/libf/phylmd/ini_histmthNMC.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histmthNMC.h	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/ini_histmthNMC.h	(revision 1352)
@@ -2,15 +2,9 @@
 ! $Header$
 !
-      IF (ok_mensuel) THEN
+c$OMP MASTER
+       zout = freq_outNMC(1)
 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)
+       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)
@@ -25,109 +19,74 @@
 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)
+cym     .                 nhori, nid_mthnmc)
 
-         CALL histbeg_phy("histNMC",itau_phy, zjulian, dtime, 
-     .                 nhori, nid_nmc)
+         CALL histbeg_phy("histmthNMC",itau_phy, zjulian, dtime, 
+     .                 nhori, nid_mthnmc)
 c
-         CALL histvert(nid_nmc, "presnivs", "Vertical levels", "mb",
-     .                 nlevSTD, rlevSTD/100., nvert)
+         CALL histvert(nid_mthnmc, "plev", "pressure", "Pa",
+     .                 nlevSTD, rlevSTD, 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",
+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
+c
+          CALL histdef(nid_mthnmc, "tnondef",
+     .                 "Valeurs non-definies","-",
      .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
-         CALL histdef(nid_nmc, "phi",
-     .                "Geopotential", "m",
+          CALL histdef(nid_mthnmc, "ta",
+     .                 "Air temperature","K",
      .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "q",
-     .                 "Specific humidity","kg/kg",
+         CALL histdef(nid_mthnmc, "zg",
+     .                "Geopotential height", "m",
      .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
-         CALL histdef(nid_nmc, "rh",
+          CALL histdef(nid_mthnmc, "hus",
+     .                 "Specific humidity","1",
+     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                "inst(X)", zout,zout)
+c
+         CALL histdef(nid_mthnmc, "hur",
      .                 "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",
+          CALL histdef(nid_mthnmc, "ua",
+     .                 "Eastward wind","m s-1",
      .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "v",
-     .                 "Meridional wind","m/s",
+          CALL histdef(nid_mthnmc, "va",
+     .                 "Northward wind","m s-1",
      .                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",
+          CALL histdef(nid_mthnmc, "wap",
+     .                 "Lagrangian tendency of air pressure","Pa s-1",
      .                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",
+          CALL histdef(nid_mthnmc, "psbg",
      .         "Pressure sfce below ground","%",
      .         iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "uv",
+          CALL histdef(nid_mthnmc, "uv",
      .         "uv ",
      .         "m2/s2",iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "vq",
+          CALL histdef(nid_mthnmc, "vq",
      .         "vq ",
      .         "m/s * (kg/kg)",iim,jj_nb,nhori, 
@@ -135,5 +94,5 @@
      .         "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "vT",
+          CALL histdef(nid_mthnmc, "vT",
      .         "vT ", 
      .         "mK/s",iim,jj_nb,nhori, 
@@ -141,5 +100,5 @@
      .         "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "wq",
+          CALL histdef(nid_mthnmc, "wq",
      .         "wq ", 
      .         "(Pa/s)*(kg/kg)",iim,jj_nb,nhori,
@@ -147,5 +106,5 @@
      .         "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "vphi",
+          CALL histdef(nid_mthnmc, "vphi",
      .         "vphi ", 
      .         "m2/s",iim,jj_nb,nhori, 
@@ -153,5 +112,5 @@
      .         "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "wT",
+          CALL histdef(nid_mthnmc, "wT",
      .         "wT ", 
      .         "K*Pa/s",iim,jj_nb,nhori,
@@ -159,5 +118,5 @@
      .         "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "uxu",
+          CALL histdef(nid_mthnmc, "uxu",
      .         "u2 ", 
      .         "m2/s2",iim,jj_nb,nhori,
@@ -165,5 +124,5 @@
      .         "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "vxv",
+          CALL histdef(nid_mthnmc, "vxv",
      .         "v2 ", 
      .         "m2/s2",iim,jj_nb,nhori,
@@ -171,5 +130,5 @@
      .         "inst(X)", zout,zout)
 c
-          CALL histdef(nid_nmc, "TxT",
+          CALL histdef(nid_mthnmc, "TxT",
      .         "T2 ", 
      .         "K2",iim,jj_nb,nhori,
@@ -177,9 +136,6 @@
      .         "inst(X)", zout,zout)
 c
-      ENDIF !(type_run.EQ."AMIP")
 
-         CALL histend(nid_nmc)
+         CALL histend(nid_mthnmc)
 c
 c$OMP END MASTER
-
-      ENDIF ! fin de test sur ok_mensuel
Index: /LMDZ4/trunk/libf/phylmd/ini_undefSTD.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_undefSTD.F	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/ini_undefSTD.F	(revision 1352)
@@ -3,8 +3,8 @@
 !
 
-      SUBROUTINE ini_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,
-     $           tnondef,tsumSTD)
+      SUBROUTINE ini_undefSTD(itap,
+     $           freq_outNMC)
       USE dimphy
+      USE phys_state_var_mod ! Variables sauvegardees de la physique
       IMPLICIT none
 c
@@ -27,6 +27,5 @@
 c nout=3 !var. mensuelle "NMC" moyennee toutes les 6heures
 c
-c
-c NB: mettre "inst(X)" dans le write_histXXX.h !
+c NB: mettre "inst(X)" dans le write_hist*NMC.h !
 c====================================================================
 c
@@ -36,51 +35,58 @@
 cym #include "dimphy.h"
 c variables Input/Output
-      INTEGER nlevSTD, klevSTD, itap
-      PARAMETER(klevSTD=17)
-      REAL dtime
-      REAL ecrit_day,ecrit_mth
+c     INTEGER nlevSTD, klevSTD, itap
+      INTEGER itap
+c     PARAMETER(klevSTD=17)
+c     REAL dtime
 c
 c variables locales
-      INTEGER i, k, nout
-      PARAMETER(nout=3) !nout=1 day/nout=2 mth/nout=3 NMC
+c     INTEGER i, k, nout, n
+      INTEGER i, k, n
+c     PARAMETER(nout=3) !nout=1 day/nout=2 mth/nout=3 NMC
+      REAL freq_outNMC(nout)
 c
 c variables Output
-      REAL tnondef(klon,klevSTD,nout)
-      REAL tsumSTD(klon,klevSTD,nout)
+c     REAL tnondef(klon,klevSTD,nout)
+c     REAL tsumSTD(klon,klevSTD,nout)
 c
-c initialisation variables journalieres en debut de journee
+      DO n=1, nout
 c
-      IF(MOD(itap,NINT(ecrit_day/dtime)).EQ.1.) THEN
-       DO k=1, nlevSTD
-        DO i=1, klon
-         tnondef(i,k,1)=0.
-         tsumSTD(i,k,1)=0.
-        ENDDO !i
-       ENDDO !k
-      ENDIF
+c initialisation variables en debut de la journee ou du mois
 c
-c initialisation variables mensuelles (calculees a chaque pas de temps) 
-c en debut de mois : nout=2
+       IF(MOD(itap,NINT(freq_outNMC(n)/dtime)).EQ.1.) THEN
 c
-      IF(MOD(itap,NINT(ecrit_mth/dtime)).EQ.1.) THEN
+c       print*,'n freq_ini=',n,itap,freq_outNMC(n)/dtime
 c
-       DO k=1, nlevSTD
-        DO i=1, klon
-         tnondef(i,k,2)=0.
-         tsumSTD(i,k,2)=0.
-        ENDDO !i
-       ENDDO !k
+        DO k=1, nlevSTD
+         DO i=1, klon
+          tnondef(i,k,n)=0.
+          tsumSTD(i,k,n)=0.
+          usumSTD(i,k,n)=0.
+          vsumSTD(i,k,n)=0.
+          wsumSTD(i,k,n)=0.
+          phisumSTD(i,k,n)=0.
+          qsumSTD(i,k,n)=0.
+          rhsumSTD(i,k,n)=0.
+          uvsumSTD(i,k,n)=0.
+          vqsumSTD(i,k,n)=0.
+          vTsumSTD(i,k,n)=0.
+          wqsumSTD(i,k,n)=0.
+          vphisumSTD(i,k,n)=0.
+          wTsumSTD(i,k,n)=0.
+          u2sumSTD(i,k,n)=0.
+          v2sumSTD(i,k,n)=0.
+          T2sumSTD(i,k,n)=0.
+         ENDDO !i
+        ENDDO !k
 c
-c initialisation variables mensuelles - runs type Amip - (calculees toutes les 6h)
-c en debut de mois : nout = 3
+c          if(n.EQ.1.AND.i.EQ.4513.AND.k.EQ.17) THEN
+           if(n.EQ.1.AND.i.EQ.1128.AND.k.EQ.17) THEN
+            print*,'itap rlon rlat tlevSTD=',itap,rlon(i),rlat(i),
+     $tlevSTD(i,k)
+           endif
 c
-       DO k=1, nlevSTD
-        DO i=1, klon
-         tnondef(i,k,3)=0.
-         tsumSTD(i,k,3)=0.
-        ENDDO !i
-       ENDDO !k
+       ENDIF !MOD(itap,NINT(freq_outNMC(n)/dtime)).EQ.1.
 c
-      ENDIF
+      ENDDO !n
 c
       RETURN
Index: /LMDZ4/trunk/libf/phylmd/moy_undefSTD.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/moy_undefSTD.F	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/moy_undefSTD.F	(revision 1352)
@@ -2,9 +2,8 @@
 ! $Header$
 !
-      SUBROUTINE moy_undefSTD(nlevSTD,itap,
-     $           dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
-     $           tnondef,tsumSTD)
+      SUBROUTINE moy_undefSTD(itap,freq_outNMC,freq_moyNMC)
       USE netcdf
       USE dimphy
+      USE phys_state_var_mod ! Variables sauvegardees de la physique
       IMPLICIT none
 c
@@ -14,5 +13,5 @@
 c
 c Moyenne - a des frequences differentes - des valeurs bien definies
-c         (.NE.1.E+20) des variables interpolees a un niveau de
+c         (.NE.missing_val) des variables interpolees a un niveau de
 c         pression.
 c 1) les variables de type "day" (nout=1) ou "mth" (nout=2) sont sommees
@@ -23,5 +22,5 @@
 c
 c
-c NB: mettre "inst(X)" dans le write_histXXX.h !
+c NB: mettre "inst(X)" dans le write_hist*NMC.h !
 c====================================================================
 cym#include "dimensions.h"
@@ -32,15 +31,18 @@
 c
 c variables Input
-      INTEGER nlevSTD, klevSTD, itap
-      PARAMETER(klevSTD=17)
-      REAL dtime, ecrit_day, ecrit_mth, ecrit_hf2mth
+c     INTEGER nlevSTD, klevSTD, itap
+c     PARAMETER(klevSTD=17)
+      INTEGER itap
 c
 c variables locales
-      INTEGER i, k, nout
-      PARAMETER(nout=3) !nout=1 day/nout=2 mth/nout=3 NMC
+c     INTEGER i, k, nout, n
+c     PARAMETER(nout=3) !nout=1 day/nout=2 mth/nout=3 NMC
+      INTEGER i, k, n
+c     REAL dtime, freq_outNMC(nout), freq_moyNMC(nout)
+      REAL freq_outNMC(nout), freq_moyNMC(nout)
 c
 c variables Output
-      REAL tnondef(klon,klevSTD,nout)
-      REAL tsumSTD(klon,klevSTD,nout)
+c     REAL tnondef(klon,klevSTD,nout)
+c     REAL tsumSTD(klon,klevSTD,nout)
 c
       REAL missing_val
@@ -48,41 +50,79 @@
       missing_val=nf90_fill_real
 c
+      DO n=1, nout
+c 
 c calcul 1 fois par jour
 c
-      IF(MOD(itap,NINT(ecrit_day/dtime)).EQ.0) THEN
-       DO k=1, nlevSTD
-        DO i=1, klon
-         IF (NINT(tnondef(i,k,1)).NE.NINT(ecrit_day/dtime)) THEN
-          tsumSTD(i,k,1)=tsumSTD(i,k,1)/
-     $    (ecrit_day/dtime-tnondef(i,k,1))
-         ELSE
-          tsumSTD(i,k,1)=missing_val
-         ENDIF !tnondef
-        ENDDO !i
-       ENDDO !k
-      ENDIF !MOD(itap,ecrit_day).EQ.0
+       IF(MOD(itap,NINT(freq_outNMC(n)/dtime)).EQ.0) THEN
 c
-c calcul 1 fois par mois
+c      print*,'n freq_ini=',n,itap,freq_outNMC(n),missing_val
 c
-      IF(MOD(itap,NINT(ecrit_mth/dtime)).EQ.0) THEN
-       DO k=1, nlevSTD
-        DO i=1, klon
-         IF(tnondef(i,k,2).NE.ecrit_mth/dtime) THEN
-          tsumSTD(i,k,2)=tsumSTD(i,k,2)/
-     $    (ecrit_mth/dtime-tnondef(i,k,2))
-         ELSE
-          tsumSTD(i,k,2)=missing_val
-         ENDIF !tnondef
+        DO k=1, nlevSTD
+         DO i=1, klon
+          IF(tnondef(i,k,n).NE.(freq_moyNMC(n))) THEN
+           tsumSTD(i,k,n)=tsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+cIM BEG
+          usumSTD(i,k,n)=usumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          vsumSTD(i,k,n)=vsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          wsumSTD(i,k,n)=wsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          phisumSTD(i,k,n)=phisumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          qsumSTD(i,k,n)=qsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          rhsumSTD(i,k,n)=rhsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          uvsumSTD(i,k,n)=uvsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          vqsumSTD(i,k,n)=vqsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          vTsumSTD(i,k,n)=vTsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          wqsumSTD(i,k,n)=wqsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          vphisumSTD(i,k,n)=vphisumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          wTsumSTD(i,k,n)=wTsumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          u2sumSTD(i,k,n)=u2sumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          v2sumSTD(i,k,n)=v2sumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+          T2sumSTD(i,k,n)=T2sumSTD(i,k,n)/
+     $     (freq_moyNMC(n)-tnondef(i,k,n))
+cIM END
+          ELSE
+           tsumSTD(i,k,n)=missing_val
+           usumSTD(i,k,n)=missing_val
+           vsumSTD(i,k,n)=missing_val
+           wsumSTD(i,k,n)=missing_val
+           phisumSTD(i,k,n)=missing_val
+           qsumSTD(i,k,n)=missing_val
+           rhsumSTD(i,k,n)=missing_val
+           uvsumSTD(i,k,n)=missing_val
+           vqsumSTD(i,k,n)=missing_val
+           vTsumSTD(i,k,n)=missing_val
+           wqsumSTD(i,k,n)=missing_val
+           vphisumSTD(i,k,n)=missing_val
+           wTsumSTD(i,k,n)=missing_val
+           u2sumSTD(i,k,n)=missing_val
+           v2sumSTD(i,k,n)=missing_val
+           T2sumSTD(i,k,n)=missing_val
+          ENDIF !tnondef(i,k,n).NE.(freq_moyNMC(n))
 c
-         IF(tnondef(i,k,3).NE.NINT(ecrit_hf2mth)) THEN
-          tsumSTD(i,k,3)=tsumSTD(i,k,3)/
-     $    (ecrit_hf2mth-tnondef(i,k,3))
-         ELSE
-          tsumSTD(i,k,3)=missing_val
-         ENDIF !tnondef
+c          if(n.EQ.1.AND.i.EQ.4513.AND.k.EQ.17) THEN
+           if(n.EQ.1.AND.i.EQ.1128.AND.k.EQ.17) THEN
+            print*,'itap rlon rlat tlevSTD=',itap,rlon(i),rlat(i),
+     $tlevSTD(i,k)
+           endif
 c
-        ENDDO !i
-       ENDDO !k
-      ENDIF !MOD
+         ENDDO !i
+        ENDDO !k
+       ENDIF !MOD(itap,NINT(freq_outNMC(n)/dtime)).EQ.0
+c
+      ENDDO !n
 c
       RETURN
Index: /LMDZ4/trunk/libf/phylmd/phys_state_var_mod.F90
===================================================================
--- /LMDZ4/trunk/libf/phylmd/phys_state_var_mod.F90	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/phys_state_var_mod.F90	(revision 1352)
@@ -8,9 +8,11 @@
       USE dimphy
       INTEGER, PARAMETER :: nlevSTD=17
+      INTEGER, PARAMETER :: nlevSTD8=8
+      INTEGER, PARAMETER :: nlevSTD3=3
       INTEGER, PARAMETER :: nout=3
       INTEGER, PARAMETER :: napisccp=1
       INTEGER, SAVE :: radpas
+!$OMP THREADPRIVATE(radpas)
       REAL, SAVE :: dtime, solaire_etat0
-!$OMP THREADPRIVATE(radpas)
 !$OMP THREADPRIVATE(dtime, solaire_etat0)
 
@@ -115,4 +117,18 @@
       REAL,ALLOCATABLE,SAVE :: T2sumSTD(:,:,:)
 !$OMP THREADPRIVATE(T2sumSTD)
+!IM begin
+      REAL,ALLOCATABLE,SAVE :: wlevSTD(:,:), ulevSTD(:,:), vlevSTD(:,:)
+      REAL,ALLOCATABLE,SAVE :: tlevSTD(:,:), qlevSTD(:,:), rhlevSTD(:,:)
+      REAL,ALLOCATABLE,SAVE :: philevSTD(:,:)
+      REAL,ALLOCATABLE,SAVE :: uvSTD(:,:)
+      REAL,ALLOCATABLE,SAVE :: vqSTD(:,:)
+      REAL,ALLOCATABLE,SAVE :: vTSTD(:,:)
+      REAL,ALLOCATABLE,SAVE :: wqSTD(:,:)
+      REAL,ALLOCATABLE,SAVE :: vphiSTD(:,:)
+      REAL,ALLOCATABLE,SAVE :: wTSTD(:,:)
+      REAL,ALLOCATABLE,SAVE :: u2STD(:,:)
+      REAL,ALLOCATABLE,SAVE :: v2STD(:,:) 
+      REAL,ALLOCATABLE,SAVE :: T2STD(:,:)
+!IM end
       INTEGER,ALLOCATABLE,SAVE :: seed_old(:,:)
 !$OMP THREADPRIVATE(seed_old)
@@ -351,4 +367,14 @@
       ALLOCATE(v2sumSTD(klon,nlevSTD,nout))
       ALLOCATE(T2sumSTD(klon,nlevSTD,nout))
+!IM beg
+      ALLOCATE(wlevSTD(klon,nlevSTD), ulevSTD(klon,nlevSTD), vlevSTD(klon,nlevSTD))
+      ALLOCATE(tlevSTD(klon,nlevSTD), qlevSTD(klon,nlevSTD), rhlevSTD(klon,nlevSTD))
+      ALLOCATE(philevSTD(klon,nlevSTD))
+      ALLOCATE(uvSTD(klon,nlevSTD),vqSTD(klon,nlevSTD))
+      ALLOCATE(vTSTD(klon,nlevSTD),wqSTD(klon,nlevSTD))
+      ALLOCATE(vphiSTD(klon,nlevSTD),wTSTD(klon,nlevSTD))
+      ALLOCATE(u2STD(klon,nlevSTD),v2STD(klon,nlevSTD))
+      ALLOCATE(T2STD(klon,nlevSTD))
+!IM end
       ALLOCATE(seed_old(klon,napisccp))
       ALLOCATE(zuthe(klon),zvthe(klon))
@@ -452,4 +478,8 @@
       deallocate(v2sumSTD)
       deallocate(T2sumSTD)
+!IM beg
+      deallocate(wlevSTD,ulevSTD,vlevSTD,tlevSTD,qlevSTD,rhlevSTD,philevSTD)
+      deallocate(uvSTD,vqSTD,vTSTD,wqSTD,vphiSTD,wTSTD,u2STD,v2STD,T2STD)
+!IM end
       deallocate(seed_old)
       deallocate(zuthe, zvthe)
Index: /LMDZ4/trunk/libf/phylmd/physiq.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/physiq.F	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/physiq.F	(revision 1352)
@@ -34,4 +34,6 @@
       use regr_pr_av_m, only: regr_pr_av
       use netcdf95, only: nf95_close
+cIM for NMC files
+      use netcdf, only: nf90_fill_real
       use mod_phys_lmdz_mpi_data, only: is_mpi_root
       USE aero_mod
@@ -53,5 +55,5 @@
 c   CLEFS CPP POUR LES IO
 c   =====================
-c#define histmthNMC
+#define histNMC
 c#define histISCCP
 c======================================================================
@@ -256,10 +258,5 @@
       CHARACTER*4 bb2
       CHARACTER*2 bb3
-c
-      real tlevSTD(klon,nlevSTD), qlevSTD(klon,nlevSTD)
-      real rhlevSTD(klon,nlevSTD), philevSTD(klon,nlevSTD)
-      real ulevSTD(klon,nlevSTD), vlevSTD(klon,nlevSTD)
-      real wlevSTD(klon,nlevSTD) 
-
+c 
       real twriteSTD(klon,nlevSTD,nfiles)
       real qwriteSTD(klon,nlevSTD,nfiles)
@@ -269,4 +266,33 @@
       real vwriteSTD(klon,nlevSTD,nfiles)
       real wwriteSTD(klon,nlevSTD,nfiles)
+cIM for NMC files
+      REAL geo500(klon)
+      real :: rlevSTD3(nlevSTD3)
+      DATA rlevSTD3/85000., 50000., 25000./
+      SAVE rlevSTD3
+c$OMP THREADPRIVATE(rlevSTD3)
+      real :: rlevSTD8(nlevSTD8)
+      DATA rlevSTD8/100000., 85000., 70000., 50000., 25000., 10000.,
+     $     5000., 1000./
+      SAVE rlevSTD8
+c$OMP THREADPRIVATE(rlevSTD8) 
+      real twriteSTD3(klon,nlevSTD3)
+      real qwriteSTD3(klon,nlevSTD3)
+      real rhwriteSTD3(klon,nlevSTD3)
+      real phiwriteSTD3(klon,nlevSTD3)
+      real uwriteSTD3(klon,nlevSTD3)
+      real vwriteSTD3(klon,nlevSTD3)
+      real wwriteSTD3(klon,nlevSTD3)
+c
+      real tnondefSTD8(klon,nlevSTD8)
+      real twriteSTD8(klon,nlevSTD8)
+      real qwriteSTD8(klon,nlevSTD8)
+      real rhwriteSTD8(klon,nlevSTD8)
+      real phiwriteSTD8(klon,nlevSTD8)
+      real uwriteSTD8(klon,nlevSTD8)
+      real vwriteSTD8(klon,nlevSTD8)
+      real wwriteSTD8(klon,nlevSTD8)
+c
+c plevSTD3 END
 c
 c nout : niveau de output des variables a une pression donnee
@@ -276,15 +302,4 @@
 c a partir des valeurs instantannees toutes les 6 h
 c qui sont moyennees sur le mois
-c
-      real uvSTD(klon,nlevSTD)
-      real vqSTD(klon,nlevSTD)
-      real vTSTD(klon,nlevSTD)
-      real wqSTD(klon,nlevSTD)
-c
-      real vphiSTD(klon,nlevSTD)
-      real wTSTD(klon,nlevSTD)
-      real u2STD(klon,nlevSTD)
-      real v2STD(klon,nlevSTD)
-      real T2STD(klon,nlevSTD)
 c
 #include "radopt.h"
@@ -971,5 +986,5 @@
       REAL zx_tmp_fi2d(klon)      ! variable temporaire grille physique
       REAL zx_tmp_fi3d(klon,klev) ! variable temporaire pour champs 3D 
-c#ifdef histmthNMC
+c#ifdef histNMC
 cym   A voir plus tard !!!!
 cym      REAL zx_tmp_NC(iim,jjmp1,nlevSTD)
@@ -979,10 +994,15 @@
       REAL zx_tmp_2d(iim,jjmp1), zx_tmp_3d(iim,jjmp1,klev)
       REAL zx_lon(iim,jjmp1), zx_lat(iim,jjmp1)
-c
-      INTEGER nid_day, nid_mth, nid_ins, nid_nmc, nid_day_seri
-      INTEGER nid_ctesGCM
-      SAVE nid_day, nid_mth, nid_ins, nid_nmc, nid_day_seri
-      SAVE nid_ctesGCM
-c$OMP THREADPRIVATE(nid_day, nid_mth, nid_ins, nid_nmc)
+cIM for NMC files
+      REAL missing_val
+      REAL, SAVE :: freq_moyNMC(nout)
+c$OMP THREADPRIVATE(freq_moyNMC)
+c
+      INTEGER nid_day, nid_mth, nid_ins, nid_mthnmc, nid_daynmc
+      INTEGER nid_hfnmc, nid_day_seri, nid_ctesGCM
+      SAVE nid_day, nid_mth, nid_ins, nid_mthnmc, nid_daynmc
+      SAVE nid_hfnmc, nid_day_seri, nid_ctesGCM
+c$OMP THREADPRIVATE(nid_day, nid_mth, nid_ins)
+c$OMP THREADPRIVATE(nid_mthnmc, nid_daynmc, nid_hfnmc)
 c$OMP THREADPRIVATE(nid_day_seri,nid_ctesGCM)
 c
@@ -1107,4 +1127,6 @@
 !     edges of pressure intervals for ozone climatologies, in Pa, in strictly
 !     ascending order
+cIM for NMC files en parallele
+c$OMP THREADPRIVATE(read_climoz, ncid_climoz, press_climoz)
 
       integer, save:: co3i = 0
@@ -1130,4 +1152,6 @@
 c============================================================
       real :: mr_ozone(klon,klev)
+cIM for NMC files
+      missing_val=nf90_fill_real
 c======================================================================
 ! Ecriture eventuelle d'un profil verticale en entree de la physique.
@@ -1175,4 +1199,6 @@
       print*, 'Allocation des variables locales et sauvegardees'
       call phys_local_var_init
+c
+      pasphys=pdtphys
 c     appel a la lecture du run.def physique
       call conf_phys(ok_journe, ok_mensuel,
@@ -1192,5 +1218,11 @@
       call phys_output_var_init
       print*, '================================================='
-
+cIM for NMC files
+cIM freq_moyNMC = frequences auxquelles on moyenne les champs accumules 
+cIM               sur les niveaux de pression standard du NMC
+      DO n=1, nout
+       freq_moyNMC(n)=freq_outNMC(n)/freq_calNMC(n)
+      ENDDO
+c
 cIM beg
           dnwd0=0.0
@@ -1469,5 +1501,7 @@
 #endif
 
-#ifdef histmthNMC
+#ifdef histNMC
+#include "ini_histhfNMC.h"
+#include "ini_histdayNMC.h"
 #include "ini_histmthNMC.h"
 #endif
@@ -1483,9 +1517,9 @@
 
          ecrit_hf = ecrit_hf * un_jour
-!IM
+cIM
          IF(ecrit_day.LE.1.) THEN
           ecrit_day = ecrit_day * un_jour !en secondes
          ENDIF
-!IM
+cIM
          ecrit_mth = ecrit_mth * un_jour
          ecrit_ins = ecrit_ins * un_jour
@@ -3331,19 +3365,19 @@
 c
 #include "calcul_STDlev.h"
-      twriteSTD(:,:,1)=tsumSTD(:,:,2)
-      qwriteSTD(:,:,1)=qsumSTD(:,:,2)
-      rhwriteSTD(:,:,1)=rhsumSTD(:,:,2)
-      phiwriteSTD(:,:,1)=phisumSTD(:,:,2)
-      uwriteSTD(:,:,1)=usumSTD(:,:,2)
-      vwriteSTD(:,:,1)=vsumSTD(:,:,2)
-      wwriteSTD(:,:,1)=wsumSTD(:,:,2)
-
-      twriteSTD(:,:,2)=tsumSTD(:,:,1)
-      qwriteSTD(:,:,2)=qsumSTD(:,:,1)
-      rhwriteSTD(:,:,2)=rhsumSTD(:,:,1)
-      phiwriteSTD(:,:,2)=phisumSTD(:,:,1)
-      uwriteSTD(:,:,2)=usumSTD(:,:,1)
-      vwriteSTD(:,:,2)=vsumSTD(:,:,1)
-      wwriteSTD(:,:,2)=wsumSTD(:,:,1)
+      twriteSTD(:,:,1)=tsumSTD(:,:,1)
+      qwriteSTD(:,:,1)=qsumSTD(:,:,1)
+      rhwriteSTD(:,:,1)=rhsumSTD(:,:,1)
+      phiwriteSTD(:,:,1)=phisumSTD(:,:,1)
+      uwriteSTD(:,:,1)=usumSTD(:,:,1)
+      vwriteSTD(:,:,1)=vsumSTD(:,:,1)
+      wwriteSTD(:,:,1)=wsumSTD(:,:,1)
+
+      twriteSTD(:,:,2)=tsumSTD(:,:,2)
+      qwriteSTD(:,:,2)=qsumSTD(:,:,2)
+      rhwriteSTD(:,:,2)=rhsumSTD(:,:,2)
+      phiwriteSTD(:,:,2)=phisumSTD(:,:,2)
+      uwriteSTD(:,:,2)=usumSTD(:,:,2)
+      vwriteSTD(:,:,2)=vsumSTD(:,:,2)
+      wwriteSTD(:,:,2)=wsumSTD(:,:,2)
 
       twriteSTD(:,:,3)=tlevSTD(:,:)
@@ -3362,4 +3396,42 @@
       vwriteSTD(:,:,4)=vlevSTD(:,:)
       wwriteSTD(:,:,4)=wlevSTD(:,:)
+c
+cIM initialisation 5eme fichier de sortie 
+      twriteSTD(:,:,5)=tlevSTD(:,:)
+      qwriteSTD(:,:,5)=qlevSTD(:,:)
+      rhwriteSTD(:,:,5)=rhlevSTD(:,:)
+      phiwriteSTD(:,:,5)=philevSTD(:,:)
+      uwriteSTD(:,:,5)=ulevSTD(:,:)
+      vwriteSTD(:,:,5)=vlevSTD(:,:)
+      wwriteSTD(:,:,5)=wlevSTD(:,:)
+cIM for NMC files
+      DO n=1, nlevSTD3
+       DO k=1, nlevSTD
+        if(rlevSTD3(n).EQ.rlevSTD(k)) THEN
+         twriteSTD3(:,n)=tlevSTD(:,k)
+         qwriteSTD3(:,n)=qlevSTD(:,k)
+         rhwriteSTD3(:,n)=rhlevSTD(:,k)
+         phiwriteSTD3(:,n)=philevSTD(:,k)
+         uwriteSTD3(:,n)=ulevSTD(:,k)
+         vwriteSTD3(:,n)=vlevSTD(:,k)
+         wwriteSTD3(:,n)=wlevSTD(:,k)
+        endif !rlevSTD3(n).EQ.rlevSTD(k)
+       ENDDO 
+      ENDDO 
+c
+      DO n=1, nlevSTD8
+       DO k=1, nlevSTD
+        if(rlevSTD8(n).EQ.rlevSTD(k)) THEN
+         tnondefSTD8(:,n)=tnondef(:,k,2)
+         twriteSTD8(:,n)=tsumSTD(:,k,2)
+         qwriteSTD8(:,n)=qsumSTD(:,k,2)
+         rhwriteSTD8(:,n)=rhsumSTD(:,k,2)
+         phiwriteSTD8(:,n)=phisumSTD(:,k,2)
+         uwriteSTD8(:,n)=usumSTD(:,k,2)
+         vwriteSTD8(:,n)=vsumSTD(:,k,2)
+         wwriteSTD8(:,n)=wsumSTD(:,k,2)
+        endif !rlevSTD8(n).EQ.rlevSTD(k)
+       ENDDO 
+      ENDDO 
 c
 c slp sea level pressure
@@ -3521,5 +3593,7 @@
 #endif
 
-#ifdef histmthNMC
+#ifdef histNMC
+#include "write_histhfNMC.h"
+#include "write_histdayNMC.h"
 #include "write_histmthNMC.h"
 #endif
Index: /LMDZ4/trunk/libf/phylmd/undefSTD.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/undefSTD.F	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/undefSTD.F	(revision 1352)
@@ -2,9 +2,8 @@
 ! $Header$
 !
-      SUBROUTINE undefSTD(nlevSTD,itap,tlevSTD,
-     $           dtime,ecrit_hf,
-     $           oknondef,tnondef,tsumSTD)
+      SUBROUTINE undefSTD(itap,freq_calNMC)
       USE netcdf
       USE dimphy
+      USE phys_state_var_mod ! Variables sauvegardees de la physique
       IMPLICIT none
 c
@@ -14,5 +13,5 @@
 c
 c Calcul * du nombre de pas de temps (FLOAT(ecrit_XXX)-tnondef)) 
-c          ou la variable tlevSTD est bien definie (.NE.1.E+20), 
+c          ou la variable tlevSTD est bien definie (.NE.missing_val), 
 c et 
 c        * de la somme de tlevSTD => tsumSTD
@@ -22,8 +21,8 @@
 c nout=2 !var. mensuelle "mth" moyennee sur tous les pas de temps
 c        ! de la physique
-c nout=3 !var. mensuelle "NMC" moyennee toutes les 6heures
+c nout=3 !var. mensuelle "NMC" moyennee toutes les ecrit_hf
 c
 c
-c NB: mettre "inst(X)" dans le write_histXXX.h !
+c NB: mettre "inst(X)" dans le write_hist*NMC.h !
 c====================================================================
 c
@@ -34,16 +33,19 @@
 c variables Input
 c
-      INTEGER nlevSTD, klevSTD, itap
-      PARAMETER(klevSTD=17)
-      REAL dtime, ecrit_hf
+c     INTEGER nlevSTD, klevSTD, itap
+c     PARAMETER(klevSTD=17)
+      INTEGER itap
+c     REAL dtime
 c
 c variables locales
-      INTEGER i, k, nout
-      PARAMETER(nout=3) !nout=1 : day; =2 : mth; =3 : NMC
+c     INTEGER i, k, nout, n
+c     PARAMETER(nout=3) !nout=1 : day; =2 : mth; =3 : NMC
+      INTEGER i, k, n
+      REAL freq_calNMC(nout)
 c
 c variables Output
-      REAL tlevSTD(klon,klevSTD), tsumSTD(klon,klevSTD,nout)
-      LOGICAL oknondef(klon,klevSTD,nout)
-      REAL tnondef(klon,klevSTD,nout)
+c     REAL tlevSTD(klon,klevSTD), tsumSTD(klon,klevSTD,nout)
+c     LOGICAL oknondef(klon,klevSTD,nout)
+c     REAL tnondef(klon,klevSTD,nout)
 c
       REAL missing_val
@@ -51,42 +53,52 @@
       missing_val=nf90_fill_real
 c
-c calcul variables tous les pas de temps de la physique 
+      DO n=1, nout
 c
-      DO k=1, nlevSTD
-       DO i=1, klon
-        IF(tlevSTD(i,k).EQ.missing_val) THEN
-         IF(oknondef(i,k,1)) THEN          
-          tnondef(i,k,1)=tnondef(i,k,1)+1.
-         ENDIF !oknondef(i,k)
 c
-         IF(oknondef(i,k,2)) THEN          
-          tnondef(i,k,2)=tnondef(i,k,2)+1.
-         ENDIF !oknondef(i,k)
+c calcul variables tous les freq_calNMC(n)/dtime pas de temps 
+c de la physique
 c
-        ELSE IF(tlevSTD(i,k).NE.missing_val) THEN
-         tsumSTD(i,k,1)=tsumSTD(i,k,1)+tlevSTD(i,k)
-         tsumSTD(i,k,2)=tsumSTD(i,k,2)+tlevSTD(i,k)
-        ENDIF 
-       ENDDO !i
-      ENDDO !k
+       IF(MOD(itap,NINT(freq_calNMC(n)/dtime)).EQ.0) THEN
 c
-c calcul variables toutes les 6h
+c       print*,'n freq_cal=',n,itap,freq_calNMC(n)/dtime
 c
-      IF(MOD(itap,NINT(ecrit_hf/dtime)).EQ.0) THEN
+        DO k=1, nlevSTD
+         DO i=1, klon
+          IF(tlevSTD(i,k).EQ.missing_val) THEN
+c          IF(oknondef(i,k,n)) THEN          
+            tnondef(i,k,n)=tnondef(i,k,n)+1.
+c          ENDIF !oknondef(i,k)
 c
-       DO k=1, nlevSTD
-        DO i=1, klon
-         IF(tlevSTD(i,k).EQ.missing_val) THEN
-          IF(oknondef(i,k,3)) THEN          
-           tnondef(i,k,3)=tnondef(i,k,3)+1.
-          ENDIF !oknondef(i,k)
+          ELSE IF(tlevSTD(i,k).NE.missing_val) THEN
+           tsumSTD(i,k,n)=tsumSTD(i,k,n)+tlevSTD(i,k)
+           usumSTD(i,k,n)=usumSTD(i,k,n)+ulevSTD(i,k)
+           vsumSTD(i,k,n)=vsumSTD(i,k,n)+vlevSTD(i,k)
+           wsumSTD(i,k,n)=wsumSTD(i,k,n)+wlevSTD(i,k)
+           phisumSTD(i,k,n)=phisumSTD(i,k,n)+philevSTD(i,k)
+           qsumSTD(i,k,n)=qsumSTD(i,k,n)+qlevSTD(i,k)
+           rhsumSTD(i,k,n)=rhsumSTD(i,k,n)+rhlevSTD(i,k)
+           uvsumSTD(i,k,n)=uvsumSTD(i,k,n)+uvSTD(i,k)
+           vqsumSTD(i,k,n)=vqsumSTD(i,k,n)+vqSTD(i,k)
+           vTsumSTD(i,k,n)=vTsumSTD(i,k,n)+vTSTD(i,k)
+           wqsumSTD(i,k,n)=wqsumSTD(i,k,n)+wqSTD(i,k)
+           vphisumSTD(i,k,n)=vphisumSTD(i,k,n)+vphiSTD(i,k)
+           wTsumSTD(i,k,n)=wTsumSTD(i,k,n)+wTSTD(i,k)
+           u2sumSTD(i,k,n)=u2sumSTD(i,k,n)+u2STD(i,k)
+           v2sumSTD(i,k,n)=v2sumSTD(i,k,n)+v2STD(i,k)
+           T2sumSTD(i,k,n)=T2sumSTD(i,k,n)+T2STD(i,k)
 c
-         ELSE IF(tlevSTD(i,k).NE.missing_val) THEN
-         tsumSTD(i,k,3)=tsumSTD(i,k,3)+tlevSTD(i,k)
-         ENDIF 
-        ENDDO !i
-       ENDDO !k
-
-      ENDIF !MOD(itap,NINT(ecrit_hf/dtime)).EQ.0
+c          if(n.EQ.1.AND.i.EQ.4513.AND.k.EQ.17) THEN
+           if(n.EQ.1.AND.i.EQ.1128.AND.k.EQ.17) THEN
+            print*,'itap rlon rlat tlevSTD=',itap,rlon(i),rlat(i),
+     $tlevSTD(i,k)
+           endif 
+c
+          ENDIF 
+         ENDDO !i
+        ENDDO !k
+c
+       ENDIF !MOD(itap,NINT(freq_calNMC(n)/dtime)).EQ.0
+c
+      ENDDO !n
 c
       RETURN
Index: /LMDZ4/trunk/libf/phylmd/write_histmthNMC.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histmthNMC.h	(revision 1351)
+++ /LMDZ4/trunk/libf/phylmd/write_histmthNMC.h	(revision 1352)
@@ -2,5 +2,4 @@
 ! $Header$
 !
-      IF (ok_mensuel) THEN
 c
        ndex3d = 0
@@ -9,118 +8,59 @@
 c  Champs interpolles sur des niveaux de pression du NMC
 c
-c     PARAMETER(nout=3) !nout=1 : day; =2 : mth; =3 : NMC
+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(type_run.EQ."CLIM".OR.type_run.EQ."ENSP") THEN
-ccc
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,tsumSTD(:,:,2),
-cym     $      zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"temp",itau_w,tsumSTD(:,:,2))
+       CALL histwrite_phy(nid_mthnmc,"tnondef",itau_w,tnondef(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,phisumSTD(:,:,2),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"phi",itau_w,phisumSTD(:,:,2))
+c      CALL histwrite_phy(nid_mthnmc,"ta",itau_w,twriteSTD(:,:,1))
+       CALL histwrite_phy(nid_mthnmc,"ta",itau_w,tsumSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,qsumSTD(:,:,2),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"q",itau_w,qsumSTD(:,:,2))
+       CALL histwrite_phy(nid_mthnmc,"zg",itau_w,phiwriteSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,rhsumSTD(:,:,2),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"rh",itau_w,rhsumSTD(:,:,2))
+       CALL histwrite_phy(nid_mthnmc,"hus",itau_w,qwriteSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,usumSTD(:,:,2),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"u",itau_w,usumSTD(:,:,2))
+       CALL histwrite_phy(nid_mthnmc,"hur",itau_w,rhwriteSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vsumSTD(:,:,2),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"v",itau_w,vsumSTD(:,:,2))
-ccc
-      ELSE IF(type_run.EQ."AMIP".OR.type_run.EQ."CFMI") THEN
-ccc
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,tsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"temp",itau_w,tsumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"ua",itau_w,uwriteSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,phisumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"phi",itau_w,phisumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"va",itau_w,vwriteSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,qsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"q",itau_w,qsumSTD(:,:,3))
-c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,rhsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"rh",itau_w,rhsumSTD(:,:,3))
-c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,usumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"u",itau_w,usumSTD(:,:,3))
-c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"v",itau_w,vsumSTD(:,:,3))
-c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,wsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"w",itau_w,wsumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"wap",itau_w,wwriteSTD(:,:,1))
 c
        DO k=1, nlevSTD
         DO i=1, klon
-         IF(tnondef(i,k,3).NE.1.E+20) THEN
-          zx_tmp_fiNC(i,k) = (100.*tnondef(i,k,3))/ecrit_hf2mth
+         IF(tnondef(i,k,1).NE.missing_val) THEN
+          zx_tmp_fiNC(i,k) = (100.*tnondef(i,k,1))/ecrit_hf2mth
          ELSE
-          zx_tmp_fiNC(i,k) = 1.E+20
+          zx_tmp_fiNC(i,k) = missing_val
          ENDIF
         ENDDO
        ENDDO !k=1, nlevSTD
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,zx_tmp_fiNC,zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"psbg",itau_w,zx_tmp_fiNC)
+       CALL histwrite_phy(nid_mthnmc,"psbg",itau_w,zx_tmp_fiNC)
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,uvsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"uv",itau_w,uvsumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"uv",itau_w,uvsumSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vqsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"vq",itau_w,vqsumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"vq",itau_w,vqsumSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vTsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"vT",itau_w,vTsumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"vT",itau_w,vTsumSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1, wqsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"wq",itau_w,wqsumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"wq",itau_w,wqsumSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vphisumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"vphi",itau_w,vphisumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"vphi",itau_w,vphisumSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,wTsumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"wT",itau_w,wTsumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"wT",itau_w,wTsumSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,u2sumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"uxu",itau_w,u2sumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"uxu",itau_w,u2sumSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,v2sumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"vxv",itau_w,v2sumSTD(:,:,3))
+       CALL histwrite_phy(nid_mthnmc,"vxv",itau_w,v2sumSTD(:,:,1))
 c
-cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,T2sumSTD(:,:,3),
-cym     $     zx_tmp_NC)
-       CALL histwrite_phy(nid_nmc,"TxT",itau_w,T2sumSTD(:,:,3))
-c
-      ENDIF !type_run
+       CALL histwrite_phy(nid_mthnmc,"TxT",itau_w,T2sumSTD(:,:,1))
 c
       if (ok_sync) then
 c$OMP MASTER
-        call histsync(nid_nmc)
+        call histsync(nid_mthnmc)
 c$OMP END MASTER
       endif
-
-      ENDIF
