Index: LMDZ.3.3/branches/rel-LF/libf/phylmd/ini_histhf.h
===================================================================
--- LMDZ.3.3/branches/rel-LF/libf/phylmd/ini_histhf.h	(revision 467)
+++ LMDZ.3.3/branches/rel-LF/libf/phylmd/ini_histhf.h	(revision 506)
@@ -2,9 +2,29 @@
       IF (ok_hf) THEN
 c
-         PRINT*, 'La frequence de sortie instant. est de ', ecrit_hf
-
-cccIM    CALL ymds2ju(anne_ini, 1, 1, 0.0, zjulian)
+       IF(region.EQ.'3d') THEN
+c
+        zout = dtime * REAL(NINT(86400./dtime*ecrit_hf))
+        zsto = zout
+        zsto1 = dtime
+        PRINT*, 'La frequence de sortie instant. est de ', ecrit_hf
+c
+       ELSEIF(region.EQ.'1d') THEN 
+c
+c   pour les champs instantannes, il faut mettre la meme valeur pour
+c   zout et tsto.
+c   dtime est passe par ailleurs a histbeg
+         zsto = dtime
+c        zout = dtime
+         zout = dtime *4. 
+       ENDIF 
+       print*,'zout,zsto=',zout,zsto
+cIM cf LF
          idayref = day_ref
          CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
+
+cccIM    CALL ymds2ju(anne_ini, 1, 1, 0.0, zjulian)
+c        CALL ymds2ju(annee_ref, 1, 1, 0.0, zjulian)
+c        zjulian = zjulian + day_ini
+cIM cf LF
 
 c
