Index: /LMDZ5/trunk/libf/phylmd/ini_paramLMDZ_phy.h
===================================================================
--- /LMDZ5/trunk/libf/phylmd/ini_paramLMDZ_phy.h	(revision 1537)
+++ /LMDZ5/trunk/libf/phylmd/ini_paramLMDZ_phy.h	(revision 1538)
@@ -1,361 +1,133 @@
-cym    Non implemente en mode parallele
+cIM    Implemente en modes sequentiel et parallele
 
-       IF (is_sequential) THEN  
+       CALL gather(rlat,rlat_glo)
+       CALL bcast(rlat_glo)
+       CALL gather(rlon,rlon_glo)
+       CALL bcast(rlon_glo)
+
+c$OMP MASTER
+      if (is_mpi_root) then
 c
        zstophy = dtime
-       zout = ecrit_day
+       zout = mth_len*un_jour
 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)
+       CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon_glo,zx_lon)
        if (iim.gt.1) then
        DO i = 1, iim
-         zx_lon(i,1) = rlon(i+1)
-         zx_lon(i,jjmp1) = rlon(i+1)
+         zx_lon(i,1) = rlon_glo(i+1)
+         zx_lon(i,jjmp1) = rlon_glo(i+1)
        ENDDO
        endif
-       CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
+       CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat_glo,zx_lat)
 c
        CALL histbeg("paramLMDZ_phy.nc", 
-     .                 iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
+     .                 np,zx_lon(np:np,1), np,zx_lat(1,np:np),
      .                 1,1,1,1,
      .                 itau_phy, zjulian, dtime,
      .                 nhori, nid_ctesGCM)
 c
