Index: /LMDZ4/branches/LMDZ4_par_0/libf/dyn3d/gcm.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/dyn3d/gcm.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/dyn3d/gcm.F	(revision 634)
@@ -9,4 +9,7 @@
       USE IOIPSL
 #endif
+
+      USE dimphy
+      USE comgeomphy
 
       IMPLICIT NONE
@@ -188,4 +191,10 @@
 c
 c
+c------------------------------------
+c   Initialisation partie parallele
+c------------------------------------
+      call InitDimphy
+      call InitComgeomphy
+
 c-----------------------------------------------------------------------
 c   Initialisation des traceurs
Index: /LMDZ4/branches/LMDZ4_par_0/libf/dyn3d/paramet.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/dyn3d/paramet.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/dyn3d/paramet.h	(revision 634)
@@ -10,6 +10,6 @@
       INTEGER jcfil,jcfllm
 
-      PARAMETER( iip1= iim+1-1/iim,iip2=iim+2,iip3=iim+3
-     s    ,jjp1=jjm+1-1/jjm)
+      PARAMETER( iip1= iim+1-1/iim,iip2=iim+2,iip3=iim+3)
+      PARAMETER( jjp1=jjm+1-1/jjm)
       PARAMETER( llmp1 = llm+1,  llmp2 = llm+2, llmm1 = llm-1 )
       PARAMETER( kftd  = iim/2 -ndm )
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/aeropt.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/aeropt.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/aeropt.F	(revision 634)
@@ -5,10 +5,11 @@
      .            tau_ae, piz_ae, cg_ae, ai        )
 c
+      USE dimphy
       IMPLICIT none
 c
 c
 c     
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ajsec.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ajsec.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ajsec.F	(revision 634)
@@ -3,4 +3,5 @@
 !
       SUBROUTINE ajsec(paprs, pplay, t,q, d_t,d_q)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -13,6 +14,6 @@
 c d_t-----output-R-Incrementation de la temperature
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
       REAL paprs(klon,klev+1), pplay(klon,klev)
@@ -22,5 +23,5 @@
       INTEGER limbas, limhau ! les couches a ajuster
 ccc      PARAMETER (limbas=klev-3, limhau=klev)
-      PARAMETER (limbas=1, limhau=klev)
+cym      PARAMETER (limbas=1, limhau=klev)
 c
       LOGICAL mixq
@@ -38,4 +39,8 @@
 c Initialisation:
 c
+cym
+      limbas=1
+      limhau=klev
+  
       DO k = 1, klev
       DO i = 1, klon
@@ -149,4 +154,5 @@
       END
       SUBROUTINE ajsec_old(paprs, pplay, t, d_t)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -159,6 +165,6 @@
 c d_t-----output-R-Incrementation de la temperature
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
       REAL paprs(klon,klev+1), pplay(klon,klev)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/albedo.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/albedo.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/albedo.F	(revision 634)
@@ -5,4 +5,5 @@
 c
       SUBROUTINE alboc(rjour,rlat,albedo)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -17,6 +18,6 @@
 c albedo (out,R): albedo obtenu (de 0 a 1)
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
@@ -127,4 +128,5 @@
 c=====================================================================
       SUBROUTINE alboc_cd(rmu0,albedo)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -140,6 +142,6 @@
 c albedo (out): albedo de surface de l'ocean
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
       REAL rmu0(klon), albedo(klon)
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/calcratqs.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/calcratqs.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/calcratqs.F	(revision 634)
@@ -5,4 +5,5 @@
      I            paprs,pplay,q_seri,d_t_con,d_t_ajs
      O           ,ratqs,zpt_conv)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -23,6 +24,6 @@
 c pplay---input-R-pression pour le mileu de chaque couche (en Pa)
 c presnivs-input_R_pressions approximat. des milieux couches ( en PA)
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
       REAL paprs(klon,klev+1)
       REAL pplay(klon,klev)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/calltherm.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/calltherm.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/calltherm.F	(revision 634)
@@ -8,7 +8,8 @@
      s      ,fm_therm,entr_therm)
 
+      USE dimphy
       implicit none
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "thermcell.h"
 
@@ -35,7 +36,9 @@
       REAL d_u_the(klon,klev),d_v_the(klon,klev)
 c
-      real zfm_therm(klon,klev+1),zentr_therm(klon,klev),zdt
-      save zentr_therm,zfm_therm
-
+cym      real zfm_therm(klon,klev+1),zentr_therm(klon,klev),zdt
+cym      save zentr_therm,zfm_therm
+      real,allocatable,dimension(:,:),save :: zfm_therm,zentr_therm
+      real :: zdt
+      logical,save :: first=.true.
       integer i,k
 
@@ -47,5 +50,12 @@
        print*,'avant isplit ',nsplit_thermals
 
-
+cym initialisation dynamique
+         if (first) then
+	   allocate(zfm_therm(klon,klev+1),zentr_therm(klon,klev))
+	   zfm_therm(:,:)=0.
+	   zentr_therm(:,:)=0.
+	   first=.false.
+	 endif
+	 
          fm_therm(:,:)=0.
          entr_therm(:,:)=0.
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/clmain.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/clmain.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/clmain.F	(revision 634)
@@ -4,4 +4,6 @@
 c
 c
+#define IO_DISCONNECTED
+
       SUBROUTINE clmain(dtime,itap,date0,pctsrf,pctsrf_new,
      .                  t,q,u,v,
@@ -39,4 +41,5 @@
       USE ioipsl
       USE interface_surf
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -83,6 +86,6 @@
 c d_tr-------output-R tendance de traceurs
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "indicesol.h"
 c$$$ PB ajout pour soil
@@ -225,8 +228,10 @@
       INTEGER nhoridbg, nidbg
       SAVE nhoridbg, nidbg
+#ifndef IO_DISCONNECTED
       INTEGER ndexbg(iim*(jjm+1))
       REAL zx_lon(iim,jjm+1), zx_lat(iim,jjm+1), zjulian
       REAL tabindx(klon)
       REAL debugtab(iim,jjm+1)
+#endif
       LOGICAL first_appel
       SAVE first_appel
@@ -274,4 +279,5 @@
 ! initialisation sorties netcdf
 !
+#ifndef IO_DISCONNECTED
           idayref = day_ini
           CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
@@ -297,4 +303,5 @@
           CALL histend(nidbg)
           CALL histsync(nidbg)
+#endif
       ENDIF 
           
@@ -430,4 +437,5 @@
 c variables pour avoir une sortie IOIPSL des INDEX
 c
+#ifndef IO_DISCONNECTED
       IF (debugindex) THEN 
           tabindx(:)=0.
@@ -442,4 +450,8 @@
      $        ,ndexbg)
       ENDIF 
+#endif
+
+      fluxlat(:,nsrf) = 0.
+      
       IF (knon.EQ.0) GOTO 99999
       DO j = 1, knon
@@ -927,5 +939,5 @@
 
       USE interface_surf
-
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -934,5 +946,5 @@
 c======================================================================
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -1203,4 +1215,6 @@
       ccanopy = co2_ppm
 
+!      if (monocpu) then
+
       CALL interfsurf(itime, dtime, date0, jour, rmu0,
      e klon, iim, jjm, nisurf, knon, knindex, pctsrf, 
@@ -1222,4 +1236,10 @@
      s pctsrf_new, agesno,fqcalving,ffonte, run_off_lic_0)
 
+!      else
+        
+!	STOP 'clmain : interfsurf n est pas encore parallelise => abort'
+	
+!      endif
+      
 
       do i = 1, knon
@@ -1268,4 +1288,5 @@
      e                  paprs,pplay,delp,
      s                  d_ven,flux_v)
+      use dimphy
       IMPLICIT none
 c======================================================================
@@ -1290,6 +1311,6 @@
 c flux_v---output-R- (diagnostic) flux du vent: (kg m/s)/(m**2 s)
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "iniprint.h"
       INTEGER knon
@@ -1393,4 +1414,5 @@
      .                  qsurf, 
      .                  pcfm, pcfh)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1415,6 +1437,6 @@
 c pcfh-----output-R- coefficients a calculer (chaleur et humidite)
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "indicesol.h"
@@ -1462,5 +1484,5 @@
       PARAMETER (mixlen=35.0)
       INTEGER isommet ! le sommet de la couche limite
-      PARAMETER (isommet=klev)
+cym      PARAMETER (isommet=klev)
       LOGICAL tvirtu ! calculer Ri d'une maniere plus performante
       PARAMETER (tvirtu=.TRUE.)
@@ -1510,4 +1532,7 @@
       DATA appel1er /.TRUE./
 c
+cym
+      isommet=klev
+      
       IF (appel1er) THEN
         if (prt_level > 9) THEN
@@ -1713,4 +1738,5 @@
       SUBROUTINE coefkz2(nsrf, knon, paprs, pplay,t,
      .                  pcfm, pcfh)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1729,6 +1755,6 @@
 c pcfh-----output-R- coefficients a calculer (chaleur et humidite)
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "indicesol.h"
@@ -1816,4 +1842,5 @@
       SUBROUTINE calbeta(dtime,indice,knon,snow,qsol,
      .                    vbeta,vcal,vdif)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1824,6 +1851,6 @@
 c Calculer quelques parametres pour appliquer la couche limite
 c ------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "indicesol.h"
@@ -1893,4 +1920,5 @@
      .                    tsol,beta,u,v,t,q,
      .                    cd_h, cd_m, pcfh, pcfm, cgh, cgq)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1907,6 +1935,6 @@
 c model. J. of Climate, vol. 6, 1825-1842.
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "iniprint.h"
@@ -1927,5 +1955,5 @@
 c
       INTEGER isommet
-      PARAMETER (isommet=klev)
+cym      PARAMETER (isommet=klev)
       REAL vk
       PARAMETER (vk=0.40)
@@ -2003,4 +2031,7 @@
 c Initialisation
 c
+cym
+      isommet=klev
+
       DO i = 1, klon
          pcfh(i,1) = cd_h(i)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cltrac.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cltrac.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cltrac.F	(revision 634)
@@ -4,4 +4,5 @@
       SUBROUTINE cltrac(dtime,coef,t,tr,flux,paprs,pplay,delp,
      s                  d_tr)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -25,6 +26,6 @@
 c flux_tr--output-R- flux de tr
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
       REAL dtime
       REAL coef(klon,klev)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cltracrn.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cltracrn.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cltracrn.F	(revision 634)
@@ -9,4 +9,5 @@
      s              d_tr,d_trs )
 
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -42,6 +43,6 @@
 c d_trs----output-R- le changement de "trs"
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "indicesol.h"
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/coefkzmin.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/coefkzmin.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/coefkzmin.F	(revision 634)
@@ -5,8 +5,9 @@
      .   ,km,kn)
 c      SUBROUTINE coefkzmin(ngrid,zlev,teta,ustar,km,kn)
+      USE dimphy
       IMPLICIT NONE
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 
@@ -59,6 +60,6 @@
 
       integer nlay,nlev
-      PARAMETER (nlay=klev)
-      PARAMETER (nlev=klev+1)
+cym      PARAMETER (nlay=klev)
+cym      PARAMETER (nlev=klev+1)
 
       integer ig,k
@@ -71,5 +72,6 @@
       real fl,zzz,zl0,zq2,zn2
 
-
+      nlay=klev
+      nlev=klev+1
 c.......................................................................
 c  en attendant une version ou les zlev, et zlay soient
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conccm.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conccm.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conccm.F	(revision 634)
@@ -5,4 +5,5 @@
      s                   d_t, d_q, rain, snow, kbascm, ktopcm)
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -11,6 +12,6 @@
 c        (schema standard du modele NCAR CCM2)
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -143,4 +144,5 @@
      $                  tb, shb,
      $                  cmfprt, cmfprs, cnt, cnb)
+      USE dimphy
       IMPLICIT none
 C-----------------------------------------------------------------------
@@ -163,6 +165,6 @@
 c                    simplifier la lecture et la comprehension.
 C-----------------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
       INTEGER pcnst ! nombre de traceurs passifs
       PARAMETER (pcnst=1)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/concvl.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/concvl.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/concvl.F	(revision 634)
@@ -12,4 +12,5 @@
  
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -46,5 +47,5 @@
 c
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 c
       integer NTRAC
@@ -82,6 +83,7 @@
        INTEGER i,k,itra
        REAL qs(klon,klev)
-       REAL cbmf(klon)
-       SAVE cbmf
+cym       REAL cbmf(klon)
+cym       SAVE cbmf
+       REAL,ALLOCATABLE,SAVE :: cbmf(:)
        INTEGER ifrst
        SAVE ifrst
@@ -97,4 +99,5 @@
       IF (ifrst .EQ. 0) THEN
          ifrst = 1
+	 allocate(cbmf(klon))
          DO i = 1, klon
           cbmf(i) = 0.
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conema3.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conema3.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conema3.F	(revision 634)
@@ -9,4 +9,5 @@
      .             qcond_incld)
 
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -54,5 +55,5 @@
 c
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "conema3.h"
       INTEGER i, l,m,itra
@@ -84,19 +85,31 @@
       REAL qcond_incld(klon,klev)
 c
-      REAL em_t(klev)
-      REAL em_q(klev)
-      REAL em_qs(klev)
-      REAL em_u(klev), em_v(klev), em_tra(klev,ntrac)
-      REAL em_ph(klev+1), em_p(klev)
-      REAL em_work1(klev), em_work2(klev)
-      REAL em_precip, em_d_t(klev), em_d_q(klev)
-      REAL em_d_u(klev), em_d_v(klev), em_d_tra(klev,ntrac)
-      REAL em_upwd(klev), em_dnwd(klev), em_dnwdbis(klev)
+      LOGICAL,SAVE :: first=.true.
+cym      REAL em_t(klev)
+      REAL,ALLOCATABLE,SAVE :: em_t(:)
+cym      REAL em_q(klev)
+      REAL,ALLOCATABLE,SAVE :: em_q(:)
+cym      REAL em_qs(klev)
+      REAL,ALLOCATABLE,SAVE :: em_qs(:)  
+cym      REAL em_u(klev), em_v(klev), em_tra(klev,ntrac)
+      REAL,ALLOCATABLE,SAVE :: em_u(:),em_v(:),em_tra(:,:)
+cym      REAL em_ph(klev+1), em_p(klev)
+      REAL,ALLOCATABLE,SAVE ::em_ph(:),em_p(:)
+cym      REAL em_work1(klev), em_work2(klev)
+      REAL,ALLOCATABLE,SAVE ::em_work1(:),em_work2(:)
+cym      REAL em_precip, em_d_t(klev), em_d_q(klev)
+      REAL,SAVE :: em_precip
+      REAL,ALLOCATABLE,SAVE :: em_d_t(:),em_d_q(:)
+cym      REAL em_d_u(klev), em_d_v(klev), em_d_tra(klev,ntrac)
+      REAL,ALLOCATABLE,SAVE ::em_d_u(:),em_d_v(:),em_d_tra(:,:)
+cym      REAL em_upwd(klev), em_dnwd(klev), em_dnwdbis(klev)
+      REAL,ALLOCATABLE,SAVE :: em_upwd(:),em_dnwd(:),em_dnwdbis(:)
       REAL em_dtvpdt1(klev), em_dtvpdq1(klev)
       REAL em_dplcldt, em_dplcldr
-      SAVE em_t,em_q, em_qs, em_ph, em_p, em_work1, em_work2
-      SAVE em_u,em_v, em_tra
-      SAVE em_d_u,em_d_v, em_d_tra
-      SAVE em_precip, em_d_t, em_d_q, em_upwd, em_dnwd, em_dnwdbis
+cym      SAVE em_t,em_q, em_qs, em_ph, em_p, em_work1, em_work2
+cym      SAVE em_u,em_v, em_tra
+cym      SAVE em_d_u,em_d_v, em_d_tra
+cym      SAVE em_precip, em_d_t, em_d_q, em_upwd, em_dnwd, em_dnwdbis
+
       INTEGER em_bas, em_top
       SAVE em_bas, em_top
@@ -113,12 +126,15 @@
 cccccccccccccccccccccccccccccccccccccccccccccccccc
  
-      REAL emmip(klev) !variation de flux ascnon dilue i et i+1
-      SAVE emmip
-      real emMke(klev)
-      save emMke
+cym      REAL emmip(klev) !variation de flux ascnon dilue i et i+1
+      REAL,ALLOCATABLE,SAVE ::emmip(:)
+cym      SAVE emmip
+cym      real emMke(klev)
+      REAL,ALLOCATABLE,SAVE ::emMke(:)
+cym      save emMke
       real top
       real bas
-      real emMa(klev)
-      save emMa
+cym      real emMa(klev)
+      REAL,ALLOCATABLE,SAVE ::emMa(:)
+cym      save emMa
       real Ma(klon,klev)
       real Ment(klev,klev)
@@ -151,5 +167,23 @@
 #include "YOETHF.h"
 #include "FCTTRE.h"
- 
+     
+      if (first) then
+  
+        allocate(em_t(klev))
+        allocate(em_q(klev))
+        allocate(em_qs(klev))
+        allocate(em_u(klev), em_v(klev), em_tra(klev,ntrac))
+        allocate(em_ph(klev+1), em_p(klev))
+        allocate(em_work1(klev), em_work2(klev))
+        allocate(em_d_t(klev), em_d_q(klev))
+        allocate(em_d_u(klev), em_d_v(klev), em_d_tra(klev,ntrac))
+        allocate(em_upwd(klev), em_dnwd(klev), em_dnwdbis(klev))
+        allocate(emmip(klev)) 
+	allocate(emMke(klev))
+        allocate(emMa(klev))
+  
+        first=.false.
+      endif
+  
       qcond_incld(:,:) = 0.
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conemav.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conemav.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conemav.F	(revision 634)
@@ -9,4 +9,5 @@
  
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -43,5 +44,5 @@
 c
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 c
       integer NTRAC
@@ -73,6 +74,7 @@
        INTEGER i,k,itra
        REAL qs(klon,klev)
-       REAL cbmf(klon)
-       SAVE cbmf
+cym       REAL cbmf(klon)
+cym       SAVE cbmf
+       REAL,ALLOCATABLE,SAVE :: cbmf(:)
        INTEGER ifrst
        SAVE ifrst
@@ -85,4 +87,5 @@
       IF (ifrst .EQ. 0) THEN
          ifrst = 1
+	 allocate(cbmf(klon))
          DO i = 1, klon
           cbmf(i) = 0.
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conflx.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conflx.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conflx.F	(revision 634)
@@ -8,4 +8,5 @@
      s                   kcbot, kctop, kdtop, pmflxr, pmflxs)
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -17,6 +18,6 @@
 c         et lessivage des traceurs passifs.
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -214,8 +215,9 @@
      .                   pmfu, pmfd, pen_u, pde_u, pen_d, pde_d,
      .                   dt_con, dq_con, pmflxr, pmflxs)
+      USE dimphy
       IMPLICIT none
 C     ------------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -504,4 +506,5 @@
      .           pdmfdp, pmfu, pmfus, pmfuq, pdmfup, pdpmel, plu, plude,
      .           klab,pen_u, pde_u, pen_d, pde_d)
+      USE dimphy
       IMPLICIT none
 C----------------------------------------------------------------------
@@ -510,6 +513,6 @@
 C AND INITIALIZES VALUES FOR UPDRAFTS
 C----------------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -629,4 +632,5 @@
       SUBROUTINE flxbase(ptenh, pqenh, pgeoh, paph,
      *     ptu, pqu, plu, ldcum, kcbot, klab)
+      USE dimphy
       IMPLICIT none
 C----------------------------------------------------------------------
@@ -641,6 +645,6 @@
 C (NON ENTRAINING PLUME,I.E.CONSTANT MASSFLUX)
 C----------------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -714,4 +718,5 @@
      .     pmful, plude, pdmfup, kcbot, kctop, kctop0, kcum,
      .     pen_u, pde_u)
+      USE dimphy
       IMPLICIT none
 C----------------------------------------------------------------------
@@ -719,6 +724,6 @@
 C FOR CUMULUS PARAMETERIZATION
 C----------------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -1018,4 +1023,5 @@
      .  ,  pten, prfl, psfl, pdpmel, ktopm2
      .  ,  pmflxr, pmflxs)
+      USE dimphy
       IMPLICIT none
 C----------------------------------------------------------------------
@@ -1023,6 +1029,6 @@
 C FLUXES IN THE CLOUD LAYER AND IN THE SUBCLOUD LAYER
 C----------------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -1262,10 +1268,11 @@
      .  ,  pmfus, pmfds, pmfuq, pmfdq, pmful, pdmfup, pdmfdp
      .  ,  pdpmel, dt_con, dq_con)
+      USE dimphy
       IMPLICIT none
 c----------------------------------------------------------------------
 c calculer les tendances T et Q
 c----------------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -1333,4 +1340,5 @@
      .     ldcum, kcbot, kctop, pmfub, prfl, ptd, pqd,
      .     pmfd, pmfds, pmfdq, pdmfdp, kdtop, lddraf)
+      USE dimphy
       IMPLICIT none
 C
@@ -1350,6 +1358,6 @@
 C MOIST ENVIRONMENTAL AIR AND CLOUD AIR.
 C----------------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -1444,4 +1452,5 @@
      .           ptd, pqd, pmfd, pmfds, pmfdq, pdmfdp,
      .           lddraf, pen_d, pde_d)
+      USE dimphy
       IMPLICIT none
 C
@@ -1461,6 +1470,6 @@
 C
 C----------------------------------------------------------------------
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -1559,4 +1568,5 @@
       END
       SUBROUTINE flxadjtq(pp, pt, pq, ldflag, kcall)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1568,6 +1578,6 @@
 C        kcall=2  EVAPORATION IN DOWNDRAFTS (E.G. CUDLFS,CUDDRAF)
 C
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 C
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conlmd.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conlmd.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/conlmd.F	(revision 634)
@@ -4,4 +4,5 @@
       SUBROUTINE conlmd (dtime, paprs, pplay, t, q, conv_q,
      s                   d_t, d_q, rain, snow, ibas, itop)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -10,6 +11,6 @@
 c        Ajustement humide (Manabe) + Ajustement convectif (Kuo)
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -93,4 +94,5 @@
      s                   d_t, d_q, d_ql, rneb,
      s                   rain, snow, ibas, itop)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -105,6 +107,6 @@
 c du modele.
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
@@ -301,4 +303,5 @@
      s                    d_t, d_q, d_ql, rneb,
      s                    rain, snow, ibas, itop,accompli,imprim)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -309,6 +312,6 @@
 c        et itop est le haut du plus haut bloc
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
@@ -1064,4 +1067,5 @@
      s                  d_t, d_q, d_ql, rneb, 
      s                  rain, snow, ibas, itop)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1071,6 +1075,6 @@
 c N.B. version vectorielle (le 6 oct. 1997)
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
@@ -1587,4 +1591,5 @@
       END
       SUBROUTINE kuofcl(pt, pq, pg, pp, LDCUM, kcbot)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1603,6 +1608,6 @@
 c kcbot---output-I- Niveau du bas de la convection
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -1688,4 +1693,5 @@
       END
       SUBROUTINE adjtq(pp, pt, pq, LDFLAG, KCALL)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1706,6 +1712,6 @@
 C        KCALL=2  EVAPORATION IN DOWNDRAFTS (E.G. CUDLFS,CUDDRAF)
 C
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 C
@@ -1797,10 +1803,11 @@
      .                 d_t, d_q, d_ql, rneb,
      .                 rain, snow, ibas, itop)
+      USE dimphy
       IMPLICIT NONE
 c
 c Ajustement humide (Schema de convection de Manabe)
 C.
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
@@ -2095,8 +2102,9 @@
      .                 d_t, d_q, d_ql,rneb,
      .                 rain, snow, ibas, itop)
+      USE dimphy
       IMPLICIT NONE
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/convect1.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/convect1.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/convect1.F	(revision 634)
@@ -107,8 +107,9 @@
 c
 c
+       USE dimphy
       implicit none
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 c
       integer len
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/convect2.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/convect2.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/convect2.F	(revision 634)
@@ -148,8 +148,9 @@
 c
 c
+      USE dimphy
       implicit none
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 c
       integer kmax2,imax2,kmin2,imin2
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/convect3.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/convect3.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/convect3.F	(revision 634)
@@ -18,6 +18,8 @@
 cFleur       Introduction des traceurs dans convect3 le 6 juin 200
 c#################################################################
+      USE dimphy
+
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
       PARAMETER (NA=60)
 
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cv_driver.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cv_driver.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cv_driver.F	(revision 634)
@@ -11,4 +11,5 @@
      &                   da1,phi1,mp1)
 C
+      USE dimphy
       implicit none
 C
@@ -64,6 +65,6 @@
 c
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       integer len
@@ -250,7 +251,7 @@
 c (local) compressed fields:
 c
-      integer nloc
-      parameter (nloc=klon) ! pour l'instant
-
+cym      integer nloc
+cym      parameter (nloc=klon) ! pour l'instant
+#define nloc klon
       integer idcum(nloc)
       integer iflag(nloc),nk(nloc),icb(nloc)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cvltr.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cvltr.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/cvltr.F	(revision 634)
@@ -3,4 +3,5 @@
 c
       SUBROUTINE cvltr(pdtime,da, phi, mp,paprs,pplay,x,upd,dnd,dx)
+      USE dimphy
       IMPLICIT NONE 
 c=====================================================================
@@ -9,6 +10,8 @@
 c=====================================================================
 c
-#include "dimensions.h"
-#include "dimphy.h"
+
+
+clf#include "dimensions.h"
+clf#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOECUMF.h" 
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/fisrtilp.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/fisrtilp.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/fisrtilp.F	(revision 634)
@@ -10,4 +10,5 @@
 
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -18,6 +19,6 @@
 c======================================================================
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "tracstoke.h"
@@ -110,5 +111,5 @@
       REAL zlh_solid(klon), zm_solid
 cIM 
-      INTEGER klevm1
+cym      INTEGER klevm1
 c---------------------------------------------------------------
 c
@@ -210,5 +211,5 @@
 c
 cIM : klevm1
-      klevm1=klev-1
+cym      klevm1=klev-1
       DO 9999 k = klev, 1, -1
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/fisrtilp_tr.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/fisrtilp_tr.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/fisrtilp_tr.F	(revision 634)
@@ -11,4 +11,5 @@
 
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -19,6 +20,6 @@
 c======================================================================
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "tracstoke.h"
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/flxtr.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/flxtr.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/flxtr.F	(revision 634)
@@ -4,4 +4,5 @@
       SUBROUTINE flxtr(pdtime,pmfu,pmfd,pen_u,pde_u,pen_d,pde_d,
      .                 pt,pplay,paprs,kcbot,kctop,kdtop,x,dx) 
+      USE dimphy
       IMPLICIT NONE 
 c=====================================================================
@@ -24,6 +25,6 @@
 c=====================================================================
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOECUMF.h" 
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/hgardfou.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/hgardfou.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/hgardfou.F	(revision 634)
@@ -3,10 +3,11 @@
 !
       SUBROUTINE hgardfou (t,tsol,text)
+      use dimphy
       IMPLICIT none
 c======================================================================
 c Verifier la temperature
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "indicesol.h"
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/histo_o500_pctau.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/histo_o500_pctau.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/histo_o500_pctau.F	(revision 634)
@@ -3,10 +3,11 @@
 !
       SUBROUTINE histo_o500_pctau(nbreg,pct_ocean,w,histo,histoW,nhisto)
+      USE dimphy
       IMPLICIT none
 
       INTEGER :: ij, k, l, nw
       INTEGER :: nreg, nbreg
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
       INTEGER, PARAMETER :: kmax=8, lmax=8
       INTEGER, PARAMETER :: kmaxm1=kmax-1, lmaxm1=lmax-1
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/homogene.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/homogene.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/homogene.F	(revision 634)
@@ -3,4 +3,5 @@
 !
       SUBROUTINE homogene(paprs, q, dq, u,v, du, dv)
+      USE dimphy
       IMPLICIT NONE
 c==============================================================
@@ -17,6 +18,6 @@
 c dv:   output, incrementation pour v
 c==============================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 c
       REAL paprs(klon,klev+1)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/hydrol.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/hydrol.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/hydrol.F	(revision 634)
@@ -6,4 +6,5 @@
       SUBROUTINE hydrol(dtime,pctsrf,rain_fall,snow_fall,evap,
      .                  agesno, tsol,qsol,snow,runoff)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -22,6 +23,6 @@
 c snow: couverture neigeuse
 C
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "indicesol.h"
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histISCCP.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histISCCP.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histISCCP.h	(revision 634)
@@ -32,15 +32,18 @@
 c definition coordonnees lon,lat en globale
 c
-        CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-        DO i = 1, iim
-          zx_lon(i,1) = rlon(i+1)
-          zx_lon(i,jjmp1) = rlon(i+1)
-        ENDDO
+cym        CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
+cym        DO i = 1, iim
+cym          zx_lon(i,1) = rlon(i+1)
+cym          zx_lon(i,jjmp1) = rlon(i+1)
+cym        ENDDO
 
-        CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
+cym        CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
 c