@@ -19,19 +39,18 @@
 cccIM      CALL histbeg("histhf", iim,zx_lon, jjmp1,zx_lat,
          CALL histbeg("histhf", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
+cIM cf LF    .                 1,iim,1,jjmp1, 0, zjulian, dtime, 
+c071103
+c    .                 1,iim,1,jjmp1, 
+     .                 imin_debut,nbpti,
+     .                 jmin_debut,nbptj,
+c071103
+     .                 itau_phy, zjulian, dtime, 
      .                 nhori, nid_hf)
 
          CALL histvert(nid_hf, "presnivs", "Vertical levels", "mb",
      .                 klev, presnivs, nvert)
-         zsto = dtime
-
-c   pour les champs instantannes, il faut mettre la meme valeur pour
-c   zout et tsto.
-c   dtime est passe par ailleurs a histbeg
-
-         zout = dtime * REAL(NINT(86400./dtime*ecrit_hf))
-         zsto = zout
-         print*,'zout,zsto=',zout,zsto
-
+c
+
+      IF(lev_histhf.GE.1) THEN
 c
 c        CALL histdef(nid_hf, "phis", "Surface geop. height", "-",
@@ -43,8 +62,24 @@
 c    .                "once", zsto,zout)
 c
+         CALL histdef(nid_hf, "aireTER","Grid area CONT","-",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "once", zsto,zout)
+c
+         CALL histdef(nid_hf, "contfracATM","% sfce ter+lic ","-",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "once", zsto,zout)
+c
+         CALL histdef(nid_hf, "contfracOR","% sfce terre OR", "-",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "once", zsto,zout)
+c
 c Champs 2D:
 c
-         CALL histdef(nid_hf, "tsol", "Surface Temperature", "K",
+         CALL histdef(nid_hf, "t2m", "Temperature 2m", "K",
      .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                "inst(X)", zsto,zout)
+c
+         CALL histdef(nid_hf, "q2m", "Specific humidity", "kg/kg",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
@@ -55,55 +90,126 @@
          print*,'ATTENTION METTRE AVE(X) POUR LES PRECIPS'
 
-         CALL histdef(nid_hf, "rain", "Precipitation", "mm/d",
+         CALL histdef(nid_hf, "rain", "Precipitation", "kg/m^2s",
      .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_hf, "u850", "Zonal wind 850mb", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-
-         CALL histdef(nid_hf, "v850", "Meridional wind 850mb", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-c
-         CALL histdef(nid_hf, "u500", "Zonal wind 500mb", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-
-         CALL histdef(nid_hf, "v500", "Meridional wind 500mb", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-
-         CALL histdef(nid_hf, "u200", "Zonal wind 200mb", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-
-         CALL histdef(nid_hf, "v200", "Meridional wind 200mb", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-
-         CALL histdef(nid_hf, "phi500", "Geopotentiel a 500mb", "m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "inst(X)", zsto,zout)
-
-cIM cf FH
-         CALL histdef(nid_hf,"u1","Zonal wind at 1st layer", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
-
-         CALL histdef(nid_hf,"v1","Meridional wind at 1st layer",
-     .                "m/s",iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zsto,zout)
- 
+     .                "ave(X)", zsto1,zout)
+c
+cIM ENSEMBLES BEG
+c
+         CALL histdef(nid_hf, "tsol", "Surface Temperature", "K",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+c
+         CALL histdef(nid_hf, "slp", "Sea Level Pressure", "Pa",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+c
+c
+         CALL histdef(nid_hf, "u10m", "Vent zonal 10m", "m/s",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+c
+         CALL histdef(nid_hf, "v10m", "Vent meridien 10m", "m/s",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+c
+         CALL histdef(nid_hf, "wind10m","10-m wind speed","m/s",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+c
+         DO k=1, nlevENS 
+          IF(clev(k).EQ."500") THEN
+          CALL histdef(nid_hf, "phi"//clev(k),
+     .                "Geopotential"//clev(k)//"mb", "m2/s2",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+          ENDIF !clev(k).EQ."500"
+         ENDDO !k=1, nlevENS
+c
+      ENDIF !lev_histhf.GE.1
+c
+      IF(lev_histhf.GE.2) THEN
+c
+         CALL histdef(nid_hf, "cldt", "Total cloudiness", "-",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zsto1,zout)
+c
+c
+         CALL histdef(nid_hf, "SWdownOR",
+     .                "Sfce incident SW radiation OR", "W/m^2",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zsto1,zout)
+c
+         CALL histdef(nid_hf, "LWdownOR",
+     .                "Sfce incident LW radiation OR", "W/m^2",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zsto1,zout)
+      ENDIF !lev_histhf.GE.2
+c
+cIM ENSEMBLES END
+c
+      IF(lev_histhf.GE.3) THEN
+c
+         DO k=1, nlevENS
+c
+          CALL histdef(nid_hf, "t"//clev(k),
+     .                 "Temperature"//clev(k)//"mb","K",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+c
+          IF(clev(k).NE."500") THEN
+          CALL histdef(nid_hf, "phi"//clev(k), 
+     .                "Geopotential"//clev(k)//"mb", "m2/s2",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+          ENDIF
+c
+          CALL histdef(nid_hf, "q"//clev(k),
+     .                 "Specific humidity"//clev(k)//"mb","kg/kg",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+c
+         IF(1.EQ.0) THEN
+         CALL histdef(nid_hf, "rh"//clev(k),
+     .                 "Relative humidity"//clev(k)//"mb", "%",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+         ENDIF
+c
+          CALL histdef(nid_hf, "u"//clev(k),
+     .                 "Zonal wind"//clev(k)//"mb","m/s",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+c
+          CALL histdef(nid_hf, "v"//clev(k),
+     .                 "Meridional wind"//clev(k)//"mb","m/s",
+     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "inst(X)", zsto,zout)
+c
+         ENDDO !nlevENS
+         IF(1.EQ.0) THEN
          CALL histdef(nid_hf, "cdrm", " Momentum drag coef.", "-",
      .                iim,jjmp1,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
-
+c
          CALL histdef(nid_hf, "cdrh", "Heat drag coef.", "-",
      .                iim,jjmp1,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
- 
+         ENDIF !(1.EQ.0) THEN
+c
+      ENDIF !lev_histhf.GE.3
+c
+      IF(lev_histhf.GE.4) THEN
+#define histhf3d
+#ifdef histhf3d
+#include "ini_histhf3d.h"
+#endif
+      ENDIF !lev_histhf.GE.4
+c
+c#define histhf3d
+c#ifdef histhf3d
+c#include "ini_histhf3d.h"
+c#endif
 c
          CALL histend(nid_hf)
-
+c
       endif ! ok_hf
