Index: /LMDZ4/trunk/libf/phylmd/aeropt.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/aeropt.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/aeropt.F	(revision 766)
@@ -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/trunk/libf/phylmd/ajsec.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ajsec.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ajsec.F	(revision 766)
@@ -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/trunk/libf/phylmd/albedo.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/albedo.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/albedo.F	(revision 766)
@@ -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/trunk/libf/phylmd/atm2geo.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/atm2geo.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/atm2geo.F	(revision 766)
@@ -4,9 +4,12 @@
 C
       SUBROUTINE atm2geo ( im, jm, pte, ptn, plon, plat, pxx, pyy, pzz )
+      USE dimphy
+      IMPLICIT NONE
+      include 'dimensions90.h'
 cc
 cc Change wind local atmospheric coordinates to
 cc geocentric
 cc
-c$$$      INCLUDE 'param.h'
+cxxx      INCLUDE 'param.h'
 c
       INTEGER, INTENT (in)              :: im, jm
@@ -22,6 +25,7 @@
 c
       LOGICAL, SAVE :: linit = .FALSE.
+c$OMP THREADPRIVATE(linit)
 c
-c$$$      IF ( .NOT. linit ) THEN 
+cxxx      IF ( .NOT. linit ) THEN 
           zsinlon = SIN (rad * plon)
           zcoslon = COS (rad * plon)
@@ -29,19 +33,25 @@
           zcoslat = COS (rad * plat)
           linit = .TRUE.
-c$$$      ENDIF 
+cxxx      ENDIF 
 c
       pxx = - zsinlon * pte - zsinlat * zcoslon * ptn
       pyy =   zcoslon * pte - zsinlat * zsinlon * ptn
       pzz =   zcoslat * ptn
+
 c
 c Value at North Pole
-      pxx ( :,  1) = - ptn ( 1, 1)
-      pyy ( :,  1) = - pte ( 1, 1)
-      pzz ( :,  1) = 0.0
+      IF (jjphy_begin==1) THEN
+        pxx ( :,  1) = - ptn ( 1, 1)
+        pyy ( :,  1) = - pte ( 1, 1)
+        pzz ( :,  1) = 0.0
+      ENDIF
 c Value at South Pole
-      pxx ( :, jm) = + ptn ( 1, jm)
-      pyy ( :, jm) = + pte ( 1, jm)
-      pzz ( :, jm) = 0.0
-c
+      
+      IF (jjphy_end==jjm+1) THEN
+        pxx ( :, jm) = + ptn ( 1, jm)
+        pyy ( :, jm) = + pte ( 1, jm)
+        pzz ( :, jm) = 0.0
+      ENDIF
+ 
       RETURN 
       END SUBROUTINE atm2geo
Index: /LMDZ4/trunk/libf/phylmd/calcratqs.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/calcratqs.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/calcratqs.F	(revision 766)
@@ -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)
@@ -36,5 +37,5 @@
       save firstcall
       data firstcall/.true./
-
+c$OMP THREADPRIVATE(firstcall)
 
       REAL ratqsmin,ratqsmax,zx,epmax
@@ -46,4 +47,7 @@
       save ratqs1,ratqs2,ratqs3,ratqs4
       save ratqsc1,ratqsc2,ratqsc3,ratqsc4
+c$OMP THREADPRIVATE(ratqsmin,ratqsmax,epmax)
+c$OMP THREADPRIVATE(ratqs1,ratqs2,ratqs3,ratqs4)
+c$OMP THREADPRIVATE(ratqsc1,ratqsc2,ratqsc3,ratqsc4)
       real zpt_conv(klon,klev)
 
Index: /LMDZ4/trunk/libf/phylmd/calcul_divers.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/calcul_divers.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/calcul_divers.h	(revision 766)
@@ -5,5 +5,5 @@
 c initialisations diverses au "debut" du mois
 c
-      IF(MOD(itap,NINT(ecrit_mth/dtime)).EQ.1) THEN
+      IF(MOD(itap,ecrit_mth).EQ.1) THEN
          DO i=1, klon
           nday_rain(i)=0.
@@ -17,7 +17,7 @@
        ENDDO
 c
-      ENDIF
+      ENDIF !MOD(itap,ecrit_mth).EQ.1
 c
-      IF(MOD(itap,NINT(ecrit_day/dtime)).EQ.0) THEN
+      IF(MOD(itap,ecrit_day).EQ.0) THEN
 c
 cIM calcul total_rain, nday_rain
@@ -27,3 +27,3 @@
         IF(total_rain(i).GT.0.) nday_rain(i)=nday_rain(i)+1.
        ENDDO
-      ENDIF
+      ENDIF !itap.EQ.ecrit_mth
Index: /LMDZ4/trunk/libf/phylmd/calcul_simulISCCP.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/calcul_simulISCCP.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/calcul_simulISCCP.h	(revision 766)
@@ -64,15 +64,20 @@
 c
       IF (debut) THEN
+c$OMP MASTER
 c     open(99,file='tautab.bin',access='sequential',
 c    $     form='unformatted',status='old')
-c     read(99) tautab
+c     read(99) tautab_omp
 c
       open(99,file='tautab.formatted', FORM='FORMATTED')
-      read(99,'(f30.20)') tautab
+      read(99,'(f30.20)') tautab_omp
       close(99)
 c
       open(99,file='invtau.formatted',form='FORMATTED')
-      read(99,'(i10)') invtau
+      read(99,'(i10)') invtau_omp
       close(99)
+c$OMP END MASTER
+c$OMP BARRIER
+      tautab=tautab_omp
+      invtau=invtau_omp
 c
       ENDIF !debut
Index: /LMDZ4/trunk/libf/phylmd/calltherm.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/calltherm.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/calltherm.F	(revision 766)
@@ -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,11 @@
       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
+c$OMP THREADPRIVATE(zfm_therm,zentr_therm)
+      real :: zdt
+      logical,save :: first=.true.
+c$OMP THREADPRIVATE(first)
       integer i,k
 
@@ -47,5 +52,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/trunk/libf/phylmd/clesphys.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/clesphys.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/clesphys.h	(revision 766)
@@ -10,4 +10,11 @@
        REAL*8 RCO2, RCH4, RN2O, RCFC11, RCFC12  
        REAL*8 CH4_ppb, N2O_ppb, CFC11_ppt, CFC12_ppt
+
+cOM ---> correction du bilan d'eau global
+cOM Correction sur precip KE
+       REAL cvl_corr
+cOM Fonte calotte dans bilan eau
+       LOGICAL ok_lic_melt
+
 cIM simulateur ISCCP 
        INTEGER top_height, overlap
@@ -42,3 +49,6 @@
      S     , ecrit_mth, ecrit_tra, ecrit_reg
      S     , freqin_isccp, freqout_isccp, ip_ebil_phy
-     S     , ok_slab_sicOBS
+     S     , ok_slab_sicOBS, ok_lic_melt, cvl_corr
+     
+c$OMP THREADPRIVATE(/clesphys/)
+ 
Index: /LMDZ4/trunk/libf/phylmd/clmain.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/clmain.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/clmain.F	(revision 766)
@@ -4,4 +4,6 @@
 c
 c
+#define IO_DISCONNECTED
+
       SUBROUTINE clmain(dtime,itap,date0,pctsrf,pctsrf_new,
      .                  t,q,u,v,
@@ -24,5 +26,5 @@
      .                  pblh,capCL,oliqCL,cteiCL,pblT,
      .                  therm,trmb1,trmb2,trmb3,plcl,
-     .                  fqcalving,ffonte, run_off_lic_0,
+     .                  fqcalving,fqfonte,ffonte, run_off_lic_0,
 cIM "slab" ocean
      .                  flux_o, flux_g, tslab, seaice)
@@ -45,4 +47,5 @@
       USE ioipsl
       USE interface_surf
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -85,4 +88,5 @@
 ccc
 c ffonte----Flux thermique utilise pour fondre la neige
+c fqfonte -- quantite d'eau due a la fonte de la calotte
 c fqcalving-Flux d'eau "perdue" par la surface et necessaire pour limiter la
 c           hauteur de neige, en kg/m2/s
@@ -105,8 +109,8 @@
 c pblT------- T au nveau HCL
 c======================================================================
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "indicesol.h"
-c$$$ PB ajout pour soil
+cxxx PB ajout pour soil
 #include "dimsoil.h"
 #include "iniprint.h"
@@ -133,6 +137,6 @@
       REAL amn, amx
 cIM cf JLD
-      REAL y_fqcalving(klon), y_ffonte(klon)
-      REAL fqcalving(klon,nbsrf), ffonte(klon,nbsrf)
+      REAL y_fqcalving(klon), y_fqfonte(klon), y_ffonte(klon)
+      REAL fqcalving(klon,nbsrf), fqfonte(klon,nbsrf),ffonte(klon,nbsrf)
       REAL run_off_lic_0(klon), y_run_off_lic_0(klon)
 
@@ -159,5 +163,5 @@
       REAL albe(klon,nbsrf)
       REAL alblw(klon,nbsrf)
-c$$$ PB
+cxxx PB
       REAL fluxlat(klon,nbsrf)
 C
@@ -174,5 +178,5 @@
       REAL zv1(klon)
 cAA
-c$$$ PB ajout pour soil
+cxxx PB ajout pour soil
       LOGICAL soil_model
 cIM ajout seuils cdrm, cdrh
@@ -197,5 +201,5 @@
       real yfder(klon), ytaux(klon), ytauy(klon)
       REAL yrugm(klon), yrads(klon),yrugoro(klon)
-c$$$ PB
+cxxx PB
       REAL yfluxlat(klon)
 C
@@ -248,18 +252,25 @@
       CHARACTER*80 cldebug
       SAVE cldebug
+c$OMP THREADPRIVATE(cldebug)
       CHARACTER*8 cl_surf(nbsrf)
       SAVE cl_surf
+c$OMP THREADPRIVATE(cl_surf)
       INTEGER nhoridbg, nidbg
       SAVE nhoridbg, nidbg
+c$OMP THREADPRIVATE(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
       DATA first_appel/.true./
+c$OMP THREADPRIVATE(first_appel)
       LOGICAL debugindex
       SAVE debugindex
       DATA debugindex/.false./
+c$OMP THREADPRIVATE(debugindex)
       integer idayref
 #include "temps.h"
@@ -327,9 +338,10 @@
           call flush(6)
       endif
-      IF (debugindex .and. first_appel) THEN
-          first_appel=.false.
+      IF (first_appel) THEN
+!          first_appel=.false.
 !
 ! initialisation sorties netcdf
 !
+#ifndef IO_DISCONNECTED
           idayref = day_ini
           CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
@@ -355,4 +367,5 @@
           CALL histend(nidbg)
           CALL histsync(nidbg)
+#endif
       ENDIF 
           
@@ -409,5 +422,5 @@
       y_flux_u = 0.0
       y_flux_v = 0.0
-C$$ PB
+Cxx PB
       y_dflux_t = 0.0
       y_dflux_q = 0.0
@@ -424,5 +437,5 @@
       ENDDO
       END DO
-C§§§ PB
+C PB
       yfluxlat=0.
       flux_t = 0.
@@ -434,10 +447,10 @@
          d_t(i,k) = 0.0
          d_q(i,k) = 0.0
-c$$$         flux_t(i,k) = 0.0
-c$$$         flux_q(i,k) = 0.0
+cxxx         flux_t(i,k) = 0.0
+cxxx         flux_q(i,k) = 0.0
          d_u(i,k) = 0.0
          d_v(i,k) = 0.0
-c$$$         flux_u(i,k) = 0.0
-c$$$         flux_v(i,k) = 0.0
+cxxx         flux_u(i,k) = 0.0
+cxxx         flux_v(i,k) = 0.0
          zcoefh(i,k) = 0.0
       ENDDO
@@ -488,9 +501,10 @@
 c variables pour avoir une sortie IOIPSL des INDEX
 c
+#ifndef IO_DISCONNECTED
       IF (debugindex) THEN 
           tabindx(:)=0.
 c          tabindx(1:knon)=(/FLOAT(i),i=1:knon/)
           DO i=1,knon
-            tabindx(1:knon)=FLOAT(i)
+            tabindx(i)=FLOAT(i)
           END DO 
           debugtab(:,:)=0.
@@ -500,5 +514,9 @@
      $        ,ndexbg)
       ENDIF 
-      IF (knon.EQ.0) GOTO 99999
+#endif
+
+      fluxlat(:,nsrf) = 0.
+      
+cym      IF (knon.EQ.0) GOTO 99999
       DO j = 1, knon
       i = ni(j)
@@ -546,5 +564,5 @@
           yqsol(:)=0.
       ENDIF 
-c$$$ PB ajour pour soil
+cxxx PB ajour pour soil
       DO k = 1, nsoilmx
         DO j = 1, knon
@@ -567,5 +585,12 @@
 c
 c
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 c calculer Cdrag et les coefficients d'echange
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+c  Calcul anciens du LMD. Effectues de toutes facons.
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+
       CALL coefkz(nsrf, knon, ypaprs, ypplay,
 cIM 261103
@@ -705,8 +730,8 @@
 
 c FH modif sur le cdrag temperature
-c$$$PB : déplace dans clcdrag
-c$$$      do i=1,knon
-c$$$         ycoefh(i,1)=ycoefm(i,1)*0.8
-c$$$      enddo
+cxxxPB : d�lace dans clcdrag
+cxxx      do i=1,knon
+cxxx         ycoefh(i,1)=ycoefm(i,1)*0.8
+cxxx      enddo
 
 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
@@ -726,10 +751,10 @@
      e          ywindsp, 
 c -- LOOP
-c$$$     e          ysollw, ysolsw,
+cxxx     e          ysollw, ysolsw,
      e          ysollw, ysollwdown, ysolsw,yfluxlat,
      s          pctsrf_new, yagesno,
      s          y_d_t, y_d_q, y_d_ts, yz0_new,
      s          y_flux_t, y_flux_q, y_dflux_t, y_dflux_q,
-     s          y_fqcalving,y_ffonte,y_run_off_lic_0,
+     s          y_fqcalving,y_fqfonte,y_ffonte,y_run_off_lic_0,
 cIM "slab" ocean
      s          y_flux_o, y_flux_g, ytslab, y_seaice)
@@ -758,15 +783,15 @@
           y_d_t(j,k) = y_d_t(j,k) * ypct(j)
           y_d_q(j,k) = y_d_q(j,k) * ypct(j)
-C§§§ PB
+C PB
           flux_t(i,k,nsrf) = y_flux_t(j,k)
           flux_q(i,k,nsrf) = y_flux_q(j,k)
           flux_u(i,k,nsrf) = y_flux_u(j,k)
           flux_v(i,k,nsrf) = y_flux_v(j,k)
-c$$$ PB        y_flux_t(j,k) = y_flux_t(j,k) * ypct(j)
-c$$$ PB        y_flux_q(j,k) = y_flux_q(j,k) * ypct(j)
+cxxx PB        y_flux_t(j,k) = y_flux_t(j,k) * ypct(j)
+cxxx PB        y_flux_q(j,k) = y_flux_q(j,k) * ypct(j)
           y_d_u(j,k) = y_d_u(j,k) * ypct(j)
           y_d_v(j,k) = y_d_v(j,k) * ypct(j)
-c$$$ PB        y_flux_u(j,k) = y_flux_u(j,k) * ypct(j)
-c$$$ PB        y_flux_v(j,k) = y_flux_v(j,k) * ypct(j)
+cxxx PB        y_flux_u(j,k) = y_flux_u(j,k) * ypct(j)
+cxxx PB        y_flux_v(j,k) = y_flux_v(j,k) * ypct(j)
         ENDDO
       ENDDO
@@ -790,5 +815,5 @@
          rugos(i,nsrf) = yz0_new(j)
          fluxlat(i,nsrf) = yfluxlat(j)
-c$$$ pb         rugmer(i) = yrugm(j)
+cxxx pb         rugmer(i) = yrugm(j)
          IF (nsrf .EQ. is_oce) then 
            rugmer(i) = yrugm(j)
@@ -798,4 +823,5 @@
          agesno(i,nsrf) = yagesno(j)
          fqcalving(i,nsrf) = y_fqcalving(j)        
+         fqfonte(i,nsrf) = y_fqfonte(j)        
          ffonte(i,nsrf) = y_ffonte(j)        
          cdragh(i) = cdragh(i) + ycoefh(j,1)
@@ -818,5 +844,5 @@
         END DO
       END IF 
-c$$$ PB ajout pour soil
+c@$$ PB ajout pour soil
       ftsoil(:,:,nsrf) = 0.
       DO k = 1, nsoilmx
@@ -838,10 +864,10 @@
          d_t(i,k) = d_t(i,k) + y_d_t(j,k)
          d_q(i,k) = d_q(i,k) + y_d_q(j,k)
-c$$$ PB        flux_t(i,k) = flux_t(i,k) + y_flux_t(j,k)
-c$$$         flux_q(i,k) = flux_q(i,k) + y_flux_q(j,k)
+c@$$ PB        flux_t(i,k) = flux_t(i,k) + y_flux_t(j,k)
+c@$$         flux_q(i,k) = flux_q(i,k) + y_flux_q(j,k)
          d_u(i,k) = d_u(i,k) + y_d_u(j,k)
          d_v(i,k) = d_v(i,k) + y_d_v(j,k)
-c$$$  PB       flux_u(i,k) = flux_u(i,k) + y_flux_u(j,k)
-c$$$         flux_v(i,k) = flux_v(i,k) + y_flux_v(j,k)
+c@$$  PB       flux_u(i,k) = flux_u(i,k) + y_flux_u(j,k)
+c@$$         flux_v(i,k) = flux_v(i,k) + y_flux_v(j,k)
          zcoefh(i,k) = zcoefh(i,k) + ycoefh(j,k)
       ENDDO
@@ -1013,10 +1039,10 @@
      s                d_t, d_q, d_ts, z0_new, 
      s                flux_t, flux_q,dflux_s,dflux_l,
-     s                fqcalving,ffonte,run_off_lic_0,
+     s                fqcalving,fqfonte,ffonte,run_off_lic_0,
 cIM "slab" ocean
      s                flux_o,flux_g,tslab,seaice)
 
       USE interface_surf
-
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1025,5 +1051,5 @@
 c======================================================================
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -1089,7 +1115,9 @@
 c Flux thermique utiliser pour fondre la neige
       REAL ffonte(klon)
-c Flux d'eau "perdue" par la surface et nécessaire pour que limiter la
+c Flux d'eau "perdu" par la surface et n�essaire pour que limiter la
 c hauteur de neige, en kg/m2/s
       REAL fqcalving(klon)
+c Quantite d'eau de fonte de la calotte kg/m?s
+      REAL fqfonte(klon)
 cIM "slab" ocean
       REAL tslab(klon)  !temperature du slab ocean (K) (OCEAN='slab  ')
@@ -1139,5 +1167,5 @@
       real sollw(klon), sollwdown(klon), swnet(klon), swdown(klon)
       real p1lay(klon)
-c$$$C PB ajout pour soil
+c@$$C PB ajout pour soil
       LOGICAL soil_model
       REAL tsoil(klon, nsoilmx)
@@ -1325,5 +1353,5 @@
      s evap, fluxsens, fluxlat, dflux_l, dflux_s,              
      s tsol_rad, tsurf_new, alb_new, alblw, emis_new, z0_new, 
-     s pctsrf_new, agesno,fqcalving,ffonte, run_off_lic_0,
+     s pctsrf_new, agesno,fqcalving,fqfonte,ffonte, run_off_lic_0,
 cIM "slab" ocean 
      s flux_o, flux_g, tslab, seaice)
@@ -1375,4 +1403,5 @@
      e                  paprs,pplay,delp,
      s                  d_ven,flux_v)
+      use dimphy
       IMPLICIT none
 c======================================================================
@@ -1397,6 +1426,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
@@ -1500,4 +1529,5 @@
      .                  qsurf, 
      .                  pcfm, pcfh)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1522,6 +1552,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"
@@ -1569,5 +1599,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.)
@@ -1604,4 +1634,5 @@
       LOGICAL appel1er
       SAVE appel1er
+c$OMP THREADPRIVATE(appel1er)
 c
 c Fonctions thermodynamiques et fonctions d'instabilite
@@ -1617,4 +1648,7 @@
       DATA appel1er /.TRUE./
 c
+cym
+      isommet=klev
+      
       IF (appel1er) THEN
         if (prt_level > 9) THEN
@@ -1820,4 +1854,5 @@
       SUBROUTINE coefkz2(nsrf, knon, paprs, pplay,t,
      .                  pcfm, pcfh)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1836,6 +1871,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"
@@ -1923,4 +1958,5 @@
       SUBROUTINE calbeta(dtime,indice,knon,snow,qsol,
      .                    vbeta,vcal,vdif)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1931,6 +1967,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"
@@ -2000,4 +2036,5 @@
      .                    tsol,beta,u,v,t,q,
      .                    cd_h, cd_m, pcfh, pcfm, cgh, cgq)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -2014,6 +2051,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"
@@ -2034,5 +2071,5 @@
 c
       INTEGER isommet
-      PARAMETER (isommet=klev)
+cym      PARAMETER (isommet=klev)
       REAL vk
       PARAMETER (vk=0.40)
@@ -2110,4 +2147,7 @@
 c Initialisation
 c
+cym
+      isommet=klev
+
       DO i = 1, klon
          pcfh(i,1) = cd_h(i)
Index: /LMDZ4/trunk/libf/phylmd/cltrac.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/cltrac.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/cltrac.F	(revision 766)
@@ -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/trunk/libf/phylmd/cltracrn.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/cltracrn.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/cltracrn.F	(revision 766)
@@ -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/trunk/libf/phylmd/coefkzmin.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/coefkzmin.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/coefkzmin.F	(revision 766)
@@ -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,17 +60,16 @@
 
       integer nlay,nlev
-      PARAMETER (nlay=klev)
-      PARAMETER (nlev=klev+1)
+cym      PARAMETER (nlay=klev)
+cym      PARAMETER (nlev=klev+1)
 
       integer ig,k
 
-      real kap
-      save kap
-      data kap/0.4/
+      real,parameter :: kap=0.4
 
       real frif,falpha,fsm
       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/trunk/libf/phylmd/comgeomphy.F90
===================================================================
--- /LMDZ4/trunk/libf/phylmd/comgeomphy.F90	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/comgeomphy.F90	(revision 766)
@@ -5,4 +5,5 @@
    real,save,allocatable :: rlatd(:)
    real,save,allocatable :: rlond(:)
+!$OMP THREADPRIVATE(airephy,cuphy,cvphy,rlatd,rlond)
 contains
   
@@ -11,9 +12,11 @@
   implicit none
     
-    allocate(airephy(klon))
-    allocate(cuphy(klon))
-    allocate(cvphy(klon))
-    allocate(rlatd(klon))
-    allocate(rlond(klon))
+ 
+    allocate(airephy(klon_omp))
+    allocate(cuphy(klon_omp))
+    allocate(cvphy(klon_omp))
+    allocate(rlatd(klon_omp))
+    allocate(rlond(klon_omp))
+
   end subroutine InitComgeomphy
   
Index: /LMDZ4/trunk/libf/phylmd/compbl.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/compbl.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/compbl.h	(revision 766)
@@ -1,2 +1,3 @@
       integer iflag_pbl
       common/compbl/iflag_pbl
+!$OMP THREADPRIVATE(/compbl/)
Index: /LMDZ4/trunk/libf/phylmd/concvl.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/concvl.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/concvl.F	(revision 766)
@@ -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,9 +83,13 @@
        INTEGER i,k,itra
        REAL qs(klon,klev)
-       REAL cbmf(klon)
-       SAVE cbmf
+cym       REAL cbmf(klon)
+cym       SAVE cbmf
+       REAL,ALLOCATABLE,SAVE :: cbmf(:)
+c$OMP THREADPRIVATE(cbmf)
        INTEGER ifrst
        SAVE ifrst
        DATA ifrst /0/
+c$OMP THREADPRIVATE(ifrst)
+
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -97,4 +102,5 @@
       IF (ifrst .EQ. 0) THEN
          ifrst = 1
+	 allocate(cbmf(klon))
          DO i = 1, klon
           cbmf(i) = 0.
Index: /LMDZ4/trunk/libf/phylmd/condsurf.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/condsurf.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/condsurf.F	(revision 766)
@@ -2,4 +2,5 @@
 c
       SUBROUTINE condsurf( jour, jourvrai, lmt_bils )
+      USE dimphy
       IMPLICIT none
 c
@@ -20,6 +21,6 @@
       INTEGER epais(2)
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "indicesol.h"
 #include "temps.h"
@@ -37,4 +38,10 @@
       INTEGER anneelim,anneemax
       CHARACTER*20 fich
+      
+      REAL :: lmt_bils_glo(klon2)
+      REAL,ALLOCATABLE,SAVE :: lmt_bils_mpi(:)
+      
+      LOGICAL,SAVE :: first
+c$OMP THREADPRIVATE(first)
 cc
 cc   .....................................................................
@@ -46,4 +53,8 @@
 c
 c
+      IF (first) THEN
+        ALLOCATE(lmt_bils_mpi(klon_mpi))
+      ENDIF
+      
       IF (jour.LT.0 .OR. jour.GT.(360-1)) THEN
          PRINT*,'Le jour demande n est pas correct: ', jour
@@ -80,4 +91,6 @@
 c Ouvrir le fichier en format NetCDF:
 c
+c$OMP MASTER
+      IF (phy_rank==0) THEN
       ierr = NF_OPEN (fich, NF_NOWRITE,nid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -93,5 +106,5 @@
       debut(1) = 1
       debut(2) = jourvrai
-      epais(1) = klon
+      epais(1) = klon2
       epais(2) = 1
 c
@@ -105,7 +118,7 @@
       PRINT*,'debut,epais',debut,epais,'jour,jourvrai',jour,jourvrai
 #ifdef NC_DOUBLE
-      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,debut,epais,lmt_bils)
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,debut,epais,lmt_bils_glo)
 #else
-      ierr = NF_GET_VARA_REAL(nid, nvarid,debut,epais,lmt_bils)
+      ierr = NF_GET_VARA_REAL(nid, nvarid,debut,epais,lmt_bils_glo)
 #endif
       IF (ierr .NE. NF_NOERR) THEN
@@ -118,4 +131,12 @@
 c
       ierr = NF_CLOSE(nid)
+      
+      ENDIF ! phyrank==0
+
+      CALL scatterField(lmt_bils_glo,lmt_bils_mpi,1)
+c$OMP END MASTER
+c$OMP BARRIER
+      CALL scatterField_omp(lmt_bils_mpi,lmt_bils,1)
+            
 c
 c
Index: /LMDZ4/trunk/libf/phylmd/conema3.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/conema3.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/conema3.F	(revision 766)
@@ -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,22 +85,46 @@
       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.
+c$OMP THREADPRIVATE(first)
+      
+cym      REAL em_t(klev)
+      REAL,ALLOCATABLE,SAVE :: em_t(:)
+c$OMP THREADPRIVATE(em_t)  
+cym      REAL em_q(klev)
+      REAL,ALLOCATABLE,SAVE :: em_q(:)
+c$OMP THREADPRIVATE(em_q) 
+cym      REAL em_qs(klev)
+      REAL,ALLOCATABLE,SAVE :: em_qs(:) 
+c$OMP THREADPRIVATE(em_qs)  
+cym      REAL em_u(klev), em_v(klev), em_tra(klev,ntrac)
+      REAL,ALLOCATABLE,SAVE :: em_u(:),em_v(:),em_tra(:,:)
+c$OMP THREADPRIVATE(em_u,em_v,em_tra)      
+cym      REAL em_ph(klev+1), em_p(klev)
+      REAL,ALLOCATABLE,SAVE ::em_ph(:),em_p(:)
+c$OMP THREADPRIVATE(em_ph,em_p)
+cym      REAL em_work1(klev), em_work2(klev)
+      REAL,ALLOCATABLE,SAVE ::em_work1(:),em_work2(:)
+c$OMP THREADPRIVATE(em_work1,em_work2)      
+cym      REAL em_precip, em_d_t(klev), em_d_q(klev)
+      REAL,SAVE :: em_precip
+c$OMP THREADPRIVATE(em_precip)      
+      REAL,ALLOCATABLE,SAVE :: em_d_t(:),em_d_q(:)
+c$OMP THREADPRIVATE(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(:,:)
+c$OMP THREADPRIVATE(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(:)
+c$OMP THREADPRIVATE(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
-
+c$OMP THREADPRIVATE(em_bas,em_top)
       REAL em_wd
       REAL em_qcond(klev)
@@ -113,12 +138,18 @@
 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(:)
+c$OMP THREADPRIVATE(emmip)
+cym      SAVE emmip
+cym      real emMke(klev)
+      REAL,ALLOCATABLE,SAVE ::emMke(:)
+c$OMP THREADPRIVATE(emMke)
+cym      save emMke
       real top
       real bas
-      real emMa(klev)
-      save emMa
+cym      real emMa(klev)
+      REAL,ALLOCATABLE,SAVE ::emMa(:)
+c$OMP THREADPRIVATE(emMa)
+cym      save emMa
       real Ma(klon,klev)
       real Ment(klev,klev)
@@ -151,8 +182,26 @@
 #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
-c$$$      print*,'debut conema'
+c@$$      print*,'debut conema'
 
       DO 999 i = 1, klon
@@ -170,11 +219,11 @@
           em_tra(l,itra) = tra(i,l,itra)
          enddo
-c$$$      print*,'em_t',em_t
-c$$$      print*,'em_q',em_q
-c$$$      print*,'em_qs',em_qs
-c$$$      print*,'em_u',em_u
-c$$$      print*,'em_v',em_v
-c$$$      print*,'em_tra',em_tra
-c$$$      print*,'em_p',em_p
+c@$$      print*,'em_t',em_t
+c@$$      print*,'em_q',em_q
+c@$$      print*,'em_qs',em_qs
+c@$$      print*,'em_u',em_u
+c@$$      print*,'em_v',em_v
+c@$$      print*,'em_tra',em_tra
+c@$$      print*,'em_p',em_p
 
  
@@ -184,9 +233,9 @@
          zx_qs= r2es * FOEEW(zx_t,zdelta)/em_p(l)/100.0
          zx_qs=MIN(0.5,zx_qs)
-c$$$       print*,'zx_qs',zx_qs
+c@$$       print*,'zx_qs',zx_qs
          zcor=1./(1.-retv*zx_qs) 
          zx_qs=zx_qs*zcor
          em_qs(l) = zx_qs
-c$$$      print*,'em_qs',em_qs
+c@$$      print*,'em_qs',em_qs
 c
          em_work1(l) = work1(i,l)
@@ -219,5 +268,5 @@
 1793  format('w avant convect ',/,10(1X,E13.5))
  
-c$$$      print*,'avant convect' 
+c@$$      print*,'avant convect' 
 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 c 
Index: /LMDZ4/trunk/libf/phylmd/conema3.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/conema3.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/conema3.h	(revision 766)
@@ -7,2 +7,3 @@
 
       common/comconema/epmax,ok_adj_ema,iflag_clw
+!$OMP THREADPRIVATE(/comconema/)
Index: /LMDZ4/trunk/libf/phylmd/conemav.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/conemav.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/conemav.F	(revision 766)
@@ -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,9 +74,12 @@
        INTEGER i,k,itra
        REAL qs(klon,klev)
-       REAL cbmf(klon)
-       SAVE cbmf
+cym       REAL cbmf(klon)
+cym       SAVE cbmf
+       REAL,ALLOCATABLE,SAVE :: cbmf(:)
+c$OMP THREADPRIVATE(cbmf)
        INTEGER ifrst
        SAVE ifrst
        DATA ifrst /0/
+c$OMP THREADPRIVATE(ifrst)
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -85,4 +89,5 @@
       IF (ifrst .EQ. 0) THEN
          ifrst = 1
+	 allocate(cbmf(klon))
          DO i = 1, klon
           cbmf(i) = 0.
Index: /LMDZ4/trunk/libf/phylmd/conf_phys.F90
===================================================================
--- /LMDZ4/trunk/libf/phylmd/conf_phys.F90	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/conf_phys.F90	(revision 766)
@@ -23,5 +23,5 @@
 include "clesphys.inc"
 include "compbl.h"
-#include "control.inc"
+include "control.inc"
 !
 ! Configuration de la "physique" de LMDZ a l'aide de la fonction
@@ -49,6 +49,14 @@
   REAL                 :: bl95_b0, bl95_b1
   real                 :: fact_cldcon, facttemps,ratqsbas,ratqshaut
-!IM integer            :: iflag_cldcon, if_ebil
   integer              :: iflag_cldcon
+
+  character (len = 6),SAVE  :: ocean_omp
+  logical,SAVE              :: ok_veget_omp, ok_newmicro_omp
+  logical,SAVE        :: ok_journe_omp, ok_mensuel_omp, ok_instan_omp        
+  LOGICAL,SAVE        :: ok_ade_omp, ok_aie_omp
+  REAL,SAVE           :: bl95_b0_omp, bl95_b1_omp
+  real,SAVE           :: fact_cldcon_omp, facttemps_omp,ratqsbas_omp
+  real,SAVE           :: ratqshaut_omp
+  integer,SAVE        :: iflag_cldcon_omp, ip_ebil_phy_omp
 
 ! Local
@@ -57,9 +65,33 @@
 
   integer :: iflag_thermals,nsplit_thermals
-!
-!
-!
-
-
+  integer,SAVE :: iflag_thermals_omp,nsplit_thermals_omp
+
+  REAL,SAVE :: R_ecc_omp,R_peri_omp,R_incl_omp,solaire_omp,co2_ppm_omp
+  REAL,SAVE :: RCO2_omp,CH4_ppb_omp,RCH4_omp,N2O_ppb_omp,RN2O_omp,CFC11_ppt_omp
+  REAL,SAVE :: RCFC11_omp,CFC12_ppt_omp,RCFC12_omp,epmax_omp
+  LOGICAL,SAVE :: ok_adj_ema_omp
+  INTEGER,SAVE :: iflag_clw_omp
+  REAL,SAVE :: cld_lc_lsc_omp,cld_lc_con_omp,cld_tau_lsc_omp,cld_tau_con_omp
+  REAL,SAVE :: ffallv_lsc_omp, ffallv_con_omp,coef_eva_omp
+  LOGICAL,SAVE :: reevap_ice_omp
+  INTEGER,SAVE :: iflag_pdf_omp
+  REAL,SAVE :: rad_froid_omp, rad_chau1_omp, rad_chau2_omp
+  INTEGER,SAVE :: top_height_omp,overlap_omp
+  REAL,SAVE :: cdmmax_omp,cdhmax_omp,ksta_omp,ksta_ter_omp
+  LOGICAL,SAVE :: ok_kzmin_omp
+  INTEGER,SAVE :: iflag_pbl_omp,lev_histhf_omp,lev_histday_omp,lev_histmth_omp
+  CHARACTER*4, SAVE :: type_run_omp
+  LOGICAL,SAVE :: ok_isccp_omp
+  REAL,SAVE :: lonmin_ins_omp, lonmax_ins_omp, latmin_ins_omp, latmax_ins_omp
+  REAL,SAVE :: ecrit_hf_omp, ecrit_day_omp, ecrit_mth_omp, ecrit_reg_omp
+  REAL,SAVE :: ecrit_tra_omp
+  LOGICAL, SAVE :: ok_slab_sicOBS_omp
+  REAL,SAVE :: cvl_corr_omp
+  LOGICAL,SAVE :: ok_lic_melt_omp
+!
+!
+!
+
+!$OMP MASTER
 !Config Key  = OCEAN 
 !Config Desc = Type d'ocean
@@ -67,6 +99,6 @@
 !Config Help = Type d'ocean utilise: force, slab,couple
 !
-  ocean = 'force '
-  call getin('OCEAN', ocean)
+  ocean_omp = 'force '
+  call getin('OCEAN', ocean_omp)
 !
 !Config Key  = VEGET 
@@ -75,6 +107,6 @@
 !Config Help = Type de modele de vegetation utilise
 !
-  ok_veget = .false.
-  call getin('VEGET', ok_veget)
+  ok_veget_omp = .false.
+  call getin('VEGET', ok_veget_omp)
 !
 !Config Key  = OK_journe
@@ -84,6 +116,6 @@
 !              journalieres 
 !
-  ok_journe = .false.
-  call getin('OK_journe', ok_journe)
+  ok_journe_omp = .false.
+  call getin('OK_journe', ok_journe_omp)
 !
 !Config Key  = OK_mensuel
@@ -93,6 +125,6 @@
 !              mensuelles 
 !
-  ok_mensuel = .true.
-  call getin('OK_mensuel', ok_mensuel)
+  ok_mensuel_omp = .true.
+  call getin('OK_mensuel', ok_mensuel_omp)
 !
 !Config Key  = OK_instan
@@ -102,6 +134,6 @@
 !              instantanees 
 !
-  ok_instan = .false.
-  call getin('OK_instan', ok_instan)
+  ok_instan_omp = .false.
+  call getin('OK_instan', ok_instan_omp)
 !
 !Config Key  = ok_ade
@@ -110,6 +142,6 @@
 !Config Help = Used in radlwsw.F
 !
-  ok_ade = .false.
-  call getin('ok_ade', ok_ade)
+  ok_ade_omp = .false.
+  call getin('ok_ade', ok_ade_omp)
 
 !
@@ -119,6 +151,6 @@
 !Config Help = Used in nuage.F and radlwsw.F
 !
-  ok_aie = .false.
-  call getin('ok_aie', ok_aie)
+  ok_aie_omp = .false.
+  call getin('ok_aie', ok_aie_omp)
 
 !
@@ -128,6 +160,6 @@
 !Config Help = Used in nuage.F
 !
-  bl95_b0 = 2.
-  call getin('bl95_b0', bl95_b0)
+  bl95_b0_omp = 2.
+  call getin('bl95_b0', bl95_b0_omp)
 
 !Config Key  = bl95_b1
@@ -136,6 +168,6 @@
 !Config Help = Used in nuage.F
 !
-  bl95_b1 = 0.2
-  call getin('bl95_b1', bl95_b1)
+  bl95_b1_omp = 0.2
+  call getin('bl95_b1', bl95_b1_omp)
 
 !
@@ -147,6 +179,6 @@
 !               
 !
-  ip_ebil_phy = 0
-  call getin('ip_ebil_phy', ip_ebil_phy)
+  ip_ebil_phy_omp = 0
+  call getin('ip_ebil_phy', ip_ebil_phy_omp)
 !!
 !! Constante solaire & Parametres orbitaux & taux gaz effet de serre BEG
@@ -158,6 +190,6 @@
 !               
 !valeur AMIP II
-  R_ecc = 0.016715
-  call getin('R_ecc', R_ecc)
+  R_ecc_omp = 0.016715
+  call getin('R_ecc', R_ecc_omp)
 !!
 !Config Key  = R_peri
@@ -168,6 +200,6 @@
 !
 !valeur AMIP II
-  R_peri = 102.7
-  call getin('R_peri', R_peri)
+  R_peri_omp = 102.7
+  call getin('R_peri', R_peri_omp)
 !!
 !Config Key  = R_incl
@@ -178,6 +210,6 @@
 !
 !valeur AMIP II
-  R_incl = 23.441
-  call getin('R_incl', R_incl)
+  R_incl_omp = 23.441
+  call getin('R_incl', R_incl_omp)
 !!
 !Config Key  = solaire
@@ -188,6 +220,6 @@
 !
 !valeur AMIP II
-  solaire = 1365.
-  call getin('solaire', solaire)
+  solaire_omp = 1365.
+  call getin('solaire', solaire_omp)
 !!
 !Config Key  = co2_ppm
@@ -198,6 +230,6 @@
 !
 !valeur AMIP II
-  co2_ppm = 348.
-  call getin('co2_ppm', co2_ppm)
+  co2_ppm_omp = 348.
+  call getin('co2_ppm', co2_ppm_omp)
 !!
 !Config Key  = RCO2
@@ -209,5 +241,5 @@
 ! RCO2 = 5.286789092164308E-04
 !ancienne valeur
-  RCO2 = co2_ppm * 1.0e-06  * 44.011/28.97 ! pour co2_ppm=348.
+  RCO2_omp = co2_ppm_omp * 1.0e-06  * 44.011/28.97 ! pour co2_ppm=348.
 
 !!  call getin('RCO2', RCO2)
@@ -228,6 +260,6 @@
   zzz = 1650.
   call getin('CH4_ppb', zzz)
-  CH4_ppb = zzz
-  RCH4 = CH4_ppb * 1.0E-09 * 16.043/28.97
+  CH4_ppb_omp = zzz
+  RCH4_omp = CH4_ppb_omp * 1.0E-09 * 16.043/28.97
 !!
 !Config Key  = RN2O
@@ -246,6 +278,6 @@
   zzz=306.
   call getin('N2O_ppb', zzz)
-  N2O_ppb = zzz
-  RN2O = N2O_ppb * 1.0E-09 * 44.013/28.97
+  N2O_ppb_omp = zzz
+  RN2O_omp = N2O_ppb_omp * 1.0E-09 * 44.013/28.97
 !!
 !Config Key  = RCFC11
@@ -258,6 +290,6 @@
   zzz = 280.
   call getin('CFC11_ppt',zzz)
-  CFC11_ppt = zzz
-  RCFC11=CFC11_ppt* 1.0E-12 * 137.3686/28.97
+  CFC11_ppt_omp = zzz
+  RCFC11_omp=CFC11_ppt_omp* 1.0E-12 * 137.3686/28.97
 ! RCFC11 = 1.327690990680013E-09
 !OK call getin('RCFC11', RCFC11)
@@ -272,6 +304,6 @@
   zzz = 484.
   call getin('CFC12_ppt',zzz)
-  CFC12_ppt = zzz
-  RCFC12 = CFC12_ppt * 1.0E-12 * 120.9140/28.97
+  CFC12_ppt_omp = zzz
+  RCFC12_omp = CFC12_ppt_omp * 1.0E-12 * 120.9140/28.97
 ! RCFC12 = 2.020102726958923E-09
 !OK call getin('RCFC12', RCFC12)
@@ -281,4 +313,13 @@
 !! KE
 !
+
+!Config key  = cvl_corr
+!Config Desc = Facteur multiplication des precip convectives dans KE
+!Config Def  = 1.00
+!Config Help = 1.02 pour un moderne ou un pre-ind. A ajuster pour un glaciaire
+  cvl_corr_omp = 1.00
+  CALL getin('cvl_corr', cvl_corr_omp)
+
+
 !Config Key  = epmax
 !Config Desc = Efficacite precip
@@ -286,6 +327,6 @@
 !Config Help = 
 !
-  epmax = .993
-  call getin('epmax', epmax)
+  epmax_omp = .993
+  call getin('epmax', epmax_omp)
 !
 !Config Key  = ok_adj_ema
@@ -294,6 +335,6 @@
 !Config Help = 
 !
-  ok_adj_ema = .false.
-  call getin('ok_adj_ema',ok_adj_ema)
+  ok_adj_ema_omp = .false.
+  call getin('ok_adj_ema',ok_adj_ema_omp)
 !
 !Config Key  = iflag_clw
@@ -302,6 +343,6 @@
 !Config Help = 
 !
-  iflag_clw = 0
-  call getin('iflag_clw',iflag_clw)
+  iflag_clw_omp = 0
+  call getin('iflag_clw',iflag_clw_omp)
 !
 !Config Key  = cld_lc_lsc 
@@ -310,6 +351,6 @@
 !Config Help = 
 !
-  cld_lc_lsc = 2.6e-4
-  call getin('cld_lc_lsc',cld_lc_lsc)
+  cld_lc_lsc_omp = 2.6e-4
+  call getin('cld_lc_lsc',cld_lc_lsc_omp)
 !
 !Config Key  = cld_lc_con
@@ -318,6 +359,6 @@
 !Config Help = 
 !
-  cld_lc_con = 2.6e-4
-  call getin('cld_lc_con',cld_lc_con)
+  cld_lc_con_omp = 2.6e-4
+  call getin('cld_lc_con',cld_lc_con_omp)
 !
 !Config Key  = cld_tau_lsc
@@ -326,6 +367,6 @@
 !Config Help = 
 !
-  cld_tau_lsc = 3600.
-  call getin('cld_tau_lsc',cld_tau_lsc)
+  cld_tau_lsc_omp = 3600.
+  call getin('cld_tau_lsc',cld_tau_lsc_omp)
 !
 !Config Key  = cld_tau_con
@@ -334,6 +375,6 @@
 !Config Help = 
 !
-  cld_tau_con = 3600.
-  call getin('cld_tau_con',cld_tau_con)
+  cld_tau_con_omp = 3600.
+  call getin('cld_tau_con',cld_tau_con_omp)
 !
 !Config Key  = ffallv_lsc
@@ -342,6 +383,6 @@
 !Config Help = 
 !
-  ffallv_lsc = 1.
-  call getin('ffallv_lsc',ffallv_lsc)
+  ffallv_lsc_omp = 1.
+  call getin('ffallv_lsc',ffallv_lsc_omp)
 !
 !Config Key  = ffallv_con
@@ -350,6 +391,6 @@
 !Config Help = 
 !
-  ffallv_con = 1.
-  call getin('ffallv_con',ffallv_con)
+  ffallv_con_omp = 1.
+  call getin('ffallv_con',ffallv_con_omp)
 !
 !Config Key  = coef_eva
@@ -358,6 +399,6 @@
 !Config Help = 
 !
-  coef_eva = 2.e-5
-  call getin('coef_eva',coef_eva)
+  coef_eva_omp = 2.e-5
+  call getin('coef_eva',coef_eva_omp)
 !
 !Config Key  = reevap_ice
@@ -366,6 +407,6 @@
 !Config Help = 
 !
-  reevap_ice = .false.
-  call getin('reevap_ice',reevap_ice)
+  reevap_ice_omp = .false.
+  call getin('reevap_ice',reevap_ice_omp)
 !
 !Config Key  = iflag_cldcon 
@@ -374,6 +415,6 @@
 !Config Help = 
 !
-  iflag_cldcon = 1
-  call getin('iflag_cldcon',iflag_cldcon)
+  iflag_cldcon_omp = 1
+  call getin('iflag_cldcon',iflag_cldcon_omp)
 
 !
@@ -383,6 +424,6 @@
 !Config Help = 
 !
-  iflag_pdf = 0
-  call getin('iflag_pdf',iflag_pdf)
+  iflag_pdf_omp = 0
+  call getin('iflag_pdf',iflag_pdf_omp)
 !
 !Config Key  = fact_cldcon
@@ -391,6 +432,6 @@
 !Config Help = 
 !
-  fact_cldcon = 0.375
-  call getin('fact_cldcon',fact_cldcon)
+  fact_cldcon_omp = 0.375
+  call getin('fact_cldcon',fact_cldcon_omp)
 
 !
@@ -400,6 +441,6 @@
 !Config Help = 
 !
-  facttemps = 1.e-4
-  call getin('facttemps',facttemps)
+  facttemps_omp = 1.e-4
+  call getin('facttemps',facttemps_omp)
 
 !
@@ -409,6 +450,6 @@
 !Config Help = 
 !
-  ok_newmicro = .true.
-  call getin('ok_newmicro',ok_newmicro)
+  ok_newmicro_omp = .true.
+  call getin('ok_newmicro',ok_newmicro_omp)
 !
 !Config Key  = ratqsbas
@@ -417,6 +458,6 @@
 !Config Help = 
 !
-  ratqsbas = 0.01
-  call getin('ratqsbas',ratqsbas)
+  ratqsbas_omp = 0.01
+  call getin('ratqsbas',ratqsbas_omp)
 !
 !Config Key  = ratqshaut
@@ -425,6 +466,6 @@
 !Config Help = 
 !
-  ratqshaut = 0.3
-  call getin('ratqshaut',ratqshaut)
+  ratqshaut_omp = 0.3
+  call getin('ratqshaut',ratqshaut_omp)
 
 !
@@ -434,6 +475,6 @@
 !Config Help = 
 !
-  rad_froid = 35.0
-  call getin('rad_froid',rad_froid)
+  rad_froid_omp = 35.0
+  call getin('rad_froid',rad_froid_omp)
 
 !
@@ -443,6 +484,6 @@
 !Config Help = 
 !
-  rad_chau1 = 13.0
-  call getin('rad_chau1',rad_chau1)
+  rad_chau1_omp = 13.0
+  call getin('rad_chau1',rad_chau1_omp)
 
 !
@@ -452,6 +493,6 @@
 !Config Help = 
 !
-  rad_chau2 = 9.0
-  call getin('rad_chau2',rad_chau2)
+  rad_chau2_omp = 9.0
+  call getin('rad_chau2',rad_chau2_omp)
 
 !
@@ -461,6 +502,6 @@
 !Config Help =
 !
-  top_height = 3
-  call getin('top_height',top_height)
+  top_height_omp = 3
+  call getin('top_height',top_height_omp)
 
 !
@@ -470,6 +511,6 @@
 !Config Help =
 !
-  overlap = 3
-  call getin('overlap',overlap)
+  overlap_omp = 3
+  call getin('overlap',overlap_omp)
 
 
@@ -481,6 +522,6 @@
 !Config Help =
 !
-  cdmmax = 1.3E-3
-  call getin('cdmmax',cdmmax)
+  cdmmax_omp = 1.3E-3
+  call getin('cdmmax',cdmmax_omp)
 
 !
@@ -490,6 +531,6 @@
 !Config Help =
 !
-  cdhmax = 1.1E-3
-  call getin('cdhmax',cdhmax)
+  cdhmax_omp = 1.1E-3
+  call getin('cdhmax',cdhmax_omp)
 
 !261103
@@ -500,6 +541,6 @@
 !Config Help =
 !
-  ksta = 1.0e-10
-  call getin('ksta',ksta)
+  ksta_omp = 1.0e-10
+  call getin('ksta',ksta_omp)
 
 !
@@ -509,6 +550,6 @@
 !Config Help =
 !
-  ksta_ter = 1.0e-10
-  call getin('ksta_ter',ksta_ter)
+  ksta_ter_omp = 1.0e-10
+  call getin('ksta_ter',ksta_ter_omp)
 
 !
@@ -518,6 +559,13 @@
 !Config Help =
 !
-  ok_kzmin = .true.
-  call getin('ok_kzmin',ok_kzmin)
+  ok_kzmin_omp = .true.
+  call getin('ok_kzmin',ok_kzmin_omp)
+
+!Config Key = ok_lic_melt
+!Config Desc = Prise en compte de la fonte de la calotte dans le bilan d'eau
+!Config Def  = .false.
+!Config Help = mettre a .false. pour assurer la conservation en eau
+  ok_lic_melt_omp = .false.
+  call getin('ok_lic_melt', ok_lic_melt_omp)
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -530,6 +578,6 @@
 !Config Help =
 !
-  iflag_pbl = 1
-  call getin('iflag_pbl',iflag_pbl)
+  iflag_pbl_omp = 1
+  call getin('iflag_pbl',iflag_pbl_omp)
 !
 !Config Key  = iflag_thermals
@@ -538,6 +586,6 @@
 !Config Help =
 !
-  iflag_thermals = 0
-  call getin('iflag_thermals',iflag_thermals)
+  iflag_thermals_omp = 0
+  call getin('iflag_thermals',iflag_thermals_omp)
 !
 !
@@ -547,6 +595,6 @@
 !Config Help =
 !
-  nsplit_thermals = 1
-  call getin('nsplit_thermals',nsplit_thermals)
+  nsplit_thermals_omp = 1
+  call getin('nsplit_thermals',nsplit_thermals_omp)
 
 
@@ -558,6 +606,6 @@
 !Config Help =
 !
-  lev_histhf = 1
-  call getin('lev_histhf',lev_histhf)
+  lev_histhf_omp = 1
+  call getin('lev_histhf',lev_histhf_omp)
 
 !
@@ -567,6 +615,6 @@
 !Config Help =
 !
-  lev_histday = 1
-  call getin('lev_histday',lev_histday)
+  lev_histday_omp = 1
+  call getin('lev_histday',lev_histday_omp)
 
 !
@@ -576,8 +624,8 @@
 !Config Help =
 !
-  lev_histmth = 2
-  call getin('lev_histmth',lev_histmth)
-
-!
+  lev_histmth_omp = 2
+  call getin('lev_histmth',lev_histmth_omp)
+
+  !
 !Config Key  = type_run
 !Config Desc =
@@ -585,8 +633,8 @@
 !Config Help =
 !
-  type_run = 'AMIP'
-  call getin('type_run',type_run)
-
-!
+  type_run_omp = 'AMIP'
+  call getin('type_run',type_run_omp)
+
+  !
 !Config Key  = ok_isccp
 !Config Desc =
@@ -595,6 +643,6 @@
 !
 ! ok_isccp = .true.
-  ok_isccp = .false.
-  call getin('ok_isccp',ok_isccp)
+  ok_isccp_omp = .false.
+  call getin('ok_isccp',ok_isccp_omp)
 
 !
@@ -607,6 +655,6 @@
 !Config Help = 
 !
-   lonmin_ins = 100.
-   call getin('lonmin_ins',lonmin_ins)
+   lonmin_ins_omp = 100.
+   call getin('lonmin_ins',lonmin_ins_omp)
 !
 !Config Key  = lonmax_ins
@@ -616,5 +664,5 @@
 !
    lonmax_ins = 130.
-   call getin('lonmax_ins',lonmax_ins)
+   call getin('lonmax_ins',lonmax_ins_omp)
 !
 !Config Key  = latmin_ins
@@ -623,6 +671,6 @@
 !Config Help = 
 !
-   latmin_ins = -20.
-   call getin('latmin_ins',latmin_ins)
+   latmin_ins_omp = -20.
+   call getin('latmin_ins',latmin_ins_omp)
 !
 !Config Key  = latmax_ins
@@ -631,6 +679,6 @@
 !Config Help =
 !
-   latmax_ins = 20.
-   call getin('latmax_ins',latmax_ins)
+   latmax_ins_omp = 20.
+   call getin('latmax_ins',latmax_ins_omp)
 !
 !Config Key  = ecrit_hf
@@ -639,6 +687,6 @@
 !Config Help =
 !
-  ecrit_hf = 1./8.
-  call getin('ecrit_hf',ecrit_hf)
+  ecrit_hf_omp = 1./8.
+  call getin('ecrit_hf',ecrit_hf_omp)
 !
 !Config Key  = ecrit_day
@@ -647,6 +695,6 @@
 !Config Help =
 !
-  ecrit_day = 1.0
-  call getin('ecrit_day',ecrit_day)
+  ecrit_day_omp = 1.0
+  call getin('ecrit_day',ecrit_day_omp)
 !
 !Config Key  = ecrit_mth
@@ -655,6 +703,6 @@
 !Config Help =
 !
-  ecrit_mth = 30.
-  call getin('ecrit_mth',ecrit_mth)
+  ecrit_mth_omp = 30.
+  call getin('ecrit_mth',ecrit_mth_omp)
 !
 !Config Key  = ecrit_tra
@@ -663,6 +711,6 @@
 !Config Help =
 !
-  ecrit_tra = 30.
-  call getin('ecrit_tra',ecrit_tra)
+  ecrit_tra_omp = 30.
+  call getin('ecrit_tra',ecrit_tra_omp)
 !
 !Config Key  = ecrit_reg
@@ -671,6 +719,6 @@
 !Config Help =
 !
-  ecrit_reg = 0.25   !4 fois par jour
-  call getin('ecrit_reg',ecrit_reg)
+  ecrit_reg_omp = 0.25   !4 fois par jour
+  call getin('ecrit_reg',ecrit_reg_omp)
 !
 !
@@ -682,6 +730,86 @@
 !              de glace de mer Observee
 !
-  ok_slab_sicOBS = .true.
-  call getin('ok_slab_sicOBS', ok_slab_sicOBS)
+  ok_slab_sicOBS_omp = .true.
+  call getin('ok_slab_sicOBS', ok_slab_sicOBS_omp)
+
+
+!$OMP END MASTER
+!$OMP BARRIER
+
+    R_ecc = R_ecc_omp
+    R_peri = R_peri_omp
+    R_incl = R_incl_omp
+    solaire = solaire_omp
+    co2_ppm = co2_ppm_omp
+    RCO2 = RCO2_omp
+    CH4_ppb = CH4_ppb_omp
+    RCH4 = RCH4_omp
+    N2O_ppb = N2O_ppb_omp
+    RN2O = RN2O_omp
+    CFC11_ppt = CFC11_ppt_omp
+    RCFC11 = RCFC11_omp
+    CFC12_ppt = CFC12_ppt_omp
+    RCFC12 = RCFC12_omp
+    epmax = epmax_omp
+    ok_adj_ema = ok_adj_ema_omp
+    iflag_clw = iflag_clw_omp
+    cld_lc_lsc = cld_lc_lsc_omp
+    cld_lc_con = cld_lc_con_omp
+    cld_tau_lsc = cld_tau_lsc_omp
+    cld_tau_con = cld_tau_con_omp
+    ffallv_lsc = ffallv_lsc_omp
+    ffallv_con = ffallv_con_omp
+    coef_eva = coef_eva_omp
+    reevap_ice = reevap_ice_omp
+    iflag_pdf = iflag_pdf_omp
+    rad_froid = rad_froid_omp
+    rad_chau1 = rad_chau1_omp
+    rad_chau2 = rad_chau2_omp
+    top_height = top_height_omp
+    overlap = overlap_omp
+    cdmmax = cdmmax_omp
+    cdhmax = cdhmax_omp
+    ksta = ksta_omp
+    ksta_ter = ksta_ter_omp
+    ok_kzmin = ok_kzmin_omp
+    iflag_pbl = iflag_pbl_omp
+    lev_histhf = lev_histhf_omp
+    lev_histday = lev_histday_omp
+    lev_histmth = lev_histmth_omp
+
+    ocean = ocean_omp
+    ok_veget = ok_veget_omp
+    ok_newmicro = ok_newmicro_omp
+    ok_journe = ok_journe_omp
+    ok_mensuel = ok_mensuel_omp
+    ok_instan = ok_instan_omp
+    ok_ade = ok_ade_omp
+    ok_aie = ok_aie_omp
+    bl95_b0 = bl95_b0_omp
+    bl95_b1 = bl95_b1_omp
+    fact_cldcon = fact_cldcon_omp
+    facttemps = facttemps_omp
+    ratqsbas = ratqsbas_omp
+    ratqshaut = ratqshaut_omp
+    iflag_cldcon = iflag_cldcon_omp
+    ip_ebil_phy = ip_ebil_phy_omp
+    iflag_thermals = iflag_thermals_omp
+    nsplit_thermals = nsplit_thermals_omp
+    type_run = type_run_omp
+    ok_isccp = ok_isccp_omp
+    lonmin_ins = lonmin_ins_omp
+    lonmax_ins = lonmax_ins_omp
+    latmin_ins = latmin_ins_omp
+    latmax_ins = latmax_ins_omp
+    ecrit_hf   = ecrit_hf_omp
+    ecrit_day = ecrit_day_omp
+    ecrit_mth = ecrit_mth_omp
+    ecrit_tra = ecrit_tra_omp
+    ecrit_reg = ecrit_reg_omp
+    ok_slab_sicOBS = ok_slab_sicOBS_omp
+    cvl_corr = cvl_corr_omp
+    ok_lic_melt = ok_lic_melt_omp
+
+!$OMP MASTER
 
   write(numout,*)' ##############################################'
@@ -703,4 +831,6 @@
   write(numout,*)' CFC11_ppt=',CFC11_ppt,' RCFC11 =  ',RCFC11
   write(numout,*)' CFC12_ppt=',CFC12_ppt,' RCFC12 =  ',RCFC12
+  write(numout,*)' cvl_corr=', cvl_corr
+  write(numout,*)'ok_lic_melt=', ok_lic_melt
   write(numout,*)' epmax = ', epmax
   write(numout,*)' ok_adj_ema = ', ok_adj_ema
@@ -741,8 +871,11 @@
   write(numout,*)' lonmin lonmax latmin latmax bilKP_ins =',&
  & lonmin_ins, lonmax_ins, latmin_ins, latmax_ins
-  write(numout,*)' ecrit_ hf, day, mth, reg, tra',&
+  write(numout,*)' ecrit_ hf, day, mth, reg',&
  & ecrit_hf, ecrit_day, ecrit_mth, ecrit_reg, ecrit_tra
+
+!$OMP END MASTER
+
   return
-
+  
   end subroutine conf_phys
 
@@ -761,4 +894,5 @@
 
   REAL          :: tau_calv
+  REAL,SAVE     :: tau_calv_omp
 
 ! Local
@@ -770,10 +904,18 @@
 !Config Help = 
 !
-  tau_calv = 360.
-  call getin('tau_calv',tau_calv)
-
+  tau_calv_omp = 360.*10.
+!$OMP MASTER
+  call getin('tau_calv',tau_calv_omp)
+!$OMP END MASTER
+!$OMP BARRIER
+
+  tau_calv=tau_calv_omp
+  
+!$OMP MASTER
   write(numout,*)' ##############################################'
   WRITE(numout,*)' Configuration de l''interface atm/surfaces  : '
   WRITE(numout,*)' tau_calv = ',tau_calv
+!$OMP END MASTER
+
   return
 
Index: /LMDZ4/trunk/libf/phylmd/conflx.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/conflx.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/conflx.F	(revision 766)
@@ -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"
@@ -265,4 +267,5 @@
       SAVE firstcal
       DATA firstcal / .TRUE. /
+c$OMP THREADPRIVATE(firstcal)
 C---------------------------------------------------------------------
       IF (firstcal) THEN
@@ -504,4 +507,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 +514,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 +633,5 @@
       SUBROUTINE flxbase(ptenh, pqenh, pgeoh, paph,
      *     ptu, pqu, plu, ldcum, kcbot, klab)
+      USE dimphy
       IMPLICIT none
 C----------------------------------------------------------------------
@@ -641,6 +646,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 +719,5 @@
      .     pmful, plude, pdmfup, kcbot, kctop, kctop0, kcum,
      .     pen_u, pde_u)
+      USE dimphy
       IMPLICIT none
 C----------------------------------------------------------------------
@@ -719,6 +725,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 +1024,5 @@
      .  ,  pten, prfl, psfl, pdpmel, ktopm2
      .  ,  pmflxr, pmflxs)
+      USE dimphy
       IMPLICIT none
 C----------------------------------------------------------------------
@@ -1023,11 +1030,11 @@
 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"
 #include "YOECUMF.h"
 C
-      REAL cevapcu(klev)
+      REAL cevapcu(klon,klev)
 C     -----------------------------------------------------------------
       REAL pqen(klon,klev), pqenh(klon,klev), pqsen(klon,klev)
@@ -1064,6 +1071,8 @@
 c
       DO 101 k=1,klev
-      CEVAPCU(k)=1.93E-6*261.*SQRT(1.E3/(38.3*0.293)
-     1 *SQRT(0.5*(paph(1,k)+paph(1,k+1))/paph(1,klev+1)) ) * 0.5/RG
+        DO i=1,klon
+      CEVAPCU(i,k)=1.93E-6*261.*SQRT(1.E3/(38.3*0.293)
+     1 *SQRT(0.5*(paph(i,k)+paph(i,k+1))/paph(i,klev+1)) ) * 0.5/RG
+        ENDDO
  101  CONTINUE
 c
@@ -1213,5 +1222,5 @@
          IF (zrfl.GT.1.0E-20) THEN
             zrnew=(MAX(0.,SQRT(zrfl/zcucov)-
-     .            CEVAPCU(k)*(paph(i,k+1)-paph(i,k))*
+     .            CEVAPCU(i,k)*(paph(i,k+1)-paph(i,k))*
      .            MAX(0.,pqsen(i,k)-pqen(i,k))))**2*zcucov
             zrmin=zrfl-zcucov*MAX(0.,0.8*pqsen(i,k)-pqen(i,k))
@@ -1262,10 +1271,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 +1343,5 @@
      .     ldcum, kcbot, kctop, pmfub, prfl, ptd, pqd,
      .     pmfd, pmfds, pmfdq, pdmfdp, kdtop, lddraf)
+      USE dimphy
       IMPLICIT none
 C
@@ -1350,6 +1361,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 +1455,5 @@
      .           ptd, pqd, pmfd, pmfds, pmfdq, pdmfdp,
      .           lddraf, pen_d, pde_d)
+      USE dimphy
       IMPLICIT none
 C
@@ -1461,6 +1473,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 +1571,5 @@
       END
       SUBROUTINE flxadjtq(pp, pt, pq, ldflag, kcall)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1568,6 +1581,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/trunk/libf/phylmd/conlmd.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/conlmd.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/conlmd.F	(revision 766)
@@ -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
@@ -154,10 +156,14 @@
       INTEGER ncpt
       SAVE ncpt
+c$OMP THREADPRIVATE(ncpt)
       REAL frac(nb) ! valeur de la maille fractionnelle
       SAVE frac
+c$OMP THREADPRIVATE(frac)
       INTEGER opt_cld(nb) ! option pour le modele nuageux
       SAVE opt_cld
+c$OMP THREADPRIVATE(opt_cld)
       LOGICAL appel1er
       SAVE appel1er
+c$OMP THREADPRIVATE(appel1er)
 c
 c Fonctions thermodynamiques:
@@ -301,4 +307,5 @@
      s                    d_t, d_q, d_ql, rneb,
      s                    rain, snow, ibas, itop,accompli,imprim)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -309,6 +316,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 +1071,5 @@
      s                  d_t, d_q, d_ql, rneb, 
      s                  rain, snow, ibas, itop)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1071,6 +1079,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
@@ -1145,4 +1153,5 @@
       LOGICAL appel1er
       SAVE appel1er
+c$OMP THREADPRIVATE(appel1er)
 c
 c Fonctions thermodynamiques
@@ -1587,4 +1596,5 @@
       END
       SUBROUTINE kuofcl(pt, pq, pg, pp, LDCUM, kcbot)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1603,6 +1613,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 +1698,5 @@
       END
       SUBROUTINE adjtq(pp, pt, pq, LDFLAG, KCALL)
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1706,6 +1717,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 +1808,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 +2107,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/trunk/libf/phylmd/convect1.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/convect1.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/convect1.F	(revision 766)
@@ -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/trunk/libf/phylmd/convect2.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/convect2.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/convect2.F	(revision 766)
@@ -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/trunk/libf/phylmd/convect3.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/convect3.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/convect3.F	(revision 766)
@@ -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)
 
@@ -1341,59 +1343,59 @@
 
 
-c$$$cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
-c$$$         call writeg1d(1,klev,ma,'ma  ','ma  ')
-c$$$          call writeg1d(1,klev,upwd,'upwd  ','upwd  ')
-c$$$          call writeg1d(1,klev,dnwd,'dnwd  ','dnwd  ')
-c$$$          call writeg1d(1,klev,dnwd0,'dnwd0  ','dnwd0  ')
-c$$$          call writeg1d(1,klev,tvp,'tvp  ','tvp  ')
-c$$$          call writeg1d(1,klev,tra(1:klev,3),'tra3  ','tra3  ')
-c$$$          call writeg1d(1,klev,tra(1:klev,4),'tra4  ','tra4  ')
-c$$$          call writeg1d(1,klev,tra(1:klev,5),'tra5  ','tra5  ')
-c$$$          call writeg1d(1,klev,tra(1:klev,6),'tra6  ','tra6  ')
-c$$$          call writeg1d(1,klev,tra(1:klev,7),'tra7  ','tra7  ')
-c$$$          call writeg1d(1,klev,tra(1:klev,8),'tra8  ','tra8  ')
-c$$$          call writeg1d(1,klev,tra(1:klev,9),'tra9  ','tra9  ')
-c$$$          call writeg1d(1,klev,tra(1:klev,10),'tra10','tra10')
-c$$$          call writeg1d(1,klev,tra(1:klev,11),'tra11','tra11')
-c$$$          call writeg1d(1,klev,tra(1:klev,12),'tra12','tra12')
-c$$$          call writeg1d(1,klev,tra(1:klev,13),'tra13','tra13')
-c$$$          call writeg1d(1,klev,tra(1:klev,14),'tra14','tra14')
-c$$$          call writeg1d(1,klev,tra(1:klev,15),'tra15','tra15')
-c$$$          call writeg1d(1,klev,tra(1:klev,16),'tra16','tra16')
-c$$$          call writeg1d(1,klev,tra(1:klev,17),'tra17','tra17')
-c$$$          call writeg1d(1,klev,tra(1:klev,18),'tra18','tra18')
-c$$$          call writeg1d(1,klev,tra(1:klev,19),'tra19','tra19')
-c$$$          call writeg1d(1,klev,tra(1:klev,20),'tra20','tra20 ')
-c$$$          call writeg1d(1,klev,trap(1:klev,1),'trp1','trp1')
-c$$$          call writeg1d(1,klev,trap(1:klev,2),'trp2','trp2')
-c$$$          call writeg1d(1,klev,trap(1:klev,3),'trp3','trp3')
-c$$$          call writeg1d(1,klev,trap(1:klev,4),'trp4','trp4')
-c$$$          call writeg1d(1,klev,trap(1:klev,5),'trp5','trp5')
-c$$$          call writeg1d(1,klev,trap(1:klev,10),'trp10','trp10')
-c$$$          call writeg1d(1,klev,trap(1:klev,12),'trp12','trp12')
-c$$$          call writeg1d(1,klev,trap(1:klev,15),'trp15','trp15')
-c$$$          call writeg1d(1,klev,trap(1:klev,20),'trp20','trp20')
-c$$$          call writeg1d(1,klev,ftra(1:klev,1),'ftr1  ','ftr1  ')
-c$$$          call writeg1d(1,klev,ftra(1:klev,2),'ftr2  ','ftr2  ')
-c$$$          call writeg1d(1,klev,ftra(1:klev,3),'ftr3  ','ftr3  ')
-c$$$          call writeg1d(1,klev,ftra(1:klev,4),'ftr4  ','ftr4  ')
-c$$$          call writeg1d(1,klev,ftra(1:klev,5),'ftr5  ','ftr5  ')
-c$$$          call writeg1d(1,klev,ftra(1:klev,6),'ftr6  ','ftr6  ')
-c$$$          call writeg1d(1,klev,ftra(1:klev,7),'ftr7  ','ftr7  ')
-c$$$          call writeg1d(1,klev,ftra(1:klev,8),'ftr8  ','ftr8  ')
-c$$$          call writeg1d(1,klev,ftra(1:klev,9),'ftr9  ','ftr9  ')
-c$$$          call writeg1d(1,klev,ftra(1:klev,10),'ftr10','ftr10')
-c$$$          call writeg1d(1,klev,ftra(1:klev,11),'ftr11','ftr11')
-c$$$          call writeg1d(1,klev,ftra(1:klev,12),'ftr12','ftr12')
-c$$$          call writeg1d(1,klev,ftra(1:klev,13),'ftr13','ftr13')
-c$$$          call writeg1d(1,klev,ftra(1:klev,14),'ftr14','ftr14')
-c$$$          call writeg1d(1,klev,ftra(1:klev,15),'ftr15','ftr15')
-c$$$          call writeg1d(1,klev,ftra(1:klev,16),'ftr16','ftr16')
-c$$$          call writeg1d(1,klev,ftra(1:klev,17),'ftr17','ftr17')
-c$$$          call writeg1d(1,klev,ftra(1:klev,18),'ftr18','ftr18')
-c$$$          call writeg1d(1,klev,ftra(1:klev,19),'ftr19','ftr19')
-c$$$          call writeg1d(1,klev,ftra(1:klev,20),'ftr20','ftr20 ')
-c$$$          call writeg1d(1,klev,mp,'mp  ','mp ')
-c$$$          call writeg1d(1,klev,Mke,'Mke  ','Mke ')
+c@$$cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+c@$$         call writeg1d(1,klev,ma,'ma  ','ma  ')
+c@$$          call writeg1d(1,klev,upwd,'upwd  ','upwd  ')
+c@$$          call writeg1d(1,klev,dnwd,'dnwd  ','dnwd  ')
+c@$$          call writeg1d(1,klev,dnwd0,'dnwd0  ','dnwd0  ')
+c@$$          call writeg1d(1,klev,tvp,'tvp  ','tvp  ')
+c@$$          call writeg1d(1,klev,tra(1:klev,3),'tra3  ','tra3  ')
+c@$$          call writeg1d(1,klev,tra(1:klev,4),'tra4  ','tra4  ')
+c@$$          call writeg1d(1,klev,tra(1:klev,5),'tra5  ','tra5  ')
+c@$$          call writeg1d(1,klev,tra(1:klev,6),'tra6  ','tra6  ')
+c@$$          call writeg1d(1,klev,tra(1:klev,7),'tra7  ','tra7  ')
+c@$$          call writeg1d(1,klev,tra(1:klev,8),'tra8  ','tra8  ')
+c@$$          call writeg1d(1,klev,tra(1:klev,9),'tra9  ','tra9  ')
+c@$$          call writeg1d(1,klev,tra(1:klev,10),'tra10','tra10')
+c@$$          call writeg1d(1,klev,tra(1:klev,11),'tra11','tra11')
+c@$$          call writeg1d(1,klev,tra(1:klev,12),'tra12','tra12')
+c@$$          call writeg1d(1,klev,tra(1:klev,13),'tra13','tra13')
+c@$$          call writeg1d(1,klev,tra(1:klev,14),'tra14','tra14')
+c@$$          call writeg1d(1,klev,tra(1:klev,15),'tra15','tra15')
+c@$$          call writeg1d(1,klev,tra(1:klev,16),'tra16','tra16')
+c@$$          call writeg1d(1,klev,tra(1:klev,17),'tra17','tra17')
+c@$$          call writeg1d(1,klev,tra(1:klev,18),'tra18','tra18')
+c@$$          call writeg1d(1,klev,tra(1:klev,19),'tra19','tra19')
+c@$$          call writeg1d(1,klev,tra(1:klev,20),'tra20','tra20 ')
+c@$$          call writeg1d(1,klev,trap(1:klev,1),'trp1','trp1')
+c@$$          call writeg1d(1,klev,trap(1:klev,2),'trp2','trp2')
+c@$$          call writeg1d(1,klev,trap(1:klev,3),'trp3','trp3')
+c@$$          call writeg1d(1,klev,trap(1:klev,4),'trp4','trp4')
+c@$$          call writeg1d(1,klev,trap(1:klev,5),'trp5','trp5')
+c@$$          call writeg1d(1,klev,trap(1:klev,10),'trp10','trp10')
+c@$$          call writeg1d(1,klev,trap(1:klev,12),'trp12','trp12')
+c@$$          call writeg1d(1,klev,trap(1:klev,15),'trp15','trp15')
+c@$$          call writeg1d(1,klev,trap(1:klev,20),'trp20','trp20')
+c@$$          call writeg1d(1,klev,ftra(1:klev,1),'ftr1  ','ftr1  ')
+c@$$          call writeg1d(1,klev,ftra(1:klev,2),'ftr2  ','ftr2  ')
+c@$$          call writeg1d(1,klev,ftra(1:klev,3),'ftr3  ','ftr3  ')
+c@$$          call writeg1d(1,klev,ftra(1:klev,4),'ftr4  ','ftr4  ')
+c@$$          call writeg1d(1,klev,ftra(1:klev,5),'ftr5  ','ftr5  ')
+c@$$          call writeg1d(1,klev,ftra(1:klev,6),'ftr6  ','ftr6  ')
+c@$$          call writeg1d(1,klev,ftra(1:klev,7),'ftr7  ','ftr7  ')
+c@$$          call writeg1d(1,klev,ftra(1:klev,8),'ftr8  ','ftr8  ')
+c@$$          call writeg1d(1,klev,ftra(1:klev,9),'ftr9  ','ftr9  ')
+c@$$          call writeg1d(1,klev,ftra(1:klev,10),'ftr10','ftr10')
+c@$$          call writeg1d(1,klev,ftra(1:klev,11),'ftr11','ftr11')
+c@$$          call writeg1d(1,klev,ftra(1:klev,12),'ftr12','ftr12')
+c@$$          call writeg1d(1,klev,ftra(1:klev,13),'ftr13','ftr13')
+c@$$          call writeg1d(1,klev,ftra(1:klev,14),'ftr14','ftr14')
+c@$$          call writeg1d(1,klev,ftra(1:klev,15),'ftr15','ftr15')
+c@$$          call writeg1d(1,klev,ftra(1:klev,16),'ftr16','ftr16')
+c@$$          call writeg1d(1,klev,ftra(1:klev,17),'ftr17','ftr17')
+c@$$          call writeg1d(1,klev,ftra(1:klev,18),'ftr18','ftr18')
+c@$$          call writeg1d(1,klev,ftra(1:klev,19),'ftr19','ftr19')
+c@$$          call writeg1d(1,klev,ftra(1:klev,20),'ftr20','ftr20 ')
+c@$$          call writeg1d(1,klev,mp,'mp  ','mp ')
+c@$$          call writeg1d(1,klev,Mke,'Mke  ','Mke ')
 
  
Index: /LMDZ4/trunk/libf/phylmd/cv_driver.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/cv_driver.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/cv_driver.F	(revision 766)
@@ -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)
@@ -290,4 +291,5 @@
       real wd(nloc)           ! gust
 
+      nent(:,:)=0
 !-------------------------------------------------------------------
 ! --- SET CONSTANTS AND PARAMETERS
Index: /LMDZ4/trunk/libf/phylmd/cvflag.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/cvflag.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/cvflag.h	(revision 766)
@@ -5,2 +5,3 @@
 
       COMMON /cvflag/ cvflag_grav 
+c$OMP THREADPRIVATE(/cvflag/)
Index: /LMDZ4/trunk/libf/phylmd/cvltr.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/cvltr.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/cvltr.F	(revision 766)
@@ -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,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/trunk/libf/phylmd/cvparam.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/cvparam.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/cvparam.h	(revision 766)
@@ -27,2 +27,3 @@
      :                ,dtmax, cu, betad, alpha, damp, delta
 
+c$OMP THREADPRIVATE(/cvparam/)
Index: /LMDZ4/trunk/libf/phylmd/cvparam3.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/cvparam3.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/cvparam3.h	(revision 766)
@@ -28,2 +28,3 @@
      :                ,dtcrit, tau, beta, alpha, delta, betad
 
+c$OMP THREADPRIVATE(/cvparam3/)
Index: /LMDZ4/trunk/libf/phylmd/cvthermo.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/cvthermo.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/cvthermo.h	(revision 766)
@@ -14,2 +14,3 @@
      :                 ,eps, epsi, epsim1, ginv, hrd, grav
 
+c$OMP THREADPRIVATE(/cvthermo/)
Index: /LMDZ4/trunk/libf/phylmd/diagphy.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/diagphy.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/diagphy.F	(revision 766)
@@ -74,4 +74,5 @@
       save pas
       data pas/0/
+c$OMP THREADPRIVATE(pas)
 C
       pas=pas+1
@@ -258,4 +259,5 @@
       save pas
       data pas/ndiag*0/
+c$OMP THREADPRIVATE(pas)
 C     
       REAL      h_vcol_pre(ndiag), h_dair_pre(ndiag), h_qw_pre(ndiag)
@@ -264,5 +266,6 @@
       SAVE      h_vcol_pre, h_dair_pre, h_qw_pre, h_ql_pre
      $        , h_qs_pre, qw_pre, ql_pre, qs_pre , ec_pre
-
+c$OMP THREADPRIVATE(h_vcol_pre, h_dair_pre, h_qw_pre, h_ql_pre)
+c$OMP THREADPRIVATE(h_qs_pre, qw_pre, ql_pre, qs_pre , ec_pre)
 c======================================================================
 C
Index: /LMDZ4/trunk/libf/phylmd/dimphy.F90
===================================================================
--- /LMDZ4/trunk/libf/phylmd/dimphy.F90	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/dimphy.F90	(revision 766)
@@ -1,321 +1,4 @@
 module dimphy
-
-  
-  logical, save :: monocpu
-!  logical, save :: parallel
-   
-  INTEGER,SAVE :: iiphy_begin
-  INTEGER,SAVE :: iiphy_end
-  INTEGER,SAVE :: jjphy_begin
-  INTEGER,SAVE :: jjphy_end
-  INTEGER,SAVE :: jjphy_nb
-  INTEGER,SAVE :: ijphy_begin
-  INTEGER,SAVE :: ijphy_end
-  INTEGER,SAVE :: ijphy_nb
-  INTEGER,SAVE :: klon_begin
-  INTEGER,SAVE :: klon_end
-  
-  
-  INTEGER,SAVE,allocatable,dimension(:) :: jjphy_para_nb
-  INTEGER,SAVE,allocatable,dimension(:) :: jjphy_para_begin
-  INTEGER,SAVE,allocatable,dimension(:) :: jjphy_para_end
-  INTEGER,SAVE,dimension(:),allocatable :: Liste_i
-  INTEGER,SAVE,dimension(:),allocatable :: Liste_j
-  INTEGER,SAVE,dimension(:),allocatable :: klon_para_nb
-  INTEGER,SAVE,dimension(:),allocatable :: klon_para_begin
-  INTEGER,SAVE,dimension(:),allocatable :: klon_para_end 
-
-  
-  INTEGER,save :: phy_rank
-  INTEGER,save :: phy_size
-  
-
-  INTEGER,save :: klev, klevp1,klevm1,klon,kfdia,kidia
-  INTEGER,save :: klon2
-  INTEGER,save :: nbtr 
-  INTEGER,save :: kdlon, kflev
-  REAL,save,allocatable,dimension(:) :: zmasq
-  
-
-  
-contains
-  
-   subroutine InitDimphy
-
-#ifdef CPP_PARALLEL
-   use parallel
-#endif
-
-   implicit none
-#include "dimensions90.h"
-#include "paramet90.h" 
-    integer :: rank
-    integer :: i,j,Pos,Index
-    logical,save :: First=.true.
-#ifndef CPP_PARALLEL
-   logical, save :: pole_nord = .true.
-   logical, save :: pole_sud = .true.
-#endif
-
-#ifdef CPP_PARALLEL      
-      monocpu=.false.
-#else
-      monocpu = .true.
-#endif
-      
-      if (monocpu) then
-        
-	phy_rank=0
-	phy_size=1
-	
-#ifdef CPP_PARALLEL      
-      else
- 
-        phy_rank=mpi_rank
-	phy_size=mpi_size
-#endif
-      
-      endif
-
-      if (First) then
-        allocate(jjphy_para_nb(0:phy_size-1))
-        allocate(jjphy_para_begin(0:phy_size-1))
-        allocate(jjphy_para_end(0:phy_size-1))
-        allocate(klon_para_nb(0:phy_size-1))
-        allocate(klon_para_begin(0:phy_size-1))
-        allocate(klon_para_end(0:phy_size-1))
-      endif
-	
-      klev=llm
-      klevp1=klev+1
-      klevm1=klev-1
-      klon2=iim*(jjm-1)+2
-      
-     
-!        do i=0,phy_size-1
-!          klon_para_nb(i)=(klon2/phy_size)
-!          if (i<MOD(klon2,phy_size)) klon_para_nb(i)=klon_para_nb(i)+1
-!          if (i==0) then 
-!            klon_para_begin(i)=1
-!          else 
-!            klon_para_begin(i)=klon_para_end(i-1)+1
-!          endif
-!          klon_para_end(i)=klon_para_begin(i)+klon_para_nb(i)-1
-!        enddo
-      
-      if (First) then
-        do i=0,phy_size-1
-          klon_para_nb(i)=(klon2/phy_size)
-          if (i<MOD(klon2,phy_size)) klon_para_nb(i)=klon_para_nb(i)+1
-        enddo
-      endif
-        
-      do i=0,phy_size-1
-        if (i==0) then 
-          klon_para_begin(i)=1
-        else 
-          klon_para_begin(i)=klon_para_end(i-1)+1
-        endif
-        klon_para_end(i)=klon_para_begin(i)+klon_para_nb(i)-1
-      enddo
-	
-      klon=klon_para_nb(phy_rank)
-      klon_begin=klon_para_begin(phy_rank)
-      klon_end=klon_para_end(phy_rank)
-	
-      nbtr=nqmx-2+1/(nqmx-1)
-
-      kidia=1
-      kfdia=klon
-      
-      if (klon==6818 .and. monocpu) then
-        kdlon=487
-      else
-        kdlon=klon
-      endif
-      kflev=klev
-    
-      if (.not.first) then
-        deallocate(zmasq,liste_i,liste_j)
-      endif
-      
-      allocate(zmasq(klon))
-
-      
-      allocate(Liste_i(klon))
-      allocate(Liste_j(klon))
-    
-      Index=1
-      if (Pole_Nord) then
-        Liste_i(1)=1
-        Liste_j(1)=1
-        iiphy_begin=1
-        jjphy_begin=1
-	ijphy_begin=1
-        Index=Index+1
-      endif
-    
-      Pos=2
-      do j=2,jjm
-        do i=1,iim
-      
-	  if (Pos==klon_begin) then
-            iiphy_begin=i
-            jjphy_begin=j
-	    ijphy_begin=j*iip1+i
-          endif
-       
-          if (Pos==klon_end) then
-            iiphy_end=i
-            jjphy_end=j
-	    ijphy_end=j*iip1+i
-          endif
-        
-          if (Pos>=klon_begin .AND. Pos<=klon_end) then
-            Liste_i(Index)=i
-            Liste_j(Index)=j
-            Index=Index+1
-          endif
-          Pos=Pos+1
-        enddo
-      enddo
-    
-      if (pole_sud) then
-        Liste_i(Index)=1
-        Liste_j(Index)=jjp1
-        iiphy_end=1
-        jjphy_end=jjp1
-	ijphy_end=jjp1*iip1+1
-      endif
-    
-      ijphy_nb=ijphy_end-ijphy_begin+1
-      jjphy_nb=jjphy_end-jjphy_begin+1
-	
-	    
-      Pos=2
-      rank=0
-      jjphy_para_begin(rank)=1
-    
-      do j=2,jjm
-        do i=1,iim
-          if (Pos==klon_para_begin(rank)) then
-            jjphy_para_begin(rank)=j
-          endif
-          if (Pos==klon_para_end(rank)) then
-            jjphy_para_end(rank)=j
-            rank=rank+1
-          endif
-          Pos=Pos+1
-        enddo
-      enddo
-      jjphy_para_end(rank)=jjp1
-      
-      First=.false.    
-   end subroutine InitDimphy
-   
-
-   subroutine GatherField(Fields,Fieldr,ll)
-     implicit none
-#ifdef CPP_PARALLEL      
-     include 'mpif.h'
-#endif
-     INTEGER :: ll
-     REAL, dimension(klon,ll) :: Fields
-     REAL, dimension(klon2,ll) :: Fieldr     
-     REAL, dimension(klon2*ll) :: Field_tmp     
-     INTEGER, dimension(0:phy_size-1) :: displs
-     INTEGER, dimension(0:phy_size-1) :: sendcounts
-     INTEGER :: l,Pos,rank,ierr
-     INTEGER :: klon_b,klon_e, Nb
-     
-     Pos=1     
-     do rank=0,phy_size-1
-       klon_b=klon_para_begin(rank)
-       klon_e=klon_para_end(rank)
-       Nb=klon_para_nb(rank)
-       displs(rank)=Pos-1
-       sendcounts(rank)=Nb*ll
-       Pos=Pos+Nb*ll
-     enddo
-         
-      if (monocpu) then
-        Fieldr(:,:)=Fields(:,:)
-#ifdef CPP_PARALLEL      
-      else
-        call MPI_Gatherv(Fields,klon*ll,MPI_REAL8,Field_tmp,sendcounts,  &
-	                 displs,MPI_REAL8,0,MPI_COMM_WORLD,ierr)
-#endif
-      endif
-      
-     Pos=1     
-     do rank=0,phy_size-1
-       klon_b=klon_para_begin(rank)
-       klon_e=klon_para_end(rank)
-       Nb=klon_para_nb(rank)
-       do l=1,ll
-         Fieldr(klon_b:klon_e,l)=Field_tmp(Pos:Pos+Nb-1)
-	 Pos=Pos+Nb
-       enddo
-     enddo
-      
-   end subroutine GatherField
-
-   subroutine AllGatherField(Fields,Fieldr,ll)
-     implicit none
-#ifdef CPP_PARALLEL      
-     include 'mpif.h'
-#endif   
-     INTEGER :: ll
-     REAL, dimension(klon,ll) :: Fields
-     REAL, dimension(klon2,ll) :: Fieldr     
-     
-     INTEGER :: ierr
-
-#ifdef CPP_PARALLEL             
-     call GatherField(Fields,Fieldr,ll)
-     call MPI_BCAST(Fieldr,klon2*ll,MPI_REAL8,0,MPI_COMM_WORLD,ierr)
-#endif   
-   end subroutine AllGatherField
-   
-           
-   subroutine ScatterField(Fields,Fieldr,ll)
-     implicit none
-#ifdef CPP_PARALLEL      
-     include 'mpif.h'
-#endif
-     INTEGER :: ll
-     REAL, dimension(klon2,ll) :: Fields
-     REAL, dimension(klon,ll) :: Fieldr     
-     REAL, dimension(klon2*ll) :: Field_tmp     
-     INTEGER, dimension(0:phy_size-1) :: displs
-     INTEGER, dimension(0:phy_size-1) :: sendcounts
-     INTEGER :: l,Pos,rank,ierr
-     INTEGER :: klon_b,klon_e, Nb
-
-     Pos=1    
-     do rank=0,phy_size-1
-       klon_b=klon_para_begin(rank)
-       klon_e=klon_para_end(rank)
-       Nb=klon_para_nb(rank)
-       displs(rank)=Pos-1
-       sendcounts(rank)=Nb*ll
-       do l=1,ll
-         Field_tmp(Pos:Pos+Nb-1)=Fields(klon_b:klon_e,l)
-	 Pos=Pos+Nb
-       enddo
-     enddo
-           
-     if (monocpu) then
-       Fieldr(:,:)=Fields(:,:)
-     else
-#ifdef CPP_PARALLEL      
-       call MPI_Scatterv(Field_tmp,sendcounts,displs,MPI_REAL8,         &
-	                 Fieldr,klon*ll,MPI_REAL8,0,MPI_COMM_WORLD,ierr)
-#endif
-     endif
-      
-        
-   end subroutine ScatterField
-   
-   
+  USE mod_phys_mpi
+  USE mod_phys_openmp
 end module dimphy
Index: /LMDZ4/trunk/libf/phylmd/fisrtilp.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/fisrtilp.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/fisrtilp.F	(revision 766)
@@ -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"
@@ -90,4 +91,5 @@
       LOGICAL appel1er
       SAVE appel1er
+c$OMP THREADPRIVATE(appel1er)
 c
 c---------------------------------------------------------------
@@ -99,4 +101,5 @@
       REAL a_tr_sca(4)
       save a_tr_sca
+c$OMP THREADPRIVATE(a_tr_sca)
 c
 c Variables intermediaires
@@ -110,5 +113,5 @@
       REAL zlh_solid(klon), zm_solid
 cIM 
-      INTEGER klevm1
+cym      INTEGER klevm1
 c---------------------------------------------------------------
 c
@@ -210,5 +213,5 @@
 c
 cIM : klevm1
-      klevm1=klev-1
+cym      klevm1=klev-1
       DO 9999 k = klev, 1, -1
 c
@@ -269,5 +272,5 @@
      .                            /RG/dtime
 
-c pour la glace, on réévapore toute la précip dans la couche du dessous
+c pour la glace, on r�vapore toute la pr�ip dans la couche du dessous
 c la glace venant de la couche du dessus est simplement dans la couche
 c du dessous.
@@ -322,5 +325,5 @@
 c   zqn   : eau totale dans le nuage
 c   zcond : eau condensee moyenne dans la maille.
-c           on prend en compte le réchauffement qui diminue la partie condensee
+c           on prend en compte le r�hauffement qui diminue la partie condensee
 c
 c   Version avec les raqts
@@ -427,5 +430,5 @@
             zct(i)=1./cld_tau_lsc
          endif
-c  quantité d'eau à élminier.
+c  quantit�d'eau ��minier.
          zchau(i) = zct(i)*dtime/FLOAT(ninter) * zoliq(i)
      .         *(1.0-EXP(-(zoliq(i)/zneb(i)/zcl(i))**2)) *(1.-zfice(i))
Index: /LMDZ4/trunk/libf/phylmd/fisrtilp.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/fisrtilp.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/fisrtilp.h	(revision 766)
@@ -20,2 +20,3 @@
      s     ,iflag_pdf     ! 0
 
+!$OMP THREADPRIVATE(/comfisrtilp/)
Index: /LMDZ4/trunk/libf/phylmd/fisrtilp.inc
===================================================================
--- /LMDZ4/trunk/libf/phylmd/fisrtilp.inc	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/fisrtilp.inc	(revision 766)
@@ -19,3 +19,3 @@
      &     ,reevap_ice  &
      &     ,iflag_pdf  
-
+!$OMP THREADPRIVATE(/comfisrtilp/)
Index: /LMDZ4/trunk/libf/phylmd/fisrtilp_tr.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/fisrtilp_tr.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/fisrtilp_tr.F	(revision 766)
@@ -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"
@@ -101,4 +102,5 @@
       LOGICAL appel1er
       SAVE appel1er
+c$OMP THREADPRIVATE(appel1er)
 c
 c---------------------------------------------------------------
@@ -110,4 +112,5 @@
       REAL a_tr_sca(4)
       save a_tr_sca
+c$OMP THREADPRIVATE(a_tr_sca)
 c
 c Variables intermediaires
Index: /LMDZ4/trunk/libf/phylmd/flxtr.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/flxtr.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/flxtr.F	(revision 766)
@@ -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/trunk/libf/phylmd/hbtm.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/hbtm.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/hbtm.F	(revision 766)
@@ -4,4 +4,5 @@
      .                pblh,cape,EauLiq,ctei,pblT,
      .                therm,trmb1,trmb2,trmb3,plcl)
+        USE dimphy
         IMPLICIT none
 
@@ -38,6 +39,6 @@
 c
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
       REAL RLvCp, REPS
@@ -60,5 +61,5 @@
 c
       INTEGER isommet
-      PARAMETER (isommet=klev) ! limite max sommet pbl
+cum      PARAMETER (isommet=klev) ! limite max sommet pbl
       REAL vk
       PARAMETER (vk=0.35)     ! Von Karman => passer a .41 ! cf U.Olgstrom
@@ -172,4 +173,5 @@
 
 ! initialisations (Anne)
+      isommet=klev
       th_th(:) = 0.
       q_star = 0
@@ -193,5 +195,5 @@
 C++ r4 = 35.86             7.66           Kelvin
 C++  q_sat = eps*e_sat/(p-(1-eps)*e_sat)
-C++ derivée :
+C++ deriv� :
 C++ =========
 C++                   r3*(Tf-r4)*q_sat(T,p)
@@ -474,5 +476,5 @@
 cIM 091204 BEG
         a1=b1*(1.+2.*RETV*qT_th(i))*t_star**2
-        a2=(RETV*Th_th(i))**2*b2*q_star**2
+        a2=(RETV*Th_th(i))**2*b2*q_star*q_star
         a3=2.*RETV*Th_th(i)*b212*q_star*t_star
         aa=a1+a2+a3
@@ -486,5 +488,5 @@
 cIM 091204 END
         therm(i) = sqrt( b1*(1.+2.*RETV*qT_th(i))*t_star**2
-     +             + (RETV*Th_th(i))**2*b2*q_star**2
+     +             + (RETV*Th_th(i))**2*b2*q_star*q_star
 cIM 101204  +             + 2.*RETV*Th_th(i)*b212*q_star*t_star
      +             + max(0.,2.*RETV*Th_th(i)*b212*q_star*t_star)
Index: /LMDZ4/trunk/libf/phylmd/hgardfou.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/hgardfou.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/hgardfou.F	(revision 766)
@@ -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/trunk/libf/phylmd/histo_o500_pctau.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/histo_o500_pctau.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/histo_o500_pctau.F	(revision 766)
@@ -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/trunk/libf/phylmd/homogene.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/homogene.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/homogene.F	(revision 766)
@@ -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/trunk/libf/phylmd/hydrol.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/hydrol.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/hydrol.F	(revision 766)
@@ -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/trunk/libf/phylmd/inc_cpl.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/inc_cpl.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/inc_cpl.h	(revision 766)
@@ -22,4 +22,5 @@
       CHARACTER*8 cl_f_writ(jpmaxfld), cl_f_read(jpmaxfld)
       COMMON / comcpl / cl_writ, cl_read, cl_f_writ, cl_f_read
+!$OMP THREADPRIVATE(/comcpl/)
 #endif
 !     -------------------------------------------------------------------
Index: /LMDZ4/trunk/libf/phylmd/inc_sipc.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/inc_sipc.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/inc_sipc.h	(revision 766)
@@ -24,3 +24,4 @@
       INTEGER  mpoolread(jpmaxfld)
       COMMON / compool / mpoolinitr, mpoolinitw, mpoolwrit, mpoolread
+c$OMP THREADPRIVATE(/compool/)
 C     -------------------------------------------------------------------
Index: /LMDZ4/trunk/libf/phylmd/indicesol.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/indicesol.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/indicesol.h	(revision 766)
@@ -19,2 +19,4 @@
       CHARACTER *3 clnsurf(nbsrf)
       DATA clnsurf/'ter', 'lic', 'oce', 'sic'/
+      SAVE clnsurf
+!$OMP THREADPRIVATE(clnsurf)
Index: /LMDZ4/trunk/libf/phylmd/indicesol.inc
===================================================================
--- /LMDZ4/trunk/libf/phylmd/indicesol.inc	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/indicesol.inc	(revision 766)
@@ -11,2 +11,4 @@
       CHARACTER (len=3),dimension(nbsrf) :: clnsurf(nbsrf)
       DATA clnsurf/'ter', 'lic', 'oce', 'sic'/
+      SAVE clnsurf
+!$OMP THREADPRIVATE(clnsurf)
Index: /LMDZ4/trunk/libf/phylmd/ini_bilKP_ave.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_bilKP_ave.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_bilKP_ave.h	(revision 766)
@@ -11,19 +11,22 @@
          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)
-         write(*,*)'zx_lon = ',zx_lon(:,1)
-         write(*,*)'zx_lat = ',zx_lat(1,:)
-         CALL histbeg("histbilKP_ave", 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         write(*,*)'zx_lon = ',zx_lon(:,1)
+cym         write(*,*)'zx_lat = ',zx_lat(1,:)
+cym         CALL histbeg("histbilKP_ave", iim,zx_lon(:,1), jjmp1,
+cym     .                zx_lat(1,:),
+cym     .                1,iim,1,jjmp1, itau_phy, zjulian, dtime,
+cym     .                nhori, nid_bilKPave)
+         CALL histbeg_phy("histbilKP_ave", itau_phy, zjulian, dtime,
      .                nhori, nid_bilKPave)
+
          write(*,*)'Journee ', itau_phy, zjulian
          CALL histvert(nid_bilKPave, "presnivs",
@@ -36,20 +39,20 @@
          CALL histdef(nid_bilKPave,"ue",
      .   "Zonal energy transport","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32, 
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"ve",
      .   "Merid energy transport","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32, 
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"uq",
      .   "Zonal humidity transport","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32, 
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"vq",
      .   "Merid humidity transport","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32, 
      .                typeval, zsto,zout)
 c
@@ -58,30 +61,30 @@
          CALL histdef(nid_bilKPave,"temp",
      .   "Air temperature","K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"ovap",
      .   "Specific humidity","Kg/Kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"geop",
      .   "Geopotential height","m",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"vitu",
      .   "Zonal wind","m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"vitv",
      .   "Meridional wind","m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "vitw", 
      .   "Vertical wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -89,5 +92,5 @@
      .   "Inter-Layer Air pressure",
      .                "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -95,5 +98,5 @@
      .   "Mean-Layer Air pressure",
      .                "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -101,50 +104,50 @@
      .   "Liquid water content", 
      .                "kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dtdyn", 
      .   "Dynamics dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dqdyn", 
      .   "Dynamics dQ", "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dtcon", 
      .   "Convection dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "ducon", 
      .   "Convection du", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dvcon", 
      .   "Convection dv", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"dqcon",
      .   "Convection dQ","Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dtlsc", 
      .   "Condensation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"dqlsc",
      .   "Condensation dQ","Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"dtvdf",
      .   "Boundary-layer dT","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -152,10 +155,10 @@
      .   "Boundary-layer dQ", 
      .               "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"dtajs",
      .   "Ajustement sec dT","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -163,10 +166,10 @@
      .   "Ajustement sec dQ", 
      .               "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dteva", 
      .   "Reevaporation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -174,5 +177,5 @@
      .   "Reevaporation dQ",
      .                "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 
@@ -180,30 +183,30 @@
          CALL histdef(nid_bilKPave, "dtswr", 
      .   "SW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dtsw0", 
      .   "SW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dtlwr", 
      .   "LW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dtlw0", 
      .   "LW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"duvdf",
      .   "Boundary-layer dU","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave,"dvvdf",
      .   "Boundary-layer dV","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -212,10 +215,10 @@
          CALL histdef(nid_bilKPave, "duoli",
      .   "Orography dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPave, "dvoli", 
      .   "Orography dV", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -225,25 +228,25 @@
          CALL histdef(nid_bilKPave, "duphy",
      .   "Physiq dU","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 C
          CALL histdef(nid_bilKPave, "dvphy",
      .   "Physiq dV","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 C
          CALL histdef(nid_bilKPave, "dtphy",
      .   "Physiq dT","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 C
          CALL histdef(nid_bilKPave, "dqphy",
      .   "Physiq dQ","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 C
          CALL histdef(nid_bilKPave, "dqlphy",
      .   "Physiq dQl","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 C
Index: /LMDZ4/trunk/libf/phylmd/ini_bilKP_ins.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_bilKP_ins.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_bilKP_ins.h	(revision 766)
@@ -11,15 +11,15 @@
          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)
-         write(*,*)'zx_lon = ',zx_lon(:,1)
-         write(*,*)'zx_lat = ',zx_lat(1,:)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlat,zx_lat)
+cym         write(*,*)'zx_lon = ',zx_lon(:,1)
+cym         write(*,*)'zx_lat = ',zx_lat(1,:)
 c
 cIM 280405 BEG
@@ -30,12 +30,12 @@
           jmin_ins=1
           jmax_ins=jjmp1
-          do i=1,iim-1
-             if(zx_lon(i,1).lt.lonmin_ins) imin_ins=i
-             if(zx_lon(i,1).le.lonmax_ins) imax_ins=i+1
-          enddo
-          do j=1,jjmp1
-             if(zx_lat(1,j).ge.latmin_ins) jmax_ins=j
-             if(zx_lat(1,j).gt.latmax_ins) jmin_ins=j
-          enddo
+cym          do i=1,iim-1
+cym             if(zx_lon(i,1).lt.lonmin_ins) imin_ins=i
+cym             if(zx_lon(i,1).le.lonmax_ins) imax_ins=i+1
+cym          enddo
+cym          do j=1,jjmp1
+cym             if(zx_lat(1,j).ge.latmin_ins) jmax_ins=j
+cym             if(zx_lat(1,j).gt.latmax_ins) jmin_ins=j
+cym          enddo
 c
           print*,'On stoke le fichier bilKP instantanne sur ',
@@ -48,9 +48,9 @@
 cIM 280405 END
 c
-         IF(1.EQ.0) THEN
-         CALL histbeg("histbilKP_ins", iim,zx_lon(:,1), jjmp1,
-     .                zx_lat(1,:),
-     .                1,iim,1,jjmp1, itau_phy, zjulian, dtime,
-     .                nhori, nid_bilKPins)
+cym         IF(1.EQ.0) THEN
+cym         CALL histbeg("histbilKP_ins", iim,zx_lon(:,1), jjmp1,
+cym     .                zx_lat(1,:),
+cym     .                1,iim,1,jjmp1, itau_phy, zjulian, dtime,
+cym     .                nhori, nid_bilKPins)
          ENDIF
 c
@@ -58,9 +58,11 @@
 c
 cIM cf. AM 081204 BEG region
-         CALL histbeg("histbilKP_ins", iim,zx_lon(:,1), 
-     .                 jjmp1,zx_lat(1,:),
-     .                 imin_ins,imax_ins-imin_ins+1,
-     .                 jmin_ins,jmax_ins-jmin_ins+1,
-     .                 itau_phy, zjulian, dtime,
+cym         CALL histbeg("histbilKP_ins", iim,zx_lon(:,1), 
+cym     .                 jjmp1,zx_lat(1,:),
+cym     .                 imin_ins,imax_ins-imin_ins+1,
+cym     .                 jmin_ins,jmax_ins-jmin_ins+1,
+cym     .                 itau_phy, zjulian, dtime,
+cym     .                 nhori, nid_bilKPins)
+         CALL histbeg_phy("histbilKP_ins", itau_phy, zjulian, dtime,
      .                 nhori, nid_bilKPins)
 cIM 081204 END
@@ -77,20 +79,20 @@
          CALL histdef(nid_bilKPins,"ue",
      .   "Zonal energy transport","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32, 
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"ve",
      .   "Merid energy transport","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32, 
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"uq",
      .   "Zonal humidity transport","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32, 
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"vq",
      .   "Merid humidity transport","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32, 
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32, 
      .                typeval, zsto,zout)
 c
@@ -99,30 +101,30 @@
          CALL histdef(nid_bilKPins, "temp",
      .   "Air temperature", "K",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"ovap",
      .   "Specific humidity","Kg/Kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"geop",
      .   "Geopotential height", "m",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"vitu", 
      .   "Zonal wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"vitv", 
      .   "Meridional wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "vitw",
      .   "Vertical wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -130,5 +132,5 @@
      .   "Inter-Layer Air pressure",
      .                "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -136,5 +138,5 @@
      .   "Mean-Layer Air pressure",
      .                "Pa",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -142,50 +144,50 @@
      .   "Liquid water content", 
      .                "kg/kg",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "dtdyn",
      .   "Dynamics dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "dqdyn",
      .   "Dynamics dQ", "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "dtcon",
      .   "Convection dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "ducon",
      .   "Convection du", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "dvcon",
      .   "Convection dv", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"dqcon",
      .   "Convection dQ","Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "dtlsc",
      .   "Condensation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"dqlsc",
      .   "Condensation dQ","Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"dtvdf",
      .   "Boundary-layer dT","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -193,10 +195,10 @@
      .   "Boundary-layer dQ", 
      .               "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"dtajs",
      .   "Ajustement sec dT","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -204,10 +206,10 @@
      .   "Ajustement sec dQ", 
      .               "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"dteva",
      .   "Reevaporation dT","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -215,5 +217,5 @@
      .   "Reevaporation dQ",
      .                "Kg/Kg/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 
@@ -221,30 +223,30 @@
          CALL histdef(nid_bilKPins, "dtswr", 
      .   "SW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "dtsw0", 
      .   "SW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "dtlwr", 
      .   "LW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "dtlw0", 
      .   "LW radiation dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"duvdf",
      .   "Boundary-layer dU","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins,"dvvdf",
      .   "Boundary-layer dV","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -253,10 +255,10 @@
          CALL histdef(nid_bilKPins, "duoli", 
      .   "Orography dU", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
          CALL histdef(nid_bilKPins, "dvoli", 
      .   "Orography dV", "m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 c
@@ -266,25 +268,25 @@
          CALL histdef(nid_bilKPins, "duphy",
      .   "Physiq dU","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 C
          CALL histdef(nid_bilKPins, "dvphy",
      .   "Physiq dV","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 C
          CALL histdef(nid_bilKPins, "dtphy",
      .   "Physiq dT","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 C
          CALL histdef(nid_bilKPins, "dqphy",
      .   "Physiq dQ","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 C
          CALL histdef(nid_bilKPins, "dqlphy",
      .   "Physiq dQl","-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                typeval, zsto,zout)
 cIM 280405 BEG
@@ -303,10 +305,10 @@
           CALL histdef(nid_bilKPins, "u"//bb2,
      .                 "Zonal wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                typeval, zsto,zout)
 c
           CALL histdef(nid_bilKPins, "v"//bb2,
      .                 "Meridional wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                typeval, zsto,zout)
 c
Index: /LMDZ4/trunk/libf/phylmd/ini_histISCCP.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histISCCP.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_histISCCP.h	(revision 766)
@@ -4,4 +4,5 @@
       IF (ok_isccp) THEN
 c
+c$OMP MASTER
       ndex2d = 0
       ndex3d = 0
@@ -53,46 +54,57 @@
 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
-
-        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)
 c
 cIM BEG region
+cym Desole dans un premier temps le mode region ne marchera pas
+cym Il faudra voir dans un second temps pour l'implementer
+cym Mais cela posera des problemes au niveau de la reconstruction
+
           imin_ins=1
           imax_ins=iim
           jmin_ins=1
           jmax_ins=jjmp1
-          do i=1,iim-1
-             if(zx_lon(i,1).lt.lonmin_ins) imin_ins=i
-             if(zx_lon(i,1).le.lonmax_ins) imax_ins=i+1
-          enddo
-          do j=1,jjmp1
-             if(zx_lat(1,j).ge.latmin_ins) jmax_ins=j
-             if(zx_lat(1,j).gt.latmax_ins) jmin_ins=j
-          enddo
+cym          do i=1,iim-1
+cym             if(zx_lon(i,1).lt.lonmin_ins) imin_ins=i
+cym             if(zx_lon(i,1).le.lonmax_ins) imax_ins=i+1
+cym          enddo
+cym          do j=1,jjmp1
+cym             if(zx_lat(1,j).ge.latmin_ins) jmax_ins=j
+cym             if(zx_lat(1,j).gt.latmax_ins) jmin_ins=j
+cym          enddo
 c
           print*,'On stoke le fichier histISCCP instantanne sur ',
      s   imin_ins,imax_ins,jmin_ins,jmax_ins
-          print*,'On stoke le fichier histISCCP instantanne sur ',
-     s   zx_lon(imin_ins,1),zx_lon(imax_ins,1),
-     s   zx_lat(1,jmin_ins),zx_lat(1,jmax_ins)
+cym          print*,'On stoke le fichier histISCCP instantanne sur ',
+cym     s   zx_lon(imin_ins,1),zx_lon(imax_ins,1),
+cym     s   zx_lat(1,jmin_ins),zx_lat(1,jmax_ins)
 cIM END region
 c
         IF(1.EQ.0) THEN
-         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)
+
         ENDIF !(1.EQ.0) THEN
 c
-         CALL histbeg("histISCCP.nc", iim,zx_lon(:,1),
-     .                 jjmp1,zx_lat(1,:),
-     .                 imin_ins,imax_ins-imin_ins+1,
-     .                 jmin_ins,jmax_ins-jmin_ins+1,
-     .                 itau_phy, zjulian, dtime,
+cym         CALL histbeg("histISCCP.nc", iim,zx_lon(:,1),
+cym     .                 jjmp1,zx_lat(1,:),
+cym     .                 imin_ins,imax_ins-imin_ins+1,
+cym     .                 jmin_ins,jmax_ins-jmin_ins+1,
+cym     .                 itau_phy, zjulian, dtime,
+cym     .                 nhori, nid_isccp)
+
+         CALL histbeg_phy("histISCCP.nc", itau_phy, zjulian, dtime,
      .                 nhori, nid_isccp)
+
 c
         IF(type_run.EQ."ENSP".OR.type_run.EQ."CLIM") THEN
@@ -118,5 +130,5 @@
           CALL histdef(nid_isccp, "cldISCCP_"//taulev(k)//typinout(n),
      .                "LMDZ ISCCP cld", "%",
-     .                iim, jjmp1,nhori,lmaxm1,1,lmaxm1,nvert,32,
+     .                iim, jjphy_nb,nhori,lmaxm1,1,lmaxm1,nvert,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
          ENDDO
@@ -124,5 +136,5 @@
          CALL histdef(nid_isccp, "nsunlit"//typinout(n),
      .                "Nb of calls with sunlit ", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
@@ -140,5 +152,5 @@
            CALL histdef(nid_isccp, pclev(l)//taulev(k)//typinout(n),
      .                "LMDZ ISCCP cld "//cnameisccp(l,k), "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
@@ -149,5 +161,5 @@
           CALL histdef(nid_isccp, "nsunlit"//typinout(n),
      .                "Nb of calls with sunlit ", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
@@ -155,45 +167,45 @@
           CALL histdef(nid_isccp, "cirr",
      .                "Cirrus lk ISCCP-D2", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "cist",
      .                "CiSt lk ISCCP-D2", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "deep",
      .                "Deep lk ISCCP-D2", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "alcu",
      .                "AlCu lk ISCCP-D2", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "alst",
      .                "AlSt lk ISCCP-D2", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "nist",
      .                "NiSt lk ISCCP-D2", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "cumu",
      .                "Cumu lk ISCCP-D2", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "stcu",
      .                "StCu lk ISCCP-D2", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "stra",
      .                "Stra lk ISCCP-D2", "%",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
@@ -201,15 +213,15 @@
           CALL histdef(nid_isccp, "thin",
      .                "Opt. thin ISCCP-D2 like clouds", "%",
-     .                iim, jjmp1,nhori,lmax3,1,lmax3,nvert3,32,
+     .                iim, jjphy_nb,nhori,lmax3,1,lmax3,nvert3,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "mid",
      .                "Opt. intermediate ISCCP-D2 like clouds", "%",
-     .                iim, jjmp1,nhori,lmax3,1,lmax3,nvert3,32,
+     .                iim, jjphy_nb,nhori,lmax3,1,lmax3,nvert3,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
           CALL histdef(nid_isccp, "thick",
      .                "Opt. thick ISCCP-D2 like clouds", "%",
-     .                iim, jjmp1,nhori,lmax3,1,lmax3,nvert3,32,
+     .                iim, jjphy_nb,nhori,lmax3,1,lmax3,nvert3,32,
      .                "ave(X)", zcals(n),zout_isccp(n))
 c
@@ -224,5 +236,5 @@
           CALL histdef(nid_isccp,"boxptop"//verticaxe(n),
      .                "Boxptop axe"//verticaxe(n), "mb",
-     .                iim, jjmp1,nhori,
+     .                iim, jjphy_nb,nhori,
      .                ncol(n),1,ncol(n),nvlev(n),32,
 cIM  .                ncolmx,1,ncolmx,nvlev,32,
@@ -237,5 +249,5 @@
           CALL histdef(nid_isccp, "seed"//verticaxe(n),
      .                "seed axe"//verticaxe(n), "-",
-     .                iim, jjmp1,nhori,1,1,1,-99,32,
+     .                iim, jjphy_nb,nhori,1,1,1,-99,32,
 cIM  .                "inst(X)", dtime,dtime)
      .                "ave(X)", zcals(n),zout_isccp(n))
@@ -245,3 +257,4 @@
         CALL histend(nid_isccp)
 c
+c$OMP END MASTER
       ENDIF ! ok_isccp
Index: /LMDZ4/trunk/libf/phylmd/ini_histREGDYN.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histREGDYN.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_histREGDYN.h	(revision 766)
@@ -4,4 +4,6 @@
 
       IF (ok_regdyn) THEN
+      
+        if (monocpu) then
 c
 cIM      PRINT*, 'La frequence de sortie REGDYN est de ', ecrit_mth
@@ -120,4 +122,6 @@
 c
          CALL histend(nid_regdyn)
+	 
+	 endif ! monocpu
 
       endif ! ok_regdyn
Index: /LMDZ4/trunk/libf/phylmd/ini_histday.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histday.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_histday.h	(revision 766)
@@ -3,4 +3,6 @@
 c
       IF (ok_journe) THEN
+
+c$OMP MASTER
 c
        zstophy = dtime
@@ -11,16 +13,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("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",
      .                 klev, presnivs/100., nvert)
@@ -29,17 +36,17 @@
 c
          CALL histdef(nid_day, "phis", "Surface geop. height", "m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "once", zstophy,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", zstophy,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", zstophy,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", zstophy,zout)
 c
@@ -47,37 +54,37 @@
 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)", zstophy,zout)
 c
          CALL histdef(nid_day, "t2m", "Temperature 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zstophy,zout)
-c
-c Champs retires momentannéement en attendant un hypothetique
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zstophy,zout)
+c
+c Champs retires momentannement en attendant un hypothetique
 c debugage
 
          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, zstophy,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, zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_day, "snowl", "Solid Large-scale Precip.",
      .   "kg/(m2*s)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
@@ -85,102 +92,102 @@
          CALL histdef(nid_day, "snowc", "Solid Convective Precip.",
      .   "kg/(m2*s)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstoday,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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, zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_day, "snowf", "Snow fall", "kg/(m2*s)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,zout)
 c
 c        CALL histdef(nid_day, "snow_mass", "Snow Mass", "kg/m2",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
 c    .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "evap", "Evaporation", "kg/(m2*s)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_day, "radsol", "Rayonnement au sol", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -203,10 +210,10 @@
           CALL histdef(nid_day, "u"//bb2,
      .                 "Zonal wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_day, "v"//bb2,
      .                 "Meridional wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
@@ -217,10 +224,10 @@
          CALL histdef(nid_day, "w"//bb2, "Vertical wind "//bb2//"mb",
      .                "m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
          CALL histdef(nid_day,"phi"//bb2, "Geopotential "//bb2//"mb",
      .                "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
@@ -230,22 +237,22 @@
 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)", zstophy,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, zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -257,5 +264,5 @@
           CALL histdef(nid_day, "lmt_bils", 
      .         "Bilan au sol atmosphere forcee", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,zout)
 c
@@ -264,17 +271,17 @@
           CALL histdef(nid_day, "slab_bils",
      .                "Bilan au sol slab", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_day, "tslab", "Slab SST ", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_day, "seaice", "Slab seaice", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_day, "siceh", "Slab seaice height", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
@@ -283,10 +290,10 @@
          CALL histdef(nid_day, "fluxo",
      .                "Flux turbulents ocean-atmosphere", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "fluxg",
      .                "Flux ocean-glace de mer", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
@@ -296,9 +303,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)", zstophy,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)", zstophy,zout)
 c
@@ -314,29 +321,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_day, "geop", "Geopotential height", "m2/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_day, "vitw", "Vertical wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,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)", zstophy,zout)
 c
@@ -354,33 +361,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -388,10 +395,10 @@
          CALL histdef(nid_day, "LWdnSFC",
      .                "LW down at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "LWupSFC",
      .                "LW down at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
@@ -400,5 +407,5 @@
 c    .                "Cld top pressure","mb",
      .                "Cld top pressure (cf ISCCP simulator)","Pa",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 cIM     ENDIF !(iflag_con.GE.3) THEN 
@@ -411,75 +418,75 @@
 c
          CALL histdef(nid_day, "tter", "Surface Temperature ter", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "tlic", "Surface Temperature lic", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "toce", "Surface Temperature oce", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "tsic", "Surface Temperature sic", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "t2mter", "Temp.tere 2m", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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, zstophy,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, zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -488,45 +495,45 @@
            call histdef(nid_day, "pourc_"//clnsurf(nsrf), 
      $         "% "//clnsurf(nsrf), "%",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
            call histdef(nid_day, "fract_"//clnsurf(nsrf), 
      $         "Fraction "//clnsurf(nsrf), "1",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
            call histdef(nid_day, "tsol_"//clnsurf(nsrf), 
      $         "Temperature "//clnsurf(nsrf), "K",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 
            call histdef(nid_day, "tauy_"//clnsurf(nsrf), 
      $         "Meridional wind stress "//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
            call histdef(nid_day, "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)", zstophy,zout)
 C
            call histdef(nid_day, "rugs_"//clnsurf(nsrf), 
      $         "Rugosite "//clnsurf(nsrf), "m",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
@@ -545,59 +552,59 @@
          CALL histdef(nid_day, "tops0", "CS 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)", zstophy,zout)
 c
          CALL histdef(nid_day, "topl0", "CS 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)", zstophy,zout)
 c
          CALL histdef(nid_day, "sols0", "CS 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)", zstophy,zout)
 c
          CALL histdef(nid_day, "soll0", "CS 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)", zstophy,zout)
 c
          CALL histdef(nid_day, "rneb", "Cloud fraction", "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "rnebcon", "Convective Cloud Fraction"
      .                , "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day,"lwcon","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)", zstophy,zout)
 c
         CALL histdef(nid_day,"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)", zstophy,zout)
 c
          CALL histdef(nid_day,"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)", zstophy,zout)
 c
          CALL histdef(nid_day,"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)", zstophy,zout)
 c
         CALL histdef(nid_day,"meantaucld",
      .                "ISCCP mean cloud optical thickness","1",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_day,"cldtau","Cloud optical thickness","1",
-     .                iim,jjmp1,nhori, klev,1,klev, nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev, nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_day,"cldemi","Cloud optical emissivity","1",
-     .                iim,jjmp1,nhori, klev,1,klev, nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev, nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
@@ -605,27 +612,27 @@
 c
          CALL histdef(nid_day, "dtcon", "Convection dT", "K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "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)", zstophy,zout)
 c
          CALL histdef(nid_day, "rh2m", "Relative humidity at 2m", "%",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "qsat2m", "Saturant humidity at 2m", "%",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "tpot", 
      .                "Surface air potential temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_day, "tpote", 
      .        "Surface air equivalent potential temperature", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
@@ -639,3 +646,4 @@
 c
 c=================================================================
+c$OMP END MASTER
       ENDIF ! fin de test sur ok_journe
Index: /LMDZ4/trunk/libf/phylmd/ini_histday_seri.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histday_seri.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_histday_seri.h	(revision 766)
@@ -2,4 +2,7 @@
 c $Header$
 c
+cym Ne fonctionnera pas en mode parallele
+      IF (monocpu) THEN
+      
       IF (type_run.EQ."AMIP") THEN
 c
@@ -125,2 +128,4 @@
 c=================================================================
       ENDIF ! fin de test sur type_run.EQ.AMIP
+      
+      ENDIF ! monocpu
Index: /LMDZ4/trunk/libf/phylmd/ini_histhf.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histhf.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_histhf.h	(revision 766)
@@ -4,4 +4,5 @@
 
       IF (ok_hf) THEN
+c$OMP MASTER
 c
        zstohf = ecrit_hf
@@ -14,13 +15,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)
-         CALL histbeg("histhf", 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,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,
+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)
 
@@ -34,13 +40,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", zstohf,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", zstohf,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", zstohf,zout)
 c
@@ -48,38 +54,38 @@
 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)", zstohf,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)", zstohf,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)", zstohf,zout)
 c
          CALL histdef(nid_hf, "precip", "Precipitation", "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,zout)
 c
 cIM ENSEMBLES BEG
          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)", zstohf,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)", zstohf,zout)
 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)", zstohf,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)", zstohf,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)", zstohf,zout)
 c
@@ -99,5 +105,5 @@
           CALL histdef(nid_hf, "phi"//bb2,
      .                "Geopotential "//bb2//"mb", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zout)
           ENDIF !bb2.EQ."500"
@@ -109,20 +115,20 @@
 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)", zstophy,zout)
 c
          CALL histdef(nid_hf, "SWnetOR",
      .                "Sfce net SW radiation OR", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_hf, "SWdownOR",
      .                "Sfce incident SW radiation OR", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_hf, "LWdownOR",
      .                "Sfce incident LW radiation OR", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
       ENDIF !lev_histhf.GE.2
@@ -148,5 +154,5 @@
           CALL histdef(nid_hf, "t"//bb2,
      .                 "Temperature "//bb2//"mb","K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zout)
 c
@@ -154,5 +160,5 @@
           CALL histdef(nid_hf, "phi"//bb2, 
      .                "Geopotential "//bb2//"mb", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zout)
           ENDIF
@@ -160,15 +166,15 @@
           CALL histdef(nid_hf, "q"//bb2,
      .                 "Specific humidity "//bb2//"mb","kg/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zout)
 c
           CALL histdef(nid_hf, "u"//bb2,
      .                 "Zonal wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zout)
 c
           CALL histdef(nid_hf, "v"//bb2,
      .                 "Meridional wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zout)
 c
@@ -210,10 +216,10 @@
           CALL histdef(nid_hf, "u"//bb2,
      .                 "Zonal wind "//bb2//"mb","m/s",
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "inst(X)", zstohf,zstohf)
 c
           CALL histdef(nid_hf, "v"//bb2,
      .                 "Meridional wind "//bb2//"mb","m/s",
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "inst(X)", zstohf,zstohf)
 c
@@ -223,14 +229,14 @@
         CALL histdef(nid_hf, "topl", 
      .       "Outgoing longwave radiation", "W/m2",
-     .       iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .       iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .       "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_hf, "precip","Total precipitation rate",
-     .       "kg/(s*m2)",iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .       "kg/(s*m2)",iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .       "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_hf, "slp", 
      .       "Mean sea-level pressure", "Pa",
-     .       iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .       iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .       "inst(X)", zstohf,zout)
 c
@@ -255,10 +261,10 @@
           CALL histdef(nid_hf, "t"//bb2,
      .                 "Temperature "//bb2//"mb","K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zstohf)
 c
           CALL histdef(nid_hf, "q"//bb2,
      .                 "Specific humidity "//bb2//"mb","kg/kg",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zstohf)
 c
@@ -269,10 +275,10 @@
           CALL histdef(nid_hf, "phi"//bb2,
      .                "Geopotential "//bb2//"mb", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zstohf)
 c
           CALL histdef(nid_hf, "w"//bb2,
      .                 "Vertical motion "//bb2//"mb","Pa/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zstohf)
          ENDIF !bb2.EQ."500"
@@ -282,15 +288,15 @@
           CALL histdef(nid_hf, "t"//bb3,
      .                 "Temperature "//bb3//"mb","K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zstohf,zstohf)
 c
           CALL histdef(nid_hf, "u"//bb3,
      .                 "Zonal wind "//bb3//"mb","m/s",
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "inst(X)", zstohf,zstohf)
 c
           CALL histdef(nid_hf, "v"//bb3,
      .                 "Meridional wind "//bb3//"mb","m/s",
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "inst(X)", zstohf,zstohf)
 c
@@ -300,77 +306,77 @@
 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)", zstohf,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)", zstohf,zout)
 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)", zstohf,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)", zstohf,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)", zstohf,zout)
 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)", zstohf,zout)
 c
         CALL histdef(nid_hf, "taux",
      $         "Zonal wind stress","Pa",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstohf,zout)
 c
         CALL histdef(nid_hf, "tauy",
      $         "Meridional wind stress ", "Pa",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstohf,zout)
 c
         CALL histdef(nid_hf, "prw", "Precipitable water", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
 cIM 090904  .                "ave(X)", zstohf,zout)
      .                "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_hf, "sens", "Sensible heat flux", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
 cIM 090904  .                "ave(X)", zstohf,zout)
      .                "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_hf, "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)", zstohf,zout)
 c
 c       CALL histdef(nid_hf, "snow_mass", "Snow Mass", "kg/m2",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+c    .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
 c    .                "ave(X)", zstohf,zout)
 c
         CALL histdef(nid_hf, "SWdnSFC", "SWdn at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstohf,zout)
 c
         CALL histdef(nid_hf, "SWupSFC", "SWup at surface","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstohf,zout)
 c
         CALL histdef(nid_hf,"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)", zstohf,zout)
 c
         CALL histdef(nid_hf,"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)", zstohf,zout)
 c
         CALL histdef(nid_hf, "SWdnTOA", "SWdn at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstohf,zout)
 c
         CALL histdef(nid_hf, "SWupTOA", "SWup at TOA","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstohf,zout)
 c
@@ -378,5 +384,5 @@
          CALL histdef(nid_hf, "PV"//ctetaSTD(k),
      $               "Vorticite potentielle "//ctetaSTD(k)//"K",
-     $               "1/(Pa*s)",iim,jjmp1,nhori, 1,1,1, -99,
+     $               "1/(Pa*s)",iim,jjphy_nb,nhori, 1,1,1, -99,
      $                 32, "inst(X)", zstohf,zout) 
         ENDDO !k=1, nbteta
@@ -393,3 +399,4 @@
       CALL histend(nid_hf)
 c
+c$OMP END MASTER
       ENDIF ! ok_hf
Index: /LMDZ4/trunk/libf/phylmd/ini_histins.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histins.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_histins.h	(revision 766)
@@ -3,4 +3,5 @@
 !
       IF (ok_instan) THEN
+c$OMP MASTER
 c
           zsto = ecrit_ins
@@ -10,15 +11,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
@@ -31,9 +34,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
@@ -41,50 +44,50 @@
 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
@@ -94,49 +97,49 @@
 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)
 
@@ -145,58 +148,58 @@
            call histdef(nid_ins, "pourc_"//clnsurf(nsrf), 
      $         "% "//clnsurf(nsrf), "%",  
-     $         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, "fract_"//clnsurf(nsrf), 
      $         "Fraction "//clnsurf(nsrf), "1",  
-     $         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
@@ -205,44 +208,44 @@
 c HBTM2
          CALL histdef(nid_ins, "s_pblh", "Boundary Layer Height", "m",
-     .                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, "s_pblt", "T at Boundary Layer Height", 
      .                "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, "s_lcl", "Condensation level", "m",
-     .                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, "s_capCL", "Conv avlbl pot ener for 
      .                ABL", "J/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, "s_oliqCL", "Liq Water in BL", "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, "s_cteiCL", "Instability criteria 
      .                (ABL)", "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, "s_therm", "Exces du thermique", "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, "s_trmb1", "deep_cape(HBTM2)", "J/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, "s_trmb2", "inhibition (HBTM2)", "J/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, "s_trmb3", "Point Omega (HBTM2)", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zsto,zout)
 c
@@ -252,29 +255,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
@@ -285,3 +288,5 @@
          ndex3d = 0
 c
+c$OMP END MASTER
+
       ENDIF
Index: /LMDZ4/trunk/libf/phylmd/ini_histmth.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histmth.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_histmth.h	(revision 766)
@@ -3,4 +3,5 @@
 c
       IF (ok_mensuel) THEN
+c$OMP MASTER
 c
        zstophy = dtime
@@ -13,48 +14,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
-c
-cIM cf. AM 081204 BEG region
-c         imin_histmth=1
-c         imax_histmth=iim
-c         jmin_histmth=1
-c         jmax_histmth=jjmp1
-c         do i=1,iim-1
-c            if(zx_lon(i,1).lt.lonmin_histmth) imin_histmth=i
-c            if(zx_lon(i,1).le.lonmax_histmth) imax_histmth=i+1
-c         enddo
-cIM 220704 BAD??       do j=1,jjmp1-1
-c         do j=1,jjmp1
-c            if(zx_lat(1,j).ge.latmin_histmth) jmax_histmth=j
-c            if(zx_lat(1,j).gt.latmax_histmth) jmin_histmth=j
-c         enddo
-c
-c         print*,'On stoke le fichier instantanne sur, ',
-c     s   imin_histmth,imax_histmth,jmin_histmth,jmax_histmth
-c         print*,'On stoke le fichier instantanne sur, ',
-c     s   zx_lon(imin_histmth,1),zx_lon(imax_histmth,1),
-c     s   zx_lat(1,jmin_histmth),zx_lat(1,jmax_histmth)
-cIM cf. AM 081204 END region
-c
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
+cym         DO i = 1, iim
+cym            zx_lon(i,1) = rlon(i+1)
+cym            zx_lon(i,jjmp1) = rlon(i+1)
+cym         ENDDO
          DO ll=1,klev
             znivsig(ll)=float(ll)
          ENDDO
-         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",itau_phy, zjulian, dtime, 
      .                 nhori, nid_mth)
-c
-cIM cf. AM 081204 BEG region
-c         CALL histbeg("histmth.nc", iim,zx_lon(:,1), jjmp1,zx_lat(1,:),
-c     .                 imin_histmth,imax_histmth-imin_histmth+1
-c     .                 ,jmin_histmth,jmax_histmth-jmin_histmth+1
-c     .                 , itau_phy, zjulian, dtime,
-c     .                 nhori, nid_mth)
-cIM 081204 END
-c
+     
+       write(*,*)'Mensuel ', itau_phy, zjulian
          CALL histvert(nid_mth, "presnivs", "Vertical levels", "mb",
      .                 klev, presnivs/100., nvert)
@@ -66,19 +40,19 @@
          CALL histdef(nid_mth, "phis", 
      .                "Surface geop. height", "m2/s2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "once",  zstophy,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",  zstophy,zout)
 c
          CALL histdef(nid_mth, "pourc_"//clnsurf(is_ter), 
      .         "% "//clnsurf(is_ter), "%",  
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "once", zstophy,zout)
 c
          CALL histdef(nid_mth, "fract_"//clnsurf(is_ter), 
      .         "Fraction "//clnsurf(is_ter), "1",  
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "once", zstophy,zout)
 c
@@ -86,13 +60,13 @@
 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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -100,49 +74,49 @@
          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, zstophy,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, zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
 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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
       endif
@@ -150,162 +124,162 @@
          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)", zstomth,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
 c        CALL histdef(nid_mth, "snow_mass", "Snow Mass", "kg/m2",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
 c    .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "tops0", "CS 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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "SWup200", "SWup at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "SWup200clr", 
      .                "SWup clear sky at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "SWdn200", "SWdn at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "SWdn200clr", 
      .                "SWdn clear sky at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "LWup200", "LWup at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "LWup200clr", 
      .                "LWup clear sky at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "LWdn200", "LWdn at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "LWdn200clr", 
      .                "LWdn clear sky at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "radsol", "Rayonnement au sol", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -315,32 +289,36 @@
 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)", zstophy,zout)
 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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "fqcalving","Ice Calving",
-     .                "kg/m2/s",iim,jjmp1,nhori, 1,1,1, -99, 32,
-     .                "ave(X)", zstophy,zout)
-c
+     .                "kg/m2/s",iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zstophy,zout)
+c
+         CALL histdef(nid_mth, "fqfonte","Land ice melt",
+     .                "kg/m2/s",iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "ave(X)", zsto,zout)
+
          DO nsrf = 1, nbsrf
            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)", zstophy,zout)
 
            call histdef(nid_mth, "tauy_"//clnsurf(nsrf), 
      $         "Meridional wind stress "//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
          ENDDO
@@ -351,10 +329,10 @@
            call histdef(nid_mth, "pourc_"//clnsurf(nsrf), 
      $         "% "//clnsurf(nsrf), "%",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 c
            call histdef(nid_mth, "fract_"//clnsurf(nsrf), 
      $         "Fraction "//clnsurf(nsrf), "1",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
           ENDIF !nsrf.GT.2
@@ -362,35 +340,35 @@
            call histdef(nid_mth, "tsol_"//clnsurf(nsrf), 
      $         "Temperature "//clnsurf(nsrf), "K",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 C
            call histdef(nid_mth, "wbilo_"//clnsurf(nsrf),
      $         "Bilan eau "//clnsurf(nsrf), "kg/(m2*s)",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
@@ -400,10 +378,10 @@
            call histdef(nid_mth, "evapour_"//clnsurf(nsrf),
      $         "Evap*pourc "//clnsurf(nsrf), "kg/(s*m2)",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
            call histdef(nid_mth, "prepour_"//clnsurf(nsrf),
      $         "Precip*pourc "//clnsurf(nsrf), "kg/(s*m2)",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
@@ -414,53 +392,53 @@
 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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          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)", zstophy,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)", zstophy,zout)
 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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 cKE43
@@ -468,21 +446,21 @@
 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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "pbase", "Cld base pressure", "mb",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "ptop", "Cld top pressure", "mb",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,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)", zstophy,zout)
 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)", zstophy,zout)
 c
@@ -493,35 +471,35 @@
 c HBTM2
          CALL histdef(nid_mth, "s_pblh", "Boundary Layer Height", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_pblt", "t at Boundary Layer Height",
      .                "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_lcl", "Condensation level", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_capCL", "Conv avlbl pot ener 
      .                for ABL", "J/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_oliqCL", "Liq Water in BL", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_cteiCL", "Instability criteria 
      .                (ABL)", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_therm", "Exces du thermique", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_trmb1", "deep_cape(HBTM2)", "J/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_trmb2", "inhibition (HBTM2)", "J/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_trmb3", "Point Omega (HBTM2)", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
@@ -545,20 +523,20 @@
           CALL histdef(nid_mth, "u"//bb2,
      .                 "Zonal wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_mth, "v"//bb2,
      .                 "Meridional wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_mth, "w"//bb2,
      .                 "Vertical wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_mth, "phi"//bb2,
      .                 "Geopotential "//bb2//"mb","m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
@@ -571,15 +549,15 @@
        CALL histdef(nid_mth, "fluxo",
      .              "Flux turbulents ocean-atmosphere", "W/m2",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
        CALL histdef(nid_mth, "fluxg",
      .              "Flux turbulents ocean-glace de mer","W/m2",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
        CALL histdef(nid_mth, "t_oce_sic",
      .              "Temp. mixte oce-sic","K",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
@@ -588,5 +566,5 @@
         CALL histdef(nid_mth, "lmt_bils",
      .       "Bilan au sol atmosphere forcee", "W/m2",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
@@ -595,17 +573,17 @@
         CALL histdef(nid_mth, "slab_bils",
      .       "Bilan au sol Slab", "W/m2",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_mth, "tslab", "Slab SST ", "K",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_mth, "seaice", "Slab seaice", "kg/m2",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_mth, "siceh", "Slab seaice height", "m",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
@@ -621,70 +599,70 @@
          CALL histdef(nid_mth,"lwcon","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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "geop", "Geopotential height", "m2/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "vitw", "Vertical wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "ozone", "Ozone concentration", "ppmv",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -697,14 +675,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -712,8 +690,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)", zstophy,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)", zstophy,zout)
 c
@@ -725,119 +703,119 @@
      .                "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)", zstophy,zout)
 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)", zstophy,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)", zstophy,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)", zstophy,zout)
 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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "dtlschr",
-     $       "Large-scale condensational heating rate", "K/s",iim,jjmp1
-     $       ,nhori, klev,1,klev,nvert, 32,"ave(X)", zstophy,zout)
+     $     "Large-scale condensational heating rate", "K/s",iim,jjphy_nb
+     $     ,nhori, klev,1,klev,nvert, 32,"ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -846,9 +824,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)", zstophy,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)", zstophy,zout)
          ENDIF
@@ -859,5 +837,5 @@
          WRITE(str2,'(i2.2)') iq
          CALL histdef(nid_mth, "trac"//str2, "Tracer No."//str2, "-",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
          ELSE
@@ -875,48 +853,48 @@
 c
          CALL histdef(nid_mth, "phis", "Surface geop. height", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "once",  zstophy,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",  zstophy,zout)
 c
          CALL histdef(nid_mth, "pourc_"//clnsurf(is_ter), 
      .         "% "//clnsurf(is_ter), "%",  
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "once", zstophy,zout)
 c
          CALL histdef(nid_mth, "fract_"//clnsurf(is_ter), 
      .         "Fraction "//clnsurf(is_ter), "1",  
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "once", zstophy,zout)
 c
          CALL histdef(nid_mth, "pourc_"//clnsurf(is_lic), 
      .         "% "//clnsurf(is_lic), "%",  
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "once", zstophy,zout)
 c
          CALL histdef(nid_mth, "fract_"//clnsurf(is_lic), 
      .         "Fraction "//clnsurf(is_lic), "1",  
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "once", zstophy,zout)
 c
          CALL histdef(nid_mth, "pourc_"//clnsurf(is_sic),
      .         "% "//clnsurf(is_sic), "%",
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "fract_"//clnsurf(is_sic),
      .         "Fraction "//clnsurf(is_sic), "1",
-     .         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "bilTOA",
      .                "Net radiation at TOA", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
@@ -925,88 +903,88 @@
 c    .                "TOA reflected clear-sky shortwave 
 c    .                radiation (method 1)", "W/m2",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+c    .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
 c    .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dtdia","dtdia","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dtsw","dtsw","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dtlw","dtlw","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dtcon","dtcon","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dtajs","dtajs","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dtlsc","dtlsc","K/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dqdia","dqdia","(kg/kg)/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "duoli",
      .         "duoli","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dvoli",
      .         "dvoli","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "ducon",
      .         "ducon","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dvcon",
      .         "dvcon","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dutot",
      .         "dutot","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "dvtot",
      .         "dvtot","m/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,zout)
 c
 c         CALL histdef(nid_mth, "cldtrue",
 c    .         "TRUE Cloud fraction ","%",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
 c    .         "inst(X)", zout,zout)
 c
 c         CALL histdef(nid_mth, "cldTOA",
 c    .         "Cloud amount (satellite view)","%",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
 c    .         "ave(X)", zstophy,zout)
 c
 c         CALL histdef(nid_mth, "cldSFC",
 c    .         "Cloud amount (surface view)","%",
-c    .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+c    .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
 c    .         "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "GWDtaux",
      .         "GWD induced Ewd wind stress","Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "ave(X)", zstophy,zout)
 c
           CALL histdef(nid_mth, "GWDtauy",
      .         "GWD induced Nwd wind stress","Pa",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .         "ave(X)", zstophy,zout)
 c
@@ -1014,62 +992,62 @@
 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)", zstorad,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)", zstophy,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)", zstorad,zout)
 c
          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, zstophy,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, zstophy,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)", zstophy,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)", zstorad,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)", zstophy,zout)
 
 c
          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)", zstorad,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)", zstorad,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)", zstorad,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)", zstorad,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)", zstophy,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)", zstophy,zout)
       endif
@@ -1077,187 +1055,187 @@
          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)", zstomth,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "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)", zstophy,zout)
 c
 c        CALL histdef(nid_mth, "snow_mass", "Snow Mass", "kg/m2",
-c    .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+c    .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
 c    .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "evap", 
      .                "Evaporation plus sublimation rate", "kg/(s*m2)",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32, 
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32, 
      .                "ave(X)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "tops0", "CS 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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "SWup200", "SWup at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "SWup200clr", 
      .                "SWup clear sky at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "SWdn200", "SWdn at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "SWdn200clr", 
      .                "SWdn clear sky at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "LWup200", "LWup at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "LWup200clr", 
      .                "LWup clear sky at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "LWdn200", "LWdn at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "LWdn200clr", 
      .                "LWdn clear sky at 200mb","W/m2",
-     .                iim,jjmp1,nhori, 1,1,1,-99,
+     .                iim,jjphy_nb,nhori, 1,1,1,-99,
      .                32, "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "radsol", "Rayonnement au sol", "W/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -1265,10 +1243,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)", zstophy,zout)
 
            call histdef(nid_mth, "tauy_"//clnsurf(nsrf), 
      $         "Meridional wind stress "//clnsurf(nsrf), "Pa",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
          ENDDO
@@ -1276,10 +1254,10 @@
            call histdef(nid_mth, "pourc_"//clnsurf(is_oce), 
      $         "% "//clnsurf(is_oce), "%",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 c
            call histdef(nid_mth, "fract_"//clnsurf(is_oce), 
      $         "Fraction "//clnsurf(is_oce), "1",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
@@ -1288,35 +1266,35 @@
            call histdef(nid_mth, "tsol_"//clnsurf(nsrf), 
      $         "Temperature "//clnsurf(nsrf), "K",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 C
            call histdef(nid_mth, "wbilo_"//clnsurf(nsrf),
      $         "Bilan eau "//clnsurf(nsrf), "kg/(m2*s)",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
@@ -1326,10 +1304,10 @@
            call histdef(nid_mth, "evapour_"//clnsurf(nsrf),
      $         "Evap*pourc "//clnsurf(nsrf), "kg/(s*m2)",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
            call histdef(nid_mth, "prepour_"//clnsurf(nsrf),
      $         "Precip*pourc "//clnsurf(nsrf), "kg/(s*m2)",
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,zout)
 C
@@ -1340,53 +1318,53 @@
 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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          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)", zstophy,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)", zstophy,zout)
 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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 cKE43
@@ -1394,25 +1372,25 @@
 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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "pbase", "Cld base pressure", "mb",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
          CALL histdef(nid_mth, "ptop", "Cld top pressure", "mb",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,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)", zstophy,zout)
 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)", zstophy,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)", zstophy,zout)
 c
@@ -1423,35 +1401,35 @@
 c HBTM2
          CALL histdef(nid_mth, "s_pblh", "Boundary Layer Height", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_pblt", "T at Boundary Layer Height",
      .                "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_lcl", "Condensation level", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth,"s_capCL","Conv avlbl pot ener for ABL",
      .                "J/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_oliqCL", "Liq Water in BL", "kg/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth,"s_cteiCL","Instability criteria (ABL)",
      .                "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_therm", "Exces du thermique", "K",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_trmb1", "deep_cape(HBTM2)", "J/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_trmb2", "inhibition (HBTM2)", "J/m2",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
          CALL histdef(nid_mth, "s_trmb3", "Point Omega (HBTM2)", "m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "ave(X)", zstophy,zout)
 c
@@ -1475,20 +1453,20 @@
           CALL histdef(nid_mth, "u"//bb2,
      .                 "Zonal wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_mth, "v"//bb2,
      .                 "Meridional wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_mth, "w"//bb2,
      .                 "Vertical wind "//bb2//"mb","m/s",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_mth, "phi"//bb2,
      .                 "Geopotential "//bb2//"mb","m",
-     .                iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .                "inst(X)", zout,zout)
 c
@@ -1502,15 +1480,15 @@
        CALL histdef(nid_mth, "fluxo",
      .              "Flux turbulents ocean-atmosphere", "W/m2",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
        CALL histdef(nid_mth, "fluxg",
      .              "Flux turbulents ocean-glace de mer","W/m2",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
        CALL histdef(nid_mth, "t_oce_sic",
      .              "Temp. mixte oce-sic","K",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
@@ -1519,5 +1497,5 @@
         CALL histdef(nid_mth, "lmt_bils",
      .       "Bilan au sol atmosphere forcee", "W/m2",
-     .       iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .       iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .       "ave(X)", zstophy,zout)
 c
@@ -1526,17 +1504,17 @@
         CALL histdef(nid_mth, "slab_bils",
      .              "Bilan au sol Slab", "W/m2",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_mth, "tslab", "Slab SST ", "K",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_mth, "seaice", "Slab seaice", "kg/m2",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
         CALL histdef(nid_mth, "siceh", "Slab seaice height", "m",
-     .              iim,jjmp1,nhori, 1,1,1, -99, 32,
+     .              iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      .              "ave(X)", zstophy,zout)
 c
@@ -1552,66 +1530,66 @@
          CALL histdef(nid_mth,"lwcon","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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "geop", "Geopotential height", "m2/s2",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "vitw", "Vertical wind", "m/s",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "ozone", "Ozone concentration", "ppmv",
-     .                iim,jjmp1,nhori, klev,1,klev,nvert, 32,
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -1624,14 +1602,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)", zstophy,zout)
 c
            call histdef(nid_mth, "rugs_"//clnsurf(nsrf), 
      $         "Rugosite "//clnsurf(nsrf), "m",  
-     $         iim,jjmp1,nhori, 1,1,1, -99, 32,
+     $         iim,jjphy_nb,nhori, 1,1,1, -99, 32,
      $         "ave(X)", zstophy,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)", zstophy,zout)
 c
@@ -1639,8 +1617,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)", zstophy,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)", zstophy,zout)
 c
@@ -1652,103 +1630,104 @@
      .                "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)", zstophy,zout)
 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)", zstophy,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)", zstophy,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)", zstophy,zout)
 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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
          CALL histdef(nid_mth, "dtlschr",
-     $       "Large-scale condensational heating rate", "K/s",iim,jjmp1
+     $       "Large-scale condensational heating rate", "K/s",
+     $       iim,jjphy_nb
      $       ,nhori, klev,1,klev,nvert, 32,"ave(X)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 
 c
          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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,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)", zstophy,zout)
 c
@@ -1757,9 +1736,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)", zstophy,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)", zstophy,zout)
          ENDIF
@@ -1769,5 +1748,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)", zstophy,zout)
          ENDDO
@@ -1783,3 +1762,4 @@
          ndex3d = 0
 c
+c$OMP END MASTER
       ENDIF ! fin de test sur ok_mensuel
Index: /LMDZ4/trunk/libf/phylmd/ini_histmthNMC.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histmthNMC.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_histmthNMC.h	(revision 766)
@@ -4,4 +4,6 @@
       IF (ok_mensuel) THEN
 c
+c$OMP MASTER
+
        zstophy = dtime
        zstohf = ecrit_hf
@@ -12,15 +14,18 @@
          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",itau_phy, zjulian, dtime, 
      .                 nhori, nid_nmc)
 c
@@ -34,30 +39,30 @@
           CALL histdef(nid_nmc, "temp",
      .                 "Temperature","K",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
          CALL histdef(nid_nmc, "phi",
      .                "Geopotential", "m",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_nmc, "q",
      .                 "Specific humidity","kg/kg",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
          CALL histdef(nid_nmc, "rh",
      .                 "Relative humidity", "%",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_nmc, "u",
      .                 "Zonal wind","m/s",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_nmc, "v",
      .                 "Meridional wind","m/s",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
@@ -73,35 +78,35 @@
           CALL histdef(nid_nmc, "temp",
      .                 "Temperature","K",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
          CALL histdef(nid_nmc, "phi",
      .                "Geopotential ", "m",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_nmc, "q",
      .                 "Specific humidity","kg/kg",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
          CALL histdef(nid_nmc, "rh",
      .                 "Relative humidity", "%",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_nmc, "u",
      .                 "Zonal wind","m/s",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_nmc, "v",
      .                 "Meridional wind","m/s",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
           CALL histdef(nid_nmc, "w",
      .                 "Vertical motion","Pa/s",
-     .                iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .                iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .                "inst(X)", zout,zout)
 c
@@ -116,15 +121,15 @@
           CALL histdef(nid_nmc, "psbg",
      .         "Pressure sfce below ground","%",
-     .         iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .         iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
 c
           CALL histdef(nid_nmc, "uv",
      .         "uv ",
-     .         "m2/s2",iim,jjmp1,nhori, nlevSTD,1,nlevSTD, nvert, 32,
+     .         "m2/s2",iim,jjphy_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
 c
           CALL histdef(nid_nmc, "vq",
      .         "vq ",
-     .         "m/s * (kg/kg)",iim,jjmp1,nhori, 
+     .         "m/s * (kg/kg)",iim,jjphy_nb,nhori, 
      .          nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
@@ -132,5 +137,5 @@
           CALL histdef(nid_nmc, "vT",
      .         "vT ", 
-     .         "mK/s",iim,jjmp1,nhori, 
+     .         "mK/s",iim,jjphy_nb,nhori, 
      .          nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
@@ -138,5 +143,5 @@
           CALL histdef(nid_nmc, "wq",
      .         "wq ", 
-     .         "(Pa/s)*(kg/kg)",iim,jjmp1,nhori,
+     .         "(Pa/s)*(kg/kg)",iim,jjphy_nb,nhori,
      .          nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
@@ -144,5 +149,5 @@
           CALL histdef(nid_nmc, "vphi",
      .         "vphi ", 
-     .         "m2/s",iim,jjmp1,nhori, 
+     .         "m2/s",iim,jjphy_nb,nhori, 
      .          nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
@@ -150,5 +155,5 @@
           CALL histdef(nid_nmc, "wT",
      .         "wT ", 
-     .         "K*Pa/s",iim,jjmp1,nhori,
+     .         "K*Pa/s",iim,jjphy_nb,nhori,
      .          nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
@@ -156,5 +161,5 @@
           CALL histdef(nid_nmc, "uxu",
      .         "u2 ", 
-     .         "m2/s2",iim,jjmp1,nhori,
+     .         "m2/s2",iim,jjphy_nb,nhori,
      .          nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
@@ -162,5 +167,5 @@
           CALL histdef(nid_nmc, "vxv",
      .         "v2 ", 
-     .         "m2/s2",iim,jjmp1,nhori,
+     .         "m2/s2",iim,jjphy_nb,nhori,
      .          nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
@@ -168,5 +173,5 @@
           CALL histdef(nid_nmc, "TxT",
      .         "T2 ", 
-     .         "K2",iim,jjmp1,nhori,
+     .         "K2",iim,jjphy_nb,nhori,
      .          nlevSTD,1,nlevSTD, nvert, 32,
      .         "inst(X)", zout,zout)
@@ -176,3 +181,5 @@
          CALL histend(nid_nmc)
 c
+c$OMP END MASTER
+
       ENDIF ! fin de test sur ok_mensuel
Index: /LMDZ4/trunk/libf/phylmd/ini_histrac.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_histrac.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_histrac.h	(revision 766)
@@ -2,283 +2,44 @@
 ! $Header$
 !
+#ifndef INCA
+c$OMP MASTER 
          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",
      .                 klev, presnivs, nvert)
 
-#ifdef INCA_AER
-         CALL histbeg("histrac_aer", iim,zx_lon(:,1), jjm+1,zx_lat(1,:),
-     .                 1,iim,1,jjm+1,  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,
-     .                 nhori, nid_tra3)
-
-         call histvert(nid_tra2, "presnivs", "Vertical levels", "mb",
-     .                 klev, presnivs, nvert)
-         call histvert(nid_tra3, "presnivs", "presnivs", "mb",
-     .                 klev, presnivs, nvert)
-#endif
 
 
          zsto = pdtphys
-         zout = ecrit_tra
+         zout = pdtphys * FLOAT(ecrit_tra)
 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,
-     .                "ave(X)", zsto,zout)
-
-         CALL histdef(nid_tra, "ptrop", "Tropopause pressure", "Pa",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-
-         CALL histdef(nid_tra, "u", "zonal wind component", "m/s",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-
-         CALL histdef(nid_tra, "h2o", "Specific Humidity", "MMR",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-
-         CALL histdef(nid_tra, "pdel", "Delta Pressure", "Pa",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-
-! MS info
-#ifdef INCA_AER
-         CALL histdef(nid_tra, "airm", "Air mass", "kg",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-#endif
-#ifdef INCA
-#ifdef INCAINFO
-
-#ifdef INCA_CH4
-         DO it=1, phtcnt
-         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,
-     .                "ave(X)", zsto,zout)
-         ENDDO
-         DO it=1, hetcnt
-         WRITE(str2,'(i2.2)') it
-         CALL histdef(nid_tra, "w"//str2,"w"//str2, "S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-         ENDDO
-         DO it=1, extcnt
-         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,
-     .                "ave(X)", zsto,zout)
-         ENDDO
-#endif
-#ifdef INCA_NMHC
-         DO it=1, phtcnt
-         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,
-     .                "ave(X)", zsto,zout)
-         ENDDO
-         DO it=1, hetcnt
-         WRITE(str2,'(i2.2)') it
-         CALL histdef(nid_tra, "w"//str2,"w"//str2, "S-1",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-         ENDDO
-         DO it=1, extcnt
-         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,
-     .                "ave(X)", zsto,zout)
-         ENDDO
-#endif
-         DO it=1, nfs
-         WRITE(str2,'(i2.2)') it
-         CALL histdef(nid_tra, "INV"//str2, "INV"//str2, "CM-3",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-         ENDDO
-
-#else
-
-#ifdef INCA_NMHC
-         CALL histdef(nid_tra, "jO3","jO3", "CM-3 S-1",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-         CALL histdef(nid_tra, "jH2O2","jH2O2", "CM-3 S-1",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-         CALL histdef(nid_tra, "kN2O5", "kN2O5","CM-3 S-1",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-#endif
-#ifdef INCA_CH4
-         CALL histdef(nid_tra, "jO3","jO3", "CM-3 S-1",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-         CALL histdef(nid_tra, "jH2O2","jH2O2", "CM-3 S-1",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-         CALL histdef(nid_tra, "kN2O5", "kN2O5","CM-3 S-1",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-#endif
-#endif
-
-!         DO it=1, grpcnt
-!         CALL histdef(nid_tra, grpsym(it), grpsym(it), "VMR",
-!     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-!     .                "ave(X)", zsto,zout)
-!         ENDDO
-#endif
-
-#ifdef INCA_AER
-
-        CALL histdef(nid_tra2, "scavcoef_st","scavcoef_st", "S-1",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-        CALL histdef(nid_tra2, "AngstroemComp","AngstroemComp",
-     .      "angs comp", iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .      "ave(X)", zsto,zout)
-
-        CALL histdef(nid_tra2, "TOTAERH2O", "Total aerosol water",
-     .      "kg/m2", iim,jjm+1,nhori, klev,1,klev, nvert, 32,
-     .      "ave(X)", zsto,zout)
-#endif
-#endif
          DO it=1,nqmax
 C champ 2D
-#ifdef INCA
-         IF ( prt_flag_ts(it) == 0 ) CYCLE
-         CALL histdef(nid_tra, "Emi_"//solsym(it), "Emi_"//solsym(it),
-     .           "kg/m2/s", iim,jjm+1,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,
-     .           "ave(X)", zsto,zout)
-#ifdef INCA_AER
-
-         CALL histdef(nid_tra2, "Dry_"//solsym(it), "Dry_"//solsym(it),
-     .           "kg/m2/s", iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .           "ave(X)", zsto,zout)
-          
-        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,
-     .      "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,
-     .      "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,
-     .      "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,
-     .      "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,
-     .      "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,
-     .      "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,
-     .      "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,
-     .        "ave(X)", zsto,zout)
-
-            CALL histdef(nid_tra2, "OD3D"//cla(la)//"_"//solsym(it), "OD3d_"//cla(la)//"_"//solsym(it),
-     .        "opt. depth 3D", iim,jjm+1,nhori, klev,1,klev, nvert, 32,
-     .        "ave(X)", zsto,zout)
-          enddo
-
-          CALL histdef(nid_tra2, "CLOAD_"//solsym(it), "3D LOAD_"//solsym(it),
-     .      "kg/m2 resp. #/m2", iim,jjm+1,nhori, klev,1,klev, nvert, 32,
-     .      "ave(X)", zsto,zout)
-
-          CALL histdef(nid_tra2, "MD_"//solsym(it), "MD_"//solsym(it),
-     .      "median diameter [m]", iim,jjm+1,nhori, klev,1,klev, nvert, 32,
-     .      "ave(X)", zsto,zout)
-
-          CALL histdef(nid_tra2, "MDW_"//solsym(it), "MDW_"//solsym(it),
-     .      "wet median diameter [m]", iim,jjm+1,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,
-     .      "inst(X)", zout,zout)
-
-        endif
-
-#endif
-         CALL histdef(nid_tra, solsym(it), solsym(it), "VMR",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-#else
          iq=it+2
          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
@@ -287,211 +48,82 @@
          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	 
 
-#endif
          ENDDO
 
-#ifdef INCA
-         CALL histdef(nid_tra, "O3_column", "O3_column",
-     .           "DU", iim,jjm+1,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,
-     .           "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,
-     .           "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,
-     .           "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,
-     .           "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,
+         CALL histdef(nid_tra, "pyu1", "Vent niv 1", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zout,zout)
+
+         CALL histdef(nid_tra, "pyv1", "Vent niv 1", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zout,zout)
+         CALL histdef(nid_tra, "psrf1", "nature sol", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zout,zout)
+         CALL histdef(nid_tra, "psrf2", "nature sol", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zout,zout)
+         CALL histdef(nid_tra, "psrf3", "nature sol", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zout,zout)
+         CALL histdef(nid_tra, "psrf4", "nature sol", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zout,zout)
+         CALL histdef(nid_tra, "ftsol1", "temper sol", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zout,zout)
+         CALL histdef(nid_tra, "ftsol2", "temper sol", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zout,zout)
+         CALL histdef(nid_tra, "ftsol3", "temper sol", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst",  zout,zout)
+         CALL histdef(nid_tra, "ftsol4", "temper sol", "-",
+     .                iim,jjphy_nb,nhori, 1,1,1, -99, 32,
+     .                "inst(X)",  zout,zout)
+         CALL histdef(nid_tra, "pplay", "flux u mont","-",
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
+     .                "inst(X)", zout,zout)
+         CALL histdef(nid_tra, "t", "flux u mont","-",
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
+     .                "inst(X)", zout,zout)
+         CALL histdef(nid_tra, "mfu", "flux u mont","-",
+     .                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,
+         CALL histdef(nid_tra, "mfd", "flux u decen","-",
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "en_u", "flux u mont","-",
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "en_d", "flux u mont","-",
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "de_d", "flux u mont","-",
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "de_u", "flux u decen","-",
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
+     .                "ave(X)", zsto,zout)
+         CALL histdef(nid_tra, "coefh", "turbulent coef","-",
+     .                iim,jjphy_nb,nhori, klev,1,klev,nvert, 32,
      .                "ave(X)", zsto,zout)
 
-!        Special variables for daytime averaging
-!        CALL histdef(nid_tra, "day_cnt", "day_cnt", "-",
-!    .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-!    .                "t_sum(X)", zsto,zout)
-!        CALL histdef(nid_tra, "NO_day", "NO_day", "VMR",
-!    .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-!    .                "t_sum(X)", zsto,zout)
-
-
-
-!! Ajout Anne
-#ifdef INCA_AER
-! 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,
-     .                "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,
-     .                "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,
-     .                "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,
-     .                "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,
-     .                "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,
-     .                "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,
-     .                "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,
-     .                "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,
-     .                "ave(X)", zsto,zout)
-
-         CALL histdef(nid_tra, "Wet3D_SO2", "Wet3D_SO2",
-     .           "kg/m2/s", iim,jjm+1,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,
-     .           "ave(X)", zsto,zout)
-         CALL histdef(nid_tra, "Wet3D_HNO3", "Wet3D_HNO3",
-     .           "kg/m2/s", iim,jjm+1,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,
-     .           "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,
-     .                "ave(X)", zsto,zout)
-#endif
-
-#ifdef INCA_CH4
-         DO it=1, grpcnt
-         CALL histdef(nid_tra, grpsym(it), grpsym(it), "VMR",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-         ENDDO
-
-#endif
-
-
-#ifdef INCA_NMHC
-         CALL histdef(nid_tra, "CO2_basprod", "CO2_basprod", "CM-3 S-1",
-     .                iim,jjm+1,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,
-     .                "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,
-     .                "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,
-     .                "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,
-     .                "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,
-     .                "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,
-     .                "ave(X)", zsto,zout)
-
-         DO it=1, grpcnt
-         CALL histdef(nid_tra, grpsym(it), grpsym(it), "VMR",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-         ENDDO
-
-
-#endif
-! Fin ajout Anne
-#else
-         CALL histdef(nid_tra, "pyu1", "Vent niv 1", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)", zout,zout)
-
-         CALL histdef(nid_tra, "pyv1", "Vent niv 1", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)",  zout,zout)
-         CALL histdef(nid_tra, "psrf1", "nature sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)",  zout,zout)
-         CALL histdef(nid_tra, "psrf2", "nature sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)",  zout,zout)
-         CALL histdef(nid_tra, "psrf3", "nature sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)",  zout,zout)
-         CALL histdef(nid_tra, "psrf4", "nature sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)",  zout,zout)
-         CALL histdef(nid_tra, "ftsol1", "temper sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)",  zout,zout)
-         CALL histdef(nid_tra, "ftsol2", "temper sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)",  zout,zout)
-         CALL histdef(nid_tra, "ftsol3", "temper sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)",  zout,zout)
-         CALL histdef(nid_tra, "ftsol4", "temper sol", "-",
-     .                iim,jjm+1,nhori, 1,1,1, -99, 32,
-     .                "inst(X)",  zout,zout)
-         CALL histdef(nid_tra, "pplay", "flux u mont","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "inst(X)", zout,zout)
-         CALL histdef(nid_tra, "t", "flux u mont","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "inst(X)", zout,zout)
-         CALL histdef(nid_tra, "mfu", "flux u mont","-",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-         CALL histdef(nid_tra, "en_u", "flux u mont","-",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-         CALL histdef(nid_tra, "de_d", "flux u mont","-",
-     .                iim,jjm+1,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,
-     .                "ave(X)", zsto,zout)
-         CALL histdef(nid_tra, "coefh", "turbulent coef","-",
-     .                iim,jjm+1,nhori, klev,1,klev,nvert, 32,
-     .                "ave(X)", zsto,zout)
-
-#endif
 c
          CALL histend(nid_tra)
-#ifdef INCA_AER
-         CALL histend(nid_tra2)
-         CALL histend(nid_tra3)
-#endif
          ndex2d = 0
          ndex3d = 0
          ndex = 0
+c$OMP END MASTER
+#endif
Index: /LMDZ4/trunk/libf/phylmd/ini_paramLMDZ_phy.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_paramLMDZ_phy.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_paramLMDZ_phy.h	(revision 766)
@@ -1,2 +1,5 @@
+cym    Non implemente en mode parallele
+
+       IF (monocpu) THEN  
 c
        zstophy = dtime
@@ -357,4 +360,6 @@
 c
        CALL histend(nid_ctesGCM)
+       
+       ENDIF ! monocpu
 c
 c=================================================================
Index: /LMDZ4/trunk/libf/phylmd/ini_undefSTD.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ini_undefSTD.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ini_undefSTD.F	(revision 766)
@@ -2,4 +2,5 @@
      $           dtime,ecrit_day,ecrit_mth,
      $           tnondef,tsumSTD)
+      USE dimphy
       IMPLICIT none
 c
@@ -26,8 +27,8 @@
 c====================================================================
 c
-#include "dimensions.h"
-      integer jjmp1
-      parameter (jjmp1=jjm+1-1/jjm)
-#include "dimphy.h"
+cym #include "dimensions.h"
+cym      integer jjmp1
+cym      parameter (jjmp1=jjm+1-1/jjm)
+cym #include "dimphy.h"
 c variables Input/Output
       INTEGER nlevSTD, klevSTD, itap
Index: /LMDZ4/trunk/libf/phylmd/inifis.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/inifis.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/inifis.F	(revision 766)
@@ -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/trunk/libf/phylmd/iniphysiq.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/iniphysiq.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/iniphysiq.F	(revision 766)
@@ -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,8 +45,8 @@
 c   -------------
  
-#include "dimensions.h"
-#include "dimphy.h"
-#include "comgeomphy.h"
-
+cym#include "dimensions.h"
+cym#include "dimphy.h"
+cym#include "comgeomphy.h"
+#include "YOMCST.h"
       REAL prad,pg,pr,pcpp,punjours
  
@@ -52,4 +54,5 @@
       REAL plat(ngrid),plon(ngrid),parea(klon),pcu(klon),pcv(klon)
       INTEGER pdayref
+      INTEGER :: ibegin,iend
  
       REAL ptimestep
@@ -70,12 +73,19 @@
          STOP
       ENDIF
+c$OMP PARALLEL PRIVATE(ibegin,iend) 
+c$OMP+         SHARED(parea,pcu,pcv,plon,plat)
+      ibegin=klon_begin+klon_omp_begin(omp_rank)-1
+      iend=ibegin+klon_omp-1
 
-      airephy=parea
-      cuphy=pcu
-      cvphy=pcv
-      rlond = plon
-      rlatd = plat
+      airephy(1:klon_omp)=parea(ibegin:iend)
+      cuphy(1:klon_omp)=pcu(ibegin:iend)
+      cvphy(1:klon_omp)=pcv(ibegin:iend)
+      rlond(1:klon_omp) = plon(ibegin:iend)
+      rlatd(1:klon_omp) = plat(ibegin:iend)
 
       call suphec
+
+c$OMP END PARALLEL
+
       print*,'ATTENTION !!! TRAVAILLER SUR INIPHYSIQ'
       print*,'CONTROLE DES LATITUDES, LONGITUDES, PARAMETRES ...'
Index: /LMDZ4/trunk/libf/phylmd/initphysto.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/initphysto.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/initphysto.F	(revision 766)
@@ -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,16 +92,16 @@
       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$OMP MASTER	
 C  Appel a histvert pour la grille verticale
 C
@@ -108,5 +109,5 @@
             nivsigs(l)=float(l)
          ENDDO
-	
+
 	write(*,*) 'avant histvert ds initphysto'
 
@@ -120,5 +121,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 +127,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 �rit ---> a �iminer ?
          CALL histdef(fileid, "dtime", "tps phys ", "s",
      .                1,1,nhoriid, 1,1,1, -99, 32,
@@ -141,5 +143,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 +149,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 +156,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 +163,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 +170,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 +177,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 +185,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 +191,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 +207,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 +218,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 +225,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 +233,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 +240,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 +247,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 +254,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 +261,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 +268,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 +275,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 +282,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 +289,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)
 	
@@ -295,5 +297,5 @@
 c     if (ok_sync) call histsync(fileid)
       if (ok_sync) call histsync
-
+c$OMP END MASTER
 	
 
Index: /LMDZ4/trunk/libf/phylmd/initrrnpb.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/initrrnpb.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/initrrnpb.F	(revision 766)
@@ -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/trunk/libf/phylmd/interface_surf.F90
===================================================================
--- /LMDZ4/trunk/libf/phylmd/interface_surf.F90	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/interface_surf.F90	(revision 766)
@@ -22,5 +22,5 @@
 ! L. Fairhead, LMD, 02/2000
 
-  USE ioipsl
+!ym  USE ioipsl
 
   IMPLICIT none
@@ -44,13 +44,21 @@
 ! run_off      ruissellement total
   REAL, ALLOCATABLE, DIMENSION(:),SAVE    :: run_off, run_off_lic
+!$OMP THREADPRIVATE(run_off, run_off_lic)
   real, allocatable, dimension(:),save    :: coastalflow, riverflow
+!$OMP THREADPRIVATE(coastalflow, riverflow)
 !!$PB
   REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: tmp_rriv, tmp_rcoa,tmp_rlic
+!$OMP THREADPRIVATE(tmp_rriv, tmp_rcoa,tmp_rlic)
 !! pour simuler la fonte des glaciers antarctiques
   REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: coeff_iceberg
+!$OMP THREADPRIVATE(coeff_iceberg)
   real, save                              :: surf_maille 
+!$OMP THREADPRIVATE(surf_maille)
   real, save                              :: cte_flux_iceberg = 6.3e7
+!$OMP THREADPRIVATE(cte_flux_iceberg)  
   integer, save                           :: num_antarctic = 1
+!$OMP THREADPRIVATE(num_antarctic)
   REAL, save                              :: tau_calv
+!$OMP THREADPRIVATE(tau_calv)
 !!$
   CONTAINS
@@ -75,9 +83,10 @@
       & evap, fluxsens, fluxlat, dflux_l, dflux_s, &              
       & tsol_rad, tsurf_new, alb_new, alblw, emis_new, &
-      & z0_new, pctsrf_new, agesno,fqcalving,ffonte, run_off_lic_0,&
+      & z0_new, pctsrf_new, agesno,fqcalving,fqfonte,ffonte, run_off_lic_0,&
 !IM "slab" ocean
       & flux_o, flux_g, tslab, seaice)
 
 
+   USE dimphy,only : monocpu,jjphy_nb,omp_rank
 ! 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.
@@ -189,8 +198,11 @@
   real, dimension(klon), intent(INOUT) :: tslab
   real, allocatable, dimension(:), save :: tmp_tslab
+!$OMP THREADPRIVATE(tmp_tslab)
   real, dimension(klon), intent(OUT) :: flux_o, flux_g
   real, dimension(klon), intent(INOUT)        :: seaice ! glace de mer (kg/m2)
   real, dimension(klon)                       :: siceh  ! hauteur glace de mer (m)
   REAL, DIMENSION(klon), INTENT(INOUT) :: radsol,fder
+  
+!  real, dimension(klon), intent(IN) :: zmasq
   real, dimension(klon), intent(IN) :: zmasq
   real, dimension(klon), intent(IN) :: taux, tauy, rugos, rugoro
@@ -221,8 +233,8 @@
 !jld a rajouter   real, dimension(klon), intent(INOUT):: ffonte
   real, dimension(klon), intent(INOUT):: ffonte
-! Flux d'eau "perdue" par la surface et nécessaire pour que limiter la
-! hauteur de neige, en kg/m2/s
-!jld a rajouter   real, dimension(klon), intent(INOUT):: fqcalving
-  real, dimension(klon), intent(INOUT):: fqcalving
+! Flux d'eau "perdue" par la surface et necessaire pour que limiter la
+! hauteur de neige, en kg/m2/s. Et quantite d'eau de fonte de la calotte.
+!jld a rajouter   real, dimension(klon), intent(INOUT):: fqcalving, fqfonte
+  REAL, DIMENSION(klon), INTENT(INOUT):: fqcalving, fqfonte
 !IM: "slab" ocean
   real, dimension(klon) :: new_dif_grnd 
@@ -232,15 +244,22 @@
   integer i
   real, allocatable, dimension(:), save :: tmp_flux_o, tmp_flux_g
+!$OMP THREADPRIVATE(tmp_flux_o, tmp_flux_g)  
   real, allocatable, dimension(:), save :: tmp_radsol
+!$OMP THREADPRIVATE(tmp_radsol)
   real, allocatable, dimension(:,:), save :: tmp_pctsrf_slab
+!$OMP THREADPRIVATE(tmp_pctsrf_slab)
   real, allocatable, dimension(:), save :: tmp_seaice
-
+!$OMP THREADPRIVATE(tmp_seaice)
 ! Local
   character (len = 20),save :: modname = 'interfsurf_hq'
+!$OMP THREADPRIVATE(modname)
   character (len = 80) :: abort_message 
   logical, save        :: first_call = .true.
+!$OMP THREADPRIVATE(first_call)  
   integer, save        :: error
+!$OMP THREADPRIVATE(error)  
   integer              :: ii, index
-  logical,save              :: check = .false.
+  logical,save              :: check = .true.
+!$OMP THREADPRIVATE(check)  
   real, dimension(klon):: cal, beta, dif_grnd, capsol
 !!$PB  real, parameter      :: calice=1.0/(5.1444e+06*0.15), tau_gl=86400.*5.
@@ -258,4 +277,6 @@
   real, dimension(klon):: fder_prev
   REAL, dimension(klon) :: bidule
+  real, dimension(klon) :: ps_tmp,p1lay_tmp
+  INTEGER :: j
 !
 !IM ?? quelques variables pour netcdf
@@ -295,8 +316,19 @@
 !      call abort_gcm(modname,abort_message,1)
 !    endif
+  endif
+  first_call = .false.
+  
+! Initialisations diverses
+!
+!!$  cal=0.; beta=1.; dif_grnd=0.; capsol=0.
+!!$  alb_new = 0.; z0_new = 0.; alb_neig = 0.0
+!!$! PB
+!!$  tsurf_new = 0.
 
 !IM cf JLD
   ffonte(1:knon)=0.
   fqcalving(1:knon)=0.
+  fqfonte  (1:knon)=0.
+
 
   cal = 999999. ; beta = 999999. ; dif_grnd = 999999. ; capsol = 999999.
@@ -368,14 +400,4 @@
      tmp_tslab(i)=tslab(i)
     ENDDO
-  endif
-  first_call = .false.
-  
-! Initialisations diverses
-!
-!!$  cal=0.; beta=1.; dif_grnd=0.; capsol=0.
-!!$  alb_new = 0.; z0_new = 0.; alb_neig = 0.0
-!!$! PB
-!!$  tsurf_new = 0.
-
 !
 ! Aiguillage vers les differents schemas de surface
@@ -407,23 +429,23 @@
 
 !!$PB
-      ALLOCATE (tmp_rriv(iim,jjm+1), stat=error)
+      ALLOCATE (tmp_rriv(iim,jjphy_nb), stat=error)
       if (error /= 0) then
         abort_message='Pb allocation tmp_rriv'
         call abort_gcm(modname,abort_message,1)
       endif
-      ALLOCATE (tmp_rcoa(iim,jjm+1), stat=error)
+      tmp_rriv=0.
+      ALLOCATE (tmp_rcoa(iim,jjphy_nb), stat=error)
       if (error /= 0) then
         abort_message='Pb allocation tmp_rcoa'
         call abort_gcm(modname,abort_message,1)
       endif
-      ALLOCATE (tmp_rlic(iim,jjm+1), stat=error)
+      tmp_rcoa=0.
+!ym      ALLOCATE (tmp_rlic(iim,jjm+1), stat=error)
+      ALLOCATE (tmp_rlic(iim,jjphy_nb), stat=error)
       if (error /= 0) then
         abort_message='Pb allocation tmp_rlic'
         call abort_gcm(modname,abort_message,1)
       endif
-      tmp_rriv = 0.0
-      tmp_rcoa = 0.0
-      tmp_rlic = 0.0
-
+      tmp_rlic=0.
 !!$
     else if (size(coastalflow) /= knon) then
@@ -449,6 +471,5 @@
      & alb_new, z0_new)
 !  
-! calcul snow et qsurf, hydrol adapté
-!
+! calcul snow et qsurf, hydrol adapte !
        CALL calbeta(dtime, nisurf, knon, snow, qsol, beta, capsol, dif_grnd)
 
@@ -474,5 +495,5 @@
      &   petAcoef, peqAcoef, petBcoef, peqBcoef, &
      &   tsurf_new, evap, fluxlat, fluxsens, dflux_s, dflux_l, &
-     &   fqcalving,ffonte, run_off_lic_0)
+     &   fqcalving,fqfonte,ffonte, run_off_lic_0)
 
 
@@ -491,5 +512,8 @@
 !
 #ifdef CPP_VEGET
-      call interfsol(itime, klon, dtime, date0, nisurf, knon, &
+      p1lay_tmp(1:knon)=p1lay(1:knon)/100.
+      ps_tmp(1:knon)=ps(1:knon)/100.
+ 
+       call interfsol(itime, klon, dtime, date0, nisurf, knon, &
      &  knindex, rlon, rlat, cufi, cvfi, iim, jjm, pctsrf, &
      &  debut, lafin, ok_veget, &
@@ -497,5 +521,5 @@
      &  tq_cdrag, petAcoef, peqAcoef, petBcoef, peqBcoef, &
      &  precip_rain, precip_snow, sollwdown, swnet, swdown, &
-     &  tsurf, p1lay/100., ps/100., radsol, &
+     &  tsurf, p1lay_tmp, ps_tmp, radsol, &
      &  evap, fluxsens, fluxlat, &              
      &  tsol_rad, tsurf_new, alb_new, alblw, &
@@ -779,5 +803,5 @@
              &   petAcoef, peqAcoef, petBcoef, peqBcoef, &
              &   tsurf_new, evap, fluxlat, fluxsens, dflux_s, dflux_l, &
-             &   fqcalving,ffonte, run_off_lic_0)
+             &   fqcalving,fqfonte,ffonte, run_off_lic_0)
 
 !     calcul albedo
@@ -893,5 +917,5 @@
 
     if (.not. allocated(run_off_lic)) then
-      allocate(run_off_lic(knon), stat = error)
+      allocate(run_off_lic(klon), stat = error)
       if (error /= 0) then
         abort_message='Pb allocation run_off_lic'
@@ -928,5 +952,5 @@
      &   petAcoef, peqAcoef, petBcoef, peqBcoef, &
      &   tsurf_new, evap, fluxlat, fluxsens, dflux_s, dflux_l, &
-     &   fqcalving,ffonte, run_off_lic_0)
+     &   fqcalving,fqfonte,ffonte, run_off_lic_0)
 
 ! passage du run-off des glaciers calcule dans fonte_neige au coupleur
@@ -1010,5 +1034,6 @@
 
   USE intersurf
-
+  USE dimphy, klon_x=>klon
+  IMPLICIT NONE
 ! Cette routine sert d'interface entre le modele atmospherique et le 
 ! modele de sol continental. Appel a sechiba
@@ -1128,6 +1153,5 @@
 ! offset pour calculer les point voisins
   integer, dimension(8,3), save :: off_ini
-  integer, dimension(8), save :: offset
-! Identifieurs des fichiers restart et histoire
+ ! Identifieurs des fichiers restart et histoire
   integer, save          :: rest_id, hist_id 
   integer, save          :: rest_id_stom, hist_id_stom
@@ -1145,9 +1169,12 @@
   integer, dimension(:), save, allocatable :: ig, jg
   integer :: indi, indj
-  integer, dimension(klon) :: ktindex
+  integer, save, allocatable,dimension(:) :: ktindex
   REAL, dimension(klon) :: bidule
 ! Essai cdrag
   real, dimension(klon) :: cdrag
-
+  integer :: jjb,jje,ijb,ije
+  INTEGER,SAVE :: offset
+  REAL, dimension(klon2) :: rlon_g,rlat_g
+  INTEGER, SAVE          :: orch_comm
 #include "temps.inc"
 #include "YOMCST.inc"
@@ -1157,9 +1184,10 @@
   if (check) write(lunout,*)'ok_veget = ',ok_veget
 
-  ktindex(:) = knindex(:) + iim - 1
-
+
+  
 ! initialisation
+  
   if (debut) then
-
+    ALLOCATE(ktindex(klon))
   IF ( .NOT. allocated(albedo_keep)) THEN
      ALLOCATE(albedo_keep(klon))
@@ -1184,41 +1212,5 @@
    ig(klon) = 1
    jg(klon) = jjm + 1
-!
-!  Initialisation des offset    
-!
-! offset bord ouest
-   off_ini(1,1) = - iim  ; off_ini(2,1) = - iim + 1; off_ini(3,1) = 1
-   off_ini(4,1) = iim + 1; off_ini(5,1) = iim      ; off_ini(6,1) = 2 * iim - 1
-   off_ini(7,1) = iim -1 ; off_ini(8,1) = - 1
-! offset point normal
-   off_ini(1,2) = - iim  ; off_ini(2,2) = - iim + 1; off_ini(3,2) = 1
-   off_ini(4,2) = iim + 1; off_ini(5,2) = iim      ; off_ini(6,2) = iim - 1
-   off_ini(7,2) = -1     ; off_ini(8,2) = - iim - 1
-! offset bord   est
-   off_ini(1,3) = - iim; off_ini(2,3) = - 2 * iim + 1; off_ini(3,3) = - iim + 1
-   off_ini(4,3) =  1   ; off_ini(5,3) = iim          ; off_ini(6,3) = iim - 1
-   off_ini(7,3) = -1   ; off_ini(8,3) = - iim - 1
-!
-! Initialisation des correspondances point -> indices i,j
-!
-    if (( .not. allocated(correspond))) then
-      allocate(correspond(iim,jjm+1), stat = error)
-      if (error /= 0) then
-        abort_message='Pb allocation correspond'
-        call abort_gcm(modname,abort_message,1)
-      endif      
-    endif
-!
-! Attention aux poles
-!
-    do igrid = 1, knon
-      index = ktindex(igrid)
-          jj = int((index - 1)/iim) + 1
-          ij = index - (jj - 1) * iim
-      correspond(ij,jj) = igrid
-    enddo
-
-! Allouer et initialiser le tableau de coordonnees du sol
-!
+
     if ((.not. allocated(lalo))) then
       allocate(lalo(knon,2), stat = error)
@@ -1248,33 +1240,27 @@
       lalo(igrid,2) = rlon(index)
       lalo(igrid,1) = rlat(index)
-      ij = index - int((index-1)/iim)*iim - 1
-      jj = 2 + int((index-1)/iim)
-      if (mod(index,iim) == 1 ) then
-        jj = 1 + int((index-1)/iim)
-        ij = iim
-      endif
-!      lon_scat(ij,jj) = rlon(index)
-!      lat_scat(ij,jj) = rlat(index)
+
     enddo
-    index = 1
-    do jj = 2, jjm
-      do ij = 1, iim
-        index = index + 1
-        lon_scat(ij,jj) = rlon(index)
-        lat_scat(ij,jj) = rlat(index)
+   
+
+    
+    Call GatherField(rlon,rlon_g,1)
+    Call GatherField(rlat,rlat_g,1)
+
+    IF (phy_rank==0) THEN
+      index = 1
+      do jj = 2, jjm
+        do ij = 1, iim
+          index = index + 1
+          lon_scat(ij,jj) = rlon_g(index)
+          lat_scat(ij,jj) = rlat_g(index)
+        enddo
       enddo
-    enddo
-    lon_scat(:,1) = lon_scat(:,2)
-    lat_scat(:,1) = rlat(1)
-    lon_scat(:,jjm+1) = lon_scat(:,2)
-    lat_scat(:,jjm+1) = rlat(klon)
-! Pb de correspondances de grilles!
-!    do igrid = 1, knon
-!      index = ktindex(igrid)
-!      ij = ig(index)
-!      jj = jg(index)
-!      lon_scat(ij,jj) = rlon(index)
-!      lat_scat(ij,jj) = rlat(index)
-!    enddo
+     lon_scat(:,1) = lon_scat(:,2)
+     lat_scat(:,1) = rlat_g(1)
+     lon_scat(:,jjm+1) = lon_scat(:,2)
+     lat_scat(:,jjm+1) = rlat_g(klon2)
+   ENDIF
+   
 
 !
@@ -1302,23 +1288,6 @@
     enddo
 
-    do igrid = 1, knon
-      iglob = ktindex(igrid)
-      if (mod(iglob, iim) == 1) then
-        offset = off_ini(:,1)
-      else if(mod(iglob, iim) == 0) then
-        offset = off_ini(:,3)
-      else
-        offset = off_ini(:,2)
-      endif 
-      do i = 1, 8
-        index = iglob + offset(i)
-        ireal = (min(max(1, index - iim + 1), klon))
-        if (pctsrf(ireal, is_ter) > EPSFRA) then
-          jj = int((index - 1)/iim) + 1
-          ij = index - (jj - 1) * iim
-            neighbours(igrid, i) = correspond(ij, jj)
-        endif
-      enddo
-    enddo
+
+   CALL Init_neighbours(iim,jjm,knon,neighbours,knindex,pctsrf(:,is_ter))
 
 !
@@ -1336,10 +1305,4 @@
       resolution(igrid,2) = cvfi(ij)
     enddo  
-!IM tester la resolution que recoit Orchidee
-    IF((maxval(resolution(:,2)) == 0.).OR. &
-   &   (maxval(resolution(:,1)) == 0.)) THEN
-     abort_message='STOP interfsol : resolution recue par Orchidee = 0.'
-     call abort_gcm(modname,abort_message,1)
-    ENDIF
 
   endif                          ! (fin debut) 
@@ -1374,15 +1337,32 @@
 ! Init Orchidee
 !
+!  if (pole_nord) then 
+!    offset=0
+!    ktindex(:)=ktindex(:)+iim-1
+!  else
+!    offset = klon_begin-1+iim-1
+!    ktindex(:)=ktindex(:)+MOD(offset,iim)
+!    offset=offset-MOD(offset,iim)
+!  endif
+  
+  PRINT *,'ORCHIDEE ------> KNON : ',knon
+  
+   
   if (debut) then
-    call intersurf_main (itime+itau_phy-1, iim, jjm+1, knon, ktindex, dtime, &
-     & lrestart_read, lrestart_write, lalo, &
-     & contfrac, neighbours, resolution, date0, &
-     & zlev,  u1_lay, v1_lay, spechum, temp_air, epot_air, ccanopy, &
-     & cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, &
-     & precip_rain, precip_snow, lwdown, swnet, swdown, ps, &
-     & evap, fluxsens, fluxlat, coastalflow, riverflow, &
-     & tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, &
-     & lon_scat, lat_scat)
-
+    CALL Get_orchidee_communicator(knon,orch_comm)
+    IF (knon /=0) THEN
+      CALL Init_orchidee_index(iim,knon,orch_comm,knindex,offset,ktindex)
+    
+      call intersurf_main (itime+itau_phy-1, iim, jjm+1,offset, knon, ktindex, & 
+       & orch_comm,dtime, lrestart_read, lrestart_write, lalo, &
+       & contfrac, neighbours, resolution, date0, &
+       & zlev,  u1_lay, v1_lay, spechum, temp_air, epot_air, ccanopy, &
+       & cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, &
+       & precip_rain, precip_snow, lwdown, swnet, swdown, ps, &
+       & evap, fluxsens, fluxlat, coastalflow, riverflow, &
+       & tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, &
+       & lon_scat, lat_scat)
+
+     ENDIF
 !IM cf. JP +++
     albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2.
@@ -1392,19 +1372,21 @@
 
 !IM cf. JP +++
-!IM swdown_vrai(1:knon) = swnet(1:knon)/(1. - albedo_keep(1:knon))
-!IM modification faite dans clmain
-    swdown_vrai(1:knon) = swdown(1:knon)
+!  swdown_vrai(1:knon) = swnet(1:knon)/(1. - albedo_keep(1:knon))
+  swdown_vrai(1:knon) = swdown(1:knon)
+
 !IM cf. JP ---
-
-  call intersurf_main (itime+itau_phy, iim, jjm+1, knon, ktindex, dtime, &
-     & lrestart_read, lrestart_write, lalo, &
-     & contfrac, neighbours, resolution, date0, &
-     & zlev,  u1_lay, v1_lay, spechum, temp_air, epot_air, ccanopy, &
-     & cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, &
-     & precip_rain, precip_snow, lwdown, swnet, swdown_vrai, ps, &
-     & evap, fluxsens, fluxlat, coastalflow, riverflow, &
-     & tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, &
-     & lon_scat, lat_scat)
-
+    IF (knon /=0) THEN
+    
+      call intersurf_main (itime+itau_phy, iim, jjm+1,offset, knon, ktindex, & 
+       & orch_comm,dtime, lrestart_read, lrestart_write, lalo, &
+       & contfrac, neighbours, resolution, date0, &
+       & zlev,  u1_lay, v1_lay, spechum, temp_air, epot_air, ccanopy, &
+       & cdrag, petA_orc, peqA_orc, petB_orc, peqB_orc, &
+       & precip_rain, precip_snow, lwdown, swnet, swdown_vrai, ps, &
+       & evap, fluxsens, fluxlat, coastalflow, riverflow, &
+       & tsol_rad, tsurf_new, qsurf, albedo_out, emis_new, z0_new, &
+       & lon_scat, lat_scat)
+
+    ENDIF
 !IM cf. JP +++
     albedo_keep(1:knon) = (albedo_out(1:knon,1)+albedo_out(1:knon,2))/2.
@@ -1413,8 +1395,8 @@
     bidule=0.
     bidule(1:knon)=riverflow(1:knon)
-    call gath2cpl(bidule, tmp_rriv, klon, knon,iim,jjm,knindex)
+    call gath2cpl(bidule, tmp_rriv, klon, knon,iim,jjphy_nb,knindex)
     bidule=0.
     bidule(1:knon)=coastalflow(1:knon)
-    call gath2cpl(bidule, tmp_rcoa, klon, knon,iim,jjm,knindex)
+    call gath2cpl(bidule, tmp_rcoa, klon, knon,iim,jjphy_nb,knindex)
     alb_new(1:knon) = albedo_out(1:knon,1) 
     alblw(1:knon) = albedo_out(1:knon,2)
@@ -1430,4 +1412,217 @@
 
   END SUBROUTINE interfsol
+  
+  SUBROUTINE Init_orchidee_index(iim,knon,orch_comm,knindex,offset,ktindex)
+  USE dimphy
+  IMPLICIT NONE
+    INTEGER,INTENT(IN)  :: iim
+    INTEGER,INTENT(IN)  :: knon
+    INTEGER,INTENT(IN)  :: orch_comm
+    INTEGER,INTENT(IN)  :: knindex(knon)
+    INTEGER,INTENT(OUT) :: offset
+    INTEGER,INTENT(OUT) :: ktindex(knon)
+
+#ifdef CPP_PARA
+    INCLUDE 'mpif.h'
+    INTEGER :: status(MPI_STATUS_SIZE)
+#endif
+    INTEGER :: MyLastPoint
+    INTEGER :: LastPoint
+    INTEGER :: mpi_rank
+    INTEGER :: mpi_size
+    INTEGER :: ierr   
+    
+    MyLastPoint=klon_begin-1+knindex(knon)+iim-1
+
+    IF (.NOT. monocpu) THEN
+#ifdef CPP_PARA    
+      call MPI_COMM_SIZE(orch_comm,mpi_size,ierr)
+      call MPI_COMM_RANK(orch_comm,mpi_rank,ierr)
+#endif
+    ELSE
+      mpi_rank=0
+      mpi_size=1
+    ENDIF
+    
+    IF (.NOT. monocpu) THEN
+      IF (mpi_rank /= 0) then
+#ifdef CPP_PARA
+        CALL MPI_RECV(LastPoint,1,MPI_INTEGER,mpi_rank-1,1234,orch_comm,status,ierr)
+#endif
+      ENDIF
+        
+      IF (mpi_rank /= mpi_size-1) THEN
+#ifdef CPP_PARA
+        CALL MPI_SEND(MyLastPoint,1,MPI_INTEGER,mpi_rank+1,1234,orch_comm,ierr)  
+#endif
+      ENDIF
+    ENDIF
+    
+    IF (mpi_rank==0) THEN 
+      offset=0
+    ELSE
+     offset=LastPoint-MOD(LastPoint,iim)
+    ENDIF
+     
+    ktindex(:)=knindex(:)+(klon_begin+iim-1)-offset-1	
+    
+
+   END SUBROUTINE  Init_orchidee_index 
+
+  
+  SUBROUTINE Get_orchidee_communicator(knon,orch_comm)
+  USE dimphy, only : phy_rank
+#ifdef CPP_PARA
+  USE parallel, only : COMM_LMDZ
+#endif
+  IMPLICIT NONE
+#ifdef CPP_PARA
+    include 'mpif.h'
+#endif    
+    INTEGER,INTENT(IN)  :: knon
+    INTEGER,INTENT(OUT) :: orch_comm
+    
+    INTEGER :: color
+    INTEGER :: ierr
+    
+    IF (knon==0) THEN 
+      color = 0
+    ELSE 
+      color = 1
+    ENDIF
+
+#ifdef CPP_PARA    
+    CALL MPI_COMM_SPLIT(COMM_LMDZ,color,phy_rank,orch_comm,ierr)
+#endif
+    
+  END SUBROUTINE Get_orchidee_communicator 
+    
+    
+  SUBROUTINE Init_neighbours(iim,jjm,knon,neighbours,ktindex,pctsrf)
+#ifdef CPP_PARA
+  USE parallel,only : COMM_LMDZ
+#endif
+  USE dimphy
+  IMPLICIT NONE
+#ifdef CPP_PARA
+  include 'mpif.h'
+#endif
+  INTEGER :: iim,jjm
+  INTEGER :: knon
+  INTEGER :: neighbours(knon,8)
+  INTEGER :: ktindex(knon)
+  REAL :: pctsrf(klon)
+  
+  INTEGER :: knon_nb(0:phy_size-1)
+  INTEGER,DIMENSION(0:phy_size-1) :: displs,sendcount
+  INTEGER,ALLOCATABLE :: ktindex_g(:)
+  REAL*8  :: pctsrf_g(klon2)
+  INTEGER,ALLOCATABLE ::neighbours_g(:,:)
+  INTEGER :: knon_g
+  REAL*8 :: correspond(iim,jjm+1)
+  INTEGER :: i,igrid,jj,ij,iglob,ierr,ireal,index
+  integer, dimension(8,3) :: off_ini
+  integer, dimension(8)   :: offset  
+  INTEGER :: ktindex_p(knon)
+
+  IF (monocpu) THEN
+    knon_nb(:)=knon
+  ELSE  
+
+#ifdef CPP_PARA  
+    CALL MPI_GATHER(knon,1,MPI_INTEGER,knon_nb,1,MPI_INTEGER,0,COMM_LMDZ,ierr)
+#endif
+  
+  ENDIF
+    
+  IF (phy_rank==0) THEN
+    knon_g=sum(knon_nb(:))
+    ALLOCATE(ktindex_g(knon_g))
+    ALLOCATE(neighbours_g(knon_g,8))
+    neighbours_g(:,:)=-1
+    displs(0)=0
+    DO i=1,phy_size-1
+      displs(i)=displs(i-1)+knon_nb(i-1)
+    ENDDO  
+  ENDIF
+  
+  ktindex_p(:)=ktindex(:)+klon_begin-1+iim-1
+
+  IF (monocpu) THEN
+    ktindex_g(:)=ktindex_p(:)
+  ELSE
+
+#ifdef CPP_PARA  
+    CALL MPI_GATHERV(ktindex_p,knon,MPI_INTEGER,ktindex_g,knon_nb,displs,MPI_INTEGER,0,COMM_LMDZ,ierr)
+#endif
+
+  ENDIF
+     
+  CALL GatherField(pctsrf,pctsrf_g,1)
+  
+  IF (phy_rank==0) THEN
+!  Initialisation des offset    
+!
+! offset bord ouest
+   off_ini(1,1) = - iim  ; off_ini(2,1) = - iim + 1; off_ini(3,1) = 1
+   off_ini(4,1) = iim + 1; off_ini(5,1) = iim      ; off_ini(6,1) = 2 * iim - 1
+   off_ini(7,1) = iim -1 ; off_ini(8,1) = - 1
+! offset point normal
+   off_ini(1,2) = - iim  ; off_ini(2,2) = - iim + 1; off_ini(3,2) = 1
+   off_ini(4,2) = iim + 1; off_ini(5,2) = iim      ; off_ini(6,2) = iim - 1
+   off_ini(7,2) = -1     ; off_ini(8,2) = - iim - 1
+! offset bord   est
+   off_ini(1,3) = - iim; off_ini(2,3) = - 2 * iim + 1; off_ini(3,3) = - iim + 1
+   off_ini(4,3) =  1   ; off_ini(5,3) = iim          ; off_ini(6,3) = iim - 1
+   off_ini(7,3) = -1   ; off_ini(8,3) = - iim - 1
+!
+!
+! Attention aux poles
+!
+    do igrid = 1, knon_g
+      index = ktindex_g(igrid)
+          jj = int((index - 1)/iim) + 1
+          ij = index - (jj - 1) * iim
+      correspond(ij,jj) = igrid
+    enddo
+
+    do igrid = 1, knon_g
+      iglob = ktindex_g(igrid)
+      if (mod(iglob, iim) == 1) then
+        offset = off_ini(:,1)
+      else if(mod(iglob, iim) == 0) then
+        offset = off_ini(:,3)
+      else
+        offset = off_ini(:,2)
+      endif 
+      do i = 1, 8
+        index = iglob + offset(i)
+        ireal = (min(max(1, index - iim + 1), klon2))
+        if (pctsrf_g(ireal) > EPSFRA) then
+          jj = int((index - 1)/iim) + 1
+          ij = index - (jj - 1) * iim
+            neighbours_g(igrid, i) = correspond(ij, jj)
+        endif
+      enddo
+    enddo
+
+!    DO i=0,phy_size-1
+!      displs(i)=displs(i)*8
+!      sendcount(i)=knon_nb(i)*8
+!    ENDDO
+  
+  ENDIF
+  
+  DO i=1,8
+    IF (monocpu) THEN
+      neighbours(:,i)=neighbours_g(:,i)
+    ELSE
+#ifdef CPP_PARA
+    CALL MPI_SCATTERV(neighbours_g(:,i),knon_nb,displs,MPI_INTEGER,neighbours(:,i),knon,MPI_INTEGER,0,COMM_LMDZ,ierr) 
+#endif
+    ENDIF
+  ENDDO
+  
+  END SUBROUTINE Init_neighbours
 #endif
 !
@@ -1446,4 +1641,17 @@
       & pctsrf_new)
 
+   USE ioipsl
+   USE dimphy, only : jjphy_nb, iiphy_begin,iiphy_end,phy_rank,phy_size, monocpu
+   USE iophy
+#ifdef CPP_PARA
+   USE parallel, only: pole_nord,pole_sud,COMM_LMDZ
+#endif
+#ifdef CPP_PSMILE
+   USE oasis
+#endif
+   USE write_field_phy
+   implicit none
+#include "indicesol.inc"
+#include "YOMCST.inc"
 ! Cette routine sert d'interface entre le modele atmospherique et un 
 ! coupleur avec un modele d'ocean 'complet' derriere
@@ -1500,8 +1708,5 @@
 !   alb_ice      albedo de la glace
 !
-#ifdef CPP_PSMILE  
-  USE oasis
-  integer :: il_time_secs !time in seconds
-#endif
+
 
 ! Parametres d'entree
@@ -1561,14 +1766,21 @@
   REAL, ALLOCATABLE, DIMENSION(:,:,:),SAVE :: tmp_tauy
 ! variables a passer au coupleur
-  real, dimension(iim, jjm+1) :: wri_sol_ice, wri_sol_sea, wri_nsol_ice 
-  real, dimension(iim, jjm+1) :: wri_nsol_sea, wri_fder_ice, wri_evap_ice
-  REAL, DIMENSION(iim, jjm+1) :: wri_evap_sea, wri_rcoa, wri_rriv
-  REAL, DIMENSION(iim, jjm+1) :: wri_rain, wri_snow, wri_taux, wri_tauy
-! -- LOOP
-   REAL, DIMENSION(iim, jjm+1) :: wri_windsp
-! -- LOOP
-  REAL, DIMENSION(iim, jjm+1) :: wri_calv
-  REAL, DIMENSION(iim, jjm+1) :: wri_tauxx, wri_tauyy, wri_tauzz
-  REAL, DIMENSION(iim, jjm+1) :: tmp_lon, tmp_lat
+!ym  real, dimension(iim, jjm+1) :: wri_sol_ice, wri_sol_sea, wri_nsol_ice 
+!ym  real, dimension(iim, jjm+1) :: wri_nsol_sea, wri_fder_ice, wri_evap_ice
+!ym  REAL, DIMENSION(iim, jjm+1) :: wri_evap_sea, wri_rcoa, wri_rriv
+!ym  REAL, DIMENSION(iim, jjm+1) :: wri_rain, wri_snow, wri_taux, wri_tauy
+!ym  REAL, DIMENSION(iim, jjm+1) :: wri_calv
+!ym  REAL, DIMENSION(iim, jjm+1) :: wri_tauxx, wri_tauyy, wri_tauzz
+!ym  REAL, DIMENSION(iim, jjm+1) :: tmp_lon, tmp_lat
+
+  real, dimension(iim, jjphy_nb) :: wri_sol_ice, wri_sol_sea, wri_nsol_ice 
+  real, dimension(iim, jjphy_nb) :: wri_nsol_sea, wri_fder_ice, wri_evap_ice
+  REAL, DIMENSION(iim, jjphy_nb) :: wri_evap_sea, wri_rcoa, wri_rriv
+  REAL, DIMENSION(iim, jjphy_nb) :: wri_rain, wri_snow, wri_taux, wri_tauy
+  REAL, DIMENSION(iim, jjphy_nb) :: wri_calv
+  REAL, DIMENSION(iim, jjphy_nb) :: wri_tauxx, wri_tauyy, wri_tauzz
+  REAL, DIMENSION(iim, jjphy_nb) :: tmp_lon, tmp_lat
+  REAL, DIMENSION(iim, jjphy_nb) :: wri_windsp
+
 ! variables relues par le coupleur
 ! read_sic = fraction de glace
@@ -1581,8 +1793,8 @@
 ! l'avoir lu
   real, allocatable,dimension(:,:),save :: pctsrf_sav
-  real, dimension(iim, jjm+1, 2) :: tamp_srf
+  real, dimension(iim, jjphy_nb, 3) :: tamp_srf
   integer, allocatable, dimension(:), save :: tamp_ind
   real, allocatable, dimension(:,:),save :: tamp_zmasq
-  real, dimension(iim, jjm+1) :: deno
+  real, dimension(iim, jjphy_nb) :: deno
   integer                     :: idtime
   integer, allocatable,dimension(:),save :: unity
@@ -1603,8 +1815,20 @@
   integer :: nb_interf_cpl
 ! -- LOOP
+
+  real :: Up,Down
+  integer :: ierr
+  integer :: il_time_secs
+  real :: tmp_field(klon)
+  
 #include "param_cou.h"
 #include "inc_cpl.h"
 #include "temps.inc"
 #include "iniprint.h"
+
+#ifdef CPP_PARA
+  include 'mpif.h'
+  integer :: status(MPI_STATUS_SIZE)
+#endif
+
 !
 ! Initialisation
@@ -1643,13 +1867,25 @@
 ! -- LOOP
     allocate(cpl_tauy(klon,2), stat = error); sum_error = sum_error + error
-    ALLOCATE(cpl_rriv(iim,jjm+1), stat=error); sum_error = sum_error + error
-    ALLOCATE(cpl_rcoa(iim,jjm+1), stat=error); sum_error = sum_error + error
-    ALLOCATE(cpl_rlic(iim,jjm+1), stat=error); sum_error = sum_error + error
+!ym    ALLOCATE(cpl_rriv(iim,jjm+1), stat=error); sum_error = sum_error + error
+!ym    ALLOCATE(cpl_rcoa(iim,jjm+1), stat=error); sum_error = sum_error + error
+!ym    ALLOCATE(cpl_rlic(iim,jjm+1), stat=error); sum_error = sum_error + error
+    ALLOCATE(cpl_rriv(iim,jjphy_nb), stat=error); sum_error = sum_error + error
+    ALLOCATE(cpl_rcoa(iim,jjphy_nb), stat=error); sum_error = sum_error + error
+    ALLOCATE(cpl_rlic(iim,jjphy_nb), stat=error); sum_error = sum_error + error
+
+
 !!
-    allocate(read_sst(iim, jjm+1), stat = error); sum_error = sum_error + error
-    allocate(read_sic(iim, jjm+1), stat = error); sum_error = sum_error + error
-    allocate(read_sit(iim, jjm+1), stat = error); sum_error = sum_error + error
-    allocate(read_alb_sic(iim, jjm+1), stat = error); sum_error = sum_error + error
-
+!ym    allocate(read_sst(iim, jjm+1), stat = error); sum_error = sum_error + error
+!ym    allocate(read_sic(iim, jjm+1), stat = error); sum_error = sum_error + error
+!ym    allocate(read_sit(iim, jjm+1), stat = error); sum_error = sum_error + error
+!ym    allocate(read_alb_sic(iim, jjm+1), stat = error); sum_error = sum_error + error
+    allocate(read_sst(iim, jjphy_nb), stat = error); sum_error = sum_error + error
+    allocate(read_sic(iim, jjphy_nb), stat = error); sum_error = sum_error + error
+    allocate(read_sit(iim, jjphy_nb), stat = error); sum_error = sum_error + error
+    allocate(read_alb_sic(iim, jjphy_nb), stat = error); sum_error = sum_error + error
+    read_sst=0.
+    read_sic=0.
+    read_sit=0.
+    read_alb_sic=0.
     if (sum_error /= 0) then
       abort_message='Pb allocation variables couplees'
@@ -1665,9 +1901,12 @@
     sum_error = 0
     allocate(tamp_ind(klon), stat = error); sum_error = sum_error + error
-    allocate(tamp_zmasq(iim, jjm+1), stat = error); sum_error = sum_error + error    
+!ym    allocate(tamp_zmasq(iim, jjm+1), stat = error); sum_error = sum_error + error    
+    allocate(tamp_zmasq(iim, jjphy_nb), stat = error); sum_error = sum_error + error    
+    tamp_zmasq=1.
+    
     do ig = 1, klon
       tamp_ind(ig) = ig
     enddo
-    call gath2cpl(zmasq, tamp_zmasq, klon, klon, iim, jjm, tamp_ind)
+    call gath2cpl(zmasq, tamp_zmasq, klon, klon, iim, jjphy_nb, tamp_ind)
 !
 ! initialisation couplage
@@ -1676,6 +1915,10 @@
 #ifdef CPP_COUPLE
 #ifdef CPP_PSMILE
-    CALL inicma(iim, (jjm+1))
+   CALL inicma(iim, (jjm+1))
 #else
+   if (.not. monocpu) then
+      abort_message='coupleur parallele uniquement avec PSMILE'
+      call abort_gcm(modname,abort_message,1)
+   endif
    call inicma(npas , nexca, idtime,(jjm+1)*iim)
 #endif
@@ -1684,4 +1927,6 @@
 ! initialisation sorties netcdf
 !
+ !ym  IO de check deconnecte pour le moment en //
+    IF (monocpu) THEN
     idayref = day_ini
     CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
@@ -1722,16 +1967,20 @@
     CALL histsync(nidcs)
 
+    ENDIF    ! monocpu
+    
 ! pour simuler la fonte des glaciers antarctiques
 ! 
-    surf_maille = (4. * rpi * ra**2) / (iim * (jjm +1))
-    ALLOCATE(coeff_iceberg(iim,jjm+1), stat=error)
-    if (error /= 0) then
-      abort_message='Pb allocation variable coeff_iceberg'
-      call abort_gcm(modname,abort_message,1)
-    endif
-    open (12,file='flux_iceberg',form='formatted',status='old')
-    read (12,*) coeff_iceberg
-    close (12)
-    num_antarctic = max(1, count(coeff_iceberg > 0))
+!ym => pour le moment, c'est en commentaire, donc je squizze
+
+!ym    surf_maille = (4. * rpi * ra**2) / (iim * (jjm +1))
+!ym    ALLOCATE(coeff_iceberg(iim,jjm+1), stat=error)
+!ym    if (error /= 0) then
+!ym      abort_message='Pb allocation variable coeff_iceberg'
+!ym      call abort_gcm(modname,abort_message,1)
+!ym    endif
+!ym    open (12,file='flux_iceberg',form='formatted',status='old')
+!ym    read (12,*) coeff_iceberg
+!ym    close (12)
+!ym    num_antarctic = max(1, count(coeff_iceberg > 0))
     
     first_appel = .false.
@@ -1800,7 +2049,12 @@
 #ifdef CPP_PSMILE
       il_time_secs=(itime-1)*dtime
-      CALL fromcpl(il_time_secs, iim, (jjm+1),                           &
+      CALL fromcpl(il_time_secs, iim, jjphy_nb,                           &
      &        read_sst, read_sic, read_sit, read_alb_sic)
 #else
+     if (.not. monocpu) then
+        abort_message='coupleur parallele uniquement avec PSMILE'
+        call abort_gcm(modname,abort_message,1)
+     endif
+
       call fromcpl(itime-1,(jjm+1)*iim,                                  &
      &        read_sst, read_sic, read_sit, read_alb_sic)
@@ -1810,15 +2064,18 @@
 ! sorties NETCDF des champs recus
 !
-      ndexcs(:)=0
-      itau_w = itau_phy + itime
-      CALL histwrite(nidcs,cl_read(1),itau_w,read_sst,iim*(jjm+1),ndexcs)
-      CALL histwrite(nidcs,cl_read(2),itau_w,read_sic,iim*(jjm+1),ndexcs)
-      CALL histwrite(nidcs,cl_read(3),itau_w,read_alb_sic,iim*(jjm+1),ndexcs)
-      CALL histwrite(nidcs,cl_read(4),itau_w,read_sit,iim*(jjm+1),ndexcs)
-      CALL histsync(nidcs)
+     if (monocpu) THEN
+       ndexcs(:)=0
+       itau_w = itau_phy + itime
+       CALL histwrite(nidcs,cl_read(1),itau_w,read_sst,iim*(jjm+1),ndexcs)
+       CALL histwrite(nidcs,cl_read(2),itau_w,read_sic,iim*(jjm+1),ndexcs)
+       CALL histwrite(nidcs,cl_read(3),itau_w,read_alb_sic,iim*(jjm+1),ndexcs)
+       CALL histwrite(nidcs,cl_read(4),itau_w,read_sit,iim*(jjm+1),ndexcs)
+       CALL histsync(nidcs)
+     endif
 ! pas utile      IF (npas-itime.LT.nexca )CALL histclo(nidcs)
 
-      do j = 1, jjm + 1
-        do ig = 1, iim
+!ym      do j = 1, jjm + 1
+       do j = 1, jjphy_nb
+         do ig = 1, iim
           if (abs(1. - read_sic(ig,j)) < 0.00001) then
             read_sst(ig,j) = RTT - 1.8
@@ -1839,5 +2096,5 @@
 ! transformer read_sic en pctsrf_sav
 !
-      call cpl2gath(read_sic, tamp_sic , klon, klon,iim,jjm, unity)
+      call cpl2gath(read_sic, tamp_sic , klon, klon,iim,jjphy_nb, unity)
       do ig = 1, klon
         IF (pctsrf(ig,is_oce) > epsfra .OR.            &
@@ -1882,16 +2139,16 @@
     if (nisurf == is_oce .and. (.not. cumul) ) then
       sum_error = 0
-      allocate(tmp_sols(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-      allocate(tmp_nsol(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-      allocate(tmp_rain(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-      allocate(tmp_snow(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-      allocate(tmp_evap(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-      allocate(tmp_tsol(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-      allocate(tmp_fder(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-      allocate(tmp_albe(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-      allocate(tmp_taux(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-      allocate(tmp_tauy(iim,jjm+1,2), stat=error); sum_error = sum_error + error
-! -- LOOP
-       allocate(tmp_windsp(iim,jjm+1,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_sols(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_nsol(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_rain(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_snow(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_evap(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_tsol(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_fder(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_albe(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_taux(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+      allocate(tmp_tauy(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
+! -- LOOP
+       allocate(tmp_windsp(iim,jjphy_nb,2), stat=error); sum_error = sum_error + error
 ! -- LOOP
 !!$      allocate(tmp_rriv(iim,jjm+1,2), stat=error); sum_error = sum_error + error
@@ -1908,17 +2165,17 @@
     cpl_index = 1
     if (nisurf == is_sic) cpl_index = 2
-    call gath2cpl(cpl_sols(1,cpl_index), tmp_sols(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
-    call gath2cpl(cpl_nsol(1,cpl_index), tmp_nsol(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
-    call gath2cpl(cpl_rain(1,cpl_index), tmp_rain(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
-    call gath2cpl(cpl_snow(1,cpl_index), tmp_snow(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
-    call gath2cpl(cpl_evap(1,cpl_index), tmp_evap(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
-    call gath2cpl(cpl_tsol(1,cpl_index), tmp_tsol(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
-    call gath2cpl(cpl_fder(1,cpl_index), tmp_fder(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
-    call gath2cpl(cpl_albe(1,cpl_index), tmp_albe(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
-    call gath2cpl(cpl_taux(1,cpl_index), tmp_taux(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
-! -- LOOP
-     call gath2cpl(cpl_windsp(1,cpl_index), tmp_windsp(1,1,cpl_index), klon, knon,iim,jjm,             knindex)
-! -- LOOP
-    call gath2cpl(cpl_tauy(1,cpl_index), tmp_tauy(1,1,cpl_index), klon, knon,iim,jjm,                  knindex)
+    call gath2cpl(cpl_sols(1,cpl_index), tmp_sols(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+    call gath2cpl(cpl_nsol(1,cpl_index), tmp_nsol(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+    call gath2cpl(cpl_rain(1,cpl_index), tmp_rain(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+    call gath2cpl(cpl_snow(1,cpl_index), tmp_snow(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+    call gath2cpl(cpl_evap(1,cpl_index), tmp_evap(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+    call gath2cpl(cpl_tsol(1,cpl_index), tmp_tsol(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+    call gath2cpl(cpl_fder(1,cpl_index), tmp_fder(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+    call gath2cpl(cpl_albe(1,cpl_index), tmp_albe(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+    call gath2cpl(cpl_taux(1,cpl_index), tmp_taux(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+    call gath2cpl(cpl_tauy(1,cpl_index), tmp_tauy(1,1,cpl_index), klon, knon,iim,jjphy_nb,                  knindex)
+! -- LOOP
+     call gath2cpl(cpl_windsp(1,cpl_index), tmp_windsp(1,1,cpl_index), klon, knon,iim,jjphy_nb,            knindex)
+! -- LOOP
 
 !
@@ -1931,6 +2188,6 @@
        wri_windsp = 0.
 ! -- LOOP      
-      call gath2cpl(pctsrf(1,is_oce), tamp_srf(1,1,1), klon, klon, iim, jjm, tamp_ind)
-      call gath2cpl(pctsrf(1,is_sic), tamp_srf(1,1,2), klon, klon, iim, jjm, tamp_ind)
+      call gath2cpl(pctsrf(1,is_oce), tamp_srf(1,1,1), klon, klon, iim, jjphy_nb, tamp_ind)
+      call gath2cpl(pctsrf(1,is_sic), tamp_srf(1,1,2), klon, klon, iim, jjphy_nb, tamp_ind)
 
       wri_sol_ice = tmp_sols(:,:,2)
@@ -1948,8 +2205,52 @@
       wri_rriv = cpl_rriv(:,:)
       wri_rcoa = cpl_rcoa(:,:)
-      DO j = 1, jjm + 1
-        wri_calv(:,j) = sum(cpl_rlic(:,j)) / iim
-      enddo
-
+
+!ym  !! ATTENTION ICI
+      
+!ym      DO j = 1, jjm + 1
+!ym        wri_calv(:,j) = sum(cpl_rlic(:,j)) / iim
+!ym      enddo
+
+!Essai OM+JLD : ca marche !!!! (17 mars 2006)
+      tamp_srf(:,:,3)=0.
+      CALL gath2cpl( pctsrf(1,is_lic), tamp_srf(1,1,3), klon, klon, iim, jjphy_nb, tamp_ind)
+
+!YM pour retrouver resultat avant tamp_srf(:,3)=1.
+      
+      DO j = 1, jjphy_nb
+         wri_calv(:,j) = DOT_PRODUCT (cpl_rlic(1:iim,j), tamp_srf(1:iim,j,3)) / REAL(iim)
+      ENDDO
+
+!ym      wri_calv(:,:)=0.
+!ym      DO j = 1, jjphy_nb
+!ym        wri_calv(:,j) = sum(cpl_rlic(:,j))/iim
+!ym      enddo
+
+      IF (.NOT. monocpu) THEN
+        if (phy_rank /= 0) then
+#ifdef CPP_PARA
+          call MPI_RECV(Up,1,MPI_REAL8,phy_rank-1,1234,COMM_LMDZ,status,ierr)
+          call MPI_SEND(wri_calv(1,1),1,MPI_REAL8,phy_rank-1,1234,COMM_LMDZ,ierr)
+#endif
+        endif
+        
+        if (phy_rank /= phy_size-1) then
+#ifdef CPP_PARA
+          call MPI_SEND(wri_calv(1,jjphy_nb),1,MPI_REAL8,phy_rank+1,1234,COMM_LMDZ,ierr)  
+          call MPI_RECV(down,1,MPI_REAL8,phy_rank+1,1234,COMM_LMDZ,status,ierr)
+#endif
+        endif
+  	
+        if (phy_rank /=0 .and. iiphy_begin /=1) then
+          Up=Up+wri_calv(iim,1)
+	  wri_calv(:,1)=Up
+        endif
+      
+        if (phy_rank /=phy_size-1 .and. iiphy_end /= iim) then
+          Down=Down+wri_calv(1,jjphy_nb)
+	  wri_calv(:,jjphy_nb)=Down	 
+        endif
+      ENDIF
+      
       where (tamp_zmasq /= 1.)
         deno =  tamp_srf(:,:,1) + tamp_srf(:,:,2)
@@ -1970,27 +2271,32 @@
 !      wri_calv = coeff_iceberg * cte_flux_iceberg / (num_antarctic * surf_maille)
 !
-! on passe les coordonnées de la grille
-!
-
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlon,tmp_lon)
-      CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlat,tmp_lat)
-
-      DO i = 1, iim
-        tmp_lon(i,1) = rlon(i+1)
-        tmp_lon(i,jjm + 1) = rlon(i+1)
-      ENDDO
+! on passe les coordonnees de la grille
+!
+
+!ym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlon,tmp_lon)
+!ym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,rlat,tmp_lat)
+
+      CALL phy2dyn(rlon,tmp_lon,1)
+      CALL phy2dyn(rlat,tmp_lat,1)
+      
+!ym      DO i = 1, iim
+!ym        tmp_lon(i,1) = rlon(i+1)
+!ym        tmp_lon(i,jjm + 1) = rlon(i+1)
+!ym      ENDDO
+
 !
 ! sortie netcdf des champs pour le changement de repere
 !
-      ndexct(:)=0
-      CALL histwrite(nidct,'tauxe',itau_w,wri_taux,iim*(jjm+1),ndexct)
-      CALL histwrite(nidct,'tauyn',itau_w,wri_tauy,iim*(jjm+1),ndexct)
-      CALL histwrite(nidct,'tmp_lon',itau_w,tmp_lon,iim*(jjm+1),ndexct)
-      CALL histwrite(nidct,'tmp_lat',itau_w,tmp_lat,iim*(jjm+1),ndexct)
-
-!
-! calcul 3 coordonnées du vent
-!
-      CALL atm2geo (iim , jjm + 1, wri_taux, wri_tauy, tmp_lon, tmp_lat, &
+      IF (monocpu) THEN
+        ndexct(:)=0
+        CALL histwrite(nidct,'tauxe',itau_w,wri_taux,iim*(jjm+1),ndexct)
+        CALL histwrite(nidct,'tauyn',itau_w,wri_tauy,iim*(jjm+1),ndexct)
+        CALL histwrite(nidct,'tmp_lon',itau_w,tmp_lon,iim*(jjm+1),ndexct)
+        CALL histwrite(nidct,'tmp_lat',itau_w,tmp_lat,iim*(jjm+1),ndexct)
+      ENDIF  
+!
+! calcul 3 coordonnees du vent
+!
+      CALL atm2geo (iim , jjphy_nb, wri_taux, wri_tauy, tmp_lon, tmp_lat, &
          & wri_tauxx, wri_tauyy, wri_tauzz )
 !
@@ -1998,4 +2304,5 @@
 ! envoi au coupleur
 !
+    IF (monocpu) THEN
       CALL histwrite(nidct,cl_writ(8),itau_w,wri_sol_ice,iim*(jjm+1),ndexct)
       CALL histwrite(nidct,cl_writ(9),itau_w,wri_sol_sea,iim*(jjm+1),ndexct)
@@ -2020,9 +2327,10 @@
 ! -- LOOP
       CALL histsync(nidct)
+    ENDIF
 ! pas utile      IF (lafin) CALL histclo(nidct)
 #ifdef CPP_COUPLE
 #ifdef CPP_PSMILE
       il_time_secs=(itime-1)*dtime
-
+      
       CALL intocpl(il_time_secs, iim, jjm+1, wri_sol_ice, wri_sol_sea, wri_nsol_ice,&
       & wri_nsol_sea, wri_fder_ice, wri_evap_ice, wri_evap_sea, wri_rain, &
@@ -2081,11 +2389,49 @@
 !
   if (nisurf == is_oce) then
-    call cpl2gath(read_sst, tsurf_new, klon, knon,iim,jjm, knindex)
+    call cpl2gath(read_sst, tsurf_new, klon, knon,iim,jjphy_nb, knindex)
   else if (nisurf == is_sic) then
-    call cpl2gath(read_sit, tsurf_new, klon, knon,iim,jjm, knindex)
-    call cpl2gath(read_alb_sic, alb_new, klon, knon,iim,jjm, knindex)
+    call cpl2gath(read_sit, tsurf_new, klon, knon,iim,jjphy_nb, knindex)
+    call cpl2gath(read_alb_sic, alb_new, klon, knon,iim,jjphy_nb, knindex)
   endif
   pctsrf_new(:,nisurf) = pctsrf_sav(:,nisurf)
   
+  if (mod(itime, nexca) == -1) then
+    tmp_field=0.
+    do i = 1, knon
+      ig = knindex(i)
+      tmp_field(ig) = 1.
+    enddo    
+!ym    call WriteField_phy('knindex',tmp_field,1)
+    
+    tmp_field=0.
+    do i = 1, knon
+      ig = knindex(i)
+      tmp_field(ig) = tsurf_new(i)
+    enddo    
+!ym    call WriteField_phy('tsurf_new',tmp_field,1)
+    
+    tmp_field=0.
+    do i = 1, knon
+      ig = knindex(i)
+      tmp_field(ig) = alb_new(i)
+    enddo    
+!ym    call WriteField_phy('alb_new',tmp_field,1)
+    
+!    tmp_field=0.
+!   do i = 1, knon
+!      ig = knindex(i)
+!      tmp_field(ig) = pctsrf_new(i,nisurf)
+ !   enddo    
+!ym    call WriteField_phy('pctsrf_new', pctsrf_new(:,nisurf),1)
+  endif
+!ym  do j=1,jjphy_nb
+!ym    do i=1,iim
+!ym      print *,phy_rank,'read_sst(',i,',',j,')=',read_sst(i,j)
+!ym    enddo
+!ym  enddo
+  
+!ym  do i=1,knon
+!ym    print *,phy_rank,'tsurf_new(',i,')=',tsurf_new(i)
+!ym  enddo
 !  if (lafin) call quitcpl
 
@@ -2140,9 +2486,13 @@
   REAL :: amn, amx
   INTEGER, save :: lmt_pas, julien, idayvrai
+!$OMP THREADPRIVATE(lmt_pas, julien, idayvrai) 
   REAL, parameter :: unjour=86400.
   real, allocatable, dimension(:), save :: tmp_tslab, tmp_seaice
   REAL, allocatable, dimension(:), save :: slab_bils
   REAL, allocatable, dimension(:), save :: lmt_bils
+!$OMP THREADPRIVATE(tmp_tslab, tmp_seaice,slab_bils,lmt_bils)
   logical,save              :: check = .false.
+!$OMP THREADPRIVATE(check) 
+
 !
   REAL, parameter :: cyang=50.0 * 4.228e+06 ! capacite calorifique volumetrique de l'eau J/(m2 K)
@@ -2317,7 +2667,11 @@
 !
   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
+
+#include "indicesol.inc"
 
 ! Cette routine sert d'interface entre le modele atmospherique et un fichier
@@ -2346,13 +2700,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
@@ -2360,16 +2717,30 @@
   INTEGER,save :: lmt_pas     ! frequence de lecture des conditions limites 
                              ! (en pas de physique)
+!$OMP THREADPRIVATE(lmt_pas)
   logical,save :: deja_lu    ! pour indiquer que le jour a lire a deja
                              ! lu pour une surface precedente
+!$OMP THREADPRIVATE(deja_lu)
   integer,save :: jour_lu 
+!$OMP THREADPRIVATE(jour_lu)
   integer      :: ierr
   character (len = 20) :: modname = 'interfoce_lim'
   character (len = 80) :: abort_message
   character (len = 20),save :: fich ='limit.nc'
+!$OMP THREADPRIVATE(fich)
   logical, save     :: newlmt = .TRUE.
+!$OMP THREADPRIVATE(newlmt)
   logical, save     :: check = .FALSE.
+!$OMP THREADPRIVATE(check)
 ! 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
+!$OMP THREADPRIVATE(sst_lu_p)
+  real, allocatable , save, dimension(:) :: sst_lu_mpi
+
+  real, allocatable , save, dimension(:,:) :: pct_tmp_p
+!$OMP THREADPRIVATE(pct_tmp_p)
+  real, allocatable , save, dimension(:,:) :: pct_tmp_mpi
+  real, dimension(klon,nbsrf) :: pct_tmp
+  real, dimension(klon) :: sst_lu
+  real, dimension(klon) :: nat_lu
 !
 ! quelques variables pour netcdf
@@ -2379,13 +2750,12 @@
   integer, dimension(2) :: start, epais
 !
-! Fin déclaration
-!
-    
-  if (debut .and. .not. allocated(sst_lu)) then
+! Fin declaration
+!
+  
+  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(klon_omp))
+    allocate(pct_tmp_p(klon_omp,nbsrf))
   endif
 
@@ -2400,4 +2770,10 @@
 ! Ouverture du fichier
 !
+!$OMP MASTER
+    if (.not. allocated(sst_lu_mpi)) allocate(sst_lu_mpi(klon_mpi))
+    if (.not. allocated(pct_tmp_mpi)) allocate(pct_tmp_mpi(klon_mpi,nbsrf))
+    
+    if (phy_rank==0) then
+    
     fich = trim(fich)
     ierr = NF_OPEN (fich, NF_NOWRITE,nid)
@@ -2539,17 +2915,31 @@
 !
     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_mpi,1)
+  call ScatterField(pct_tmp(:,is_oce),pct_tmp_mpi(:,is_oce),1)
+  call ScatterField(pct_tmp(:,is_sic),pct_tmp_mpi(:,is_sic),1)
+!$OMP END MASTER
+!$OMP BARRIER
+  call ScatterField_omp(sst_lu_mpi,sst_lu_p,1)
+  call ScatterField_omp(pct_tmp_mpi(:,is_oce),pct_tmp_p(:,is_oce),1)
+  call ScatterField_omp(pct_tmp_mpi(:,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
@@ -2559,7 +2949,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
@@ -2581,5 +2973,5 @@
 !   lmt_sst      SST lues dans le fichier de CL
 !   lmt_alb      Albedo lu 
-!   lmt_rug      longueur de rugosité lue
+!   lmt_rug      longueur de rugosite lue
 !   pctsrf_new   sous-maille fractionnelle
 !
@@ -2592,11 +2984,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
@@ -2604,15 +2999,24 @@
   integer,save :: lmt_pas     ! frequence de lecture des conditions limites 
                              ! (en pas de physique)
+!$OMP THREADPRIVATE(lmt_pas) 
   logical,save :: deja_lu_sur! pour indiquer que le jour a lire a deja
                              ! lu pour une surface precedente
+!$OMP THREADPRIVATE(deja_lu_sur) 
   integer,save :: jour_lu_sur 
+!$OMP THREADPRIVATE(jour_lu_sur) 
   integer      :: ierr
   character (len = 20) :: modname = 'interfsur_lim'
   character (len = 80) :: abort_message
   character (len = 20),save :: fich ='limit.nc'
+!$OMP THREADPRIVATE(fich) 
   logical,save     :: newlmt = .false.
+!$OMP THREADPRIVATE(newlmt) 
   logical,save     :: check = .false.
+!$OMP THREADPRIVATE(check) 
 ! 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
+!$OMP THREADPRIVATE(alb_lu_p, rug_lu_p) 
+  real, allocatable , save, dimension(:) :: alb_lu_mpi, rug_lu_mpi
+  real, dimension(klon) :: alb_lu, rug_lu
 !
 ! quelques variables pour netcdf
@@ -2620,14 +3024,16 @@
 #include "netcdf.inc"
   integer ,save             :: nid, nvarid
+!$OMP THREADPRIVATE(nid, nvarid) 
   integer, dimension(2),save :: start, epais
-!
-! Fin déclaration
-!
-    
+!$OMP THREADPRIVATE(start, epais) 
+!
+! Fin declaration
+!
+  
   if (debut) then
     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(klon_omp))
+    allocate(rug_lu_p(klon_omp))
   endif
 
@@ -2640,4 +3046,9 @@
 ! 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
+
+!$OMP MASTER
+    if (.not. allocated(alb_lu_mpi)) allocate(alb_lu_mpi(klon_mpi))
+    if (.not. allocated(rug_lu_mpi)) allocate(rug_lu_mpi(klon_mpi))  
+  if (phy_rank==0) then
 !
 ! Ouverture du fichier
@@ -2676,6 +3087,5 @@
     endif
 !
-! Lecture rugosité
-!
+! Lecture rugosite !
     ierr = NF_INQ_VARID(nid, 'RUG', nvarid)
     if (ierr /= NF_NOERR) then
@@ -2697,7 +3107,22 @@
 !
     ierr = NF_CLOSE(nid)
+
+
+  endif  !! phyrank
+
+    call ScatterField(alb_lu,alb_lu_mpi,1)
+    call ScatterField(rug_lu,rug_lu_mpi,1)
+!$OMP END MASTER
+!$OMP BARRIER
+
+    call ScatterField_omp(alb_lu_mpi,alb_lu_p,1)
+    call ScatterField_omp(rug_lu_mpi,rug_lu_p,1)
+    
     deja_lu_sur = .true.
     jour_lu_sur = jour
+
+
   endif
+  
 !
 ! Recopie des variables dans les champs de sortie
@@ -2705,10 +3130,12 @@
 !!$  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
+
 
   END SUBROUTINE interfsur_lim
@@ -2724,5 +3151,5 @@
      & petAcoef, peqAcoef, petBcoef, peqBcoef, &
      & tsurf_new, evap, fluxlat, fluxsens, dflux_s, dflux_l)
-
+     USE dimphy,only : omp_rank
 ! Cette routine calcule les fluxs en h et q a l'interface et eventuellement
 ! une temperature de surface (au cas ou ok_veget = false)
@@ -2762,4 +3189,5 @@
 #include "FCTTRE.inc"
 #include "indicesol.inc"
+#include "YOMCST.inc"
 
 ! Parametres d'entree
@@ -2795,9 +3223,13 @@
 !
   logical, save         :: check = .false.
+!$OMP THREADPRIVATE(check)
   character (len = 20)  :: modname = 'calcul_fluxs'
   logical, save         :: fonte_neige = .false.
+!$OMP THREADPRIVATE(fonte_neige)
   real, save            :: max_eau_sol = 150.0
+!$OMP THREADPRIVATE(max_eau_sol)
   character (len = 80) :: abort_message 
   logical,save         :: first = .true.,second=.false.
+!$OMP THREADPRIVATE(first,second)
 
   if (check) write(*,*)'Entree ', modname,' surface = ',nisurf
@@ -2952,6 +3384,8 @@
 !#########################################################################
 !
-  SUBROUTINE gath2cpl(champ_in, champ_out, klon, knon, iim, jjm, knindex)
-
+  SUBROUTINE gath2cpl(champ_in, champ_out, klon, knon, iim, jmp1, knindex)
+  use dimphy, only: liste_i,liste_j,jjphy_begin,jjphy_nb,phy_rank,phy_size 
+  implicit none
+  
 ! Cette routine ecrit un champ 'gathered' sur la grille 2D pour le passer
 ! au coupleur.
@@ -2969,9 +3403,9 @@
 !
 ! input
-  integer                   :: klon, knon, iim, jjm
+  integer                   :: klon, knon, iim, jmp1
   real, dimension(klon)     :: champ_in
   integer, dimension(klon)  :: knindex
 ! output
-  real, dimension(iim,jjm+1)  :: champ_out
+  real, dimension(iim,jmp1)  :: champ_out
 ! local
   integer                   :: i, ig, j
@@ -2983,14 +3417,24 @@
     tamp(ig) = champ_in(i)
   enddo    
-  ig = 1
-  champ_out(:,1) = tamp(ig)
-  do j = 2, jjm
-    do i = 1, iim
-      ig = ig + 1
-      champ_out(i,j) = tamp(ig)
-    enddo
+
+!ym  ig = 1
+!ym  champ_out(:,1) = tamp(ig)
+!ym  do j = 2, jjm
+!ym    do i = 1, iim
+!ym      ig = ig + 1
+!ym      champ_out(i,j) = tamp(ig)
+!ym    enddo
+!ym  enddo
+!ym  ig = ig + 1
+!ym  champ_out(:,jjm+1) = tamp(ig)
+
+  do ig=1,klon
+    i=liste_i(ig)
+    j=liste_j(ig)-jjphy_begin+1
+    champ_out(i,j)=tamp(ig)
   enddo
-  ig = ig + 1
-  champ_out(:,jjm+1) = tamp(ig)
+  
+  if (phy_rank==0) champ_out(:,1)=tamp(1)
+  if (phy_rank==phy_size-1) champ_out(:,jjphy_nb)=tamp(klon)
 
   END SUBROUTINE gath2cpl
@@ -2998,6 +3442,7 @@
 !#########################################################################
 !
-  SUBROUTINE cpl2gath(champ_in, champ_out, klon, knon, iim, jjm, knindex)
-
+  SUBROUTINE cpl2gath(champ_in, champ_out, klon, knon, iim, jmp1, knindex)
+  use dimphy, only : liste_i, liste_j, jjphy_begin
+  implicit none
 ! Cette routine ecrit un champ 'gathered' sur la grille 2D pour le passer
 ! au coupleur.
@@ -3015,6 +3460,6 @@
 !
 ! input
-  integer                   :: klon, knon, iim, jjm
-  real, dimension(iim,jjm+1)     :: champ_in
+  integer                   :: klon, knon, iim, jmp1
+  real, dimension(iim,jmp1)     :: champ_in
   integer, dimension(klon)  :: knindex
 ! output
@@ -3024,16 +3469,23 @@
   real, dimension(klon)     :: tamp
   logical ,save                  :: check = .false.
-
-  ig = 1
-  tamp(ig) = champ_in(1,1)
-  do j = 2, jjm
-    do i = 1, iim
-      ig = ig + 1
-      tamp(ig) = champ_in(i,j)
-    enddo
+!$OMP THREADPRIVATE(check)
+
+!ym  ig = 1
+!ym  tamp(ig) = champ_in(1,1)
+!ym  do j = 2, jjm
+!ym    do i = 1, iim
+!ym      ig = ig + 1
+!ym      tamp(ig) = champ_in(i,j)
+!ym    enddo
+!ym  enddo
+!ym  ig = ig + 1
+!ym  tamp(ig) = champ_in(1,jjm+1)
+
+  do ig=1,klon
+   i=liste_i(ig)
+   j=liste_j(ig)-jjphy_begin+1
+   tamp(ig)=champ_in(i,j)
   enddo
-  ig = ig + 1
-  tamp(ig) = champ_in(1,jjm+1)
-
+  
   do i = 1, knon
     ig = knindex(i)
@@ -3057,4 +3509,5 @@
  
   REAL, DIMENSION(nvm),SAVE :: init, decay
+!$OMP THREADPRIVATE(init, decay)
   REAL :: as
   DATA init /0.55, 0.14, 0.18, 0.29, 0.15, 0.15, 0.14, 0./
@@ -3092,9 +3545,8 @@
      & petAcoef, peqAcoef, petBcoef, peqBcoef, &
      & tsurf_new, evap, fluxlat, fluxsens, dflux_s, dflux_l, &
-     & fqcalving,ffonte,run_off_lic_0)
+     & fqcalving,fqfonte,ffonte,run_off_lic_0)
 
 ! Routine de traitement de la fonte de la neige dans le cas du traitement
-! de sol simplifié
-!
+! de sol simplifie !
 ! LF 03/2001
 ! input:
@@ -3126,5 +3578,5 @@
 !   dflux_l      derivee du flux de chaleur latente  / Ts
 ! in/out:
-!   run_off_lic_0 run off glacier du pas de temps précedent
+!   run_off_lic_0 run off glacier du pas de temps precedent
 !
 
@@ -3152,7 +3604,7 @@
 ! Flux thermique utiliser pour fondre la neige
   real, dimension(klon), intent(INOUT):: ffonte
-! Flux d'eau "perdue" par la surface et necessaire pour que limiter la
-! hauteur de neige, en kg/m2/s
-  real, dimension(klon), intent(INOUT):: fqcalving
+! Flux d'eau "perdu" par la surface et necessaire pour que limiter la
+! hauteur de neige, en kg/m2/s. Et flux d'eau de fonte de la calotte.
+  REAL, DIMENSION(klon), INTENT(INOUT):: fqcalving, fqfonte
   real, dimension(klon), intent(INOUT):: run_off_lic_0
 ! Variables locales
@@ -3181,9 +3633,13 @@
 !
   logical, save         :: check = .FALSE.
+!$OMP THREADPRIVATE(check)
   character (len = 20)  :: modname = 'fonte_neige'
   logical, save         :: neige_fond = .false.
+!$OMP THREADPRIVATE(neige_fond)
   real, save            :: max_eau_sol = 150.0
+!$OMP THREADPRIVATE(max_eau_sol)
   character (len = 80) :: abort_message 
   logical,save         :: first = .true.,second=.false.
+!$OMP THREADPRIVATE(first,second)
   real                 :: coeff_rel
 #include "FCTTRE.inc"
@@ -3275,4 +3731,5 @@
       fq_fonte = MIN( MAX((tsurf_new(i)-RTT )/chasno,0.0),snow(i))
       ffonte(i) = fq_fonte * RLMLT/dtime
+      fqfonte(i) = fq_fonte/dtime
       snow(i) = max(0., snow(i) - fq_fonte)
       bil_eau_s(i) = bil_eau_s(i) + fq_fonte 
@@ -3283,5 +3740,8 @@
         fq_fonte = MAX((tsurf_new(i)-RTT )/chaice,0.0)
         ffonte(i) = ffonte(i) + fq_fonte * RLMLT/dtime
-        bil_eau_s(i) = bil_eau_s(i) + fq_fonte
+        IF ( ok_lic_melt ) THEN
+           fqfonte(i) = fqfonte(i) + fq_fonte/dtime
+           bil_eau_s(i) = bil_eau_s(i) + fq_fonte
+        ENDIF
         tsurf_new(i) = RTT
       ENDIF
@@ -3301,5 +3761,5 @@
  &                        (1. - coeff_rel) * run_off_lic_0(i)
       run_off_lic_0(i) = run_off_lic(i)
-      run_off_lic(i) = run_off_lic(i) + bil_eau_s(i)/dtime
+      run_off_lic(i) = run_off_lic(i) + fqfonte(i)/dtime
     endif
   enddo
Index: /LMDZ4/trunk/libf/phylmd/iophy.F90
===================================================================
--- /LMDZ4/trunk/libf/phylmd/iophy.F90	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/iophy.F90	(revision 766)
@@ -7,8 +7,11 @@
   REAL,private,allocatable,dimension(:),save :: io_lat
   REAL,private,allocatable,dimension(:),save :: io_lon
+  INTEGER, save :: phys_domain_id
   
   INTERFACE histwrite_phy
     MODULE PROCEDURE histwrite2d_phy,histwrite3d_phy
   END INTERFACE 
+  
+  REAL,private,allocatable,save,dimension(:,:) :: buffer_omp
 
 contains
@@ -16,9 +19,19 @@
   subroutine init_iophy(lat,lon)
   use dimphy
+  use ioipsl
   implicit none
   include 'dimensions90.h'   
     real,dimension(iim),intent(in) :: lon
     real,dimension(jjm+1),intent(in) :: lat
-  
+
+    INTEGER,DIMENSION(2) :: ddid
+    INTEGER,DIMENSION(2) :: dsg
+    INTEGER,DIMENSION(2) :: dsl
+    INTEGER,DIMENSION(2) :: dpf
+    INTEGER,DIMENSION(2) :: dpl
+    INTEGER,DIMENSION(2) :: dhs
+    INTEGER,DIMENSION(2) :: dhe 
+
+!$OMP MASTER  
     allocate(io_lat(jjm+1))
     io_lat(:)=lat(:)
@@ -31,5 +44,24 @@
     ndex2d(:)=0
     ndex3d(:)=0
+    allocate(buffer_omp(klon_mpi,klev))
+    
+    ddid=(/ 1,2 /)
+    dsg=(/ iim, jjm+1 /)
+    dsl=(/ iim, jjphy_nb /)
+    dpf=(/ 1,jjphy_begin /)
+    dpl=(/ iim, jjphy_end /)
+    dhs=(/ iiphy_begin-1,0 /)
+    if (phy_rank==phy_size-1) then
+      dhe=(/0,0/)
+    else
+      dhe=(/ iim-iiphy_end,0 /)  
+    endif
+    
+    call flio_dom_set(phy_size,phy_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
+                      'APPLE',phys_domain_id)
 
+!$OMP END MASTER
+!$OMP FLUSH(buffer_omp)
+      
   end subroutine init_iophy
   
@@ -47,12 +79,14 @@
     integer,intent(out) :: nhori
     integer,intent(out) :: nid_day
-    
+
+!$OMP MASTER    
     if (monocpu) then
       call histbeg(name,iim,io_lon, jjphy_nb,io_lat(jjphy_begin:jjphy_end), &
                    1,iim,1,jjphy_nb,itau0, zjulian, dtime, nhori, nid_day)
     else
-      call histbeg(name//'_'//trim(int2str(phy_rank)),iim,io_lon, jjphy_nb,io_lat(jjphy_begin:jjphy_end), &
-                   1,iim,1,jjphy_nb,itau0, zjulian, dtime, nhori, nid_day)
+      call histbeg(name,iim,io_lon, jjphy_nb,io_lat(jjphy_begin:jjphy_end), &
+                   1,iim,1,jjphy_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
     endif
+!$OMP END MASTER
   
   end subroutine histbeg_phy
@@ -68,8 +102,10 @@
     integer, intent(in) :: itau
     real,dimension(klon),intent(in) :: field
-    
-    CALL phy2dyn(field,tmp_tab2d,1)
+
+    CALL GatherField_omp(field,buffer_omp,1)    
+!$OMP MASTER
+    CALL phy2dyn(buffer_omp,tmp_tab2d,1)
     CALL histwrite(nid,name,itau,tmp_tab2d,iim*jjphy_nb,ndex2d)
-    
+!$OMP END MASTER    
   end subroutine histwrite2d_phy
   
@@ -85,7 +121,9 @@
     real,dimension(klon,klev),intent(in) :: field
     
-    CALL phy2dyn(field,tmp_tab3d,klev)
+    CALL GatherField_omp(field,buffer_omp,klev)
+!$OMP MASTER
+    CALL phy2dyn(buffer_omp,tmp_tab3d,klev)
     CALL histwrite(nid,name,itau,tmp_tab3d,iim*jjphy_nb*klev,ndex3d)
-    
+!$OMP END MASTER    
   end subroutine histwrite3d_phy
   
@@ -96,5 +134,5 @@
   include 'dimensions90.h'
   
-    real,dimension(klon,nlev),intent(in) :: field_phy
+    real,dimension(klon_mpi,nlev),intent(in) :: field_phy
     real,dimension(iim,jjphy_nb,nlev),intent(out) :: field_dyn
     integer,intent(in) :: nlev
@@ -107,5 +145,5 @@
 	if (jjphy_begin==jjphy_end) then
 	  field_dyn(:,1,l)=0.
-	  field_dyn(iiphy_begin:iiphy_end,1,l)=field_phy(1:klon,l)
+	  field_dyn(iiphy_begin:iiphy_end,1,l)=field_phy(1:klon_mpi,l)
 	else
 	
@@ -115,5 +153,5 @@
 	 else
 	   field_dyn(:,1,l)=0.
-	   next=iim-iiphy_begin+1
+	   next=iim-iiphy_begin+2
 	   field_dyn(iiphy_begin:iim,1,l)=field_phy(1:next-1,l)   
 	 endif
@@ -125,5 +163,5 @@
 	  
 	  if (jjphy_end==jjm+1) then
-             field_dyn(:,jjphy_nb,l)=field_phy(klon,l)
+             field_dyn(:,jjphy_nb,l)=field_phy(klon_mpi,l)
 	  else
 	   field_dyn(:,jjphy_nb,l)=0.
Index: /LMDZ4/trunk/libf/phylmd/minmaxqfi.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/minmaxqfi.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/minmaxqfi.F	(revision 766)
@@ -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/trunk/libf/phylmd/moy_undefSTD.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/moy_undefSTD.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/moy_undefSTD.F	(revision 766)
@@ -2,4 +2,5 @@
      $           dtime,ecrit_day,ecrit_mth,ecrit_hf2mth,
      $           tnondef,tsumSTD)
+      USE dimphy
       IMPLICIT none
 c
@@ -20,8 +21,8 @@
 c NB: mettre "inst(X)" dans le write_histXXX.h !
 c====================================================================
-#include "dimensions.h"
-      integer jjmp1
-      parameter (jjmp1=jjm+1-1/jjm)
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym      integer jjmp1
+cym      parameter (jjmp1=jjm+1-1/jjm)
+cym#include "dimphy.h"
 c
 c variables Input
Index: /LMDZ4/trunk/libf/phylmd/moyglo_aire.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/moyglo_aire.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/moyglo_aire.F	(revision 766)
@@ -2,4 +2,5 @@
      .            ok_msk, msk, moyglo)
 c
+       USE dimphy
        IMPLICIT none
 c
@@ -14,5 +15,5 @@
 c
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
        INTEGER i, nhori
        REAL champ(klon), aire(klon), msk(klon)
@@ -61,4 +62,5 @@
        SUBROUTINE moyglo_pondaima(nhori, nvert, champ,
      . aire, pbord, moyglo)
+       USE dimphy
        IMPLICIT none
 c ==================================================================
@@ -72,5 +74,5 @@
 c ==================================================================
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
        INTEGER i, k, nhori, nvert
@@ -107,4 +109,5 @@
        SUBROUTINE moyglo_pondmass(nhori, nvert, champ,
      . aire, pbord, moyglo)
+       USE dimphy
        IMPLICIT none
 c ==================================================================
@@ -118,5 +121,5 @@
 c ==================================================================
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
        INTEGER i, k, nhori, nvert
Index: /LMDZ4/trunk/libf/phylmd/mpiclim.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/mpiclim.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/mpiclim.h	(revision 766)
@@ -21,4 +21,5 @@
 C
       common/CLIM_mpiclim/mpi_totproc, mpi_nproc, cmpi_modnam 
+c$OMP THREADPRIVATE(/CLIM_mpiclim/)
 C
 C     -----------------------------------------------------------------
Index: /LMDZ4/trunk/libf/phylmd/newmicro.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/newmicro.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/newmicro.F	(revision 766)
@@ -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"
 cIM cf. CR: include pour NOVLP et ZEPSEC
@@ -116,4 +117,5 @@
        xflwp(i)=0.
        xfiwp(i)=0.
+cccccccccccc!CDIR NOVECTOR
       DO k = 1, klev
 c
Index: /LMDZ4/trunk/libf/phylmd/nflxtr.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/nflxtr.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/nflxtr.F	(revision 766)
@@ -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/trunk/libf/phylmd/nuage.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/nuage.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/nuage.F	(revision 766)
@@ -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/trunk/libf/phylmd/nuage.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/nuage.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/nuage.h	(revision 766)
@@ -5,2 +5,3 @@
 
       common /nuagecom/ rad_froid,rad_chau1, rad_chau2
+!$OMP THREADPRIVATE(/nuagecom/)
Index: /LMDZ4/trunk/libf/phylmd/oasis.dummy
===================================================================
--- /LMDZ4/trunk/libf/phylmd/oasis.dummy	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/oasis.dummy	(revision 766)
@@ -95,8 +95,8 @@
       cl_writ(18)='CORIVFLU'
       cl_writ(19)='COCALVIN'
-c$$$      cl_writ(13)='COZOTAUX'
-c$$$      cl_writ(14)='COZOTAUV'
-c$$$      cl_writ(15)='COMETAUY'
-c$$$      cl_writ(16)='COMETAUU'
+cxxx      cl_writ(13)='COZOTAUX'
+cxxx      cl_writ(14)='COZOTAUV'
+cxxx      cl_writ(15)='COMETAUY'
+cxxx      cl_writ(16)='COMETAUU'
       cl_writ(1)='COTAUXXU'
       cl_writ(2)='COTAUYYU'
@@ -365,8 +365,8 @@
       REAL rivrunoff(imjm)
       REAL calving(imjm)
-c$$$      REAL tauxu(imjm)
-c$$$      REAL tauxv(imjm)
-c$$$      REAL tauyu(imjm)
-c$$$      REAL tauyv(imjm)
+cxxx      REAL tauxu(imjm)
+cxxx      REAL tauxv(imjm)
+cxxx      REAL tauyu(imjm)
+cxxx      REAL tauyv(imjm)
       REAL tauxx_u(imjm)
       REAL tauxx_v(imjm)
@@ -496,16 +496,16 @@
      $          CALL locwrite(cl_writ(jf),calving, imjm,
      $          file_unit_field(jf), ierror) 
-c$$$            IF (jf.eq.13)
-c$$$     $          CALL locwrite(cl_writ(jf),tauxu, imjm,
-c$$$     $          file_unit_field(jf),ierror) 
-c$$$            IF (jf.eq.1')
-c$$$     $          CALL locwrite(cl_writ(jf),tauxv, imjm,
-c$$$     $          file_unit_field(jf),ierror) 
-c$$$            IF (jf.eq.15)
-c$$$     $          CALL locwrite(cl_writ(jf),tauyv, imjm,
-c$$$     $          file_unit_field(jf),ierror) 
-c$$$            IF (jf.eq.16)
-c$$$     $          CALL locwrite(cl_writ(jf),tauyu, imjm,
-c$$$     $          file_unit_field(jf), ierror) 
+cxxx            IF (jf.eq.13)
+cxxx     $          CALL locwrite(cl_writ(jf),tauxu, imjm,
+cxxx     $          file_unit_field(jf),ierror) 
+cxxx            IF (jf.eq.1')
+cxxx     $          CALL locwrite(cl_writ(jf),tauxv, imjm,
+cxxx     $          file_unit_field(jf),ierror) 
+cxxx            IF (jf.eq.15)
+cxxx     $          CALL locwrite(cl_writ(jf),tauyv, imjm,
+cxxx     $          file_unit_field(jf),ierror) 
+cxxx            IF (jf.eq.16)
+cxxx     $          CALL locwrite(cl_writ(jf),tauyu, imjm,
+cxxx     $          file_unit_field(jf), ierror) 
             IF (jf.eq.1)
      $          CALL locwrite(cl_writ(jf),tauxx_u, imjm,
@@ -574,8 +574,8 @@
           IF (jn.eq.18) CALL CLIM_Export(cl_writ(jn),kt,rivrunoff,info)
           IF (jn.eq.19) CALL CLIM_Export(cl_writ(jn),kt,calving,info)
-c$$$          IF (jn.eq.13) CALL CLIM_Export(cl_writ(jn), kt, tauxu, info)
-c$$$          IF (jn.eq.14) CALL CLIM_Export(cl_writ(jn), kt, tauxv, info)
-c$$$          IF (jn.eq.15) CALL CLIM_Export(cl_writ(jn), kt, tauyv, info)
-c$$$          IF (jn.eq.16) CALL CLIM_Export(cl_writ(jn), kt, tauyu, info)
+cxxx          IF (jn.eq.13) CALL CLIM_Export(cl_writ(jn), kt, tauxu, info)
+cxxx          IF (jn.eq.14) CALL CLIM_Export(cl_writ(jn), kt, tauxv, info)
+cxxx          IF (jn.eq.15) CALL CLIM_Export(cl_writ(jn), kt, tauyv, info)
+cxxx          IF (jn.eq.16) CALL CLIM_Export(cl_writ(jn), kt, tauyu, info)
           IF (jn.eq.1) CALL CLIM_Export(cl_writ(jn), kt, tauxx_u, info)
           IF (jn.eq.2) CALL CLIM_Export(cl_writ(jn), kt, tauyy_u, info)
Index: /LMDZ4/trunk/libf/phylmd/oasis.psmile
===================================================================
--- /LMDZ4/trunk/libf/phylmd/oasis.psmile	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/oasis.psmile	(revision 766)
@@ -45,5 +45,5 @@
    use mod_prism_proto
    use mod_prism_def_partition_proto
-
+   use dimphy
    implicit none
 
@@ -94,16 +94,16 @@
 ! Here we go: psmile initialisation
 !
-   call prism_init_comp_proto (comp_id, clmodnam, ierror)
-
-   IF (ierror .ne. PRISM_Ok) THEN
-      abort_message=' Probleme init dans prism_init_comp '
-      call abort_gcm(modname,abort_message,1)
-   ELSE
-      WRITE(nuout,*) 'inicma : init psmile ok '
-   ENDIF
-
-! PSMILe attribution of local communicator
-!
-   call prism_get_localcomm_proto (il_commlocal, ierror)
+    IF (monocpu) THEN
+      call prism_init_comp_proto (comp_id, clmodnam, ierror)
+
+      IF (ierror .ne. PRISM_Ok) THEN
+         abort_message=' Probleme init dans prism_init_comp '
+         call abort_gcm(modname,abort_message,1)
+      ELSE
+         WRITE(nuout,*) 'inicma : init psmile ok '
+      ENDIF
+    ENDIF
+
+      call prism_get_localcomm_proto (il_commlocal, ierror)
 !
 ! and domain decomposition
@@ -111,11 +111,15 @@
 ! monoproc case
 !
-   allocate(ig_paral(5))
-   ig_paral (1) = 2
-   ig_paral (2) = 0
-   ig_paral (3) = im
-   ig_paral (4) = jm
-   ig_paral (5) = im
-
+   allocate(ig_paral(3))
+!ym   ig_paral(1) = 0
+!ym   ig_paral(2) = 0
+!ym   ig_paral(3) = im * jm
+   ig_paral(1) = 1    ! apple partition for //
+   ig_paral(2) = (jjphy_begin-1)*im+iiphy_begin-1
+   ig_paral(3) = (jjphy_end*im+iiphy_end)-(jjphy_begin*im+iiphy_begin)+1
+   if (phy_rank==phy_size-1) ig_paral(3)=ig_paral(3)+im-1
+   print *,phy_rank,'ig_paral--->',ig_paral(2),ig_paral(3)
+   
+   ierror=PRISM_Ok
    call prism_def_partition_proto (il_part_id, ig_paral, ierror)
    deallocate(ig_paral)
@@ -140,7 +144,7 @@
       cl_writ(5)='COTAUYYV'
       cl_writ(6)='COTAUZZV'
-c -- LOOP
+! -- LOOP
       cl_writ(7)='COWINDSP'
-c -- LOOP
+! -- LOOP
       cl_writ(8)='COSHFICE'
       cl_writ(9)='COSHFOCE'
@@ -218,5 +222,5 @@
    use mod_prism_proto
    use mod_prism_get_proto
-
+   use dimphy
    IMPLICIT none
 
@@ -225,8 +229,8 @@
 !
    integer                 :: im, jm, kt
-   real, dimension(im, jm)   :: sst            ! sea-surface-temperature
-   real, dimension(im, jm)   :: gla     ! sea-ice
-   real, dimension(im, jm)   :: tice    ! temp glace
-   real, dimension(im, jm)   :: albedo  ! albedo glace
+   real, dimension(im*jm)   :: sst            ! sea-surface-temperature
+   real, dimension(im*jm)   :: gla     ! sea-ice
+   real, dimension(im*jm)   :: tice    ! temp glace
+   real, dimension(im*jm)   :: albedo  ! albedo glace
 !
 ! local variables
@@ -236,4 +240,5 @@
    character (len = 20),save  :: modname = 'fromcpl'
    character (len = 80)       :: abort_message 
+   integer :: istart,iend
 !
 #include "param_cou.h"
@@ -245,5 +250,12 @@
    CALL flush (nuout)
 
-   call prism_get_proto(in_var_id(1), kt, sst, ierror)
+   istart=iiphy_begin
+   if (phy_rank==phy_size-1) then
+    iend=(jjphy_end-jjphy_begin)*im+im
+   else
+    iend=(jjphy_end-jjphy_begin)*im+iiphy_end
+   endif
+   
+   call prism_get_proto(in_var_id(1), kt, sst(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Recvd .and. &
  &     ierror.ne.PRISM_FromRest &
@@ -254,5 +266,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_get_proto(in_var_id(2), kt, gla, ierror)
+   call prism_get_proto(in_var_id(2), kt, gla(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Recvd .and. &
  &     ierror.ne.PRISM_FromRest &
@@ -263,5 +275,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_get_proto(in_var_id(3), kt, albedo, ierror)
+   call prism_get_proto(in_var_id(3), kt, albedo(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Recvd .and. &
  &     ierror.ne.PRISM_FromRest &
@@ -272,5 +284,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_get_proto(in_var_id(4), kt, tice, ierror)
+   call prism_get_proto(in_var_id(4), kt, tice(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Recvd .and. &
  &     ierror.ne.PRISM_FromRest &
@@ -288,9 +300,9 @@
    SUBROUTINE intocpl(kt, im, jm, fsolice, fsolwat, fnsolice, fnsolwat, &
  &    fnsicedt, evice, evwat, lpre, spre, dirunoff, rivrunoff, & 
- &    calving, tauxx_u, tauyy_u, tauzz_u, tauxx_v, tauyy_v, tauzz_v &
-c -- LOOP
-     $    windsp,
-c -- LOOP
- &    , last) 
+ &    calving, tauxx_u, tauyy_u, tauzz_u, tauxx_v, tauyy_v, tauzz_v, &
+! -- LOOP
+ &    windsp,                                                       &
+! -- LOOP
+ &    last) 
 ! ======================================================================
 ! L. Fairhead (09/2003) adapted From L.Z.X Li: this subroutine provides the 
@@ -301,5 +313,6 @@
    use mod_prism_proto
    use mod_prism_put_proto
-
+   use dimphy
+   use write_field_phy
    IMPLICIT NONE
 
@@ -308,11 +321,14 @@
 !
    integer               :: kt, im, jm
-   real, dimension(im, jm) :: fsolice, fsolwat, fnsolwat, fnsolice
-   real, dimension(im, jm) :: fnsicedt, evice, evwat, lpre, spre
-   real, dimension(im, jm) :: dirunoff, rivrunoff, calving
-   real, dimension(im, jm) :: tauxx_u, tauxx_v, tauyy_u
-   real, dimension(im, jm) :: tauyy_v, tauzz_u, tauzz_v
-   real, dimension(im, jm) :: windsp
+   real, dimension(im* jm) :: fsolice, fsolwat, fnsolwat, fnsolice
+   real, dimension(im* jm) :: fnsicedt, evice, evwat, lpre, spre
+   real, dimension(im* jm) :: dirunoff, rivrunoff, calving
+   real, dimension(im* jm) :: tauxx_u, tauxx_v, tauyy_u
+   real, dimension(im* jm) :: tauyy_v, tauzz_u, tauzz_v
+   real, dimension(im*jm) :: windsp
    logical               :: last
+   logical :: checkout=.FALSE.
+   integer :: istart,iend
+   integer :: wstart,wend
 !
 ! local
@@ -329,5 +345,39 @@
       WRITE(nuout,*)
 
-   call prism_put_proto(il_out_var_id(8), kt, fsolice, ierror)
+   istart=iiphy_begin
+   if (phy_rank==phy_size-1) then
+    iend=(jjphy_end-jjphy_begin)*im+im
+   else
+    iend=(jjphy_end-jjphy_begin)*im+iiphy_end
+   endif
+
+   IF (checkout) THEN   
+     wstart=istart
+     wend=iend
+     IF (phy_rank==0) wstart=istart+im-1
+     IF (phy_rank==phy_size-1) wend=iend-im+1
+   
+     CALL writeField_phy("fsolice",fsolice(wstart:wend),1)
+     CALL writeField_phy("fsolwat",fsolwat(wstart:wend),1)
+     CALL writeField_phy("fnsolice",fnsolice(wstart:wend),1)
+     CALL writeField_phy("fnsolwat",fnsolwat(wstart:wend),1)
+     CALL writeField_phy("fnsicedt",fnsicedt(wstart:wend),1)
+     CALL writeField_phy("evice",evice(wstart:wend),1)
+     CALL writeField_phy("evwat",evwat(wstart:wend),1)
+     CALL writeField_phy("lpre",lpre(wstart:wend),1)
+     CALL writeField_phy("spre",spre(wstart:wend),1)
+     CALL writeField_phy("dirunoff",dirunoff(wstart:wend),1)
+     CALL writeField_phy("rivrunoff",rivrunoff(wstart:wend),1)
+     CALL writeField_phy("calving",calving(wstart:wend),1)
+     CALL writeField_phy("tauxx_u",tauxx_u(wstart:wend),1)
+     CALL writeField_phy("tauyy_u",tauyy_u(wstart:wend),1)
+     CALL writeField_phy("tauzz_u",tauzz_u(wstart:wend),1)
+     CALL writeField_phy("tauxx_v",tauxx_v(wstart:wend),1)
+     CALL writeField_phy("tauyy_v",tauyy_v(wstart:wend),1)
+     CALL writeField_phy("tauzz_v",tauzz_v(wstart:wend),1)
+     CALL writeField_phy("windsp",windsp(wstart:wend),1)
+   ENDIF
+   
+   call prism_put_proto(il_out_var_id(8), kt, fsolice(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -337,5 +387,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(9), kt, fsolwat, ierror)
+   call prism_put_proto(il_out_var_id(9), kt, fsolwat(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -345,5 +395,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(10), kt, fnsolice, ierror)
+   call prism_put_proto(il_out_var_id(10), kt, fnsolice(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -353,5 +403,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(11), kt, fnsolwat, ierror)
+   call prism_put_proto(il_out_var_id(11), kt, fnsolwat(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -361,5 +411,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(12), kt, fnsicedt, ierror)
+   call prism_put_proto(il_out_var_id(12), kt, fnsicedt(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -369,5 +419,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(13), kt, evice, ierror)
+   call prism_put_proto(il_out_var_id(13), kt, evice(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -377,5 +427,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(14), kt, evwat, ierror)
+   call prism_put_proto(il_out_var_id(14), kt, evwat(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -385,5 +435,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(15), kt, lpre, ierror)
+   call prism_put_proto(il_out_var_id(15), kt, lpre(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -393,5 +443,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(16), kt, spre, ierror)
+   call prism_put_proto(il_out_var_id(16), kt, spre(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -401,5 +451,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(17), kt, dirunoff, ierror)
+   call prism_put_proto(il_out_var_id(17), kt, dirunoff(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -409,5 +459,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(18), kt, rivrunoff, ierror)
+   call prism_put_proto(il_out_var_id(18), kt, rivrunoff(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -417,5 +467,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(19), kt, calving, ierror)
+   call prism_put_proto(il_out_var_id(19), kt, calving(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -425,5 +475,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(1), kt, tauxx_u, ierror)
+   call prism_put_proto(il_out_var_id(1), kt, tauxx_u(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -433,5 +483,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(2), kt, tauyy_u, ierror)
+   call prism_put_proto(il_out_var_id(2), kt, tauyy_u(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -441,5 +491,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(3), kt, tauzz_u, ierror)
+   call prism_put_proto(il_out_var_id(3), kt, tauzz_u(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -449,5 +499,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(4), kt, tauxx_v, ierror)
+   call prism_put_proto(il_out_var_id(4), kt, tauxx_v(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -457,5 +507,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(5), kt, tauyy_v, ierror)
+   call prism_put_proto(il_out_var_id(5), kt, tauyy_v(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -465,5 +515,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(6), kt, tauzz_v, ierror)
+   call prism_put_proto(il_out_var_id(6), kt, tauzz_v(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -473,5 +523,5 @@
      call abort_gcm(modname,abort_message,1)
    endif
-   call prism_put_proto(il_out_var_id(7), kt, windsp, ierror)
+   call prism_put_proto(il_out_var_id(7), kt, windsp(istart:iend), ierror)
    IF (ierror .ne. PRISM_Ok .and. ierror.ne.PRISM_Sent .and. ierror.ne.PRISM_ToRest &
  &     .and. ierror.ne.PRISM_LocTrans .and. ierror.ne.PRISM_Output .and. &
@@ -483,9 +533,11 @@
 
    if (last) then
-     call prism_terminate_proto(ierror)
-     IF (ierror .ne. PRISM_Ok) THEN
-       abort_message=' Probleme dans prism_terminate_proto '
-       call abort_gcm(modname,abort_message,1)
-     endif
+     IF (monocpu) THEN 
+       call prism_terminate_proto(ierror)
+         IF (ierror .ne. PRISM_Ok) THEN
+         abort_message=' Probleme dans prism_terminate_proto '
+         call abort_gcm(modname,abort_message,1)
+       endif
+     ENDIF
    endif
 
Index: /LMDZ4/trunk/libf/phylmd/orbite.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/orbite.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/orbite.F	(revision 766)
@@ -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/trunk/libf/phylmd/orografi.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/orografi.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/orografi.F	(revision 766)
@@ -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
@@ -132,4 +133,5 @@
      r                 , pvom,pvol,pte )
 
+      USE dimphy
       implicit none
 
@@ -181,6 +183,6 @@
 c
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOEGWD.h"
@@ -191,5 +193,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
@@ -259,5 +262,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
@@ -466,9 +469,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"
@@ -934,7 +938,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"
@@ -1068,4 +1073,5 @@
 C     PASSAGE OF THE NEW GWDRAG TO I.F.S. (F. LOTT, 22/11/93)
 C-----------------------------------------------------------------------
+      USE dimphy
       implicit none
 C
@@ -1073,6 +1079,6 @@
 C
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 #include "YOEGWD.h"
@@ -1299,4 +1305,5 @@
      s                   d_t, d_u, d_v)
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -1316,6 +1323,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
@@ -1439,9 +1446,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"
@@ -1473,6 +1481,7 @@
 C*       0.2   LOCAL ARRAYS
 C              ------------
-      logical lifthigh
-      integer klevm1, jl, ilevh, jk
+      logical lifthigh, ll1
+cym      integer klevm1, jl, ilevh, jk
+      integer  jl, ilevh, jk
       real zcons1, ztmst, zrtmst,zpi, zhgeo
       real zdelp, zslow, zsqua, zscav, zbet
@@ -1497,5 +1506,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
@@ -1698,5 +1707,9 @@
       RETURN
       END
+
+
       SUBROUTINE SUGWD(NLON,NLEV,paprs,pplay)
+      USE dimphy
+c      USE parallel
 C
 C**** *SUGWD* INITIALIZE COMMON YOEGWD CONTROLLING GRAVITY WAVE DRAG
@@ -1751,4 +1764,9 @@
       REAL pplay(nlon,nlev)
       real zpr,zstra,zsigt,zpm1r
+      REAL,SAVE,ALLOCATABLE :: pplay_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: paprs_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: pplay_glo(:,:)
+      REAL,SAVE,ALLOCATABLE :: paprs_glo(:,:)
+
 C
 C*       1.    SET THE VALUES OF THE PARAMETERS
@@ -1766,14 +1784,41 @@
 cold  ZSIGT=0.85
 C
+c$OMP MASTER
+      ALLOCATE(pplay_mpi(klon_mpi,nlev))
+      ALLOCATE(paprs_mpi(klon_mpi,nlev+1))
+      ALLOCATE(pplay_glo(klon2,nlev))
+      ALLOCATE(paprs_glo(klon2,nlev+1))
+c$OMP END MASTER
+c$OMP BARRIER
+
+      CALL GatherField_omp(pplay,pplay_mpi,nlev)      
+      CALL GatherField_omp(paprs,paprs_mpi,nlev+1)
+
+c$OMP MASTER      
+      CALL  AllGatherField(pplay_mpi,pplay_glo,nlev)
+      CALL  AllGatherField(paprs_mpi,paprs_glo,nlev+1)
+c$OMP END MASTER
+c$OMP BARRIER
+      
       DO 110 JK=1,NLEV
-      ZPM1R=pplay(nlon/2,jk)/paprs(nlon/2,1) 
+      ZPM1R=pplay_glo(klon2/2,jk)/paprs_glo(klon2/2,1) 
       IF(ZPM1R.GE.ZSIGT)THEN
          nktopg=JK
       ENDIF
-      ZPM1R=pplay(nlon/2,jk)/paprs(nlon/2,1) 
+      ZPM1R=pplay_glo(klon2/2,jk)/paprs_glo(klon2/2,1) 
       IF(ZPM1R.GE.ZSTRA)THEN
          NSTRA=JK
       ENDIF
   110 CONTINUE
+
+c$OMP BARRIER
+c$OMP MASTER
+      DEALLOCATE(pplay_mpi)
+      DEALLOCATE(paprs_mpi)
+      DEALLOCATE(pplay_glo)
+      DEALLOCATE(paprs_glo)
+c$OMP END MASTER
+c$OMP BARRIER
+
 c
 c  inversion car dans orodrag on compte les niveaux a l'envers
Index: /LMDZ4/trunk/libf/phylmd/ozonecm.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ozonecm.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ozonecm.F	(revision 766)
@@ -3,4 +3,5 @@
 !
       SUBROUTINE ozonecm(rjour, rlat, paprs, o3)
+      USE dimphy
       IMPLICIT none
 C
@@ -19,6 +20,6 @@
 C
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "clesphys.h"
 #include "YOMCST.h"
@@ -33,4 +34,5 @@
       REAL an, unit, zo3q3
       SAVE an, unit, zo3q3
+c$OMP THREADPRIVATE(an, unit, zo3q3)
       REAL mu,gms, zslat, zsint, zcost, z, ppm, qpm, a
       REAL asec, bsec, aprim, zo3a3
Index: /LMDZ4/trunk/libf/phylmd/phyetat0.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/phyetat0.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/phyetat0.F	(revision 766)
@@ -5,13 +5,16 @@
 c
       SUBROUTINE phyetat0 (fichnom,dtime,co2_ppm_etat0,solaire_etat0,
-     .            rlat,rlon, pctsrf, tsol,tsoil,
+     .            rlat_p,rlon_p, pctsrf_p, tsol_p,tsoil_p,
 cIM "slab" ocean
-     .           ocean, tslab,seaice,
-     .           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)
+     .           ocean, tslab_p,seaice_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_p, 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======================================================================
@@ -20,5 +23,5 @@
 c======================================================================
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "netcdf.inc"
 #include "indicesol.h"
@@ -30,7 +33,45 @@
       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 tslab_p(klon2), seaice_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,SAVE ::  ancien_ok
+      LOGICAL ::  ancien_ok_p
+      
+      REAL zmasq(klon)
+      REAL rlat(klon), rlon(klon)
       REAL tsol(klon,nbsrf)
       REAL tsoil(klon,nsoilmx,nbsrf)
@@ -62,8 +103,46 @@
       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)
+
+      REAL,ALLOCATABLE,SAVE :: zmasq_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: rlat_mpi(:), rlon_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: tsol_mpi(:,:)
+      REAL,ALLOCATABLE,SAVE :: tsoil_mpi(:,:,:)
+      REAL,ALLOCATABLE,SAVE :: tslab_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: seaice_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: qsurf_mpi(:,:)
+      REAL,ALLOCATABLE,SAVE :: qsol_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: snow_mpi(:,:)
+      REAL,ALLOCATABLE,SAVE :: albe_mpi(:,:)
+      REAL,ALLOCATABLE,SAVE :: alblw_mpi(:,:)
+      REAL,ALLOCATABLE,SAVE :: evap_mpi(:,:)
+      REAL,ALLOCATABLE,SAVE :: radsol_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: rain_fall_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: snow_fall_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: sollw_mpi(:)
+      real,ALLOCATABLE,SAVE :: solsw_mpi(:)
+      real,ALLOCATABLE,SAVE :: fder_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: frugs_mpi(:,:)
+      REAL,ALLOCATABLE,SAVE :: agesno_mpi(:,:)
+      REAL,ALLOCATABLE,SAVE :: zmea_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: zstd_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: zsig_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: zgam_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: zthe_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: zpic_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: zval_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: rugsrel_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: pctsrf_mpi(:, :)
+      REAL,ALLOCATABLE,SAVE :: run_off_lic_0_mpi(:)
+      REAL,ALLOCATABLE,SAVE :: t_ancien_mpi(:,:)
+      REAL,ALLOCATABLE,SAVE :: q_ancien_mpi(:,:)
+      real,ALLOCATABLE,SAVE :: rnebcon_mpi(:,:)
+      real,ALLOCATABLE,SAVE :: clwcon_mpi(:,:)
+      real,ALLOCATABLE,SAVE :: ratqs_mpi(:,:)
+           
 
       CHARACTER*6 ocean
@@ -80,10 +159,18 @@
       PARAMETER (length=100)
       REAL tab_cntrl(length), tabcntr0(length)
+      REAL,SAVE :: tab_cntrl_omp(length)
       CHARACTER*7 str7
       CHARACTER*2 str2
+      real iolat(jjm+1)
 c
 c Ouvrir le fichier contenant l'etat initial:
 c
-      print*,'fichnom',fichnom
+
+c$OMP MASTER
+      print *,'MASTER -x , omp_rank=',omp_rank
+c$OMP END MASTER
+
+c$OMP MASTER
+      print*,'fichnom ',fichnom
       ierr = NF_OPEN (fichnom, NF_NOWRITE,nid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -92,7 +179,9 @@
         CALL ABORT
       ENDIF
+c$OMP END MASTER
 c
 c Lecture des parametres de controle:
 c
+c$OMP MASTER
       ierr = NF_INQ_VARID (nid, "controle", nvarid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -101,13 +190,21 @@
       ENDIF
 #ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl)
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl_omp)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl_omp)
 #endif
       IF (ierr.NE.NF_NOERR) THEN
          PRINT*, 'phyetat0: Lecture echouee pour <controle>'
          CALL abort
-      ELSE
-c
+      ENDIF
+c$OMP END MASTER
+c$OMP BARRIER
+       
+       DO i = 1, length
+         tab_cntrl( i ) = tab_cntrl_omp( i )
+       ENDDO
+       
+c
+       
          DO i = 1, length
            tabcntr0( i ) = tab_cntrl( i )
@@ -177,5 +274,4 @@
          IF( tab_cntrl(12) .EQ. 1. )     ok_limitvrai = .TRUE.
 
-      ENDIF
 
       itau_phy = tab_cntrl(15)
@@ -184,4 +280,5 @@
 c Lecture des latitudes (coordonnees):
 c
+c$OMP MASTER
       ierr = NF_INQ_VARID (nid, "latitude", nvarid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -198,4 +295,5 @@
          CALL abort
       ENDIF
+
 c
 c Lecture des longitudes (coordonnees):
@@ -219,4 +317,5 @@
 C Lecture du masque terre mer
 C
+
       ierr = NF_INQ_VARID (nid, "masque", nvarid)
       IF (ierr .EQ.  NF_NOERR) THEN
@@ -235,4 +334,6 @@
 C      CALL abort
       ENDIF
+
+       
 C Lecture des fractions pour chaque sous-surface
 C
@@ -243,4 +344,5 @@
 C fraction de terre
 C
+
       ierr = NF_INQ_VARID (nid, "FTER", nvarid)
       IF (ierr .EQ.  NF_NOERR) THEN
@@ -256,6 +358,7 @@
       else
           PRINT*, 'phyetat0: Le champ <FTER> est absent'
-c$$$         CALL abort
-      ENDIF
+c@$$         CALL abort
+      ENDIF
+
 C
 C fraction de glace de terre
@@ -274,5 +377,5 @@
       else
           PRINT*, 'phyetat0: Le champ <FLIC> est absent'
-c$$$         CALL abort
+c@$$         CALL abort
       ENDIF
 C
@@ -292,6 +395,7 @@
       else
           PRINT*, 'phyetat0: Le champ <FOCE> est absent'
-c$$$         CALL abort
-      ENDIF
+c@$$         CALL abort
+      ENDIF
+
 C
 C fraction glace de mer
@@ -310,6 +414,7 @@
       else
           PRINT*, 'phyetat0: Le champ <FSIC> est absent'
-c$$$         CALL abort
-      ENDIF
+c@$$         CALL abort
+      ENDIF
+
 C
 C  Verification de l'adequation entre le masque et les sous-surfaces
@@ -333,7 +438,9 @@
         ENDIF 
       END DO 
+
 C
 c Lecture des temperatures du sol:
 c
+
       ierr = NF_INQ_VARID (nid, "TS", nvarid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -360,4 +467,5 @@
              CALL abort
            ENDIF
+
            xmin = 1.0E+20
            xmax = -1.0E+20
@@ -393,4 +501,5 @@
          ENDDO
       ENDIF
+
 c
 c Lecture des temperatures du sol profond:
@@ -557,5 +666,5 @@
           PRINT*, '          Valeur par defaut nulle'
           qsol(:)=0.
-c$$$         CALL abort
+c@$$         CALL abort
       ENDIF
       xmin = 1.0E+20
@@ -886,4 +995,9 @@
       PRINT*,'Rayonnement IF au sol sollw:', xmin, xmax
 
+c$OMP END MASTER
+
+
+c$OMP MASTER
+
 c
 c Lecture derive des flux:
@@ -1280,4 +1394,5 @@
       ENDIF
 c
+      clwcon=0.
       ierr = NF_INQ_VARID (nid, "CLWCON", nvarid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -1302,4 +1417,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
@@ -1344,4 +1460,5 @@
 c Lecture ratqs
 c
+       ratqs=0.
       ierr = NF_INQ_VARID (nid, "RATQS", nvarid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -1394,4 +1511,170 @@
       ierr = NF_CLOSE(nid)
 c
+c$OMP END MASTER
+
+c$OMP MASTER
+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))
+       
+      print *,'Allocated ??',allocated(zmasq_mpi)
+      print *,'klon_mpi',klon_mpi
+      print *,'omp_rank',omp_rank
+      ALLOCATE( zmasq_mpi(klon_mpi))
+      ALLOCATE( rlat_mpi(klon_mpi), rlon_mpi(klon_mpi))
+      ALLOCATE( tsol_mpi(klon_mpi,nbsrf))
+      ALLOCATE( tsoil_mpi(klon_mpi,nsoilmx,nbsrf))
+      ALLOCATE( tslab_mpi(klon_mpi))
+      ALLOCATE( seaice_mpi(klon_mpi))
+      ALLOCATE( qsurf_mpi(klon_mpi,nbsrf))
+      ALLOCATE( qsol_mpi(klon_mpi))
+      ALLOCATE( snow_mpi(klon_mpi,nbsrf))
+      ALLOCATE( albe_mpi(klon_mpi,nbsrf))
+      ALLOCATE( alblw_mpi(klon_mpi,nbsrf))
+      ALLOCATE( evap_mpi(klon_mpi,nbsrf))
+      ALLOCATE( radsol_mpi(klon_mpi))
+      ALLOCATE( rain_fall_mpi(klon_mpi))
+      ALLOCATE( snow_fall_mpi(klon_mpi))
+      ALLOCATE( sollw_mpi(klon_mpi))
+      ALLOCATE( solsw_mpi(klon_mpi))
+      ALLOCATE( fder_mpi(klon_mpi))
+      ALLOCATE( frugs_mpi(klon_mpi,nbsrf))
+      ALLOCATE( agesno_mpi(klon_mpi,nbsrf))
+      ALLOCATE( zmea_mpi(klon_mpi))
+      ALLOCATE( zstd_mpi(klon_mpi))
+      ALLOCATE( zsig_mpi(klon_mpi))
+      ALLOCATE( zgam_mpi(klon_mpi))
+      ALLOCATE( zthe_mpi(klon_mpi))
+      ALLOCATE( zpic_mpi(klon_mpi))
+      ALLOCATE( zval_mpi(klon_mpi))
+      ALLOCATE( rugsrel_mpi(klon_mpi))
+      ALLOCATE( pctsrf_mpi(klon_mpi, nbsrf))
+      ALLOCATE( run_off_lic_0_mpi(klon_mpi))
+      ALLOCATE( t_ancien_mpi(klon_mpi,klev))
+      ALLOCATE( q_ancien_mpi(klon_mpi,klev))
+      ALLOCATE( rnebcon_mpi(klon_mpi,klev))
+      ALLOCATE( clwcon_mpi(klon_mpi,klev))
+      ALLOCATE( ratqs_mpi(klon_mpi,klev))
+      	
+      call ScatterField( rlat,rlat_mpi,1)
+      call ScatterField( rlon,rlon_mpi,1)
+      call ScatterField( tsol,tsol_mpi,nbsrf)
+      call ScatterField( tsoil,tsoil_mpi,nsoilmx*nbsrf)
+      call ScatterField( tslab,tslab_mpi,1)
+      call ScatterField( seaice,seaice_mpi,1)
+      call ScatterField( qsurf,qsurf_mpi,nbsrf)
+      call ScatterField( qsol,qsol_mpi,1)
+      call ScatterField( snow,snow_mpi,nbsrf)
+      call ScatterField( albe,albe_mpi,nbsrf)
+      call ScatterField( alblw,alblw_mpi,nbsrf)
+      call ScatterField( evap,evap_mpi,nbsrf)
+      call ScatterField( radsol,radsol_mpi,1)
+      call ScatterField( rain_fall,rain_fall_mpi,1)
+      call ScatterField( snow_fall,snow_fall_mpi,1)
+      call ScatterField( sollw,sollw_mpi,1)
+      call ScatterField( solsw,solsw_mpi,1)
+      call ScatterField( fder,fder_mpi,1)
+      call ScatterField( frugs,frugs_mpi,nbsrf)
+      call ScatterField( agesno,agesno_mpi,nbsrf)
+      call ScatterField( zmea,zmea_mpi,1)
+      call ScatterField( zstd,zstd_mpi,1)
+      call ScatterField( zsig,zsig_mpi,1)
+      call ScatterField( zgam,zgam_mpi,1)
+      call ScatterField( zthe,zthe_mpi,1)
+      call ScatterField( zpic,zpic_mpi,1)
+      call ScatterField( zval,zval_mpi,1)
+      call ScatterField( rugsrel,rugsrel_mpi,1)
+      call ScatterField( pctsrf,pctsrf_mpi, nbsrf)
+      call ScatterField( run_off_lic_0,run_off_lic_0_mpi,1)
+      call ScatterField( t_ancien,t_ancien_mpi,klev)
+      call ScatterField( q_ancien,q_ancien_mpi,klev)
+      call ScatterField( rnebcon,rnebcon_mpi,klev)
+      call ScatterField( clwcon,clwcon_mpi,klev)
+      call ScatterField( ratqs,ratqs_mpi,klev)
+      call ScatterField( zmasq,zmasq_mpi,1)
+c$OMP END MASTER
+c$OMP BARRIER
+      call ScatterField_omp( rlat_mpi,rlat_p,1)
+      call ScatterField_omp( rlon_mpi,rlon_p,1)
+      call ScatterField_omp( tsol_mpi,tsol_p,nbsrf)
+      call ScatterField_omp( tsoil_mpi,tsoil_p,nsoilmx*nbsrf)
+      call ScatterField_omp( tslab_mpi,tslab_p,1)
+      call ScatterField_omp( seaice_mpi,seaice_p,1)
+      call ScatterField_omp( qsurf_mpi,qsurf_p,nbsrf)
+      call ScatterField_omp( qsol_mpi,qsol_p,1)
+      call ScatterField_omp( snow_mpi,snow_p,nbsrf)
+      call ScatterField_omp( albe_mpi,albe_p,nbsrf)
+      call ScatterField_omp( alblw_mpi,alblw_p,nbsrf)
+      call ScatterField_omp( evap_mpi,evap_p,nbsrf)
+      call ScatterField_omp( radsol_mpi,radsol_p,1)
+      call ScatterField_omp( rain_fall_mpi,rain_fall_p,1)
+      call ScatterField_omp( snow_fall_mpi,snow_fall_p,1)
+      call ScatterField_omp( sollw_mpi,sollw_p,1)
+      call ScatterField_omp( solsw_mpi,solsw_p,1)
+      call ScatterField_omp( fder_mpi,fder_p,1)
+      call ScatterField_omp( frugs_mpi,frugs_p,nbsrf)
+      call ScatterField_omp( agesno_mpi,agesno_p,nbsrf)
+      call ScatterField_omp( zmea_mpi,zmea_p,1)
+      call ScatterField_omp( zstd_mpi,zstd_p,1)
+      call ScatterField_omp( zsig_mpi,zsig_p,1)
+      call ScatterField_omp( zgam_mpi,zgam_p,1)
+      call ScatterField_omp( zthe_mpi,zthe_p,1)
+      call ScatterField_omp( zpic_mpi,zpic_p,1)
+      call ScatterField_omp( zval_mpi,zval_p,1)
+      call ScatterField_omp( rugsrel_mpi,rugsrel_p,1)
+      call ScatterField_omp( pctsrf_mpi,pctsrf_p, nbsrf)
+      call ScatterField_omp( run_off_lic_0_mpi,run_off_lic_0_p,1)
+      call ScatterField_omp( t_ancien_mpi,t_ancien_p,klev)
+      call ScatterField_omp( q_ancien_mpi,q_ancien_p,klev)
+      call ScatterField_omp( rnebcon_mpi,rnebcon_p,klev)
+      call ScatterField_omp( clwcon_mpi,clwcon_p,klev)
+      call ScatterField_omp( ratqs_mpi,ratqs_p,klev)
+      call ScatterField_omp( zmasq_mpi,zmasq_p,1)
+      ancien_ok_p=ancien_ok
+
+c$OMP MASTER
+      DEALLOCATE( zmasq_mpi)
+      DEALLOCATE( rlat_mpi, rlon_mpi)
+      DEALLOCATE( tsol_mpi)
+      DEALLOCATE( tsoil_mpi)
+      DEALLOCATE( tslab_mpi)
+      DEALLOCATE( seaice_mpi)
+      DEALLOCATE( qsurf_mpi)
+      DEALLOCATE( qsol_mpi)
+      DEALLOCATE( snow_mpi)
+      DEALLOCATE( albe_mpi)
+      DEALLOCATE( alblw_mpi)
+      DEALLOCATE( evap_mpi)
+      DEALLOCATE( radsol_mpi)
+      DEALLOCATE( rain_fall_mpi)
+      DEALLOCATE( snow_fall_mpi)
+      DEALLOCATE( sollw_mpi)
+      DEALLOCATE( solsw_mpi)
+      DEALLOCATE( fder_mpi)
+      DEALLOCATE( frugs_mpi)
+      DEALLOCATE( agesno_mpi)
+      DEALLOCATE( zmea_mpi)
+      DEALLOCATE( zstd_mpi)
+      DEALLOCATE( zsig_mpi)
+      DEALLOCATE( zgam_mpi)
+      DEALLOCATE( zthe_mpi)
+      DEALLOCATE( zpic_mpi)
+      DEALLOCATE( zval_mpi)
+      DEALLOCATE( rugsrel_mpi)
+      DEALLOCATE( pctsrf_mpi)
+      DEALLOCATE( run_off_lic_0_mpi)
+      DEALLOCATE( t_ancien_mpi)
+      DEALLOCATE( q_ancien_mpi)
+      DEALLOCATE( rnebcon_mpi)
+      DEALLOCATE( clwcon_mpi)   
+
+c$OMP END MASTER
+c$OMP BARRIER
+
       RETURN
       END
Index: /LMDZ4/trunk/libf/phylmd/phyredem.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/phyredem.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/phyredem.F	(revision 766)
@@ -4,14 +4,14 @@
 c
       SUBROUTINE phyredem (fichnom,dtime,radpas,
-     .           rlat,rlon, pctsrf,tsol,tsoil,
+     .           rlat_p,rlon_p, pctsrf_p,tsol_p,tsoil_p,
 cIM "slab" ocean
      .           tslab,seaice,
-     .           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)
+     .           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======================================================================
@@ -19,6 +19,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"
@@ -31,37 +31,69 @@
       REAL dtime
       INTEGER radpas
-      REAL rlat(klon), rlon(klon)
-      REAL tsol(klon,nbsrf)
-      REAL tsoil(klon,nsoilmx,nbsrf)
+      REAL rlat_p(klon), rlon_p(klon)
+      REAL tsol_p(klon,nbsrf)
+      REAL tsoil_p(klon,nsoilmx,nbsrf)
 cIM "slab" ocean
-      REAL tslab(klon), seaice(klon)
-      REAL qsurf(klon,nbsrf)
-      REAL qsol(klon)
-      REAL snow(klon,nbsrf)
-      REAL albedo(klon,nbsrf)
+      REAL tslab_p(klon), seaice_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 run_off_lic_0(klon)
+      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 tslab(klon2), seaice(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(klon2)
+      REAL masq(klon2)
 c
       INTEGER nid, nvarid, idim1, idim2, idim3
@@ -75,4 +107,188 @@
       CHARACTER*2 str2
 c
+      REAL,SAVE,ALLOCATABLE :: rlat_mpi(:), rlon_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: tsol_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: tsoil_mpi(:,:,:)
+      REAL,SAVE,ALLOCATABLE :: tslab_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: seaice_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: qsurf_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: qsol_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: snow_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: albedo_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: alblw_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: evap_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: rain_fall_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: snow_fall_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: solsw_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: sollw_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: fder_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: radsol_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: frugs_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: agesno_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: zmea_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: zstd_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: zsig_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: zgam_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: zthe_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: zpic_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: zval_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: rugsrel_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: pctsrf_mpi(:, :)
+      REAL,SAVE,ALLOCATABLE :: t_ancien_mpi(:,:), q_ancien_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: clwcon_mpi(:,:),rnebcon_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: ratqs_mpi(:,:)
+      REAL,SAVE,ALLOCATABLE :: run_off_lic_0_mpi(:)
+      REAL,SAVE,ALLOCATABLE :: masq_mpi(:)
+      
+c$OMP MASTER
+      ALLOCATE( rlat_mpi(klon_mpi), rlon_mpi(klon_mpi))
+      ALLOCATE( tsol_mpi(klon_mpi,nbsrf))
+      ALLOCATE( tsoil_mpi(klon_mpi,nsoilmx,nbsrf))
+      ALLOCATE( tslab_mpi(klon_mpi))
+      ALLOCATE( seaice_mpi(klon_mpi))
+      ALLOCATE( qsurf_mpi(klon_mpi,nbsrf))
+      ALLOCATE( qsol_mpi(klon_mpi))
+      ALLOCATE( snow_mpi(klon_mpi,nbsrf))
+      ALLOCATE( albedo_mpi(klon_mpi,nbsrf))
+      ALLOCATE( alblw_mpi(klon_mpi,nbsrf))
+      ALLOCATE( evap_mpi(klon_mpi,nbsrf))
+      ALLOCATE( rain_fall_mpi(klon_mpi))
+      ALLOCATE( snow_fall_mpi(klon_mpi))
+      ALLOCATE( solsw_mpi(klon_mpi))
+      ALLOCATE( sollw_mpi(klon_mpi))
+      ALLOCATE( fder_mpi(klon_mpi))
+      ALLOCATE( radsol_mpi(klon_mpi))
+      ALLOCATE( frugs_mpi(klon_mpi,nbsrf))
+      ALLOCATE( agesno_mpi(klon_mpi,nbsrf))
+      ALLOCATE( zmea_mpi(klon_mpi))
+      ALLOCATE( zstd_mpi(klon_mpi))
+      ALLOCATE( zsig_mpi(klon_mpi))
+      ALLOCATE( zgam_mpi(klon_mpi))
+      ALLOCATE( zthe_mpi(klon_mpi))
+      ALLOCATE( zpic_mpi(klon_mpi))
+      ALLOCATE( zval_mpi(klon_mpi))
+      ALLOCATE( rugsrel_mpi(klon_mpi))
+      ALLOCATE( pctsrf_mpi(klon_mpi, nbsrf))
+      ALLOCATE( t_ancien_mpi(klon_mpi,klev))
+      ALLOCATE( q_ancien_mpi(klon_mpi,klev))
+      ALLOCATE( clwcon_mpi(klon_mpi,klev),rnebcon_mpi(klon_mpi,klev))
+      ALLOCATE( ratqs_mpi(klon_mpi,klev))
+      ALLOCATE( run_off_lic_0_mpi(klon_mpi))
+      ALLOCATE( masq_mpi(klon_mpi))
+c$OMP END MASTER
+c$OMP BARRIER      
+
+      call GatherField_omp( rlat_p,rlat_mpi,1)
+      call GatherField_omp( rlon_p,rlon_mpi,1)
+      call GatherField_omp( tsol_p,tsol_mpi,nbsrf)
+      call GatherField_omp( tsoil_p,tsoil_mpi,nsoilmx*nbsrf)
+      call GatherField_omp( tslab_p,tslab_mpi,1)
+      call GatherField_omp( seaice_p,seaice_mpi,1)
+      call GatherField_omp( qsurf_p,qsurf_mpi,nbsrf)
+      call GatherField_omp( qsol_p,qsol_mpi,1)
+      call GatherField_omp( snow_p,snow_mpi,nbsrf)
+      call GatherField_omp( albedo_p,albedo_mpi,nbsrf)
+      call GatherField_omp( alblw_p,alblw_mpi,nbsrf)
+      call GatherField_omp( evap_p,evap_mpi,nbsrf)
+      call GatherField_omp( radsol_p,radsol_mpi,1)
+      call GatherField_omp( rain_fall_p,rain_fall_mpi,1)
+      call GatherField_omp( snow_fall_p,snow_fall_mpi,1)
+      call GatherField_omp( sollw_p,sollw_mpi,1)
+      call GatherField_omp( solsw_p,solsw_mpi,1)
+      call GatherField_omp( fder_p,fder_mpi,1)
+      call GatherField_omp( frugs_p,frugs_mpi,nbsrf)
+      call GatherField_omp( agesno_p,agesno_mpi,nbsrf)
+      call GatherField_omp( zmea_p,zmea_mpi,1)
+      call GatherField_omp( zstd_p,zstd_mpi,1)
+      call GatherField_omp( zsig_p,zsig_mpi,1)
+      call GatherField_omp( zgam_p,zgam_mpi,1)
+      call GatherField_omp( zthe_p,zthe_mpi,1)
+      call GatherField_omp( zpic_p,zpic_mpi,1)
+      call GatherField_omp( zval_p,zval_mpi,1)
+      call GatherField_omp( rugsrel_p,rugsrel_mpi,1)
+      call GatherField_omp( pctsrf_p,pctsrf_mpi, nbsrf)
+      call GatherField_omp( run_off_lic_0_p,run_off_lic_0_mpi,1)
+      call GatherField_omp( t_ancien_p,t_ancien_mpi,klev)
+      call GatherField_omp( q_ancien_p,q_ancien_mpi,klev)
+      call GatherField_omp( rnebcon_p,rnebcon_mpi,klev)
+      call GatherField_omp( clwcon_p,clwcon_mpi,klev)
+      call GatherField_omp( ratqs_p,ratqs_mpi,klev)
+      call GatherField_omp( zmasq,masq_mpi,1)
+
+c$OMP MASTER      
+      call GatherField( rlat_mpi,rlat,1)
+      call GatherField( rlon_mpi,rlon,1)
+      call GatherField( tsol_mpi,tsol,nbsrf)
+      call GatherField( tsoil_mpi,tsoil,nsoilmx*nbsrf)
+      call GatherField( tslab_mpi,tslab,1)
+      call GatherField( seaice_mpi,seaice,1)
+      call GatherField( qsurf_mpi,qsurf,nbsrf)
+      call GatherField( qsol_mpi,qsol,1)
+      call GatherField( snow_mpi,snow,nbsrf)
+      call GatherField( albedo_mpi,albedo,nbsrf)
+      call GatherField( alblw_mpi,alblw,nbsrf)
+      call GatherField( evap_mpi,evap,nbsrf)
+      call GatherField( radsol_mpi,radsol,1)
+      call GatherField( rain_fall_mpi,rain_fall,1)
+      call GatherField( snow_fall_mpi,snow_fall,1)
+      call GatherField( sollw_mpi,sollw,1)
+      call GatherField( solsw_mpi,solsw,1)
+      call GatherField( fder_mpi,fder,1)
+      call GatherField( frugs_mpi,frugs,nbsrf)
+      call GatherField( agesno_mpi,agesno,nbsrf)
+      call GatherField( zmea_mpi,zmea,1)
+      call GatherField( zstd_mpi,zstd,1)
+      call GatherField( zsig_mpi,zsig,1)
+      call GatherField( zgam_mpi,zgam,1)
+      call GatherField( zthe_mpi,zthe,1)
+      call GatherField( zpic_mpi,zpic,1)
+      call GatherField( zval_mpi,zval,1)
+      call GatherField( rugsrel_mpi,rugsrel,1)
+      call GatherField( pctsrf_mpi,pctsrf, nbsrf)
+      call GatherField( run_off_lic_0_mpi,run_off_lic_0,1)
+      call GatherField( t_ancien_mpi,t_ancien,klev)
+      call GatherField( q_ancien_mpi,q_ancien,klev)
+      call GatherField( rnebcon_mpi,rnebcon,klev)
+      call GatherField( clwcon_mpi,clwcon,klev)
+      call GatherField( ratqs_mpi,ratqs,klev)
+      call GatherField( masq_mpi,masq,1)
+      
+      DEALLOCATE( rlat_mpi, rlon_mpi)
+      DEALLOCATE( tsol_mpi)
+      DEALLOCATE( tsoil_mpi)
+      DEALLOCATE( tslab_mpi)
+      DEALLOCATE( seaice_mpi)
+      DEALLOCATE( qsurf_mpi)
+      DEALLOCATE( qsol_mpi)
+      DEALLOCATE( snow_mpi)
+      DEALLOCATE( albedo_mpi)
+      DEALLOCATE( alblw_mpi)
+      DEALLOCATE( evap_mpi)
+      DEALLOCATE( rain_fall_mpi)
+      DEALLOCATE( snow_fall_mpi)
+      DEALLOCATE( solsw_mpi)
+      DEALLOCATE( sollw_mpi)
+      DEALLOCATE( fder_mpi)
+      DEALLOCATE( radsol_mpi)
+      DEALLOCATE( frugs_mpi)
+      DEALLOCATE( agesno_mpi)
+      DEALLOCATE( zmea_mpi)
+      DEALLOCATE( zstd_mpi)
+      DEALLOCATE( zsig_mpi)
+      DEALLOCATE( zgam_mpi)
+      DEALLOCATE( zthe_mpi)
+      DEALLOCATE( zpic_mpi)
+      DEALLOCATE( zval_mpi)
+      DEALLOCATE( rugsrel_mpi)
+      DEALLOCATE( pctsrf_mpi)
+      DEALLOCATE( t_ancien_mpi)
+      DEALLOCATE( q_ancien_mpi)
+      DEALLOCATE( clwcon_mpi,rnebcon_mpi)
+      DEALLOCATE( ratqs_mpi)
+      DEALLOCATE( run_off_lic_0_mpi)
+      DEALLOCATE( masq_mpi)
+
+      if (phy_rank==0) then
+      
       ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
       IF (ierr.NE.NF_NOERR) THEN
@@ -86,6 +302,6 @@
 c
       ierr = NF_DEF_DIM (nid, "index", length, idim1)
-      ierr = NF_DEF_DIM (nid, "points_physiques", klon, idim2)
-      ierr = NF_DEF_DIM (nid, "horizon_vertical", klon*klev, idim3)
+      ierr = NF_DEF_DIM (nid, "points_physiques", klon2, idim2)
+      ierr = NF_DEF_DIM (nid, "horizon_vertical", klon2*klev, idim3)
 c
       ierr = NF_ENDDEF(nid)
@@ -168,7 +384,7 @@
       ierr = NF_ENDDEF(nid)
 #ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zmasq)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,zmasq)
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,masq)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,masq)
 #endif      
 c BP ajout des fraction de chaque sous-surface
@@ -186,7 +402,7 @@
       ierr = NF_ENDDEF(nid)
 #ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pctsrf(1 : klon, is_ter))
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,pctsrf(1 : klon, is_ter))
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pctsrf(1 : klon2, is_ter))
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,pctsrf(1 : klon2, is_ter))
 #endif
 C 
@@ -203,7 +419,7 @@
       ierr = NF_ENDDEF(nid)
 #ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pctsrf(1 : klon,is_lic))
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,pctsrf(1 : klon, is_lic))
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pctsrf(1 : klon2,is_lic))
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,pctsrf(1 : klon2, is_lic))
 #endif
 C
@@ -220,7 +436,7 @@
       ierr = NF_ENDDEF(nid)
 #ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pctsrf(1 : klon, is_oce))
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,pctsrf(1 : klon, is_oce))
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pctsrf(1 : klon2, is_oce))
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,pctsrf(1 : klon2, is_oce))
 #endif
 C
@@ -237,7 +453,7 @@
       ierr = NF_ENDDEF(nid)
 #ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pctsrf(1 : klon, is_sic))
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,pctsrf(1 : klon, is_sic))
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pctsrf(1 : klon2, is_sic))
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,pctsrf(1 : klon2, is_sic))
 #endif
 C
@@ -547,4 +763,9 @@
 #endif
 c
+       endif
+c$OMP END MASTER
+cc ----> necessaire pour eviter bug openMP sur SX6
+c$OMP MASTER
+      if (phy_rank==0) then
       DO nsrf = 1, nbsrf
         IF (nsrf.LE.99) THEN
@@ -799,4 +1020,6 @@
       ierr = NF_CLOSE(nid)
 c
+      endif   ! phy_rank==0
+c$OMP END MASTER
       RETURN
       END
Index: /LMDZ4/trunk/libf/phylmd/physiq.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/physiq.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/physiq.F	(revision 766)
@@ -3,4 +3,6 @@
 !
 c
+c#define IO_DEBUG
+
       SUBROUTINE physiq (nlon,nlev,nqmax,
      .            debut,lafin,rjourvrai,gmtime,pdtphys,
@@ -16,12 +18,10 @@
 
       USE ioipsl
-      USE histcom
-#ifdef INCA
-      USE chemshut
-      USE species_names
-#ifdef INCA_CH4
-!      USE obs_pos
-#endif
-#endif
+      USE comgeomphy
+      USE write_field_phy
+      USE dimphy
+      USE iophy
+      USE misc_mod, mydebug=>debug
+      USE vampir
       IMPLICIT none
 c======================================================================
@@ -37,10 +37,10 @@
 c   CLEFS CPP POUR LES IO
 c   =====================
-#define histins
-#define histhf
-#define histday
+c#define histhf
+c#define histday
 #define histmth
-#define histmthNMC
-#define histISCCP
+c#define histins
+c#define histmthNMC
+c#define histISCCP
 c======================================================================
 c    modif   ( P. Le Van ,  12/10/98 )
@@ -80,5 +80,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"
@@ -88,5 +90,5 @@
 #include "logic.h"
 #include "temps.h"
-#include "comgeomphy.h"
+cym#include "comgeomphy.h"
 #include "advtrac.h"
 #include "iniprint.h"
@@ -106,4 +108,5 @@
 #include "oasis.h"
       INTEGER,SAVE :: npas, nexca
+c$OMP THREADPRIVATE(npas, nexca)
       logical rnpb
 #ifdef INCA
@@ -115,9 +118,10 @@
       character*6 ocean
       SAVE ocean
-
+c$OMP THREADPRIVATE(ocean)
 c      parameter (ocean = 'force ')
 c     parameter (ocean = 'couple')
       logical ok_ocean
       SAVE ok_ocean
+c$OMP THREADPRIVATE(ok_ocean)
 c
 cIM "slab" ocean
@@ -137,4 +141,5 @@
       logical ok_veget
       save ok_veget
+c$OMP THREADPRIVATE(ok_veget)
 c     parameter (ok_veget = .true.)
 c      parameter (ok_veget = .false.)
@@ -156,12 +161,15 @@
       LOGICAL ok_journe ! sortir le fichier journalier
       save ok_journe
+c$OMP THREADPRIVATE(ok_journe)
 c      PARAMETER (ok_journe=.true.)
 c
       LOGICAL ok_mensuel ! sortir le fichier mensuel
       save ok_mensuel
+c$OMP THREADPRIVATE(ok_mensuel)
 c      PARAMETER (ok_mensuel=.true.)
 c
       LOGICAL ok_instan ! sortir le fichier instantane
       save ok_instan
+c$OMP THREADPRIVATE(ok_instan)
 c      PARAMETER (ok_instan=.true.)
 c
@@ -172,6 +180,7 @@
       REAL fm_therm(klon,klev+1)
       REAL entr_therm(klon,klev)
-      real q2(klon,klev+1,nbsrf)
-      save q2
+      real,allocatable,save :: q2(:,:,:)
+c$OMP THREADPRIVATE(q2)
+cym      save q2
 c======================================================================
 c
@@ -207,9 +216,10 @@
       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(:,:)
+c$OMP THREADPRIVATE(t_ancien, q_ancien)
+cym      SAVE t_ancien, q_ancien
       LOGICAL ancien_ok
       SAVE ancien_ok
-
+c$OMP THREADPRIVATE(ancien_ok)
       REAL d_t_dyn(klon,klev)
       REAL d_q_dyn(klon,klev)
@@ -233,6 +243,10 @@
       CHARACTER*3 ctetaSTD(nbteta)
       DATA ctetaSTD/'350','380','405'/
+      SAVE ctetaSTD
+c$OMP THREADPRIVATE(ctetaSTD)
       REAL rtetaSTD(nbteta)
       DATA rtetaSTD/350., 380., 405./
+      SAVE rtetaSTD
+c$OMP THREADPRIVATE(rtetaSTD)     
 c
       REAL PVteta(klon,nbteta)
@@ -241,26 +255,32 @@
 cMI Amip2 PV a theta constante
 
-      INTEGER klevp1, klevm1
-      PARAMETER(klevp1=klev+1,klevm1=klev-1)
-#include "raddim.h"
-c
-      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
+cym      INTEGER klevp1, klevm1
+cym      PARAMETER(klevp1=klev+1,klevm1=klev-1)
+cym#include "raddim.h"
+c
+
+      REAL,allocatable,save :: swdn0(:,:), swdn(:,:)
+      REAL,allocatable,save :: swup0(:,:), swup(:,:)
+c$OMP THREADPRIVATE(swdn0 , swdn, swup0, swup)
+cym      SAVE swdn0 , swdn, swup0, swup
+c
+      REAL,allocatable,save :: SWdn200clr(:), SWdn200(:)
+      REAL,allocatable,save :: SWup200clr(:), SWup200(:)
+c$OMP THREADPRIVATE(SWdn200clr, SWdn200, SWup200clr, SWup200)
+cym      SAVE SWdn200clr, SWdn200, SWup200clr, SWup200
+c
+      REAL,allocatable,save :: lwdn0(:,:), lwdn(:,:)
+      REAL,allocatable,save :: lwup0(:,:), lwup(:,:)
+c$OMP THREADPRIVATE(lwdn0 , lwdn, lwup0, lwup)
+cym      SAVE lwdn0 , lwdn, lwup0, lwup 
+c
+      REAL,allocatable,save :: LWdn200clr(:), LWdn200(:)
+      REAL,allocatable,save :: LWup200clr(:), LWup200(:)
+c$OMP THREADPRIVATE(LWdn200clr, LWdn200, LWup200clr, LWup200)
+cym      SAVE LWdn200clr, LWdn200, LWup200clr, LWup200
+c
+      REAL,allocatable,save :: LWdnTOA(:), LWdnTOAclr(:)
+c$OMP THREADPRIVATE(LWdnTOA, LWdnTOAclr)
+cym      SAVE LWdnTOA, LWdnTOAclr
 c
 cIM Amip2
@@ -273,8 +293,12 @@
      .60000., 50000., 40000., 30000., 25000., 20000.,
      .15000., 10000., 7000., 5000., 3000., 2000., 1000./
+      SAVE rlevstd
+c$OMP THREADPRIVATE(rlevSTD)
       CHARACTER*4 clevSTD(nlevSTD)
       DATA clevSTD/'1000','925 ','850 ','700 ','600 ',
      .'500 ','400 ','300 ','250 ','200 ','150 ','100 ',
      .'70  ','50  ','30  ','20  ','10  '/
+      SAVE clevSTD
+c$OMP THREADPRIVATE(clevSTD)
 c
       CHARACTER*3 bb2
@@ -290,15 +314,18 @@
       PARAMETER(nout=3) !nout=1 : day; =2 : mth; =3 : NMC
 c
-      REAL tsumSTD(klon,nlevSTD,nout)
-      REAL usumSTD(klon,nlevSTD,nout), vsumSTD(klon,nlevSTD,nout)
-      REAL wsumSTD(klon,nlevSTD,nout), phisumSTD(klon,nlevSTD,nout)
-      REAL qsumSTD(klon,nlevSTD,nout), rhsumSTD(klon,nlevSTD,nout)
-c
-      SAVE tsumSTD, usumSTD, vsumSTD, wsumSTD, phisumSTD, 
-     .     qsumSTD, rhsumSTD
+      REAL,SAVE,ALLOCATABLE :: tsumSTD(:,:,:)
+      REAL,SAVE,ALLOCATABLE :: usumSTD(:,:,:), vsumSTD(:,:,:)
+      REAL,SAVE,ALLOCATABLE :: wsumSTD(:,:,:), phisumSTD(:,:,:)
+      REAL,SAVE,ALLOCATABLE :: qsumSTD(:,:,:), rhsumSTD(:,:,:)
+c
+cym      SAVE tsumSTD, usumSTD, vsumSTD, wsumSTD, phisumSTD, 
+cym     .     qsumSTD, rhsumSTD
+c$OMP THREADPRIVATE(tsumSTD, usumSTD, vsumSTD, wsumSTD, phisumSTD) 
+c$OMP THREADPRIVATE(qsumSTD, rhsumSTD)
 c
       logical oknondef(klon,nlevSTD,nout)
-      real tnondef(klon,nlevSTD,nout) 
-      save tnondef
+      real,SAVE,ALLOCATABLE :: tnondef(:,:,:) 
+c$OMP THREADPRIVATE(tnondef)
+cym      save tnondef
 c
 c les produits uvSTD, vqSTD, .., T2STD sont calcules
@@ -311,8 +338,8 @@
       real wqSTD(klon,nlevSTD)
 c
-      real uvsumSTD(klon,nlevSTD,nout)
-      real vqsumSTD(klon,nlevSTD,nout)
-      real vTsumSTD(klon,nlevSTD,nout)
-      real wqsumSTD(klon,nlevSTD,nout)
+      real,save,allocatable :: uvsumSTD(:,:,:)
+      real,save,allocatable :: vqsumSTD(:,:,:)
+      real,save,allocatable :: vTsumSTD(:,:,:)
+      real,save,allocatable :: wqsumSTD(:,:,:)
 c
       real vphiSTD(klon,nlevSTD)
@@ -322,12 +349,15 @@
       real T2STD(klon,nlevSTD)
 c
-      real vphisumSTD(klon,nlevSTD,nout)
-      real wTsumSTD(klon,nlevSTD,nout)
-      real u2sumSTD(klon,nlevSTD,nout)
-      real v2sumSTD(klon,nlevSTD,nout)
-      real T2sumSTD(klon,nlevSTD,nout)
-c
-      SAVE uvsumSTD, vqsumSTD, vTsumSTD, wqsumSTD
-      SAVE vphisumSTD, wTsumSTD, u2sumSTD, v2sumSTD, T2sumSTD
+      real,save,allocatable :: vphisumSTD(:,:,:)
+      real,save,allocatable :: wTsumSTD(:,:,:)
+      real,save,allocatable :: u2sumSTD(:,:,:)
+      real,save,allocatable :: v2sumSTD(:,:,:)
+      real,save,allocatable :: T2sumSTD(:,:,:)
+c
+cym      SAVE uvsumSTD, vqsumSTD, vTsumSTD, wqsumSTD
+cym      SAVE vphisumSTD, wTsumSTD, u2sumSTD, v2sumSTD, T2sumSTD
+c$OMP THREADPRIVATE(uvsumSTD, vqsumSTD, vTsumSTD, wqsumSTD)
+c$OMP THREADPRIVATE(vphisumSTD, wTsumSTD, u2sumSTD, v2sumSTD, T2sumSTD)
+
 cMI Amip2
 c
@@ -347,5 +377,5 @@
       REAL cldt_s(klon),cldq_s(klon) !nuage total, eau liquide integree
 
-      INTEGER kp1
+      INTEGER linv, kp1
 c flwp, fiwp = Liquid Water Path & Ice Water Path (kg/m2)
 c flwc, fiwc = Liquid Water Content & Ice Water Content (kg/kg)
@@ -361,6 +391,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
@@ -382,9 +412,14 @@
       DATA ifreq_isccp/3/
       SAVE ifreq_isccp
+c$OMP THREADPRIVATE(ifreq_isccp)
       CHARACTER*5 typinout(napisccp)
       DATA typinout/'i3od'/
+      SAVE typinout
+c$OMP THREADPRIVATE(typinout)
 cIM verif boxptop BEG
       CHARACTER*1 verticaxe(napisccp)
       DATA verticaxe/'1'/ 
+      SAVE verticaxe
+c$OMP THREADPRIVATE(verticaxe)
 cIM verif boxptop END
       INTEGER nvlev(napisccp)
@@ -392,12 +427,16 @@
       REAL t1, aa
       REAL seed_re(klon,napisccp)
-      INTEGER seed_old(klon,napisccp)
-      SAVE seed_old
-      INTEGER iphy(iim,jjmp1)
+      INTEGER,ALLOCATABLE,SAVE :: seed_old(:,:)
+cym      SAVE seed_old
+c$OMP THREADPRIVATE(seed_old)
+cym !!!! A voir plus tard 
+cym      INTEGER iphy(iim,jjmp1)
 cIM parametres ISCCP END
 c
 c ncol = nb. de sous-colonnes pour chaque maille du GCM 
 c ncolmx = No. max. de sous-colonnes pour chaque maille du GCM 
-      INTEGER ncol(napisccp), ncolmx, seed(klon,napisccp)
+c      INTEGER ncol(napisccp), ncolmx, seed(klon,napisccp)
+      INTEGER,SAVE :: ncol(napisccp)
+      INTEGER ncolmx, seed(klon,napisccp)
       REAL nbsunlit(nregISCtot,klon,napisccp)  !nbsunlit : moyenne de sunlit
       PARAMETER(ncolmx=1500)
@@ -407,6 +446,7 @@
 cIM verif boxptop END
 c
-      REAL tautab(0:255)
-      INTEGER invtau(-20:45000)
+      REAL,SAVE :: tautab_omp(0:255),tautab(0:255)
+      INTEGER,SAVE :: invtau_omp(-20:45000),invtau(-20:45000)
+c$OMP THREADPRIVATE(tautab,invtau)
       REAL emsfc_lw
       PARAMETER(emsfc_lw=0.99)
@@ -456,4 +496,6 @@
       INTEGER iw, iwmax
       REAL wmin, pas_w
+c     PARAMETER(wmin=-100.,pas_w=10.,iwmax=30)
+cIM 051005     PARAMETER(wmin=-200.,pas_w=10.,iwmax=40)
       PARAMETER(wmin=-100.,pas_w=10.,iwmax=20)
       REAL o500(klon)
@@ -465,6 +507,7 @@
 
       INTEGER linv
-      INTEGER pct_ocean(klon,nbregdyn)
-      SAVE pct_ocean
+      INTEGER,ALLOCATABLE,SAVE :: pct_ocean(:,:)
+c$OMP THREADPRIVATE(pct_ocean)
+cym      SAVE pct_ocean
  
 c sorties ISCCP
@@ -472,13 +515,27 @@
       integer nid_isccp
       save nid_isccp        
+c$OMP THREADPRIVATE(nid_isccp)
+
+c     data ok_isccp,ecrit_isccp/.true.,0.125/      
+c     data ok_isccp,ecrit_isccp/.true.,1./      
+cIM 190504     data ok_isccp/.true./      
+cIM 190504 #else
+cIM 190504     data ok_isccp/.false./
+cIM 190504 #endif
 
       REAL zx_tau(kmaxm1), zx_pc(lmaxm1), zx_o500(iwmax)
       DATA zx_tau/0.0, 0.3, 1.3, 3.6, 9.4, 23., 60./
+      SAVE zx_tau
+cIM bad 151205     DATA zx_pc/50., 180., 310., 440., 560., 680., 800./
       DATA zx_pc/180., 310., 440., 560., 680., 800., 1000./
-
+      SAVE zx_pc
+c$OMP THREADPRIVATE(zx_tau,zx_pc)
 c cldtopres pression au sommet des nuages
       REAL cldtopres(lmaxm1), cldtopres3(lmax3)
       DATA cldtopres/180., 310., 440., 560., 680., 800., 1000./
       DATA cldtopres3/440., 680., 1000./
+      SAVE cldtopres,cldtopres3
+c$OMP THREADPRIVATE(cldtopres,cldtopres3)
+cIM 051005 BEG
       REAL tmp_his1_3d(iwmax,kmaxm1,lmaxm1,nbregdyn,napisccp) 
       REAL tmp_his2_3d(iwmax,kmaxm1,lmaxm1,nbregdyn,napisccp) 
@@ -492,4 +549,6 @@
       CHARACTER *3 pclev(lmaxm1)
       DATA pclev/'pc1','pc2','pc3','pc4','pc5','pc6','pc7'/
+      SAVE taulev,pclev
+c$OMP THREADPRIVATE(taulev,pclev)
 c
 c cnameisccp
@@ -545,4 +604,6 @@
      .                'pc= 680-800hPa, tau> 60.',
      .                'pc= 800-1000hPa, tau> 60.'/
+       SAVE cnameisccp
+c$OMP THREADPRIVATE(cnameisccp)
 c
 c     REAL zx_lonx7(iimx7), zx_latx7(jjmp1x7)
@@ -558,5 +619,5 @@
       integer nid_hf, nid_hf3d
       save ok_hf, nid_hf, nid_hf3d
-
+c$OMP THREADPRIVATE(ok_hf, nid_hf, nid_hf3d)
 c  QUESTION : noms de variables ?
 
@@ -566,5 +627,4 @@
       data ok_hf/.false./
 #endif
-
       INTEGER        longcles
       PARAMETER    ( longcles = 20 )
@@ -575,4 +635,5 @@
       REAL xjour
       SAVE xjour
+c$OMP THREADPRIVATE(xjour)
 c
 c
@@ -581,19 +642,25 @@
       REAL dtime
       SAVE dtime                  ! pas temporel de la physique
+c$OMP THREADPRIVATE(dtime)
 c
       INTEGER radpas
       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
-c
-      REAL rlonPOS(klon)
-      SAVE rlonPOS                ! longitudes > 0. pour chaque point
+c$OMP THREADPRIVATE(radpas)
+c
+      REAL,allocatable,save :: radsol(:)
+c$OMP THREADPRIVATE(radsol)
+cym      SAVE radsol               ! bilan radiatif au sol calcule par code radiatif
+c
+      REAL,allocatable,save :: rlat(:)
+c$OMP THREADPRIVATE(rlat)
+cym      SAVE rlat                   ! latitude pour chaque point
+c
+      REAL,allocatable,save :: rlon(:)
+c$OMP THREADPRIVATE(rlon)
+cym      SAVE rlon                   ! longitude pour chaque point
+
+      REAL,SAVE,ALLOCATABLE :: rlonPOS(:)
+c$OMP THREADPRIVATE(rlonPOS)    
+cym      SAVE rlonPOS                ! longitudes > 0. pour chaque point
 c
 cc      INTEGER iflag_con
@@ -602,4 +669,5 @@
       INTEGER itap
       SAVE itap                   ! compteur pour la physique
+c$OMP THREADPRIVATE(itap)
 c
       REAL co2_ppm_etat0
@@ -609,34 +677,46 @@
       real slp(klon) ! sea level pressure
 
-      REAL ftsol(klon,nbsrf)
-      SAVE ftsol                  ! temperature du sol
+      REAL,allocatable,save :: ftsol(:,:)
+c$OMP THREADPRIVATE(ftsol)
+cym      SAVE ftsol                  ! temperature du sol
+
 cIM
-      REAL newsst(klon) !temperature de l'ocean
-      SAVE newsst
-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,SAVE,ALLOCATABLE :: newsst(:) !temperature de l'ocean
+c$OMP THREADPRIVATE(newsst)
+cym     SAVE newsst
+c
+      REAL,allocatable,save :: ftsoil(:,:,:)
+c$OMP THREADPRIVATE(ftsoil)
+cym      SAVE ftsoil                 ! temperature dans le sol
+c
+      REAL,allocatable,save :: fevap(:,:)
+c$OMP THREADPRIVATE(fevap)
+cym      SAVE fevap                 ! evaporation
+      REAL,allocatable,save :: fluxlat(:,:)
+c$OMP THREADPRIVATE(fluxlat)
+cym      SAVE fluxlat
+c
+      REAL,allocatable,save :: deltat(:)
+c$OMP THREADPRIVATE(deltat)
+cym      SAVE deltat                 ! ecart avec la SST de reference
+c
+      REAL,allocatable,save :: fqsurf(:,:)
+c$OMP THREADPRIVATE(fqsurf)
+cym      SAVE fqsurf                 ! humidite de l'air au contact de la surface
+c
+      REAL,allocatable,save :: qsol(:)
+c$OMP THREADPRIVATE(qsol)
+cym      SAVE qsol                  ! hauteur d'eau dans le sol
+c
+      REAL,allocatable,save :: fsnow(:,:)
+c$OMP THREADPRIVATE(fsnow)
+cym      SAVE fsnow                  ! epaisseur neigeuse
+c
+      REAL,allocatable,save :: falbe(:,:)
+c$OMP THREADPRIVATE(falbe)
+cym      SAVE falbe                  ! albedo par type de surface
+      REAL,allocatable,save :: falblw(:,:)
+c$OMP THREADPRIVATE(falblw)      
+cym      SAVE falblw                 ! albedo par type de surface
 
 c
@@ -644,73 +724,94 @@
 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(:)
+c$OMP THREADPRIVATE(zmea)
+cym      SAVE zmea                   ! orographie moyenne
+c
+      REAL,allocatable,save :: zstd(:)
+c$OMP THREADPRIVATE(zstd)
+cym      SAVE zstd                   ! deviation standard de l'OESM
+c
+      REAL,allocatable,save :: zsig(:)
+c$OMP THREADPRIVATE(zsig)
+cym      SAVE zsig                   ! pente de l'OESM
+c
+      REAL,allocatable,save :: zgam(:)
+c$OMP THREADPRIVATE(zgam)
+cym      save zgam                   ! anisotropie de l'OESM
+c
+      REAL,allocatable,save :: zthe(:)
+c$OMP THREADPRIVATE(zthe)      
+cym      SAVE zthe                   ! orientation de l'OESM
+c
+      REAL,allocatable,save :: zpic(:)
+c$OMP THREADPRIVATE(zpic)
+cym      SAVE zpic                   ! Maximum de l'OESM
+c
+      REAL,allocatable,save :: zval(:)
+c$OMP THREADPRIVATE(zval)
+cym      SAVE zval                   ! Minimum de l'OESM
+c
+      REAL,allocatable,save :: rugoro(:)
+c$OMP THREADPRIVATE(rugoro)
+cym      SAVE rugoro                 ! longueur de rugosite de l'OESM
 c
 cIM 141004     REAL zulow(klon),zvlow(klon),zustr(klon), zvstr(klon)
       REAL zulow(klon),zvlow(klon)
 c
-      REAL zuthe(klon),zvthe(klon)
-      SAVE zuthe
-      SAVE zvthe
+      REAL,allocatable,save :: zuthe(:),zvthe(:)
+c$OMP THREADPRIVATE(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(:,:)
+c$OMP THREADPRIVATE(agesno)
+cym      SAVE agesno                 ! age de la neige
+c
+      REAL,allocatable,save :: alb_neig(:)
+c$OMP THREADPRIVATE(alb_neig)
+cym      SAVE alb_neig               ! albedo de la neige
+c
+      REAL,allocatable,save :: run_off_lic_0(:)
+c$OMP THREADPRIVATE(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
+c$OMP THREADPRIVATE(ema_workcbmf)
+cym      SAVE ema_workcbmf
+
+      REAL,allocatable,save :: ema_cbmf(:)       ! cloud base mass flux
+c$OMP THREADPRIVATE(ema_cbmf)
+cym      SAVE ema_cbmf
+
+      REAL,allocatable,save :: ema_pcb(:)        ! cloud base pressure
+c$OMP THREADPRIVATE(ema_pcb)
+cym      SAVE ema_pcb
+
+      REAL,allocatable,save :: ema_pct(:)        ! cloud top pressure
+c$OMP THREADPRIVATE(ema_pct)
+cym      SAVE ema_pct
 
       REAL bas, top             ! cloud base and top levels
       SAVE bas
       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
+c$OMP THREADPRIVATE(bas, top)
+
+      REAL,allocatable,save :: Ma(:,:)        ! undilute upward mass flux
+c$OMP THREADPRIVATE(Ma)
+cym      SAVE Ma
+      REAL,allocatable,save :: qcondc(:,:)    ! in-cld water content from convect
+c$OMP THREADPRIVATE(qcondc)
+cym      SAVE qcondc 
+      REAL,allocatable,save :: ema_work1(:, :), ema_work2(:, :)
+c$OMP THREADPRIVATE(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
+c$OMP THREADPRIVATE(wd)
+cym      SAVE wd       ! sb
 
 c Variables locales pour la couche limite (al1):
@@ -730,19 +831,26 @@
       REAL yu1(klon)            ! vents dans la premiere couche U
       REAL yv1(klon)            ! vents dans la premiere couche V
-      REAL ffonte(klon,nbsrf)    !Flux thermique utilise pour fondre la neige
-      REAL fqcalving(klon,nbsrf) !Flux d'eau "perdue" par la surface 
+      REAL,SAVE,ALLOCATABLE :: ffonte(:,:)    !Flux thermique utilise pour fondre la neige
+c$OMP THREADPRIVATE(ffonte)
+      REAL,SAVE,ALLOCATABLE :: fqcalving(:,:) !Flux d'eau "perdu" par la surface 
+c$OMP THREADPRIVATE(fqcalving)
+      REAL,SAVE,ALLOCATABLE :: fqfonte(:,:)  !Quantite d'eau de fonte des glaciers
+c$OMP THREADPRIVATE(fqfonte)
 c                               !et necessaire pour limiter la
 c                               !hauteur de neige, en kg/m2/s
-      REAL zxffonte(klon), zxfqcalving(klon)
-
-c$$$      LOGICAL offline           ! Controle du stockage ds "physique"
-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 zxffonte(klon), zxfqcalving(klon),zxfqfonte(klon)
+
+c@$$      LOGICAL offline           ! Controle du stockage ds "physique"
+c@$$      PARAMETER (offline=.false.)
+c@$$      INTEGER physid
+      REAL,allocatable,save :: pfrac_impa(:,:)! Produits des coefs lessivage impaction
+c$OMP THREADPRIVATE(pfrac_impa)
+cym      save pfrac_impa
+      REAL,allocatable,save :: pfrac_nucl(:,:)! Produits des coefs lessivage nucleation
+c$OMP THREADPRIVATE(pfrac_nucl)
+cym      save pfrac_nucl
+      REAL,allocatable,save :: pfrac_1nucl(:,:)! Produits des coefs lessi nucl (alpha = 1)
+c$OMP THREADPRIVATE(pfrac_1nucl)
+cym      save pfrac_1nucl
       REAL frac_impa(klon,klev) ! fractions d'aerosols lessivees (impaction)
       REAL frac_nucl(klon,klev) ! idem (nucleation)
@@ -753,18 +861,24 @@
 
 cAA
-      REAL rain_fall(klon) ! pluie
-      REAL snow_fall(klon) ! neige
-      save snow_fall, rain_fall
+      REAL,allocatable,save :: rain_fall(:) ! pluie
+c$OMP THREADPRIVATE(rain_fall)
+      REAL,allocatable,save :: snow_fall(:) ! neige
+c$OMP THREADPRIVATE(snow_fall)
+cym      save snow_fall, rain_fall
+
 cIM cf FH pour Tiedtke 080604
       REAL rain_tiedtke(klon),snow_tiedtke(klon)
 c
-      REAL total_rain(klon), nday_rain(klon)
-      save nday_rain
-c
+
+      REAL,allocatable,save :: total_rain(:), nday_rain(:)
+c$OMP THREADPRIVATE(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
+c$OMP THREADPRIVATE(dlw)
 cym
-      SAVE dlw
+cym      SAVE dlw
 cym
       REAL bils(klon) ! bilan de chaleur au sol
@@ -773,6 +887,7 @@
       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)
+c$OMP THREADPRIVATE(fder) 
+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
@@ -780,6 +895,7 @@
       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
+c$OMP THREADPRIVATE(frugs) 
+cym      save frugs
       REAL zxrugs(klon) ! longueur de rugosite
 c
@@ -790,17 +906,27 @@
       INTEGER lmt_pas
       SAVE lmt_pas                ! frequence de mise a jour
-      REAL pctsrf(klon,nbsrf)
+c$OMP THREADPRIVATE(lmt_pas) 
+      REAL,allocatable,save :: pctsrf(:,:)
+c$OMP THREADPRIVATE(pctsrf) 
 cIM
       REAL pctsrf_new(klon,nbsrf) !pourcentage surfaces issus d'ORCHIDEE
-      REAL paire_ter(klon)        !surfaces terre 
-c
-      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      REAL paire_ter(klon)        !surfaces terre 
+      REAL,allocatable,save ::  paire_ter(:)        !surfaces terre 
+c$OMP THREADPRIVATE(paire_ter) 
+    
+cIM
+cym      SAVE pctsrf                 ! sous-fraction du sol
+      REAL,allocatable,save :: albsol(:)
+c$OMP THREADPRIVATE(albsol)
+cym      SAVE albsol                 ! albedo du sol total
+      REAL,allocatable,save :: albsollw(:)
+c$OMP THREADPRIVATE(albsollw)      
+cym      SAVE albsollw                 ! albedo du sol total
+
+      REAL,allocatable,save :: wo(:,:)
+c$OMP THREADPRIVATE(wo)
+cym     SAVE wo                     ! ozone
+
 cIM sorties
       REAL un_jour
@@ -849,11 +975,9 @@
 c Variables locales
 c
-      real clwcon(klon,klev),rnebcon(klon,klev)
-      real clwcon0(klon,klev),rnebcon0(klon,klev)
-cIM cf. AM 081204 BEG
-      real clwcon0th(klon,klev),rnebcon0th(klon,klev)
-cIM cf. AM 081204 END
-      save rnebcon, clwcon
-
+      real,allocatable,save :: clwcon(:,:),rnebcon(:,:)
+c$OMP THREADPRIVATE(clwcon,rnebcon)
+      real,allocatable,save :: clwcon0(:,:),rnebcon0(:,:)
+cym      save rnebcon, clwcon
+c$OMP THREADPRIVATE(clwcon0,rnebcon0)
       REAL rhcl(klon,klev)    ! humiditi relative ciel clair
       REAL dialiq(klon,klev)  ! eau liquide nuageuse
@@ -875,27 +999,39 @@
       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
+c$OMP THREADPRIVATE(heat)
+      REAL,allocatable,save :: heat0(:,:)   ! chauffage solaire ciel clair
+c$OMP THREADPRIVATE(heat0)
+      REAL,allocatable,save :: cool(:,:)    ! refroidissement infrarouge
+c$OMP THREADPRIVATE(cool)
+      REAL,allocatable,save :: cool0(:,:)   ! refroidissement infrarouge ciel clair
+c$OMP THREADPRIVATE(cool0)
+      REAL,allocatable,save :: topsw(:), toplw(:), solsw(:), sollw(:)
+c$OMP THREADPRIVATE(topsw,toplw,solsw,sollw)
+      real,allocatable,save :: sollwdown(:)    ! downward LW flux at surface
+c$OMP THREADPRIVATE(sollwdown)
 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 
+c$OMP THREADPRIVATE(sollwdownclr)
+      real,allocatable,save :: toplwdown(:)       ! downward CS LW flux at TOA
+c$OMP THREADPRIVATE(toplwdown)
+      real,allocatable,save :: toplwdownclr(:)    ! downward CS LW flux at TOA
+c$OMP THREADPRIVATE(toplwdownclr)
 cIM END
-      REAL topsw0(klon), toplw0(klon), solsw0(klon), sollw0(klon)
-      REAL albpla(klon)
+      REAL,allocatable,save :: topsw0(:),toplw0(:),solsw0(:),sollw0(:)
+c$OMP THREADPRIVATE( topsw0,toplw0,solsw0,sollw0)
+      REAL,allocatable,save :: albpla(:)
+c$OMP THREADPRIVATE(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
       SAVE itaprad
+c$OMP THREADPRIVATE(itaprad)
 c
       REAL conv_q(klon,klev) ! convergence de l'humidite (kg/kg/s)
@@ -925,19 +1061,30 @@
 c
       REAL zphi(klon,klev)
-      REAL zx_relief(iim,jjmp1)
-      REAL zx_aire(iim,jjmp1)
+cym A voir plus tard !!
+cym      REAL zx_relief(iim,jjmp1)
+cym      REAL zx_aire(iim,jjmp1)
 c
 cIM cf. AM Variables locales pour la CLA (hbtm2)
 c
-      REAL pblh(klon, nbsrf)           ! Hauteur de couche limite
-      REAL plcl(klon, nbsrf)           ! Niveau de condensation de la CLA
-      REAL capCL(klon, nbsrf)          ! CAPE de couche limite
-      REAL oliqCL(klon, nbsrf)          ! eau_liqu integree de couche limite
-      REAL cteiCL(klon, nbsrf)          ! cloud top instab. crit. couche limite
-      REAL pblt(klon, nbsrf)          ! T a la Hauteur de couche limite
-      REAL therm(klon, nbsrf)
-      REAL trmb1(klon, nbsrf)          ! deep_cape
-      REAL trmb2(klon, nbsrf)          ! inhibition 
-      REAL trmb3(klon, nbsrf)          ! Point Omega
+      REAL,SAVE,ALLOCATABLE :: pblh(:, :)           ! Hauteur de couche limite
+c$OMP THREADPRIVATE(pblh)
+      REAL,SAVE,ALLOCATABLE :: plcl(:, :)           ! Niveau de condensation de la CLA
+c$OMP THREADPRIVATE(plcl)
+      REAL,SAVE,ALLOCATABLE :: capCL(:, :)          ! CAPE de couche limite
+c$OMP THREADPRIVATE(capCL)
+      REAL,SAVE,ALLOCATABLE :: oliqCL(:, :)          ! eau_liqu integree de couche limite
+c$OMP THREADPRIVATE(oliqCL)
+      REAL,SAVE,ALLOCATABLE :: cteiCL(:, :)          ! cloud top instab. crit. couche limite
+c$OMP THREADPRIVATE(cteiCL)
+      REAL,SAVE,ALLOCATABLE :: pblt(:, :)          ! T a la Hauteur de couche limite
+c$OMP THREADPRIVATE(pblt)
+      REAL,SAVE,ALLOCATABLE :: therm(:, :)
+c$OMP THREADPRIVATE(therm)
+      REAL,SAVE,ALLOCATABLE :: trmb1(:, :)          ! deep_cape
+c$OMP THREADPRIVATE(trmb1)
+      REAL,SAVE,ALLOCATABLE :: trmb2(:, :)          ! inhibition 
+c$OMP THREADPRIVATE(trmb2)
+      REAL,SAVE,ALLOCATABLE :: trmb3(:, :)          ! Point Omega
+c$OMP THREADPRIVATE(trmb3)
 c Grdeurs de sorties
       REAL s_pblh(klon), s_lcl(klon), s_capCL(klon)
@@ -952,12 +1099,15 @@
       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
+c$OMP THREADPRIVATE(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
+c$OMP THREADPRIVATE(pbase)
+cym      SAVE pbase
+      REAL,allocatable,save :: bbase(:)          ! cloud base buoyancy
+c$OMP THREADPRIVATE(bbase)
+cym      SAVE bbase
       REAL rflag(klon)          ! flag fonctionnement de convect
       INTEGER iflagctrl(klon)          ! flag fonctionnement de convect
@@ -982,5 +1132,6 @@
 c vdf: couche limite (Vertical DiFfusion)
       REAL d_t_con(klon,klev),d_q_con(klon,klev)
-      REAL d_u_con(klon,klev),d_v_con(klon,klev)
+      REAL,SAVE,ALLOCATABLE :: d_u_con(:,:),d_v_con(:,:)
+c$OMP THREADPRIVATE(d_u_con,d_v_con)
       REAL d_t_lsc(klon,klev),d_q_lsc(klon,klev),d_ql_lsc(klon,klev)
       REAL d_t_ajs(klon,klev), d_q_ajs(klon,klev)
@@ -992,6 +1143,7 @@
 *********************************************************
 *     declarations
-      real zqasc(klon,klev)
-      save zqasc
+      real,save,allocatable :: zqasc(:,:)
+c$OMP THREADPRIVATE(zqasc)
+cym      save zqasc
       
 *********************************************************
@@ -1005,10 +1157,15 @@
       REAL prfl(klon,klev+1), psfl(klon,klev+1)
 c
-      INTEGER ibas_con(klon), itop_con(klon)
+      INTEGER,allocatable,save :: ibas_con(:), itop_con(:)
+c$OMP THREADPRIVATE(ibas_con,itop_con)
 cym
-      SAVE ibas_con,itop_con
+cym      SAVE ibas_con,itop_con
 cym
-      REAL rain_con(klon), rain_lsc(klon)
-      REAL snow_con(klon), snow_lsc(klon)
+      REAL,SAVE,ALLOCATABLE :: rain_con(:)
+c$OMP THREADPRIVATE(rain_con)
+      REAL rain_lsc(klon)
+      REAL,SAVE,ALLOCATABLE :: snow_con(:)
+c$OMP THREADPRIVATE(snow_con)
+      REAL snow_lsc(klon)
       REAL d_ts(klon,nbsrf)
 c
@@ -1022,7 +1179,11 @@
       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(:,:)
+c$OMP THREADPRIVATE(ratqs)
+      REAL ratqss(klon,klev),ratqsc(klon,klev)
       real ratqsbas,ratqshaut
-      save ratqsbas,ratqshaut, ratqs
+cym      save ratqsbas,ratqshaut, ratqs
+      save ratqsbas,ratqshaut
+c$OMP THREADPRIVATE(ratqsbas,ratqshaut)
       real zpt_conv(klon,klev)
 
@@ -1032,10 +1193,12 @@
       logical ok_newmicro
       save ok_newmicro
+c$OMP THREADPRIVATE(ok_newmicro)
       save fact_cldcon,facttemps
+c$OMP THREADPRIVATE(fact_cldcon,facttemps)
       real facteur
 
       integer iflag_cldcon
       save iflag_cldcon
-
+c$OMP THREADPRIVATE(iflag_cldcon)
       logical ptconv(klon,klev)
 cIM cf. AM 081204 BEG
@@ -1051,4 +1214,5 @@
       integer imin_ins,imax_ins,jmin_ins,jmax_ins
       save imin_ins,imax_ins,jmin_ins,jmax_ins
+c$OMP THREADPRIVATE(imin_ins,imax_ins,jmin_ins,jmax_ins)
 c      real lonmin_ins,lonmax_ins,latmin_ins
 c     s  ,latmax_ins
@@ -1087,4 +1251,5 @@
       REAL tabcntr0( length       )
 c
+
       INTEGER ndex2d(iim*jjmp1),ndex3d(iim*jjmp1*klev)
 cIM
@@ -1102,4 +1267,5 @@
       INTEGER ij, imp1jmp1
       PARAMETER(imp1jmp1=(iim+1)*jjmp1)
+cym A voir plus tard
       REAL zx_tmp(imp1jmp1), airedyn(iim+1,jjmp1)
       REAL padyn(iim+1,jjmp1,klev+1)
@@ -1111,13 +1277,15 @@
 cIM 
       REAL airetot, pi
-      REAL zm_wo(jjmp1, klev)
+cym A voir plus tard
+cym      REAL zm_wo(jjmp1, klev)
 cIM AMIP2 END
 c
       REAL zx_tmp_fi2d(klon)      ! variable temporaire grille physique
       REAL zx_tmp_fi3d(klon,klev) ! variable temporaire pour champs 3D 
-#ifdef histmthNMC
-      REAL zx_tmp_NC(iim,jjmp1,nlevSTD)
+c#ifdef histmthNMC
+cym   A voir plus tard !!!!
+cym      REAL zx_tmp_NC(iim,jjmp1,nlevSTD)
       REAL zx_tmp_fiNC(klon,nlevSTD) 
-#endif
+c#endif
       REAL*8 zx_tmp2_fi3d(klon,klev) ! variable temporaire pour champs 3D 
       REAL zx_tmp_2d(iim,jjmp1), zx_tmp_3d(iim,jjmp1,klev)
@@ -1128,8 +1296,11 @@
       SAVE nid_day, nid_mth, nid_ins, nid_nmc, nid_day_seri
       SAVE nid_ctesGCM
+c$OMP THREADPRIVATE(nid_day, nid_mth, nid_ins, nid_nmc)
+c$OMP THREADPRIVATE(nid_day_seri,nid_ctesGCM)
 c
 cIM 280405 BEG
       INTEGER nid_bilKPins, nid_bilKPave
       SAVE nid_bilKPins, nid_bilKPave
+c$OMP THREADPRIVATE(nid_bilKPins, nid_bilKPave)
 c
       REAL ve_lay(klon,klev) ! transport meri. de l'energie a chaque niveau vert.
@@ -1146,7 +1317,9 @@
       REAL zout_isccp(napisccp)
       SAVE zcals, zcalh, zoutj, zout_isccp
+c$OMP THREADPRIVATE(zcals, zcalh, zoutj, zout_isccp)
 
       real zjulian
       save zjulian
+c$OMP THREADPRIVATE(zjulian)
 
       character*20 modname
@@ -1172,11 +1345,20 @@
       SAVE      h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot
      $        , h_qs_tot, qw_tot, ql_tot, qs_tot , ec_tot
+c$OMP THREADPRIVATE(h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot,
+c$OMP+              h_qs_tot, qw_tot, ql_tot, qs_tot , ec_tot)
       REAL      d_h_vcol, d_h_dair, d_qt, d_qw, d_ql, d_qs, d_ec
       REAL      d_h_vcol_phy
       REAL      fs_bound, fq_bound
       SAVE      d_h_vcol_phy
+c$OMP THREADPRIVATE(d_h_vcol_phy)
       REAL      zero_v(klon)
       CHARACTER*15 ztit
-
+      INTEGER   ip_ebil  ! PRINT level for energy conserv. diag.
+      SAVE      ip_ebil
+      DATA      ip_ebil/0/
+c$OMP THREADPRIVATE(ip_ebil)
+      INTEGER   if_ebil ! level for energy conserv. dignostics
+      SAVE      if_ebil
+c$OMP THREADPRIVATE(if_ebil)
 c+jld ec_conser
       REAL d_t_ec(klon,klev)    ! tendance du a la conersion Ec -> E thermique
@@ -1184,6 +1366,8 @@
 c-jld ec_conser
 cIM: t2m, q2m, u10m, v10m et t2mincels, t2maxcels
-      REAL t2m(klon,nbsrf), q2m(klon,nbsrf)   !temperature, humidite a 2m
-      REAL u10m(klon,nbsrf), v10m(klon,nbsrf) !vents a 10m
+      REAL,SAVE,ALLOCATABLE :: t2m(:,:), q2m(:,:)   !temperature, humidite a 2m
+c$OMP THREADPRIVATE(t2m,q2m)
+      REAL,SAVE,ALLOCATABLE :: u10m(:,:), v10m(:,:) !vents a 10m
+c$OMP THREADPRIVATE(u10m,v10m)
       REAL zt2m(klon), zq2m(klon)             !temp., hum. 2m moyenne s/ 1 maille
       REAL zu10m(klon), zv10m(klon)           !vents a 10m moyennes s/1 maille
@@ -1192,6 +1376,7 @@
 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)
+c$OMP THREADPRIVATE(sulfate_pi)
+cym      SAVE sulfate_pi
 
       REAL cldtaupi(klon,klev)  ! Cloud optical thickness for pre-industrial (pi) aerosols
@@ -1203,11 +1388,15 @@
 
       ! Aerosol optical properties
-      REAL tau_ae(klon,klev,2), piz_ae(klon,klev,2)
-      REAL cg_ae(klon,klev,2)
-
-      REAL topswad(klon), solswad(klon) ! Aerosol direct effect.
+      REAL,SAVE,ALLOCATABLE :: tau_ae(:,:,:), piz_ae(:,:,:)
+c$OMP THREADPRIVATE(tau_ae,piz_ae)
+      REAL,SAVE,ALLOCATABLE :: cg_ae(:,:,:)
+c$OMP THREADPRIVATE(cg_ae)
+
+      REAL,SAVE,ALLOCATABLE :: topswad(:), solswad(:) ! Aerosol direct effect.
+c$OMP THREADPRIVATE(topswad,solswad)
       ! ok_ade=T -ADE=topswad-topsw
 
-      REAL topswai(klon), solswai(klon) ! Aerosol indirect effect.
+      REAL,SAVE,ALLOCATABLE :: topswai(:), solswai(:) ! Aerosol indirect effect.
+c$OMP THREADPRIVATE(topswai,solswai)
       ! ok_aie=T ->
       !        ok_ade=T -AIE=topswai-topswad
@@ -1221,45 +1410,12 @@
 cym 
       SAVE ok_ade, ok_aie, bl95_b0, bl95_b1
-cym
-c Anne
-         SAVE u10m
-         SAVE v10m
-         SAVE t2m
-         SAVE q2m
-         SAVE ffonte
-         SAVE fqcalving
-         SAVE piz_ae
-         SAVE tau_ae
-         SAVE cg_ae
-         SAVE rain_con
-         SAVE snow_con
-         SAVE topswai
-         SAVE topswad
-         SAVE solswai
-         SAVE solswad
-         SAVE d_u_con
-         SAVE d_v_con
-         SAVE rnebcon0
-         SAVE clwcon0
-         SAVE paire_ter
-c        SAVE nhistoW
-c        SAVE histoW
-c SAVE anne 20/09/2005
-         SAVE pblh
-         SAVE plcl
-         SAVE capCL
-         SAVE oliqCL
-         SAVE cteiCL
-         SAVE pblt
-         SAVE therm
-         SAVE trmb1
-         SAVE trmb2
-         SAVE trmb3
-
-c fin Anne
-cjq-end
+c$OMP THREADPRIVATE(ok_ade, ok_aie, bl95_b0, bl95_b1)
+
 c
 c Declaration des constantes et des fonctions thermodynamiques
 c
+      REAL Field_tmp(klon2,klevp1)
+      LOGICAL,SAVE :: first=.true.
+c$OMP THREADPRIVATE(first)
 #include "YOMCST.h"
 #include "YOETHF.h"
@@ -1273,5 +1429,158 @@
 c
 c======================================================================
-      modname = 'physiq'
+
+cym => necessaire pour iflag_con != 2    
+      pmfd(:,:) = 0.
+      pen_u(:,:) = 0.
+      pen_d(:,:) = 0.
+      pde_d(:,:) = 0.
+      pde_u(:,:) = 0.
+      aam=0.
+      torsfc=0.
+cym => pour le couple ocean => revoir dans clmain/intersurf
+      fluxg(:)=0.
+      fluxo(:)=0.      
+
+      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))
+      allocate(tsumSTD(klon,nlevSTD,nout))
+      allocate(usumSTD(klon,nlevSTD,nout))
+      allocate(vsumSTD(klon,nlevSTD,nout))
+      allocate(wsumSTD(klon,nlevSTD,nout))
+      allocate(phisumSTD(klon,nlevSTD,nout))
+      allocate(qsumSTD(klon,nlevSTD,nout))
+      allocate(rhsumSTD(klon,nlevSTD,nout))
+      allocate(uvsumSTD(klon,nlevSTD,nout))
+      allocate(vqsumSTD(klon,nlevSTD,nout))
+      allocate(vTsumSTD(klon,nlevSTD,nout))
+      allocate(wqsumSTD(klon,nlevSTD,nout))
+      allocate( vphisumSTD(klon,nlevSTD,nout))
+      allocate( wTsumSTD(klon,nlevSTD,nout))
+      allocate( u2sumSTD(klon,nlevSTD,nout))
+      allocate( v2sumSTD(klon,nlevSTD,nout))
+      allocate( T2sumSTD(klon,nlevSTD,nout))
+      allocate( seed_old(klon,napisccp))
+      allocate( pct_ocean(klon,nbregdyn))
+      allocate( rlonPOS(klon))
+      allocate( newsst(klon))
+      allocate( zqasc(klon,klev))
+      allocate( therm(klon, nbsrf))
+      allocate( rain_con(klon))
+      allocate( pblt(klon, nbsrf))
+      allocate( t2m(klon,nbsrf), q2m(klon,nbsrf) )  
+      allocate( u10m(klon,nbsrf), v10m(klon,nbsrf)) 
+      allocate( topswad(klon), solswad(klon))
+      allocate( topswai(klon), solswai(klon) )
+      allocate( ffonte(klon,nbsrf))
+      allocate( fqcalving(klon,nbsrf))
+      allocate( fqfonte(klon,nbsrf)) 
+      allocate( pblh(klon, nbsrf))
+      allocate( plcl(klon, nbsrf))  
+      allocate( capCL(klon, nbsrf))   
+      allocate( oliqCL(klon, nbsrf))       
+      allocate( cteiCL(klon, nbsrf))       
+      allocate( trmb1(klon, nbsrf))   
+      allocate( trmb2(klon, nbsrf))     
+      allocate( trmb3(klon, nbsrf)) 
+      allocate( clwcon0(klon,klev),rnebcon0(klon,klev))
+      allocate( tau_ae(klon,klev,2), piz_ae(klon,klev,2))
+      allocate( cg_ae(klon,klev,2))
+      allocate( snow_con(klon))
+      allocate( tnondef(klon,nlevSTD,nout)) 
+      allocate( d_u_con(klon,klev),d_v_con(klon,klev))            
+      
+      
+        paire_ter(:)=0.    
+        clwcon(:,:)=0.
+	rnebcon(:,:)=0.
+	ratqs(:,:)=0.
+	run_off_lic_0(:)=0.
+	sollw(:)=0.
+	ema_work1(:,:)=0.
+	ema_work2(:,:)=0.
+cym Attention pbase pas initialise dans concvl !!!!
+        pbase(:)=0
+	
+	first=.false.
+      endif 
+
+                  
+       modname = 'physiq'
 cIM
       IF (ip_ebil_phy.ge.1) THEN
@@ -1305,4 +1614,5 @@
          ffonte(:,:)=0.
          fqcalving(:,:)=0.
+	 fqfonte(:,:)=0.
          piz_ae(:,:,:)=0.
          tau_ae(:,:,:)=0.
@@ -1378,4 +1688,13 @@
      .       run_off_lic_0)
 
+       DO i=1,klon
+         IF ( abs( pctsrf(i, is_ter) + pctsrf(i, is_lic) + 
+     $       pctsrf(i, is_oce) + pctsrf(i, is_sic)  - 1.) .GT. EPSFRA) 
+     $       THEN 
+             WRITE(*,*) 'physiq : pb sous surface au point ', i, 
+     $           pctsrf(i, 1 : nbsrf)
+         ENDIF 
+      ENDDO
+ 
 c   ATTENTION : il faudra a terme relire q2 dans l'etat initial
          q2(:,:,:)=1.e-8
@@ -1583,4 +1902,5 @@
 #endif
 
+c#include "ini_histday_seri.h"
 #include "ini_histday_seri.h"
 
@@ -1606,4 +1926,6 @@
 c
 #ifdef INCA
+           call VTe(VTphysiq)
+	   call VTb(VTinca)
            iii = MOD(NINT(xjour),360)
            calday = FLOAT(iii) + gmtime
@@ -1612,5 +1934,5 @@
            WRITE(lunout,*) 'Appel CHEMINI ...'
 #endif
-           CALL chemini( rpi,
+           CALL chemini( 
      $                   rg,
      $                   ra,
@@ -1628,4 +1950,6 @@
            WRITE(lunout,*) 'OK.'
 #endif
+      call VTe(VTinca)
+      call VTb(VTphysiq)
 #endif
 c
@@ -1865,6 +2189,6 @@
        DO nsrf = 1, nbsrf
        DO i = 1, klon
-c$$$        fsollw(i,nsrf) = sollwdown(i) - RSIGMA*ftsol(i,nsrf)**4
-c$$$        fsollw(i,nsrf) = sollw(i)
+c@$$        fsollw(i,nsrf) = sollwdown(i) - RSIGMA*ftsol(i,nsrf)**4
+c@$$        fsollw(i,nsrf) = sollw(i)
          fsollw(i,nsrf) = sollw(i)
      $      + 4.0*RSIGMA*ztsol(i)**3 * (ztsol(i)-ftsol(i,nsrf))
@@ -1872,7 +2196,24 @@
        ENDDO
        ENDDO
-
+      
+cYM   !!!!!!!!!!!!!!!!!!!!!!!!!!!!
+cYM         Attention verrue
+cYM    ---> A supprimer plus tard       
+cYM         pour etre integre dans
+cYM         ORCHIDEE       
+      DO i = 1, klon
+        sollwdown(i)=sollw(i)+RSIGMA*ztsol(i)**4
+      ENDDO
+cYM  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!      
+      
       fder = dlw
 
+      if (mydebug) then
+        call writefield_phy('u_seri',u_seri,llm)
+        call writefield_phy('v_seri',v_seri,llm)
+        call writefield_phy('t_seri',t_seri,llm)
+	call writefield_phy('q_seri',q_seri,llm)
+      endif
+  
       IF (check) THEN
        amn=MIN(tslab(1),1000.)
@@ -1906,5 +2247,5 @@
      s            pblh,capCL,oliqCL,cteiCL,pblT,
      s            therm,trmb1,trmb2,trmb3,plcl,
-     s            fqcalving, ffonte, run_off_lic_0,
+     s            fqcalving, fqfonte,ffonte, run_off_lic_0,
 cIM "slab" ocean
      s            fluxo, fluxg, tslab, seaice) 
@@ -1948,4 +2289,13 @@
       ENDDO
       ENDDO
+
+      if (mydebug) then
+        call writefield_phy('u_seri',u_seri,llm)
+        call writefield_phy('v_seri',v_seri,llm)
+        call writefield_phy('t_seri',t_seri,llm)
+	call writefield_phy('q_seri',q_seri,llm)
+      endif
+
+
 cIM
       IF (ip_ebil_phy.ge.2) THEN 
@@ -1975,4 +2325,5 @@
          zxffonte(i) = 0.0
          zxfqcalving(i) = 0.0
+	 zxfqfonte(i) = 0.0
 cIM cf. AM 081204 BEG
 c
@@ -2016,4 +2367,6 @@
             zxfqcalving(i) = zxfqcalving(i) + 
      .                      fqcalving(i,nsrf)*pctsrf(i,nsrf)
+            zxfqfonte(i) = zxfqfonte(i) + 
+     .                      fqfonte(i,nsrf)*pctsrf(i,nsrf)
 cIM cf. AM 081204 BEG
             s_pblh(i) = s_pblh(i) + pblh(i,nsrf)*pctsrf(i,nsrf)
@@ -2054,4 +2407,5 @@
            ffonte(i,nsrf) = zxffonte(i)
            fqcalving(i,nsrf) = zxfqcalving(i)
+           fqfonte(i,nsrf) = zxfqfonte(i)
            pblh(i,nsrf)=s_pblh(i)
            plcl(i,nsrf)=s_lcl(i)
@@ -2168,4 +2522,10 @@
           ENDIF ! ok_cvl
 
+c
+c Correction precip
+          rain_con = rain_con * cvl_corr
+          snow_con = snow_con * cvl_corr
+c
+
            IF (.NOT. ok_gust) THEN
            do i = 1, klon
@@ -2229,4 +2589,12 @@
         ENDDO
       ENDDO
+
+      if (mydebug) then
+        call writefield_phy('u_seri',u_seri,llm)
+        call writefield_phy('v_seri',v_seri,llm)
+        call writefield_phy('t_seri',t_seri,llm)
+	call writefield_phy('q_seri',q_seri,llm)
+      endif
+
 cIM
       IF (ip_ebil_phy.ge.2) THEN 
@@ -2429,4 +2797,12 @@
      s      , fs_bound, fq_bound )
       END IF 
+
+      if (mydebug) then
+        call writefield_phy('u_seri',u_seri,llm)
+        call writefield_phy('v_seri',v_seri,llm)
+        call writefield_phy('t_seri',t_seri,llm)
+	call writefield_phy('q_seri',q_seri,llm)
+      endif
+
 c
 c-------------------------------------------------------------------
@@ -2477,5 +2853,5 @@
       ELSE IF (iflag_cldcon.eq.3) THEN
 c  On prend pour les nuages convectifs le max du calcul de la
-c  convection et du calcul du pas de temps précédent diminué d'un facteur
+c  convection et du calcul du pas de temps precedent diminue d'un facteur
 c  facttemps
 c      facttemps=pdtphys/1.e4
@@ -2491,4 +2867,23 @@
          enddo
       enddo
+
+c
+cjq - introduce the aerosol direct and first indirect radiative forcings
+cjq - Johannes Quaas, 27/11/2003 (quaas@lmd.jussieu.fr)
+      IF (ok_ade.OR.ok_aie) THEN
+         ! Get sulfate aerosol distribution
+         CALL readsulfate(rjourvrai, debut, sulfate)
+         CALL readsulfate_preind(rjourvrai, debut, sulfate_pi)
+
+         ! Calculate aerosol optical properties (Olivier Boucher)
+         CALL aeropt(pplay, paprs, t_seri, sulfate, rhcl,
+     .        tau_ae, piz_ae, cg_ae, aerindex)
+cym
+      ELSE
+        tau_ae(:,:,:)=0.0
+	piz_ae(:,:,:)=0.0
+	cg_ae(:,:,:)=0.0
+cym     
+      ENDIF
 
 c
@@ -2607,29 +3002,14 @@
      . EXP((Lheat *qsat2m(i))/(RCPD*zt2m(i)))
       ENDDO
-c
-cjq - introduce the aerosol direct and first indirect radiative forcings
-cjq - Johannes Quaas, 27/11/2003 (quaas@lmd.jussieu.fr)
-      IF (ok_ade.OR.ok_aie) THEN
-         ! Get sulfate aerosol distribution
-         CALL readsulfate(rjourvrai, debut, sulfate)
-         CALL readsulfate_preind(rjourvrai, debut, sulfate_pi)
-
-         ! Calculate aerosol optical properties (Olivier Boucher)
-         CALL aeropt(pplay, paprs, t_seri, sulfate, rhcl,
-     .        tau_ae, piz_ae, cg_ae, aerindex)
-cym
-      ELSE
-        tau_ae(:,:,:)=0.0
-	piz_ae(:,:,:)=0.0
-	cg_ae(:,:,:)=0.0
-cym     
-      ENDIF
+
 
 #ifdef INCA
+      call VTe(VTphysiq)
+      call VTb(VTinca)
            calday = FLOAT(julien) + gmtime
 
 #ifdef INCA_AER
-      call AEROSOL_METEO_CALC(calday,pdtphys,pplay,paprs,t,pmflxr,pmflxs,
-     &   prfl,psfl,pctsrf(1,3),airephy,xjour,rlat,rlon)
+      call AEROSOL_METEO_CALC(calday,pdtphys,pplay,paprs,t,pmflxr,pmflxs
+     &   ,prfl,psfl,pctsrf,airephy,xjour,rlat,rlon,u10m,v10m)
 #endif
 
@@ -2684,4 +3064,6 @@
            WRITE(lunout,*)'OK.'
 #endif
+      call VTe(VTinca)
+      call VTb(VTphysiq)
 #endif
 c     
@@ -2722,4 +3104,12 @@
      .               + falblw(i,is_sic) * pctsrf(i,is_sic)
       ENDDO
+
+      if (mydebug) then
+        call writefield_phy('u_seri',u_seri,llm)
+        call writefield_phy('v_seri',v_seri,llm)
+        call writefield_phy('t_seri',t_seri,llm)
+	call writefield_phy('q_seri',q_seri,llm)
+      endif
+      
       CALL radlwsw ! nouveau rayonnement (compatible Arpege-IFS)
      e            (dist, rmu0, fract, 
@@ -2750,4 +3140,12 @@
       ENDDO
       ENDDO
+c
+      if (mydebug) then
+        call writefield_phy('u_seri',u_seri,llm)
+        call writefield_phy('v_seri',v_seri,llm)
+        call writefield_phy('t_seri',t_seri,llm)
+	call writefield_phy('q_seri',q_seri,llm)
+      endif
+ 
 cIM
       IF (ip_ebil_phy.ge.2) THEN 
@@ -2837,4 +3235,11 @@
       ENDIF ! fin de test sur ok_orodr
 c
+      if (mydebug) then
+        call writefield_phy('u_seri',u_seri,llm)
+        call writefield_phy('v_seri',v_seri,llm)
+        call writefield_phy('t_seri',t_seri,llm)
+	call writefield_phy('q_seri',q_seri,llm)
+      endif
+      
       IF (ok_orolf) THEN
 c
@@ -2872,4 +3277,11 @@
 C STRESS NECESSAIRES: TOUTE LA PHYSIQUE
 
+      if (mydebug) then
+        call writefield_phy('u_seri',u_seri,llm)
+        call writefield_phy('v_seri',v_seri,llm)
+        call writefield_phy('t_seri',t_seri,llm)
+	call writefield_phy('q_seri',q_seri,llm)
+      endif
+
       DO i = 1, klon
         zustrph(i)=0.
@@ -2887,11 +3299,14 @@
 cIM calcul composantes axiales du moment angulaire et couple des montagnes
 c
-      CALL aaam_bud (27,klon,klev,rjourvrai,gmtime,
-     C               ra,rg,romega,
-     C               rlat,rlon,pphis,
-     C               zustrdr,zustrli,zustrph,
-     C               zvstrdr,zvstrli,zvstrph,
-     C               paprs,u,v,
-     C               aam, torsfc)
+      IF (monocpu) THEN
+      
+        CALL aaam_bud (27,klon,klev,rjourvrai,gmtime,
+     C                 ra,rg,romega,
+     C                 rlat,rlon,pphis,
+     C                 zustrdr,zustrli,zustrph,
+     C                 zvstrdr,zvstrli,zvstrph,
+     C                 paprs,u,v,
+     C                 aam, torsfc)
+       ENDIF
 cIM cf. FLott END
 cIM
@@ -3058,4 +3473,6 @@
 c
 #ifdef INCA
+      call VTe(VTphysiq)
+      call VTb(VTinca)
 #ifdef INCAINFO
            WRITE(lunout,*)'Appel CHEMHOOK_END ...'
@@ -3068,15 +3485,13 @@
      $                        nbtr,
      $                        paprs,
-#ifdef INCA_CH4
      $                        q_seri,
-#endif
      $                        annee_ref,
      $                        day_ini,
+     $                        airephy,      
 #ifdef INCA_AER
      $                        xjour,
      $                        pphi,
      $                        pphis,
-     $                        zx_rh,
-     $                        qx(1,1,1))
+     $                        zx_rh)
 #else
      $                        xjour)
@@ -3085,4 +3500,6 @@
            WRITE(lunout,*)'OK.'
 #endif
+      call VTe(VTinca)
+      call VTb(VTphysiq)
 #endif
 
@@ -3091,4 +3508,11 @@
 c Convertir les incrementations en tendances
 c
+      if (mydebug) then
+        call writefield_phy('u_seri',u_seri,llm)
+        call writefield_phy('v_seri',v_seri,llm)
+        call writefield_phy('t_seri',t_seri,llm)
+	call writefield_phy('q_seri',q_seri,llm)
+      endif
+
       DO k = 1, klev
       DO i = 1, klon
Index: /LMDZ4/trunk/libf/phylmd/phystokenc.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/phystokenc.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/phystokenc.F	(revision 766)
@@ -12,6 +12,6 @@
      I                   pphis,paire,dtime,itap)
       USE ioipsl
-      USE histcom
-
+      USE dimphy
+      USE iophy
       IMPLICIT none
 
@@ -23,5 +23,5 @@
 c======================================================================
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "tracstoke.h"
 #include "indicesol.h"
@@ -43,4 +43,5 @@
       integer physid, itap
       save physid
+c$OMP THREADPRIVATE(physid)
       integer ndex2d(iim*(jjm+1)),ndex3d(iim*(jjm+1)*klev)
 
@@ -54,5 +55,7 @@
       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$OMP THREADPRIVATE(t)
 c
       REAL rlon(klon), rlat(klon), dtime
@@ -69,8 +72,11 @@
 c   ---------------
       REAL pfm_therm(klon,klev+1)
-	real fm_therm1(klon,klev)
+      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$OMP THREADPRIVATE(entr_therm)
+c$OMP THREADPRIVATE(fm_therm)
 c
 c   Lessivage:
@@ -88,14 +94,18 @@
       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(:,:)
+c$OMP THREADPRIVATE(mfu,mfd,en_u,de_u,en_d,de_d,coefh)
+c$OMP THREADPRIVATE(pyu1,pyv1,pftsol,ppsrf)
       real pftsol1(klon),pftsol2(klon),pftsol3(klon),pftsol4(klon)
       real ppsrf1(klon),ppsrf2(klon),ppsrf3(klon),ppsrf4(klon)
@@ -107,10 +117,10 @@
       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
-
+c$OMP THREADPRIVATE(dtcum,iadvtr,irec)
       data iadvtr,irec/0,1/
+      logical,save :: first=.true.
+c$OMP THREADPRIVATE(first)
 c
 c   Couche limite:
@@ -123,4 +133,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 +166,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 +277,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,55 +302,43 @@
 	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)
+
+c$OMP MASTER
       if (ok_sync) call histsync(physid)
+c$OMP END MASTER
 c     if (ok_sync) call histsync
 	
Index: /LMDZ4/trunk/libf/phylmd/phytrac.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/phytrac.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/phytrac.F	(revision 766)
@@ -63,34 +63,9 @@
 
       USE ioipsl
-
-#ifdef INCA
-      USE sflx
-      USE chem_tracnm
-      USE species_names
-      USE chem_mods
-#ifdef INCA_NMHC
-      USE pht_tables, ONLY : jrates
-      USE lightning, ONLY : prod_light
-#endif
-#ifdef INCA_CH4
-      USE pht_tables, ONLY : jrates
-      USE lightning, ONLY : prod_light
-#endif
-      USE transport_controls, ONLY : conv_flg, pbl_flg
-      USE airplane_src, ONLY : ptrop
-#ifdef INCA_AER
-      USE AEROSOL_MOD, only : ntr,trmx,trnx
-      USE AEROSOL_DIAG,only : cla,las,tausum,angst,aload,cload,totaerh2o,tau,
-     $  emiss20,sconc,scavcoef_st,scavcoef_cv
-     $  ,cload05ss  ,cload05bc  ,cload05pom  ,cload05dust  ,cload05so4
-     $  ,cload125ss  ,cload125bc  ,cload125pom  ,cload125dust  ,cload125so4
-      USE AEROSOL_PROGNOS, ONLY : md,mdw
-      USE AEROSOL_METEO, only : airm
-#endif
-#ifdef INCA_NMHC
-      USE RESISTANCE_DIAGNOSE, ONLY : surf_alb, sol_irrad, surf_temp, surf_wind,
-     $                                aero_resist, lamin_resist, surf_resist
-#endif
-#endif
+      USE dimphy
+      USE comgeomphy
+      USE iophy
+      USE vampir
+
       IMPLICIT none
 c======================================================================
@@ -108,5 +83,5 @@
 #include "YOMCST.h"
 #include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimphy.h"
 #include "indicesol.h"
 #include "clesphys.h"
@@ -114,5 +89,5 @@
 #include "paramet.h"
 #include "control.h"
-#include "comgeomphy.h"
+cym#include "comgeomphy.h"
 #include "advtrac.h"
 #include "thermcell.h"
@@ -162,4 +137,5 @@
 #ifdef INCA
       REAL flxmass_w(klon,klev)
+      CHARACTER(len=8) :: solsym(nqmax)
 #endif
 c      integer iflag_con
@@ -227,26 +203,35 @@
 cAA Pour l'instant seuls les cas du rn et du pb ont ete envisages.
 
-      REAL source(klon)       ! a voir lorsque le flux est prescrit 
+      REAL source(klon,nqmax)       ! a voir lorsque le flux est prescrit 
 cAA 
 cAA Pour la source de radon et son reservoir de sol
 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
+c$OMP THREADPRIVATE(trs)
+cym      SAVE trs
+      REAL :: trs_tmp(klon2)
+      REAL,SAVE,ALLOCATABLE :: trs_mpi(:)
+      
+      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
+c$OMP THREADPRIVATE(masktr)
+cym      SAVE masktr
+      REAL,save,allocatable :: fshtr(:,:)  ! Flux surfacique dans le reservoir de sol
+c$OMP THREADPRIVATE(fshtr)
+cym      SAVE fshtr
+      REAL,save,allocatable :: hsoltr(:)      ! Epaisseur equivalente du reservoir de sol
+c$OMP THREADPRIVATE(hsoltr)
+cym      SAVE hsoltr
+      REAL,save,allocatable :: tautr(:)       ! Constante de decroissance radioactive
+c$OMP THREADPRIVATE(tautr)
+cym      SAVE tautr
+      REAL,save,allocatable :: vdeptr(:)      ! Vitesse de depot sec dans la couche Brownienne
+c$OMP THREADPRIVATE(vdeptr)
+cym      SAVE vdeptr
+      REAL,save,allocatable :: scavtr(:)      ! Coefficient de lessivage
+c$OMP THREADPRIVATE(scavtr)
+cym      SAVE scavtr
 cAA
       CHARACTER*2 itn
@@ -257,11 +242,15 @@
       INTEGER nid_tra
       SAVE nid_tra
+c$OMP THREADPRIVATE(nid_tra)
 #ifdef INCA_AER
       INTEGER nid_tra2,nid_tra3
       SAVE nid_tra2,nid_tra3
+c$OMP THREADPRIVATE(nid_tra2,nid_tra3)
 #endif
 c     REAL x(klon,klev,nbtr+2) ! traceurs 
       INTEGER ndex(1)
       INTEGER ndex2d(iim*(jjm+1)),ndex3d(iim*(jjm+1)*klev)
+      REAL zx_tmp_fi2d(klon)      ! variable temporaire grille physique
+      REAL zx_tmp_fi3d(klon,klev) ! variable temporaire pour champs 3D 
       REAL zx_tmp_2d(iim,jjm+1), zx_tmp_3d(iim,jjm+1,klev)
       REAL zx_lon(iim,jjm+1), zx_lat(iim,jjm+1)
@@ -274,5 +263,6 @@
 c
 c      INTEGER ecrit_tra
-c      SAVE ecrit_tra   
+c      SAVE ecrit_tra 
+
       logical ok_sync
       parameter (ok_sync = .true.)
@@ -280,11 +270,12 @@
 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
+c$OMP THREADPRIVATE(aerosol,clsol,radio)  
+cym      save aerosol,clsol,radio
 C
 c======================================================================
@@ -334,4 +325,6 @@
       save first,couchelimite,convection,lessivage,
      s        sorties,inirnpb
+c$OMP THREADPRIVATE(first,couchelimite,convection,lessivage,
+c$OMP+              sorties,inirnpb)
 c      data first,couchelimite,convection,lessivage,sorties
 c     s     /.true.,.true.,.false.,.true.,.true./
@@ -345,46 +338,5 @@
       INTEGER           :: lastgas
       INTEGER           :: ncsec
-
-      INTEGER           :: prt_flag_ts(nbtr)=(/
-#ifdef INCA_CH4
-     .                                         1,1,1,0,0,1,1,1,1,1,
-     .                                         0,1,0,0,0,0,0,1,0,0,
-     .                                         0,1,1,1,1,0,1,1,1,0,
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,0,0
-#ifdef INCA_AER 
-     .                                        ,1,1,1,1,0,1,1,1,1,0,
-     .                                         1,1,1,1,1,1,0,1,0,1,
-     .                                         1,1,1,1,0,1,0,1,1,1
-#endif
-#endif
-#ifdef INCA_NMHC
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1
-#ifdef INCA_AER 
-     .                                        ,1,1,1,1,0,1,1,1,1,0,
-     .                                         1,1,1,1,1,1,0,1,0,1,
-     .                                         1,1,1,1,0,1,0,1,1,1
-#endif
-#endif
-#if defined(INCA_AER) && !defined(INCA_CH4) && !defined(INCA_NMHC)
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1,1,1,1,1,1,1,1,1
-#endif
-#if defined(INCA) && !defined(INCA_CH4) && !defined(INCA_NMHC) && !defined(INCA_AER)
-     .                                         1,1,1,1,1,1,1,1,1,1,
-     .                                         1                                         
-#endif
-
-     .                                         /)
-
+      INTEGER           :: prt_flag_ts(nbtr)  
 
       REAL, PARAMETER   :: dry_mass = 28.966
@@ -393,5 +345,5 @@
       REAL              :: calday
       REAL              :: pdel(klon,klev)
-      REAL              :: dummy(klon,klev) = 0.
+      REAL              :: dummy(klon,klev)
 #endif
 #ifdef INCA_AER
@@ -400,4 +352,49 @@
 c
 c======================================================================
+
+#ifdef INCA
+      prt_flag_ts(:)=(/
+#ifdef INCA_CH4
+     .             1,1,1,0,0,1,1,1,1,1,
+     .             0,1,0,0,0,0,0,1,0,0,
+     .             0,1,1,1,1,0,1,1,1,0,
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,0,0
+#ifdef INCA_AER 
+     .             ,1,1,1,1,0,1,1,1,1,0,
+     .             1,1,1,1,1,1,0,1,0,1,
+     .             1,1,1,1,0,1,0,1,1,1
+#endif
+#endif
+#ifdef INCA_NMHC
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1
+#ifdef INCA_AER 
+     .             ,1,1,1,1,0,1,1,1,1,0,
+     .             1,1,1,1,1,1,0,1,0,1,
+     .             1,1,1,1,0,1,0,1,1,1
+#endif
+#endif
+#if defined(INCA_AER) && !defined(INCA_CH4) && !defined(INCA_NMHC)
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1,1,1,1,1,1,1,1,1
+#endif
+#if defined(INCA) && !defined(INCA_CH4) && !defined(INCA_NMHC) && !defined(INCA_AER)
+     .             1,1,1,1,1,1,1,1,1,1,
+     .             1                                         
+#endif
+
+     .             /)
+      dummy(:,:) = 0.
+
+#endif
          modname='phytrac'
 
@@ -405,6 +402,20 @@
 
          if (debutphy) then
-
-c          ecrit_tra = NINT(86400./pdtphys *ecritphy) 
+           allocate( trs(klon,nbtr) )
+c$OMP MASTER
+	   allocate( trs_mpi(klon_mpi) )  
+c$OMP END MASTER           
+	   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) 
           print*,'dans phytrac ',pdtphys,ecritphy,ecrit_tra
 
@@ -435,9 +446,15 @@
 c        print*,'valeur de debut dans phytrac :',debutphy
          trs(:,:) = 0.
-
-         open (99,file='starttrac',status='old',
+c$OMP MASTER         
+       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_mpi,1)
+c$OMP END MASTER
+      call ScatterField_omp(trs_mpi,trs(:,1),1)
 c         print*, 'apres starttrac'
 
@@ -470,4 +487,6 @@
       endif
 #ifdef INCA
+      call VTe(VTphysiq)
+      call VTb(VTinca)
 !======================================================================
 !     Chimie
@@ -509,5 +528,6 @@
      $                 rneb,         ! for chimiaq
      $                 t_seri,       ! for chimiaq
-     $                 rh)
+     $                 rh,
+     $                 lafin)
 ! fin changement anne
 
@@ -515,5 +535,4 @@
 
         CALL chemmain (tr_seri,    !mmr
-     $                 nas,        !nas
      $                 nstep,      !nstep
      $                 calday,     !calday
@@ -550,5 +569,7 @@
      $                 obuf,       !obuf
      $                 iip1,       !nx
-     $                 jjp1)       !ny
+     $                 jjp1,       !ny
+     $                 source,
+     $                 solsym)
 #ifdef INCAINFO
 #ifdef INCA_AER
@@ -582,4 +603,6 @@
       END DO
 #endif
+      call VTe(VTinca)
+      call VTb(VTphysiq)
 #else
 
@@ -755,18 +778,14 @@
 C         CALL minmaxqfi(tr_seri(1,1,it),0.,1.e33,'cltracrn it='//itn)
       else ! couche limite avec flux prescrit
-#ifdef INCA
-        DO k =  1, klon
-          source(k) = eflux(k,it)-dflux(k,it)
-        END DO
-#else
+#ifndef INCA
 
 Cmaf provisoire source / traceur a creer
         DO i=1, klon
-          source(i) = 0.0 ! pas de source, pour l'instant
+          source(i,it) = 0.0 ! pas de source, pour l'instant
         ENDDO
 C
 #endif
           CALL cltrac(pdtphys, coefh,t_seri,
-     s               tr_seri(1,1,it), source,
+     s               tr_seri(1,1,it), source(:,it),
      e               paprs, pplay, delp,
      s               d_tr_cl(1,1,it))
@@ -904,10 +923,17 @@
       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_omp(trs(:,1),trs_mpi,1)
+c$OMP MASTER	 
+	 call GatherField(trs_mpi,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
+c$OMP END MASTER
       else
 c         print*, 'physique pas fini'
Index: /LMDZ4/trunk/libf/phylmd/plevel.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/plevel.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/plevel.F	(revision 766)
@@ -7,9 +7,9 @@
 c================================================================
 c================================================================
-
+      USE dimphy
       IMPLICIT none
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cy#include "dimphy.h"
 
 c================================================================
@@ -42,15 +42,24 @@
 c   -------
 
-      INTEGER lt(klon), lb(klon)
-      REAL ptop, pbot, aist(klon), aisb(klon)
+cym      INTEGER lt(klon), lb(klon)
+cym      REAL ptop, pbot, aist(klon), aisb(klon)
 
-      save lt,lb,ptop,pbot,aist,aisb
-
+cym      save lt,lb,ptop,pbot,aist,aisb
+      INTEGER,ALLOCATABLE,SAVE,DIMENSION(:) :: lt,lb,aist,aisb
+c$OMP THREADPRIVATE(lt,lb,aist,aisb)      
+      REAL,SAVE :: ptop, pbot
+c$OMP THREADPRIVATE(ptop, pbot)      
+      LOGICAL,SAVE :: first = .true.
+c$OMP THREADPRIVATE(first)
       INTEGER i, k
 c
-
+      if (first) then
+        allocate(lt(klon),lb(klon),aist(klon),aisb(klon))
+	first=.false.
+      endif
+      
 c=====================================================================
       if (lnew) then
-c   on réinitialise les réindicages et les poids
+c   on r�nitialise les r�ndicages et les poids
 c=====================================================================
 
@@ -87,5 +96,5 @@
 c
 c ...   Modif . P. Le Van    ( 20/01/98) ....
-c       Modif Frédéric Hourdin (3/01/02)
+c       Modif Fr��ic Hourdin (3/01/02)
 
         aist(i) = LOG( pgcm(i,lb(i))/ pres )
Index: /LMDZ4/trunk/libf/phylmd/radiornpb.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/radiornpb.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/radiornpb.F	(revision 766)
@@ -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/trunk/libf/phylmd/radlwsw.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/radlwsw.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/radlwsw.F	(revision 766)
@@ -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
@@ -403,10 +404,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
@@ -509,4 +510,7 @@
       DATA itapsw /0/
       DATA appel1er /.TRUE./
+      SAVE itapsw,appel1er
+c$OMP THREADPRIVATE(appel1er)
+c$OMP THREADPRIVATE(itapsw)
 cjq-Introduced for aerosol forcings
       real*8 flag_aer
@@ -522,17 +526,33 @@
       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(:,:)
+c$OMP THREADPRIVATE(ZFSUPAD)
+      REAL*8,allocatable,save :: ZFSDNAD(:,:)
+c$OMP THREADPRIVATE(ZFSDNAD)
+      REAL*8,allocatable,save :: ZFSUPAI(:,:)
+c$OMP THREADPRIVATE(ZFSUPAI)
+      REAL*8,allocatable,save :: ZFSDNAI(:,:)
+c$OMP THREADPRIVATE(ZFSDNAI)
       logical initialized
-      SAVE ZFSUPAD, ZFSDNAD, ZFSUPAI, ZFSDNAI ! aerosol fluxes
+cym      SAVE ZFSUPAD, ZFSDNAD, ZFSUPAI, ZFSDNAI ! aerosol fluxes
 !rv
       save flag_aer
+c$OMP THREADPRIVATE(flag_aer)
       data initialized/.false./
+      save initialized
+c$OMP THREADPRIVATE(initialized)
 cjq-end
       if(.not.initialized) then
         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
@@ -710,8 +730,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"
@@ -761,10 +782,14 @@
       REAL*8 ZPDH2O,ZPDUMG
       SAVE ZPDH2O,ZPDUMG
+c$OMP THREADPRIVATE(ZPDH2O,ZPDUMG)
       REAL*8 ZPRH2O,ZPRUMG
       SAVE ZPRH2O,ZPRUMG
+c$OMP THREADPRIVATE(ZPRH2O,ZPRUMG)
       REAL*8 RTDH2O,RTDUMG
       SAVE RTDH2O,RTDUMG
+c$OMP THREADPRIVATE(RTDH2O,RTDUMG)
       REAL*8 RTH2O ,RTUMG
       SAVE RTH2O ,RTUMG
+c$OMP THREADPRIVATE(RTH2O ,RTUMG)
       DATA ZPDH2O,ZPDUMG / 0.8   , 0.75 /
       DATA ZPRH2O,ZPRUMG / 30000., 30000. /
@@ -900,8 +925,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     ------------------------------------------------------------------
@@ -991,6 +1017,8 @@
       REAL*8 RSUN(2)
       SAVE RSUN
+c$OMP THREADPRIVATE(RSUN)
       REAL*8 RRAY(2,6)
       SAVE RRAY
+c$OMP THREADPRIVATE(RRAY)
       DATA RSUN(1) / 0.441676 /
       DATA RSUN(2) / 0.558324 /
@@ -1140,8 +1168,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
@@ -1264,6 +1293,8 @@
       REAL*8 RSUN(2)
       SAVE RSUN
+c$OMP THREADPRIVATE(RSUN)
       REAL*8 RRAY(2,6)
       SAVE RRAY
+c$OMP THREADPRIVATE(RRAY)
       DATA RSUN(1) / 0.441676 /
       DATA RSUN(2) / 0.558324 /
@@ -1686,8 +1717,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"
@@ -1759,4 +1791,5 @@
       REAL*8 TAUA(2,5), RPIZA(2,5), RCGA(2,5)
       SAVE TAUA, RPIZA, RCGA
+c$OMP THREADPRIVATE(TAUA, RPIZA, RCGA)
       DATA ((TAUA(IN,JA),JA=1,5),IN=1,2) /
      S .730719, .912819, .725059, .745405, .682188 ,
@@ -2046,8 +2079,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"
@@ -2402,8 +2436,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     ------------------------------------------------------------------
@@ -2533,8 +2568,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-----------------------------------------------------------------------
@@ -2583,4 +2619,5 @@
       REAL*8 APAD(2,3,7), BPAD(2,3,7), D(2,3)
       SAVE APAD, BPAD, D
+c$OMP THREADPRIVATE(APAD, BPAD, D)
       DATA ((APAD(1,I,J),I=1,3),J=1,7) /
      S 0.912418292E+05, 0.000000000E-00, 0.925887084E-04,
@@ -2649,8 +2686,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-----------------------------------------------------------------------
@@ -2701,4 +2739,5 @@
       REAL*8 APAD(2,3,7), BPAD(2,3,7), D(2,3)
       SAVE APAD, BPAD, D
+c$OMP THREADPRIVATE(APAD, BPAD, D)
       DATA ((APAD(1,I,J),I=1,3),J=1,7) /
      S 0.912418292E+05, 0.000000000E-00, 0.925887084E-04,
@@ -2778,9 +2817,12 @@
      .              PTOPLW,PSOLLW,PTOPLW0,PSOLLW0,
      .              psollwdown,
+cIM  .              psollwdown,psollwdownclr,
+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"
@@ -2844,4 +2886,8 @@
 c Rajout LF
       real*8 psollwdown(kdlon)    ! LONGWAVE downwards flux at surface
+c Rajout IM
+cIM   real*8 psollwdownclr(kdlon) ! LONGWAVE CS downwards flux at surface
+cIM   real*8 ptoplwdown(kdlon)    ! LONGWAVE downwards flux at T.O.A.
+cIM   real*8 ptoplwdownclr(kdlon) ! LONGWAVE CS downwards flux at T.O.A.
 cIM
       REAL*8 plwup(KDLON,KFLEV+1)  ! LW up total sky
@@ -2853,11 +2899,18 @@
       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$OMP THREADPRIVATE(ZFLUX, ZFLUC, ZBINT, ZBSUI, ZCTS, ZCNTRB)
 c
       INTEGER ilim, i, k, kpl1
@@ -2871,6 +2924,8 @@
       LOGICAL appel1er
       SAVE appel1er, itaplw0, itaplw
+c$OMP THREADPRIVATE(appel1er, itaplw0, itaplw)
       DATA appel1er /.TRUE./
       DATA itaplw0,itaplw /0,0/
+
 C     ------------------------------------------------------------------
       IF (appel1er) THEN
@@ -2878,4 +2933,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
@@ -2940,8 +3002,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"
@@ -3038,12 +3101,17 @@
       REAL*8 TREF
       SAVE TREF
+c$OMP THREADPRIVATE(TREF)
       REAL*8 RT1(2)
       SAVE RT1
+c$OMP THREADPRIVATE(RT1)
       REAL*8 RAER(5,5)
       SAVE RAER
+c$OMP THREADPRIVATE(RAER)
       REAL*8 AT(8,3), BT(8,3)
       SAVE AT, BT
+c$OMP THREADPRIVATE(AT, BT)
       REAL*8 OCT(4)
       SAVE OCT
+c$OMP THREADPRIVATE(OCT)
       DATA TREF /250.0/
       DATA (RT1(IG1),IG1=1,2) / -0.577350269, +0.577350269 /
@@ -3333,8 +3401,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"
@@ -3424,8 +3493,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"
@@ -3829,8 +3899,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
@@ -3925,8 +3996,11 @@
       REAL*8 TINTP(11)
       SAVE TINTP
+c$OMP THREADPRIVATE(TINTP)
       REAL*8 GA(11,16,3), GB(11,16,3)
       SAVE GA, GB
+c$OMP THREADPRIVATE(GA, GB)
       REAL*8 XP(6,6)
       SAVE XP
+c$OMP THREADPRIVATE(XP)
 c
       DATA TINTP / 187.5, 200., 212.5, 225., 237.5, 250.,
@@ -5240,8 +5314,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"
@@ -5353,8 +5428,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"
@@ -5685,8 +5761,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
@@ -5937,8 +6014,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
@@ -6001,4 +6079,5 @@
       REAL*8 WG1(2)
       SAVE WG1
+c$OMP THREADPRIVATE(WG1)
       DATA (WG1(jk),jk=1,2) /1.0, 1.0/
 C-----------------------------------------------------------------------
@@ -6144,8 +6223,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
@@ -6319,8 +6399,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/trunk/libf/phylmd/readsulfate.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/readsulfate.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/readsulfate.F	(revision 766)
@@ -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,5 +34,5 @@
 #include "chem.h"      
 #include "dimensions.h"      
-#include "dimphy.h"      
+cym#include "dimphy.h"      
 #include "temps.h"      
 c 
@@ -45,6 +45,8 @@
 c Output:      
 c -------     
+      REAL*8  sulfate_p(klon_omp,klev)
       REAL*8  sulfate (klon, klev)  ! Mass of sulfate (monthly mean data, 
                                   !  from file) [ug SO4/m3]
+      REAL*8,SAVE,ALLOCATABLE :: sulfate_mpi(:,:) 
 c      
 c Local Variables:
@@ -62,13 +64,31 @@
       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(:, :)
+c$OMP THREADPRIVATE(so4,so4_out)
       
       LOGICAL lnewday 
       LOGICAL lonlyone
       PARAMETER (lonlyone=.FALSE.)
-
+      logical,save :: first2=.true.
+c$OMP THREADPRIVATE(first2)
+
+c$OMP MASTER
+      if (first2) then
+     
+        allocate( so4(klon, klev, 12) )
+        allocate( so4_out(klon, klev))
+        allocate(sulfate_mpi(klon_mpi,klev))  
+        first2=.false.
+	
+      endif
+
+      if (phy_rank==0) then
+            
       iday = INT(r_day) 
       
@@ -265,5 +285,12 @@
 
       ENDIF ! Did I have to do anything (was it a new day?)
-      
+
+      endif   ! phy_rank==0
+      
+      call ScatterField(real(sulfate),real(sulfate_mpi),klev)
+c$OMP END MASTER
+      call ScatterField_omp(real(sulfate_mpi),real(sulfate_p)
+     . ,klev)            
+
       RETURN
       END
@@ -277,6 +304,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
       
@@ -305,5 +332,5 @@
 #include "chem.h"      
 #include "dimensions.h"      
-#include "dimphy.h"      
+cym#include "dimphy.h"      
 #include "temps.h"      
 c 
@@ -316,6 +343,9 @@
 c Output:      
 c -------     
+      REAL*8  pi_sulfate_p (klon_omp, klev)  
+                                 
       REAL*8  pi_sulfate (klon, klev)  ! Number conc. sulfate (monthly mean data, 
-                                  !  from file)
+                                  !  from fil
+      REAL*8,SAVE,ALLOCATABLE :: pi_sulfate_mpi(:,:)			  
 c      
 c Local Variables:
@@ -327,13 +357,31 @@
       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(:, :)
+c$OMP THREADPRIVATE(pi_so4,pi_so4_out)            
       
       CHARACTER*4 cyear
       LOGICAL lnewday
-
+      logical,save :: first2=.true.
+c$OMP THREADPRIVATE(first2)
+
+c$OMP MASTER
+      if (first2) then
+     
+        allocate( pi_so4(klon, klev, 12) )
+        allocate( pi_so4_out(klon, klev))
+        allocate(pi_sulfate_mpi (klon_mpi, klev))  
+        first2=.false.
+	
+      endif
+
+      if (phy_rank==0) then
+    
       
 
@@ -479,4 +527,12 @@
 
       ENDIF ! Was this the beginning of a new day?
+
+      endif   ! phy_rank==0
+      
+      call ScatterField(real(pi_sulfate),real(pi_sulfate_mpi),klev)
+c$OMP END MASTER
+      call ScatterField_omp(real(pi_sulfate_mpi),real(pi_sulfate_p)
+     .,klev)            
+
       RETURN
       END
Index: /LMDZ4/trunk/libf/phylmd/soil.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/soil.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/soil.F	(revision 766)
@@ -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"
@@ -69,7 +70,7 @@
 
       INTEGER ig,jk
-c$$$      REAL zdz2(nsoilmx),z1(klon)
+c@$$      REAL zdz2(nsoilmx),z1(klon)
       REAL zdz2(nsoilmx),z1(klon,nbsrf)
-      REAL min_period,dalph_soil
+      REAL,SAVE :: min_period,dalph_soil
       REAL ztherm_i(klon)
 
@@ -77,18 +78,24 @@
 c   ----------------------
       REAL dz1(nsoilmx),dz2(nsoilmx)
-c$$$          REAL zc(klon,nsoilmx),zd(klon,nsoilmx)
-      REAL zc(klon,nsoilmx,nbsrf),zd(klon,nsoilmx,nbsrf)
+c@$$          REAL zc(klon,nsoilmx),zd(klon,nsoilmx)
+cym      REAL zc(klon,nsoilmx,nbsrf),zd(klon,nsoilmx,nbsrf)
+      REAL,ALLOCATABLE,SAVE ::  zc(:,:,:),zd(:,:,:)
+c$OMP THREADPRIVATE(zc,zd)
       REAL lambda
-      SAVE dz1,dz2,zc,zd,lambda
+cym      SAVE dz1,dz2,zc,zd,lambda
+      SAVE dz1,dz2,lambda
+c$OMP THREADPRIVATE(dz1,dz2,lambda)
       LOGICAL firstcall, firstsurf(nbsrf)
       SAVE firstcall, firstsurf
+c$OMP THREADPRIVATE(firstcall, firstsurf)
       REAL isol,isno,iice
       SAVE isol,isno,iice
-
+c$OMP THREADPRIVATE(isol,isno,iice)
       DATA firstcall/.true./
       DATA firstsurf/.TRUE.,.TRUE.,.TRUE.,.TRUE./
 
       DATA isol,isno,iice/2000.,2000.,2000./
-
+      LOGICAL,SAVE :: First=.true.
+c$OMP THREADPRIVATE(First)
 c-----------------------------------------------------------------------
 c   Depthts:
@@ -103,4 +110,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
@@ -128,5 +140,5 @@
 
 
-c$$$      IF (firstcall) THEN
+c@$$      IF (firstcall) THEN
       IF (firstsurf(indice)) THEN 
 
@@ -138,5 +150,5 @@
          min_period=1800. ! en secondes
          dalph_soil=2.    ! rapport entre les epaisseurs de 2 couches succ.
-
+c$OMP MASTER
          OPEN(99,file='soil.def',status='old',form='formatted',err=9999)
          READ(99,*) min_period
@@ -147,4 +159,6 @@
          CLOSE(99)
 9999     CONTINUE
+c$OMP END MASTER
+c$OMP BARRIER
 
 c   la premiere couche represente un dixieme de cycle diurne
@@ -172,5 +186,5 @@
 C PB
          firstsurf(indice) = .FALSE. 
-c$$$         firstcall =.false.
+c@$$         firstcall =.false.
 
 c   Initialisations:
@@ -202,5 +216,5 @@
 c   ---------------------------------------------------------------
 
-c$$$  PB ajout pour cas glace de mer
+c@$$  PB ajout pour cas glace de mer
       IF (indice .EQ. is_sic) THEN
           DO ig = 1 , knon
Index: /LMDZ4/trunk/libf/phylmd/suphec.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/suphec.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/suphec.F	(revision 766)
@@ -9,5 +9,7 @@
        LOGICAL firstcall
        SAVE firstcall
+c$OMP THREADPRIVATE(firstcall)
        DATA firstcall /.TRUE./
+       
        IF (firstcall) THEN
          PRINT*, 'suphec initialise les constantes du GCM'
Index: /LMDZ4/trunk/libf/phylmd/tetalevel.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/tetalevel.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/tetalevel.F	(revision 766)
@@ -4,9 +4,9 @@
 c================================================================
 c================================================================
-
+      USE dimphy
       IMPLICIT none
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
 c================================================================
@@ -39,16 +39,24 @@
 c   -------
 c
-#include "paramet.h"
+cym#include "paramet.h"
 c
-      INTEGER lt(ip1jmp1), lb(ip1jmp1)
-      REAL ptop, pbot, aist(ip1jmp1), aisb(ip1jmp1)
-      save lt,lb,ptop,pbot,aist,aisb
+      INTEGER,ALLOCATABLE,SAVE :: lt(:), lb(:)
+      REAL,ALLOCATABLE,SAVE    :: aist(:), aisb(:)
+      REAL,SAVE :: ptop, pbot 
+      LOGICAL,SAVE :: first = .TRUE.
+c$OMP THREADPRIVATE(lt,lb,aist,aisb,ptop, pbot,first)
 
       INTEGER i, k
 c
 c     PRINT*,'tetalevel pres=',pres
+      IF (first) THEN
+        ALLOCATE(lt(ilon), lb(ilon))
+	ALLOCATE(aist(ilon), aisb(ilon))
+	
+	first=.FALSE.
+      ENDIF
 c=====================================================================
       if (lnew) then
-c   on réinitialise les réindicages et les poids
+c   on r�nitialise les r�ndicages et les poids
 c=====================================================================
 
@@ -89,5 +97,5 @@
 c
 c ...   Modif . P. Le Van    ( 20/01/98) ....
-c       Modif Frédéric Hourdin (3/01/02)
+c       Modif Fr��ic Hourdin (3/01/02)
 
 c       IF(pgcm(i,lb(i)).NE.0.OR.
Index: /LMDZ4/trunk/libf/phylmd/thermcell.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/thermcell.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/thermcell.F	(revision 766)
@@ -6,5 +6,5 @@
 c    s                  ,pu_therm,pv_therm
      s                  ,r_aspect,l_mix,w2di,tho)
-
+      USE dimphy
       IMPLICIT NONE
 
@@ -14,11 +14,11 @@
 c   de "thermiques" explicitement representes
 c
-c   Réécriture à partir d'un listing papier à Habas, le 14/02/00
-c
-c   le thermique est supposé homogène et dissipé par mélange avec
-c   son environnement. la longueur l_mix contrôle l'efficacité du
-c   mélange
-c
-c   Le calcul du transport des différentes espèces se fait en prenant
+c   Reecriture a partir d'un listing papier à Habas, le 14/02/00
+c
+c   le thermique est suppose homogene et dissipe par melange avec
+c   son environnement. la longueur l_mix controle l'efficacite du
+c   melange
+c
+c   Le calcul du transport des differentes especes se fait en prenant
 c   en compte:
 c     1. un flux de masse montant
@@ -33,6 +33,6 @@
 c   -------------
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 
@@ -52,5 +52,5 @@
       save idetr
       data idetr/3/
-
+c$OMP THREADPRIVATE(idetr)
 c   local:
 c   ------
@@ -85,6 +85,7 @@
       real fracc(klon,klev+1)
       real zf,zf2
-      real thetath2(klon,klev),wth2(klon,klev)
-      common/comtherm/thetath2,wth2
+      real,allocatable,save :: thetath2(:,:),wth2(:,:)
+c$OMP THREADPRIVATE(thetath2,wth2)
+cym      common/comtherm/thetath2,wth2
 
       real count_time
@@ -93,5 +94,5 @@
       data isplit/0/
       save isplit
-
+c$OMP THREADPRIVATE(isplit)
       logical sorties
       real rho(klon,klev),rhobarz(klon,klev+1),masse(klon,klev)
@@ -120,4 +121,5 @@
       data first /.false./
       save first
+c$OMP THREADPRIVATE(first)
 cRC
 
@@ -132,5 +134,7 @@
       save ncorrec
       data ncorrec/0/
-      
+c$OMP THREADPRIVATE(ncorrec)
+      logical,save :: firstCall=.true.
+c$OMP THREADPRIVATE(firstCall)
 c
 c-----------------------------------------------------------------------
@@ -138,4 +142,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
@@ -501,5 +512,5 @@
 c   calcul de la largeur de chaque ascendance dans le cas conservatif.
 c   dans ce cas simple, on suppose que la largeur de l'ascendance provenant
-c   d'une couche est égale à la hauteur de la couche alimentante.
+c   d'une couche est egale a la hauteur de la couche alimentante.
 c   La vitesse maximale dans l'ascendance est aussi prise comme estimation
 c   de la vitesse d'entrainement horizontal dans la couche alimentante.
@@ -540,5 +551,5 @@
 c      print*,'10 OK convect8'
 c     print*,'WA2 ',wa_moy
-c   calcul de la fraction de la maille concernée par l'ascendance en tenant
+c   calcul de la fraction de la maille concerne  par l'ascendance en tenant
 c   compte de l'epluchage du thermique.
 c
@@ -979,4 +990,5 @@
       subroutine dqthermcell(ngrid,nlay,ptimestep,fm,entr,masse
      .    ,q,dq,qa)
+      use dimphy
       implicit none
 
@@ -989,6 +1001,6 @@
 c=======================================================================
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       integer ngrid,nlay
@@ -1053,4 +1065,5 @@
      .    ,fraca,larga
      .    ,u,v,du,dv,ua,va)
+       use dimphy
       implicit none
 
@@ -1063,6 +1076,6 @@
 c=======================================================================
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       integer ngrid,nlay
@@ -1106,5 +1119,5 @@
             if ((fm(ig,k+1)+detr(ig,k))*ptimestep.gt.
      s         1.e-5*masse(ig,k)) then
-c   On itère sur la valeur du coeff de freinage.
+c   On itere sur la valeur du coeff de freinage.
 c              gamma0=rho(ig,k)*(zlev(ig,k+1)-zlev(ig,k))
                gamma0=masse(ig,k)
@@ -1112,5 +1125,5 @@
      s         *0.5/larga(ig)
 c              gamma0=0.
-c   la première fois on multiplie le coefficient de freinage
+c   la premiere fois on multiplie le coefficient de freinage
 c   par le module du vent dans la couche en dessous.
                dua=ua(ig,k-1)-u(ig,k-1)
@@ -1166,4 +1179,5 @@
       subroutine dqthermcell2(ngrid,nlay,ptimestep,fm,entr,masse,frac
      .    ,q,dq,qa)
+      use dimphy
       implicit none
 
@@ -1176,6 +1190,6 @@
 c=======================================================================
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       integer ngrid,nlay
@@ -1246,4 +1260,5 @@
      .    ,fraca,larga
      .    ,u,v,du,dv,ua,va)
+      use dimphy
       implicit none
 
@@ -1256,6 +1271,6 @@
 c=======================================================================
 
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 
       integer ngrid,nlay
@@ -1302,5 +1317,5 @@
             if ((fm(ig,k+1)+detr(ig,k))*ptimestep.gt.
      s         1.e-5*masse(ig,k)) then
-c   On itère sur la valeur du coeff de freinage.
+c   On itere sur la valeur du coeff de freinage.
 c              gamma0=rho(ig,k)*(zlev(ig,k+1)-zlev(ig,k))
                gamma0=masse(ig,k)
@@ -1313,5 +1328,5 @@
                zf=0.
                zf2=1./(1.-zf)
-c   la première fois on multiplie le coefficient de freinage
+c   la premiere fois on multiplie le coefficient de freinage
 c   par le module du vent dans la couche en dessous.
                dua=ua(ig,k-1)-u(ig,k-1)
Index: /LMDZ4/trunk/libf/phylmd/thermcell.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/thermcell.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/thermcell.h	(revision 766)
@@ -7,2 +7,3 @@
      s              ,w2di_thermals
 
+c$OMP THREADPRIVATE(/ctherm/)
Index: /LMDZ4/trunk/libf/phylmd/tlift.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/tlift.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/tlift.F	(revision 766)
@@ -201,7 +201,7 @@
         SNEW=1./SNEW
         TPK(I)=TG+(ALF*QI(I)+ALV*RG*(1.-(ESI/ES)))*SNEW
-c$$$        PRINT*,'################################'
-c$$$        PRINT*,TPK(I)
-c$$$        PRINT*,(ALF*QI(I)+ALV*RG*(1.-(ESI/ES)))*SNEW
+c@$$        PRINT*,'################################'
+c@$$        PRINT*,TPK(I)
+c@$$        PRINT*,(ALF*QI(I)+ALV*RG*(1.-(ESI/ES)))*SNEW
         ENDDO
 CCC        CLW(I)=RR(1)-QSAT_NEW
Index: /LMDZ4/trunk/libf/phylmd/transp.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/transp.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/transp.F	(revision 766)
@@ -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/trunk/libf/phylmd/transp_lay.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/transp_lay.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/transp_lay.F	(revision 766)
@@ -3,4 +3,5 @@
      s                   vtran_e, vtran_q, utran_e, utran_q)
 c
+      USE dimphy
       IMPLICIT none
 c======================================================================
@@ -10,6 +11,6 @@
 c======================================================================
 c
-#include "dimensions.h"
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym#include "dimphy.h"
 #include "YOMCST.h"
 c
Index: /LMDZ4/trunk/libf/phylmd/undefSTD.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/undefSTD.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/undefSTD.F	(revision 766)
@@ -2,4 +2,5 @@
      $           dtime,ecrit_hf,
      $           oknondef,tnondef,tsumSTD)
+      USE dimphy
       IMPLICIT none
 c
@@ -23,8 +24,8 @@
 c====================================================================
 c
-#include "dimensions.h"
-      integer jjmp1
-      parameter (jjmp1=jjm+1-1/jjm)
-#include "dimphy.h"
+cym#include "dimensions.h"
+cym      integer jjmp1
+cym      parameter (jjmp1=jjm+1-1/jjm)
+cym#include "dimphy.h"
 c variables Input
       INTEGER nlevSTD, klevSTD, itap
Index: /LMDZ4/trunk/libf/phylmd/ustarhb.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/ustarhb.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/ustarhb.F	(revision 766)
@@ -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/trunk/libf/phylmd/vdif_kcay.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/vdif_kcay.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/vdif_kcay.F	(revision 766)
@@ -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 (
@@ -221,4 +222,5 @@
       save first
       data first/.true./
+c$OMP THREADPRIVATE(first)
 c.......................................................................
 c  traitment des valeur de q2 en entree
@@ -226,5 +228,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/trunk/libf/phylmd/wrgradsfi.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/wrgradsfi.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/wrgradsfi.F	(revision 766)
@@ -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/trunk/libf/phylmd/write_bilKP_ave.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_bilKP_ave.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_bilKP_ave.h	(revision 766)
@@ -11,137 +11,104 @@
       itau_w = itau_phy + itap
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, ue_lay,zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"ue",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, ue_lay,zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"ue",itau_w,ue_lay)
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, ve_lay,zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"ve",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, ve_lay,zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"ve",itau_w,ve_lay)
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, uq_lay,zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"uq",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, uq_lay,zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"uq",itau_w,uq_lay)
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, vq_lay,zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"vq",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, vq_lay,zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"vq",itau_w,vq_lay)
 c
 c Champs 3D:
 C
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"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_bilKPave,"temp",itau_w,t_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"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_bilKPave,"ovap",itau_w,qx(:,:,ivap))
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"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_bilKPave,"geop",itau_w,zphi)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"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_bilKPave,"vitu",itau_w,u_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"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_bilKPave,"vitv",itau_w,v_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"vitw",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"vitw",itau_w,omega)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"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_bilKPave,"pres",itau_w,pplay)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, paprs, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"play",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, paprs, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"play",itau_w,paprs)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldliq, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"oliq",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldliq, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"oliq",itau_w,cldliq)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_dyn, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dtdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_dyn, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dtdyn",itau_w,d_t_dyn)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_dyn, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dqdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_dyn, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dqdyn",itau_w,d_q_dyn)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_con, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dtcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_con, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dtcon",itau_w,d_t_con)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_con, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"ducon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_con, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"ducon",itau_w,d_u_con)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_con, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dvcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_con, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dvcon",itau_w,d_v_con)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_con, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dqcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_con, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dqcon",itau_w,d_q_con)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_lsc, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dtlsc",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_lsc, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dtlsc",itau_w,d_t_lsc)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_lsc, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dqlsc",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_lsc, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dqlsc",itau_w,d_q_lsc)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_vdf, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"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_bilKPave,"dtvdf",itau_w,d_t_vdf)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_vdf, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"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_bilKPave,"dqvdf",itau_w,d_q_vdf)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_ajs, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dtajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_ajs, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dtajs",itau_w,d_t_ajs)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_ajs, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dqajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_ajs, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dqajs",itau_w,d_q_ajs)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_eva, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dteva",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_eva, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dteva",itau_w,d_t_eva)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_eva, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dqeva",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_eva, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dqeva",itau_w,d_q_eva)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dtswr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dtswr",itau_w,heat)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat0, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dtsw0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat0, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dtsw0",itau_w,heat0)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dtlwr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dtlwr",itau_w,cool)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool0, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dtlw0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool0, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dtlw0",itau_w,cool0)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_vdf, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"duvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_vdf, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"duvdf",itau_w,d_u_vdf)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dvvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dvvdf",itau_w,d_v_vdf)
 c
       IF (ok_orodr) THEN
@@ -155,36 +122,29 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oli, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"duoli",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oli, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"duoli",d_u_oli)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_oli, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dvoli",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_oli, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dvoli",itau_w,d_v_oli)
 c
       ENDIF
       ENDIF
 C
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"duphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"duphy",itau_w,d_u)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dvphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dvphy",itau_w,d_v)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t, zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dtphy",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_bilKPave,"dtphy",itau_w,d_t)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,1), 
-     .zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dqphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,1), 
+cymf     .zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dqphy",itau_w,d_qx(:,:,1))
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,2), 
-     .zx_tmp_3d)
-      CALL histwrite(nid_bilKPave,"dqlphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,2), 
+cym     .zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPave,"dqlphy",itau_w,d_qx(:,:,2))
 c
 C
Index: /LMDZ4/trunk/libf/phylmd/write_bilKP_ins.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_bilKP_ins.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_bilKP_ins.h	(revision 766)
@@ -1,3 +1,3 @@
-c
+ c
 c $Header$
 c
@@ -11,137 +11,104 @@
 c Champs 3D:
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, ue_lay,zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"ue",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, ue_lay,zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"ue",itau_w,ue_lay)
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, ve_lay,zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"ve",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, ve_lay,zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"ve",itau_w,ve_lay)
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, uq_lay,zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"uq",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, uq_lay,zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"uq",itau_w,uq_lay)
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, vq_lay,zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"vq",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, vq_lay,zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"vq",itau_w,vq_lay)
 c
 c Champs 3D:
 C
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, t_seri, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"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_bilKPins,"temp",itau_w,t_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, qx(1,1,ivap), zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"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_bilKPins,"ovap",itau_w,qx(:,:,ivap))
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"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_bilKPins,"geop",itau_w,zphi)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, u_seri, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"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_bilKPins,"vitu",itau_w,u_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"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_bilKPins,"vitv",itau_w,v_seri)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"vitw",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, omega, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"vitw",itau_w,omega)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"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_bilKPins,"pres",itau_w,pplay)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, paprs, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"play",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, paprs, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"play",itau_w,paprs)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldliq, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"oliq",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldliq, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"oliq",itau_w,cldliq)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_dyn, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dtdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_dyn, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dtdyn",itau_w,d_t_dyn)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_dyn, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dqdyn",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_dyn, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dqdyn",itau_w,d_q_dyn)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_con, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dtcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_con, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dtcon",itau_w,d_t_con)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_con, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"ducon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_con, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"ducon",itau_w,d_u_con)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_con, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dvcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_con, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dvcon",itau_w,d_v_con)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_con, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dqcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_con, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dqcon",itau_w,d_q_con)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_lsc, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dtlsc",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_lsc, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dtlsc",itau_w,d_t_lsc)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_lsc, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dqlsc",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_lsc, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dqlsc",itau_w,d_q_lsc)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_vdf, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"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_bilKPins,"dtvdf",itau_w,d_t_vdf)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_vdf, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"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_bilKPins,"dqvdf",itau_w,d_q_vdf)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_ajs, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dtajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_ajs, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dtajs",itau_w,d_t_ajs)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_ajs, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dqajs",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_ajs, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dqajs",itau_w,d_q_ajs)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_eva, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dteva",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t_eva, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dteva",itau_w,d_t_eva)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_eva, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dqeva",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_q_eva, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dqeva",itau_w,d_q_eva)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dtswr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dtswr",itau_w,heat)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat0, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dtsw0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, heat0, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dtsw0",itau_w,heat0)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dtlwr",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dtlwr",itau_w,cool)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool0, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dtlw0",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cool0, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dtlw0",itau_w,cool0)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_vdf, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"duvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_vdf, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"duvdf",itau_w,d_u_vdf)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dvvdf",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_vdf, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dvvdf",itau_w,d_v_vdf)
 c
       IF (ok_orodr) THEN
@@ -155,36 +122,29 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oli, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"duoli",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u_oli, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"duoli",itau_w,d_u_oli)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_oli, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dvoli",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v_oli, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dvoli",itau_w,d_v_oli)
 c
       ENDIF
       ENDIF
 C
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"duphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_u, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"duphy",itau_w,d_u)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dvphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_v, zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dvphy",itau_w,d_v)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t, zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dtphy",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_bilKPins,"dtphy",itau_w,d_t)
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,1), 
-     .zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dqphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,1), 
+cym     .zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dqphy",itau_w,d_qx(:,:,1))
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,2), 
-     .zx_tmp_3d)
-      CALL histwrite(nid_bilKPins,"dqlphy",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_qx(:,:,2), 
+cym     .zx_tmp_3d)
+      CALL histwrite_phy(nid_bilKPins,"dqlphy",itau_w,d_qx(:,:,2))
 c
 cIM 280405 BEG
@@ -201,11 +161,9 @@
        IF(bb2.EQ."850") THEN
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,usumSTD(:,k,1),zx_tmp_2d)
-        CALL histwrite(nid_bilKPins,"u"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,usumSTD(:,k,1),zx_tmp_2d)
+        CALL histwrite_phy(nid_bilKPins,"u"//bb2,itau_w,usumSTD(:,k,1))
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,vsumSTD(:,k,1),zx_tmp_2d)
-        CALL histwrite(nid_bilKPins,"v"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,vsumSTD(:,k,1),zx_tmp_2d)
+        CALL histwrite_phy(nid_bilKPins,"v"//bb2,itau_w,vsumSTD(:,k,1))
 c
        ENDIF !(bb2.EQ."850")
Index: /LMDZ4/trunk/libf/phylmd/write_histISCCP.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histISCCP.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histISCCP.h	(revision 766)
@@ -15,16 +15,16 @@
         DO k=1,kmaxm1
          zx_tmp_fi3d(1:klon, 1:lmaxm1)=fq_isccp(1:klon,k,1:lmaxm1,n)*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)//typinout(n),
-     .                  itau_w,zx_tmp_3d,iim*jjmp1*lmaxm1,ndex3d)
+       CALL histwrite_phy(nid_isccp,"cldISCCP_"//taulev(k)//typinout(n),
+     .                  itau_w,zx_tmp_fi3d)
         ENDDO !k
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:,n),zx_tmp_2d)
-        CALL histwrite(nid_isccp,"nsunlit"//typinout(n),itau_w,
-     .                 zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:,n),zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"nsunlit"//typinout(n),itau_w,
+     .                 nbsunlit(1,:,n))
 c
         ENDDO ! n=1, napisccp
@@ -50,25 +50,25 @@
           ENDDO
          ENDIF
-         CALL gr_fi_ecrit(1,klon,iim,jjmp1,fq_is_true,
-     .                    zx_tmp_2d)
+cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,fq_is_true,
+cym     .                    zx_tmp_2d)
 c
 cIM: champ 2d : (lon,lat) pour un tau et une pc fixes
 c
-         CALL histwrite(nid_isccp,pclev(l)//taulev(k)//typinout(n),
-     .                  itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+         CALL histwrite_phy(nid_isccp,pclev(l)//taulev(k)//typinout(n),
+     .                  itau_w,fq_is_true(:,:,l,n))
          ENDDO !l
         ENDDO !k
 c
 c       print*,'n=',n,' write_ISCCP avant nbsunlit'
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:,n),zx_tmp_2d)
-        CALL histwrite(nid_isccp,"nsunlit"//typinout(n),
-     .                 itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,nbsunlit(1,:,n),zx_tmp_2d)
+        CALL histwrite_phy(nid_isccp,"nsunlit"//typinout(n),
+     .                 itau_w,nbsunlit(1,:,n))
 c
         zx_tmp_fi2d(1:klon)=float(seed(1:klon,n))
 c
 c       print*,'n=',n,' write_ISCCP avant seed'
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"seed"//verticaxe(n),
-     .                 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_isccp,"seed"//verticaxe(n),
+     .                 itau_w,zx_tmp_fi2d)
 c
 c 9types de nuages ISCCP-D2
@@ -80,7 +80,6 @@
      $  fq_is_true(i,1,3,n)+ fq_is_true(i,2,3,n)+ fq_is_true(i,3,3,n) )
         ENDDO
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"cirr",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_isccp,"cirr",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -90,7 +89,6 @@
      $   fq_is_true(i,4,3,n)+ fq_is_true(i,5,3,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"cist",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_isccp,"cist",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -100,7 +98,6 @@
      $   fq_is_true(i,6,3,n)+ fq_is_true(i,7,3,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"deep",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_isccp,"deep",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -109,7 +106,6 @@
      $  fq_is_true(i,1,5,n)+ fq_is_true(i,2,5,n)+ fq_is_true(i,3,5,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"alcu",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_isccp,"alcu",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -118,7 +114,6 @@
      $   fq_is_true(i,4,5,n)+ fq_is_true(i,5,5,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"alst",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_isccp,"alst",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -127,7 +122,6 @@
      $   fq_is_true(i,6,5,n)+ fq_is_true(i,7,5,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"nist",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_isccp,"nist",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -136,7 +130,6 @@
      $  fq_is_true(i,1,7,n)+ fq_is_true(i,2,7,n)+ fq_is_true(i,3,7,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"cumu",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_isccp,"cumu",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -145,7 +138,6 @@
      $   fq_is_true(i,4,7,n)+ fq_is_true(i,5,7,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"stcu",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_isccp,"stcu",itau_w,zx_tmp_fi2d)
 c
         DO i=1, klon
@@ -154,7 +146,6 @@
      $   fq_is_true(i,6,7,n)+ fq_is_true(i,7,7,n) )
         ENDDO
-	CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_isccp,"stra",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_isccp,"stra",itau_w,zx_tmp_fi2d)
 c
 c 3_tau_nuages x 3_levels
@@ -172,7 +163,6 @@
      $  fq_is_true(i,1,7,n)+ fq_is_true(i,2,7,n)+ fq_is_true(i,3,7,n) )
         ENDDO   
-        CALL gr_fi_ecrit(lmax3,klon,iim,jjmp1,cld_fi3d,cld_3d)
-        CALL histwrite(nid_isccp,"thin",itau_w,cld_3d,
-     $  iim*jjmp1*lmax3,ndex3d)
+cym        CALL gr_fi_ecrit(lmax3,klon,iim,jjmp1,cld_fi3d,cld_3d)
+        CALL histwrite_phy(nid_isccp,"thin",itau_w,cld_fi3d)
 c
         DO i=1, klon
@@ -188,7 +178,6 @@
      $    fq_is_true(i,4,7,n)+ fq_is_true(i,5,7,n) )
 	ENDDO   
-        CALL gr_fi_ecrit(lmax3, klon,iim,jjmp1,cld_fi3d,cld_3d)
-        CALL histwrite(nid_isccp,"mid",itau_w,cld_3d,
-     $  iim*jjmp1*lmax3,ndex3d)
+cym       CALL gr_fi_ecrit(lmax3, klon,iim,jjmp1,cld_fi3d,cld_3d)
+        CALL histwrite_phy(nid_isccp,"mid",itau_w,cld_fi3d)
 c
         DO i=1, klon
@@ -204,7 +193,6 @@
      $    fq_is_true(i,6,7,n)+ fq_is_true(i,7,7,n) )
         ENDDO   
-        CALL gr_fi_ecrit(lmax3, klon,iim,jjmp1,cld_fi3d,cld_3d)
-        CALL histwrite(nid_isccp,"thick",itau_w,cld_3d,
-     $  iim*jjmp1*lmax3,ndex3d)
+cym       CALL gr_fi_ecrit(lmax3, klon,iim,jjmp1,cld_fi3d,cld_3d)
+        CALL histwrite_phy(nid_isccp,"thick",itau_w,cld_fi3d)
 c
         ENDDO ! n=1, napisccp
@@ -213,5 +201,7 @@
 c
        if (ok_sync) then
+c$OMP MASTER
         call histsync(nid_isccp)
+c$OMP END MASTER       
        endif
 
Index: /LMDZ4/trunk/libf/phylmd/write_histREGDYN.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histREGDYN.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histREGDYN.h	(revision 766)
@@ -3,5 +3,8 @@
 !
       if (ok_regdyn) then
-c
+      
+      if (monocpu) then
+
+
       ndex3d = 0
       itau_w = itau_phy + itap
@@ -56,3 +59,5 @@
       endif
 
+      endif ! monocpu
+
       endif
Index: /LMDZ4/trunk/libf/phylmd/write_histday.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histday.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histday.h	(revision 766)
@@ -14,10 +14,8 @@
       IF(lev_histday.GE.1) THEN
 c
-       CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis,zx_tmp_2d)
-       CALL histwrite(nid_day,"phis",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-cIM 310804      CALL gr_fi_ecrit(1,klon,iim,jjmp1,paire,zx_tmp_2d)
-         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)
+       CALL histwrite_phy(nid_day,"phis",itau_w,pphis)
+ 
+c
+       CALL histwrite_phy(nid_day,"aire",itau_w,airephy)
 c
       DO i=1, klon
@@ -25,50 +23,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
@@ -76,43 +71,39 @@
       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)
+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
 cIM: 140404   CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
@@ -121,40 +112,39 @@
 c    .               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, radsol,zx_tmp_2d)
-      CALL histwrite(nid_day,"radsol",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, 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, radsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"radsol",itau_w,radsol)
+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
@@ -173,11 +163,9 @@
      $   .OR.bb2.EQ."500".OR.bb2.EQ."200") THEN
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,usumSTD(:,k,1),zx_tmp_2d)
-        CALL histwrite(nid_day,"u"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,vsumSTD(:,k,1),zx_tmp_2d)
-        CALL histwrite(nid_day,"v"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,usumSTD(:,k,1),zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"u"//bb2,itau_w,usumSTD(:,k,1))
+c
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,vsumSTD(:,k,1),zx_tmp_2d)
+        CALL histwrite_phy(nid_day,"v"//bb2,itau_w,vsumSTD(:,k,1))
 c
       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.bb2.EQ."500".OR.bb2.EQ."200") THEN
@@ -187,10 +175,9 @@
       IF(bb2.EQ."500") THEN
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,wsumSTD(:,k,1),zx_tmp_2d)
-      CALL histwrite(nid_day,"w"//bb2,itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,phisumSTD(:,k,1),zx_tmp_2d)
-      CALL histwrite(nid_day,"phi"//bb2,itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,wsumSTD(:,k,1),zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"w"//bb2,itau_w,wsumSTD(:,k,1))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,phisumSTD(:,k,1),zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"phi"//bb2,itau_w,phisumSTD(:,k,1))
 
       ENDIF !(bb2.EQ."500") THEN
@@ -198,26 +185,23 @@
       ENDDO !nlevSTD
 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
       IF (OCEAN.EQ.'force ') THEN
@@ -232,7 +216,6 @@
       ENDIF
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"lmt_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_day,"lmt_bils",itau_w, zx_tmp_fi2d)
 c
       ELSE IF (OCEAN.EQ.'slab  ') THEN
@@ -247,7 +230,6 @@
       ENDIF
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"slab_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_day,"slab_bils",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
@@ -259,15 +241,12 @@
        ENDIF
       ENDDO !i=1, klon
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"tslab",itau_w,zx_tmp_2d,
-     .     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice,zx_tmp_2d)
-      CALL histwrite(nid_day,"seaice",itau_w,zx_tmp_2d,
-     .     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice/1000.,zx_tmp_2d)
-      CALL histwrite(nid_day,"siceh",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,"tslab",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"seaice",itau_w,seaice)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice/1000.,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"siceh",itau_w,seaice/1000.)
 c
       ENDIF !(OCEAN.EQ.'slab  ') THEN
@@ -281,7 +260,6 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"fluxo",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,"fluxo",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
@@ -293,7 +271,6 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"fluxg",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,"fluxg",itau_w,zx_tmp_fi2d)
 c
       ENDIF !lev_histday.GE.1
@@ -301,9 +278,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
@@ -317,31 +294,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
@@ -356,187 +326,163 @@
 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
 cIM AMMA-MIP
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
-      CALL histwrite(nid_day,"LWdnSFC",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_day,"LWdnSFC",itau_w,sollwdown)
 c
       zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_day,"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_day,"LWupSFC",itau_w,zx_tmp_fi2d)
 c
 cIM   IF (iflag_con.GE.3) THEN
 cIM ema_pct= 0.     CALL gr_fi_ecrit(1, klon,iim,jjmp1, ema_pct,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, meanptop(:,1),zx_tmp_2d)
-      CALL histwrite(nid_day,"ptop",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, meanptop(:,1),zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"ptop",itau_w,meanptop(:,1))
 cIM   ENDIF
 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)*100.
-        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) = pctsrf( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_day,"fract_"//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,"fract_"//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  
@@ -550,83 +496,70 @@
 c rajout sorties F. Aires
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw0,zx_tmp_2d)
-      CALL histwrite(nid_day,"tops0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw0,zx_tmp_2d)
-      CALL histwrite(nid_day,"topl0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw0,zx_tmp_2d)
-      CALL histwrite(nid_day,"sols0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw0,zx_tmp_2d)
-      CALL histwrite(nid_day,"soll0",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldfra, zx_tmp_3d)
-      CALL histwrite(nid_day,"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_day,"rnebcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, flwc,zx_tmp_3d)
-      CALL histwrite(nid_day,"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_day,"iwcon",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, topsw0,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"tops0",itau_w,topsw0)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw0,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"topl0",itau_w,toplw0)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw0,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"sols0",itau_w,solsw0)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw0,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"soll0",itau_w, sollw0)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldfra, zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"rneb",itau_w,cldfra)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, rnebcon, zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"rnebcon",itau_w,rnebcon)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, flwc,zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"lwcon",itau_w,flwc)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, fiwc,zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"iwcon",itau_w,fiwc)
 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_day,"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_day,"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_day,"iwp",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1, meantaucld,zx_tmp_2d)
-      CALL histwrite(nid_day,"meantaucld",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldtau,zx_tmp_3d)
-      CALL histwrite(nid_day,"cldtau",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldemi,zx_tmp_3d)
-      CALL histwrite(nid_day,"cldemi",itau_w,zx_tmp_3d,
-     .               iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"iwp",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1, meantaucld,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"meantaucld",itau_w,meantaucld)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldtau,zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"cldtau",itau_w,cldtau)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, cldemi,zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"cldemi",itau_w,cldemi)
 c
 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_day,"dtcon",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_day,"dtcon",itau_w,zx_tmp_fi3d)
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_day,"dqcon",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      DO i=1, klon
-       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
-      ENDDO
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_day,"rh2m",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1, qsat2m,zx_tmp_2d)
-      CALL histwrite(nid_day,"qsat2m",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1, tpot,zx_tmp_2d)
-      CALL histwrite(nid_day,"tpot",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1, tpote,zx_tmp_2d)
-      CALL histwrite(nid_day,"tpote",itau_w,zx_tmp_2d,
-     .               iim*jjmp1,ndex2d)
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_day,"dqcon",itau_w,zx_tmp_fi3d)
+c
+      DO i=1, klon
+       zx_tmp_2d(i)=MIN(100.,rh2m(i)*100.)
+      ENDDO
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1, zx_tmp_2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"rh2m",itau_w,zx_tmp_2d)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1, qsat2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"qsat2m",itau_w,qsat2m)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1, tpot,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"tpot",itau_w,tpot)
+c
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1, tpote,zx_tmp_2d)
+      CALL histwrite_phy(nid_day,"tpote",itau_w,tpote)
 c
       ENDIF !lev_histday.GE.5
@@ -636,5 +569,7 @@
 c
       if (ok_sync) then
+c$OMP MASTER
         call histsync(nid_day)
+c$OMP END MASTER
       endif
 
Index: /LMDZ4/trunk/libf/phylmd/write_histday_seri.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histday_seri.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histday_seri.h	(revision 766)
@@ -2,4 +2,6 @@
 c $Header$
 c
+      IF (monocpu) THEN
+      
       IF (type_run.EQ."AMIP") THEN
 c
@@ -237,2 +239,4 @@
 c
       ENDIF !fin test sur type_run.EQ."AMIP"
+      
+      ENDIF  ! mono_cpu
Index: /LMDZ4/trunk/libf/phylmd/write_histhf.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histhf.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histhf.h	(revision 766)
@@ -14,7 +14,6 @@
       IF(lev_histhf.GE.1) THEN
 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
@@ -22,53 +21,47 @@
       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)
-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)
-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)
-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, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"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_hf,"contfracOR",itau_w,
+     .                   pctsrf_new(:,is_ter))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zt2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"t2m",itau_w,zt2m)
+c
+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,"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_hf,"precip",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)
-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)
-c
-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)
-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, zxtsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"tsol",itau_w,zxtsol)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, slp,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"slp",itau_w,slp)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zu10m,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"u10m",itau_w,zu10m)
+c
+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, nlevSTD
@@ -85,7 +78,6 @@
       IF(bb2.EQ."500") THEN
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, philevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"phi"//bb2,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_hf,"phi"//bb2,itau_w, philevSTD(:,k))
       ENDIF !bb2.EQ."500"
       ENDDO
@@ -101,20 +93,17 @@
 cIM 140904 END
 cIM 140904   CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,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,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"cldt",itau_w,zx_tmp_fi2d)
 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)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
+      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)
-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) 
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"SWdownOR",itau_w, zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"LWdownOR",itau_w,sollwdown) 
 c
 c
@@ -137,26 +126,21 @@
      $   bb2.EQ."500".OR.bb2.EQ."200") THEN
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, tlevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"t"//bb2,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_hf,"t"//bb2,itau_w, tlevSTD(:,k))
 c
       IF(bb2.NE."500") THEN !bb2.NE."500"
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,philevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"phi"//bb2,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_hf,"phi"//bb2,itau_w,philevSTD(:,k))
       ENDIF !bb2.NE."500"
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, qlevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"q"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"u"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlevSTD(:,k),zx_tmp_2d)
-      CALL histwrite(nid_hf,"v"//bb2,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_hf,"q"//bb2,itau_w, qlevSTD(:,k))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulevSTD(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"u"//bb2,itau_w,ulevSTD(:,k))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlevSTD(:,k),zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"v"//bb2,itau_w, vlevSTD(:,k))
 c
       ENDIF !bb2.EQ."850".OR.bb2.EQ."700"
@@ -164,9 +148,9 @@
 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)
-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, cdragm,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"cdrm",itau_w,cdragm)
+c
+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
@@ -199,11 +183,9 @@
         IF(bb2.EQ."850".or.bb2.EQ."200") THEN
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulevSTD(:,k),zx_tmp_2d)
-        CALL histwrite(nid_hf,"u"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlevSTD(:,k),zx_tmp_2d)
-        CALL histwrite(nid_hf,"v"//bb2,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_hf,"u"//bb2,itau_w,ulevSTD(:,k))
+c
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlevSTD(:,k),zx_tmp_2d)
+        CALL histwrite_phy(nid_hf,"v"//bb2,itau_w,vlevSTD(:,k))
 c
         ENDIF !bb2.EQ."850".or.bb2.EQ."200"
@@ -211,15 +193,15 @@
       ENDDO !nlevSTD
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
-      CALL histwrite(nid_hf,"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_hf,"topl",itau_w,toplw)
 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,"precip",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-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, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"precip",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, slp,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"slp",itau_w,slp)
 c
 cIM 280504 BEG
@@ -241,11 +223,9 @@
         IF(bb2.EQ."850".or.bb2.EQ."500") THEN
 c
-         CALL gr_fi_ecrit(1, klon,iim,jjmp1, tlevSTD(:,k),zx_tmp_2d)
-         CALL histwrite(nid_hf,"t"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-         CALL gr_fi_ecrit(1, klon,iim,jjmp1, qlevSTD(:,k),zx_tmp_2d)
-         CALL histwrite(nid_hf,"q"//bb2,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_hf,"t"//bb2,itau_w,tlevSTD(:,k))
+c
+cym         CALL gr_fi_ecrit(1, klon,iim,jjmp1, qlevSTD(:,k),zx_tmp_2d)
+         CALL histwrite_phy(nid_hf,"q"//bb2,itau_w, qlevSTD(:,k))
 c
         ENDIF !bb2.EQ."850".or.bb2.EQ."500"
@@ -253,11 +233,9 @@
         IF(bb2.EQ."500") THEN
 c
-         CALL gr_fi_ecrit(1, klon,iim,jjmp1, philevSTD(:,k),zx_tmp_2d)
-         CALL histwrite(nid_hf,"phi"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, wlevSTD(:,k),zx_tmp_2d)
-        CALL histwrite(nid_hf,"w"//bb2,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_hf,"phi"//bb2,itau_w, philevSTD(:,k))
+c
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, wlevSTD(:,k),zx_tmp_2d)
+        CALL histwrite_phy(nid_hf,"w"//bb2,itau_w, wlevSTD(:,k))
 c
         ENDIF !bb2.EQ."500"
@@ -265,15 +243,12 @@
         IF(bb3.EQ."50") THEN
 c
-         CALL gr_fi_ecrit(1, klon,iim,jjmp1, tlevSTD(:,k),zx_tmp_2d)
-         CALL histwrite(nid_hf,"t"//bb3,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulevSTD(:,k),zx_tmp_2d)
-        CALL histwrite(nid_hf,"u"//bb3,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlevSTD(:,k),zx_tmp_2d)
-        CALL histwrite(nid_hf,"v"//bb3,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_hf,"t"//bb3,itau_w, tlevSTD(:,k))
+c
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, ulevSTD(:,k),zx_tmp_2d)
+        CALL histwrite_phy(nid_hf,"u"//bb3,itau_w, ulevSTD(:,k))
+c
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1, vlevSTD(:,k),zx_tmp_2d)
+        CALL histwrite_phy(nid_hf,"v"//bb3,itau_w, vlevSTD(:,k))
 c
         ENDIF !bb3.EQ."50"
@@ -281,24 +256,21 @@
        ENDDO !k=1, nlevSTD
 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)
-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)
-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)
-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, zu10m,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"u10m",itau_w,zu10m)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zv10m,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"v10m",itau_w,zv10m)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zt2m,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"t2m",itau_w, zt2m)
+c
+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
 cIM 140904 BEG
@@ -308,68 +280,60 @@
 cIM 140904 END
 cIM 140904   CALL gr_fi_ecrit(1, klon,iim,jjmp1, cldt,zx_tmp_2d)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,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,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"cldt",itau_w,zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = zxfluxu(1 : klon, 1)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-      CALL histwrite(nid_hf,"taux",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,"taux",itau_w,zx_tmp_fi2d)
 C
       zx_tmp_fi2d(1 : klon) = zxfluxv(1 : klon, 1)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-      CALL histwrite(nid_hf,"tauy",itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, prw,zx_tmp_2d)
-      CALL histwrite(nid_hf,"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_hf,"tauy",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, prw,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"prw",itau_w,prw)
 c
       zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_hf,"sens",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxfluxlat,zx_tmp_2d)
-      CALL histwrite(nid_hf,"flat",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,"sens",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxfluxlat,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"flat",itau_w,zxfluxlat)
 c
 c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, zsnow_mass,zx_tmp_2d)
-c     CALL histwrite(nid_hf,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
-c    $               ndex2d)
+c     CALL histwrite_phy(nid_hf,"snow_mass",itau_w,zsnow_mass)
 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_hf, "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_hf, "SWdnSFC",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_hf, "SWupSFC",itau_w,zx_tmp_2d,
-     $                               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
-      CALL histwrite(nid_hf,"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_hf, "SWupSFC",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf,"LWdnSFC",itau_w,sollwdown)
 c
 cIM 090904   zx_tmp_fi2d(1:klon)=sollw(1:klon)+sollwdown(1:klon)
 cIM 130904   zx_tmp_fi2d(1:klon)=sollw(1:klon)-sollwdown(1:klon)
       zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_hf,"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_hf,"LWupSFC",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_hf, "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_hf, "SWdnTOA",itau_w,zx_tmp_fi2d)
 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_hf, "SWupTOA",itau_w,zx_tmp_2d,
-     $                               iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(nbteta,klon,iim,jjmp1,PVteta,zx_tmp_3dte)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_hf, "SWupTOA",itau_w,zx_tmp_fi2d)
+c
+      IF (monocpu) THEN
+cym      CALL gr_fi_ecrit(nbteta,klon,iim,jjmp1,PVteta,zx_tmp_3dte)
       DO k=1, nbteta
-       CALL histwrite(nid_hf,"PV"//ctetaSTD(k),
-     .      itau_w,zx_tmp_3dte(:,:,k),iim*jjmp1,ndex2d)
+       CALL histwrite_phy(nid_hf,"PV"//ctetaSTD(k),
+     .      itau_w,PVteta)
       ENDDO !k=1, nbteta
+      ENDIF
 c
 c
@@ -384,5 +348,7 @@
 c
       IF (ok_sync) THEN
+c$OMP MASTER
         call histsync(nid_hf)
+c$OMP END MASTER
       ENDIF
 
Index: /LMDZ4/trunk/libf/phylmd/write_histhf3d.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histhf3d.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histhf3d.h	(revision 766)
@@ -1,2 +1,3 @@
+
 c
 c $Header$
@@ -10,21 +11,18 @@
 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)
-c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, v_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_hf3d,"vitv",itau_w,v_seri)
       if (ok_sync) then
+c$OMP MASTER
         call histsync(nid_hf3d)
+c$OMP END MASTER      
       endif
Index: /LMDZ4/trunk/libf/phylmd/write_histins.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histins.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histins.h	(revision 766)
@@ -11,161 +11,158 @@
       itau_w = itau_phy + itap
 
-      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)
-c
-      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,pphis,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"phis",itau_w,pphis)
+c
+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)
-
-      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, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"pluc",itau_w,zx_tmp_fi2d)
+
+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)
-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)
-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)
-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)
-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)
-
-      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)
-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)
-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)
-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)
-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)
-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)
-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)
-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, zt2m, zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"t2m",itau_w,zt2m)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zq2m, zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"q2m",itau_w,zq2m)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zu10m, zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"u10m",itau_w,zu10m)
+C
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zv10m, zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"v10m",itau_w,zv10m)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, snow_fall,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"snow",itau_w,snow_fall)
+
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragm,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"cdrm",itau_w,cdragm)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, cdragh,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"cdrh",itau_w,cdragh)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, toplw,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"topl",itau_w,toplw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, evap,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"evap",itau_w,evap)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, solsw,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"sols",itau_w,solsw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollw,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"soll",itau_w,sollw)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, sollwdown,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"solldown",itau_w,sollwdown)
+c
+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)
-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)
-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)
-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)
-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)
-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, zx_tmp_fi2d,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"sens",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, fder,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"fder",itau_w,fder)
+c
+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
+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
+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
+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)*100.
-        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) = pctsrf( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_ins,"fract_"//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,"fract_"//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
 cIM: 140404   CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxsnow,zx_tmp_2d)
 c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, zsnow_mass,zx_tmp_2d)
-c     CALL histwrite(nid_ins,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
+c     CALL histwrite_phy(nid_ins,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
 c    .               ndex2d)
 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
 cIM cf. AM 081204 BEG
@@ -174,40 +171,33 @@
 c
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblh,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_pblh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblt,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_pblt",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_lcl,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_lcl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_capCL,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_capCL",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_oliqCL,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_oliqCL",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_cteiCL,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_cteiCL",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_therm,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_therm",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb1,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_trmb1",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb2,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_trmb2",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb3,zx_tmp_2d)
-      CALL histwrite(nid_ins,"s_trmb3",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblh,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_pblh",itau_w,s_pblh)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblt,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_pblt",itau_w,s_pblt)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_lcl,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_lcl",itau_w,s_lcl)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_capCL,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_capCL",itau_w,s_capCL)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_oliqCL,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_oliqCL",itau_w,s_oliqCL)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_cteiCL,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_cteiCL",itau_w,s_cteiCL)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_therm,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_therm",itau_w,s_therm)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb1,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_trmb1",itau_w,s_trmb1)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb2,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_trmb2",itau_w,s_trmb2)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb3,zx_tmp_2d)
+      CALL histwrite_phy(nid_ins,"s_trmb3",itau_w,s_trmb3)
 c
 cIM cf. AM 081204 END
@@ -215,35 +205,30 @@
 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)
-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)
-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)
-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)
-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)
-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)
-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, t_seri, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"temp",itau_w,t_seri)
+c
+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
+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
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zphi, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"geop",itau_w,zphi)
+c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, pplay, zx_tmp_3d)
+      CALL histwrite_phy(nid_ins,"pres",itau_w,pplay)
+c
+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
+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
       if (ok_sync) then
+c$OMP MASTER
         call histsync(nid_ins)
+c$OMP END MASTER
       endif
       ENDIF
Index: /LMDZ4/trunk/libf/phylmd/write_histmth.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histmth.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histmth.h	(revision 766)
@@ -16,43 +16,41 @@
 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
 cIM 310804   CALL gr_fi_ecrit(1,klon,iim,jjmp1,paire,zx_tmp_2d)
-      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)* 100.
-      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)
+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
       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,"fract_"//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,"fract_"//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
@@ -60,42 +58,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
@@ -103,25 +99,24 @@
          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)
+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
 c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, zsnow_mass,zx_tmp_2d)
@@ -129,119 +124,103 @@
 c    .               ndex2d)
 c
-      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
       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
       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
       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
       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, radsol,zx_tmp_2d)
-      CALL histwrite(nid_mth,"radsol",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, radsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"radsol",itau_w,radsol)
+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
 cIM 080904   zx_tmp_fi2d(1:klon)=sollw(1:klon)+sollwdown(1:klon)
 cIM 130904   zx_tmp_fi2d(1:klon)=sollw(1:klon)-sollwdown(1:klon)
       zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(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
       DO i=1, klon
@@ -252,11 +231,9 @@
 cIM 130904   zx_tmp_fi2d(1:klon)=sollw0(1:klon)-sollwdownclr(1:klon)
       zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(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
 c     DO i=1, klon
@@ -265,18 +242,17 @@
 c     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)
-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, sollwdownclr,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWdnSFCclr",itau_w,sollwdownclr)
+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
@@ -294,22 +270,23 @@
 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)
-c
+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)
+
+cym       CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxfqfonte,zx_tmp_2d)
+       CALL histwrite_phy(nid_mth,"fqfonte",itau_w,zxfqfonte)
+
        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
 c
@@ -318,61 +295,61 @@
        IF(nsrf.GT.2) THEN
         zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
-        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) 
 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_mth,"fract_"//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,"fract_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d) 
        ENDIF !nsrf.GT.2
 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
         zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"wbilo_"//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,"wbilo_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
        IF(1.EQ.0) THEN
 C
         zx_tmp_fi2d(1:klon) = fevap(1:klon,nsrf)*pctsrf(1:klon,nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"evapour_"//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,"evapour_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
         zx_tmp_fi2d(1:klon) = (rain_fall(1:klon) + snow_fall(1:klon))
      $                        *pctsrf(1:klon,nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"prepour_"//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,"prepour_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
        ENDIF !(1.EQ.0) THEN
@@ -380,64 +357,63 @@
       END DO  
 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
 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
       ENDIF !iflag_con.GE.3
@@ -448,40 +424,33 @@
 c
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblh,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_pblh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblt,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_pblt",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_lcl,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_lcl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_capCL,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_capCL",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_oliqCL,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_oliqCL",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_cteiCL,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_cteiCL",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_therm,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_therm",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb1,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_trmb1",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb2,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_trmb2",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb3,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_trmb3",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblh,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_pblh",itau_w,s_pblh)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblt,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_pblt",itau_w,s_pblt)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_lcl,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_lcl",itau_w,s_lcl)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_capCL,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_capCL",itau_w,s_capCL)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_oliqCL,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_oliqCL",itau_w,s_oliqCL)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_cteiCL,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_cteiCL",itau_w,s_cteiCL)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_therm,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_therm",itau_w,s_therm)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb1,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_trmb1",itau_w,s_trmb1)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb2,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_trmb2",itau_w,s_trmb2)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb3,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_trmb3",itau_w,s_trmb3)
 c
 cIM cf. AM 081204 END
@@ -502,19 +471,15 @@
      $   bb2.EQ."500".OR.bb2.EQ."200") THEN
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,usumSTD(:,k,2),zx_tmp_2d)
-        CALL histwrite(nid_mth,"u"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,vsumSTD(:,k,2),zx_tmp_2d)
-        CALL histwrite(nid_mth,"v"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,wsumSTD(:,k,2),zx_tmp_2d)
-      CALL histwrite(nid_mth,"w"//bb2,itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,phisumSTD(:,k,2),zx_tmp_2d)
-      CALL histwrite(nid_mth,"phi"//bb2,itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,usumSTD(:,k,2),zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"u"//bb2,itau_w,usumSTD(:,k,2))
+c
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,vsumSTD(:,k,2),zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"v"//bb2,itau_w,vsumSTD(:,k,2))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,wsumSTD(:,k,2),zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"w"//bb2,itau_w,wsumSTD(:,k,2))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,phisumSTD(:,k,2),zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"phi"//bb2,itau_w,phisumSTD(:,k,2))
 c
       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
@@ -529,7 +494,6 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"fluxo",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,"fluxo",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
@@ -541,7 +505,6 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"fluxg",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,"fluxg",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
@@ -556,7 +519,6 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"t_oce_sic",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,"t_oce_sic",itau_w,zx_tmp_fi2d)
 c
       IF (OCEAN.EQ.'force ') THEN
@@ -571,7 +533,6 @@
       ENDIF
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"lmt_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,"lmt_bils",itau_w,zx_tmp_fi2d)
 c
       ELSE IF (OCEAN.EQ.'slab  ') THEN
@@ -586,7 +547,6 @@
       ENDIF
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"slab_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,"slab_bils",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
@@ -598,15 +558,12 @@
        ENDIF
       ENDDO !i=1, klon
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"tslab",itau_w,zx_tmp_2d,
-     .     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice,zx_tmp_2d)
-      CALL histwrite(nid_mth,"seaice",itau_w,zx_tmp_2d,
-     .     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice/1000.,zx_tmp_2d)
-      CALL histwrite(nid_mth,"siceh",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,"tslab",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"seaice",itau_w,seaice)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice/1000.,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"siceh",itau_w, seaice/1000.)
 c
       ENDIF !OCEAN.EQ.force/slab
@@ -619,15 +576,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
@@ -635,7 +589,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
 c     zx_tmp_fi3d(1:klon,1:klev)=qx(1:klon,1:klev,ivap)/
@@ -645,36 +598,28 @@
 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
+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)
+
       DO k=1, klev
        DO i=1, klon
@@ -691,16 +636,14 @@
 c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, wo, zx_tmp_3d)
 c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp2_fi3d,zx_tmp_3d)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"ozone",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      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,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"ozone",itau_w,zx_tmp_fi3d)
+c
+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
       ENDIF !lev_histmth.GE.2
@@ -711,25 +654,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
@@ -738,157 +681,129 @@
       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)
-c
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, clwcon0, zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"clwcon",itau_w,clwcon0)
+
       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)
+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 !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, 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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqcon",itau_w,zx_tmp_fi3d)
 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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqlsc",itau_w,zx_tmp_fi3d)
 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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqvdf",itau_w,zx_tmp_fi3d)
 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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqeva",itau_w,zx_tmp_fi3d)
 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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqajs",itau_w,zx_tmp_fi3d)
 c
 cIM: 101003 : K/day ==> K/s
       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      
       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      
       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      
       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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"duvdf",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,"duvdf",itau_w,zx_tmp_fi3d)
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dvvdf",itau_w,zx_tmp_fi3d)
 c
       IF (ok_orodr) THEN
       zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"duoro",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,"duoro",itau_w,zx_tmp_fi3d)
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dvoro",itau_w,zx_tmp_fi3d)
 c
       ENDIF
@@ -896,19 +811,16 @@
       IF (ok_orolf) THEN
       zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dulif",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,"dulif",itau_w,zx_tmp_fi3d)
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dvlif",itau_w,zx_tmp_fi3d)
       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)
+cym         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
@@ -922,48 +834,47 @@
 c Champs 2D:
 c
-      CALL gr_fi_ecrit(1,klon,iim,jjmp1,pphis/RG,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/RG,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"phis",itau_w,pphis/RG)
 C
 cIM 310804   CALL gr_fi_ecrit(1,klon,iim,jjmp1,paire,zx_tmp_2d)
-      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)* 100.
-      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)
+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
       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,"fract_"//clnsurf(is_ter),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,"fract_"//clnsurf(is_ter),itau_w,
+     $      zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = pctsrf(1 : klon, is_lic)* 100.
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_mth,"pourc_"//clnsurf(is_lic),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_lic),itau_w,
+     $      zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = pctsrf(1 : klon, is_lic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d, zx_tmp_2d)
-      CALL histwrite(nid_mth,"fract_"//clnsurf(is_lic),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,"fract_"//clnsurf(is_lic),itau_w,
+     $      zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = pctsrf(1 : klon, is_sic)* 100.
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"pourc_"//clnsurf(is_sic),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_sic),itau_w,
+     $      zx_tmp_fi2d)
 c
       zx_tmp_fi2d(1 : klon) = pctsrf(1 : klon, is_sic)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"fract_"//clnsurf(is_sic),itau_w,
-     $      zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxfluxlat,zx_tmp_2d)
-      CALL histwrite(nid_mth,"flat",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,"fract_"//clnsurf(is_sic),itau_w,
+     $      zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zxfluxlat,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"flat",itau_w,zxfluxlat)
 c
       zx_tmp_fi2d(1 : klon) = topsw(1:klon)-toplw(1:klon)
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-      CALL histwrite(nid_mth,"bilTOA",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,"bilTOA",itau_w,zx_tmp_fi2d)
 c
 c     IF(itap.EQ.ecrit_mth) THEN
@@ -976,5 +887,5 @@
 c       ENDDO
 c       CALL gr_fi_ecrit(1, klon,iim,jjmp1, tops01,zx_tmp_2d)
-c       CALL histwrite(nid_mth,"tops01",itau_w,zx_tmp_2d,
+c       CALL histwrite_phy(nid_mth,"tops01",itau_w,zx_tmp_2d,
 c    .       iim*jjmp1,ndex2d)
 c     ENDIF !itap.EQ.ecrit_mth 
@@ -989,7 +900,6 @@
        ENDDO !l
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, d_t,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtdia",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,"dtdia",itau_w,d_t)
 c
 c temperature tendency due to SW radiation
@@ -1000,7 +910,6 @@
        ENDDO !l
 c
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtsw",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,"dtsw",itau_w,zx_tmp_fi3d)
 c
 c temperature tendency due to LW radiation
@@ -1011,7 +920,6 @@
        ENDDO !l
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dtlw",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,"dtlw",itau_w,zx_tmp_fi3d)
 c
 c  temperature tendency due to moist convective processes
@@ -1022,7 +930,6 @@
        ENDDO !l
 c
-      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)
+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
 c temperature tendency due to dry convective processes
@@ -1033,7 +940,6 @@
        ENDDO !l
 c
-      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)
+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
 c  temperature tendency due to large scale precipitation
@@ -1044,7 +950,6 @@
        ENDDO !l
 c
-      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)
 c
 c  total moisture tendency due to diabatic processes
@@ -1056,7 +961,6 @@
        ENDDO !l
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1, zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dqdia",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,"dqdia",itau_w,zx_tmp_fi3d)
 c
 cBEG 210404 BEG
@@ -1071,29 +975,23 @@
       ENDIF !(ok_orodr.AND.ok_orolf) THEN
 c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,d_u_oli,zx_tmp_3d)
-      CALL histwrite(nid_mth,"duoli",itau_w,zx_tmp_3d,
-     $       iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,d_v_oli,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dvoli",itau_w,zx_tmp_3d,
-     $       iim*jjmp1*klev,ndex3d)
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,d_u_oli,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"duoli",itau_w,d_u_oli)
+c
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,d_v_oli,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dvoli",itau_w,d_v_oli)
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"ducon",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,"ducon",itau_w,zx_tmp_fi3d)
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_v_con(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dvcon",itau_w,zx_tmp_3d,
-     $       iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,d_u,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dutot",itau_w,zx_tmp_3d,
-     $       iim*jjmp1*klev,ndex3d)
-c
-      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,d_v,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dvtot",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,"dvcon",itau_w,zx_tmp_fi3d)
+c
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,d_u,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dutot",itau_w,d_u)
+c
+cym      CALL gr_fi_ecrit(klev, klon,iim,jjmp1,d_v,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dvtot",itau_w,d_v)
 
 cEND 210404 END
@@ -1101,13 +999,13 @@
 c cldtrue
 c     CALL gr_fi_ecrit(klev, klon,iim,jjmp1,cldtrue,zx_tmp_3d)
-c     CALL histwrite(nid_mth,"cldtrue",itau_w,zx_tmp_3d,
+c     CALL histwrite_phy(nid_mth,"cldtrue",itau_w,zx_tmp_3d,
 c    $       iim*jjmp1*klev,ndex3d)
 c
 c     CALL gr_fi_ecrit(klev, klon,iim,jjmp1,cldTOA,zx_tmp_3d)
-c     CALL histwrite(nid_mth,"cldTOA",itau_w,zx_tmp_3d,
+c     CALL histwrite_phy(nid_mth,"cldTOA",itau_w,zx_tmp_3d,
 c    $       iim*jjmp1*klev,ndex3d)
 c
 c     CALL gr_fi_ecrit(klev, klon,iim,jjmp1,cldSFC,zx_tmp_3d)
-c     CALL histwrite(nid_mth,"cldSFC",itau_w,zx_tmp_3d,
+c     CALL histwrite_phy(nid_mth,"cldSFC",itau_w,zx_tmp_3d,
 c    $       iim*jjmp1*klev,ndex3d)
 c
@@ -1116,7 +1014,6 @@
        zx_tmp_fi2d(i)=zustrdr(i)+zustrli(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"GWDtaux",
-     $               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,"GWDtaux",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
@@ -1124,33 +1021,30 @@
        zx_tmp_fi2d(i)=zvstrdr(i)+zvstrli(i)
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"GWDtauy",
-     $               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,"GWDtauy",itau_w,zx_tmp_fi2d)
 c
 c220404 END
 cAMIP2 END
 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, 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
@@ -1158,42 +1052,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
@@ -1201,146 +1093,128 @@
          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,"snowf",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,"snowf",itau_w,snow_fall)
 c
 c     CALL gr_fi_ecrit(1, klon,iim,jjmp1, zsnow_mass,zx_tmp_2d)
-c     CALL histwrite(nid_mth,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
+c     CALL histwrite_phy(nid_mth,"snow_mass",itau_w,zx_tmp_2d,iim*jjmp1,
 c    .               ndex2d)
 c
-      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
       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
       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
       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
       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, radsol,zx_tmp_2d)
-      CALL histwrite(nid_mth,"radsol",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, radsol,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"radsol",itau_w,radsol)
+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
 cIM 080904   zx_tmp_fi2d(1:klon)=sollw(1:klon)+sollwdown(1:klon)
 cIM 130904   zx_tmp_fi2d(1:klon)=sollw(1:klon)-sollwdown(1:klon)
       zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(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
       DO i=1, klon
@@ -1351,11 +1225,9 @@
 cIM 130904   zx_tmp_fi2d(1:klon)=sollw0(1:klon)-sollwdownclr(1:klon)
       zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(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
 c     DO i=1, klon
@@ -1364,18 +1236,17 @@
 c     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)
-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, sollwdownclr,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"LWdnSFCclr",itau_w,sollwdownclr)
+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
@@ -1384,5 +1255,5 @@
 c      ENDDO
 c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-c      CALL histwrite(nid_mth,"frtu",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+c      CALL histwrite_phy(nid_mth,"frtu",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
 c
 c      DO i = 1, klon
@@ -1390,36 +1261,34 @@
 c      ENDDO
 c      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-c      CALL histwrite(nid_mth,"frtv",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-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)
+c      CALL histwrite_phy(nid_mth,"frtv",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
+c
+c
+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)
 c
        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
 c
         zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, is_oce)*100.
-        CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_mth,"pourc_"//clnsurf(is_oce),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_oce),itau_w,
+     $      zx_tmp_fi2d) 
 c
         zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, is_oce)
-        CALL gr_fi_ecrit(1,klon,iim,jjmp1,zx_tmp_fi2d,zx_tmp_2d)
-        CALL histwrite(nid_mth,"fract_"//clnsurf(is_oce),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,"fract_"//clnsurf(is_oce),itau_w,
+     $      zx_tmp_fi2d) 
 c
       DO nsrf = 1, nbsrf
@@ -1427,50 +1296,50 @@
 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
         zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"wbilo_"//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,"wbilo_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
        IF(1.EQ.0) THEN
 C
         zx_tmp_fi2d(1:klon) = fevap(1:klon,nsrf)*pctsrf(1:klon,nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"evapour_"//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,"evapour_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
         zx_tmp_fi2d(1:klon) = (rain_fall(1:klon) + snow_fall(1:klon))
      $                        *pctsrf(1:klon,nsrf)
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d , zx_tmp_2d)
-        CALL histwrite(nid_mth,"prepour_"//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,"prepour_"//clnsurf(nsrf),itau_w,
+     $      zx_tmp_fi2d)
 C
        ENDIF !(1.EQ.0) THEN
@@ -1478,64 +1347,63 @@
       END DO  
 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*100.,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*100.,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"cldt",itau_w,cldt*100.)
+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
 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
       ENDIF !iflag_con.GE.3
@@ -1545,40 +1413,33 @@
 c
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblh,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_pblh",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblt,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_pblt",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_lcl,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_lcl",itau_w,zx_tmp_2d,iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_capCL,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_capCL",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_oliqCL,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_oliqCL",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_cteiCL,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_cteiCL",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_therm,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_therm",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb1,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_trmb1",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb2,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_trmb2",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb3,zx_tmp_2d)
-      CALL histwrite(nid_mth,"s_trmb3",itau_w,zx_tmp_2d,iim*jjmp1,
-     .               ndex2d)
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblh,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_pblh",itau_w,s_pblh)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_pblt,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_pblt",itau_w,s_pblt)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_lcl,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_lcl",itau_w,s_lcl)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_capCL,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_capCL",itau_w,s_capCL)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_oliqCL,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_oliqCL",itau_w,s_oliqCL)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_cteiCL,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_cteiCL",itau_w,s_cteiCL)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_therm,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_therm",itau_w,s_therm)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb1,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_trmb1",itau_w,s_trmb1)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb2,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_trmb2",itau_w,s_trmb2)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, s_trmb3,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"s_trmb3",itau_w,s_trmb3)
 c
 cIM cf. AM 081204 END
@@ -1600,19 +1461,15 @@
      $   .OR.bb2.EQ."500".OR.bb2.EQ."200") THEN
 c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,usumSTD(:,k,2),zx_tmp_2d)
-        CALL histwrite(nid_mth,"u"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-        CALL gr_fi_ecrit(1, klon,iim,jjmp1,vsumSTD(:,k,2),zx_tmp_2d)
-        CALL histwrite(nid_mth,"v"//bb2,itau_w,zx_tmp_2d,
-     $       iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,wsumSTD(:,k,2),zx_tmp_2d)
-      CALL histwrite(nid_mth,"w"//bb2,itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1,phisumSTD(:,k,2),zx_tmp_2d)
-      CALL histwrite(nid_mth,"phi"//bb2,itau_w,zx_tmp_2d,
-     $     iim*jjmp1,ndex2d)
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,usumSTD(:,k,2),zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"u"//bb2,itau_w,usumSTD(:,k,2))
+c
+cym        CALL gr_fi_ecrit(1, klon,iim,jjmp1,vsumSTD(:,k,2),zx_tmp_2d)
+        CALL histwrite_phy(nid_mth,"v"//bb2,itau_w,vsumSTD(:,k,2))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,wsumSTD(:,k,2),zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"w"//bb2,itau_w,wsumSTD(:,k,2))
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1,phisumSTD(:,k,2),zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"phi"//bb2,itau_w,phisumSTD(:,k,2))
 c
       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700"
@@ -1627,7 +1484,6 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"fluxo",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,"fluxo",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
@@ -1639,7 +1495,6 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"fluxg",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,"fluxg",itau_w,zx_tmp_fi2d)
 c
       DO i=1, klon
@@ -1654,7 +1509,6 @@
       ENDDO
 c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"t_oce_sic",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,"t_oce_sic",itau_w,zx_tmp_fi2d)
 c
       IF (OCEAN.EQ.'force ') THEN
@@ -1669,7 +1523,7 @@
       ENDIF
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"lmt_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,"lmt_bils",itau_w,
+     .     zx_tmp_fi2d)
 c
       ELSE IF (OCEAN.EQ.'slab  ') THEN
@@ -1685,7 +1539,7 @@
       ENDIF
       ENDDO
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"slab_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,"slab_bils",itau_w,
+     .     zx_tmp_fi2d)
 c
       DO i=1, klon
@@ -1697,15 +1551,12 @@
        ENDIF
       ENDDO !i=1, klon
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, zx_tmp_fi2d,zx_tmp_2d)
-      CALL histwrite(nid_mth,"tslab",itau_w,zx_tmp_2d,
-     .     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice,zx_tmp_2d)
-      CALL histwrite(nid_mth,"seaice",itau_w,zx_tmp_2d,
-     .     iim*jjmp1,ndex2d)
-c
-      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice/1000.,zx_tmp_2d)
-      CALL histwrite(nid_mth,"siceh",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,"tslab",itau_w,zx_tmp_fi2d)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"seaice",itau_w,seaice)
+c
+cym      CALL gr_fi_ecrit(1, klon,iim,jjmp1, seaice/1000.,zx_tmp_2d)
+      CALL histwrite_phy(nid_mth,"siceh",itau_w,seaice/1000.)
 c
       ENDIF !OCEAN.EQ.force/slab
@@ -1718,15 +1569,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
@@ -1734,45 +1582,36 @@
 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
 c     zx_tmp_fi3d(1:klon,1:klev)=qx(1:klon,1:klev,ivap)/
 c    .                         (1-qx(1:klon,1:klev,ivap))
 c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, zx_tmp_fi3d, zx_tmp_3d)
-c     CALL histwrite(nid_mth,"wvap",itau_w,zx_tmp_3d,
+c     CALL histwrite_phy(nid_mth,"wvap",itau_w,zx_tmp_3d,
 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*100., 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)
+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*100., zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"rneb",itau_w,cldfra*100.)
+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
       DO k=1, klev
@@ -1790,16 +1629,12 @@
 c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1, wo, zx_tmp_3d)
 c     CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp2_fi3d,zx_tmp_3d)
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"ozone",itau_w,zx_tmp_3d,
-     .                                   iim*jjmp1*klev,ndex3d)
-c
-      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,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"ozone",itau_w,zx_tmp_fi3d)
+c
+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),zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dqphy",itau_w,d_qx(:,:,ivap))
 c
       ENDIF !lev_histmth.GE.2
@@ -1810,25 +1645,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
+     $    ,agesno)
 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
@@ -1837,142 +1672,116 @@
       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)
+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 !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, 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
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqcon",itau_w,zx_tmp_fi3d)
 c
 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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqlsc",itau_w,zx_tmp_fi3d)
 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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqvdf",itau_w,zx_tmp_fi3d)
 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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqeva",itau_w,zx_tmp_fi3d)
 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
       zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dqajs",itau_w,zx_tmp_fi3d)
 c
 cIM: 101003 : K/day ==> K/s
       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      
       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      
       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      
       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)
+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
       zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"duvdf",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,"duvdf",itau_w,zx_tmp_fi3d)
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,"dvvdf",itau_w,zx_tmp_fi3d)
 c
       IF (ok_orodr) THEN
       zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"duoro",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,"duoro",itau_w,zx_tmp_fi3d)
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dvoro",itau_w,zx_tmp_fi3d)
 c
       ENDIF
@@ -1980,19 +1789,16 @@
       IF (ok_orolf) THEN
       zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,zx_tmp_3d)
-      CALL histwrite(nid_mth,"dulif",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,"dulif",itau_w,zx_tmp_fi3d)
 c
       zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
-      CALL gr_fi_ecrit(klev,klon,iim,jjmp1,zx_tmp_fi3d,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,zx_tmp_fi3d,zx_tmp_3d)
+      CALL histwrite_phy(nid_mth,"dvlif",itau_w,zx_tmp_fi3d)
       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)
+cym         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
@@ -2003,5 +1809,7 @@
 c
       if (ok_sync) then
+c$OMP MASTER
         call histsync(nid_mth)
+c$OMP END MASTER
       endif
 c
Index: /LMDZ4/trunk/libf/phylmd/write_histmthNMC.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histmthNMC.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histmthNMC.h	(revision 766)
@@ -13,70 +13,57 @@
       IF(type_run.EQ."CLIM".OR.type_run.EQ."ENSP") THEN
 ccc
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,tsumSTD(:,:,2),
-     $      zx_tmp_NC)
-       CALL histwrite(nid_nmc,"temp",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,tsumSTD(:,:,2),
+cym     $      zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"temp",itau_w,tsumSTD(:,:,2))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,phisumSTD(:,:,2),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"phi",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,phisumSTD(:,:,2),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"phi",itau_w,phisumSTD(:,:,2))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,qsumSTD(:,:,2),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"q",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,qsumSTD(:,:,2),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"q",itau_w,qsumSTD(:,:,2))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,rhsumSTD(:,:,2),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"rh",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,rhsumSTD(:,:,2),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"rh",itau_w,rhsumSTD(:,:,2))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,usumSTD(:,:,2),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"u",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,usumSTD(:,:,2),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"u",itau_w,usumSTD(:,:,2))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vsumSTD(:,:,2),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"v",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vsumSTD(:,:,2),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"v",itau_w,vsumSTD(:,:,2))
 ccc
       ELSE IF(type_run.EQ."AMIP".OR.type_run.EQ."CFMI") THEN
 ccc
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,tsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"temp",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,tsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"temp",itau_w,tsumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,phisumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"phi",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,phisumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"phi",itau_w,phisumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,qsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"q",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,qsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"q",itau_w,qsumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,rhsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"rh",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,rhsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"rh",itau_w,rhsumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,usumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"u",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,usumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"u",itau_w,usumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"v",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"v",itau_w,vsumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,wsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"w",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,wsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"w",itau_w,wsumSTD(:,:,3))
 c
        DO k=1, nlevSTD
@@ -90,57 +77,49 @@
        ENDDO !k=1, nlevSTD
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,zx_tmp_fiNC,zx_tmp_NC)
-       CALL histwrite(nid_nmc,"psbg",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,zx_tmp_fiNC,zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"psbg",itau_w,zx_tmp_fiNC)
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,uvsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"uv",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,uvsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"uv",itau_w,uvsumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vqsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"vq",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vqsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"vq",itau_w,vqsumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vTsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"vT",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vTsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"vT",itau_w,vTsumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1, wqsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"wq",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1, wqsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"wq",itau_w,wqsumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vphisumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"vphi",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,vphisumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"vphi",itau_w,vphisumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,wTsumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"wT",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,wTsumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"wT",itau_w,wTsumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,u2sumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"uxu",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,u2sumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"uxu",itau_w,u2sumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,v2sumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"vxv",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,v2sumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"vxv",itau_w,v2sumSTD(:,:,3))
 c
-       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,T2sumSTD(:,:,3),
-     $     zx_tmp_NC)
-       CALL histwrite(nid_nmc,"TxT",itau_w,zx_tmp_NC,
-     $       iim*jjmp1*nlevSTD,ndex3d)
+cym       CALL gr_fi_ecrit(nlevSTD, klon,iim,jjmp1,T2sumSTD(:,:,3),
+cym     $     zx_tmp_NC)
+       CALL histwrite_phy(nid_nmc,"TxT",itau_w,T2sumSTD(:,:,3))
 c
       ENDIF !type_run
 c
       if (ok_sync) then
+c$OMP MASTER
         call histsync(nid_nmc)
+c$OMP END MASTER
       endif
 
Index: /LMDZ4/trunk/libf/phylmd/write_histrac.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_histrac.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_histrac.h	(revision 766)
@@ -2,4 +2,5 @@
 ! $Header$
 !
+#ifndef INCA
       ndex = 0
       ndex2d = 0
@@ -8,575 +9,98 @@
       itau_w = itau_phy + nstep
 
-      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)
-
-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)
-
-! 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)
-#endif
-
-! Fin ajout Anne
-
-#ifdef INCA
-#ifdef INCAINFO
-#ifdef INCA_NMHC
-      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)
-      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)
-      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)
-      ENDDO
-#endif
-#ifdef INCA_CH4
-       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)
-      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)
-      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)
-      ENDDO
-#endif
-
-      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)
-      ENDDO
-#else
-#ifdef INCA_NMHC
-      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)
-#endif
-#ifdef INCA_CH4
-      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)
-#endif
-#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)
-!      ENDDO
-#endif
-
-#ifdef INCA_AER
-
-      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)
-
-       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 gr_fi_ecrit(klev,klon,iim,jjm+1,totaerh2o(1,1), zx_tmp_3d)
-       CALL histwrite(nid_tra2,"TOTAERH2O",itau_w,zx_tmp_3d, 
-     .                     iim*(jjm+1)*klev,ndex3d)
-
-#endif
-#endif
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,airephy,zx_tmp_2d)      
+      CALL histwrite_phy(nid_tra,"aire",itau_w,airephy)
 
       DO it=1,nqmax
 C champs 2D
-#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)
-#ifdef INCA_AER
-      call diag(airephy,tr_seri,.false.)
-
-      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)
-
-      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,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)
-
-        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)
-          CALL gr_fi_ecrit(klev, klon,iim,jjm+1,tau(1,1,la,it),zx_tmp_3d)
-          CALL histwrite(nid_tra2,"OD3D"//cla(la)//"_"//solsym(it),itau_w,zx_tmp_3d,iim*(jjm+1)*klev,ndex3d)
-        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)
-
-        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,mdw(1,1,it),zx_tmp_3d)
-        CALL histwrite(nid_tra2,"MDW_"//solsym(it),itau_w,zx_tmp_3d,iim*(jjm+1)*klev,ndex3d)
-
-        CALL gr_fi_ecrit(klev, klon,iim,jjm+1,cload(1,1,it),zx_tmp_3d)
-        CALL histwrite(nid_tra2,"CLOAD_"//solsym(it),itau_w,zx_tmp_3d,iim*(jjm+1)*klev,ndex3d)
 
 
-      endif
-
-
-#endif
-C champs 3D
-       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,tr_seri(1,1,it),zx_tmp_3d)
-
-       !Prefer vmr to mmr for transported species
-       if( adv_mass(it) /= 0. ) then
-#ifdef INCA_AER
-         if (it .lt. trmx) then
-#endif
-       zx_tmp_3d = zx_tmp_3d * dry_mass / adv_mass(it)
-#ifdef INCA_AER
-         endif
-#endif
-       else
-#ifdef INCA_CH4
-       if ( solsym(it) == 'OX' ) then
-       zx_tmp_3d = zx_tmp_3d * dry_mass / nadv_mass(id_o3)
-       end if
-#endif
-#ifdef INCA_NMHC
-       if ( solsym(it) == 'OX' ) then
-       zx_tmp_3d = zx_tmp_3d * 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)
-#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_cv(1,1,it),zx_tmp_3d)
+       CALL histwrite_phy(nid_tra,"d_tr_cv_"//tnom(it+2),itau_w,
+     .                                           d_tr_cv(:,:,it))
+cym      CALL gr_fi_ecrit(klev,klon,iim,jjm+1,d_tr_cl(1,1,it),zx_tmp_3d)
+       CALL histwrite_phy(nid_tra,"d_tr_cl_"//tnom(it+2),itau_w,
+     .                                           d_tr_cl(:,:,it))
 c---fin Olivia      
       
-#endif
       ENDDO
 
-#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)
+C abder
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,yu1,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"pyu1",itau_w,yu1)
 
-      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)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,yv1,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"pyv1",itau_w,yv1)
 
-      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)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol1,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"ftsol1",itau_w,pftsol1)
 
-      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)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol2,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"ftsol2",itau_w,pftsol2)
 
-      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)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol3,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"ftsol3",itau_w,pftsol3)
 
-      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)
-! Ajout Anne
-#ifdef INCA_AER
-! for sulfur cycle
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,pftsol4,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"ftsol4",itau_w,pftsol4)
 
-      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)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf1,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"psrf1",itau_w,ppsrf1)
 
-      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)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf2,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"psrf2",itau_w,ppsrf2)
 
-      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)
+cym      CALL gr_fi_ecrit(1,klon,iim,jjm+1,ppsrf3,zx_tmp_2d)
+         CALL histwrite_phy(nid_tra,"psrf3",itau_w,ppsrf3)
 
-      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)
+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)
 
-      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)
-
-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)
+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)
 
 
-      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)
-#endif
+c abder
 
-#ifdef INCA_CH4
-      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)
-      ENDDO
+      if (ok_sync) then
+c$OMP MASTER
+        call histsync(nid_tra)
+c$OMP END MASTER
+       endif
 
 #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)
-
-      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)
-      ENDDO
-
-
-#endif
-
-! Fin ajout Anne
-
-!     ... Special section for daytime averaging
-!       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,day_cnt(1,1),
-!    .       zx_tmp_3d)
-!       CALL histwrite(nid_tra,"day_cnt",itau_w,zx_tmp_3d,
-!    .                                  iim*(jjm+1)*klev,ndex3d)
-!       CALL gr_fi_ecrit(klev,klon,iim,jjm+1,no_daytime(1,1),
-!    .       zx_tmp_3d)
-!       CALL histwrite(nid_tra,"NO_day",itau_w,zx_tmp_3d,
-!    .                                  iim*(jjm+1)*klev,ndex3d)
-
-!#endif
-#else
-
-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)
-
-
-c abder
-#endif
-
-      if (ok_sync) then
-         call histsync(nid_tra)
-#ifdef INCA_AER
-         call histsync(nid_tra2)
-         call histsync(nid_tra3)
-#endif
-       endif
-
-
Index: /LMDZ4/trunk/libf/phylmd/write_paramLMDZ_phy.h
===================================================================
--- /LMDZ4/trunk/libf/phylmd/write_paramLMDZ_phy.h	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/write_paramLMDZ_phy.h	(revision 766)
@@ -1,3 +1,5 @@
 c
+      IF (monocpu) THEN
+      
       ndex2d = 0
       itau_w = itau_phy + itap
@@ -301,25 +303,25 @@
      .               zx_tmp_2d,iim*jjmp1,ndex2d)
 c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_ins
+      zx_tmp_2d(1:iim,1:jjmp1)=FLOAT(ecrit_ins)
       CALL histwrite(nid_ctesGCM,"ecrit_ins",itau_w,
      .               zx_tmp_2d,iim*jjmp1,ndex2d)
 c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_hf
+      zx_tmp_2d(1:iim,1:jjmp1)=FLOAT(ecrit_hf)
       CALL histwrite(nid_ctesGCM,"ecrit_hf",itau_w,
      .               zx_tmp_2d,iim*jjmp1,ndex2d)
 c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_day
+      zx_tmp_2d(1:iim,1:jjmp1)=FLOAT(ecrit_day)
       CALL histwrite(nid_ctesGCM,"ecrit_day",itau_w,
      .               zx_tmp_2d,iim*jjmp1,ndex2d)
 c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_mth
+      zx_tmp_2d(1:iim,1:jjmp1)=FLOAT(ecrit_mth)
       CALL histwrite(nid_ctesGCM,"ecrit_mth",itau_w,
      .               zx_tmp_2d,iim*jjmp1,ndex2d)
 c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_tra
+      zx_tmp_2d(1:iim,1:jjmp1)=FLOAT(ecrit_tra)
       CALL histwrite(nid_ctesGCM,"ecrit_tra",itau_w,
      .               zx_tmp_2d,iim*jjmp1,ndex2d)
 c
-      zx_tmp_2d(1:iim,1:jjmp1)=ecrit_reg
+      zx_tmp_2d(1:iim,1:jjmp1)=FLOAT(ecrit_reg)
       CALL histwrite(nid_ctesGCM,"ecrit_reg",itau_w,
      .               zx_tmp_2d,iim*jjmp1,ndex2d)
@@ -341,2 +343,3 @@
       endif
 c
+      ENDIF ! mono_cpu
Index: /LMDZ4/trunk/libf/phylmd/yamada.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/yamada.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/yamada.F	(revision 766)
@@ -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/trunk/libf/phylmd/yamada4.F
===================================================================
--- /LMDZ4/trunk/libf/phylmd/yamada4.F	(revision 765)
+++ /LMDZ4/trunk/libf/phylmd/yamada4.F	(revision 766)
@@ -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
@@ -71,5 +72,5 @@
       save first,ipas
       data first,ipas/.true.,0/
-
+c$OMP THREADPRIVATE( first,ipas)
 
       integer ig,k
@@ -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(:)
+c$OMP THREADPRIVATE(l0)      
       real sq(klon),sqz(klon),zz(klon,klev+1)
       integer iter
@@ -91,13 +92,17 @@
       save ric,rifc,b1,kap
       data ric,rifc,b1,kap/0.195,0.191,16.6,0.4/
-
+c$OMP THREADPRIVATE(ric,rifc,b1,kap)
       real frif,falpha,fsm
       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
+c$OMP THREADPRIVATE(rino,smyam,styam,lyam,knyam,w2yam,t2yam)
+      logical,save :: firstcall=.true.
+c$OMP THREADPRIVATE(firstcall)       
       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 +111,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
@@ -378,5 +396,5 @@
 
 c====================================================================
-c   Calcul des coefficients de mélange
+c   Calcul des coefficients de m�ange
 c====================================================================
       do k=2,klev