-         CALL histbeg("histISCCP.nc", iim,zx_lon(:,1),jjmp1,zx_lat(1,:),
-     .                 1, iim, 1, jjmp1,
-     .                 itau_phy, zjulian, dtime,
+cym         CALL histbeg("histISCCP.nc", iim,zx_lon(:,1),jjmp1,zx_lat(1,:),
+cym     .                 1, iim, 1, jjmp1,
+cym     .                 itau_phy, zjulian, dtime,
+cym     .                 nhori, nid_isccp)
+
+         CALL histbeg_phy("histISCCP.nc", itau_phy, zjulian, dtime,
      .                 nhori, nid_isccp)
 c
@@ -53,5 +56,5 @@
           CALL histdef(nid_isccp, "cldISCCP_"//taulev(k),
      .                "LMDZ ISCCP cld", "%",
-     .                iim, jjmp1,nhori,lmaxm1,1,lmaxm1,nvert,32,
+     .                iim, jjphy_nb,nhori,lmaxm1,1,lmaxm1,nvert,32,
      .                "ave(X)", zsto,zout)
          ENDDO
@@ -59,5 +62,5 @@
          CALL histdef(nid_isccp, "nsunlit",
      .                "Nb of calls with sunlit ", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zsto,zout)
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histREGDYN.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histREGDYN.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histREGDYN.h	(revision 634)
@@ -4,4 +4,6 @@
 
       IF (ok_regdyn) THEN
+      
+        if (monocpu) then
 c
          PRINT*, 'La frequence de sortie REGDYN est de ', ecrit_mth
@@ -117,4 +119,6 @@
 c
          CALL histend(nid_regdyn)
+	 
+	 endif ! monocpu
 
       endif ! ok_regdyn
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histday.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histday.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histday.h	(revision 634)
@@ -13,16 +13,20 @@
          CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
 c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlon(i+1)
-            zx_lon(i,jjmp1) = rlon(i+1)
-         ENDDO
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
+cym         DO i = 1, iim
+cym            zx_lon(i,1) = rlon(i+1)
+cym            zx_lon(i,jjmp1) = rlon(i+1)
+cym         ENDDO
          DO ll=1,klev
             znivsig(ll)=float(ll)
          ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
-         CALL histbeg("histday", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
-     .                 nhori, nid_day)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
+cym         CALL histbeg("histday", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
+cym     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
+cym     .                 nhori, nid_day)
+
+         CALL histbeg_phy("histday",itau_phy, zjulian, dtime, 
+     .                    nhori, nid_day)
+
          write(*,*)'Journee ', itau_phy, zjulian
          CALL histvert(nid_day, "presnivs", "Vertical levels", "mb",
@@ -32,17 +36,17 @@
 c
          CALL histdef(nid_day, "phis", "Surface geop. height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "once", zsto,zout)
 c
          CALL histdef(nid_day, "aire", "Grid area", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "once", zsto,zout)
 c
          CALL histdef(nid_day, "contfracATM","% sfce ter+lic ","-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "once", zsto,zout)
 c
          CALL histdef(nid_day, "contfracOR","% sfce terre OR", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "once", zsto,zout)
 c
@@ -50,9 +54,9 @@
 c
          CALL histdef(nid_day, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "t2m", "Temperature 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -62,25 +66,25 @@
          CALL histdef(nid_day, "t2m_min", "Temp. 2m min.",
      .                "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                t2mincels, zsto,zout)
 c
          CALL histdef(nid_day, "t2m_max", "Temp. 2m max.",
      .                "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                t2maxcels, zsto,zout)
 c
          CALL histdef(nid_day, "plul", "Large-scale Precip.",
      .   "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "pluc", "Convective Precip.",
      .   "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "snowl", "Solid Large-scale Precip.",
      .   "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -88,98 +92,98 @@
          CALL histdef(nid_day, "snowc", "Solid Convective Precip.",
      .   "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
          ENDIF !snowc=0.
 c
          CALL histdef(nid_day, "flat", "Latent heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "sicf", "Sea-ice fraction", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto1,zout)
 c
          CALL histdef(nid_day, "q2m", "Specific humidity", "kg/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "u10m", "Vent zonal 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "v10m", "Vent meridien 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "wind10m","10-m wind speed","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "wind10max", "10-m wind speed max.",
      .                "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                t2maxcels, zsto,zout)
 c
          CALL histdef(nid_day, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "precip","Precipitation Totale liq+sol"
      .                , "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "snowf", "Snow fall", "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "snow_mass", "Snow Mass", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "evap", "Evaporation", "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "tops", "Solar rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "topl", "IR rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "sols", "Net Solar rad. at surf.", 
      .                "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "soll", "Net IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "cldl", "Low-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "cldm", "Mid-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "cldh", "High-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "cldt", "Total cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "cldq", "Cloud liquid water path", 
      .                "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "prw", "Precipitable water", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -189,10 +193,10 @@
           CALL histdef(nid_day, "u"//clev(k),
      .                 "Zonal wind"//clev(k)//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
           CALL histdef(nid_day, "v"//clev(k),
      .                 "Meridional wind"//clev(k)//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -200,30 +204,30 @@
 c
          CALL histdef(nid_day, "w500", "Verical wind 500mb", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day,"phi500", "Geopotentiel a 500mb","m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "slp", "Sea Level Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "cape_max", "CAPE max.",
      .                "J/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                capemaxcels, zsto,zout)
 c
          CALL histdef(nid_day, "solldown", "Down. IR rad. at surface", 
-     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                "W/m2", iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "sens", "Sensible heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "SWdnSFC", "SWdn at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto,zout)
 c
@@ -233,9 +237,9 @@
 c
          CALL histdef(nid_day, "bils", "Surf. total heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "fder", "Heat flux derivation", "W/m2/K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
@@ -251,29 +255,29 @@
 c
          CALL histdef(nid_day, "temp", "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "ovap", "Specific humidity", "kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "geop", "Geopotential height", "m",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "vitv", "Meridional wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "vitw", "Vertical wind", "Pa/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "pres", "Air pressure", "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -291,33 +295,33 @@
 c
          CALL histdef(nid_day, "SWupTOA", "SWup at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "SWupSFC", "SWup at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "SWdnTOA", "SWdn at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "SWupTOAclr",
      .                "SWup clear sky at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto,zout)
 
          CALL histdef(nid_day, "SWupSFCclr",
      .                "SWup clear sky at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto,zout)
 
          CALL histdef(nid_day, "SWdnTOAclr",
      .                "SWdn clear sky at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto,zout)
 
          CALL histdef(nid_day, "SWdnSFCclr",
      .                "SWdn clear sky at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto,zout)
 c
@@ -329,75 +333,75 @@
 c
          CALL histdef(nid_day, "tter", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "tlic", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "toce", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "tsic", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "t2mter", "Temp.terre 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "t2mlic", "Temp.lic 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "t2moce", "Temp.oce 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "t2msic", "Temp.sic 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "t2mter_min", "Temp.terre 2m min.",
      .                "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                t2mincels, zsto,zout)
 c
          CALL histdef(nid_day, "t2mter_max", "Temp.terre 2m max.",
      .                "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                t2maxcels, zsto,zout)
 c
          CALL histdef(nid_day, "u10mter", "Vent zonal ter 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "u10mlic", "Vent zonal lic 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "u10moce", "Vent zonal oce 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "u10msic", "Vent zonal sic 10m",
-     .                 "m/s",iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                 "m/s",iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "v10mter", "Vent meridien ter 10m", 
-     .                "m/s", iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "m/s", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "v10mlic", "Vent meridien lic 10m",
-     .                 "m/s",iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                 "m/s",iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "v10moce", "Vent meridien oce 10m",
-     .                 "m/s",iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                 "m/s",iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_day, "v10msic", "Vent meridien sic 10m",
-     .                 "m/s",iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                 "m/s",iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -406,40 +410,40 @@
            call histdef(nid_day, "pourc_"//clnsurf(nsrf), 
      $         "Fraction"//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 C
            call histdef(nid_day, "tsol_"//clnsurf(nsrf), 
      $         "Fraction"//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 C
            call histdef(nid_day, "sens_"//clnsurf(nsrf), 
      $         "Sensible heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 c
            call histdef(nid_day, "lat_"//clnsurf(nsrf), 
      $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 C
            call histdef(nid_day, "taux_"//clnsurf(nsrf), 
      $         "Zonal wind stress"//clnsurf(nsrf),"Pa",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 
            call histdef(nid_day, "tauy_"//clnsurf(nsrf), 
      $         "Meridional xind stress "//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 C
            call histdef(nid_day, "albe_"//clnsurf(nsrf), 
      $         "Albedo surf. "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 C
            call histdef(nid_day, "rugs_"//clnsurf(nsrf), 
      $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 C
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histhf.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histhf.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histhf.h	(revision 634)
@@ -14,15 +14,18 @@
 
 c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlon(i+1)
-            zx_lon(i,jjmp1) = rlon(i+1)
-         ENDDO
-
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
+cym         DO i = 1, iim
+cym            zx_lon(i,1) = rlon(i+1)
+cym            zx_lon(i,jjmp1) = rlon(i+1)
+cym         ENDDO
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
 
 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, 
+cym         CALL histbeg("histhf", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
+cym     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
+cym     .                 nhori, nid_hf)
+
+         CALL histbeg_phy("histhf", itau_phy, zjulian, dtime, 
      .                 nhori, nid_hf)
 
@@ -42,13 +45,13 @@
 c
          CALL histdef(nid_hf, "aireTER","Grid area CONT","-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,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,
+     .                iim,jjphy_nb,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,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "once", zsto,zout)
 c
@@ -56,13 +59,13 @@
 c
          CALL histdef(nid_hf, "t2m", "Temperature 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,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,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_hf, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
@@ -70,5 +73,5 @@
 
          CALL histdef(nid_hf, "rain", "Precipitation", "kg/m^2s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto1,zout)
 c
@@ -76,22 +79,22 @@
 c
          CALL histdef(nid_hf, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,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,
+     .                iim,jjphy_nb,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,
+     .                iim,jjphy_nb,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,
+     .                iim,jjphy_nb,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,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
@@ -100,5 +103,5 @@
           CALL histdef(nid_hf, "phi"//clev(k),
      .                "Geopotential"//clev(k)//"mb", "m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
           ENDIF !clev(k).EQ."500"
@@ -110,5 +113,5 @@
 c
          CALL histdef(nid_hf, "cldt", "Total cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto1,zout)
 c
@@ -116,10 +119,10 @@
          CALL histdef(nid_hf, "SWdownOR",
      .                "Sfce incident SW down radiation OR", "W/m^2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto1,zout)
 c
          CALL histdef(nid_hf, "SWnetOR",
      .                "Sfce incident SW net radiation OR", "W/m^2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto1,zout)
 c -- LOOP
@@ -127,5 +130,5 @@
          CALL histdef(nid_hf, "LWdownOR",
      .                "Sfce incident LW radiation OR", "W/m^2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto1,zout)
       ENDIF !lev_histhf.GE.2
@@ -139,5 +142,5 @@
           CALL histdef(nid_hf, "t"//clev(k),
      .                 "Temperature"//clev(k)//"mb","K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
@@ -145,5 +148,5 @@
           CALL histdef(nid_hf, "phi"//clev(k), 
      .                "Geopotential"//clev(k)//"mb", "m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
           ENDIF
@@ -151,5 +154,5 @@
           CALL histdef(nid_hf, "q"//clev(k),
      .                 "Specific humidity"//clev(k)//"mb","kg/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
@@ -157,5 +160,5 @@
          CALL histdef(nid_hf, "rh"//clev(k),
      .                 "Relative humidity"//clev(k)//"mb", "%",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
          ENDIF
@@ -163,10 +166,10 @@
           CALL histdef(nid_hf, "u"//clev(k),
      .                 "Zonal wind"//clev(k)//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,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,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
@@ -174,9 +177,9 @@
          IF(1.EQ.0) THEN
          CALL histdef(nid_hf, "cdrm", " Momentum drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,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,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
          ENDIF !(1.EQ.0) THEN
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histhf3d.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histhf3d.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histhf3d.h	(revision 634)
@@ -20,15 +20,17 @@
 
 c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlon(i+1)
-            zx_lon(i,jjmp1) = rlon(i+1)
-         ENDDO
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
+cym         DO i = 1, iim
+cym            zx_lon(i,1) = rlon(i+1)
+cym            zx_lon(i,jjmp1) = rlon(i+1)
+cym         ENDDO
 
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
 
 cccIM      CALL histbeg("histhf", iim,zx_lon, jjmp1,zx_lat,
-         CALL histbeg("histhf3d", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
+cym         CALL histbeg("histhf3d", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
+cym     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
+cym     .                 nhori, nid_hf3d)
+         CALL histbeg_phy("histhf3d", itau_phy, zjulian, dtime, 
      .                 nhori, nid_hf3d)
 
@@ -42,17 +44,17 @@
 c
          CALL histdef(nid_hf3d, "temp", "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_hf3d, "ovap", "Specific humidity", "kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_hf3d, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_hf3d, "vitv", "Meridional wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histins.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histins.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histins.h	(revision 634)
@@ -10,15 +10,17 @@
          CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
 c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlon(i+1)
-            zx_lon(i,jjmp1) = rlon(i+1)
-         ENDDO
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
+cym         DO i = 1, iim
+cym            zx_lon(i,1) = rlon(i+1)
+cym            zx_lon(i,jjmp1) = rlon(i+1)
+cym         ENDDO
          DO ll=1,klev
             znivsig(ll)=float(ll)
          ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
-         CALL histbeg("histins", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime,
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
+cym         CALL histbeg("histins", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
+cym     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime,
+cym     .                 nhori, nid_ins)
+         CALL histbeg_phy("histins", itau_phy, zjulian, dtime,
      .                 nhori, nid_ins)
          write(*,*)'Inst ', itau_phy, zjulian
@@ -30,9 +32,9 @@
 c
          CALL histdef(nid_ins, "phis", "Surface geop. height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "once", zsto,zout)
 c
          CALL histdef(nid_ins, "aire", "Grid area", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "once", zsto,zout)
 c
@@ -40,102 +42,102 @@
 c
         CALL histdef(nid_ins, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "t2m", "Temperature 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "q2m", "Specific humidity 2m", "Kg/Kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "u10m", "Vent zonal 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "v10m", "Vent meridien 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
         CALL histdef(nid_ins, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "plul", "Large-scale Precip.", "mm/day",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "pluc", "Convective Precip.", "mm/day",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "cdrm", "Momentum drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "cdrh", "Heat drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "precip", "Precipitation Totale liq+sol", 
      .                "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "snow", "Snow fall", "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "snow_mass", "Snow Mass", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "topl", "OLR", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "evap", "Evaporation", "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "sols", "Solar rad. at surf.", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "soll", "IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "solldown", "Down. IR rad. at surface", 
-     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                "W/m2", iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "bils", "Surf. total heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "sens", "Sensible heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "fder", "Heat flux derivation", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
       CALL histdef(nid_ins, "dtsvdfo", "Boundary-layer dTs(o)", "K/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
       CALL histdef(nid_ins, "dtsvdft", "Boundary-layer dTs(t)", "K/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
       CALL histdef(nid_ins, "dtsvdfg", "Boundary-layer dTs(g)", "K/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
       CALL histdef(nid_ins, "dtsvdfi", "Boundary-layer dTs(g)", "K/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 
@@ -144,53 +146,53 @@
            call histdef(nid_ins, "pourc_"//clnsurf(nsrf), 
      $         "Fraction"//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "inst(X)", zsto,zout)
 
            call histdef(nid_ins, "sens_"//clnsurf(nsrf), 
      $         "Sensible heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "inst(X)", zsto,zout)
 c
            call histdef(nid_ins, "tsol_"//clnsurf(nsrf), 
      $         "Surface Temperature"//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "inst(X)", zsto,zout)
 c
            call histdef(nid_ins, "lat_"//clnsurf(nsrf), 
      $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "inst(X)", zsto,zout)
 C
            call histdef(nid_ins, "taux_"//clnsurf(nsrf), 
      $         "Zonal wind stress"//clnsurf(nsrf),"Pa",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "inst(X)", zsto,zout)
 
            call histdef(nid_ins, "tauy_"//clnsurf(nsrf), 
      $         "Meridional xind stress "//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "inst(X)", zsto,zout)
 c
            call histdef(nid_ins, "albe_"//clnsurf(nsrf), 
      $         "Albedo "//clnsurf(nsrf), "-",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "inst(X)", zsto,zout)
 c
            call histdef(nid_ins, "rugs_"//clnsurf(nsrf), 
      $         "rugosite "//clnsurf(nsrf), "-",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "inst(X)", zsto,zout)
 CXXX
          END DO 
          CALL histdef(nid_ins, "rugs", "rugosity", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 
 c
          CALL histdef(nid_ins, "albs", "Surface albedo", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
          CALL histdef(nid_ins, "albslw", "Surface albedo LW", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto,zout)
 c
@@ -199,29 +201,29 @@
 c
          CALL histdef(nid_ins, "temp", "Temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "vitv", "Merid wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "geop", "Geopotential height", "m",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "pres", "Air pressure", "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "dtvdf", "Boundary-layer dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "inst(X)", zsto,zout)
 c
          CALL histdef(nid_ins, "dqvdf", "Boundary-layer dQ", "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "inst(X)", zsto,zout)
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histmth.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histmth.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histmth.h	(revision 634)
@@ -16,17 +16,21 @@
          CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
 c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlon(i+1)
-            zx_lon(i,jjmp1) = rlon(i+1)
-         ENDDO
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
+cym         DO i = 1, iim
+cym            zx_lon(i,1) = rlon(i+1)
+cym            zx_lon(i,jjmp1) = rlon(i+1)
+cym         ENDDO
          DO ll=1,klev
             znivsig(ll)=float(ll)
          ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
-         CALL histbeg("histmth.nc", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
+cym         CALL histbeg("histmth.nc", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
+cym     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
+cym     .                 nhori, nid_mth)
+
+           CALL histbeg_phy("histmth.nc",itau_phy, zjulian, dtime, 
      .                 nhori, nid_mth)
-         write(*,*)'Mensuel ', itau_phy, zjulian
+     
+       write(*,*)'Mensuel ', itau_phy, zjulian
          CALL histvert(nid_mth, "presnivs", "Vertical levels", "mb",
      .                 klev, presnivs, nvert)
@@ -37,14 +41,14 @@
       IF(lev_histmth.GE.1) THEN
          CALL histdef(nid_mth, "phis", "Surface geop. height", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "once",  zsto,zout)
 c
          CALL histdef(nid_mth, "aire", "Grid area", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "once",  zsto,zout)
 c
            call histdef(nid_mth, "pourc_"//clnsurf(is_ter), 
      $         "Fraction "//clnsurf(is_ter), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "once", zsto,zout)
 c
@@ -52,36 +56,36 @@
 c
          CALL histdef(nid_mth, "slp", "Sea Level Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "tsol", "Surface Temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "t2m", "Temperature 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c ENSEMBLES BEG
          CALL histdef(nid_mth, "t2m_min", "Temp. 2m min.",
      .                "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                t2mincels, zsto,zout)
 c
          CALL histdef(nid_mth, "t2m_max", "Temp. 2m max.",
      .                "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                t2maxcels, zsto,zout)
 c
 c        CALL histdef(nid_mth, "tsoil", "Sfce soil Temperature",
 c    .                "K",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+c    .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
 c    .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "wind10m","10-m wind speed","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "sicf", "Sea-ice fraction", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 
@@ -89,26 +93,26 @@
 c ENSEMBLES END
          CALL histdef(nid_mth, "q2m", "Specific humidity 2m", "kg/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "u10m", "Vent zonal 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "v10m", "Vent meridien 10m", "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "psol", "Surface Pressure", "Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "qsurf", "Surface Air humidity", "kg/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
       if (.not. ok_veget) then
          CALL histdef(nid_mth, "qsol", "Soil watter content", "mm",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
       endif
@@ -116,166 +120,166 @@
          CALL histdef(nid_mth, "ndayrain", 
      .                "Number of day with rain (liq+sol)", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "inst(X)", zsto1,zout)
 c
          CALL histdef(nid_mth, "precip", "Precipitation Totale liq+sol", 
      .                "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "plul", "Large-scale Precip.", 
      .   "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "pluc", "Convective Precip.", 
      .   "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "snow", "Snow fall", "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "snow_mass", "Snow Mass", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "evap", "Evaporation", "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "tops", "Solar rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "tops0", "Solar rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "topl", "IR rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "topl0", "IR rad. at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "SWupTOA", "SWup at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWupTOAclr", 
      .                "SWup clear sky at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWdnTOA", "SWdn at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWdnTOAclr", 
      .                "SWdn clear sky at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWup200", "SWup at 200hPa","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWup200clr", 
      .                "SWup clear sky at 200hPa","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWdn200", "SWdn at 200hPa","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWdn200clr", 
      .                "SWdn clear sky at 200hPa","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "LWup200", "LWup at 200hPa","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "LWup200clr", 
      .                "LWup clear sky at 200hPa","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "LWdn200", "LWdn at 200hPa","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "LWdn200clr", 
      .                "LWdn clear sky at 200hPa","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "sols", "Solar rad. at surf.", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "sols0", "Solar rad. at surf.", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "soll", "IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "soll0", "IR rad. at surface", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "SWupSFC", "SWup at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWupSFCclr", 
      .                "SWup clear sky at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWdnSFC", "SWdn at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "SWdnSFCclr", 
      .                "SWdn clear sky at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth,"LWupSFC","Upwd. IR rad. at surface", 
-     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                "W/m2", iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth,"LWdnSFC","Down. IR rad. at surface", 
-     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                "W/m2", iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth,"LWupSFCclr",
      .                "CS Upwd. IR rad. at surface", 
-     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                "W/m2", iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth,"LWdnSFCclr",
      .                "Down. CS IR rad. at surface", 
-     .                "W/m2", iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                "W/m2", iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto2,zout)
 c
          CALL histdef(nid_mth, "bils", "Surf. total heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "sens", "Sensible heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "fder", "Heat flux derivation", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
@@ -284,17 +288,17 @@
 c     IF (ok_ade.OR.ok_aie) THEN
          CALL histdef(nid_mth, "topsad", "ADE at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "solsad", "ADE at sfc", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "topsai", "AIE at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "solsai", "AIE at sfc", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c     endif
@@ -303,17 +307,17 @@
 c
 c          CALL histdef(nid_mth, "frtu", "Zonal wind stress", "Pa",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
 c    .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "frtv", "Meridional wind stress", "Pa",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
 c    .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "ffonte","Thermal flux for snow melting",
-     .                "W/m2",iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "W/m2",iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "fqcalving","Ice Calving",
-     .                "kg/m2/s",iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                "kg/m2/s",iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 cIM: 171003
@@ -321,10 +325,10 @@
            call histdef(nid_mth, "taux_"//clnsurf(nsrf), 
      $         "Zonal wind stress"//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 
            call histdef(nid_mth, "tauy_"//clnsurf(nsrf), 
      $         "Meridional xind stress "//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
          ENDDO
@@ -336,5 +340,5 @@
            call histdef(nid_mth, "pourc_"//clnsurf(nsrf), 
      $         "Fraction "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
           ENDIF !nsrf.GT.1
@@ -342,30 +346,30 @@
            call histdef(nid_mth, "tsol_"//clnsurf(nsrf), 
      $         "Fraction "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 C
            call histdef(nid_mth, "sens_"//clnsurf(nsrf), 
      $         "Sensible heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 c
            call histdef(nid_mth, "lat_"//clnsurf(nsrf), 
      $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 C
            call histdef(nid_mth, "flw_"//clnsurf(nsrf),
      $         "LW "//clnsurf(nsrf), "W/m2",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto2,zout)
 c
            call histdef(nid_mth, "fsw_"//clnsurf(nsrf),
      $         "SW "//clnsurf(nsrf), "W/m2",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto2,zout)
 C
            call histdef(nid_mth, "wbils_"//clnsurf(nsrf),
      $         "Bilan sol "//clnsurf(nsrf), "W/m2",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 C
@@ -373,54 +377,54 @@
 c
          CALL histdef(nid_mth, "cdrm", "Momentum drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "cdrh", "Heat drag coef.", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "cldl", "Low-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "cldm", "Mid-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "cldh", "High-level cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "cldt", "Total cloudiness", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth,"cldq","Cloud liquid water path","kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 cIM: 071003
          CALL histdef(nid_mth,"lwp","Cloud water path","kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth,"iwp","Cloud ice water path","kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 cIM: 071003
 c
          CALL histdef(nid_mth, "ue", "Zonal energy transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "ve", "Merid energy transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "uq", "Zonal humidity transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "vq", "Merid humidity transport", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 cKE43
@@ -428,17 +432,17 @@
 c
          CALL histdef(nid_mth, "cape", "Conv avlbl pot ener", "J/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "pbase", "Cld base pressure", "hPa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "ptop", "Cld top pressure", "hPa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "fbase", "Cld base mass flux", "kg/m2/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -446,5 +450,5 @@
 c
          CALL histdef(nid_mth, "prw", "Precipitable water", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -455,20 +459,20 @@
           CALL histdef(nid_mth, "u"//clev(k),
      .                 "Zonal wind"//clev(k)//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
           CALL histdef(nid_mth, "v"//clev(k),
      .                 "Meridional wind"//clev(k)//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
           CALL histdef(nid_mth, "w"//clev(k),
      .                 "Vertical wind"//clev(k)//"mb","Pa/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
           CALL histdef(nid_mth, "phi"//clev(k),
      .                 "Geopotential"//clev(k)//"mb","m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -482,66 +486,66 @@
 c
          CALL histdef(nid_mth,"lwcon","Cloud water content","kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev, nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth,"iwcon","Cloud ice water content","kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev, nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev, nvert, 32, 
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "temp", "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "ovap", "Specific humidity", "kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth,"wvap","Water vapor mixing ratio","kg/kg",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "geop", "Geopotential height", "m",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "vitu", "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "vitv", "Meridional wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "vitw", "Vertical wind", "Pa/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "pres", "Air pressure", "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
         CALL histdef(nid_mth, "rneb", "Cloud fraction", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "rnebcon", "Convective Cloud Fraction"
      .                , "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "rhum", "Relative humidity", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "ozone", "Ozone concentration", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtphy", "Physics dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dqphy", "Physics dQ", "kg/kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -559,14 +563,14 @@
            call histdef(nid_mth, "albe_"//clnsurf(nsrf), 
      $         "Albedo surf. "//clnsurf(nsrf), "-",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 c
            call histdef(nid_mth, "rugs_"//clnsurf(nsrf), 
      $         "Latent heat flux "//clnsurf(nsrf), "W/m2",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "ages_"//clnsurf(nsrf), "Snow age","day",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
@@ -574,8 +578,8 @@
 c
          CALL histdef(nid_mth, "albs", "Surface albedo", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_mth, "albslw", "Surface albedo LW", "-",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zsto,zout)
 c
@@ -587,5 +591,5 @@
      .                "Convective Cloud Liquid water content"
      .                , "kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -593,17 +597,17 @@
 c
          CALL histdef(nid_mth,"Ma","undilute adiab updraft","kg/m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "upwd", "saturated updraft", "kg/m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dnwd", "saturated downdraft","kg/m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dnwd0", "unsat. downdraft", "kg/m2/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
       ENDIF !iflag_con.GE.3
@@ -611,103 +615,103 @@
 c
          CALL histdef(nid_mth, "dtdyn", "Dynamics dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dqdyn", "Dynamics dQ", "kg/kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtcon", "Convection dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
 c        CALL histdef(nid_mth, "ducon", "Convection du", "m/s2",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
 c    .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dqcon", "Convection dQ", "kg/kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtlsc", "Condensation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 cIM: 071003
          CALL histdef(nid_mth, "dtlschr",
-     $       "Large-scale condensational heating rate", "K/s",iim,jjmp1
-     $       ,nhori, klev,1,klev,nvert, 32,"ave(X)", zsto,zout)
+     $       "Large-scale condensational heating rate", "K/s",iim,
+     $       jjphy_nb,nhori, klev,1,klev,nvert, 32,"ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dqlsc", "Condensation dQ", "kg/kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtvdf", "Boundary-layer dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dqvdf", "Boundary-layer dQ", "kg/kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dteva", "Reevaporation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dqeva", "Reevaporation dQ", "kg/kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_mth, "ptconv", "POINTS CONVECTIFS"," ",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_mth, "ratqs", "RATQS"," ",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
 c
          CALL histdef(nid_mth, "dtajs", "Dry adjust. dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_mth, "dqajs", "Dry adjust. dQ", "kg/kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtswr", "SW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtsw0", "CS SW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtlwr", "LW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth,"dtlw0","CS LW radiation dT","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dtec", "Cinetic dissip dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "duvdf", "Boundary-layer dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dvvdf", "Boundary-layer dV", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          IF (ok_orodr) THEN
          CALL histdef(nid_mth, "duoro", "Orography dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dvoro", "Orography dV", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
@@ -716,9 +720,9 @@
          IF (ok_orolf) THEN
          CALL histdef(nid_mth, "dulif", "Orography dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "dvlif", "Orography dV", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          ENDIF
@@ -728,17 +732,17 @@
 c     IF (ok_ade.OR.ok_aie) THEN
          CALL histdef(nid_mth, "re", "CDR", "um",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "redenom", "CDR denominator", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "tau", "cloud opt thickness", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_mth, "taupi", "cloud opt thickn. (pi)", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c     endif
@@ -748,5 +752,5 @@
          iiq=niadv(iq)
          CALL histdef(nid_mth, tnom(iq), ttext(iiq), "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          ENDDO
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histmthNMC.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histmthNMC.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histmthNMC.h	(revision 634)
@@ -10,16 +10,20 @@
          CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
 c
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlon(i+1)
-            zx_lon(i,jjmp1) = rlon(i+1)
-         ENDDO
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
+cym         DO i = 1, iim
+cym            zx_lon(i,1) = rlon(i+1)
+cym            zx_lon(i,jjmp1) = rlon(i+1)
+cym         ENDDO
          DO ll=1,klev
             znivsig(ll)=float(ll)
          ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
-         CALL histbeg("histNMC.nc", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
+cym         CALL histbeg("histNMC.nc", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
+cym     .                 1,iim,1,jjmp1, itau_phy, zjulian, dtime, 
+cym     .                 nhori, nid_nmc)
+
+         CALL histbeg_phy("histNMC.nc",itau_phy, zjulian, dtime, 
      .                 nhori, nid_nmc)
+
          write(*,*)'Mensuel NMC ', itau_phy, zjulian
          CALL histvert(nid_nmc, "presnivs", "Vertical levels", "mb",
@@ -44,30 +48,30 @@
           CALL histdef(nid_nmc, "t"//bb,
      .                 "Temperature"//bb//"mb","K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_nmc, "phi"//bb,
      .                "Geopotential"//bb//"mb", "m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
           CALL histdef(nid_nmc, "q"//bb,
      .                 "Specific humidity"//bb//"mb","kg/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
          CALL histdef(nid_nmc, "rh"//bb,
      .                 "Relative humidity"//bb//"mb", "%",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
           CALL histdef(nid_nmc, "u"//bb,
      .                 "Zonal wind"//bb//"mb","K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
           CALL histdef(nid_nmc, "v"//bb,
      .                 "Meridional wind"//bb//"mb","K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zsto,zout)
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histrac.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histrac.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ini_histrac.h	(revision 634)
@@ -4,12 +4,14 @@
          CALL ymds2ju(annee_ref, 1, day_ref, 0.0, zjulian)
 c
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,xlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = xlon(i+1)
-            zx_lon(i,jjm+1) = xlon(i+1)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,xlat,zx_lat)
-         CALL histbeg("histrac", iim,zx_lon(:,1), jjm+1,zx_lat(1,:),
-     .                 1,iim,1,jjm+1, itau_phy, zjulian, pdtphys,
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,xlon,zx_lon)
+cym         DO i = 1, iim
+cym            zx_lon(i,1) = xlon(i+1)
+cym            zx_lon(i,jjm+1) = xlon(i+1)
+cym         ENDDO
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,xlat,zx_lat)
+cym         CALL histbeg("histrac", iim,zx_lon(:,1), jjm+1,zx_lat(1,:),
+cym     .                 1,iim,1,jjm+1, itau_phy, zjulian, pdtphys,
+cym     .                 nhori, nid_tra)
+         CALL histbeg_phy("histrac", itau_phy, zjulian, pdtphys,
      .                 nhori, nid_tra)
          CALL histvert(nid_tra, "presnivs", "Vertical levels", "mb",
@@ -17,10 +19,14 @@
 
 #ifdef INCA_AER
-         CALL histbeg("histrac_aer", iim,zx_lon, jjm+1,zx_lat,
-     .                 1,iim,1,jjm+1,  itau_phy, zjulian, pdtphys,
+cym         CALL histbeg("histrac_aer", iim,zx_lon, jjm+1,zx_lat,
+cym     .                 1,iim,1,jjm+1,  itau_phy, zjulian, pdtphys,
+cym     .                 nhori, nid_tra2)
+         CALL histbeg_phy("histrac_aer", itau_phy, zjulian, pdtphys,
      .                 nhori, nid_tra2)
 
-         CALL histbeg("histrac_inst", iim,zx_lon, jjm+1,zx_lat,
-     .                 1,iim,1,jjm+1,  itau_phy, zjulian, pdtphys,
+cym         CALL histbeg("histrac_inst", iim,zx_lon, jjm+1,zx_lat,
+cym     .                 1,iim,1,jjm+1,  itau_phy, zjulian, pdtphys,
+cym     .                 nhori, nid_tra3)
+         CALL histbeg_phy("histrac_inst",itau_phy, zjulian, pdtphys,
      .                 nhori, nid_tra3)
 
@@ -42,47 +48,47 @@
 c
          CALL histdef(nid_tra, "phis", "Surface geop. height", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "once",  zsto,zout)
 c
          CALL histdef(nid_tra, "aire", "Grid area", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "once",  zsto,zout)
 #ifdef INCA
          CALL histdef(nid_tra, "ps", "Surface pressure", "Pa",
-     .                iim,jjm+1,nhori, 1,1,1,-99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_tra, "ptrop", "Tropopause pressure", "Pa",
-     .                iim,jjm+1,nhori, 1,1,1,-99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99, 32,
      .                "ave(X)", zsto,zout)
 
 C   3d FIELDS
          CALL histdef(nid_tra, "temp", "Air temperature", "K",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_tra, "u", "zonal wind component", "m/s",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_tra, "v", "zonal wind component", "m/s",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_tra, "h2o", "Specific Humidity", "MMR",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_tra, "pmid", "Pressure", "Pa",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_tra, "pdel", "Delta Pressure", "Pa",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
 ! MS info
          CALL histdef(nid_tra, "airm", "Air mass", "kg",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
@@ -92,5 +98,5 @@
          WRITE(str2,'(i2.2)') it
          CALL histdef(nid_tra, "j"//str2,"j"//str2, "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          ENDDO
@@ -98,5 +104,5 @@
          WRITE(str2,'(i2.2)') it
          CALL histdef(nid_tra, "w"//str2,"w"//str2, "S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          ENDDO
@@ -105,5 +111,5 @@
          WRITE(str2,'(i2.2)') it
          CALL histdef(nid_tra, "ext"//str2,"ext"//str2, "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          ENDDO
@@ -112,5 +118,5 @@
          WRITE(str2,'(i2.2)') it
          CALL histdef(nid_tra, "INV"//str2, "INV"//str2, "CM-3",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          ENDDO
@@ -118,20 +124,20 @@
 #else
          CALL histdef(nid_tra, "jO3","jO3", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "jNO2","jNO2", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "jH2O2","jH2O2", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "wHNO3","wHNO3", "S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "kN2O5", "kN2O5","CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "LghtNO","LghtNO", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 #endif
@@ -139,5 +145,5 @@
          DO it=1, grpcnt
          CALL histdef(nid_tra, grpsym(it), grpsym(it), "VMR",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          ENDDO
@@ -147,11 +153,11 @@
 
         CALL histdef(nid_tra2, "scavcoef_st","scavcoef_st", "S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
         CALL histdef(nid_tra2, "scavcoef_cv","scavcoef_cv", "S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
         CALL histdef(nid_tra2, "AngstroemComp","AngstroemComp",
-     .      "angs comp", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .      "angs comp", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .      "ave(X)", zsto,zout)
 
@@ -164,52 +170,52 @@
 
          CALL histdef(nid_tra, "Emi_"//solsym(it), "Emi_"//solsym(it),
-     .           "kg/m2/s", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .           "kg/m2/s", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .           "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "Dep_"//solsym(it), "Dep_"//solsym(it),
-     .           "cm/s", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .           "cm/s", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .           "ave(X)", zsto,zout)
 #ifdef INCA_AER
         IF  ((it .ge. trmx) .and. (it .le. trnx)) then
           CALL histdef(nid_tra2, "Sed_"//solsym(it), "Sed_"//solsym(it),
-     .      "kg/m2/s", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .      "kg/m2/s", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .      "ave(X)", zsto,zout)
           CALL histdef(nid_tra2, "Dry_"//solsym(it), "Dry_"//solsym(it),
-     .      "kg/m2/s", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .      "kg/m2/s", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .      "ave(X)", zsto,zout)
           CALL histdef(nid_tra2, "Wet_"//solsym(it), "Wet_"//solsym(it),
-     .      "kg/m2/s", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .      "kg/m2/s", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .      "ave(X)", zsto,zout)
           CALL histdef(nid_tra2, "WetST_"//solsym(it), "WetST_"//solsym(it),
-     .      "kg/m2/s", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .      "kg/m2/s", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .      "ave(X)", zsto,zout)
           CALL histdef(nid_tra2, "WetCV_"//solsym(it), "WetCV_"//solsym(it),
-     .      "kg/m2/s", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .      "kg/m2/s", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .      "ave(X)", zsto,zout)
           CALL histdef(nid_tra2, "Emi_alt_"//solsym(it), "Emi_alt_"//solsym(it),
-     .      "kg/m2/s", iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .      "kg/m2/s", iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .      "ave(X)", zsto,zout)
           CALL histdef(nid_tra2, "Load_"//solsym(it), "Load_"//solsym(it),
-     .      "kg/m2", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .      "kg/m2", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .      "ave(X)", zsto,zout)
           CALL histdef(nid_tra2, "SConc_"//solsym(it), "SConc_"//solsym(it),
-     .      "kg/m3", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .      "kg/m3", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .      "ave(X)", zsto,zout)
           do la=1,las
            CALL histdef(nid_tra2, "OD_"//cla(la)//solsym(it), 
      .                            "OD_"//cla(la)//solsym(it),
-     .        "opt. depth", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .        "opt. depth", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .        "ave(X)", zsto,zout)
           enddo
           CALL histdef(nid_tra2, "MD_"//solsym(it), "MD_"//solsym(it),
-     .      "median diameter", iim,jjm+1,nhori, klev,1,klev, nvert, 32,
+     .      "median diameter", iim,jjphy_nb,nhori, klev,1,klev, nvert, 32,
      .      "ave(X)", zsto,zout)
           CALL histdef(nid_tra3, "Inst_Load_"//solsym(it), 
      .                          "Inst_Load_"//solsym(it),
-     .      "kg/m2", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .      "kg/m2", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .      "inst(X)", zout,zout)
         endif
 #endif
          CALL histdef(nid_tra, solsym(it), solsym(it), "VMR",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 #else
@@ -217,9 +223,9 @@
          iiq=niadv(iq)
          CALL histdef(nid_tra, tnom(iq), ttext(iiq), "U/kga",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          if (lessivage) THEN
          CALL histdef(nid_tra, "fl"//tnom(iq),"Flux "//ttext(iiq),
-     .              "U/m2/s",iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .              "U/m2/s",iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .              "ave(X)", zsto,zout)
          endif
@@ -228,13 +234,13 @@
          CALL histdef(nid_tra, "d_tr_th_"//tnom(iq),
      .	              "tendance thermique"// ttext(iiq), "?",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "d_tr_cv_"//tnom(iq),
      .	              "tendance convection"// ttext(iiq), "?",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "d_tr_cl_"//tnom(iq),
      .	              "tendance couche limite"// ttext(iiq), "?",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 c---fin Olivia	 
@@ -246,23 +252,23 @@
 !#ifdef INCA_CH4
          CALL histdef(nid_tra, "O3_column", "O3_column",
-     .           "DU", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .           "DU", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .           "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "CO_column", "CO_column",
-     .           "10^18 CM-2", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .           "10^18 CM-2", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .           "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "CH4_column", "CH4_column",
-     .           "10^18 CM-2", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .           "10^18 CM-2", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .           "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "NO2_column", "NO2_column",
-     .           "10^15 CM-2", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .           "10^15 CM-2", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .           "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "O3_ste", "O3_ste",
-     .           "CM-2 S-1", iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .           "CM-2 S-1", iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .           "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "O3_prod", "O3_prod", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "O3_loss", "O3_loss", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
@@ -281,46 +287,46 @@
 ! for sulfur cycle
          CALL histdef(nid_tra, "SO2_p_dmsoh", "SO2_p_dmsoh", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "SO2_p_dmsno3", "SO2_p_dmsno3", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "SO2_p_h2soh", "SO2_p_h2soh", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "SO2_p_dmsooh", "SO2_p_dmsooh", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "DMSO_p_dmsoh", "DMSO_p_dmsoh", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "ASMSAM_p_dmsooh", "ASMSAM_p_dmsooh", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "ASSO4M_p_so2oh", "ASSO4M_p_so2oh", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "ASSO4M_p_so2h2o2", "ASSO4M_p_h2o2","CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "ASSO4M_p_so2o3", "ASSO4M_p_so2o3", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
          CALL histdef(nid_tra, "Wet3D_SO2", "Wet3D_SO2",
-     .           "kg/m2/s", iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .           "kg/m2/s", iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .           "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "Wet3D_DMS", "Wet3D_DMS",
-     .           "kg/m2/s", iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .           "kg/m2/s", iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .           "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "Wet3D_HNO3", "Wet3D_HNO3",
-     .           "kg/m2/s", iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .           "kg/m2/s", iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .           "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "Wet3D_H2O2", "Wet3D_H2O2",
-     .           "kg/m2/s", iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .           "kg/m2/s", iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .           "ave(X)", zsto,zout)
 
          CALL histdef(nid_tra, "PH_HIST", "pH over physics time step", "1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 #endif
@@ -328,23 +334,23 @@
 #ifdef INCA_NMHC
          CALL histdef(nid_tra, "CO2_basprod", "CO2_basprod", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "CO2_nmhcprod", "CO2_nmhcprod", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "CO2_radicalprod", "CO2_radicalprod", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "HNO3_prod", "HNO3_prod", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "HNO3_loss", "HNO3_loss", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "CO_prod", "CO_prod", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "CO_loss", "CO_loss", "CM-3 S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 #endif
@@ -352,60 +358,60 @@
 #else
          CALL histdef(nid_tra, "pyu1", "Vent niv 1", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)",  zsto,zout)
 
          CALL histdef(nid_tra, "pyv1", "Vent niv 1", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)",  zsto,zout)
          CALL histdef(nid_tra, "psrf1", "nature sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)",  zsto,zout)
          CALL histdef(nid_tra, "psrf2", "nature sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)",  zsto,zout)
          CALL histdef(nid_tra, "psrf3", "nature sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)",  zsto,zout)
          CALL histdef(nid_tra, "psrf4", "nature sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)",  zsto,zout)
          CALL histdef(nid_tra, "ftsol1", "temper sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)",  zsto,zout)
          CALL histdef(nid_tra, "ftsol2", "temper sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)",  zsto,zout)
          CALL histdef(nid_tra, "ftsol3", "temper sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst",  zsto,zout)
          CALL histdef(nid_tra, "ftsol4", "temper sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)",  zsto,zout)
          CALL histdef(nid_tra, "pplay", "flux u mont","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "inst(X)", zsto,zout)
          CALL histdef(nid_tra, "t", "flux u mont","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "inst(X)", zsto,zout)
          CALL histdef(nid_tra, "mfu", "flux u mont","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "mfd", "flux u decen","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "en_u", "flux u mont","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "en_d", "flux u mont","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "de_d", "flux u mont","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "de_u", "flux u decen","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
          CALL histdef(nid_tra, "coefh", "turbulent coef","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/inifis.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/inifis.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/inifis.F	(revision 634)
@@ -7,4 +7,5 @@
      $           plat,plon,parea,
      $           prad,pg,pr,pcpp)
+      use dimphy
       IMPLICIT NONE
 c
@@ -41,6 +42,6 @@
 c   -------------
  
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       REAL prad,pg,pr,pcpp,punjours
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/iniphysiq.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/iniphysiq.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/iniphysiq.F	(revision 634)
@@ -9,4 +9,6 @@
      $           plat,plon,parea,pcu,pcv,
      $           prad,pg,pr,pcpp)
+      USE dimphy,klon2=>klon,klon=>klon2
+      USE comgeomphy
       IMPLICIT NONE
 c
@@ -43,7 +45,7 @@
 c   -------------
  
-#include "dimensions.h"
-#include "dimphy.h"
-#include "comgeomphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "comgeomphy.h"
 
       REAL prad,pg,pr,pcpp,punjours
@@ -71,9 +73,9 @@
       ENDIF
 
-      airephy=parea
-      cuphy=pcu
-      cvphy=pcv
-      rlond = plon
-      rlatd = plat
+      airephy(1:klon2)=parea(klon_begin:klon_end)
+      cuphy(1:klon2)=pcu(klon_begin:klon_end)
+      cvphy(1:klon2)=pcv(klon_begin:klon_end)
+      rlond(1:klon2) = plon(klon_begin:klon_end)
+      rlatd(1:klon2) = plat(klon_begin:klon_end)
 
       call suphec
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/initphysto.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/initphysto.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/initphysto.F	(revision 634)
@@ -7,7 +7,8 @@
      .  (infile,
      .  rlon, rlat, tstep,t_ops,t_wrt,nq,fileid)
-
+       
+       USE dimphy
        USE IOIPSL
-
+       USE iophy
       implicit none
 
@@ -51,5 +52,5 @@
 #include "indicesol.h"
 #include "control.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 
 C   Arguments
@@ -91,15 +92,14 @@
       tau0 = 0
 	
-	CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlon,zx_lon)
-         DO i = 1, iim
-            zx_lon(i,1) = rlon(i+1)
-            zx_lon(i,jjm+1) = rlon(i+1)
-         ENDDO
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlat,zx_lat)
-
-
-      call histbeg(infile, iim, zx_lon(:,1), jjm+1, zx_lat(1,:),
-     .             1, iim, 1, jjm+1,
-     .             tau0, zjulian, tstep, nhoriid, fileid)
+cym	CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlon,zx_lon)
+cym         DO i = 1, iim
+cym            zx_lon(i,1) = rlon(i+1)
+cym            zx_lon(i,jjm+1) = rlon(i+1)
+cym         ENDDO
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlat,zx_lat)
+
+
+      call histbeg_phy(infile,tau0, zjulian, tstep,
+     .                 nhoriid, fileid)
 
 C  Appel a histvert pour la grille verticale
@@ -120,5 +120,5 @@
 
        CALL histdef(fileid, "phis", "Surface geop. height", "-",
-     .                iim,jjm+1,nhoriid, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhoriid, 1,1,1, -99, 32,
      .                "once", t_ops, t_wrt)
 c
@@ -126,8 +126,9 @@
 
          CALL histdef(fileid, "aire", "Grid area", "-",
-     .                iim,jjm+1,nhoriid, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhoriid, 1,1,1, -99, 32,
      .                "once", t_ops, t_wrt)
          write(*,*) 'apres aire ds initphysto'
 
+cym     Attention dtime et istphy ne sont pas écrit ---> a éliminer ?
          CALL histdef(fileid, "dtime", "tps phys ", "s",
      .                1,1,nhoriid, 1,1,1, -99, 32,
@@ -141,5 +142,5 @@
 C
       call histdef(fileid, 't', 'Temperature', 'K',
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, 'inst(X)', t_ops, t_wrt)
         write(*,*) 'apres t ds initphysto'
@@ -147,5 +148,5 @@
 C
       call histdef(fileid, 'mfu', 'flx m. pan. mt', 'kg m/s',
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, 'inst(X)', t_ops, t_wrt)
         write(*,*) 'apres mfu ds initphysto'
@@ -154,5 +155,5 @@
 C
       call histdef(fileid, 'mfd', 'flx m. pan. des', 'kg m/s',
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, 'inst(X)', t_ops, t_wrt)
 
@@ -161,5 +162,5 @@
 C
       call histdef(fileid, 'en_u', 'flx ent pan mt', 'kg m/s',
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, 'inst(X)', t_ops, t_wrt)
                write(*,*) 'apres en_u ds initphysto'
@@ -168,5 +169,5 @@
 C
       call histdef(fileid, 'de_u', 'flx det pan mt', 'kg m/s',
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, 'inst(X)', t_ops, t_wrt)
 
@@ -175,5 +176,5 @@
 C
       call histdef(fileid, 'en_d', 'flx ent pan dt', 'kg m/s',
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, 'inst(X)', t_ops, t_wrt)
 C
@@ -183,5 +184,5 @@
 C
       call histdef(fileid, 'de_d', 'flx det pan dt', 'kg m/s',
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, 'inst(X)', t_ops, t_wrt)
 
@@ -189,14 +190,14 @@
 	
 	call histdef(fileid, "coefh", " ", " ",
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, "inst(X)", t_ops, t_wrt)
 
 c abderrahmane le 16 09 02
         call histdef(fileid, "fm_th", " ", " ",
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, "inst(X)", t_ops, t_wrt)
 
         call histdef(fileid, "en_th", " ", " ",
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, "inst(X)", t_ops, t_wrt)
 c fin aj
@@ -205,9 +206,9 @@
 
 	call histdef(fileid, 'frac_impa', ' ', ' ',
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, 'inst(X)', t_ops, t_wrt)
 	
 	call histdef(fileid, 'frac_nucl', ' ', ' ',
-     .             iim, jjm+1, nhoriid, llm, 1, llm, zvertiid,
+     .             iim, jjphy_nb, nhoriid, llm, 1, llm, zvertiid,
      .             32, 'inst(X)', t_ops, t_wrt)
 
@@ -216,5 +217,5 @@
 c
       CALL histdef(fileid, "pyu1", " ", " ",
-     .                iim,jjm+1,nhoriid, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhoriid, 1,1,1, -99, 32,
      .                "inst(X)", t_ops, t_wrt)
 
@@ -223,5 +224,5 @@
 c
 	CALL histdef(fileid, "pyv1", " ", " ",
-     .                iim,jjm+1,nhoriid, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhoriid, 1,1,1, -99, 32,
      .                "inst(X)", t_ops, t_wrt)
 	
@@ -231,5 +232,5 @@
 c
 	call histdef(fileid, "ftsol1", " ", " ",
-     .             iim, jjm+1, nhoriid, 1, 1,1, -99,32,
+     .             iim, jjphy_nb, nhoriid, 1, 1,1, -99,32,
      .             "inst(X)", t_ops, t_wrt)
 
@@ -238,5 +239,5 @@
 c
         call histdef(fileid, "ftsol2", " ", " ",
-     .             iim, jjm+1, nhoriid, 1, 1,1, -99,32,
+     .             iim, jjphy_nb, nhoriid, 1, 1,1, -99,32,
      .             "inst(X)", t_ops, t_wrt)
 
@@ -245,5 +246,5 @@
 c
         call histdef(fileid, "ftsol3", " ", " ",
-     .             iim, jjm+1, nhoriid, 1, 1,1, -99,
+     .             iim, jjphy_nb, nhoriid, 1, 1,1, -99,
      .             32, "inst(X)", t_ops, t_wrt)
 
@@ -252,5 +253,5 @@
 c
         call histdef(fileid, "ftsol4", " ", " ",
-     .             iim, jjm+1, nhoriid, 1, 1,1, -99,
+     .             iim, jjphy_nb, nhoriid, 1, 1,1, -99,
      .             32, "inst(X)", t_ops, t_wrt)
 	
@@ -259,5 +260,5 @@
 c
         call histdef(fileid, "rain", " ", " ",
-     .             iim, jjm+1, nhoriid, 1, 1,1, -99,
+     .             iim, jjphy_nb, nhoriid, 1, 1,1, -99,
      .             32, "inst(X)", t_ops, t_wrt)
 
@@ -266,5 +267,5 @@
 c
 	call histdef(fileid, "psrf1", " ", " ",
-     .             iim, jjm+1, nhoriid, 1, 1, 1, -99,
+     .             iim, jjphy_nb, nhoriid, 1, 1, 1, -99,
      .             32, "inst(X)", t_ops, t_wrt)
 	
@@ -273,5 +274,5 @@
 c
         call histdef(fileid, "psrf2", " ", " ",
-     .             iim, jjm+1, nhoriid, 1, 1, 1, -99,
+     .             iim, jjphy_nb, nhoriid, 1, 1, 1, -99,
      .             32, "inst(X)", t_ops, t_wrt)
 
@@ -280,5 +281,5 @@
 c
         call histdef(fileid, "psrf3", " ", " ",
-     .             iim, jjm+1, nhoriid, 1, 1, 1, -99,
+     .             iim, jjphy_nb, nhoriid, 1, 1, 1, -99,
      .             32, "inst(X)", t_ops, t_wrt)
 
@@ -287,5 +288,5 @@
 c
         call histdef(fileid, "psrf4", " ", " ",
-     .             iim, jjm+1, nhoriid, 1, 1, 1, -99,
+     .             iim, jjphy_nb, nhoriid, 1, 1, 1, -99,
      .             32, "inst(X)", t_ops, t_wrt)
 	
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/initrrnpb.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/initrrnpb.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/initrrnpb.F	(revision 634)
@@ -4,4 +4,5 @@
       SUBROUTINE  initrrnpb(ftsol,pctsrf,masktr,fshtr,hsoltr,tautr
      .                   ,vdeptr,scavtr)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -24,6 +25,6 @@
 c scavtr---output-R- Coefficient de lessivage
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "indicesol.h"
 c======================================================================
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/interface_surf.F90
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/interface_surf.F90	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/interface_surf.F90	(revision 634)
@@ -22,5 +22,5 @@
 ! L. Fairhead, LMD, 02/2000
 
-  USE ioipsl
+!ym  USE ioipsl
 
   IMPLICIT none
@@ -76,5 +76,5 @@
       & z0_new, pctsrf_new, agesno,fqcalving,ffonte, run_off_lic_0)
 
-
+   USE dimphy,only : monocpu
 ! Cette routine sert d'aiguillage entre l'atmosphere et la surface en general 
 ! (sols continentaux, oceans, glaces) pour les fluxs de chaleur et d'humidite.
@@ -235,4 +235,5 @@
   real, dimension(klon):: fder_prev
   REAL, dimension(klon) :: bidule
+  INTEGER :: j
 
   if (check) write(*,*) 'Entree ', modname
@@ -394,4 +395,9 @@
 
     else
+    
+      if (.not.monocpu) then
+        abort_message='Appel a ORCHIDEE non encore parallelise !!'
+        call abort_gcm(modname,abort_message,1)
+      endif
 !!      CALL albsno(klon,agesno,alb_neig_grid)  
 !
@@ -434,4 +440,9 @@
 !
     if (ocean == 'couple') then
+      if (.not.monocpu) then
+        abort_message='Couplage avec l OCEAN non encore parallelise !!'
+        call abort_gcm(modname,abort_message,1)
+      endif
+
       if (nexca == 0) then
         abort_message='nexca = 0 dans interfoce_cpl'
@@ -510,4 +521,9 @@
     if (ocean == 'couple') then
 
+      if (.not.monocpu) then
+        abort_message='Couplage avec l OCEAN non encore parallelise !!'
+        call abort_gcm(modname,abort_message,1)
+      endif
+
       cumul = .true.
 
@@ -555,5 +571,10 @@
 !
     if (ocean == 'couple') then
-
+      
+      if (.not.monocpu) then
+        abort_message='Couplage avec l OCEAN non encore parallelise !!'
+        call abort_gcm(modname,abort_message,1)
+      endif
+      
       cumul =.false.
 
@@ -596,5 +617,6 @@
 !IM cf LF
       DO ii = 1, knon
-       IF (pctsrf_new(ii,nisurf) < EPSFRA) then
+       j=knindex(ii)
+       IF (pctsrf_new(j,nisurf) < EPSFRA) then
           snow(ii) = 0.0
 !IM cf LF/JLD         tsurf(ii) = RTT - 1.8
@@ -666,4 +688,9 @@
     if (ocean == 'couple') then
 
+      if (.not.monocpu) then
+        abort_message='Couplage avec l OCEAN non encore parallelise !!'
+        call abort_gcm(modname,abort_message,1)
+      endif
+
       cumul =.true.
 
@@ -733,7 +760,16 @@
 
 ! passage du run-off des glaciers calcule dans fonte_neige au coupleur
-    bidule=0.
-    bidule(1:knon)= run_off_lic(1:knon)    
-    call gath2cpl(bidule, tmp_rlic, klon, knon,iim,jjm,knindex)
+    if (ocean=='couple') then
+      
+      if (.not.monocpu) then
+        abort_message='Couplage avec l OCEAN non encore parallelise !!'
+        call abort_gcm(modname,abort_message,1)
+      endif
+
+      bidule=0.
+      bidule(1:knon)= run_off_lic(1:knon)    
+      call gath2cpl(bidule, tmp_rlic, klon, knon,iim,jjm,knindex)
+    
+    endif
 !
 ! calcul albedo
@@ -1239,4 +1275,5 @@
       & pctsrf_new)
 
+   USE ioipsl
 ! Cette routine sert d'interface entre le modele atmospherique et un 
 ! coupleur avec un modele d'ocean 'complet' derriere
@@ -1909,7 +1946,9 @@
 !
   SUBROUTINE interfoce_lim(itime, dtime, jour, &
-     & klon, nisurf, knon, knindex, &
+     & klon_xx, nisurf, knon, knindex, &
      & debut,  &
-     & lmt_sst, pctsrf_new)
+     & lmt_sst_p, pctsrf_new_p)
+     
+     USE dimphy,klon=>klon2,klon2=>klon
 
 ! Cette routine sert d'interface entre le modele atmospherique et un fichier
@@ -1938,13 +1977,16 @@
   real   , intent(IN) :: dtime
   integer, intent(IN) :: jour
+  integer, intent(in) :: klon_xx
   integer, intent(IN) :: nisurf
   integer, intent(IN) :: knon
-  integer, intent(IN) :: klon
-  integer, dimension(klon), intent(in) :: knindex
+  integer, dimension(klon2), intent(in) :: knindex
   logical, intent(IN) :: debut
 
 ! Parametres de sortie
-  real, intent(out), dimension(klon) :: lmt_sst
-  real, intent(out), dimension(klon,nbsrf) :: pctsrf_new
+  real, intent(out), dimension(klon2) :: lmt_sst_p
+  real, intent(out), dimension(klon2,nbsrf) :: pctsrf_new_p
+
+!  real, dimension(klon) :: lmt_sst
+  real, dimension(klon,nbsrf) :: pctsrf_new
 
 ! Variables locales
@@ -1962,6 +2004,9 @@
   logical, save     :: check = .FALSE.
 ! Champs lus dans le fichier de CL
-  real, allocatable , save, dimension(:) :: sst_lu, rug_lu, nat_lu
-  real, allocatable , save, dimension(:,:) :: pct_tmp
+  real, allocatable , save, dimension(:) :: sst_lu_p, rug_lu_p, nat_lu_p
+  real, allocatable , save, dimension(:,:) :: pct_tmp_p
+  real, dimension(klon,nbsrf) :: pct_tmp
+  real, dimension(klon) :: sst_lu
+  real, dimension(klon) :: nat_lu
 !
 ! quelques variables pour netcdf
@@ -1973,11 +2018,11 @@
 ! Fin déclaration
 !
-    
-  if (debut .and. .not. allocated(sst_lu)) then
+  
+  if (debut .and. .not. allocated(sst_lu_p)) then
     lmt_pas = nint(86400./dtime * 1.0) ! pour une lecture une fois par jour
     jour_lu = jour - 1
-    allocate(sst_lu(klon))
-    allocate(nat_lu(klon))
-    allocate(pct_tmp(klon,nbsrf))
+    allocate(sst_lu_p(klon2))
+    allocate(nat_lu_p(klon2))
+    allocate(pct_tmp_p(klon2,nbsrf))
   endif
 
@@ -1992,4 +2037,6 @@
 ! Ouverture du fichier
 !
+    if (phy_rank==0) then
+    
     fich = trim(fich)
     ierr = NF_OPEN (fich, NF_NOWRITE,nid)
@@ -2131,17 +2178,27 @@
 !
     ierr = NF_CLOSE(nid)
-    deja_lu = .true.
-    jour_lu = jour
-  endif
+   endif ! phyrank
 !
 ! Recopie des variables dans les champs de sortie
 !
-  lmt_sst = 999999999.
+  call ScatterField(sst_lu,sst_lu_p,1)
+  call ScatterField(pct_tmp(:,is_oce),pct_tmp_p(:,is_oce),1)
+  call ScatterField(pct_tmp(:,is_sic),pct_tmp_p(:,is_sic),1)
+  
+   deja_lu = .true.
+   jour_lu = jour
+  endif   
+  
+  lmt_sst_p = 999999999.
+  
   do ii = 1, knon
-    lmt_sst(ii) = sst_lu(knindex(ii))
+    lmt_sst_p(ii) = sst_lu_p(knindex(ii))
   enddo
 
-  pctsrf_new(:,is_oce) = pct_tmp(:,is_oce)
-  pctsrf_new(:,is_sic) = pct_tmp(:,is_sic)
+  do ii=1,klon2
+    pctsrf_new_p(ii,is_oce)=pct_tmp_p(ii,is_oce)
+    pctsrf_new_p(ii,is_sic)=pct_tmp_p(ii,is_sic)
+  enddo
+  
 
   END SUBROUTINE interfoce_lim
@@ -2151,7 +2208,9 @@
 !
   SUBROUTINE interfsur_lim(itime, dtime, jour, &
-     & klon, nisurf, knon, knindex, &
+     & klon_xx, nisurf, knon, knindex, &
      & debut,  &
-     & lmt_alb, lmt_rug)
+     & lmt_alb_p, lmt_rug_p)
+
+     USE dimphy,klon=>klon2,klon2=>klon
 
 ! Cette routine sert d'interface entre le modele atmospherique et un fichier
@@ -2184,11 +2243,14 @@
   integer, intent(IN) :: nisurf
   integer, intent(IN) :: knon
-  integer, intent(IN) :: klon
-  integer, dimension(klon), intent(in) :: knindex
+  integer, intent(IN) :: klon_xx
+  integer, dimension(klon2), intent(in) :: knindex
   logical, intent(IN) :: debut
 
 ! Parametres de sortie
-  real, intent(out), dimension(klon) :: lmt_alb
-  real, intent(out), dimension(klon) :: lmt_rug
+  real, intent(out), dimension(klon2) :: lmt_alb_p
+  real, intent(out), dimension(klon2) :: lmt_rug_p
+
+!  real,  dimension(klon) :: lmt_alb
+!  real,  dimension(klon) :: lmt_rug
 
 ! Variables locales
@@ -2206,5 +2268,6 @@
   logical,save     :: check = .false.
 ! Champs lus dans le fichier de CL
-  real, allocatable , save, dimension(:) :: alb_lu, rug_lu
+  real, allocatable , save, dimension(:) :: alb_lu_p, rug_lu_p
+  real, dimension(klon) :: alb_lu, rug_lu
 !
 ! quelques variables pour netcdf
@@ -2220,6 +2283,6 @@
     lmt_pas = nint(86400./dtime * 1.0) ! pour une lecture une fois par jour
     jour_lu_sur = jour - 1
-    allocate(alb_lu(klon))
-    allocate(rug_lu(klon))
+    allocate(alb_lu_p(klon2))
+    allocate(rug_lu_p(klon2))
   endif
 
@@ -2232,4 +2295,6 @@
 ! Tester d'abord si c'est le moment de lire le fichier
   if (mod(itime-1, lmt_pas) == 0 .and. .not. deja_lu_sur) then
+  
+  if (phy_rank==0) then
 !
 ! Ouverture du fichier
@@ -2289,4 +2354,11 @@
 !
     ierr = NF_CLOSE(nid)
+
+
+  endif  !! phyrank
+
+    call ScatterField(alb_lu,alb_lu_p,1)
+    call ScatterField(rug_lu,rug_lu_p,1)
+
     deja_lu_sur = .true.
     jour_lu_sur = jour
@@ -2297,9 +2369,10 @@
 !!$  lmt_alb(:) = 0.0
 !!$  lmt_rug(:) = 0.0
-  lmt_alb(:) = 999999.
-  lmt_rug(:) = 999999.
+ 
+  lmt_alb_p(:) = 999999.
+  lmt_rug_p(:) = 999999.
   DO ii = 1, knon
-    lmt_alb(ii) = alb_lu(knindex(ii))
-    lmt_rug(ii) = rug_lu(knindex(ii))
+    lmt_alb_p(ii) = alb_lu_p(knindex(ii))
+    lmt_rug_p(ii) = rug_lu_p(knindex(ii))
   enddo
 
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/minmaxqfi.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/minmaxqfi.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/minmaxqfi.F	(revision 634)
@@ -3,8 +3,9 @@
 !
       SUBROUTINE minmaxqfi(zq,qmin,qmax,comment)
+      USE dimphy
       IMPLICIT none
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       CHARACTER*(*) comment
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/newmicro.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/newmicro.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/newmicro.F	(revision 634)
@@ -10,4 +10,5 @@
      e                  bl95_b0, bl95_b1,
      s                  cldtaupi, re, fl)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -39,6 +40,6 @@
 #include "YOMCST.h"
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "nuage.h"
       REAL paprs(klon,klev+1), pplay(klon,klev)
@@ -110,4 +111,5 @@
        xflwp(i)=0.
        xfiwp(i)=0.
+c!CDIR NOVECTOR
       DO k = 1, klev
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/nflxtr.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/nflxtr.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/nflxtr.F	(revision 634)
@@ -4,4 +4,5 @@
       SUBROUTINE nflxtr(pdtime,pmfu,pmfd,pen_u,pde_u,pen_d,pde_d,
      .                 pplay,paprs,x,dx) 
+      USE dimphy
       IMPLICIT NONE 
 c=====================================================================
@@ -21,6 +22,6 @@
 c=====================================================================
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOECUMF.h" 
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/nuage.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/nuage.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/nuage.F	(revision 634)
@@ -9,4 +9,5 @@
      e                  bl95_b0, bl95_b1,
      s                  cldtaupi, re, fl)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -38,6 +39,6 @@
 #include "YOMCST.h"
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
       REAL paprs(klon,klev+1), pplay(klon,klev)
       REAL t(klon,klev)
@@ -229,4 +230,5 @@
       SUBROUTINE diagcld1(paprs,pplay,rain,snow,kbot,ktop,
      .                   diafra,dialiq)
+      use dimphy
       IMPLICIT none
 c
@@ -238,6 +240,6 @@
 c ces nuages. Je dois avouer que c'est une frustration.
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
@@ -313,8 +315,9 @@
       END
       SUBROUTINE diagcld2(paprs,pplay,t,q, diafra,dialiq)
+      use dimphy
       IMPLICIT none
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/orbite.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/orbite.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/orbite.F	(revision 634)
@@ -49,4 +49,5 @@
 c======================================================================
       SUBROUTINE angle(longi, lati, frac, muzero)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -64,6 +65,6 @@
 c                   la journee (0 a 1)
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
       REAL longi
       REAL lati(klon), frac(klon), muzero(klon)
@@ -108,4 +109,5 @@
       SUBROUTINE zenang(longi,gmtime,pdtrad,lat,long,
      s                  pmu0,frac)
+      USE dimphy
       IMPLICIT none
 c=============================================================
@@ -131,6 +133,6 @@
 c frac-----OUTPUT: ensoleillement moyen entre gmtime et gmtime+pdtrad
 c================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c================================================================
@@ -261,4 +263,5 @@
       SUBROUTINE zenith (longi, gmtime, lat, long,
      s                   pmu0, fract)
+      USE dimphy
       IMPLICIT none
 c
@@ -278,6 +281,6 @@
 c
 c====================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c====================================================================
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/orografi.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/orografi.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/orografi.F	(revision 634)
@@ -9,4 +9,5 @@
      s                   d_t, d_u, d_v)
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -26,6 +27,6 @@
 c d_v-----output-R-increment de la vitesse v
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
@@ -130,4 +131,5 @@
      r                 , pvom,pvol,pte )
 
+      USE dimphy
       implicit none
 
@@ -179,6 +181,6 @@
 c
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOEGWD.h"
@@ -189,5 +191,6 @@
 c
 c
-      integer nlon, nlev, klevm1
+cym      integer nlon, nlev, klevm1
+      integer nlon, nlev
       integer kgwd, jl, ilevp1, jk, ji
       real zdelp, ztemp, zforc, ztend
@@ -257,5 +260,5 @@
 c     ztmst=twodt
 c     if(nstep.eq.nstart) ztmst=0.5*twodt
-      klevm1=klev-1
+cym      klevm1=klev-1
       ztmst=ptsphy
       zrtmst=1./ztmst
@@ -464,9 +467,10 @@
 c
 c-----------------------------------------------------------------------
+      USE dimphy
       implicit none
 c
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOEGWD.h"
@@ -932,7 +936,8 @@
 c
 c-----------------------------------------------------------------------
+      USE dimphy
       implicit none
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOEGWD.h"
@@ -1066,4 +1071,5 @@
 C     PASSAGE OF THE NEW GWDRAG TO I.F.S. (F. LOTT, 22/11/93)
 C-----------------------------------------------------------------------
+      USE dimphy
       implicit none
 C
@@ -1071,6 +1077,6 @@
 C
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOEGWD.h"
@@ -1297,4 +1303,5 @@
      s                   d_t, d_u, d_v)
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1314,6 +1321,6 @@
 c d_v-----output-R-increment de la vitesse v
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
@@ -1435,9 +1442,10 @@
 C     F.LOTT  LMD 22/11/95
 C
+      USE dimphy
       implicit none
 C
 C
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOEGWD.h"
@@ -1470,5 +1478,6 @@
 C              ------------
       logical lifthigh, ll1
-      integer klevm1, jl, ilevh, jk
+cym      integer klevm1, jl, ilevh, jk
+      integer  jl, ilevh, jk
       real zcons1, ztmst, zrtmst,zpi, zhgeo
       real zdelp, zslow, zsqua, zscav, zbet
@@ -1493,5 +1502,5 @@
       IF(NLON.NE.KLON.OR.NLEV.NE.KLEV)STOP
       ZCONS1=1./RD
-      KLEVM1=KLEV-1
+cym      KLEVM1=KLEV-1
       ZTMST=PTSPHY
       ZRTMST=1./ZTMST
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ozonecm.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ozonecm.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ozonecm.F	(revision 634)
@@ -3,7 +3,8 @@
 !
       SUBROUTINE ozonecm(rjour, rlat, paprs, o3)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
       REAL rlat(klon), paprs(klon,klev+1)
       REAL o3(klon,klev)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phyetat0.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phyetat0.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phyetat0.F	(revision 634)
@@ -5,10 +5,14 @@
 c
       SUBROUTINE phyetat0 (fichnom,dtime,co2_ppm_etat0,solaire_etat0,
-     .            rlat,rlon, pctsrf, tsol,tsoil,deltat,qsurf,qsol,snow,
-     .           albe, alblw, evap, rain_fall, snow_fall, solsw, sollw,
-     .           fder,radsol,frugs,agesno,clesphy0,
-     .           zmea,zstd,zsig,zgam,zthe,zpic,zval,rugsrel,tabcntr0,
-     .           t_ancien,q_ancien,ancien_ok, rnebcon, ratqs,clwcon,
-     .           run_off_lic_0)
+     .            rlat_p,rlon_p, pctsrf_p, tsol_p,tsoil_p,deltat_p,
+     .           qsurf_p,qsol_p,snow_p,albe_p, alblw_p, evap_p,
+     .           rain_fall_p, snow_fall_p,solsw_p, sollw_p,
+     .           fder_p,radsol_p,frugs_p,agesno_p,clesphy0,
+     .           zmea_p,zstd_p,zsig_p,zgam_p,zthe_p,zpic_p,zval_p,
+     .           rugsrel_p,tabcntr0,
+     .           t_ancien_p,q_ancien_p,ancien_ok, rnebcon_p, ratqs_p,
+     .           clwcon_p,run_off_lic_0_p)
+      USE dimphy,klon=>klon2,klon2=>klon,zmasq_p=>zmasq
+      USE iophy
       IMPLICIT none
 c======================================================================
@@ -17,5 +21,5 @@
 c======================================================================
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "netcdf.inc"
 #include "indicesol.h"
@@ -27,7 +31,44 @@
       REAL dtime
       INTEGER radpas
-      REAL rlat(klon), rlon(klon)
+      REAL rlat_p(klon2), rlon_p(klon2)
       REAL co2_ppm_etat0
       REAL solaire_etat0
+      REAL tsol_p(klon2,nbsrf)
+      REAL tsoil_p(klon2,nsoilmx,nbsrf)
+      REAL deltat_p(klon2)
+      REAL qsurf_p(klon2,nbsrf)
+      REAL qsol_p(klon2)
+      REAL snow_p(klon2,nbsrf)
+      REAL albe_p(klon2,nbsrf)
+cIM BEG alblw
+      REAL alblw_p(klon2,nbsrf)
+cIM END alblw
+      REAL evap_p(klon2,nbsrf)
+      REAL radsol_p(klon2)
+      REAL rain_fall_p(klon2)
+      REAL snow_fall_p(klon2)
+      REAL sollw_p(klon2)
+      real solsw_p(klon2)
+      real fder_p(klon2)
+      REAL frugs_p(klon2,nbsrf)
+      REAL agesno_p(klon2,nbsrf)
+      REAL zmea_p(klon2)
+      REAL zstd_p(klon2)
+      REAL zsig_p(klon2)
+      REAL zgam_p(klon2)
+      REAL zthe_p(klon2)
+      REAL zpic_p(klon2)
+      REAL zval_p(klon2)
+      REAL rugsrel_p(klon2)
+      REAL pctsrf_p(klon2, nbsrf)
+      REAL run_off_lic_0_p(klon2)
+      
+      REAL t_ancien_p(klon2,klev), q_ancien_p(klon2,klev)
+      real rnebcon_p(klon2,klev),clwcon_p(klon2,klev)
+      real ratqs_p(klon2,klev)
+      LOGICAL ancien_ok
+      
+      REAL zmasq(klon)
+      REAL rlat(klon), rlon(klon)
       REAL tsol(klon,nbsrf)
       REAL tsoil(klon,nsoilmx,nbsrf)
@@ -60,8 +101,11 @@
       REAL fractint(klon)
       REAL run_off_lic_0(klon)
-
-      REAL t_ancien(klon,klev), q_ancien(klon,klev)
-      real rnebcon(klon,klev),clwcon(klon,klev),ratqs(klon,klev)
-      LOGICAL ancien_ok
+      REAL t_ancien(klon,klev)
+      REAL q_ancien(klon,klev)
+      real rnebcon(klon,klev)
+      real clwcon(klon,klev)
+      real ratqs(klon,klev)
+     
+
 
       INTEGER        longcles
@@ -78,4 +122,5 @@
       CHARACTER*7 str7
       CHARACTER*2 str2
+      real iolat(jjm+1)
 c
 c Ouvrir le fichier contenant l'etat initial:
@@ -1248,4 +1293,5 @@
       ENDIF
 c
+      clwcon=0.
       ierr = NF_INQ_VARID (nid, "CLWCON", nvarid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -1270,4 +1316,5 @@
       PRINT*,'Eau liquide convective (ecart-type) clwcon:', xmin, xmax
 c
+      rnebcon=0.
       ierr = NF_INQ_VARID (nid, "RNEBCON", nvarid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -1312,4 +1359,5 @@
 c Lecture ratqs
 c
+       ratqs=0.
       ierr = NF_INQ_VARID (nid, "RATQS", nvarid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -1362,4 +1410,50 @@
       ierr = NF_CLOSE(nid)
 c
+
+cym  en attendant mieux
+        iolat(1)=rlat(1)
+	iolat(jjm+1)=rlat(klon)
+	do i=2,jjm
+	  iolat(i)=rlat(2+(i-2)*iim)
+	enddo
+	
+        call init_iophy(iolat,rlon(2:iim+1))
+	
+      call ScatterField( rlat,rlat_p,1)
+      call ScatterField( rlon,rlon_p,1)
+      call ScatterField( tsol,tsol_p,nbsrf)
+      call ScatterField( tsoil,tsoil_p,nsoilmx*nbsrf)
+      call ScatterField( deltat,deltat_p,1)
+      call ScatterField( qsurf,qsurf_p,nbsrf)
+      call ScatterField( qsol,qsol_p,1)
+      call ScatterField( snow,snow_p,nbsrf)
+      call ScatterField( albe,albe_p,nbsrf)
+      call ScatterField( alblw,alblw_p,nbsrf)
+      call ScatterField( evap,evap_p,nbsrf)
+      call ScatterField( radsol,radsol_p,1)
+      call ScatterField( rain_fall,rain_fall_p,1)
+      call ScatterField( snow_fall,snow_fall_p,1)
+      call ScatterField( sollw,sollw_p,1)
+      call ScatterField( solsw,solsw_p,1)
+      call ScatterField( fder,fder_p,1)
+      call ScatterField( frugs,frugs_p,nbsrf)
+      call ScatterField( agesno,agesno_p,nbsrf)
+      call ScatterField( zmea,zmea_p,1)
+      call ScatterField( zstd,zstd_p,1)
+      call ScatterField( zsig,zsig_p,1)
+      call ScatterField( zgam,zgam_p,1)
+      call ScatterField( zthe,zthe_p,1)
+      call ScatterField( zpic,zpic_p,1)
+      call ScatterField( zval,zval_p,1)
+      call ScatterField( rugsrel,rugsrel_p,1)
+      call ScatterField( pctsrf,pctsrf_p, nbsrf)
+      call ScatterField( run_off_lic_0,run_off_lic_0_p,1)
+      call ScatterField( t_ancien,t_ancien_p,klev)
+      call ScatterField( q_ancien,q_ancien_p,klev)
+      call ScatterField( rnebcon,rnebcon_p,klev)
+      call ScatterField( clwcon,clwcon_p,klev)
+      call ScatterField( ratqs,ratqs_p,klev)
+      call ScatterField( zmasq,zmasq_p,1)
+      
       RETURN
       END
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phyredem.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phyredem.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phyredem.F	(revision 634)
@@ -4,11 +4,12 @@
 c
       SUBROUTINE phyredem (fichnom,dtime,radpas,
-     .           rlat,rlon, pctsrf,tsol,tsoil,deltat,qsurf,qsol,snow,
-     .           albedo, alblw, evap, rain_fall, snow_fall,
-     .           solsw, sollw,fder,
-     .           radsol,frugs,agesno,
-     .           zmea,zstd,zsig,zgam,zthe,zpic,zval,rugsrel,
-     .           t_ancien, q_ancien, rnebcon, ratqs, clwcon,
-     .           run_off_lic_0)
+     .           rlat_p,rlon_p, pctsrf_p,tsol_p,tsoil_p,deltat_p,
+     .           qsurf_p,qsol_p,snow_p,albedo_p, alblw_p, evap_p,
+     .           rain_fall_p, snow_fall_p,solsw_p, sollw_p,fder_p,
+     .           radsol_p,frugs_p,agesno_p,zmea_p,zstd_p,zsig_p,
+     .           zgam_p,zthe_p,zpic_p,zval_p,rugsrel_p,
+     .           t_ancien_p, q_ancien_p, rnebcon_p, ratqs_p, clwcon_p,
+     .           run_off_lic_0_p)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -16,6 +17,6 @@
 c Objet: Ecriture de l'etat de redemarrage pour la physique
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "netcdf.inc"
 #include "indicesol.h"
@@ -28,35 +29,66 @@
       REAL dtime
       INTEGER radpas
-      REAL rlat(klon), rlon(klon)
-      REAL tsol(klon,nbsrf)
-      REAL tsoil(klon,nsoilmx,nbsrf)
-      REAL deltat(klon)
-      REAL qsurf(klon,nbsrf)
-      REAL qsol(klon)
-      REAL snow(klon,nbsrf)
-      REAL albedo(klon,nbsrf)
+      REAL rlat_p(klon), rlon_p(klon)
+      REAL tsol_p(klon,nbsrf)
+      REAL tsoil_p(klon,nsoilmx,nbsrf)
+      REAL deltat_p(klon)
+      REAL qsurf_p(klon,nbsrf)
+      REAL qsol_p(klon)
+      REAL snow_p(klon,nbsrf)
+      REAL albedo_p(klon,nbsrf)
 cIM BEG
-      REAL alblw(klon,nbsrf)
+      REAL alblw_p(klon,nbsrf)
 cIM END
-      REAL evap(klon,nbsrf)
-      REAL rain_fall(klon)
-      REAL snow_fall(klon)
-      real solsw(klon)
-      real sollw(klon)
-      real fder(klon)
-      REAL radsol(klon)
-      REAL frugs(klon,nbsrf)
-      REAL agesno(klon,nbsrf)
-      REAL zmea(klon)
-      REAL zstd(klon)
-      REAL zsig(klon)
-      REAL zgam(klon)
-      REAL zthe(klon)
-      REAL zpic(klon)
-      REAL zval(klon)
-      REAL rugsrel(klon)
-      REAL pctsrf(klon, nbsrf)
-      REAL t_ancien(klon,klev), q_ancien(klon,klev)
-      real clwcon(klon,klev),rnebcon(klon,klev),ratqs(klon,klev)
+      REAL evap_p(klon,nbsrf)
+      REAL rain_fall_p(klon)
+      REAL snow_fall_p(klon)
+      real solsw_p(klon)
+      real sollw_p(klon)
+      real fder_p(klon)
+      REAL radsol_p(klon)
+      REAL frugs_p(klon,nbsrf)
+      REAL agesno_p(klon,nbsrf)
+      REAL zmea_p(klon)
+      REAL zstd_p(klon)
+      REAL zsig_p(klon)
+      REAL zgam_p(klon)
+      REAL zthe_p(klon)
+      REAL zpic_p(klon)
+      REAL zval_p(klon)
+      REAL rugsrel_p(klon)
+      REAL pctsrf_p(klon, nbsrf)
+      REAL t_ancien_p(klon,klev), q_ancien_p(klon,klev)
+      real clwcon_p(klon,klev),rnebcon_p(klon,klev),ratqs_p(klon,klev)
+      REAL run_off_lic_0_p(klon)
+      
+      REAL rlat(klon2), rlon(klon2)
+      REAL tsol(klon2,nbsrf)
+      REAL tsoil(klon2,nsoilmx,nbsrf)
+      REAL deltat(klon2)
+      REAL qsurf(klon2,nbsrf)
+      REAL qsol(klon2)
+      REAL snow(klon2,nbsrf)
+      REAL albedo(klon2,nbsrf)
+      REAL alblw(klon2,nbsrf)
+      REAL evap(klon2,nbsrf)
+      REAL rain_fall(klon2)
+      REAL snow_fall(klon2)
+      real solsw(klon2)
+      real sollw(klon2)
+      real fder(klon2)
+      REAL radsol(klon2)
+      REAL frugs(klon2,nbsrf)
+      REAL agesno(klon2,nbsrf)
+      REAL zmea(klon2)
+      REAL zstd(klon2)
+      REAL zsig(klon2)
+      REAL zgam(klon2)
+      REAL zthe(klon2)
+      REAL zpic(klon2)
+      REAL zval(klon2)
+      REAL rugsrel(klon2)
+      REAL pctsrf(klon2, nbsrf)
+      REAL t_ancien(klon2,klev), q_ancien(klon2,klev)
+      real clwcon(klon2,klev),rnebcon(klon2,klev),ratqs(klon2,klev)
       REAL run_off_lic_0(klon)
 c
@@ -71,4 +103,42 @@
       CHARACTER*2 str2
 c
+
+      call GatherField( rlat_p,rlat,1)
+      call GatherField( rlon_p,rlon,1)
+      call GatherField( tsol_p,tsol,nbsrf)
+      call GatherField( tsoil_p,tsoil,nsoilmx*nbsrf)
+      call GatherField( deltat_p,deltat,1)
+      call GatherField( qsurf_p,qsurf,nbsrf)
+      call GatherField( qsol_p,qsol,1)
+      call GatherField( snow_p,snow,nbsrf)
+      call GatherField( albedo_p,albedo,nbsrf)
+      call GatherField( alblw_p,alblw,nbsrf)
+      call GatherField( evap_p,evap,nbsrf)
+      call GatherField( radsol_p,radsol,1)
+      call GatherField( rain_fall_p,rain_fall,1)
+      call GatherField( snow_fall_p,snow_fall,1)
+      call GatherField( sollw_p,sollw,1)
+      call GatherField( solsw_p,solsw,1)
+      call GatherField( fder_p,fder,1)
+      call GatherField( frugs_p,frugs,nbsrf)
+      call GatherField( agesno_p,agesno,nbsrf)
+      call GatherField( zmea_p,zmea,1)
+      call GatherField( zstd_p,zstd,1)
+      call GatherField( zsig_p,zsig,1)
+      call GatherField( zgam_p,zgam,1)
+      call GatherField( zthe_p,zthe,1)
+      call GatherField( zpic_p,zpic,1)
+      call GatherField( zval_p,zval,1)
+      call GatherField( rugsrel_p,rugsrel,1)
+      call GatherField( pctsrf_p,pctsrf, nbsrf)
+      call GatherField( run_off_lic_0_p,run_off_lic_0,1)
+      call GatherField( t_ancien_p,t_ancien,klev)
+      call GatherField( q_ancien_p,q_ancien,klev)
+      call GatherField( rnebcon_p,rnebcon,klev)
+      call GatherField( clwcon_p,clwcon,klev)
+      call GatherField( ratqs_p,ratqs,klev)
+      
+      if (phy_rank==0) then
+      
       ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -780,4 +850,5 @@
       ierr = NF_CLOSE(nid)
 c
+      endif   ! phy_rank==0
       RETURN
       END
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/physiq.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/physiq.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/physiq.F	(revision 634)
@@ -15,4 +15,13 @@
       USE ioipsl
       USE histcom
+      USE comgeomphy
+      USE write_field
+      USE write_field_p
+      USE dimphy
+      USE iophy
+c$$$      USE misc_mod, mydebug=>debug
+#ifdef CPP_PARALLEL
+      USE vampir
+#endif
 #ifdef INCA
       USE chemshut
@@ -35,11 +44,11 @@
 c   CLEFS CPP POUR LES IO
 c   =====================
-#define histhf
+c#define histhf
 #define histday
 #define histmth
-#define histins
+c#define histins
 c#define histISCCP
-#define histREGDYN
-#define histmthNMC
+c#define histREGDYN
+c#define histmthNMC
 c======================================================================
 c    modif   ( P. Le Van ,  12/10/98 )
@@ -77,5 +86,7 @@
       integer jjmp1
       parameter (jjmp1=jjm+1-1/jjm)
-#include "dimphy.h"
+      integer iip1
+      parameter (iip1=iim+1)
+cym#include "dimphy.h"
 #include "regdim.h"
 #include "indicesol.h"
@@ -85,5 +96,5 @@
 #include "logic.h"
 #include "temps.h"
-#include "comgeomphy.h"
+cym#include "comgeomphy.h"
 #include "advtrac.h"
 #include "iniprint.h"
@@ -161,6 +172,6 @@
       REAL fm_therm(klon,klev+1)
       REAL entr_therm(klon,klev)
-      real q2(klon,klev+1,nbsrf)
-      save q2
+      real,allocatable,save :: q2(:,:,:)
+cym      save q2
 c======================================================================
 c
@@ -194,6 +205,6 @@
       REAL qx(klon,klev,nqmax)
 
-      REAL t_ancien(klon,klev), q_ancien(klon,klev)
-      SAVE t_ancien, q_ancien
+      REAL,allocatable,save :: t_ancien(:,:), q_ancien(:,:)
+cym      SAVE t_ancien, q_ancien
       LOGICAL ancien_ok
       SAVE ancien_ok
@@ -214,27 +225,27 @@
       real da(klon,klev),phi(klon,klev,klev),mp(klon,klev)
 
-      INTEGER klevp1, klevm1
-      PARAMETER(klevp1=klev+1,klevm1=klev-1)
-#include "raddim.h"
+cym      INTEGER klevp1, klevm1
+cym      PARAMETER(klevp1=klev+1,klevm1=klev-1)
+cym#include "raddim.h"
 c
 cIM 080304   REAL swdn0(klon,2), swdn(klon,2), swup0(klon,2), swup(klon,2)
-      REAL swdn0(klon,klevp1), swdn(klon,klevp1)
-      REAL swup0(klon,klevp1), swup(klon,klevp1)
-      SAVE swdn0 , swdn, swup0, swup
-c
-      REAL SWdn200clr(klon), SWdn200(klon)
-      REAL SWup200clr(klon), SWup200(klon)
-      SAVE SWdn200clr, SWdn200, SWup200clr, SWup200
-c
-      REAL lwdn0(klon,klevp1), lwdn(klon,klevp1)
-      REAL lwup0(klon,klevp1), lwup(klon,klevp1)
-      SAVE lwdn0 , lwdn, lwup0, lwup 
-c
-      REAL LWdn200clr(klon), LWdn200(klon)
-      REAL LWup200clr(klon), LWup200(klon)
-      SAVE LWdn200clr, LWdn200, LWup200clr, LWup200
-c
-      REAL LWdnTOA(klon), LWdnTOAclr(klon)
-      SAVE LWdnTOA, LWdnTOAclr
+      REAL,allocatable,save :: swdn0(:,:), swdn(:,:)
+      REAL,allocatable,save :: swup0(:,:), swup(:,:)
+cym      SAVE swdn0 , swdn, swup0, swup
+c
+      REAL,allocatable,save :: SWdn200clr(:), SWdn200(:)
+      REAL,allocatable,save :: SWup200clr(:), SWup200(:)
+cym      SAVE SWdn200clr, SWdn200, SWup200clr, SWup200
+c
+      REAL,allocatable,save :: lwdn0(:,:), lwdn(:,:)
+      REAL,allocatable,save :: lwup0(:,:), lwup(:,:)
+cym      SAVE lwdn0 , lwdn, lwup0, lwup 
+c
+      REAL,allocatable,save :: LWdn200clr(:), LWdn200(:)
+      REAL,allocatable,save :: LWup200clr(:), LWup200(:)
+cym      SAVE LWdn200clr, LWdn200, LWup200clr, LWup200
+c
+      REAL,allocatable,save :: LWdnTOA(:), LWdnTOAclr(:)
+cym      SAVE LWdnTOA, LWdnTOAclr
 c
 c vents meridien et zonal a un niveau de pression
@@ -296,6 +307,6 @@
 cv3.4
       INTEGER debug, debugcol
-      INTEGER npoints
-      PARAMETER(npoints=klon) 
+cym      INTEGER npoints
+cym      PARAMETER(npoints=klon) 
 c
       INTEGER sunlit(klon) !sunlit=1 if day; sunlit=0 if night
@@ -457,12 +468,12 @@
       SAVE radpas                 ! frequence d'appel rayonnement
 c
-      REAL radsol(klon)
-      SAVE radsol               ! bilan radiatif au sol calcule par code radiatif
-c
-      REAL rlat(klon)
-      SAVE rlat                   ! latitude pour chaque point
-c
-      REAL rlon(klon)
-      SAVE rlon                   ! longitude pour chaque point
+      REAL,allocatable,save :: radsol(:)
+cym      SAVE radsol               ! bilan radiatif au sol calcule par code radiatif
+c
+      REAL,allocatable,save :: rlat(:)
+cym      SAVE rlat                   ! latitude pour chaque point
+c
+      REAL,allocatable,save :: rlon(:)
+cym      SAVE rlon                   ! longitude pour chaque point
 c
 cc      INTEGER iflag_con
@@ -478,31 +489,31 @@
       real slp(klon) ! sea level pressure
 
-      REAL ftsol(klon,nbsrf)
-      SAVE ftsol                  ! temperature du sol
-c
-      REAL ftsoil(klon,nsoilmx,nbsrf)
-      SAVE ftsoil                 ! temperature dans le sol
-c
-      REAL fevap(klon,nbsrf)
-      SAVE fevap                 ! evaporation
-      REAL fluxlat(klon,nbsrf)
-      SAVE fluxlat
-c
-      REAL deltat(klon)
-      SAVE deltat                 ! ecart avec la SST de reference
-c
-      REAL fqsurf(klon,nbsrf)
-      SAVE fqsurf                 ! humidite de l'air au contact de la surface
-c
-      REAL qsol(klon)
-      SAVE qsol                  ! hauteur d'eau dans le sol
-c
-      REAL fsnow(klon,nbsrf)
-      SAVE fsnow                  ! epaisseur neigeuse
-c
-      REAL falbe(klon,nbsrf)
-      SAVE falbe                  ! albedo par type de surface
-      REAL falblw(klon,nbsrf)
-      SAVE falblw                 ! albedo par type de surface
+      REAL,allocatable,save :: ftsol(:,:)
+cym      SAVE ftsol                  ! temperature du sol
+c
+      REAL,allocatable,save :: ftsoil(:,:,:)
+cym      SAVE ftsoil                 ! temperature dans le sol
+c
+      REAL,allocatable,save :: fevap(:,:)
+cym      SAVE fevap                 ! evaporation
+      REAL,allocatable,save :: fluxlat(:,:)
+cym      SAVE fluxlat
+c
+      REAL,allocatable,save :: deltat(:)
+cym      SAVE deltat                 ! ecart avec la SST de reference
+c
+      REAL,allocatable,save :: fqsurf(:,:)
+cym      SAVE fqsurf                 ! humidite de l'air au contact de la surface
+c
+      REAL,allocatable,save :: qsol(:)
+cym      SAVE qsol                  ! hauteur d'eau dans le sol
+c
+      REAL,allocatable,save :: fsnow(:,:)
+cym      SAVE fsnow                  ! epaisseur neigeuse
+c
+      REAL,allocatable,save :: falbe(:,:)
+cym      SAVE falbe                  ! albedo par type de surface
+      REAL,allocatable,save :: falblw(:,:)
+cym      SAVE falblw                 ! albedo par type de surface
 
 c
@@ -510,57 +521,57 @@
 c  Parametres de l'Orographie a l'Echelle Sous-Maille (OESM):
 c
-      REAL zmea(klon)
-      SAVE zmea                   ! orographie moyenne
-c
-      REAL zstd(klon)
-      SAVE zstd                   ! deviation standard de l'OESM
-c
-      REAL zsig(klon)
-      SAVE zsig                   ! pente de l'OESM
-c
-      REAL zgam(klon)
-      save zgam                   ! anisotropie de l'OESM
-c
-      REAL zthe(klon)
-      SAVE zthe                   ! orientation de l'OESM
-c
-      REAL zpic(klon)
-      SAVE zpic                   ! Maximum de l'OESM
-c
-      REAL zval(klon)
-      SAVE zval                   ! Minimum de l'OESM
-c
-      REAL rugoro(klon)
-      SAVE rugoro                 ! longueur de rugosite de l'OESM
+      REAL,allocatable,save :: zmea(:)
+cym      SAVE zmea                   ! orographie moyenne
+c
+      REAL,allocatable,save :: zstd(:)
+cym      SAVE zstd                   ! deviation standard de l'OESM
+c
+      REAL,allocatable,save :: zsig(:)
+cym      SAVE zsig                   ! pente de l'OESM
+c
+      REAL,allocatable,save :: zgam(:)
+cym      save zgam                   ! anisotropie de l'OESM
+c
+      REAL,allocatable,save :: zthe(:)
+cym      SAVE zthe                   ! orientation de l'OESM
+c
+      REAL,allocatable,save :: zpic(:)
+cym      SAVE zpic                   ! Maximum de l'OESM
+c
+      REAL,allocatable,save :: zval(:)
+cym      SAVE zval                   ! Minimum de l'OESM
+c
+      REAL,allocatable,save :: rugoro(:)
+cym      SAVE rugoro                 ! longueur de rugosite de l'OESM
 c
       REAL zulow(klon),zvlow(klon),zustr(klon), zvstr(klon)
 c
-      REAL zuthe(klon),zvthe(klon)
-      SAVE zuthe
-      SAVE zvthe
+      REAL,allocatable,save :: zuthe(:),zvthe(:)
+cym      SAVE zuthe
+cym      SAVE zvthe
       INTEGER igwd,idx(klon),itest(klon)
 c
-      REAL agesno(klon,nbsrf)
-      SAVE agesno                 ! age de la neige
-c
-      REAL alb_neig(klon)
-      SAVE alb_neig               ! albedo de la neige
-c
-      REAL run_off_lic_0(klon)
-      SAVE run_off_lic_0
+      REAL,allocatable,save :: agesno(:,:)
+cym      SAVE agesno                 ! age de la neige
+c
+      REAL,allocatable,save :: alb_neig(:)
+cym      SAVE alb_neig               ! albedo de la neige
+c
+      REAL,allocatable,save :: run_off_lic_0(:)
+cym      SAVE run_off_lic_0
 cKE43
 c Variables liees a la convection de K. Emanuel (sb):
 c
-      REAL ema_workcbmf(klon)   ! cloud base mass flux
-      SAVE ema_workcbmf
-
-      REAL ema_cbmf(klon)       ! cloud base mass flux
-      SAVE ema_cbmf
-
-      REAL ema_pcb(klon)        ! cloud base pressure
-      SAVE ema_pcb
-
-      REAL ema_pct(klon)        ! cloud top pressure
-      SAVE ema_pct
+      REAL,allocatable,save :: ema_workcbmf(:)   ! cloud base mass flux
+cym      SAVE ema_workcbmf
+
+      REAL,allocatable,save :: ema_cbmf(:)       ! cloud base mass flux
+cym      SAVE ema_cbmf
+
+      REAL,allocatable,save :: ema_pcb(:)        ! cloud base pressure
+cym      SAVE ema_pcb
+
+      REAL,allocatable,save :: ema_pct(:)        ! cloud top pressure
+cym      SAVE ema_pct
 
       REAL bas, top             ! cloud base and top levels
@@ -568,14 +579,14 @@
       SAVE top
 
-      REAL Ma(klon,klev)        ! undilute upward mass flux
-      SAVE Ma
-      REAL qcondc(klon,klev)    ! in-cld water content from convect
-      SAVE qcondc 
-      REAL ema_work1(klon, klev), ema_work2(klon, klev)
-      SAVE ema_work1, ema_work2
+      REAL,allocatable,save :: Ma(:,:)        ! undilute upward mass flux
+cym      SAVE Ma
+      REAL,allocatable,save :: qcondc(:,:)    ! in-cld water content from convect
+cym      SAVE qcondc 
+      REAL,allocatable,save :: ema_work1(:, :), ema_work2(:, :)
+cym      SAVE ema_work1, ema_work2
       REAL wdn(klon), tdn(klon), qdn(klon)
 
-      REAL wd(klon) ! sb
-      SAVE wd       ! sb
+      REAL,allocatable,save :: wd(:) ! sb
+cym      SAVE wd       ! sb
 
 c Variables locales pour la couche limite (al1):
@@ -604,10 +615,10 @@
 c$$$      PARAMETER (offline=.false.)
 c$$$      INTEGER physid
-      REAL pfrac_impa(klon,klev)! Produits des coefs lessivage impaction
-      save pfrac_impa
-      REAL pfrac_nucl(klon,klev)! Produits des coefs lessivage nucleation
-      save pfrac_nucl
-      REAL pfrac_1nucl(klon,klev)! Produits des coefs lessi nucl (alpha = 1)
-      save pfrac_1nucl
+      REAL,allocatable,save :: pfrac_impa(:,:)! Produits des coefs lessivage impaction
+cym      save pfrac_impa
+      REAL,allocatable,save :: pfrac_nucl(:,:)! Produits des coefs lessivage nucleation
+cym      save pfrac_nucl
+      REAL,allocatable,save :: pfrac_1nucl(:,:)! Produits des coefs lessi nucl (alpha = 1)
+cym      save pfrac_1nucl
       REAL frac_impa(klon,klev) ! fractions d'aerosols lessivees (impaction)
       REAL frac_nucl(klon,klev) ! idem (nucleation)
@@ -618,22 +629,22 @@
 
 cAA
-      REAL rain_fall(klon) ! pluie
-      REAL snow_fall(klon) ! neige
-      save snow_fall, rain_fall
+      REAL,allocatable,save :: rain_fall(:) ! pluie
+      REAL,allocatable,save :: snow_fall(:) ! neige
+cym      save snow_fall, rain_fall
 cIM 050204 BEG
-      REAL total_rain(klon), nday_rain(klon)
-      save total_rain, nday_rain
+      REAL,allocatable,save :: total_rain(:), nday_rain(:)
+cym      save total_rain, nday_rain
 cIM 050204 END
       REAL evap(klon), devap(klon) ! evaporation et sa derivee
       REAL sens(klon), dsens(klon) ! chaleur sensible et sa derivee
-      REAL dlw(klon)    ! derivee infra rouge
+      REAL,allocatable,save :: dlw(:)    ! derivee infra rouge
 cym
-      SAVE dlw
+cym      SAVE dlw
 cym
       REAL bils(klon) ! bilan de chaleur au sol
       REAL wfbils(klon,nbsrf) ! bilan de chaleur au sol, pour chaque
 C                             ! type de sous-surface et pondere par la fraction
-      REAL fder(klon) ! Derive de flux (sensible et latente) 
-      save fder
+      REAL,allocatable,save :: fder(:) ! Derive de flux (sensible et latente) 
+cym      save fder
       REAL ve(klon) ! integr. verticale du transport meri. de l'energie
       REAL vq(klon) ! integr. verticale du transport meri. de l'eau
@@ -641,27 +652,30 @@
       REAL uq(klon) ! integr. verticale du transport zonal de l'eau
 c
-      REAL frugs(klon,nbsrf) ! longueur de rugosite
-      save frugs
+      REAL,allocatable,save :: frugs(:,:) ! longueur de rugosite
+cym      save frugs
       REAL zxrugs(klon) ! longueur de rugosite
 c
 c Conditions aux limites
 c
+      INTEGER :: iii
       INTEGER julien
 c
       INTEGER lmt_pas
       SAVE lmt_pas                ! frequence de mise a jour
-      REAL pctsrf(klon,nbsrf)
+      REAL,allocatable,save :: pctsrf(:,:)
 cIM
       REAL pctsrf_new(klon,nbsrf) !pourcentage surfaces issus d'ORCHIDEE
-      REAL paire_ter(klon)        !surfaces terre 
+cym      REAL paire_ter(klon)        !surfaces terre 
+      REAL,allocatable,save ::  paire_ter(:)        !surfaces terre 
+    
 cIM
-      SAVE pctsrf                 ! sous-fraction du sol
-      REAL albsol(klon)
-      SAVE albsol                 ! albedo du sol total
-      REAL albsollw(klon)
-      SAVE albsollw                 ! albedo du sol total
-
-      REAL wo(klon,klev)
-      SAVE wo                     ! ozone
+cym      SAVE pctsrf                 ! sous-fraction du sol
+      REAL,allocatable,save :: albsol(:)
+cym      SAVE albsol                 ! albedo du sol total
+      REAL,allocatable,save :: albsollw(:)
+cym      SAVE albsollw                 ! albedo du sol total
+
+      REAL,allocatable,save :: wo(:,:)
+cym     SAVE wo                     ! ozone
 c======================================================================
 c
@@ -702,7 +716,7 @@
 c Variables locales
 c
-      real clwcon(klon,klev),rnebcon(klon,klev)
+      real,allocatable,save :: clwcon(:,:),rnebcon(:,:)
       real clwcon0(klon,klev),rnebcon0(klon,klev)
-      save rnebcon, clwcon
+cym      save rnebcon, clwcon
 
       REAL rhcl(klon,klev)    ! humiditi relative ciel clair
@@ -725,24 +739,24 @@
       REAL zxfluxv(klon, klev)
 CXXX
-      REAL heat(klon,klev)    ! chauffage solaire
-      REAL heat0(klon,klev)   ! chauffage solaire ciel clair
-      REAL cool(klon,klev)    ! refroidissement infrarouge
-      REAL cool0(klon,klev)   ! refroidissement infrarouge ciel clair
-      REAL topsw(klon), toplw(klon), solsw(klon), sollw(klon)
-      real sollwdown(klon)    ! downward LW flux at surface
+      REAL,allocatable,save :: heat(:,:)    ! chauffage solaire
+      REAL,allocatable,save :: heat0(:,:)   ! chauffage solaire ciel clair
+      REAL,allocatable,save :: cool(:,:)    ! refroidissement infrarouge
+      REAL,allocatable,save :: cool0(:,:)   ! refroidissement infrarouge ciel clair
+      REAL,allocatable,save :: topsw(:), toplw(:), solsw(:), sollw(:)
+      real,allocatable,save :: sollwdown(:)    ! downward LW flux at surface
 cIM BEG
-      real sollwdownclr(klon)    ! downward CS LW flux at surface 
-      real toplwdown(klon)       ! downward CS LW flux at TOA
-      real toplwdownclr(klon)    ! downward CS LW flux at TOA
+      real,allocatable,save :: sollwdownclr(:)    ! downward CS LW flux at surface 
+      real,allocatable,save :: toplwdown(:)       ! downward CS LW flux at TOA
+      real,allocatable,save :: toplwdownclr(:)    ! downward CS LW flux at TOA
 cIM END
-      REAL topsw0(klon), toplw0(klon), solsw0(klon), sollw0(klon)
-      REAL albpla(klon)
+      REAL,allocatable,save :: topsw0(:),toplw0(:),solsw0(:),sollw0(:)
+      REAL,allocatable,save :: albpla(:)
       REAL fsollw(klon, nbsrf)   ! bilan flux IR pour chaque sous surface
       REAL fsolsw(klon, nbsrf)   ! flux solaire absorb. pour chaque sous surface
 c Le rayonnement n'est pas calcule tous les pas, il faut donc
 c                      sauvegarder les sorties du rayonnement
-      SAVE  heat,cool,albpla,topsw,toplw,solsw,sollw,sollwdown
-      SAVE  sollwdownclr, toplwdown, toplwdownclr
-      SAVE  topsw0,toplw0,solsw0,sollw0, heat0, cool0
+cym      SAVE  heat,cool,albpla,topsw,toplw,solsw,sollw,sollwdown
+cym      SAVE  sollwdownclr, toplwdown, toplwdownclr
+cym      SAVE  topsw0,toplw0,solsw0,sollw0, heat0, cool0
 c
       INTEGER itaprad
@@ -785,12 +799,12 @@
       REAL dnwd0(klon,klev)     ! unsaturated downdraft mass flux
       REAL tvp(klon,klev)       ! virtual temp of lifted parcel
-      REAL cape(klon)           ! CAPE
-      SAVE cape
+      REAL,allocatable,save :: cape(:)           ! CAPE
+cym      SAVE cape
       CHARACTER*40 capemaxcels  !max(CAPE)
 
-      REAL pbase(klon)          ! cloud base pressure
-      SAVE pbase
-      REAL bbase(klon)          ! cloud base buoyancy
-      SAVE bbase
+      REAL,allocatable,save :: pbase(:)          ! cloud base pressure
+cym      SAVE pbase
+      REAL,allocatable,save :: bbase(:)          ! cloud base buoyancy
+cym      SAVE bbase
       REAL rflag(klon)          ! flag fonctionnement de convect
       INTEGER iflagctrl(klon)          ! flag fonctionnement de convect
@@ -829,7 +843,7 @@
       REAL prfl(klon,klev+1), psfl(klon,klev+1)
 c
-      INTEGER ibas_con(klon), itop_con(klon)
+      INTEGER,allocatable,save :: ibas_con(:), itop_con(:)
 cym
-      SAVE ibas_con,itop_con
+cym      SAVE ibas_con,itop_con
 cym
       REAL rain_con(klon), rain_lsc(klon)
@@ -846,7 +860,9 @@
       REAL d_u_oli(klon,klev), d_v_oli(klon,klev) !tendances dues a oro et lif 
 
-      REAL ratqs(klon,klev),ratqss(klon,klev),ratqsc(klon,klev)
+      REAL,allocatable,save :: ratqs(:,:)
+      REAL ratqss(klon,klev),ratqsc(klon,klev)
       real ratqsbas,ratqshaut
-      save ratqsbas,ratqshaut, ratqs
+cym      save ratqsbas,ratqshaut, ratqs
+      save ratqsbas,ratqshaut
       real zpt_conv(klon,klev)
 
@@ -956,6 +972,6 @@
 cjq   Aerosol effects (Johannes Quaas, 27/11/2003)
       REAL sulfate(klon, klev) ! SO4 aerosol concentration [ug/m3]
-      REAL sulfate_pi(klon, klev) ! SO4 aerosol concentration [ug/m3] (pre-industrial value)
-      SAVE sulfate_pi
+      REAL,allocatable,save :: sulfate_pi(:,:) ! SO4 aerosol concentration [ug/m3] (pre-industrial value)
+cym      SAVE sulfate_pi
 
       REAL cldtaupi(klon,klev)  ! Cloud optical thickness for pre-industrial (pi) aerosols
@@ -990,7 +1006,101 @@
 c Declaration des constantes et des fonctions thermodynamiques
 c
+      LOGICAL :: first=.true.
 #include "YOMCST.h"
 #include "YOETHF.h"
 #include "FCTTRE.h"
+
+      REAL Field_tmp(klon2,klevp1)
+      
+      if (first) then 
+      
+      allocate( t_ancien(klon,klev), q_ancien(klon,klev))
+      allocate( q2(klon,klev+1,nbsrf))
+      allocate( swdn0(klon,klevp1), swdn(klon,klevp1))
+      allocate( swup0(klon,klevp1), swup(klon,klevp1))
+      allocate( SWdn200clr(klon), SWdn200(klon))
+      allocate( SWup200clr(klon), SWup200(klon))
+      allocate( lwdn0(klon,klevp1), lwdn(klon,klevp1))
+      allocate( lwup0(klon,klevp1), lwup(klon,klevp1))
+      allocate( LWdn200clr(klon), LWdn200(klon))
+      allocate( LWup200clr(klon), LWup200(klon))
+      allocate( LWdnTOA(klon), LWdnTOAclr(klon))
+      allocate( radsol(klon))
+      allocate( rlat(klon))
+      allocate( rlon(klon))
+      allocate( ftsol(klon,nbsrf))
+      allocate( ftsoil(klon,nsoilmx,nbsrf))
+      allocate( fevap(klon,nbsrf))
+      allocate( fluxlat(klon,nbsrf))
+      allocate( deltat(klon))
+      allocate( fqsurf(klon,nbsrf))
+      allocate( qsol(klon))
+      allocate( fsnow(klon,nbsrf))
+      allocate( falbe(klon,nbsrf))
+      allocate( falblw(klon,nbsrf))
+      allocate( zmea(klon))
+      allocate( zstd(klon))
+      allocate( zsig(klon))
+      allocate( zgam(klon))
+      allocate( zthe(klon))
+      allocate( zpic(klon))
+      allocate( zval(klon))
+      allocate( rugoro(klon))
+      allocate( zuthe(klon),zvthe(klon))
+      allocate( agesno(klon,nbsrf))
+      allocate( alb_neig(klon))
+      allocate( run_off_lic_0(klon))
+      allocate( ema_workcbmf(klon))   
+      allocate( ema_cbmf(klon)) 
+      allocate( ema_pcb(klon))
+      allocate( ema_pct(klon))  
+      allocate( Ma(klon,klev) )
+      allocate( qcondc(klon,klev))  
+      allocate( ema_work1(klon, klev), ema_work2(klon, klev))
+      allocate( wd(klon) )
+      allocate( pfrac_impa(klon,klev))
+      allocate( pfrac_nucl(klon,klev))
+      allocate( pfrac_1nucl(klon,klev))
+      allocate( rain_fall(klon) )
+      allocate( snow_fall(klon) )
+      allocate( total_rain(klon), nday_rain(klon))
+      allocate( dlw(klon)   )
+      allocate( fder(klon) )
+      allocate( frugs(klon,nbsrf) )
+      allocate( pctsrf(klon,nbsrf))
+      allocate( albsol(klon))
+      allocate( albsollw(klon))
+      allocate( wo(klon,klev))
+      allocate( clwcon(klon,klev),rnebcon(klon,klev))
+      allocate( heat(klon,klev)    )
+      allocate( heat0(klon,klev)  )
+      allocate( cool(klon,klev)    )
+      allocate( cool0(klon,klev)   )
+      allocate( topsw(klon), toplw(klon), solsw(klon), sollw(klon))
+      allocate( sollwdown(klon)    )
+      allocate( sollwdownclr(klon)  ) 
+      allocate( toplwdown(klon)      )
+      allocate( toplwdownclr(klon)   )
+      allocate( topsw0(klon), toplw0(klon), solsw0(klon), sollw0(klon))
+      allocate( albpla(klon))
+      allocate( cape(klon)   )        
+      allocate( pbase(klon)   )     
+      allocate( bbase(klon)    )     
+      allocate( ibas_con(klon), itop_con(klon))
+      allocate( ratqs(klon,klev))
+      allocate( sulfate_pi(klon, klev)) 
+      allocate( paire_ter(klon))
+      
+        paire_ter(:)=0.    
+        clwcon(:,:)=0.
+	rnebcon(:,:)=0.
+	ratqs(:,:)=0.
+	run_off_lic_0(:)=0.
+	sollw(:)=0.
+	ema_work1(:,:)=0.
+	ema_work2(:,:)=0.
+	
+	first=.false.
+      endif 
 c======================================================================
 !rv
@@ -1164,5 +1274,5 @@
           DO i = 1, klon
            ibas_con(i) = 1
-           itop_con(i) = 1
+           itop_con(i) = klev+1
           ENDDO
 cIM15/11/02 rajout initialisation ibas_con,itop_con cf. SB =>END
@@ -1292,4 +1402,6 @@
 c
 #ifdef INCA
+           call VTe(VTphysiq)
+	   call VTb(VTinca)
            iii = MOD(NINT(xjour),360)
            calday = FLOAT(iii) + gmtime
@@ -1314,4 +1426,6 @@
            WRITE(lunout,*) 'OK.'
 #endif
+      call VTe(VTinca)
+      call VTb(VTphysiq)
 #endif
 c
@@ -1538,5 +1652,11 @@
       fder = dlw
 
-
+c$$$      if (mydebug) then
+c$$$        call WriteField_phy_p('u_seri',u_seri,llm)
+c$$$        call WriteField_phy_p('v_seri',v_seri,llm)
+c$$$        call WriteField_phy_p('t_seri',t_seri,llm)
+c$$$	call WriteField_phy_p('q_seri',q_seri,llm)
+c$$$      endif
+  
       CALL clmain(dtime,itap,date0,pctsrf,pctsrf_new,
      e            t_seri,q_seri,u_seri,v_seri,
@@ -1596,4 +1716,12 @@
       ENDDO
       ENDDO
+
+c$$$      if (mydebug) then
+c$$$        call WriteField_phy_p('u_seri',u_seri,llm)
+c$$$        call WriteField_phy_p('v_seri',v_seri,llm)
+c$$$        call WriteField_phy_p('t_seri',t_seri,llm)
+c$$$	call WriteField_phy_p('q_seri',q_seri,llm)
+c$$$      endif
+
 c
       IF (if_ebil.ge.2) THEN 
@@ -1833,4 +1961,11 @@
         ENDDO
       ENDDO
+
+c$$$      if (mydebug) then
+c$$$        call WriteField_phy_p('u_seri',u_seri,llm)
+c$$$        call WriteField_phy_p('v_seri',v_seri,llm)
+c$$$        call WriteField_phy_p('t_seri',t_seri,llm)
+c$$$	call WriteField_phy_p('q_seri',q_seri,llm)
+c$$$      endif
 c
       IF (if_ebil.ge.2) THEN 
@@ -2033,4 +2168,12 @@
      s      , fs_bound, fq_bound )
       END IF 
+
+c$$$      if (mydebug) then
+c$$$        call WriteField_phy_p('u_seri',u_seri,llm)
+c$$$        call WriteField_phy_p('v_seri',v_seri,llm)
+c$$$        call WriteField_phy_p('t_seri',t_seri,llm)
+c$$$	call WriteField_phy_p('q_seri',q_seri,llm)
+c$$$      endif
+
 c
 c-------------------------------------------------------------------
@@ -2252,5 +2395,7 @@
      &     boxptop)
 
-
+      
+      if (monocpu) then
+      
 c passage de la grille (klon,7,7) a (iim,jjmp1,7,7)
       DO l=1, lmaxm1
@@ -2301,4 +2446,6 @@
        ENDDO
       ENDDO
+      
+      endif ! monocpu
 c
       ENDIF !ok_isccp
@@ -2380,4 +2527,6 @@
 
 #ifdef INCA
+      call VTe(VTphysiq)
+      call VTb(VTinca)
            calday = FLOAT(julien) + gmtime
 
@@ -2433,4 +2582,6 @@
            WRITE(lunout,*)'OK.'
 #endif
+      call VTe(VTinca)
+      call VTb(VTphysiq)
 #endif
 c     
@@ -2471,4 +2622,12 @@
      .               + falblw(i,is_sic) * pctsrf(i,is_sic)
       ENDDO
+
+c$$$      if (mydebug) then
+c$$$        call WriteField_phy_p('u_seri',u_seri,llm)
+c$$$        call WriteField_phy_p('v_seri',v_seri,llm)
+c$$$        call WriteField_phy_p('t_seri',t_seri,llm)
+c$$$	call WriteField_phy_p('q_seri',q_seri,llm)
+c$$$      endif
+      
       CALL radlwsw ! nouveau rayonnement (compatible Arpege-IFS)
      e            (dist, rmu0, fract, 
@@ -2500,4 +2659,11 @@
       ENDDO
 c
+c$$$      if (mydebug) then
+c$$$        call WriteField_phy_p('u_seri',u_seri,llm)
+c$$$        call WriteField_phy_p('v_seri',v_seri,llm)
+c$$$        call WriteField_phy_p('t_seri',t_seri,llm)
+c$$$	call WriteField_phy_p('q_seri',q_seri,llm)
+c$$$      endif
+      
       IF (if_ebil.ge.2) THEN 
         ztit='after rad'
@@ -2585,4 +2751,11 @@
       ENDIF ! fin de test sur ok_orodr
 c
+c$$$      if (mydebug) then
+c$$$        call WriteField_phy_p('u_seri',u_seri,llm)
+c$$$        call WriteField_phy_p('v_seri',v_seri,llm)
+c$$$        call WriteField_phy_p('t_seri',t_seri,llm)
+c$$$	call WriteField_phy_p('q_seri',q_seri,llm)
+c$$$      endif
+      
       IF (ok_orolf) THEN
 c
@@ -2617,4 +2790,12 @@
       ENDIF ! fin de test sur ok_orolf
 c
+
+c$$$      if (mydebug) then
+c$$$        call WriteField_phy_p('u_seri',u_seri,llm)
+c$$$        call WriteField_phy_p('v_seri',v_seri,llm)
+c$$$        call WriteField_phy_p('t_seri',t_seri,llm)
+c$$$	call WriteField_phy_p('q_seri',q_seri,llm)
+c$$$      endif
+
       IF (if_ebil.ge.2) THEN 
         ztit='after orography'
@@ -2852,4 +3033,11 @@
 c Convertir les incrementations en tendances
 c
+c$$$      if (mydebug) then
+c$$$        call WriteField_phy_p('u_seri',u_seri,llm)
+c$$$        call WriteField_phy_p('v_seri',v_seri,llm)
+c$$$        call WriteField_phy_p('t_seri',t_seri,llm)
+c$$$	call WriteField_phy_p('q_seri',q_seri,llm)
+c$$$      endif
+
       DO k = 1, klev
       DO i = 1, klon
@@ -2918,4 +3106,6 @@
 
 #ifdef INCA
+      call VTe(VTphysiq)
+      call VTb(VTinca)
 #ifdef INCAINFO
            WRITE(lunout,*)'Appel CHEMHOOK_END ...'
@@ -2945,4 +3135,6 @@
            WRITE(lunout,*)'OK.'
 #endif
+      call VTe(VTinca)
+      call VTb(VTphysiq)
 #endif
 
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phystokenc.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phystokenc.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phystokenc.F	(revision 634)
@@ -13,5 +13,6 @@
       USE ioipsl
       USE histcom
-
+      USE dimphy
+      USE iophy
       IMPLICIT none
 
@@ -23,5 +24,5 @@
 c======================================================================
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "tracstoke.h"
 #include "indicesol.h"
@@ -54,5 +55,6 @@
       REAL pen_d(klon,klev) ! flux entraine dans le panache descendant
       REAL pde_d(klon,klev) ! flux detraine dans le panache descendant
-	real pt(klon,klev),t(klon,klev)
+      real pt(klon,klev)
+      REAL,allocatable,save :: t(:,:)
 c
       REAL rlon(klon), rlat(klon), dtime
@@ -71,6 +73,7 @@
 	real fm_therm1(klon,klev)
       REAL pentr_therm(klon,klev)
-      REAL entr_therm(klon,klev)
-      REAL fm_therm(klon,klev)
+    
+      REAL,allocatable,save :: entr_therm(:,:)
+      REAL,allocatable,save :: fm_therm(:,:)
 c
 c   Lessivage:
@@ -88,14 +91,17 @@
       INTEGER i, k
 c
-      REAL mfu(klon,klev)  ! flux de masse dans le panache montant
-      REAL mfd(klon,klev)  ! flux de masse dans le panache descendant
-      REAL en_u(klon,klev) ! flux entraine dans le panache montant
-      REAL de_u(klon,klev) ! flux detraine dans le panache montant
-      REAL en_d(klon,klev) ! flux entraine dans le panache descendant
-      REAL de_d(klon,klev) ! flux detraine dans le panache descendant
-      REAL coefh(klon,klev) ! flux detraine dans le panache descendant
-
-      REAL pyu1(klon),pyv1(klon)
-      REAL pftsol(klon,nbsrf),ppsrf(klon,nbsrf)
+      REAL,allocatable,save :: mfu(:,:)  ! flux de masse dans le panache montant
+      REAL,allocatable,save :: mfd(:,:)  ! flux de masse dans le panache descendant
+      REAL,allocatable,save :: en_u(:,:) ! flux entraine dans le panache montant
+      REAL,allocatable,save :: de_u(:,:) ! flux detraine dans le panache montant
+      REAL,allocatable,save :: en_d(:,:) ! flux entraine dans le panache descendant
+      REAL,allocatable,save :: de_d(:,:) ! flux detraine dans le panache descendant
+      REAL,allocatable,save :: coefh(:,:) ! flux detraine dans le panache descendant
+
+      REAL,allocatable,save :: pyu1(:)
+      REAL,allocatable,save :: pyv1(:)
+      REAL,allocatable,save :: pftsol(:,:)
+      REAL,allocatable,save :: ppsrf(:,:)
+
       real pftsol1(klon),pftsol2(klon),pftsol3(klon),pftsol4(klon)
       real ppsrf1(klon),ppsrf2(klon),ppsrf3(klon),ppsrf4(klon)
@@ -107,10 +113,9 @@
       logical ok_sync
  
-      save t,mfu,mfd,en_u,de_u,en_d,de_d,coefh,dtcum
-	save fm_therm,entr_therm
+      save dtcum
       save iadvtr,irec
-      save pyu1,pyv1,pftsol,ppsrf
 
       data iadvtr,irec/0,1/
+      logical,save :: first=.true.
 c
 c   Couche limite:
@@ -123,4 +128,24 @@
       print*,'istdyn= ',istdyn
 
+      if (first) then
+      
+        allocate( t(klon,klev))
+        allocate( mfu(klon,klev))  
+        allocate( mfd(klon,klev))  
+        allocate( en_u(klon,klev)) 
+        allocate( de_u(klon,klev)) 
+        allocate( en_d(klon,klev)) 
+        allocate( de_d(klon,klev)) 
+        allocate( coefh(klon,klev)) 
+        allocate( entr_therm(klon,klev))
+        allocate( fm_therm(klon,klev))
+        allocate( pyu1(klon))
+        allocate( pyv1(klon))
+        allocate( pftsol(klon,nbsrf))
+        allocate( ppsrf(klon,nbsrf))
+  
+        first=.false.
+      endif
+      
       IF (iadvtr.eq.0) THEN
 	
@@ -136,10 +161,10 @@
       ndex3d = 0
       i=itap 
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
-      CALL histwrite(physid,"phis",i,zx_tmp_2d,iim*(jjm+1),ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
+      CALL histwrite_phy(physid,"phis",i,pphis)
 c
       i=itap
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,paire,zx_tmp_2d)
-      CALL histwrite(physid,"aire",i,zx_tmp_2d,iim*(jjm+1),ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,paire,zx_tmp_2d)
+      CALL histwrite_phy(physid,"aire",i,paire)
 
       iadvtr=iadvtr+1
@@ -247,29 +272,21 @@
 
 ccccc
-         CALL gr_fi_ecrit(klev,klon,iim,jjm+1, t, zx_tmp_3d)
-         CALL histwrite(physid,"t",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-         CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfu, zx_tmp_3d)
-      CALL histwrite(physid,"mfu",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-	CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfd, zx_tmp_3d)
-      CALL histwrite(physid,"mfd",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_u, zx_tmp_3d)
-      CALL histwrite(physid,"en_u",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_u, zx_tmp_3d)
-      CALL histwrite(physid,"de_u",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_d, zx_tmp_3d)
-      CALL histwrite(physid,"en_d",itap,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_d, zx_tmp_3d)       
-      CALL histwrite(physid,"de_d",itap,zx_tmp_3d,    
-     .                                   iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, coefh, zx_tmp_3d)         
-      CALL histwrite(physid,"coefh",itap,zx_tmp_3d,    
-     .                                   iim*(jjm+1)*klev,ndex3d)	
+cym         CALL gr_fi_ecrit(klev,klon,iim,jjm+1, t, zx_tmp_3d)
+         CALL histwrite_phy(physid,"t",itap,t)
+
+cym         CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfu, zx_tmp_3d)
+      CALL histwrite_phy(physid,"mfu",itap,mfu)
+cym	CALL gr_fi_ecrit(klev,klon,iim,jjm+1, mfd, zx_tmp_3d)
+      CALL histwrite_phy(physid,"mfd",itap,mfd)
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_u, zx_tmp_3d)
+      CALL histwrite_phy(physid,"en_u",itap,en_u)
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_u, zx_tmp_3d)
+      CALL histwrite_phy(physid,"de_u",itap,de_u)
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, en_d, zx_tmp_3d)
+      CALL histwrite_phy(physid,"en_d",itap,en_d)
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, de_d, zx_tmp_3d)       
+      CALL histwrite_phy(physid,"de_d",itap,de_d)
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1, coefh, zx_tmp_3d)         
+      CALL histwrite_phy(physid,"coefh",itap,coefh)	
 
 c ajou...
@@ -280,53 +297,39 @@
 	enddo
 
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, fm_therm1, zx_tmp_3d)
-      CALL histwrite(physid,"fm_th",itap,zx_tmp_3d,
-     .                                 iim*(jjm+1)*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, entr_therm, zx_tmp_3d)
-      CALL histwrite(physid,"en_th",itap,zx_tmp_3d,
-     .                                iim*(jjm+1)*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, fm_therm1, zx_tmp_3d)
+      CALL histwrite_phy(physid,"fm_th",itap,fm_therm1)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, entr_therm, zx_tmp_3d)
+      CALL histwrite_phy(physid,"en_th",itap,entr_therm)
 cccc
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_impa,zx_tmp_3d)
-        CALL histwrite(physid,"frac_impa",itap,zx_tmp_3d,
-     .  iim*(jjm+1)*klev,ndex3d)
-
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_nucl,zx_tmp_3d)
-        CALL histwrite(physid,"frac_nucl",itap,zx_tmp_3d,
-     .  iim*(jjm+1)*klev,ndex3d)
+cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_impa,zx_tmp_3d)
+        CALL histwrite_phy(physid,"frac_impa",itap,frac_impa)
+
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,frac_nucl,zx_tmp_3d)
+        CALL histwrite_phy(physid,"frac_nucl",itap,frac_nucl)
  
-        CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyu1,zx_tmp_2d)
-      CALL histwrite(physid,"pyu1",itap,zx_tmp_2d,iim*(jjm+1),
-     .                                                ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyu1,zx_tmp_2d)
+      CALL histwrite_phy(physid,"pyu1",itap,pyu1)
 	
-	CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyv1,zx_tmp_2d)
-      CALL histwrite(physid,"pyv1",itap,zx_tmp_2d,iim*(jjm+1)
-     .                                                ,ndex2d)
+cym	CALL gr_fi_ecrit(1, klon,iim,jjm+1, pyv1,zx_tmp_2d)
+      CALL histwrite_phy(physid,"pyv1",itap,pyv1)
 	
-	CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol1, zx_tmp_2d)
-      CALL histwrite(physid,"ftsol1",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol2, zx_tmp_2d)
-      CALL histwrite(physid,"ftsol2",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-          CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol3, zx_tmp_2d)
-      CALL histwrite(physid,"ftsol3",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol4, zx_tmp_2d)
-      CALL histwrite(physid,"ftsol4",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-
-        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf1, zx_tmp_2d)
-      CALL histwrite(physid,"psrf1",itap,zx_tmp_2d,   
-     .                                   iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf2, zx_tmp_2d)
-      CALL histwrite(physid,"psrf2",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf3, zx_tmp_2d)
-      CALL histwrite(physid,"psrf3",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf4, zx_tmp_2d)
-      CALL histwrite(physid,"psrf4",itap,zx_tmp_2d,
-     .                                   iim*(jjm+1),ndex2d)
+cym	CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol1, zx_tmp_2d)
+      CALL histwrite_phy(physid,"ftsol1",itap,pftsol1)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol2, zx_tmp_2d)
+      CALL histwrite_phy(physid,"ftsol2",itap,pftsol2)
+cym          CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol3, zx_tmp_2d)
+      CALL histwrite_phy(physid,"ftsol3",itap,pftsol3)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1, pftsol4, zx_tmp_2d)
+      CALL histwrite_phy(physid,"ftsol4",itap,pftsol4)
+
+cym        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf1, zx_tmp_2d)
+      CALL histwrite_phy(physid,"psrf1",itap,ppsrf1)
+cym        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf2, zx_tmp_2d)
+      CALL histwrite_phy(physid,"psrf2",itap,ppsrf2)
+cym        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf3, zx_tmp_2d)
+      CALL histwrite_phy(physid,"psrf3",itap,ppsrf3)
+cym        CALL gr_fi_ecrit(1,klon,iim,jjm+1, ppsrf4, zx_tmp_2d)
+      CALL histwrite_phy(physid,"psrf4",itap,ppsrf4)
 
       if (ok_sync) call histsync(physid)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phytrac.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phytrac.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/phytrac.F	(revision 634)
@@ -64,5 +64,10 @@
 
       USE ioipsl
-
+      USE dimphy
+      USE comgeomphy
+      USE iophy
+#ifdef CPP_PARALLEL
+      USE vampir
+#endif
 #ifdef INCA
       USE sflx
@@ -76,4 +81,7 @@
 #ifdef INCA_AER
       USE AEROSOL_MOD, only : ntr,trmx,trnx
+cym      USE AEROSOL_DIAG, only : cla,las,tausum,angst,aload,scon
+cym     .                            ,scavcoef_st,scavcoef_cv
+cym      USE AEROSOL_PROGNOS, ONLY : md
       USE AEROSOL_DIAG,only : cla,las,tausum,angst,aload,cload,totaerh2o,tau,
      $  emiss20,sconc,scavcoef_st,scavcoef_cv
@@ -103,10 +111,10 @@
 #include "YOMCST.h"
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "indicesol.h"
 #include "temps.h"
 #include "paramet.h"
 #include "control.h"
-#include "comgeomphy.h"
+cym#include "comgeomphy.h"
 #include "advtrac.h"
 c======================================================================
@@ -225,21 +233,22 @@
 cAA ................................................
  
-      REAL trs(klon,nbtr)    ! Conc. radon ds le sol
-      SAVE trs
-
-      REAL masktr(klon,nbtr) ! Masque reservoir de sol traceur
+      REAL,save,allocatable :: trs(:,:)    ! Conc. radon ds le sol
+cym      SAVE trs
+      REAL :: trs_tmp(klon2)
+      
+      REAL,save,allocatable :: masktr(:,:) ! Masque reservoir de sol traceur
 c                            Masque de l'echange avec la surface
 c                           (1 = reservoir) ou (possible => 1 )
-      SAVE masktr
-      REAL fshtr(klon,nbtr)  ! Flux surfacique dans le reservoir de sol
-      SAVE fshtr
-      REAL hsoltr(nbtr)      ! Epaisseur equivalente du reservoir de sol
-      SAVE hsoltr
-      REAL tautr(nbtr)       ! Constante de decroissance radioactive
-      SAVE tautr
-      REAL vdeptr(nbtr)      ! Vitesse de depot sec dans la couche Brownienne
-      SAVE vdeptr
-      REAL scavtr(nbtr)      ! Coefficient de lessivage
-      SAVE scavtr
+cym      SAVE masktr
+      REAL,save,allocatable :: fshtr(:,:)  ! Flux surfacique dans le reservoir de sol
+cym      SAVE fshtr
+      REAL,save,allocatable :: hsoltr(:)      ! Epaisseur equivalente du reservoir de sol
+cym      SAVE hsoltr
+      REAL,save,allocatable :: tautr(:)       ! Constante de decroissance radioactive
+cym      SAVE tautr
+      REAL,save,allocatable :: vdeptr(:)      ! Vitesse de depot sec dans la couche Brownienne
+cym      SAVE vdeptr
+      REAL,save,allocatable :: scavtr(:)      ! Coefficient de lessivage
+cym      SAVE scavtr
 cAA
       CHARACTER*2 itn
@@ -273,11 +282,11 @@
 C nature du traceur
 c
-      logical aerosol(nbtr)  ! Nature du traceur
+      logical,save,allocatable :: aerosol(:)  ! Nature du traceur
 c                            ! aerosol(it) = true  => aerosol 
 c                            ! aerosol(it) = false => gaz 
 c                            ! nat_trac(it) = 1. aerosol
-      logical clsol(nbtr)    ! clsol(it) = true => CL sol calculee
-      logical radio(nbtr)    ! radio(it)=true => decroisssance radioactive
-      save aerosol,clsol,radio
+      logical,save,allocatable :: clsol(:)    ! clsol(it) = true => CL sol calculee
+      logical,save,allocatable :: radio(:)    ! radio(it)=true => decroisssance radioactive
+cym      save aerosol,clsol,radio
 C
 c======================================================================
@@ -298,5 +307,7 @@
       REAL d_tr(klon,klev), d_trs(klon) ! tendances de traceurs 
       REAL d_tr_cl(klon,klev,nbtr) ! tendance de traceurs  couche limite
-      REAL d_tr_cv(klon,klev,nbtr) ! tendance de traceurs  conv pour chq traceur
+      REAL d_tr_cli(klon,klev,nbtr) ! tendance de traceurs  CL pour chq traceur
+      REAL d_tr_cv(klon,klev,nbtr) ! tendance de traceurs  convection
+      REAL d_tr_cvi(klon,klev,nbtr) ! tendance de traceurs  conv pour chq traceur
       REAL d_tr_th(klon,klev,nbtr) ! la tendance des thermiques
       REAL d_tr_dec(klon,klev,nbtr) ! la tendance de la decroissance 
@@ -367,15 +378,5 @@
 #endif
      .                                         /)
-
-
-      REAL, PARAMETER   :: dry_mass = 28.966
-      REAL, POINTER     :: hbuf(:)
-      REAL, ALLOCATABLE :: obuf(:)
-      REAL              :: calday
-      REAL              :: pdel(klon,klev)
-      REAL              :: dummy(klon,klev) = 0.
-#endif
-#ifdef INCA_AER
-      integer la
+      dummy(:,:)=0.
 #endif
 c
@@ -386,4 +387,14 @@
 
          if (debutphy) then
+           allocate( trs(klon,nbtr) )  
+           allocate( masktr(klon,nbtr)) 
+           allocate( fshtr(klon,nbtr) )
+           allocate( hsoltr(nbtr))
+           allocate( tautr(nbtr))
+           allocate( vdeptr(nbtr))
+           allocate( scavtr(nbtr))
+           allocate( aerosol(nbtr))
+           allocate( clsol(nbtr))
+           allocate( radio(nbtr))
 
           ecrit_tra = NINT(86400./pdtphys *ecritphy) 
@@ -416,9 +427,13 @@
 c        print*,'valeur de debut dans phytrac :',debutphy
          trs(:,:) = 0.
-
-         open (99,file='starttrac',status='old',
+         
+       if (phy_rank==0) then
+         trs_tmp(:)=0.
+	 open (99,file='starttrac',status='old',
      .         err=999,form='formatted')
-         read(99,*) (trs(i,1),i=1,klon)
+         read(99,*) (trs_tmp(i),i=1,klon2)
 999      close(99)
+       endif
+       call ScatterField(trs_tmp,trs(:,1),1)
 c         print*, 'apres starttrac'
 
@@ -451,4 +466,6 @@
       endif
 #ifdef INCA
+      call VTe(VTphysiq)
+      call VTb(VTinca)
 !======================================================================
 !     Chimie
@@ -539,4 +556,6 @@
       END DO
 #endif
+      call VTe(VTinca)
+      call VTb(VTphysiq)
 #else
 
@@ -861,10 +880,15 @@
       if (lafin) then
          print*, 'c est la fin de la physique'
-         open (99,file='restarttrac',  form='formatted')
-         do i=1,klon
-             write(99,*) trs(i,1)
-         enddo
-         PRINT*, 'Ecriture du fichier restarttrac'
-         close(99)
+	 
+	 call GatherField(trs(:,1),trs_tmp,1)
+	 if (phy_rank==0) then
+         
+	   open (99,file='restarttrac',  form='formatted')
+           do i=1,klon
+               write(99,*) trs_tmp(i)
+           enddo
+           PRINT*, 'Ecriture du fichier restarttrac'
+           close(99)
+	 endif
       else
          print*, 'physique pas fini'
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/raddim.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/raddim.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/raddim.h	(revision 634)
@@ -1,5 +1,5 @@
 !
-! $Header $
+! $Header$
 !
       INTEGER kdlon, kflev
-      PARAMETER (kdlon=klon,kflev=klev)
+      PARAMETER (kdlon=149,kflev=klev)
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/radiornpb.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/radiornpb.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/radiornpb.F	(revision 634)
@@ -3,4 +3,5 @@
 !
       SUBROUTINE radiornpb(tr,dtime,tautr,d_tr) 
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -12,6 +13,6 @@
 c Arguments:
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 c======================================================================
 C
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/radlwsw.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/radlwsw.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/radlwsw.F	(revision 634)
@@ -16,4 +16,5 @@
      .                  cldtaupi, topswai, solswai)
 c      
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -69,7 +70,7 @@
       
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "YOETHF.h"
 c
@@ -428,10 +429,10 @@
      S              PTOPSWAD,PSOLSWAD,PTOPSWAI,PSOLSWAI,
      J              ok_ade, ok_aie )
-      
+      USE dimphy      
       IMPLICIT none
 
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "YOMCST.h"
 C
@@ -547,10 +548,10 @@
       REAL*8 PSOLSWAI(KDLON)     ! SHORTWAVE FLUX AT SURFACE(+AEROSOL IND)
 cjq - Fluxes including aerosol effects
-      REAL*8 ZFSUPAD(KDLON,KFLEV+1)
-      REAL*8 ZFSDNAD(KDLON,KFLEV+1)
-      REAL*8 ZFSUPAI(KDLON,KFLEV+1)
-      REAL*8 ZFSDNAI(KDLON,KFLEV+1)
+      REAL*8,allocatable,save :: ZFSUPAD(:,:)
+      REAL*8,allocatable,save :: ZFSDNAD(:,:)
+      REAL*8,allocatable,save :: ZFSUPAI(:,:)
+      REAL*8,allocatable,save :: ZFSDNAI(:,:)
       logical initialized
-      SAVE ZFSUPAD, ZFSDNAD, ZFSUPAI, ZFSDNAI ! aerosol fluxes
+cym      SAVE ZFSUPAD, ZFSDNAD, ZFSUPAI, ZFSDNAI ! aerosol fluxes
 !rv
       save flag_aer
@@ -560,4 +561,13 @@
         flag_aer=0.
         initialized=.TRUE.
+        allocate(ZFSUPAD(KDLON,KFLEV+1))
+        allocate(ZFSDNAD(KDLON,KFLEV+1))
+        allocate(ZFSUPAI(KDLON,KFLEV+1))
+        allocate(ZFSDNAI(KDLON,KFLEV+1))
+	ZFSUPAD(:,:)=0.
+        ZFSDNAD(:,:)=0.
+        ZFSUPAI(:,:)=0.
+        ZFSDNAI(:,:)=0.
+	
       endif
 !rv
@@ -735,8 +745,9 @@
      S                PTAVE,PWV,PAKI,PCLD,PCLEAR,PDSIG,PFACT,
      S                PRMU,PSEC,PUD)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "radepsi.h"
 #include "radopt.h"
@@ -925,8 +936,9 @@
      S  ,  PDSIG , POMEGA, POZ  , PRMU , PSEC , PTAU  , PUD  
      S  ,  PFD   , PFU)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 C
 C     ------------------------------------------------------------------
@@ -1165,8 +1177,9 @@
      S  ,  PUD   ,PWV , PQS
      S  ,  PFDOWN,PFUP                                            )
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "radepsi.h"
 C
@@ -1711,8 +1724,9 @@
      S  , PCGAZ , PPIZAZ, PRAY1 , PRAY2 , PREFZ , PRJ  
      S  , PRK   , PRMU0 , PTAUAZ, PTRA1 , PTRA2                   )
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "radepsi.h"
 #include "radopt.h"
@@ -2071,8 +2085,9 @@
      S  , PCGAZ , PPIZAZ, PRAY1, PRAY2, PREFZ , PRJ  , PRK , PRMUE
      S  , PTAUAZ, PTRA1 , PTRA2 )
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "radepsi.h"
 #include "radopt.h"
@@ -2427,8 +2442,9 @@
       SUBROUTINE SWDE (PGG,PREF,PRMUZ,PTO1,PW,
      S                 PRE1,PRE2,PTR1,PTR2)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 C
 C     ------------------------------------------------------------------
@@ -2558,8 +2574,9 @@
       END
       SUBROUTINE SWTT (KNU,KA,PU,PTR)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 C
 C-----------------------------------------------------------------------
@@ -2674,8 +2691,9 @@
       END
       SUBROUTINE SWTT1(KNU,KABS,KIND, PU, PTR)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 C
 C-----------------------------------------------------------------------
@@ -2806,8 +2824,9 @@
 cIM  .              ptoplwdown,ptoplwdownclr)
      .              plwup, plwdn, plwup0, plwdn0)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 #include "YOMCST.h"
@@ -2884,11 +2903,17 @@
       REAL*8 ZOZ(KDLON,KFLEV)
 c
-      REAL*8 ZFLUX(KDLON,2,KFLEV+1) ! RADIATIVE FLUXES (1:up; 2:down)
-      REAL*8 ZFLUC(KDLON,2,KFLEV+1) ! CLEAR-SKY RADIATIVE FLUXES
-      REAL*8 ZBINT(KDLON,KFLEV+1)            ! Intermediate variable
-      REAL*8 ZBSUI(KDLON)                    ! Intermediate variable
-      REAL*8 ZCTS(KDLON,KFLEV)               ! Intermediate variable
-      REAL*8 ZCNTRB(KDLON,KFLEV+1,KFLEV+1)   ! Intermediate variable
-      SAVE ZFLUX, ZFLUC, ZBINT, ZBSUI, ZCTS, ZCNTRB
+cym      REAL*8 ZFLUX(KDLON,2,KFLEV+1) ! RADIATIVE FLUXES (1:up; 2:down)
+cym      REAL*8 ZFLUC(KDLON,2,KFLEV+1) ! CLEAR-SKY RADIATIVE FLUXES
+cym      REAL*8 ZBINT(KDLON,KFLEV+1)            ! Intermediate variable
+cym      REAL*8 ZBSUI(KDLON)                    ! Intermediate variable
+cym      REAL*8,ZCTS(KDLON,KFLEV)               ! Intermediate variable
+cym      REAL*8 ZCNTRB(KDLON,KFLEV+1,KFLEV+1)   ! Intermediate variable
+cym      SAVE ZFLUX, ZFLUC, ZBINT, ZBSUI, ZCTS, ZCNTRB
+      REAL*8,allocatable,save :: ZFLUX(:,:,:) ! RADIATIVE FLUXES (1:up; 2:down)
+      REAL*8,allocatable,save :: ZFLUC(:,:,:) ! CLEAR-SKY RADIATIVE FLUXES
+      REAL*8,allocatable,save :: ZBINT(:,:)            ! Intermediate variable
+      REAL*8,allocatable,save :: ZBSUI(:)                    ! Intermediate variable
+      REAL*8,allocatable,save :: ZCTS(:,:)               ! Intermediate variable
+      REAL*8,allocatable,save :: ZCNTRB(:,:,:)   ! Intermediate variable
 c
       INTEGER ilim, i, k, kpl1
@@ -2909,4 +2934,11 @@
          PRINT*, "LW cloudy-sky calling frequency: ", lwpas
          PRINT*, "   In general, they should be 1"
+cym
+	 allocate(ZFLUX(KDLON,2,KFLEV+1) )
+         allocate(ZFLUC(KDLON,2,KFLEV+1) )
+         allocate(ZBINT(KDLON,KFLEV+1))
+         allocate(ZBSUI(KDLON))
+         allocate(ZCTS(KDLON,KFLEV))
+         allocate(ZCNTRB(KDLON,KFLEV+1,KFLEV+1))
          appel1er=.FALSE.
       ENDIF
@@ -2973,8 +3005,9 @@
      S               PAER,PDP,PPMB,PPSOL,POZ,PTAVE,PVIEW,PWV,
      S               PABCU)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 #include "YOMCST.h"
@@ -3366,8 +3399,9 @@
       SUBROUTINE LWBV(KLIM,PDP,PDT0,PEMIS,PPMB,PTL,PTAVE,PABCU,
      S                PFLUC,PBINT,PBSUI,PCTS,PCNTRB)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 #include "YOMCST.h"
@@ -3457,8 +3491,9 @@
      R               PBINT,PBSUIN,PCTS,PCNTRB,
      S               PFLUX)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "radepsi.h"
 #include "radopt.h"
@@ -3862,8 +3897,9 @@
      S  , PB,PBINT,PBSUIN,PBSUR,PBTOP,PDBSL
      S  , PGA,PGB,PGASUR,PGBSUR,PGATOP,PGBTOP)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 C
@@ -5273,8 +5309,9 @@
      R  , PGA,PGB,PGASUR,PGBSUR,PGATOP,PGBTOP
      S  , PCNTRB,PCTS,PFLUC)
+       USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 #include "YOMCST.h"
@@ -5386,8 +5423,9 @@
      R  , PGA,PGB,PGASUR,PGBSUR,PGATOP,PGBTOP
      S  , PCTS,PFLUC)
+       USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 #include "radopt.h"
@@ -5718,8 +5756,9 @@
      R  , PGA,PGB
      S  , PCNTRB,PDISD,PDISU)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 C
@@ -5970,8 +6009,9 @@
      R  , PABCU,PDBSL,PGA,PGB
      S  , PADJD,PADJU,PCNTRB,PDBDT)
+       USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 C
@@ -6177,8 +6217,9 @@
       END
       SUBROUTINE LWTT(PGA,PGB,PUU, PTT)
+       USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 C
@@ -6352,8 +6393,9 @@
       END
       SUBROUTINE LWTTM(PGA,PGB,PUU1,PUU2, PTT)
+      USE dimphy
       IMPLICIT none
-#include "dimensions.h"
-#include "dimphy.h"
-#include "raddim.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "raddim.h"
 #include "raddimlw.h"
 C
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/readsulfate.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/readsulfate.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/readsulfate.F	(revision 634)
@@ -2,6 +2,6 @@
 ! $Header$
 !
-      SUBROUTINE readsulfate (r_day, first, sulfate)
-      
+      SUBROUTINE readsulfate (r_day, first, sulfate_p)
+      USE dimphy, klon=>klon2,klon2=>klon
       IMPLICIT none
       
@@ -34,10 +34,10 @@
 #include "chem.h"      
 #include "dimensions.h"      
-#include "dimphy.h"      
+cym#include "dimphy.h"      
 #include "temps.h"      
 c 
 c Input:
 c ------
-      REAL*8  r_day                   ! Day of integration
+      REAL  r_day                   ! Day of integration
       LOGICAL first                 ! First timestep 
                                     ! (and therefore initialization necessary)
@@ -45,7 +45,10 @@
 c Output:      
 c -------     
-      REAL*8  sulfate (klon, klev)  ! Mass of sulfate (monthly mean data, 
-                                  !  from file) [ug SO4/m3]
-c      
+c$$$      REAL*8  sulfate_p(klon2,klev)
+c$$$      REAL*8  sulfate (klon, klev)  ! Mass of sulfate (monthly mean data, 
+c$$$                                  !  from file) [ug SO4/m3]
+      REAL  sulfate_p(klon2,klev)
+      REAL  sulfate (klon, klev)  ! Mass of sulfate (monthly mean data, 
+                                  !  from file) [ug SO4/m3]c      
 c Local Variables:
 c ----------------      
@@ -62,13 +65,28 @@
       REAL*8 so4_2(iim, jjm+1, klev, 12)   ! The sulfate distributions
       
-      REAL*8 so4(klon, klev, 12)  ! SO4 in right dimension
-      SAVE so4
-      REAL*8 so4_out(klon, klev)
-      SAVE so4_out
+cym      REAL*8 so4(klon, klev, 12)  ! SO4 in right dimension
+cym      SAVE so4
+cym      REAL*8 so4_out(klon, klev)
+cym      SAVE so4_out
+
+      REAL*8,allocatable,save :: so4(:, :, :)  ! SO4 in right dimension
+      REAL*8,allocatable,save :: so4_out(:, :)
       
       LOGICAL lnewday 
       LOGICAL lonlyone
       PARAMETER (lonlyone=.FALSE.)
-
+      logical,save :: first2=.true.
+
+      if (first2) then
+     
+        allocate( so4(klon, klev, 12) )
+        allocate( so4_out(klon, klev))
+          
+        first2=.false.
+	
+      endif
+
+      if (phy_rank==0) then
+            
       iday = INT(r_day) 
       
@@ -249,5 +267,9 @@
 
       ENDIF ! Did I have to do anything (was it a new day?)
-      
+
+      endif   ! phy_rank==0
+      
+      call ScatterField(sulfate,sulfate_p,klev)
+            
       RETURN
       END
@@ -261,6 +283,6 @@
 c-----------------------------------------------------------------------------
       
-      SUBROUTINE readsulfate_preind (r_day, first, pi_sulfate)
-      
+      SUBROUTINE readsulfate_preind (r_day, first, pi_sulfate_p)
+      USE dimphy, klon=>klon2,klon2=>klon
       IMPLICIT none
       
@@ -289,10 +311,10 @@
 #include "chem.h"      
 #include "dimensions.h"      
-#include "dimphy.h"      
+cym#include "dimphy.h"      
 #include "temps.h"      
 c 
 c Input:
 c ------
-      REAL*8  r_day                   ! Day of integration
+      REAL r_day                   ! Day of integration
       LOGICAL first                 ! First timestep 
                                     ! (and therefore initialization necessary)
@@ -300,6 +322,7 @@
 c Output:      
 c -------     
-      REAL*8  pi_sulfate (klon, klev)  ! Number conc. sulfate (monthly mean data, 
-                                  !  from file)
+      REAL pi_sulfate_p (klon2, klev)  
+      REAL pi_sulfate (klon, klev)  ! Number conc. sulfate 
+                                       ! (monthly mean data, 
 c      
 c Local Variables:
@@ -311,13 +334,29 @@
       INTEGER im, day1, day2, im2, ismaller
       REAL*8 pi_so4_1(iim, jjm+1, klev, 12)
-      
-      REAL*8 pi_so4(klon, klev, 12)  ! SO4 in right dimension
-      SAVE pi_so4
-      REAL*8 pi_so4_out(klon, klev)
-      SAVE pi_so4_out
+
+cym      REAL*8 pi_so4(klon, klev, 12)  ! SO4 in right dimension
+cym      SAVE pi_so4
+cym      REAL*8 pi_so4_out(klon, klev)
+cym      SAVE pi_so4_out
+
+      REAL*8,allocatable,save :: pi_so4(:, :, :)  ! SO4 in right dimension
+      REAL*8,allocatable,save :: pi_so4_out(:, :)
+            
       
       CHARACTER*4 cyear
       LOGICAL lnewday
-
+      logical,save :: first2=.true.
+
+      if (first2) then
+     
+        allocate( pi_so4(klon, klev, 12) )
+        allocate( pi_so4_out(klon, klev))
+          
+        first2=.false.
+	
+      endif
+
+      if (phy_rank==0) then
+    
       
 
@@ -463,4 +502,10 @@
 
       ENDIF ! Was this the beginning of a new day?
+
+      endif   ! phy_rank==0
+      
+      call ScatterField(pi_sulfate,pi_sulfate_p,klev)
+
+
       RETURN
       END
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/soil.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/soil.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/soil.F	(revision 634)
@@ -4,4 +4,5 @@
       SUBROUTINE soil(ptimestep, indice, knon, snow, ptsrf, ptsoil,
      s          pcapcal, pfluxgrd)
+      use dimphy
       IMPLICIT NONE
 
@@ -49,7 +50,7 @@
 c   -------------
 
-#include "dimensions.h"
+cym#include "dimensions.h"
 #include "YOMCST.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "dimsoil.h"
 #include "indicesol.h"
@@ -78,7 +79,9 @@
       REAL dz1(nsoilmx),dz2(nsoilmx)
 c$$$          REAL zc(klon,nsoilmx),zd(klon,nsoilmx)
-      REAL zc(klon,nsoilmx,nbsrf),zd(klon,nsoilmx,nbsrf)
+cym      REAL zc(klon,nsoilmx,nbsrf),zd(klon,nsoilmx,nbsrf)
+      REAL,ALLOCATABLE,SAVE ::  zc(:,:,:),zd(:,:,:)
       REAL lambda
-      SAVE dz1,dz2,zc,zd,lambda
+cym      SAVE dz1,dz2,zc,zd,lambda
+      SAVE dz1,dz2,lambda
       LOGICAL firstcall, firstsurf(nbsrf)
       SAVE firstcall, firstsurf
@@ -90,5 +93,5 @@
 
       DATA isol,isno,iice/2000.,2000.,2000./
-
+      LOGICAL,SAVE :: First=.true.
 c-----------------------------------------------------------------------
 c   Depthts:
@@ -103,4 +106,9 @@
 c   on corrige si on a un point de terre avec ou sans glace
 c
+      IF (first) THEN
+        allocate(zc(klon,nsoilmx,nbsrf),zd(klon,nsoilmx,nbsrf))
+	first=.false.
+      ENDIF
+      
       IF (indice.EQ.is_sic) THEN
          DO ig = 1, knon
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/thermcell.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/thermcell.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/thermcell.F	(revision 634)
@@ -6,5 +6,5 @@
 c    s                  ,pu_therm,pv_therm
      s                  ,r_aspect,l_mix,w2di,tho)
-
+      USE dimphy
       IMPLICIT NONE
 
@@ -33,6 +33,6 @@
 c   -------------
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 
@@ -85,6 +85,6 @@
       real fracc(klon,klev+1)
       real zf,zf2
-      real thetath2(klon,klev),wth2(klon,klev)
-      common/comtherm/thetath2,wth2
+      real,allocatable,save :: thetath2(:,:),wth2(:,:)
+cym      common/comtherm/thetath2,wth2
 
       real count_time
@@ -132,5 +132,5 @@
       save ncorrec
       data ncorrec/0/
-      
+      logical,save :: firstCall=.true.
 c
 c-----------------------------------------------------------------------
@@ -138,4 +138,11 @@
 c   ---------------
 c
+      if (firstcall) then
+        allocate(thetath2(klon,klev),wth2(klon,klev))
+	thetath2(:,:)=0.
+	wth2(:,:)=0.
+	firstcall=.false.
+      endif
+      
        sorties=.true.
       IF(ngrid.NE.klon) THEN
@@ -979,4 +986,5 @@
       subroutine dqthermcell(ngrid,nlay,ptimestep,fm,entr,masse
      .    ,q,dq,qa)
+      use dimphy
       implicit none
 
@@ -989,6 +997,6 @@
 c=======================================================================
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       integer ngrid,nlay
@@ -1053,4 +1061,5 @@
      .    ,fraca,larga
      .    ,u,v,du,dv,ua,va)
+       use dimphy
       implicit none
 
@@ -1063,6 +1072,6 @@
 c=======================================================================
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       integer ngrid,nlay
@@ -1166,4 +1175,5 @@
       subroutine dqthermcell2(ngrid,nlay,ptimestep,fm,entr,masse,frac
      .    ,q,dq,qa)
+      use dimphy
       implicit none
 
@@ -1176,6 +1186,6 @@
 c=======================================================================
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       integer ngrid,nlay
@@ -1246,4 +1256,5 @@
      .    ,fraca,larga
      .    ,u,v,du,dv,ua,va)
+      use dimphy
       implicit none
 
@@ -1256,6 +1267,6 @@
 c=======================================================================
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       integer ngrid,nlay
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/transp.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/transp.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/transp.F	(revision 634)
@@ -5,5 +5,6 @@
      e                   t, q, u, v, geom,
      s                   vtran_e, vtran_q, utran_e, utran_q)
-c
+c 
+       USE dimphy
       IMPLICIT none
 c======================================================================
@@ -13,6 +14,6 @@
 c======================================================================
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ustarhb.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ustarhb.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/ustarhb.F	(revision 634)
@@ -3,4 +3,5 @@
 !
       SUBROUTINE ustarhb(knon,u,v,cd_m, ustar)
+      use dimphy
       IMPLICIT none
 c======================================================================
@@ -17,6 +18,6 @@
 c model. J. of Climate, vol. 6, 1825-1842.
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/vdif_kcay.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/vdif_kcay.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/vdif_kcay.F	(revision 634)
@@ -5,8 +5,9 @@
      s   ,zlev,zlay,u,v,teta,cd,q2,q2diag,km,kn,ustar
      s   ,l_mix)
+      use dimphy
       IMPLICIT NONE
 c.......................................................................
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 c.......................................................................
 c
@@ -195,6 +196,6 @@
       PARAMETER (q2min=1.e-5)
       PARAMETER (q2max=1.E+2)
-      PARAMETER (nlay=klev)
-      PARAMETER (nlev=klev+1)
+cym      PARAMETER (nlay=klev)
+cym      PARAMETER (nlev=klev+1)
 c
       PARAMETER (
@@ -226,5 +227,7 @@
 c
 c   Initialisation de q2
-
+      nlay=klev
+      nlev=klev+1
+       
       call yamada(ngrid,dt,g,rconst,plev,temp
      s   ,zlev,zlay,u,v,teta,cd,q2diag,km,kn,ustar
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/wrgradsfi.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/wrgradsfi.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/wrgradsfi.F	(revision 634)
@@ -2,5 +2,6 @@
 ! $Header$
 !
-      subroutine wrgradsfi(if,nl,fieldfi,name,titlevar)
+      subroutine wrgradsfi(if,nl,fieldfi_p,name,titlevar)
+      use dimphy
       implicit none
 
@@ -8,9 +9,10 @@
 
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 
 c   arguments
       integer if,nl
-      real fieldfi(klon,nl)
+      real fieldfi_p(klon,nl)
+      real fieldfi(klon2,nl)
       real fielddyn((iim+1)*(jjm+1),llm)
       character*10 name
@@ -24,9 +26,13 @@
 
 c     print*,'Transformation pour ',name
-      call gr_fi_dyn(nl,klon,iim+1,jjm+1,fieldfi,fielddyn)
+      call GatherField(fieldfi_p,fieldfi,nl)
+      
+      if (phy_rank==0) then
+        call gr_fi_dyn(nl,klon,iim+1,jjm+1,fieldfi,fielddyn)
 c     print*,'Transformation OK '
-      call wrgrads(if,nl,fielddyn,name,titlevar)
+        call wrgrads(if,nl,fielddyn,name,titlevar)
 c     print*,'Ecriture ok'
-
+      endif
+      
       return
       end
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histISCCP.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histISCCP.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histISCCP.h	(revision 634)
@@ -11,16 +11,15 @@
         DO k=1,kmaxm1
          zx_tmp_fi3d(1:klon, 1:lmaxm1)=fq_isccp(1:klon,k,1:lmaxm1)*100.
-         CALL gr_fi_ecrit(lmaxm1,klon,iim,jjmp1,zx_tmp_fi3d,
-     .                    zx_tmp_3d)
+cym         CALL gr_fi_ecrit(lmaxm1,klon,iim,jjmp1,zx_tmp_fi3d,
+cym     .                    zx_tmp_3d)
 c
 cIM: champ 3d : (lon,lat,pres) pour un tau fixe
 c
-         CALL histwrite(nid_isccp,"cldISCCP_"//taulev(k),itau_w,
-     .                  zx_tmp_3d,iim*jjmp1*lmaxm1,ndex3d)
+         CALL histwrite_phy(nid_isccp,"cldISCCP_"//taulev(k),itau_w,
+     .                  zx_tmp_fi3d)
         ENDDO !k
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:),zx_tmp_2d)
-        CALL histwrite(nid_isccp,"nsunlit",itau_w,
-     .                 zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:),zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"nsunlit",itau_w,nbsunlit(1,:))
 c
        if (ok_sync) then
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histREGDYN.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histREGDYN.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histREGDYN.h	(revision 634)
@@ -3,4 +3,6 @@
 !
       if (ok_regdyn) then
+      
+      if (monocpu) then
 
 c   Comprendre comment marche el i=nint(zout/zsto)
@@ -66,4 +68,6 @@
         call histsync(nid_regdyn)
       endif
+      
+      endif ! monocpu
 
       endif
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histday.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histday.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histday.h	(revision 634)
@@ -14,9 +14,9 @@
 
          i = NINT(zout/zsto)
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
 c
       IF(lev_histday.GE.1) THEN
 c
-       CALL histwrite(nid_day,"phis",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+       CALL histwrite_phy(nid_day,"phis",itau_w,pphis)
          varname = 'phis'
          vartitle= 'Surface geop. height'
@@ -24,6 +24,6 @@
 c
          i = NINT(zout/zsto)
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,airephy,zx_tmp_2d)
-       CALL histwrite(nid_day,"aire",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,airephy,zx_tmp_2d)
+       CALL histwrite_phy(nid_day,"aire",itau_w,airephy)
          varname = 'aire'
          vartitle= 'Grid area'
@@ -34,50 +34,47 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"contfracATM",itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pctsrf_new(:,is_ter),zx_tmp_2d)
-      CALL histwrite(nid_day,"contfracOR",itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
-      CALL histwrite(nid_day,"tsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-C
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
-      CALL histwrite(nid_day,"t2m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"contfracATM",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pctsrf_new(:,is_ter),zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"contfracOR",itau_w,
+     &                   pctsrf_new(:,is_ter))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"tsol",itau_w,zxtsol)
+C
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"t2m",itau_w,zt2m)
 c
 c   En attendant un eventuel debugage.
 
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
-      CALL histwrite(nid_day,"t2m_min",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
-      CALL histwrite(nid_day,"t2m_max",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"t2m_min",itau_w,zt2m)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"t2m_max",itau_w,zt2m)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"plul",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"plul",itau_w,zx_tmp_fi2d)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"pluc",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_lsc,zx_tmp_2d)
-      CALL histwrite(nid_day,"snowl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"pluc",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_lsc,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"snowl",itau_w,snow_lsc)
 c
       IF(1.EQ.0) THEN
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_con,zx_tmp_2d)
-      CALL histwrite(nid_day,"snowc",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_con,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"snowc",itau_w,snow_con)
       ENDIF
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxfluxlat,zx_tmp_2d)
-      CALL histwrite(nid_day,"flat",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxfluxlat,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"flat",itau_w,zxfluxlat)
 c
       DO i = 1, klon
@@ -85,92 +82,84 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"sicf",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zq2m,zx_tmp_2d)
-      CALL histwrite(nid_day,"q2m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zu10m,zx_tmp_2d)
-      CALL histwrite(nid_day,"u10m",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zv10m,zx_tmp_2d)
-      CALL histwrite(nid_day,"v10m",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"sicf",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zq2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"q2m",itau_w,zq2m)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zu10m,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"u10m",itau_w,zu10m)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zv10m,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"v10m",itau_w,zv10m)
 c
       DO i=1, klon
        zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"wind10m",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"wind10max",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)     
+      CALL histwrite_phy(nid_day,"wind10m",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"wind10max",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
          zx_tmp_fi2d(i) = paprs(i,1)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"psol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"psol",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
          zx_tmp_fi2d(i) = (rain_fall(i) + snow_fall(i))
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"precip",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
-      CALL histwrite(nid_day,"snowf",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
-      CALL histwrite(nid_day,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, evap,zx_tmp_2d)
-      CALL histwrite(nid_day,"evap",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw,zx_tmp_2d)
-      CALL histwrite(nid_day,"tops",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
-      CALL histwrite(nid_day,"topl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
-      CALL histwrite(nid_day,"sols",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
-      CALL histwrite(nid_day,"soll",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldl,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldm,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldh,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldt",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldq,zx_tmp_2d)
-      CALL histwrite(nid_day,"cldq",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, prw,zx_tmp_2d)
-      CALL histwrite(nid_day,"prw",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"precip",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"snowf",itau_w,snow_fall)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"snow_mass",itau_w,zxsnow)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, evap,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"evap",itau_w,evap)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"tops",itau_w,topsw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"topl",itau_w,toplw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"sols",itau_w,solsw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"soll",itau_w,sollw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldl,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"cldl",itau_w,cldl)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldm,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"cldm",itau_w,cldm)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldh,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"cldh",itau_w,cldh)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"cldt",itau_w,cldt)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldq,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"cldq",itau_w,cldq)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, prw,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"prw",itau_w,prw)
 
 c   Ecriture de champs dynamiques sur des niveaux de pression
       DO k=1, nlevENS
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulev(:,k),zx_tmp_2d)
-        CALL histwrite(nid_day,"u"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlev(:,k),zx_tmp_2d)
-        CALL histwrite(nid_day,"v"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulev(:,k),zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"u"//clev(k),itau_w,ulev(:,k))
+c
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlev(:,k),zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"v"//clev(k),itau_w,vlev(:,k))
 c
       ENDDO !nlevENS
@@ -179,6 +168,8 @@
       IF(clev(k).EQ."500") THEN
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, wlev(:,indENS(k)),zx_tmp_2d)
-      CALL histwrite(nid_day,"w500",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, wlev(:,indENS(k)),zx_tmp_2d)
+cym      CALL histwrite_phy(nid_day,"w500",itau_w,wlev(:,indENS(k)))
+         CALL histwrite_phy(nid_day,"w500",itau_w,wlev(:,k))
+
 c
 c     DO i=1, klon
@@ -188,32 +179,29 @@
 c
 cBAD  CALL gr_fi_ecrit(1, klon,iim,jjmp1, philev(:,indENS(k)),zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_day,"phi500",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"phi500",itau_w,philev(:,k))
 c
       ENDIF !clev(k).EQ.500
       ENDDO !k=1, nlevENS 
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, slp,zx_tmp_2d)
-      CALL histwrite(nid_day,"slp",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,cape,zx_tmp_2d)
-      CALL histwrite(nid_day,"cape_max",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
-      CALL histwrite(nid_day,"solldown",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, slp,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"slp",itau_w,slp)
+
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,cape,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"cape_max",itau_w,cape)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"solldown",itau_w,sollwdown)
 c
       DO i=1, klon
         zx_tmp_fi2d(i)=-1*sens(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"sens",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"sens",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = swdn(1 : klon, 1)
 
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day, "SWdnSFC",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day, "SWdnSFC",itau_w,zx_tmp_fi2d)
 c
       ENDIF !lev_histday.GE.1
@@ -221,9 +209,9 @@
       IF(lev_histday.GE.2) THEN
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, bils,zx_tmp_2d)
-      CALL histwrite(nid_day,"bils",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
-      CALL histwrite(nid_day,"fder",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, bils,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"bils",itau_w, bils)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"fder",itau_w,fder)
 c
       ENDIF !lev_histday.GE.2
@@ -237,31 +225,24 @@
 c Champs 3D:
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      CALL histwrite(nid_day,"temp",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
-      CALL histwrite(nid_day,"ovap",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
-      CALL histwrite(nid_day,"geop",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      CALL histwrite(nid_day,"vitu",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
-      CALL histwrite(nid_day,"vitv",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
-      CALL histwrite(nid_day,"vitw",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
-      CALL histwrite(nid_day,"pres",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"temp",itau_w,t_seri)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"ovap",itau_w,qx(:,:,ivap))
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"geop",itau_w,zphi)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"vitu",itau_w,u_seri)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"vitv",itau_w,v_seri)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"vitw",itau_w,omega)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"pres",itau_w,pplay)
 c
       ENDIF !lev_histday.GE.3
@@ -276,165 +257,144 @@
 c=================================================================
       zx_tmp_fi2d(1 : klon) = swup( 1 : klon, klevp1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day, "SWupTOA",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day, "SWupTOA",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = swup( 1 : klon, 1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day, "SWupSFC",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day, "SWupSFC",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = swdn( 1 : klon, klevp1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day, "SWdnTOA",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day, "SWdnTOA",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = swup0( 1 : klon, klevp1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day, "SWupTOAclr",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day, "SWupTOAclr",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = swup0( 1 : klon, 1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day, "SWupSFCclr",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day, "SWupSFCclr",itau_w,zx_tmp_fi2d)
 c 
       zx_tmp_fi2d(1 : klon) = swdn0( 1 : klon, klevp1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day, "SWdnTOAclr",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day, "SWdnTOAclr",itau_w,zx_tmp_fi2d)
 c 
       zx_tmp_fi2d(1 : klon) = swdn0( 1 : klon, 1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day, "SWdnSFCclr",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day, "SWdnSFCclr",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = ftsol(1 : klon, is_ter)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d ,zx_tmp_2d)
-      CALL histwrite(nid_day,"tter",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d ,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"tter",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = ftsol(1 : klon, is_lic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"tlic",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"tlic",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = ftsol(1 : klon, is_oce)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"toce",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"toce",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = ftsol(1 : klon, is_sic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"tsic",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"tsic",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, is_ter)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"t2mter",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"t2mter",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, is_ter)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"t2mter_min",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"t2mter_min",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, is_ter)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"t2mter_max",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"t2mter_max",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, is_lic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"t2mlic",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"t2mlic",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, is_oce)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"t2moce",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"t2moce",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, is_sic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"t2msic",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"t2msic",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, is_ter)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"u10mter",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"u10mter",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, is_ter)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"v10mter",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"v10mter",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, is_lic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"u10mlic",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"u10mlic",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, is_lic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"v10mlic",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"v10mlic",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, is_oce)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"u10moce",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"u10moce",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, is_oce)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"v10moce",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"v10moce",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, is_sic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"u10msic",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"u10msic",itau_w,zx_tmp_fi2d)
 C
       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, is_sic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"v10msic",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"v10msic",itau_w,zx_tmp_fi2d)
 C
       DO nsrf = 1, nbsrf
 C
         zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"pourc_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"pourc_"//clnsurf(nsrf),itau_w,
+     $                     zx_tmp_fi2d) 
 C
         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"tsol_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"tsol_"//clnsurf(nsrf),itau_w,
+     $                     zx_tmp_fi2d) 
 C 
         zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"sens_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"sens_"//clnsurf(nsrf),itau_w,
+     $                     zx_tmp_fi2d) 
 C  
         zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"lat_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"lat_"//clnsurf(nsrf),itau_w,
+     $                     zx_tmp_fi2d) 
 C
         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"taux_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"taux_"//clnsurf(nsrf),itau_w,
+     $                     zx_tmp_fi2d) 
 C      
         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"tauy_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"tauy_"//clnsurf(nsrf),itau_w,
+     $                     zx_tmp_fi2d)
 C
         zx_tmp_fi2d(1 : klon) = falbe( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"albe_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"albe_"//clnsurf(nsrf),itau_w,
+     $                     zx_tmp_fi2d) 
 C
         zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"rugs_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"rugs_"//clnsurf(nsrf),itau_w,
+     $                     zx_tmp_fi2d) 
 C 
       END DO  
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histhf.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histhf.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histhf.h	(revision 634)
@@ -24,7 +24,6 @@
 c     CALL histwrite(nid_hf,"aire",i,zx_tmp_2d,iim*jjmp1,ndex2d)
 C
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, paire_ter, zx_tmp_2d)
-      CALL histwrite(nid_hf,"aireTER",itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, paire_ter, zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"aireTER",itau_w,paire_ter)
 c
       DO i=1, klon
@@ -32,58 +31,52 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_hf,"contfracATM",itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"contfracATM",itau_w,zx_tmp_fi2d)
 c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pctsrf_new(:,is_ter),zx_tmp_2d)
-      CALL histwrite(nid_hf,"contfracOR",itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pctsrf_new(:,is_ter),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"contfracOR",itau_w,
+     .                   pctsrf_new(:,is_ter))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zt2m,zx_tmp_2d)
-      CALL histwrite(nid_hf,"t2m",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zt2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"t2m",itau_w,zt2m)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zq2m,zx_tmp_2d)
-      CALL histwrite(nid_hf,"q2m",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zq2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"q2m",itau_w,zq2m)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = paprs(i,1)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_hf,"psol",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"psol",itau_w,zx_tmp_fi2d)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_hf,"rain",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"rain",itau_w,zx_tmp_fi2d)
 c
 c ENSEMBLES BEG
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
-      CALL histwrite(nid_hf,"tsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"tsol",itau_w,zxtsol)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, slp,zx_tmp_2d)
-      CALL histwrite(nid_hf,"slp",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, slp,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"slp",itau_w,slp)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zu10m,zx_tmp_2d)
-      CALL histwrite(nid_hf,"u10m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zu10m,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"u10m",itau_w,zu10m)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zv10m,zx_tmp_2d)
-      CALL histwrite(nid_hf,"v10m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zv10m,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"v10m",itau_w,zv10m)
 c
       DO i=1, klon
        zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_hf,"wind10m",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"wind10m",itau_w,zx_tmp_fi2d)
 c
       DO k=1, nlevENS
       IF(clev(k).EQ."500") THEN
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"phi"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"phi"//clev(k),itau_w,philev(:,k))
       ENDIF !clev(k).EQ."500"
       ENDDO
@@ -93,20 +86,14 @@
       IF(lev_histhf.GE.2) THEN
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
-      CALL histwrite(nid_hf,"cldt",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"cldt",itau_w,cldt)
 c
       zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-      CALL histwrite(nid_hf,"SWnetOR",itau_w,
-     $     zx_tmp_2d,iim*jjmp1,ndex2d)
+      CALL histwrite_phy(nid_hf,"SWnetOR",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol(1:klon))
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_hf,"SWdownOR",itau_w,
-     $     zx_tmp_2d,iim*jjmp1,ndex2d)
+      CALL histwrite(nid_hf,"SWdownOR",itau_w,zx_tmp_fi2d)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
-      CALL histwrite(nid_hf,"LWdownOR",itau_w,zx_tmp_2d,iim*jjmp1,
-     $     ndex2d) 
+      CALL histwrite(nid_hf,"LWdownOR",itau_w,zx_tmp_fi2d) 
 c
 c
@@ -117,40 +104,34 @@
       DO k=1, nlevENS
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, tlev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"t"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, tlev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"t"//clev(k),itau_w,tlev(:,k))
 c
       IF(clev(k).NE."500") THEN !clev(k).NE."500"
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"phi"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"phi"//clev(k),itau_w,philev(:,k))
       ENDIF !clev(k).NE."500"
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, qlev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"q"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, qlev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"q"//clev(k),itau_w,qlev(:,k))
 c
       IF(1.EQ.0) THEN
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, rhlev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"rh"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, rhlev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"rh"//clev(k),itau_w,rhlev(:,k))
       ENDIF !1.EQ.0
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"u"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"u"//clev(k),itau_w,ulev(:,k))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"v"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"v"//clev(k),itau_w,vlev(:,k))
 c
       ENDDO !nlevENS
 c
       IF(1.EQ.0) THEN
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
-      CALL histwrite(nid_hf,"cdrm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"cdrm",itau_w,cdragm)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
-      CALL histwrite(nid_hf,"cdrh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"cdrh",itau_w,cdragh)
       ENDIF !(1.EQ.0) THEN
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histhf3d.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histhf3d.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histhf3d.h	(revision 634)
@@ -18,19 +18,15 @@
 c Champs 3D:
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      CALL histwrite(nid_hf3d,"temp",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_hf3d,"temp",itau_w,t_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
-      CALL histwrite(nid_hf3d,"ovap",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
+      CALL histwrite_phy(nid_hf3d,"ovap",itau_w,qx(:,:,ivap))
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      CALL histwrite(nid_hf3d,"vitu",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_hf3d,"vitu",itau_w,u_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
-      CALL histwrite(nid_hf3d,"vitv",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_hf3d,"vitv",itau_w,v_seri)
 c
 c     ENDIF !lev_histhf.GE.1
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histins.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histins.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histins.h	(revision 634)
@@ -14,186 +14,175 @@
 
          i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
-      CALL histwrite(nid_ins,"phis",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"phis",itau_w,pphis)
 c
          i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,airephy,zx_tmp_2d)
-      CALL histwrite(nid_ins,"aire",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,airephy,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"aire",itau_w,airephy)
 
       DO i = 1, klon
          zx_tmp_fi2d(i) = paprs(i,1)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_ins,"psol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"psol",itau_w,zx_tmp_fi2d)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_ins,"precip",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"precip",itau_w,zx_tmp_fi2d)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_ins,"plul",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)    
+      CALL histwrite_phy(nid_ins,"plul",itau_w,zx_tmp_fi2d)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_ins,"pluc",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"pluc",itau_w,zx_tmp_fi2d)
 
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
-      CALL histwrite(nid_ins,"tsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"tsol",itau_w,zxtsol)
 cccIM
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zt2m, zx_tmp_2d)
-      CALL histwrite(nid_ins,"t2m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zt2m, zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"t2m",itau_w,zt2m)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zq2m, zx_tmp_2d)
-      CALL histwrite(nid_ins,"q2m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zq2m, zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"q2m",itau_w,zq2m)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zu10m, zx_tmp_2d)
-      CALL histwrite(nid_ins,"u10m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zu10m, zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"u10m",itau_w,zu10m)
 C
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zv10m, zx_tmp_2d)
-      CALL histwrite(nid_ins,"v10m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zv10m, zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"v10m",itau_w,zv10m)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
-      CALL histwrite(nid_ins,"snow",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"snow",itau_w,snow_fall)
 
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
-      CALL histwrite(nid_ins,"cdrm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"cdrm",itau_w,cdragm)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
-      CALL histwrite(nid_ins,"cdrh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"cdrh",itau_w,cdragh)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
-      CALL histwrite(nid_ins,"topl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"topl",itau_w,toplw)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, evap,zx_tmp_2d)
-      CALL histwrite(nid_ins,"evap",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, evap,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"evap",itau_w,evap)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
-      CALL histwrite(nid_ins,"sols",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"sols",itau_w,solsw)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
-      CALL histwrite(nid_ins,"soll",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"soll",itau_w,sollw)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
-      CALL histwrite(nid_ins,"solldown",itau_w,zx_tmp_2d,iim*jjmp1,
-     .                ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"solldown",itau_w,sollwdown)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, bils,zx_tmp_2d)
-      CALL histwrite(nid_ins,"bils",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, bils,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"bils",itau_w,bils)
 c
       zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
 c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, sens,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_ins,"sens",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"sens",itau_w,zx_tmp_fi2d)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
-      CALL histwrite(nid_ins,"fder",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"fder",itau_w,fder)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_oce),zx_tmp_2d)
-      CALL histwrite(nid_ins,"dtsvdfo",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_oce),zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"dtsvdfo",itau_w,d_ts(:,is_oce))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_ter),zx_tmp_2d)
-      CALL histwrite(nid_ins,"dtsvdft",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_ter),zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"dtsvdft",itau_w,d_ts(:,is_ter))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_lic),zx_tmp_2d)
-      CALL histwrite(nid_ins,"dtsvdfg",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_lic),zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"dtsvdfg",itau_w, d_ts(:,is_lic))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_sic),zx_tmp_2d)
-      CALL histwrite(nid_ins,"dtsvdfi",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, d_ts(1,is_sic),zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"dtsvdfi",itau_w,d_ts(:,is_sic))
 
       DO nsrf = 1, nbsrf
 CXXX
         zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"pourc_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_ins,"pourc_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
 C 
         zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"sens_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_ins,"sens_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
 C
         zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"lat_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_ins,"lat_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
 C
         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"tsol_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_ins,"tsol_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
 C
         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"taux_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_ins,"taux_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
 C      
         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"tauy_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_ins,"tauy_"//clnsurf(nsrf),itau_w,
+     $     zx_tmp_fi2d)
 C
         zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"rugs_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_ins,"rugs_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
 C
         zx_tmp_fi2d(1 : klon) = falbe( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"albe_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_ins,"albe_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
 C 
       END DO  
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsol,zx_tmp_2d)
-      CALL histwrite(nid_ins,"albs",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsollw,zx_tmp_2d)
-      CALL histwrite(nid_ins,"albslw",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"albs",itau_w,albsol)
+      
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsollw,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"albslw",itau_w,albsollw)
+
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
-      CALL histwrite(nid_ins,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"snow_mass",itau_w,zxsnow)
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxrugs,zx_tmp_2d)
-      CALL histwrite(nid_ins,"rugs",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxrugs,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"rugs",itau_w,zxrugs)
 c
 c Champs 3D:
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      CALL histwrite(nid_ins,"temp",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"temp",itau_w,t_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      CALL histwrite(nid_ins,"vitu",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"vitu",itau_w,u_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
-      CALL histwrite(nid_ins,"vitv",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"vitv",itau_w,v_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
-      CALL histwrite(nid_ins,"geop",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"geop",itau_w,zphi)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
-      CALL histwrite(nid_ins,"pres",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"pres",itau_w,pplay)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_vdf, zx_tmp_3d)
-      CALL histwrite(nid_ins,"dtvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_vdf, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"dtvdf",itau_w,d_t_vdf)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_vdf, zx_tmp_3d)
-      CALL histwrite(nid_ins,"dqvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_vdf, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"dqvdf",itau_w,d_q_vdf)
 
 c
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histmth.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histmth.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histmth.h	(revision 634)
@@ -17,38 +17,36 @@
 c Champs 2D:
 c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
-      CALL histwrite(nid_mth,"phis",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"phis",itau_w,pphis)
 C
       i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,airephy,zx_tmp_2d)
-      CALL histwrite(nid_mth,"aire",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,airephy,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"aire",itau_w,airephy)
 c
       zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, is_ter)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-      CALL histwrite(nid_mth,"pourc_"//clnsurf(is_ter),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, slp,zx_tmp_2d)
-      CALL histwrite(nid_mth,"slp",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)  
+      CALL histwrite_phy(nid_mth,"pourc_"//clnsurf(is_ter),itau_w,
+     $      zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, slp,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"slp",itau_w,slp)
 
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
-      CALL histwrite(nid_mth,"tsol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zt2m,zx_tmp_2d)
-      CALL histwrite(nid_mth,"t2m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxtsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"tsol",itau_w,zxtsol)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zt2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"t2m",itau_w,zt2m)
 c
 c ENSEMBLES BEG
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
-      CALL histwrite(nid_mth,"t2m_min",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
-      CALL histwrite(nid_mth,"t2m_max",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"t2m_min",itau_w,zt2m)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zt2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"t2m_max",itau_w,zt2m)
 c
 c     CALL gr_fi_ecrit(1,klon,iim,jjmp1,ftsoil(:,1,is_ter),zx_tmp_2d)
 c     CALL gr_fi_ecrit(1,klon,iim,jjmp1,ftsol(:,is_ter),zx_tmp_2d)
 c     CALL gr_fi_ecrit(1,klon,iim,jjmp1,ztsol,zx_tmp_2d)
-c     CALL histwrite(nid_mth,"tsoil",itau_w,zx_tmp_2d,
+c     CALL histwrite_phy(nid_mth,"tsoil",itau_w,zx_tmp_2d,
 c    .               iim*jjmp1,ndex2d)
 c
@@ -56,42 +54,40 @@
        zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
       ENDDO 
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"wind10m",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"wind10m",itau_w,zx_tmp_fi2d)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = pctsrf(i,is_sic)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"sicf",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"sicf",itau_w,zx_tmp_fi2d)
 c
 c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-c     CALL histwrite(nid_mth,"temp",itau_w,zx_tmp_3d,
+c     CALL histwrite_phy(nid_mth,"temp",itau_w,zx_tmp_3d,
 c    .                                   iim*jjmp1*klev,ndex3d)
 c
 c ENSEMBLES END
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zq2m,zx_tmp_2d)
-      CALL histwrite(nid_mth,"q2m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zu10m,zx_tmp_2d)
-      CALL histwrite(nid_mth,"u10m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-C
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zv10m,zx_tmp_2d)
-      CALL histwrite(nid_mth,"v10m",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zq2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"q2m",itau_w,zq2m)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zu10m,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"u10m",itau_w,zu10m)
+C
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zv10m,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"v10m",itau_w,zv10m)
 C
       DO i = 1, klon
          zx_tmp_fi2d(i) = paprs(i,1)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"psol",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxqsurf,zx_tmp_2d)
-      CALL histwrite(nid_mth,"qsurf",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"psol",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxqsurf,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"qsurf",itau_w,zxqsurf)
 c
       if (.not. ok_veget) then
-          CALL gr_fi_ecrit(1, klon,iim,jjmp1, qsol,zx_tmp_2d)
-          CALL histwrite(nid_mth,"qsol",itau_w,zx_tmp_2d,iim*jjmp1
-     $        ,ndex2d)
+cym          CALL gr_fi_ecrit(1, klon,iim,jjmp1, qsol,zx_tmp_2d)
+          CALL histwrite_phy(nid_mth,"qsol",itau_w,qsol)
       endif
 c
@@ -99,54 +95,51 @@
          zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"precip",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, nday_rain,zx_tmp_2d)
-      CALL histwrite(nid_mth,"ndayrain",itau_w,zx_tmp_2d,
-     $               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"precip",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, nday_rain,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"ndayrain",itau_w,nday_rain)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"plul",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"plul",itau_w,zx_tmp_fi2d)
 c
       DO i = 1, klon
          zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"pluc",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
-      CALL histwrite(nid_mth,"snow",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
-      CALL histwrite(nid_mth,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"pluc",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"snow",itau_w,snow_fall)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"snow_mass",itau_w,zxsnow)
 c
 cIM: 071003
 c     zx_tmp_fi2d(1:klon)=evap(1:klon)*86400.
 c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, evap,zx_tmp_2d)
-      CALL histwrite(nid_mth,"evap",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"tops",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw0,zx_tmp_2d)
-      CALL histwrite(nid_mth,"tops0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"topl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw0,zx_tmp_2d)
-      CALL histwrite(nid_mth,"topl0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, evap,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"evap",itau_w,evap)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"tops",itau_w,topsw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw0,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"tops0",itau_w,topsw0)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"topl",itau_w,toplw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw0,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"topl0",itau_w,toplw0)
 c
 c     zx_tmp_fi2d(1 : klon) = ZFSUP( 1 : klon, klevp1)
 cIM 080304   zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 2 )
       zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth, "SWupTOA",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth, "SWupTOA",itau_w,zx_tmp_fi2d)
 c
 c
@@ -154,106 +147,88 @@
 cIM 080304   zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 2 )
       zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth, "SWupTOAclr",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth, "SWupTOAclr",itau_w,zx_tmp_fi2d)
 c
 c      zx_tmp_fi2d(1 : klon) = ZFSDN( 1 : klon, klevp1)
 cIM 080304   zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 2 )
       zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth, "SWdnTOA",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth, "SWdnTOA",itau_w,zx_tmp_fi2d)
 c
 c      zx_tmp_fi2d(1 : klon) = ZFSDN0( 1 : klon, klevp1)
 cIM 080304   zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 2 )
       zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth, "SWdnTOAclr",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, SWup200,zx_tmp_2d)
-      CALL histwrite(nid_mth,"SWup200",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, SWup200clr,zx_tmp_2d)
-      CALL histwrite(nid_mth,"SWup200clr",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, SWdn200,zx_tmp_2d)
-      CALL histwrite(nid_mth,"SWdn200",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, SWdn200clr,zx_tmp_2d)
-      CALL histwrite(nid_mth,"SWdn200clr",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, LWup200,zx_tmp_2d)
-      CALL histwrite(nid_mth,"LWup200",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, LWup200clr,zx_tmp_2d)
-      CALL histwrite(nid_mth,"LWup200clr",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth, "SWdnTOAclr",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, SWup200,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"SWup200",itau_w,SWup200)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, SWup200clr,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"SWup200clr",itau_w,SWup200clr)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, SWdn200,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"SWdn200",itau_w,SWdn200)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, SWdn200clr,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"SWdn200clr",itau_w,SWdn200clr)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, LWup200,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWup200",itau_w,LWup200)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, LWup200clr,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWup200clr",itau_w,LWup200clr)
 c
       zx_tmp_fi2d(1:klon)=-1*LWdn200(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"LWdn200",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWdn200",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1:klon)=-1*LWdn200clr(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"LWdn200clr",itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWdn200clr",itau_w,zx_tmp_fi2d)
 c
 c200 END 
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"sols",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw0,zx_tmp_2d)
-      CALL histwrite(nid_mth,"sols0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"soll",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw0,zx_tmp_2d)
-      CALL histwrite(nid_mth,"soll0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"sols",itau_w,solsw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw0,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"sols0",itau_w,solsw0)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"soll",itau_w,sollw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw0,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"soll0",itau_w,sollw0)
 c
 c      zx_tmp_fi2d(1 : klon) = ZFSUP( 1 : klon, 1)
       zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth, "SWupSFC",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth, "SWupSFC",itau_w,zx_tmp_fi2d)
 c
 c      zx_tmp_fi2d(1 : klon) = ZFSUP0( 1 : klon, 1)
       zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth, "SWupSFCclr",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth, "SWupSFCclr",itau_w,zx_tmp_fi2d)
 c
 c      zx_tmp_fi2d(1 : klon) = ZFSDN( 1 : klon, 1)
       zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth, "SWdnSFC",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth, "SWdnSFC",itau_w,zx_tmp_fi2d)
 c
 c      zx_tmp_fi2d(1 : klon) = ZFSDN0( 1 : klon, 1)
       zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth, "SWdnSFCclr",itau_w,zx_tmp_2d,
-     .                               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth, "SWdnSFCclr",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1:klon)=sollw(1:klon)+sollwdown(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_mth,"LWupSFC",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWupSFC",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1:klon)=sollw0(1:klon)+sollwdownclr(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_mth,"LWupSFCclr",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
-      CALL histwrite(nid_mth,"LWdnSFC",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWupSFCclr",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWdnSFC",itau_w,sollwdown)
 c
       DO i=1, klon
@@ -261,7 +236,6 @@
       ENDDO !i=1, klon
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdownclr,zx_tmp_2d)
-      CALL histwrite(nid_mth,"LWdnSFCclr",itau_w,zx_tmp_2d,
-     $               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdownclr,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWdnSFCclr",itau_w,sollwdownclr)
 c
 c
@@ -271,33 +245,34 @@
       zx_tmp_fi2d(1:klon) = topswai(1:klon) - topswad(1:klon)
 c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topswad,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d ,zx_tmp_2d)
-      CALL histwrite(nid_mth,"topsad",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d ,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"topsad",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1:klon) = solswai(1:klon) - solswad(1:klon)
 c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solswad,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d ,zx_tmp_2d)
-      CALL histwrite(nid_mth,"solsad",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d ,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"solsad",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1:klon) = topsw(1:klon) - topswai(1:klon)
 c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topswai,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d ,zx_tmp_2d)
-      CALL histwrite(nid_mth,"topsai",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d ,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"topsai",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1:klon) = solsw(1:klon) - solswai(1:klon)
 c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solswai,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d ,zx_tmp_2d)
-      CALL histwrite(nid_mth,"solsai",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c     endif
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, bils,zx_tmp_2d)
-      CALL histwrite(nid_mth,"bils",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d ,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"solsai",itau_w,zx_tmp_fi2d)
+cym
+c      endif
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, bils,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"bils",itau_w,bils)
 c
       zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
 c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, sens,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"sens",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
-      CALL histwrite(nid_mth,"fder",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"sens",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"fder",itau_w,fder)
 c
 c
@@ -315,22 +290,20 @@
 c
 c
-       CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxffonte,zx_tmp_2d)
-       CALL histwrite(nid_mth,"ffonte",itau_w,zx_tmp_2d,iim*jjmp1,
-     $                ndex2d)
-c
-       CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxfqcalving,zx_tmp_2d)
-       CALL histwrite(nid_mth,"fqcalving",itau_w,zx_tmp_2d,iim*jjmp1,
-     $                ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxffonte,zx_tmp_2d)
+       CALL histwrite_phy(nid_mth,"ffonte",itau_w,zxffonte)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxfqcalving,zx_tmp_2d)
+       CALL histwrite_phy(nid_mth,"fqcalving",itau_w,zxfqcalving)
 cIM: 171003
        DO nsrf = 1, nbsrf
         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"taux_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"taux_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
 C      
         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"tauy_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"tauy_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
        ENDDO
 cIM: 171003
@@ -341,38 +314,38 @@
        IF(nsrf.GT.1) THEN
         zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"pourc_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"pourc_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
        ENDIF !nsrf.GT.1
 C 
         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"tsol_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"tsol_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
         zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"sens_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"sens_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
         zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"lat_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d) 
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"lat_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
 C
         zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"flw_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"flw_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 c
         zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"fsw_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"fsw_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
         zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"wbils_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"wbils_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
 
@@ -381,58 +354,58 @@
 
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cdrm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cdrh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldl,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldm,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldm",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldh,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldt",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldq,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cldq",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"cdrm",itau_w,cdragm)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"cdrh",itau_w,cdragh)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldl,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"cldl",itau_w,cldl)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldm,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"cldm",itau_w,cldm)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldh,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"cldh",itau_w,cldh)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"cldt",itau_w,cldt)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldq,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"cldq",itau_w,cldq)
 c
       zx_tmp_fi2d(1:klon) = flwp(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"lwp",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"lwp",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1:klon) = fiwp(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"iwp",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ue,zx_tmp_2d)
-      CALL histwrite(nid_mth,"ue",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ve,zx_tmp_2d)
-      CALL histwrite(nid_mth,"ve",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, uq,zx_tmp_2d)
-      CALL histwrite(nid_mth,"uq",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, vq,zx_tmp_2d)
-      CALL histwrite(nid_mth,"vq",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"iwp",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ue,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"ue",itau_w,ue)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ve,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"ve",itau_w,ve)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, uq,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"uq",itau_w,uq)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, vq,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"vq",itau_w,vq)
 cKE43
       IF (iflag_con.GE.3) THEN ! sb
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cape,zx_tmp_2d)
-      CALL histwrite(nid_mth,"cape",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,pbase,zx_tmp_2d)
-      CALL histwrite(nid_mth,"pbase",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,ema_pct,zx_tmp_2d)
-      CALL histwrite(nid_mth,"ptop",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,ema_cbmf,zx_tmp_2d)
-      CALL histwrite(nid_mth,"fbase",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cape,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"cape",itau_w,cape)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,pbase,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"pbase",itau_w,pbase)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,ema_pct,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"ptop",itau_w,ema_pct)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,ema_cbmf,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"fbase",itau_w,ema_cbmf)
 c
 c34EK
@@ -440,7 +413,6 @@
       ENDIF !iflag_con.GE.3
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, prw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"prw",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, prw,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"prw",itau_w,prw)
 c
 c
@@ -450,19 +422,15 @@
       DO k=1, nlevENS
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulev(:,k),zx_tmp_2d)
-        CALL histwrite(nid_mth,"u"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlev(:,k),zx_tmp_2d)
-        CALL histwrite(nid_mth,"v"//clev(k),itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, wlev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_mth,"w"//clev(k),itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philev(:,k),zx_tmp_2d)
-      CALL histwrite(nid_mth,"phi"//clev(k),itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulev(:,k),zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"u"//clev(k),itau_w, ulev(:,k))
+c
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlev(:,k),zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"v"//clev(k),itau_w,vlev(:,k))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, wlev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"w"//clev(k),itau_w,wlev(:,k))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philev(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"phi"//clev(k),itau_w,philev(:,k))
 c
       ENDDO !nlevENS
@@ -474,15 +442,12 @@
 C
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, flwc,zx_tmp_3d)
-      CALL histwrite(nid_mth,"lwcon",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, fiwc,zx_tmp_3d)
-      CALL histwrite(nid_mth,"iwcon",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      CALL histwrite(nid_mth,"temp",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, flwc,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"lwcon",itau_w,flwc)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, fiwc,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"iwcon",itau_w,fiwc)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"temp",itau_w,t_seri)
 c
 c#ifdef histmthNMC
@@ -490,7 +455,6 @@
 c#endif
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
-      CALL histwrite(nid_mth,"ovap",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"ovap",itau_w,qx(:,:,ivap))
 c
 cIM: 071003
@@ -501,49 +465,38 @@
 c    .                                   iim*jjmp1*klev,ndex3d)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
-      CALL histwrite(nid_mth,"geop",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      CALL histwrite(nid_mth,"vitu",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
-      CALL histwrite(nid_mth,"vitv",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
-      CALL histwrite(nid_mth,"vitw",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
-      CALL histwrite(nid_mth,"pres",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldfra, zx_tmp_3d)
-      CALL histwrite(nid_mth,"rneb",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, rnebcon, zx_tmp_3d)
-      CALL histwrite(nid_mth,"rnebcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zx_rh, zx_tmp_3d)
-      CALL histwrite(nid_mth,"rhum",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, wo, zx_tmp_3d)
-      CALL histwrite(nid_mth,"ozone",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"geop",itau_w,zphi)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"vitu",itau_w,u_seri)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"vitv",itau_w,v_seri)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"vitw",itau_w,omega)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"pres",itau_w,pplay)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldfra, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"rneb",itau_w,cldfra)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, rnebcon, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"rnebcon",itau_w,rnebcon)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zx_rh, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"rhum",itau_w,zx_rh)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, wo, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"ozone",itau_w,wo)
 c
 cIM 22.03.04 BEG
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,ivap), 
-     .                 zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtphy",itau_w,d_t)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,ivap), 
+cym     .                 zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dqphy",itau_w, d_qx(:,:,ivap))
 cIM 22.03.04 END
 c
@@ -555,25 +508,25 @@
 c
         zx_tmp_fi2d(1 : klon) = falbe( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"albe_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"albe_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
         zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"rugs_"//clnsurf(nsrf),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"rugs_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, agesno,zx_tmp_2d)
-      CALL histwrite(nid_mth,"ages_"//clnsurf(nsrf),itau_w
-     $    ,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, agesno,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"ages_"//clnsurf(nsrf),itau_w
+     $    ,zx_tmp_fi2d)
 c
       ENDDO !nsrf=1, nbsrf
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsol,zx_tmp_2d)
-      CALL histwrite(nid_mth,"albs",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsollw,zx_tmp_2d)
-      CALL histwrite(nid_mth,"albslw",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"albs",itau_w,albsol)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, albsollw,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"albslw",itau_w,albsollw)
 c
       ENDIF !lev_histmth.GE.3
@@ -582,164 +535,134 @@
       IF(lev_histmth.GE.4) THEN
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, clwcon0, zx_tmp_3d)
-      CALL histwrite(nid_mth,"clwcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, clwcon0, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"clwcon",itau_w,clwcon0)
 c
       IF (iflag_con.GE.3) THEN
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, Ma, zx_tmp_3d)
-      CALL histwrite(nid_mth,"Ma",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, upwd, zx_tmp_3d)
-      CALL histwrite(nid_mth,"upwd",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, dnwd, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dnwd",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, dnwd0, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dnwd0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      ENDIF !iflag_con.GE.3
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_dyn, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_dyn, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, Ma, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"Ma",itau_w,Ma)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, upwd, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"upwd",itau_w,upwd)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, dnwd, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dnwd",itau_w,dnwd)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, dnwd0, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dnwd0",itau_w,dnwd0)
+c
+
+      ENDIF
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_dyn, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtdyn",itau_w,d_t_dyn)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_dyn, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dqdyn",itau_w,d_q_dyn)
 c
 cIM: 101003 : K/30min ==> K/s
       zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_con, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtcon",itau_w,zx_tmp_fi3d)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_con, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dqcon",itau_w,d_q_con)
 c
 cIM: 101003 : K/30min ==> K/s
       zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtlsc",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtlsc",itau_w,zx_tmp_fi3d)
 cIM: 071003
 cIM: 101003 : K/30min ==> K/s
       zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+
      .                             d_t_eva(1:klon,1:klev))/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zx_tmp_fi3d, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtlschr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_lsc, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqlsc",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zx_tmp_fi3d, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtlschr",itau_w,zx_tmp_fi3d)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_lsc, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dqlsc",itau_w,d_q_lsc)
 c
 cIM: 101003 : K/30min ==> K/s
       zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_vdf, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtvdf",itau_w,zx_tmp_fi3d)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_vdf, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dqvdf",itau_w,d_q_vdf)
 c
 cIM: 101003 : K/30min ==> K/s
       zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dteva",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_eva, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqeva",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dteva",itau_w,zx_tmp_fi3d)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_eva, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dqeva",itau_w, d_q_eva)
 c
       zpt_conv = 0.
       where (ptconv) zpt_conv = 1.
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zpt_conv, zx_tmp_3d)
-      CALL histwrite(nid_mth,"ptconv",itau_w,zx_tmp_3d,
-     .                                   iim*(jjmp1)*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, ratqs, zx_tmp_3d)
-      CALL histwrite(nid_mth,"ratqs",itau_w,zx_tmp_3d,
-     .                                   iim*(jjmp1)*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zpt_conv, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"ptconv",itau_w,zpt_conv)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, ratqs, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"ratqs",itau_w,ratqs)
 c
 cIM: 101003 : K/30min ==> K/s
       zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_ajs, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtajs",itau_w,zx_tmp_fi3d)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_ajs, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dqajs",itau_w,d_q_ajs)
 c
 cIM: 101003 : K/day ==> K/s
 cIM: LMD_ARMIP3   zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)*pdtphys/RDAY 
       zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY 
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtswr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtswr",itau_w,zx_tmp_fi3d)
 c
 cIM: 101003 : K/day ==> K/s      
 cIM: LMD_ARMIP3   zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)*pdtphys/RDAY
       zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtsw0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtsw0",itau_w,zx_tmp_fi3d)
 c
 cIM: 101003 : K/day ==> K/s      
 cIM: LMD_ARMIP3     zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)*pdtphys/RDAY
       zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtlwr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtlwr",itau_w,zx_tmp_fi3d)
 c
 cIM: 101003 : K/day ==> K/s      
 cIM: LMD_ARMIP3     zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)*pdtphys/RDAY
       zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtlw0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtlw0",itau_w,zx_tmp_fi3d)
 c
 cIM: 101003 : deja en K/s      
       zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtec",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_vdf, zx_tmp_3d)