-c Variables type caractere : plusieurs valeurs possibles
-c
-       CALL histdef(nid_ctesGCM, "ocean", 
-     .        "Type ocean utilise: 1=force, 2=slab, 3=couple",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "type_run",
-     .        "Type run: 1= CLIM ou ENSP, 2= AMIP ou CFMI",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-c Variables logiques (1=true, 0=false)
-c
-       CALL histdef(nid_ctesGCM, "ok_veget", 
-     .        "Type de modele de vegetation: 1=ORCHIDEE, 0=bucket",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ok_journe", 
-     .        "Creation du fichier histday: 1=true, 0=false",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ok_mensuel", 
-     .        "Creation du fichier histmth: 1=true, 0=false",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ok_instan", 
-     .        "Creation du fichier histins: 1=true, 0=false",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ok_ade", 
-     .        "Aerosol direct effect: 1=true, 0=false",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ok_aie", 
-     .        "Aerosol indirect effect: 1=true, 0=false",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "bl95_b0", 
-     .        "Parameter in CDNC-maer link (Boucher&Lohmann 1995)",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "bl95_b1", 
-     .        "Parameter in CDNC-maer link (Boucher&Lohmann 1995)",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ip_ebil_phy", 
-     .                "Niveau sortie diags bilan energie cote physique",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32, 
-     .                "ave(X)", zstophy,zout)
-c
        CALL histdef(nid_ctesGCM, "R_ecc", 
      .                "Excentricite","-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
        CALL histdef(nid_ctesGCM, "R_peri", 
      .                "Equinoxe","-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
        CALL histdef(nid_ctesGCM, "R_incl", 
      .                "Inclinaison","deg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
        CALL histdef(nid_ctesGCM, "solaire", 
      .                "Constante solaire","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
        CALL histdef(nid_ctesGCM, "co2_ppm", 
      .                "Concentration du CO2", "ppm",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                1,1,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,zout)
 c
        CALL histdef(nid_ctesGCM, "CH4_ppb", 
      .                "Concentration du CH4", "ppb",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                1,1,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,zout)
 c
        CALL histdef(nid_ctesGCM, "N2O_ppb",
      .                "Concentration du N2O", "ppb",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                1,1,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
        CALL histdef(nid_ctesGCM, "CFC11_ppt",
      .                "Concentration du CFC11", "ppt",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                1,1,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
        CALL histdef(nid_ctesGCM, "CFC12_ppt",
      .                "Concentration du CFC12", "ppt",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                1,1,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "epmax",
-     .                "Efficacite precip", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+       CALL histdef(nid_ctesGCM, "bils",
+     .                "Surface total heat flux", "W m-2",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "ok_adj_ema",
-     .                "ok_adj_ema: 1=true, 0=false", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+       CALL histdef(nid_ctesGCM, "evap",
+     .                "Evaporation", "kg m-2 s-1",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "iflag_clw",
-     .                "iflag_clw", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+       CALL histdef(nid_ctesGCM, "evap_land",
+     .                "Land evaporation", "kg m-2 s-1",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "cld_lc_lsc",
-     .                "cld_lc_lsc", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+       CALL histdef(nid_ctesGCM, "flat",
+     .                "Latent heat flux", "W m-2",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "cld_lc_con",
-     .                "cld_lc_con", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+       CALL histdef(nid_ctesGCM, "nettop0",
+     .                "Clear sky net downward radiatif flux at TOA", 
+     .                "W m-2",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "cld_tau_lsc",
-     .                "cld_tau_lsc", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+       CALL histdef(nid_ctesGCM, "nettop",
+     .                "Net downward radiatif flux at TOA", "W m-2",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "cld_tau_con",
-     .                "cld_tau_con", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+       CALL histdef(nid_ctesGCM, "precip",
+     .                "Total precipitation (liq+sol)", "kg m-2 s-1",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "ffallv_lsc",
-     .                "ffallv_lsc", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+       CALL histdef(nid_ctesGCM, "tsol",
+     .                "Surface temperature", "K",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "ffallv_con",
-     .                "ffallv_con", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
+       CALL histdef(nid_ctesGCM, "t2m",
+     .                "Temperature at 2m", "K",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout)
 c
-       CALL histdef(nid_ctesGCM, "coef_eva",
-     .                "coef_eva", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "reevap_ice",
-     .                "reevap_ice: 1=true, 0=false", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "iflag_cldcon",
-     .                "iflag_cldcon", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "iflag_pdf",
-     .                "iflag_pdf", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "fact_cldcon",
-     .                "fact_cldcon", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "facttemps",
-     .                "facttemps", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ok_newmicro",
-     .                "Nouvelle micro-physique: 1=true, 0=false",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ratqsbas",
-     .                "ratqsbas", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ratqshaut",
-     .                "ratqshaut", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "rad_froid",
-     .                "rad_froid", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "rad_chau1",
-     .                "rad_chau1", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "rad_chau2",
-     .                "rad_chau2", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "top_height",
-     .                "top_height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "overlap",
-     .                "overlap", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "cdmmax",
-     .                "cdmmax", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "cdhmax",
-     .                "cdhmax", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ksta",
-     .                "ksta", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ksta_ter",
-     .                "ksta_ter", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ok_kzmin",
-     .                "ok_kzmin: 1=true, 0=false", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "iflag_pbl",
-     .                "iflag_pbl", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "lev_histhf",
-     .                "lev_histhf", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "lev_histday",
-     .                "lev_histday", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "lev_histmth",
-     .                "lev_histmth", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ok_isccp",
-     .                "Creation fichier histISCCP: 1=true, 0=false",
-     .                "-",iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "lonmin_ins",
-     .                "lonmin_ins", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "lonmax_ins",
-     .                "lonmax_ins", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "latmin_ins",
-     .                "latmin_ins", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "latmax_ins",
-     .                "latmax_ins", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ecrit_ins",
-     .                "ecrit_ins", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ecrit_hf",
-     .                "ecrit_hf", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ecrit_day",
-     .                "ecrit_day", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ecrit_mth",
-     .                "ecrit_mth", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ecrit_tra",
-     .                "ecrit_tra", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ecrit_reg",
-     .                "ecrit_reg", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "freq_ISCCP",
-     .                "freq_ISCCP", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
-       CALL histdef(nid_ctesGCM, "ecrit_ISCCP",
-     .                "ecrit_ISCCP", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "once", zstophy,zout)
-c
+       CALL histdef(nid_ctesGCM, "prw",
+     .                "Precipitable water", "kg m-2",
+     .                1,1,nhori, 1,1,1, -99, 32,
+     .                "ave", zstophy,zout) 
 c=================================================================
 c
        CALL histend(nid_ctesGCM)
        
-       ENDIF ! is_sequential
-c
+       endif !(is_mpi_root)
+c$OMP END MASTER
 c=================================================================
Index: /LMDZ5/trunk/libf/phylmd/physiq.F
===================================================================
--- /LMDZ5/trunk/libf/phylmd/physiq.F	(revision 1537)
+++ /LMDZ5/trunk/libf/phylmd/physiq.F	(revision 1538)
@@ -1179,4 +1179,13 @@
 c============================================================
       real :: mr_ozone(klon,klev)
+
+cIM sorties fichier 1D paramLMDZ_phy.nc
+      REAL :: zx_tmp_0d(1,1)
+      INTEGER, PARAMETER :: np=1
+      REAL,dimension(klon_glo)        :: rlat_glo
+      REAL,dimension(klon_glo)        :: rlon_glo
+      REAL gbils(1), gevap(1), gevapt(1), glat(1), gnet0(1), gnet(1)
+      REAL grain(1), gtsol(1), gt2m(1), gprw(1)
+
 cIM for NMC files
       missing_val=nf90_fill_real
Index: /LMDZ5/trunk/libf/phylmd/write_paramLMDZ_phy.h
===================================================================
--- /LMDZ5/trunk/libf/phylmd/write_paramLMDZ_phy.h	(revision 1537)
+++ /LMDZ5/trunk/libf/phylmd/write_paramLMDZ_phy.h	(revision 1538)
@@ -1,353 +1,93 @@
 c
-      IF (is_sequential) THEN
-      
+c calcul moyennes globales
+c
+       zx_tmp_fi2d=bils*airephy
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,gbils)
+       zx_tmp_fi2d=evap*airephy
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,gevap)
+       zx_tmp_fi2d(:)=fevap(:, is_ter)*airephy(:)
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,gevapt)
+       zx_tmp_fi2d=zxfluxlat*airephy
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,glat)
+       zx_tmp_fi2d=(topsw0-toplw0)*airephy
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,gnet0)
+       zx_tmp_fi2d=(topsw-toplw)*airephy
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,gnet)
+       zx_tmp_fi2d=(rain_fall+snow_fall)*airephy
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,grain)
+       zx_tmp_fi2d=zxtsol*airephy
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,gtsol)
+       zx_tmp_fi2d=zt2m*airephy
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,gt2m)
+       zx_tmp_fi2d=prw*airephy
+       CALL global_mean(zx_tmp_fi2d,airephy,.TRUE.,gprw)
+c
+c$OMP MASTER
+      if (is_mpi_root) then      
+c
       ndex2d = 0
       itau_w = itau_phy + itap
 c
-c Variables type caractere : plusieurs valeurs possibles
+c Variables globales
 c
-      IF(type_ocean.EQ.'force ') THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE IF(type_ocean.EQ.'slab  ') THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=2.
-      ELSE IF(type_ocean.EQ.'couple') THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=3.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ocean",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
+      zx_tmp_0d=R_ecc
+      CALL histwrite(nid_ctesGCM,"R_ecc",itau_w,
+     .               zx_tmp_0d,np,ndex2d)
 c
-      IF(type_run.EQ.'CLIM'.OR.type_run.EQ.'ENSP') THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE IF(type_run.EQ.'AMIP'.OR.type_run.EQ.'CFMI') THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=2.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"type_run",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
+      zx_tmp_0d=R_peri
+      CALL histwrite(nid_ctesGCM,"R_peri",itau_w,
+     .               zx_tmp_0d,np,ndex2d)
 c
-c Variables logiques (1=true, 2=false)
+      zx_tmp_0d=R_incl
+      CALL histwrite(nid_ctesGCM,"R_incl",itau_w,
+     .               zx_tmp_0d,np,ndex2d)
 c
-      IF(ok_veget) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_veget",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
+      zx_tmp_0d=solaire
+      CALL histwrite(nid_ctesGCM,"solaire",itau_w,
+     .               zx_tmp_0d,np,ndex2d)
 c
-      IF(ok_journe) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_journe",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
+      zx_tmp_0d=co2_ppm
+      CALL histwrite(nid_ctesGCM,"co2_ppm",itau_w,
+     .               zx_tmp_0d,np,ndex2d)
 c
-      IF(ok_mensuel) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_mensuel",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
+      zx_tmp_0d=CH4_ppb
+      CALL histwrite(nid_ctesGCM,"CH4_ppb",itau_w,
+     .               zx_tmp_0d,np,ndex2d)
 c
-      IF(ok_instan) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_instan",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
+      zx_tmp_0d=N2O_ppb
+      CALL histwrite(nid_ctesGCM,"N2O_ppb",itau_w,
+     .               zx_tmp_0d,np,ndex2d)
 c
-      IF(ok_ade) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_ade",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
+      zx_tmp_0d=CFC11_ppt
+      CALL histwrite(nid_ctesGCM,"CFC11_ppt",itau_w,
+     .               zx_tmp_0d,np,ndex2d)
 c
-      IF(ok_aie) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_aie",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-
-c
-c Champs 2D:
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=bl95_b0
-      CALL histwrite(nid_ctesGCM,"bl95_b0",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=bl95_b1
-      CALL histwrite(nid_ctesGCM,"bl95_b1",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ip_ebil_phy
-      CALL histwrite(nid_ctesGCM,"ip_ebil_phy",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=R_ecc
-      CALL histwrite(nid_ctesGCM,"R_ecc",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=R_peri
-      CALL histwrite(nid_ctesGCM,"R_peri",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=R_incl
-      CALL histwrite(nid_ctesGCM,"R_incl",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=solaire
-      CALL histwrite(nid_ctesGCM,"solaire",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=co2_ppm
-      CALL histwrite(nid_ctesGCM,"co2_ppm",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=CH4_ppb
-      CALL histwrite(nid_ctesGCM,"CH4_ppb",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=N2O_ppb
-      CALL histwrite(nid_ctesGCM,"N2O_ppb",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=CFC11_ppt
-      CALL histwrite(nid_ctesGCM,"CFC11_ppt",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=CFC12_ppt
+      zx_tmp_0d=CFC12_ppt
       CALL histwrite(nid_ctesGCM,"CFC12_ppt",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=epmax
-      CALL histwrite(nid_ctesGCM,"epmax",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
-! Mais est-il bien raisonable de stoker ces fichiers comme des
-! champs 2D...
-! WARNING :
-! Il faudrait ici ajoute l'ecriture des champs
-!      cycle_diurne = cycle_diurne_omp
-!   soil_model = soil_model_omp
-!   new_oliq = new_oliq_omp
-!   ok_orodr = ok_orodr_omp
-!   ok_orolf = ok_orolf_omp
-!   ok_limitvrai = ok_limitvrai_omp
-!   nbapp_rad = nbapp_rad_omp
-!   iflag_con = iflag_con_omp
-! qui se trouvaient auparavant dans gcm.def et maintenant dans 
-! physiq.def.
-! Mais regarder d'abord a quoi ca sert ...
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-
-c
-      IF(ok_adj_ema) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_adj_ema",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=iflag_clw
-      CALL histwrite(nid_ctesGCM,"iflag_clw",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=cld_lc_lsc
-      CALL histwrite(nid_ctesGCM,"cld_lc_lsc",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=cld_lc_con
-      CALL histwrite(nid_ctesGCM,"cld_lc_con",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=cld_tau_lsc
-      CALL histwrite(nid_ctesGCM,"cld_tau_lsc",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=cld_tau_con
-      CALL histwrite(nid_ctesGCM,"cld_tau_con",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ffallv_lsc
-      CALL histwrite(nid_ctesGCM,"ffallv_lsc",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ffallv_con
-      CALL histwrite(nid_ctesGCM,"ffallv_con",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=coef_eva
-      CALL histwrite(nid_ctesGCM,"coef_eva",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      IF(reevap_ice) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"reevap_ice",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=iflag_cldcon
-      CALL histwrite(nid_ctesGCM,"iflag_cldcon",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=iflag_pdf
-      CALL histwrite(nid_ctesGCM,"iflag_pdf",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=fact_cldcon
-      CALL histwrite(nid_ctesGCM,"fact_cldcon",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=facttemps
-      CALL histwrite(nid_ctesGCM,"facttemps",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      IF(ok_newmicro) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_newmicro",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ratqsbas
-      CALL histwrite(nid_ctesGCM,"ratqsbas",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ratqshaut
-      CALL histwrite(nid_ctesGCM,"ratqshaut",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=rad_froid
-      CALL histwrite(nid_ctesGCM,"rad_froid",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=rad_chau1
-      CALL histwrite(nid_ctesGCM,"rad_chau1",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=rad_chau2
-      CALL histwrite(nid_ctesGCM,"rad_chau2",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=top_height
-      CALL histwrite(nid_ctesGCM,"top_height",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=overlap
-      CALL histwrite(nid_ctesGCM,"overlap",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=cdmmax
-      CALL histwrite(nid_ctesGCM,"cdmmax",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=cdhmax
-      CALL histwrite(nid_ctesGCM,"cdhmax",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ksta
-      CALL histwrite(nid_ctesGCM,"ksta",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ksta_ter
-      CALL histwrite(nid_ctesGCM,"ksta_ter",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      IF(ok_kzmin) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_kzmin",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=iflag_pbl
-      CALL histwrite(nid_ctesGCM,"iflag_pbl",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=lev_histhf
-      CALL histwrite(nid_ctesGCM,"lev_histhf",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=lev_histday
-      CALL histwrite(nid_ctesGCM,"lev_histday",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=lev_histmth
-      CALL histwrite(nid_ctesGCM,"lev_histmth",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      IF(ok_isccp) THEN
-       zx_tmp_2d(1:iim,1:jjmp1)=1.
-      ELSE
-       zx_tmp_2d(1:iim,1:jjmp1)=0.
-      ENDIF
-      CALL histwrite(nid_ctesGCM,"ok_isccp",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=lonmin_ins
-      CALL histwrite(nid_ctesGCM,"lonmin_ins",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=lonmax_ins
-      CALL histwrite(nid_ctesGCM,"lonmax_ins",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=latmin_ins
-      CALL histwrite(nid_ctesGCM,"latmin_ins",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=latmax_ins
-      CALL histwrite(nid_ctesGCM,"latmax_ins",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_ins
-      CALL histwrite(nid_ctesGCM,"ecrit_ins",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_hf
-      CALL histwrite(nid_ctesGCM,"ecrit_hf",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_day
-      CALL histwrite(nid_ctesGCM,"ecrit_day",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_mth
-      CALL histwrite(nid_ctesGCM,"ecrit_mth",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_tra
-      CALL histwrite(nid_ctesGCM,"ecrit_tra",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_reg
-      CALL histwrite(nid_ctesGCM,"ecrit_reg",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=freq_ISCCP
-      CALL histwrite(nid_ctesGCM,"freq_ISCCP",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_ISCCP
-      CALL histwrite(nid_ctesGCM,"ecrit_ISCCP",itau_w,
-     .               zx_tmp_2d,iim*jjmp1,ndex2d)
+     .               zx_tmp_0d,np,ndex2d)
 c
 c=================================================================
-c=================================================================
+c moyennes globales
+c
+      CALL histwrite(nid_ctesGCM,"bils",itau_w,
+     .               gbils,np,ndex2d)
+      CALL histwrite(nid_ctesGCM,"evap",itau_w,
+     .               gevap,np,ndex2d)
+      CALL histwrite(nid_ctesGCM,"evap_land",itau_w,
+     .               gevapt,np,ndex2d)
+      CALL histwrite(nid_ctesGCM,"flat",itau_w,
+     .               glat,np,ndex2d)
+      CALL histwrite(nid_ctesGCM,"nettop0",itau_w,
+     .               gnet0,np,ndex2d)
+      CALL histwrite(nid_ctesGCM,"nettop",itau_w,
+     .               gnet,np,ndex2d)
+      CALL histwrite(nid_ctesGCM,"precip",itau_w,
+     .               grain,np,ndex2d)
+      CALL histwrite(nid_ctesGCM,"tsol",itau_w,
+     .               gtsol,np,ndex2d)
+      CALL histwrite(nid_ctesGCM,"t2m",itau_w,
+     .               gt2m,np,ndex2d)
+      CALL histwrite(nid_ctesGCM,"prw",itau_w,
+     .               gprw,np,ndex2d)
 c=================================================================
 c
@@ -356,3 +96,4 @@
       endif
 c
-      ENDIF ! mono_cpu
+      endif !(is_mpi_root) then      
+c$OMP END MASTER