-      CALL histwrite(nid_mth,"duvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dvvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dtec",itau_w,zx_tmp_fi3d)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_vdf, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"duvdf",itau_w,d_u_vdf)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dvvdf",itau_w,d_v_vdf)
 c
       IF (ok_orodr) THEN
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oro, zx_tmp_3d)
-      CALL histwrite(nid_mth,"duoro",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_oro, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dvoro",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oro, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"duoro",itau_w,d_u_oro)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_oro, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dvoro",itau_w,d_v_oro)
 c
       ENDIF
 C
       IF (ok_orolf) THEN
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_lif, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dulif",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_lif, zx_tmp_3d)
-      CALL histwrite(nid_mth,"dvlif",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_lif, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dulif",itau_w,d_u_lif)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_lif, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dvlif",itau_w, d_v_lif)
       ENDIF
 C
@@ -748,26 +671,21 @@
 c
 c     IF (ok_ade.OR.ok_aie) THEN
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, re, zx_tmp_3d)
-      CALL histwrite(nid_mth,"re",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, fl, zx_tmp_3d)
-      CALL histwrite(nid_mth,"redenom",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldtau, zx_tmp_3d)
-      CALL histwrite(nid_mth,"tau",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldtaupi, zx_tmp_3d)
-      CALL histwrite(nid_mth,"taupi",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, re, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"re",itau_w,re)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, fl, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"redenom",itau_w,fl)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldtau, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"tau",itau_w,cldtau)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldtaupi, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"taupi",itau_w,cldtaupi)
 c     endif
 c
       IF (nqmax.GE.3) THEN
       DO iq=3,nqmax
-         CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,iq), zx_tmp_3d)
-         CALL histwrite(nid_mth,tnom(iq),itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+c         CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,iq), zx_tmp_3d)
+         CALL histwrite_phy(nid_mth,tnom(iq),itau_w,qx(:,:,iq))
       ENDDO
       ENDIF
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histmthNMC.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histmthNMC.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histmthNMC.h	(revision 634)
@@ -28,27 +28,21 @@
          ENDIF
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, tlevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_nmc,"t"//bb,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, tlevSTD(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_nmc,"t"//bb,itau_w,tlevSTD(:,k))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_nmc,"phi"//bb,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philevSTD(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_nmc,"phi"//bb,itau_w,philevSTD(:,k))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, qlevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_nmc,"q"//bb,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, qlevSTD(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_nmc,"q"//bb,itau_w,qlevSTD(:,k))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, rhlevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_nmc,"rh"//bb,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, rhlevSTD(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_nmc,"rh"//bb,itau_w,rhlevSTD(:,k))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_nmc,"u"//bb,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulevSTD(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_nmc,"u"//bb,itau_w,ulevSTD(:,k))
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_nmc,"v"//bb,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlevSTD(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_nmc,"v"//bb,itau_w,vlevSTD(:,k))
 c
       ENDDO !k=1, nlevSTD
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histrac.h
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histrac.h	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/write_histrac.h	(revision 634)
@@ -12,49 +12,43 @@
       
       i = NINT(zout/zsto)
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
-      CALL histwrite(nid_tra,"phis",itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pphis,zx_tmp_2d)
+      CALL histwrite_phy(nid_tra,"phis",itau_w,pphis)
 C
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,airephy,zx_tmp_2d)      
-      CALL histwrite(nid_tra,"aire",itau_w,zx_tmp_2d,iim*(jjm+1),ndex2d)
-#ifdef INCA
-      CALL gr_fi_ecrit(1, klon,iim,jjm+1, ps,zx_tmp_2d)
-      CALL histwrite(nid_tra,"ps",itau_w,zx_tmp_2d,
-     .     iim*(jjm+1),ndex2d)
-
-      CALL gr_fi_ecrit(1, klon,iim,jjm+1, ptrop,zx_tmp_2d)
-      CALL histwrite(nid_tra,"ptrop",itau_w,zx_tmp_2d,
-     .     iim*(jjm+1),ndex2d)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,airephy,zx_tmp_2d)      
+      CALL histwrite_phy(nid_tra,"aire",itau_w,airephy)
+#ifdef INCA
+cym      CALL gr_fi_ecrit(1, klon,iim,jjm+1, ps,zx_tmp_2d)
+      CALL histwrite_phy(nid_tra,"ps",itau_w,ps)
+
+      print *,"WRITE PTROP"
+cym      CALL gr_fi_ecrit(1, klon,iim,jjm+1, ptrop,zx_tmp_2d)
+      CALL histwrite_phy(nid_tra,"ptrop",itau_w,ptrop)
 
 C   3d FIELDS
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,t_seri, zx_tmp_3d)
-      CALL histwrite(nid_tra,"temp",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,u, zx_tmp_3d)
-      CALL histwrite(nid_tra,"u",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,v, zx_tmp_3d)
-      CALL histwrite(nid_tra,"v",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,sh, zx_tmp_3d)
-      CALL histwrite(nid_tra,"h2o",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pdel, zx_tmp_3d)
-      CALL histwrite(nid_tra,"pdel",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pplay, zx_tmp_3d)
-      CALL histwrite(nid_tra,"pmid",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+     
+       print *,"WRITE T_SERI"
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,t_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"temp",itau_w,t_seri)
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,u, zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"u",itau_w,u)
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,v, zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"v",itau_w,v)
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,sh, zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"h2o",itau_w,sh)
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pdel, zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"pdel",itau_w,pdel)
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pplay, zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"pmid",itau_w,pplay)
+
 
 ! Ajout Anne
 !#ifdef INCA_AER
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,airm, zx_tmp_3d)
-      CALL histwrite(nid_tra,"airm",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
+c      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,airm, zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"airm",itau_w,airm)
 !#endif
 
@@ -65,70 +59,60 @@
       DO it=1, phtcnt
       WRITE(str2,'(i2.2)') it
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,it),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"j"//str2,itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,it),
+cym     .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"j"//str2,itau_w,jrates(:,:,it))
       ENDDO
 
       DO it=1, hetcnt
       WRITE(str2,'(i2.2)') it
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hrates(1,1,it),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"w"//str2,itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hrates(1,1,it),
+cym     .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"w"//str2,itau_w,hrates(:,:,it))
       ENDDO
 
       DO it=1, extcnt
       WRITE(str2,'(i2.2)') it
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,extflx(1,1,it),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"ext"//str2,itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,extflx(1,1,it),
+cym     .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"ext"//str2,itau_w,extflx(:,:,it))
       ENDDO
 
       DO it=1, nfs
       WRITE(str2,'(i2.2)') it
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,invariants(1,1,it),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"INV"//str2,itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,invariants(1,1,it),
+cym     .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"INV"//str2,itau_w,invariants(:,:,it))
       ENDDO
 #else
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,2),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"jO3",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,4),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"jNO2",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,13),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"jH2O2",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hrates(1,1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"wHNO3",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,krates(1,1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"kN2O5",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,extflx(1,1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"LghtNO",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,2),
+cym    .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"jO3",itau_w,jrates(:,:,2))
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,4),
+cym     .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"jNO2",itau_w,jrates(:,:,4))
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,jrates(1,1,13),
+cym     .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"jH2O2",itau_w,jrates(:,:,13))
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hrates(1,1,1),
+cym     .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"wHNO3",itau_w,hrates(:,:,1))
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,krates(1,1,1),
+cym     .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"kN2O5",itau_w,krates(:,:,1))
+
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,extflx(1,1,1),
+cym     .     zx_tmp_3d)
+      CALL histwrite_phy(nid_tra,"LghtNO",itau_w,extflx(:,:,1))
 #endif
       DO it=1, grpcnt
 
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,nas(1,1,it),zx_tmp_3d)
-      zx_tmp_3d = zx_tmp_3d * dry_mass / nadv_mass(it)
-      CALL histwrite(nid_tra,grpsym(it),itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,nas(1,1,it),zx_tmp_3d)
+cym      zx_tmp_3d = zx_tmp_3d * dry_mass / nadv_mass(it)
+      CALL histwrite_phy(nid_tra,grpsym(it),itau_w,
+     .          nas(:,:,it)* dry_mass / nadv_mass(it))
       ENDDO
 #endif
@@ -137,16 +121,15 @@
 
       it = id_CIDUSTM
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,scavcoef_st(1,1,it),
-     .                  zx_tmp_3d)
-       CALL histwrite(nid_tra2,"scavcoef_st",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,scavcoef_cv(1,1,it),
-     .                  zx_tmp_3d)
-       CALL histwrite(nid_tra2,"scavcoef_cv",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
+cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,scavcoef_st(1,1,it),
+cym     .                  zx_tmp_3d)
+       CALL histwrite_phy(nid_tra,"scavcoef_st",itau_w,
+     .                scavcoef_st(:,:,it))
+cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,scavcoef_cv(1,1,it),
+cym     .                  zx_tmp_3d)
+       CALL histwrite_phy(nid_tra,"scavcoef_cv",itau_w,
+     .                 scavcoef_cv(:,:,it))
 
        CALL gr_fi_ecrit(1, klon,iim,jjm+1,angst(1),zx_tmp_2d)
-       CALL histwrite(nid_tra2,"AngstroemComp",itau_w,zx_tmp_2d,
-     .                     iim*(jjm+1),ndex2d)
+       CALL histwrite_phy(nid_tra2,"AngstroemComp",itau_w,angst(:))
 
 #endif
@@ -157,61 +140,62 @@
 #ifdef INCA
       IF ( prt_flag_ts(it) == 0 ) CYCLE
-      CALL gr_fi_ecrit(1, klon,iim,jjm+1, eflux(1,it),zx_tmp_2d)
-      CALL histwrite(nid_tra,"Emi_"//solsym(it),itau_w,zx_tmp_2d,
-     .     iim*(jjm+1),ndex2d)
-
-      CALL gr_fi_ecrit(1, klon,iim,jjm+1, dvel(1,it),zx_tmp_2d)
-      CALL histwrite(nid_tra,"Dep_"//solsym(it),itau_w,zx_tmp_2d,
-     .     iim*(jjm+1),ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjm+1, eflux(1,it),zx_tmp_2d)
+      CALL histwrite_phy(nid_tra,"Emi_"//solsym(it),itau_w,
+     .               eflux(:,it))
+
+cym      CALL gr_fi_ecrit(1, klon,iim,jjm+1, dvel(1,it),zx_tmp_2d)
+      CALL histwrite_phy(nid_tra,"Dep_"//solsym(it),itau_w,
+     .               dvel(:,it))
 #ifdef INCA_AER
       call diag(airephy,tr_seri)
 
       IF  ((it .ge. trmx) .and. (it .le. trnx)) then
-        CALL gr_fi_ecrit(1, klon,iim,jjm+1,sflux(1,it),zx_tmp_2d)
-        CALL histwrite(nid_tra2,"Sed_"//solsym(it),itau_w,
-     .         zx_tmp_2d,iim*(jjm+1),ndex2d)
-
-        CALL gr_fi_ecrit(1, klon,iim,jjm+1,dflux(1,it),zx_tmp_2d)
-        CALL histwrite(nid_tra2,"Dry_"//solsym(it),itau_w,zx_tmp_2d,
-     .                 iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(1, klon,iim,jjm+1,wflux(1,it),zx_tmp_2d)
-        CALL histwrite(nid_tra2,"Wet_"//solsym(it),itau_w,zx_tmp_2d,
-     .               iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(1, klon,iim,jjm+1,wsflux(1,it),zx_tmp_2d)
-        CALL histwrite(nid_tra2,"WetST_"//solsym(it),itau_w,zx_tmp_2d,
-     .            iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(1, klon,iim,jjm+1,wcflux(1,it),zx_tmp_2d)
-        CALL histwrite(nid_tra2,"WetCV_"//solsym(it),itau_w,zx_tmp_2d,
-     .         iim*(jjm+1),ndex2d)
-
-        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,eflux_alt(1,1,it),zx_tmp_3d)
-        CALL histwrite(nid_tra2,"Emi_alt_"//solsym(it),itau_w,zx_tmp_3d,
-     .              iim*(jjm+1)*klev,ndex3d)
-
-        CALL gr_fi_ecrit(1, klon,iim,jjm+1,aload(1,it),zx_tmp_2d)
-        CALL histwrite(nid_tra2,"Load_"//solsym(it),itau_w,zx_tmp_2d,
-     .              iim*(jjm+1),ndex2d)
-        CALL histwrite(nid_tra3,"Inst_Load_"//solsym(it),itau_w,zx_tmp_2d,
-     .             iim*(jjm+1),ndex2d)
-
-        CALL gr_fi_ecrit(1, klon,iim,jjm+1,sconc(1,it),zx_tmp_2d)
-        CALL histwrite(nid_tra2,"SConc_"//solsym(it),itau_w,zx_tmp_2d,
-     .           iim*(jjm+1),ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjm+1,sflux(1,it),zx_tmp_2d)
+        CALL histwrite_phy(nid_tra2,"Sed_"//solsym(it),itau_w,
+     .        sflux(:,it))
+
+cym        CALL gr_fi_ecrit(1, klon,iim,jjm+1,dflux(1,it),zx_tmp_2d)
+        CALL histwrite_phy(nid_tra2,"Dry_"//solsym(it),itau_w,
+     .                 dflux(:,it))
+cym        CALL gr_fi_ecrit(1, klon,iim,jjm+1,wflux(1,it),zx_tmp_2d)
+        CALL histwrite_phy(nid_tra2,"Wet_"//solsym(it),itau_w,
+     .                 wflux(:,it))
+cym        CALL gr_fi_ecrit(1, klon,iim,jjm+1,wsflux(1,it),zx_tmp_2d)
+        CALL histwrite_phy(nid_tra2,"WetST_"//solsym(it),itau_w,
+     .                 wsflux(:,it))
+cym        CALL gr_fi_ecrit(1, klon,iim,jjm+1,wcflux(1,it),zx_tmp_2d)
+        CALL histwrite_phy(nid_tra2,"WetCV_"//solsym(it),itau_w,
+     .                 wcflux(:,it))
+
+cym        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,eflux_alt(1,1,it),zx_tmp_3d)
+        CALL histwrite_phy(nid_tra2,"Emi_alt_"//solsym(it),itau_w,
+     .                 eflux_alt(:,:,it))
+
+cym        CALL gr_fi_ecrit(1, klon,iim,jjm+1,aload(1,it),zx_tmp_2d)
+        CALL histwrite_phy(nid_tra2,"Load_"//solsym(it),itau_w,
+     .                 aload(:,it))
+        CALL histwrite_phy(nid_tra3,"Inst_Load_"//solsym(it),itau_w,
+     .             aload(:,it))
+
+cym        CALL gr_fi_ecrit(1, klon,iim,jjm+1,sconc(1,it),zx_tmp_2d)
+        CALL histwrite_phy(nid_tra2,"SConc_"//solsym(it),itau_w,
+     .                sconc(:,it))
 
         do la=1,las
-          CALL gr_fi_ecrit(1, klon,iim,jjm+1,tausum(1,la,it),zx_tmp_2d)
-          CALL histwrite(nid_tra2,"OD_"//cla(la)//solsym(it),itau_w,zx_tmp_2d,
-     .                    iim*(jjm+1),ndex2d)
+cym          CALL gr_fi_ecrit(1, klon,iim,jjm+1,tausum(1,la,it),zx_tmp_2d)
+          CALL histwrite_phy(nid_tra2,"OD_"//cla(la)//solsym(it),
+     .                       itau_w,tausum(:,la,it))
         enddo
 
-        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,md(1,1,it),zx_tmp_3d)
-        CALL histwrite(nid_tra2,"MD_"//solsym(it),itau_w,zx_tmp_3d,
-     .              iim*(jjm+1)*klev,ndex3d)
+cym        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,md(1,1,it),zx_tmp_3d)
+        CALL histwrite_phy(nid_tra2,"MD_"//solsym(it),itau_w,
+     .                 md(:,:,it))
 
       endif
 #endif
 C champs 3D
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,tr_seri(1,1,it),zx_tmp_3d)
-
+cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,tr_seri(1,1,it),zx_tmp_3d)
+
+       zx_tmp_fi3d(:,:)=tr_seri(:,:,it)
        !Prefer vmr to mmr for transported species
        if( adv_mass(it) /= 0. ) then
@@ -219,5 +203,5 @@
          if (it .lt. trmx) then
 #endif
-       zx_tmp_3d = zx_tmp_3d * dry_mass / adv_mass(it)
+       zx_tmp_fi3d(:,:)= zx_tmp_fi3d(:,:) * dry_mass / adv_mass(it)
 #ifdef INCA_AER
          endif
@@ -226,32 +210,30 @@
 #ifdef INCA
        if ( solsym(it) == 'OX' ) then
-       zx_tmp_3d = zx_tmp_3d * dry_mass / nadv_mass(id_o3)
+       zx_tmp_fi3d(:,:)=zx_tmp_fi3d(:,:)*dry_mass/nadv_mass(id_o3)
        end if
 #endif
        end if
 
-       CALL histwrite(nid_tra,solsym(it),itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+       CALL histwrite_phy(nid_tra,solsym(it),itau_w,zx_tmp_fi3d)
 #else
 
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,tr_seri(1,1,it),zx_tmp_3d)
-       CALL histwrite(nid_tra,tnom(it+2),itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,tr_seri(1,1,it),zx_tmp_3d)
+       CALL histwrite_phy(nid_tra,tnom(it+2),itau_w,tr_seri(:,:,it))
        if (lessivage) THEN
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,flestottr(1,1,it),zx_tmp_3d)
-       CALL histwrite(nid_tra,"fl"//tnom(it+2),itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,flestottr(1,1,it),zx_tmp_3d)
+       CALL histwrite_phy(nid_tra,"fl"//tnom(it+2),itau_w,
+     .                                   flestottr(:,:,it))
       endif
       
 c----Olivia
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_th(1,1,it),zx_tmp_3d)
-       CALL histwrite(nid_tra,"d_tr_th_"//tnom(it+2),itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_cv(1,1,it),zx_tmp_3d)
-       CALL histwrite(nid_tra,"d_tr_cv_"//tnom(it+2),itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_cl(1,1,it),zx_tmp_3d)
-       CALL histwrite(nid_tra,"d_tr_cl_"//tnom(it+2),itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_th(1,1,it),zx_tmp_3d)
+       CALL histwrite_phy(nid_tra,"d_tr_th_"//tnom(it+2),itau_w,
+     .                                   d_tr_th(:,:,it))
+cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_cvi(1,1,it),zx_tmp_3d)
+       CALL histwrite_phy(nid_tra,"d_tr_cv_"//tnom(it+2),itau_w,
+     .                                  d_tr_cvi(:,:,it))
+cym       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_cli(1,1,it),zx_tmp_3d)
+       CALL histwrite_phy(nid_tra,"d_tr_cl_"//tnom(it+2),itau_w,
+     .                                   d_tr_cli(:,:,it))
 c---fin Olivia      
       
@@ -261,137 +243,64 @@
 #ifdef INCA
 !#ifdef INCA_CH4
-      CALL gr_fi_ecrit(1, klon,iim,jjm+1, o3_col(1), zx_tmp_2d)
-      CALL histwrite(nid_tra,"O3_column",itau_w,zx_tmp_2d,
-     .     iim*(jjm+1),ndex2d)
-
-      CALL gr_fi_ecrit(1, klon,iim,jjm+1, co_col(1), zx_tmp_2d)
-      CALL histwrite(nid_tra,"CO_column",itau_w,zx_tmp_2d,
-     .     iim*(jjm+1),ndex2d)
-
-      CALL gr_fi_ecrit(1, klon,iim,jjm+1, ch4_col(1), zx_tmp_2d)
-      CALL histwrite(nid_tra,"CH4_column",itau_w,zx_tmp_2d,
-     .     iim*(jjm+1),ndex2d)
-
-      CALL gr_fi_ecrit(1, klon,iim,jjm+1, no2_col(1), zx_tmp_2d)
-      CALL histwrite(nid_tra,"NO2_column",itau_w,zx_tmp_2d,
-     .     iim*(jjm+1),ndex2d)
-
-      CALL gr_fi_ecrit(1, klon,iim,jjm+1, o3_st_flx(1), zx_tmp_2d)
-      CALL histwrite(nid_tra,"O3_ste",itau_w,zx_tmp_2d,
-     .     iim*(jjm+1),ndex2d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,o3_prod(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"O3_prod",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,o3_loss(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"O3_loss",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex3d)
+      CALL histwrite_phy(nid_tra,"O3_column",itau_w,o3_col)
+
+      CALL histwrite_phy(nid_tra,"CO_column",itau_w,co_col)
+
+      CALL histwrite_phy(nid_tra,"CH4_column",itau_w,ch4_col)
+
+      CALL histwrite_phy(nid_tra,"NO2_column",itau_w,no2_col)
+
+      CALL histwrite_phy(nid_tra,"O3_ste",itau_w,o3_st_flx)
+
+      CALL histwrite_phy(nid_tra,"O3_prod",itau_w,o3_prod)
+
+      CALL histwrite_phy(nid_tra,"O3_loss",itau_w,o3_loss)
+
 ! Ajout Anne
 #ifdef INCA_AER
 ! for sulfur cycle
 
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,SO2_p_dmsoh(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"SO2_p_dmsoh",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,SO2_p_dmsno3(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"SO2_p_dmsno3",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,SO2_p_h2soh(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"SO2_p_h2soh",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,SO2_p_dmsooh(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"SO2_p_dmsooh",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,DMSO_p_dmsoh(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"DMSO_p_dmsoh",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,ASMSAM_p_dmsooh(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"ASMSAM_p_dmsooh",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,ASSO4M_p_so2oh(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"ASSO4M_p_so2oh",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,ASSO4M_p_so2h2o2(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"ASSO4M_p_so2h2o2",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,ASSO4M_p_so2o3(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"ASSO4M_p_so2o3",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
+      CALL histwrite_phy(nid_tra,"SO2_p_dmsoh",itau_w,SO2_p_dmsoh)
+
+      CALL histwrite_phy(nid_tra,"SO2_p_dmsno3",itau_w,SO2_p_dmsno3)
+
+      CALL histwrite_phy(nid_tra,"SO2_p_h2soh",itau_w,SO2_p_h2soh)
+
+      CALL histwrite_phy(nid_tra,"SO2_p_dmsooh",itau_w,SO2_p_dmsooh)
+
+      CALL histwrite_phy(nid_tra,"DMSO_p_dmsoh",itau_w,DMSO_p_dmsoh)
+
+      CALL histwrite_phy(nid_tra,"ASMSAM_p_dmsooh",itau_w,ASMSAM_p_dmsooh)
+
+      CALL histwrite_phy(nid_tra,"ASSO4M_p_so2oh",itau_w,ASSO4M_p_so2oh)
+
+      CALL histwrite_phy(nid_tra,"ASSO4M_p_so2h2o2",itau_w,ASSO4M_p_so2h2o2)
+
+      CALL histwrite_phy(nid_tra,"ASSO4M_p_so2o3",itau_w,ASSO4M_p_so2o3)
 
 c closing the sulfur budget
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, wet3d_so2(1,1), zx_tmp_3d)
-      CALL histwrite(nid_tra,"Wet3D_SO2",itau_w,zx_tmp_3d,
-     .     iim*(jjm+1)*klev,ndex)
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, wet3d_dms(1,1), zx_tmp_3d)
-      CALL histwrite(nid_tra,"Wet3D_DMS",itau_w,zx_tmp_3d,
-     .     iim*(jjm+1)*klev,ndex)
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, wet3d_hno3(1,1), zx_tmp_3d)
-      CALL histwrite(nid_tra,"Wet3D_HNO3",itau_w,zx_tmp_3d,
-     .     iim*(jjm+1)*klev,ndex)
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1, wet3d_h2o2(1,1), zx_tmp_3d)
-      CALL histwrite(nid_tra,"Wet3D_H2O2",itau_w,zx_tmp_3d,
-     .     iim*(jjm+1)*klev,ndex)
-
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,PH_HIST(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"PH_HIST",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
+      CALL histwrite_phy(nid_tra,"Wet3D_SO2",itau_w,wet3d_so2)
+      CALL histwrite_phy(nid_tra,"Wet3D_DMS",itau_w,wet3d_dms)
+      CALL histwrite_phy(nid_tra,"Wet3D_HNO3",itau_w,wet3d_hno3)
+      CALL histwrite_phy(nid_tra,"Wet3D_H2O2",itau_w,wet3d_h2o2)
+
+
+      CALL histwrite_phy(nid_tra,"PH_HIST",itau_w,PH_HIST)
 #endif
 
 #ifdef INCA_NMHC
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,CO2_basprod(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"CO2_basprod",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,CO2_nmhcprod(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"CO2_nmhcprod",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,CO2_radicalprod(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"CO2_radicalprod",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hno3_prod(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"HNO3_prod",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,hno3_loss(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"HNO3_loss",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,co_prod(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"CO_prod",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
-
-      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,co_loss(1,1),
-     .     zx_tmp_3d)
-      CALL histwrite(nid_tra,"CO_loss",itau_w,zx_tmp_3d,
-     .                                   iim*(jjm+1)*klev,ndex)
+      CALL histwrite_phy(nid_tra,"CO2_basprod",itau_w,CO2_basprod)
+
+      CALL histwrite_phy(nid_tra,"CO2_nmhcprod",itau_w,CO2_nmhcprod)
+
+      CALL histwrite_phy(nid_tra,"CO2_radicalprod",itau_w,CO2_radicalprod)
+
+      CALL histwrite_phy(nid_tra,"HNO3_prod",itau_w,hno3_prod)
+
+      CALL histwrite_phy(nid_tra,"HNO3_loss",itau_w,hno3_loss)
+
+      CALL histwrite_phy(nid_tra,"CO_prod",itau_w,co_prod)
+
+      CALL histwrite_phy(nid_tra,"CO_loss",itau_w,co_loss)
 
 #endif
@@ -413,71 +322,60 @@
 
 C abder
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,yu1,zx_tmp_2d)
-         CALL histwrite(nid_tra,"pyu1",itau_w,zx_tmp_2d,
-     s                                  iim*(jjm+1),ndex2d)
-
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,yv1,zx_tmp_2d)
-         CALL histwrite(nid_tra,"pyv1",itau_w,zx_tmp_2d,
-     s                                  iim*(jjm+1),ndex2d)
-
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol1,zx_tmp_2d)
-         CALL histwrite(nid_tra,"ftsol1",itau_w,zx_tmp_2d,
-     s                                       iim*(jjm+1),ndex2d)
-
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol2,zx_tmp_2d)
-         CALL histwrite(nid_tra,"ftsol2",itau_w,zx_tmp_2d,
-     s                                       iim*(jjm+1),ndex2d)
-
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol3,zx_tmp_2d)
-         CALL histwrite(nid_tra,"ftsol3",itau_w,zx_tmp_2d,
-     s                                      iim*(jjm+1),ndex2d)
-
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol4,zx_tmp_2d)
-         CALL histwrite(nid_tra,"ftsol4",itau_w,zx_tmp_2d,
-     s                                      iim*(jjm+1),ndex2d)
-
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf1,zx_tmp_2d)
-         CALL histwrite(nid_tra,"psrf1",itau_w,zx_tmp_2d,
-     s                                     iim*(jjm+1),ndex2d)
-
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf2,zx_tmp_2d)
-         CALL histwrite(nid_tra,"psrf2",itau_w,zx_tmp_2d,
-     s                                     iim*(jjm+1),ndex2d)
-
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf3,zx_tmp_2d)
-         CALL histwrite(nid_tra,"psrf3",itau_w,zx_tmp_2d,
-     s                                     iim*(jjm+1),ndex2d)
-
-         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf4,zx_tmp_2d)
-         CALL histwrite(nid_tra,"psrf4",itau_w,zx_tmp_2d,
-     s                                     iim*(jjm+1),ndex2d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pplay,zx_tmp_3d)
-        CALL histwrite(nid_tra,"pplay",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
-
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,t_seri,zx_tmp_3d)
-        CALL histwrite(nid_tra,"t",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pmfu,zx_tmp_3d)
-        CALL histwrite(nid_tra,"mfu",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pmfd,zx_tmp_3d)
-        CALL histwrite(nid_tra,"mfd",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pen_u,zx_tmp_3d)
-        CALL histwrite(nid_tra,"en_u",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pen_d,zx_tmp_3d)
-        CALL histwrite(nid_tra,"en_d",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pde_d,zx_tmp_3d)
-        CALL histwrite(nid_tra,"de_d",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pde_u,zx_tmp_3d)
-        CALL histwrite(nid_tra,"de_u",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
-        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,coefh,zx_tmp_3d)
-        CALL histwrite(nid_tra,"coefh",itau_w,zx_tmp_3d,
-     .                  iim*(jjm+1)*klev,ndex3d)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,yu1,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"pyu1",itau_w,yu1)
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,yv1,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"pyv1",itau_w,yv1)
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol1,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"ftsol1",itau_w,pftsol1)
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol2,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"ftsol2",itau_w,pftsol2)
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol3,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"ftsol3",itau_w,pftsol3)
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol4,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"ftsol4",itau_w,pftsol4)
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf1,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"psrf1",itau_w,ppsrf1)
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf2,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"psrf2",itau_w,ppsrf2)
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf3,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"psrf3",itau_w,ppsrf3)
+
+cym         CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf4,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"psrf4",itau_w,ppsrf4)
+	 
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pplay,zx_tmp_3d)
+        CALL histwrite_phy(nid_tra,"pplay",itau_w,pplay)
+
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,t_seri,zx_tmp_3d)
+        CALL histwrite_phy(nid_tra,"t",itau_w,t_seri)
+	
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pmfu,zx_tmp_3d)
+        CALL histwrite_phy(nid_tra,"mfu",itau_w,pmfu)
+     
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pmfd,zx_tmp_3d)
+        CALL histwrite_phy(nid_tra,"mfd",itau_w,pmfd)
+     
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pen_u,zx_tmp_3d)
+        CALL histwrite_phy(nid_tra,"en_u",itau_w,pen_u)
+     
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pen_d,zx_tmp_3d)
+        CALL histwrite_phy(nid_tra,"en_d",itau_w,pen_d)
+     
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pde_d,zx_tmp_3d)
+        CALL histwrite_phy(nid_tra,"de_d",itau_w,pde_d)
+     
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,pde_u,zx_tmp_3d)
+        CALL histwrite_phy(nid_tra,"de_u",itau_w,pde_u)
+     
+cym        CALL gr_fi_ecrit(klev,klon,iim,jjm+1,coefh,zx_tmp_3d)
+        CALL histwrite_phy(nid_tra,"coefh",itau_w,coefh)
 
 
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/yamada.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/yamada.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/yamada.F	(revision 634)
@@ -5,8 +5,9 @@
      s   ,zlev,zlay,u,v,teta,cd,q2,km,kn,ustar
      s   ,l_mix)
+      use dimphy
       IMPLICIT NONE
 c.......................................................................
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 c.......................................................................
 c
@@ -48,6 +49,6 @@
 
       integer nlay,nlev
-      PARAMETER (nlay=klev)
-      PARAMETER (nlev=klev+1)
+cym      PARAMETER (nlay=klev)
+cym      PARAMETER (nlev=klev+1)
 
       logical first
@@ -77,4 +78,7 @@
       fsm(ri)=1.96*(0.1912-ri)*(0.2341-ri)/((1.-ri)*(0.2231-ri))
 
+      nlay=klev
+      nlev=klev+1
+      
       if (0.eq.1.and.first) then
       do ig=1,1000
Index: /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/yamada4.F
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/yamada4.F	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/libf/phylmd/yamada4.F	(revision 634)
@@ -5,8 +5,9 @@
      s   ,zlev,zlay,u,v,teta,cd,q2,km,kn,kq,ustar
      s   ,iflag_pbl)
+      use dimphy
       IMPLICIT NONE
 c.......................................................................
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 c.......................................................................
 c
@@ -64,6 +65,6 @@
 
       integer nlay,nlev
-      PARAMETER (nlay=klev)
-      PARAMETER (nlev=klev+1)
+cym      PARAMETER (nlay=klev)
+cym      PARAMETER (nlev=klev+1)
 
       logical first
@@ -82,7 +83,7 @@
       real dtetadz(klon,klev+1)
       real m2cstat,mcstat,kmcstat
-      real l(klon,klev+1),l0(klon)
-      save l0
-
+      real l(klon,klev+1)
+      real,allocatable,save :: l0(:)
+      
       real sq(klon),sqz(klon),zz(klon,klev+1)
       integer iter
@@ -95,9 +96,12 @@
       real fl,zzz,zl0,zq2,zn2
 
-      real rino(klon,klev+1),smyam(klon,klev),styam(klon,klev)
-     s  ,lyam(klon,klev),knyam(klon,klev)
-     s  ,w2yam(klon,klev),t2yam(klon,klev)
-      common/pbldiag/rino,smyam,styam,lyam,knyam,w2yam,t2yam
-
+cym      real rino(klon,klev+1),smyam(klon,klev),styam(klon,klev)
+cym     s  ,lyam(klon,klev),knyam(klon,klev)
+cym     s  ,w2yam(klon,klev),t2yam(klon,klev)
+      real,allocatable,save,dimension(:,:) :: rino,smyam,styam,lyam,
+     s                                        knyam,w2yam,t2yam
+cym      common/pbldiag/rino,smyam,styam,lyam,knyam,w2yam,t2yam
+      logical,save :: firstcall=.true.
+      
       frif(ri)=0.6588*(ri+0.1776-sqrt(ri*ri-0.3221*ri+0.03156))
       falpha(ri)=1.318*(0.2231-ri)/(0.2341-ri)
@@ -106,4 +110,17 @@
      s     max(min(l0(ig)*kap*zlev(ig,k)/(kap*zlev(ig,k)+l0(ig))
      s     ,0.5*sqrt(q2(ig,k))/sqrt(max(n2(ig,k),1.e-10))) ,1.)
+
+
+      nlay=klev
+      nlev=klev+1
+      
+      if (firstcall) then
+        allocate(rino(klon,klev+1),smyam(klon,klev),styam(klon,klev))
+        allocate(lyam(klon,klev),knyam(klon,klev))
+        allocate(w2yam(klon,klev),t2yam(klon,klev))
+	allocate(l0(klon))
+	firstcall=.false.
+      endif
+
 
       if (.not.(iflag_pbl.ge.6.and.iflag_pbl.le.9)) then
Index: /LMDZ4/branches/LMDZ4_par_0/physiq.def
===================================================================
--- /LMDZ4/branches/LMDZ4_par_0/physiq.def	(revision 633)
+++ /LMDZ4/branches/LMDZ4_par_0/physiq.def	(revision 634)
@@ -4,8 +4,8 @@
 
 OCEAN=force 
-VEGET=y
-OK_journe=n
+VEGET=n
+OK_journe=y
 OK_mensuel=y
-OK_instan=n
+OK_instan=y
 if_ebil=0
 #
