Index: LMDZ5/branches/testing/libf/phylmd/clesphys.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/clesphys.h	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/clesphys.h	(revision 1864)
@@ -61,4 +61,5 @@
        REAL pasphys
        LOGICAL ok_histNMC(3)
+       INTEGER levout_histNMC(3)
        REAL freq_outNMC(3) , freq_calNMC(3)
        CHARACTER(len=4) type_run
@@ -73,5 +74,5 @@
        REAL freq_COSP
        LOGICAL :: ok_cosp,ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP
-       INTEGER :: ip_ebil_phy, iflag_rrtm
+       INTEGER :: ip_ebil_phy, iflag_rrtm, iflag_ice_thermo
        LOGICAL :: ok_strato
        LOGICAL :: ok_hines
@@ -91,5 +92,5 @@
      &     , f_cdrag_ter,f_cdrag_oce,f_rugoro                           &
      &     , lev_histhf, lev_histday, lev_histmth                       &
-     &     , lev_histins, lev_histLES, lev_histdayNMC                   &
+     &     , lev_histins, lev_histLES, lev_histdayNMC, levout_histNMC   &
      &     , pasphys, ok_histNMC, freq_outNMC, freq_calNMC              &
      &     , type_run, ok_isccp, ok_regdyn, ok_cosp                     &
@@ -101,5 +102,5 @@
      &     , ok_lic_melt, cvl_corr, aer_type                            &
      &     , qsol0, iflag_rrtm, ok_strato,ok_hines,ecrit_LES            &
-     &     , co2_ppm0
+     &     , co2_ppm0, iflag_ice_thermo
      
        save /clesphys/
Index: LMDZ5/branches/testing/libf/phylmd/concvl.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/concvl.F	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/concvl.F	(revision 1864)
@@ -1,6 +1,6 @@
-      SUBROUTINE concvl (iflag_con,iflag_clos,
+      SUBROUTINE concvl (iflag_clos,
      .             dtime,paprs,pplay,
      .             t,q,t_wake,q_wake,s_wake,u,v,tra,ntra,
-     .             ALE,ALP,work1,work2,
+     .             ALE,ALP,sig1,w01,
      .             d_t,d_q,d_u,d_v,d_tra,
      .             rain, snow, kbas, ktop, sigd,
@@ -70,7 +70,9 @@
 c======================================================================
 c
+
+#include "clesphys.h"
 #include "dimensions.h"
 c
-       INTEGER iflag_con,iflag_clos
+       INTEGER iflag_clos
 c
        REAL dtime, paprs(klon,klev+1),pplay(klon,klev)
@@ -80,5 +82,5 @@
        REAL tra(klon,klev,nbtr)
        INTEGER ntra
-       REAL work1(klon,klev),work2(klon,klev),ptop2(klon)
+       REAL sig1(klon,klev),w01(klon,klev),ptop2(klon)
        REAL pmflxr(klon,klev+1),pmflxs(klon,klev+1)
        REAL ALE(klon),ALP(klon)
@@ -354,10 +356,10 @@
       if (iflag_con.eq.30) then
 
-      print *, '-> cv_driver'      !jyg
+!      print *, '-> cv_driver'      !jyg
       CALL cv_driver(klon,klev,klevp1,ntra,iflag_con,
      :              t,q,qs,u,v,tra,
      $              em_p,em_ph,iflag,
      $              d_t,d_q,d_u,d_v,d_tra,rain,
-     $              Vprecip,cbmf,work1,work2,                  !jyg
+     $              Vprecip,cbmf,sig1,w01,                  !jyg
      $              kbas,ktop,
      $              dtime,Ma,upwd,dnwd,dnwdbis,qcondc,wd,cape,
@@ -365,5 +367,5 @@
      $              evap,ep,epmlmMm,eplaMm,                    !RomP
      $              wdtrainA,wdtrainM)                         !RomP
-      print *, 'cv_driver ->'      !jyg
+!      print *, 'cv_driver ->'      !jyg
 c
       DO i = 1,klon
@@ -376,5 +378,6 @@
       nloc=klon
       CALL cva_driver(klon,klev,klev+1,ntra,nloc,
-     $              iflag_con,iflag_mix,iflag_clos,dtime,
+     $              iflag_con,iflag_mix,iflag_ice_thermo,
+     $              iflag_clos,dtime,
      :              t,q,qs,t_wake,q_wake,qs_wake,s_wake,u,v,tra,
      $              em_p,em_ph,
@@ -382,5 +385,5 @@
      .              em_sig1feed,em_sig2feed,em_wght,
      .              iflag,d_t,d_q,d_u,d_v,d_tra,rain,kbas,ktop,
-     $              cbmf,plcl,plfc,wbeff,work1,work2,ptop2,sigd,
+     $              cbmf,plcl,plfc,wbeff,sig1,w01,ptop2,sigd,
      $              Ma,mip,Vprecip,upwd,dnwd,dnwdbis,qcondc,wd,
      $              cape,cin,tvp,
Index: LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/conf_phys_m.F90	(revision 1864)
@@ -141,4 +141,5 @@
   LOGICAL,SAVE :: reevap_ice_omp
   INTEGER,SAVE :: iflag_pdf_omp
+  INTEGER,SAVE :: iflag_ice_thermo_omp
   REAL,SAVE :: rad_froid_omp, rad_chau1_omp, rad_chau2_omp
   REAL,SAVE :: t_glace_min_omp, t_glace_max_omp
@@ -155,4 +156,5 @@
   Integer, save :: lev_histins_omp, lev_histLES_omp 
   INTEGER, SAVE :: lev_histdayNMC_omp
+  INTEGER, SAVE :: levout_histNMC_omp(3)
   LOGICAL, SAVE :: ok_histNMC_omp(3)
   REAL, SAVE :: freq_outNMC_omp(3), freq_calNMC_omp(3)
@@ -966,4 +968,13 @@
   call getin('t_glace_max',t_glace_max_omp)
 
+!
+!Config Key  = iflag_ice_thermo
+!Config Desc =  
+!Config Def  = 0
+!Config Help = 
+!
+  iflag_ice_thermo_omp = 0
+  call getin('iflag_ice_thermo',iflag_ice_thermo_omp)
+
 !Config Key  = rei_min
 !Config Desc =  
@@ -1267,5 +1278,5 @@
   lev_histLES_omp = 1
   call getin('lev_histLES',lev_histLES_omp)
-!
+! 
 !Config Key  = lev_histdayNMC
 !Config Desc =
@@ -1275,4 +1286,14 @@
   lev_histdayNMC_omp = 8
   call getin('lev_histdayNMC',lev_histdayNMC_omp)
+!
+!Config Key  = levout_histNMC
+!Config Desc =
+!Config Def  = 5
+!Config Help =
+!
+  levout_histNMC_omp(1) = 5
+  levout_histNMC_omp(2) = 5
+  levout_histNMC_omp(3) = 5
+  call getin('levout_histNMC',levout_histNMC_omp)
 !
 !histNMC BEG
@@ -1296,5 +1317,4 @@
 !Config Help =
 !
-! freq_outNMC_omp(1) = 2592000.
   freq_outNMC_omp(1) = mth_len*86400.
   freq_outNMC_omp(2) = 86400.
@@ -1684,4 +1704,5 @@
     t_glace_min = t_glace_min_omp
     t_glace_max = t_glace_max_omp
+    iflag_ice_thermo = iflag_ice_thermo_omp
     rei_min = rei_min_omp
     rei_max = rei_max_omp
@@ -1702,4 +1723,5 @@
     lev_histLES = lev_histLES_omp
     lev_histdayNMC = lev_histdayNMC_omp
+    levout_histNMC = levout_histNMC_omp
     ok_histNMC(:) = ok_histNMC_omp(:)
     freq_outNMC(:) = freq_outNMC_omp(:)
@@ -1900,4 +1922,5 @@
   write(lunout,*)' t_glace_min = ',t_glace_min
   write(lunout,*)' t_glace_max = ',t_glace_max
+  write(lunout,*)' iflag_ice_thermo = ',iflag_ice_thermo
   write(lunout,*)' rei_min = ',rei_min
   write(lunout,*)' rei_max = ',rei_max
@@ -1925,4 +1948,5 @@
   write(lunout,*)' lev_histLES = ',lev_histLES
   write(lunout,*)' lev_histdayNMC = ',lev_histdayNMC
+  write(lunout,*)' levout_histNMC = ',levout_histNMC
   write(lunout,*)' ok_histNMC = ',ok_histNMC
   write(lunout,*)' freq_outNMC = ',freq_outNMC
Index: LMDZ5/branches/testing/libf/phylmd/cv3_routines.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/cv3_routines.F	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/cv3_routines.F	(revision 1864)
@@ -143,5 +143,5 @@
 
       SUBROUTINE cv3_prelim(len,nd,ndp1,t,q,p,ph
-     :                    ,lv,cpn,tv,gz,h,hm,th)
+     :                    ,lv,lf,cpn,tv,gz,h,hm,th)
       implicit none
 
@@ -157,5 +157,5 @@
 
 c outputs:
-      real lv(len,nd), cpn(len,nd), tv(len,nd)
+      real lv(len,nd), lf(len,nd), cpn(len,nd), tv(len,nd)
       real gz(len,nd), h(len,nd), hm(len,nd)
       real th(len,nd)
@@ -178,4 +178,5 @@
 cdebug          lv(i,k)= lv0-clmcpv*(t(i,k)-t0)
           lv(i,k)= lv0-clmcpv*(t(i,k)-273.15)
+          lf(i,k)= lf0-clmci*(t(i,k)-273.15)
           cpn(i,k)=cpd*(1.0-q(i,k))+cpv*q(i,k)
           cpx(i,k)=cpd*(1.0-q(i,k))+cl*q(i,k)
@@ -918,8 +919,40 @@
       end
 
+      SUBROUTINE Icefrac(t,clw,qi,nl,len)
+      implicit none
+
+
+cJAM--------------------------------------------------------------------
+C    Calcul de la quantité d'eau sous forme de glace
+C--------------------------------------------------------------------
+      Real qi(len,nl)
+      Real t(len,nl), clw(len,nl)
+      Real fracg
+      Integer nl, len, k, i
+
+      do k=3, nl
+           do i = 1, len
+           if (t(i,k).gt.263.15) then
+           qi(i,k)=0.
+           else
+           if (t(i,k).lt.243.15) then
+           qi(i,k)=clw(i,k)
+           else
+           fracg=(263.15-t(i,k))/20
+           qi(i,k)=clw(i,k)*fracg
+           endif
+           endif
+C           print*,t(i,k),qi(i,k),'temp,testglace'
+           enddo
+       enddo
+
+      return
+
+      end
+
       SUBROUTINE cv3_undilute2(nloc,ncum,nd,icb,icbs,nk
      :                       ,tnk,qnk,gznk,hnk,t,q,qs,gz
-     :                       ,p,h,tv,lv,pbase,buoybase,plcl
-     o                       ,inb,tp,tvp,clw,hp,ep,sigp,buoy)
+     :                       ,p,h,tv,lv,lf,pbase,buoybase,plcl
+     o                       ,inb,tp,tvp,clw,hp,ep,sigp,buoy,frac)
       implicit none
 
@@ -945,7 +978,8 @@
 #include "cv3param.h"
 #include "conema3.h"
+#include "cvflag.h"
 
 c inputs:
-      integer ncum, nd, nloc
+      integer ncum, nd, nloc, j
       integer icb(nloc), icbs(nloc), nk(nloc)
       real t(nloc,nd), q(nloc,nd), qs(nloc,nd), gz(nloc,nd)
@@ -953,5 +987,5 @@
       real tnk(nloc), qnk(nloc), gznk(nloc)
       real hnk(nloc)
-      real lv(nloc,nd), tv(nloc,nd), h(nloc,nd)
+      real lv(nloc,nd), lf(nloc,nd), tv(nloc,nd), h(nloc,nd)
       real pbase(nloc), buoybase(nloc), plcl(nloc)
 
@@ -964,9 +998,13 @@
 c local variables:
       integer i, k
-      real tg,qg,ahg,alv,s,tc,es,denom,rg,tca,elacrit
-      real by, defrac, pden
+       real tg,qg,ahg,alv,alf,s,tc,es,esi,denom,rg,tca,elacrit
+      real als 
+      real qsat_new,snew, qi(nloc,nd)
+      real by, defrac, pden, tbis
       real ah0(nloc), cape(nloc), capem(nloc), byp(nloc)
+      real frac(nloc,nd)
       logical lcape(nloc)
       integer iposit(nloc)
+      Real fracg
 
 !=====================================================================
@@ -978,4 +1016,5 @@
        ep(i,k)=0.0
        sigp(i,k)=spfac
+       qi(i,k)=0.
  160  continue
  170  continue
@@ -1060,6 +1099,11 @@
 
 c convect3: no approximation:
-           tp(i,k)=(ah0(i)-gz(i,k)-alv*qg)/(cpd+(cl-cpd)*qnk(i))
-
+           if (cvflag_ice) then
+              tp(i,k)=Max(0.,(ah0(i)-gz(i,k)-alv*qg)
+     &                /(cpd+(cl-cpd)*qnk(i)))
+           else
+              tp(i,k)=(ah0(i)-gz(i,k)-alv*qg)/(cpd+(cl-cpd)*qnk(i))
+           endif
+c          
                clw(i,k)=qnk(i)-qg
                clw(i,k)=max(0.0,clw(i,k))
@@ -1068,5 +1112,83 @@
 c convect3: (qg utilise au lieu du vrai mixing ratio rg):
                tvp(i,k)=tp(i,k)*(1.+qg/eps-qnk(i)) ! whole thing
+               if (cvflag_ice) then
+               if(clw(i,k).lt.1.e-11) then
+               tp(i,k)=tv(i,k)
+               tvp(i,k)=tv(i,k)
+               endif
+               endif
             endif
+
+        if (cvflag_ice) then
+cCR:attention boucle en klon dans Icefrac          
+c          Call Icefrac(t,clw,qi,nl,nloc)
+           if (t(i,k).gt.263.15) then
+           qi(i,k)=0.
+           else
+           if (t(i,k).lt.243.15) then
+           qi(i,k)=clw(i,k)
+           else
+           fracg=(263.15-t(i,k))/20
+           qi(i,k)=clw(i,k)*fracg
+           endif
+           endif     
+cCR: fin test     
+          if(t(i,k).lt.263.15) then
+cCR: on commente les calculs d'Arnaud car division par zero
+cnouveau calcul propose par JYG
+c           alv=lv0-clmcpv*(t(i,k)-273.15)
+c           alf=lf0-clmci*(t(i,k)-273.15)
+c           tg=tp(i,k)
+c           tc=tp(i,k)-273.15
+c           denom=243.5+tc
+c             do j=1,3
+ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+c         il faudra que esi vienne en argument de la convection
+ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+c             tbis=t(i,k)+(tp(i,k)-tg)
+c             esi=exp(23.33086-(6111.72784/tbis)
+c     :               +0.15215*log(tbis))
+c             qsat_new=eps*esi/(p(i,k)-esi*(1.-eps))
+c             snew=cpd*(1.-qnk(i))+cl*qnk(i)+alv*alv*qsat_new/
+c     :                               (rrv*tbis*tbis)
+c             snew=1./snew
+c             print*,esi,qsat_new,snew,'esi,qsat,snew'
+c             tp(i,k)=tg+(alf*qi(i,k)+alv*qg*(1.-(esi/es)))*snew
+c             print*,k,tp(i,k),qnk(i),'avec glace'
+c             print*,'tpNAN',tg,alf,qi(i,k),alv,qg,esi,es,snew
+c             enddo
+
+           alv=lv0-clmcpv*(t(i,k)-273.15)
+           alf=lf0+clmci*(t(i,k)-273.15)
+           als=alf+alv
+           tg=tp(i,k)
+           tp(i,k) = t(i,k)
+           do j=1,3
+             esi=exp(23.33086-(6111.72784/tp(i,k))
+     :               +0.15215*log(tp(i,k)))
+             qsat_new=eps*esi/(p(i,k)-esi*(1.-eps))
+             snew=cpd*(1.-qnk(i))+cl*qnk(i)+alv*als*qsat_new/
+     :                               (rrv*tp(i,k)*tp(i,k))
+             snew=1./snew
+cc             print*,esi,qsat_new,snew,'esi,qsat,snew'
+             tp(i,k)=tp(i,k)+
+     :         ( (cpd*(1.-qnk(i))+cl*qnk(i))*(tg-tp(i,k)) +
+     :         alv*(qg-qsat_new) + alf*qi(i,k) )*snew
+c             print*,k,tp(i,k),qsat_new,qnk(i),qi(i,k),
+c     :             'k,tp,q,qt,qi avec glace'
+           enddo
+
+cCR:reprise du code AJ
+           clw(i,k)=qnk(i)-qsat_new
+           clw(i,k)=max(0.0,clw(i,k))
+           tvp(i,k)=Max(0.,tp(i,k)*(1.+qsat_new/eps-qnk(i)))
+c           print*,tvp(i,k),'tvp'
+          endif
+          if(clw(i,k).lt.1.e-11) then
+           tp(i,k)=tv(i,k)
+           tvp(i,k)=tv(i,k)
+          endif
+        endif  ! (cvflag_ice)
+
   290     continue
   300   continue
@@ -1303,5 +1425,15 @@
         do 590 i=1,ncum
         if((k.ge.icb(i)).and.(k.le.inb(i)))then
+
+          if (cvflag_ice) then
+          frac(i,k)=1.-(t(i,k)-243.15)/(263.15-243.15)
+          frac(i,k)=min(max(frac(i,k),0.0),1.0)
+          hp(i,k)=hnk(i)+(lv(i,k)+(cpd-cpv)*t(i,k)+frac(i,k)*lf(i,k))
+     :            *ep(i,k)*clw(i,k)
+
+          else
           hp(i,k)=hnk(i)+(lv(i,k)+(cpd-cpv)*t(i,k))*ep(i,k)*clw(i,k)
+          endif
+
         endif
  590    continue
@@ -1555,5 +1687,5 @@
 
       SUBROUTINE cv3_mixing(nloc,ncum,nd,na,ntra,icb,nk,inb
-     :                    ,ph,t,rr,rs,u,v,tra,h,lv,qnk
+     :                    ,ph,t,rr,rs,u,v,tra,h,lv,lf,frac,qnk
      :                    ,unk,vnk,hp,tv,tvp,ep,clw,m,sig
      :   ,ment,qent,uent,vent,nent,sij,elij,ments,qents,traent)
@@ -1567,4 +1699,5 @@
 #include "cvthermo.h"
 #include "cv3param.h"
+#include "cvflag.h"
 
 c inputs:
@@ -1578,4 +1711,5 @@
       real tra(nloc,nd,ntra) ! input of convect3
       real lv(nloc,na), h(nloc,na), hp(nloc,na)
+      real lf(nloc,na), frac(nloc,na)
       real tv(nloc,na), tvp(nloc,na), ep(nloc,na), clw(nloc,na)
       real m(nloc,na)        ! input of convect3
@@ -1659,4 +1793,14 @@
           rti=qnk(il)-ep(il,i)*clw(il,i)
           bf2=1.+lv(il,j)*lv(il,j)*rs(il,j)/(rrv*t(il,j)*t(il,j)*cpd)
+
+
+          if (cvflag_ice) then
+c          print*,cvflag_ice,'cvflag_ice dans do 700'
+          if (t(il,j).le.263.15) then
+          bf2=1.+(lf(il,j)+lv(il,j))*(lv(il,j)+frac(il,j)
+     :          *lf(il,j))*rs(il,j)/(rrv*t(il,j)*t(il,j)*cpd)
+          endif
+          endif
+
           anum=h(il,j)-hp(il,i)+(cpv-cpd)*t(il,j)*(rti-rr(il,j))
           denom=h(il,i)-hp(il,i)+(cpd-cpv)*(rr(il,i)-rti)*t(il,j)
@@ -1671,6 +1815,14 @@
           if((stemp.lt.0.0.or.stemp.gt.1.0.or.altem.gt.cwat)
      :                 .and.j.gt.i)then
+
+          if (cvflag_ice) then
+          anum=anum-(lv(il,j)+frac(il,j)*lf(il,j))*(rti-rs(il,j)
+     :          -cwat*bf2)
+          denom=denom+(lv(il,j)+frac(il,j)*lf(il,j))*(rr(il,i)-rti)
+          else
            anum=anum-lv(il,j)*(rti-rs(il,j)-cwat*bf2)
            denom=denom+lv(il,j)*(rr(il,i)-rti)
+          endif
+
            if(abs(denom).lt.0.01)denom=0.01
            sij(il,i,j)=anum/denom
@@ -1780,8 +1932,19 @@
         lwork(il)=(nent(il,i).ne.0)
         qp=qnk(il)-ep(il,i)*clw(il,i)
+
+        if(cvflag_ice) then
+
+        anum=h(il,i)-hp(il,i)-(lv(il,i)+frac(il,i)*lf(il,i))*
+     :       (qp-rs(il,i))+(cpv-cpd)*t(il,i)*(qp-rr(il,i))
+        denom=h(il,i)-hp(il,i)+(lv(il,i)+frac(il,i)*lf(il,i))*
+     :        (rr(il,i)-qp)+(cpd-cpv)*t(il,i)*(rr(il,i)-qp)
+        else
+
         anum=h(il,i)-hp(il,i)-lv(il,i)*(qp-rs(il,i))
      :           +(cpv-cpd)*t(il,i)*(qp-rr(il,i))
         denom=h(il,i)-hp(il,i)+lv(il,i)*(rr(il,i)-qp)
      :           +(cpd-cpv)*t(il,i)*(rr(il,i)-qp)
+        endif
+
         if(abs(denom).lt.0.01)denom=0.01
         scrit(il)=anum/denom
@@ -1948,7 +2111,8 @@
       SUBROUTINE cv3_unsat(nloc,ncum,nd,na,ntra,icb,inb,iflag
      :              ,t,rr,rs,gz,u,v,tra,p,ph
-     :              ,th,tv,lv,cpn,ep,sigp,clw
+     :              ,th,tv,lv,lf,cpn,ep,sigp,clw
      :              ,m,ment,elij,delt,plcl,coef_clos
-     o              ,mp,rp,up,vp,trap,wt,water,evap,b,sigd
+     o              ,mp,rp,up,vp,trap,wt,water,evap,fondue,ice
+     :              ,faci,b,sigd
      o              ,wdtrainA,wdtrainM)                                ! RomP
       implicit none
@@ -1969,4 +2133,5 @@
       real ep(nloc,na), sigp(nloc,na), clw(nloc,na)
       real th(nloc,na),tv(nloc,na),lv(nloc,na),cpn(nloc,na)
+      real lf(nloc,na)
       real m(nloc,na), ment(nloc,na,na), elij(nloc,na,na)
       real coef_clos(nloc)
@@ -1978,4 +2143,5 @@
       real mp(nloc,na), rp(nloc,na), up(nloc,na), vp(nloc,na)
       real water(nloc,na), evap(nloc,na), wt(nloc,na)
+      real ice(nloc,na), fondue(nloc,na),faci(nloc,na)
       real trap(nloc,na,ntra)
       real b(nloc,na), sigd(nloc)
@@ -1988,12 +2154,14 @@
 c local variables
       integer i,j,k,il,num1,ndp1
-      real tinv, delti
+      real tinv, delti, coef
       real awat, afac, afac1, afac2, bfac
-      real pr1, pr2, sigt, b6, c6, revap, delth
+      real pr1, pr2, sigt, b6, c6, d6, e6, f6, revap, delth
       real amfac, amp2, xf, tf, fac2, ur, sru, fac, d, af, bf
-      real ampmax
+      real ampmax, thaw
       real tevap(nloc)
-      real lvcp(nloc,na)
+      real lvcp(nloc,na),lfcp(nloc,na)
       real h(nloc,na),hm(nloc,na)
+      real frac(nloc,na)
+      real fraci(nloc,na),prec(nloc,na)
       real wdtrain(nloc)
       logical lwork(nloc),mplus(nloc)
@@ -2015,7 +2183,14 @@
           wt(il,i)=0.001
           water(il,i)=0.0
+          frac(il,i)=0.0
+          faci(il,i)=0.0
+          fraci(il,i)=0.0
+          ice(il,i)=0.0
+          prec(il,i)=0.0
+          fondue(il,i)=0.0
           evap(il,i)=0.0
           b(il,i)=0.0
           lvcp(il,i)=lv(il,i)/cpn(il,i)
+          lfcp(il,i)=lf(il,i)/cpn(il,i)
          enddo
         enddo
@@ -2115,9 +2290,28 @@
       wt(il,i)=45.0
 
+      if (cvflag_ice) then
+      frac(il,inb(il)) = 1. -(t(il,inb(il))-243.15)/(263.15-243.15)
+      frac(il,inb(il)) = min(max(frac(il,inb(il)),0.),1.)
+      fraci(il,inb(il)) = frac(il,inb(il))
+      else
+      continue
+      endif
+
       if(i.lt.inb(il))then
+
+      if (cvflag_ice) then
+      thaw = (t(il,i)-273.15)/(275.15-273.15)
+      thaw = min(max(thaw,0.0),1.0)
+      frac(il,i)=frac(il,i)*(1.-thaw)
+      else
+      continue
+      endif
+
        rp(il,i)=rp(il,i+1)
      :       +(cpd*(t(il,i+1)-t(il,i))+gz(il,i+1)-gz(il,i))/lv(il,i)
        rp(il,i)=0.5*(rp(il,i)+rr(il,i))
       endif
+      fraci(il,i)=1.-(t(il,i)-243.15)/(263.15-243.15)
+      fraci(il,i)=min(max(fraci(il,i),0.0),1.0)
       rp(il,i)=max(rp(il,i),0.0)
       rp(il,i)=amin1(rp(il,i),rs(il,i))
@@ -2126,4 +2320,7 @@
       if(i.eq.1)then
        afac=p(il,1)*(rs(il,1)-rp(il,1))/(1.0e4+2000.0*p(il,1)*rs(il,1))
+       if (cvflag_ice) then
+       afac1=p(il,i)*(rs(il,1)-rp(il,1))/(1.0e4+2000.0*p(il,1)*rs(il,1))
+       endif
       else
        rp(il,i-1)=rp(il,i)
@@ -2161,7 +2358,9 @@
 c       b6 = bfac*100.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac
 c       c6 = water(il,i+1) + wdtrain(il)*bfac
+c       c6 = prec(il,i+1) + wdtrain(il)*bfac
 c        revap=0.5*(-b6+sqrt(b6*b6+4.*c6))
 c        evap(il,i)=sigt*afac*revap
 c        water(il,i)=revap*revap
+c        prec(il,i)=revap*revap
 cc        print *,' i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il) ',
 cc     $            i,b6,c6,revap,evap(il,i),water(il,i),wdtrain(il)
@@ -2169,4 +2368,87 @@
 c
 c--------retour à la formulation originale d'Emanuel.
+       if (cvflag_ice) then
+
+c      b6=bfac*50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac
+c      c6=prec(il,i+1)+bfac*wdtrain(il)
+c     :    -50.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*evap(il,i+1)
+c      if(c6.gt.0.0)then
+c       revap=0.5*(-b6+sqrt(b6*b6+4.*c6))
+c
+cJAM  Attention: evap=sigt*E
+c     Modification: evap devient l'évaporation en milieu de couche
+c     car nécessaire dans cv3_yield
+c     Du coup, il faut modifier pas mal d'équations...
+c     et l'expression de afac qui devient afac1
+c     revap=sqrt((prec(i+1)+prec(i))/2)
+
+      b6=bfac*50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac1
+      c6=prec(il,i+1)+0.5*bfac*wdtrain(il)
+c      print *,'bfac,sigd(il),sigt,afac1 ',bfac,sigd(il),sigt,afac1
+c      print *,'prec(il,i+1),wdtrain(il) ',prec(il,i+1),wdtrain(il)
+c      print *,'b6,c6,b6*b6+4.*c6 ',b6,c6,b6*b6+4.*c6
+      if (c6 .gt. b6*b6+1.e-20) then
+       revap=2.*c6/(b6+sqrt(b6*b6+4.*c6))
+      else
+       revap=(-b6+sqrt(b6*b6+4.*c6))/2.
+      endif
+      prec(il,i)=Max(0.,2.*revap*revap-prec(il,i+1))
+c      print*,prec(il,i),'neige'
+
+cjyg    Dans sa formulation originale, Emanuel calcule l'evaporation par:
+cc             evap(il,i)=sigt*afac*revap
+c     ce qui n'est pas correct. Dans cv_routines, la formulation a été modifiee.
+c     Ici,l'evaporation evap est simplement calculee par l'equation de
+c     conservation.
+c       prec(il,i)=revap*revap
+c      else
+cjyg----   Correction : si c6 <= 0, water(il,i)=0.
+c       prec(il,i)=0.
+c      endif
+
+cjyg---   Dans tous les cas, evaporation = [tt ce qui entre dans la couche i]
+c                                    moins [tt ce qui sort de la couche i]
+c       print *, 'evap avec ice'
+       evap(il,i)=
+     :       (wdtrain(il)+sigd(il)*wt(il,i)*(prec(il,i+1)-prec(il,i)))
+     :                 /(sigd(il)*(ph(il,i)-ph(il,i+1))*100.)
+
+      d6=bfac*wdtrain(il)-100.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))
+     :   *evap(il,i)
+      e6=bfac*wdtrain(il)
+      f6=-100.*sigd(il)*bfac*(ph(il,i)-ph(il,i+1))*
+     :   evap(il,i)
+
+      thaw=(t(il,i)-273.15)/(275.15-273.15)
+      thaw=min(max(thaw,0.0),1.0)
+      water(il,i)=water(il,i+1)+(1-fraci(il,i))*d6
+      water(il,i)=max(water(il,i),0.)
+      ice(il,i)=ice(il,i+1)+fraci(il,i)*d6
+      ice(il,i)=max(ice(il,i),0.)
+      fondue(il,i)=ice(il,i)*thaw
+      water(il,i)=water(il,i)+fondue(il,i)
+      ice(il,i)=ice(il,i)-fondue(il,i)
+
+      if(water(il,i)+ice(il,i).lt.1.e-30)then
+      faci(il,i)=0.
+      else
+      faci(il,i)=ice(il,i)/(water(il,i)+ice(il,i))
+      endif
+
+c      water(il,i)=water(il,i+1)+(1.-fraci(il,i))*e6+(1.-faci(il,i))*f6
+c      water(il,i)=max(water(il,i),0.)
+c      ice(il,i)=ice(il,i+1)+fraci(il,i)*e6+faci(il,i)*f6
+c      ice(il,i)=max(ice(il,i),0.)
+c      fondue(il,i)=ice(il,i)*thaw
+c      water(il,i)=water(il,i)+fondue(il,i)
+c      ice(il,i)=ice(il,i)-fondue(il,i)
+c
+c      if((water(il,i)+ice(il,i)).lt.1.e-30)then
+c       faci(il,i)=0.
+c      else
+c       faci(il,i)=ice(il,i)/(water(il,i)+ice(il,i))
+c      endif
+
+      else
       b6=bfac*50.*sigd(il)*(ph(il,i)-ph(il,i+1))*sigt*afac
       c6=water(il,i+1)+bfac*wdtrain(il)
@@ -2174,32 +2456,14 @@
       if(c6.gt.0.0)then
        revap=0.5*(-b6+sqrt(b6*b6+4.*c6))
-cjyg    Dans sa formulation originale, Emanuel calcule l'evaporation par:
-cc             evap(il,i)=sigt*afac*revap
-c     ce qui n'est pas correct. Dans cv_routines, la formulation a été modifiee.
-c     Ici,l'evaporation evap est simplement calculee par l'equation de
-c     conservation.
        water(il,i)=revap*revap
       else
-cjyg----   Correction : si c6 <= 0, water(il,i)=0.
-       water(il,i) = 0.
+       water(il,i)= 0.
       endif
-cJYG/IM : ci-dessous formulation originale de KE
-c      evap(il,i)=-evap(il,i+1)
-c    :            +(wdtrain(il)+sigd(il)*wt(il,i)*water(il,i+1))
-c    :                 /(sigd(il)*(ph(il,i)-ph(il,i+1))*50.)
-c
-cJYG/IM : ci-dessous modification formulation originale de KE
-c        pour eliminer oscillations verticales de pluie se produisant
-c        lorsqu'il y a evaporation totale de la pluie
-c
-c       evap(il,i)= +(wdtrain(il)+sigd(il)*wt(il,i)*water(il,i+1)) !itlmd(jyg)
-c     :                 /(sigd(il)*(ph(il,i)-ph(il,i+1))*100.)
-c      end if  !itlmd(jyg)
-cjyg---   Dans tous les cas, evaporation = [tt ce qui entre dans la couche i]
-c                                    moins [tt ce qui sort de la couche i]
+c       print *, 'evap sans ice'
        evap(il,i)=
      :       (wdtrain(il)+sigd(il)*wt(il,i)*(water(il,i+1)-water(il,i)))
      :                 /(sigd(il)*(ph(il,i)-ph(il,i+1))*100.)
-c
+
+       endif
        endif !(i.le.inb(il) .and. lwork(il))
 995   Continue
@@ -2215,4 +2479,22 @@
       tevap(il)=max(0.0,evap(il,i))
       delth=max(0.001,(th(il,i)-th(il,i-1)))
+      if (cvflag_ice) then
+      if (cvflag_grav) then
+       mp(il,i)=100.*ginv*(lvcp(il,i)*sigd(il)*tevap(il)
+     :          *(p(il,i-1)-p(il,i))/delth
+     :          +lfcp(il,i)*sigd(il)*faci(il,i)*tevap(il)
+     :          *(p(il,i-1)-p(il,i))/delth
+     :          +lfcp(il,i)*sigd(il)*wt(il,i)/100.*fondue(il,i)
+     :          *(p(il,i-1)-p(il,i))/delth/(ph(il,i)-ph(il,i+1)))
+      else
+       mp(il,i)=10.*(lvcp(il,i)*sigd(il)*tevap(il)
+     :          *(p(il,i-1)-p(il,i))/delth
+     :          +lfcp(il,i)*sigd(il)*faci(il,i)*tevap(il)
+     :          *(p(il,i-1)-p(il,i))/delth
+     :          +lfcp(il,i)*sigd(il)*wt(il,i)/100.*fondue(il,i)
+     :          *(p(il,i-1)-p(il,i))/delth/(ph(il,i)-ph(il,i+1)))
+
+      endif
+      else
       if (cvflag_grav) then
        mp(il,i)=100.*ginv*lvcp(il,i)*sigd(il)*tevap(il)
@@ -2223,4 +2505,6 @@
       endif
 c
+      endif
+c
        endif !(i.le.inb(il) .and. lwork(il) .and. i.ne.1)
 996   Continue
@@ -2243,6 +2527,17 @@
      :               /(lvcp(il,i)*sigd(il)*th(il,i))
        af=xf*tf+mp(il,i+1)*mp(il,i+1)*tinv
+
+       if (cvflag_ice) then
+       bf=2.*(tinv*mp(il,i+1))**3+tinv*mp(il,i+1)*xf*tf
+     :            +50.*(p(il,i-1)-p(il,i))*xf*
+     :            (tevap(il)*(1.+(lf(il,i)/lv(il,i))*faci(il,i))+
+     :            (lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i)/
+     :            (ph(il,i)-ph(il,i+1)))
+       else
+
        bf=2.*(tinv*mp(il,i+1))**3+tinv*mp(il,i+1)*xf*tf
      :            +50.*(p(il,i-1)-p(il,i))*xf*tevap(il)
+       endif
+
        fac2=1.0
        if(bf.lt.0.0)fac2=-1.0
@@ -2262,9 +2557,28 @@
        mp(il,i)=max(0.0,mp(il,i))
 
+       if (cvflag_ice) then
        if (cvflag_grav) then
 Cjyg : il y a vraisemblablement une erreur dans la ligne 2 suivante:
 C il faut diviser par (mp(il,i)*sigd(il)*grav) et non par (mp(il,i)+sigd(il)*0.1).
 C Et il faut bien revoir les facteurs 100.
-        b(il,i-1)=b(il,i)+100.0*(p(il,i-1)-p(il,i))*tevap(il)
+         b(il,i-1)=b(il,i)+100.0*(p(il,i-1)-p(il,i))*
+     :            (tevap(il)*(1.+(lf(il,i)/lv(il,i))*faci(il,i))+
+     :            (lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i)
+     :            /(ph(il,i)-ph(il,i+1)))
+     2            /(mp(il,i)+sigd(il)*0.1)
+     3 -10.0*(th(il,i)-th(il,i-1))*t(il,i)/(lvcp(il,i)
+     : *sigd(il)*th(il,i))
+       else
+        b(il,i-1)=b(il,i)+100.0*(p(il,i-1)-p(il,i))*
+     :            (tevap(il)*(1.+(lf(il,i)/lv(il,i))*faci(il,i))+
+     :            (lf(il,i)/lv(il,i))*wt(il,i)/100.*fondue(il,i)
+     :            /(ph(il,i)-ph(il,i+1)))
+     2            /(mp(il,i)+sigd(il)*0.1)
+     3 -10.0*(th(il,i)-th(il,i-1))*t(il,i)/(lvcp(il,i)
+     : *sigd(il)*th(il,i))
+       endif
+       else
+       if (cvflag_grav) then
+         b(il,i-1)=b(il,i)+100.0*(p(il,i-1)-p(il,i))*tevap(il)
      2   /(mp(il,i)+sigd(il)*0.1)
      3 -10.0*(th(il,i)-th(il,i-1))*t(il,i)/(lvcp(il,i)
@@ -2276,4 +2590,5 @@
      : *sigd(il)*th(il,i))
        endif
+      endif
        b(il,i-1)=max(b(il,i-1),0.0)
 c
@@ -2391,7 +2706,7 @@
      :                    ,icb,inb,delt
      :                    ,t,rr,t_wake,rr_wake,s_wake,u,v,tra
-     :                    ,gz,p,ph,h,hp,lv,cpn,th,th_wake
+     :                    ,gz,p,ph,h,hp,lv,lf,cpn,th,th_wake
      :                    ,ep,clw,m,tp,mp,rp,up,vp,trap
-     :                    ,wt,water,evap,b,sigd
+     :                    ,wt,water,ice,evap,fondue,faci,b,sigd
      :                    ,ment,qent,hent,iflag_mix,uent,vent
      :                    ,nent,elij,traent,sig
@@ -2422,7 +2737,9 @@
       real th(nloc,na), p(nloc,nd), tp(nloc,na)
       real lv(nloc,na), cpn(nloc,na), ep(nloc,na), clw(nloc,na)
+      real lf(nloc,na)
       real m(nloc,na), mp(nloc,na), rp(nloc,na), up(nloc,na)
       real vp(nloc,na), wt(nloc,nd), trap(nloc,nd,ntra)
       real water(nloc,na), evap(nloc,na), b(nloc,na), sigd(nloc)
+      real fondue(nloc,na),faci(nloc,na), ice(nloc,na)
       real ment(nloc,na,na), qent(nloc,na,na), uent(nloc,na,na)
       real hent(nloc,na,na)
@@ -2455,5 +2772,5 @@
       real cpinv, rdcp, dpinv
       real awat(nloc)
-      real lvcp(nloc,na), mke(nloc,na)
+      real lvcp(nloc,na), lfcp(nloc,na), mke(nloc,na)
       real am(nloc), work(nloc), ad(nloc), amp1(nloc)
 c!!      real up1(nloc), dn1(nloc)
@@ -2513,4 +2830,5 @@
        do il=1,ncum
          lvcp(il,i)=lv(il,i)/cpn(il,i)
+         lfcp(il,i)=lf(il,i)/cpn(il,i)
        enddo
       enddo
@@ -2522,4 +2840,12 @@
       do il=1,ncum
        if(ep(il,inb(il)).ge.0.0001 .and. iflag(il) .le. 1)then
+        if (cvflag_ice) then
+        if (cvflag_grav) then
+           precip(il)=wt(il,1)*sigd(il)*(water(il,1)+ice(il,1))*86400.
+     :               *1000./(rowl*grav)
+        else
+         precip(il)=wt(il,1)*sigd(il)*(water(il,1)+ice(il,1))*8640.
+        endif
+        else
         if (cvflag_grav) then
            precip(il)=wt(il,1)*sigd(il)*water(il,1)*86400.*1000.
@@ -2527,4 +2853,5 @@
         else
          precip(il)=wt(il,1)*sigd(il)*water(il,1)*8640.
+        endif
         endif
        endif
@@ -2539,8 +2866,18 @@
        if(ep(il,inb(il)).ge.0.0001 .and. i.le.inb(il)
      :    .and. iflag(il) .le. 1)then
+        if (cvflag_ice) then
+        if (cvflag_grav) then
+           VPrecip(il,i) = wt(il,i)*sigd(il)*(water(il,i)+ice(il,i))
+     :                     /grav
+        else
+           VPrecip(il,i) = wt(il,i)*sigd(il)*(water(il,i)+ice(il,i))
+     :                     /10.
+        endif
+        else
         if (cvflag_grav) then
            VPrecip(il,i) = wt(il,i)*sigd(il)*water(il,i)/grav
         else
            VPrecip(il,i) = wt(il,i)*sigd(il)*water(il,i)/10.
+        endif
         endif
        endif
@@ -2585,5 +2922,12 @@
 cjyg  Correction pour conserver l'eau
 ccc       ft(il,1)=-0.5*lvcp(il,1)*sigd(il)*(evap(il,1)+evap(il,2)) !precip
-       ft(il,1)=-lvcp(il,1)*sigd(il)*evap(il,1)                  !precip
+       if (cvflag_ice) then
+       ft(il,1)=-lvcp(il,1)*sigd(il)*evap(il,1)
+     :           -lfcp(il,1)*sigd(il)*evap(il,1)*faci(il,1)
+     :           -lfcp(il,1)*sigd(il)*(fondue(il,1)*wt(il,1))/
+     :           (100.*(ph(il,1)-ph(il,2)))                               !precip
+       else
+       ft(il,1)=-lvcp(il,1)*sigd(il)*evap(il,1)
+       endif
 
       if (cvflag_grav) then
@@ -2595,6 +2939,13 @@
       endif
 
+      if (cvflag_ice) then
+        ft(il,1)=ft(il,1)+0.01*sigd(il)*wt(il,1)*(cl-cpd)*water(il,2)
+     :     *(t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il,1)+
+     :     0.01*sigd(il)*wt(il,1)*(ci-cpd)*ice(il,2)*
+     :     (t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il,1)
+      else
       ft(il,1)=ft(il,1)+0.01*sigd(il)*wt(il,1)*(cl-cpd)*water(il,2)
      :     *(t_wake(il,2)-t_wake(il,1))*work(il)/cpn(il,1)
+      endif
 
       ftd(il,1) = ft(il,1)                        ! fin precip
@@ -2791,5 +3142,13 @@
        ! precip
 ccc       ft(il,i)= -0.5*sigd(il)*lvcp(il,i)*(evap(il,i)+evap(il,i+1))
+       if (cvflag_ice) then
        ft(il,i)= -sigd(il)*lvcp(il,i)*evap(il,i)
+     :           -sigd(il)*lfcp(il,i)*evap(il,i)*faci(il,i)
+     :           -sigd(il)*lfcp(il,i)*fondue(il,i)*wt(il,i)/
+     :           (100.*(p(il,i-1)-p(il,i)))
+       else
+       ft(il,i)= -sigd(il)*lvcp(il,i)*evap(il,i)
+       endif
+
         rat=cpn(il,i-1)*cpinv
 c
@@ -2798,6 +3157,14 @@
      :   *(mp(il,i+1)*t_wake(il,i)*b(il,i)
      :   -mp(il,i)*t_wake(il,i-1)*rat*b(il,i-1))*dpinv
+       if (cvflag_ice) then
        ft(il,i)=ft(il,i)+0.01*sigd(il)*wt(il,i)*(cl-cpd)*water(il,i+1)
      :           *(t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
+     :           +0.01*sigd(il)*wt(il,i)*(ci-cpd)*ice(il,i+1)*
+     :           (t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
+      else
+       ft(il,i)=ft(il,i)+0.01*sigd(il)*wt(il,i)*(cl-cpd)*water(il,i+1)
+     :           *(t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
+      endif
+
        ftd(il,i)=ft(il,i)
         ! fin precip
@@ -2818,6 +3185,15 @@
      :   *(mp(il,i+1)*t_wake(il,i)*b(il,i)
      :   -mp(il,i)*t_wake(il,i-1)*rat*b(il,i-1))*dpinv
+
+       if (cvflag_ice) then
        ft(il,i)=ft(il,i)+0.01*sigd(il)*wt(il,i)*(cl-cpd)*water(il,i+1)
      :           *(t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
+     :           +0.01*sigd(il)*wt(il,i)*(ci-cpd)*ice(il,i+1)*
+     :           (t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
+       else
+       ft(il,i)=ft(il,i)+0.01*sigd(il)*wt(il,i)*(cl-cpd)*water(il,i+1)
+     :           *(t_wake(il,i+1)-t_wake(il,i))*dpinv*cpinv
+       endif
+
        ftd(il,i)=ft(il,i)
         ! fin precip
@@ -3744,3 +4120,2 @@
         return
         end
-
Index: LMDZ5/branches/testing/libf/phylmd/cv3a_compress.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/cv3a_compress.F	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/cv3a_compress.F	(revision 1864)
@@ -6,6 +6,6 @@
      :    ,u1,v1,gz1,th1,th1_wake
      :    ,tra1
-     :    ,h1     ,lv1     ,cpn1   ,p1,ph1,tv1    ,tp1,tvp1,clw1
-     :    ,h1_wake,lv1_wake,cpn1_wake     ,tv1_wake
+     :    ,h1     ,lv1, lf1     ,cpn1   ,p1,ph1,tv1    ,tp1,tvp1,clw1
+     :    ,h1_wake,lv1_wake,lf1_wake,cpn1_wake     ,tv1_wake
      :    ,sig1,w01,ptop21
      :    ,Ale1,Alp1
@@ -16,6 +16,6 @@
      o    ,u,v,gz,th,th_wake
      o    ,tra
-     o    ,h     ,lv     ,cpn    ,p,ph,tv    ,tp,tvp,clw
-     o    ,h_wake,lv_wake,cpn_wake    ,tv_wake
+     o    ,h     ,lv, lf     ,cpn    ,p,ph,tv    ,tp,tvp,clw
+     o    ,h_wake,lv_wake,lf_wake,cpn_wake    ,tv_wake
      o    ,sig,w0,ptop2
      o    ,Ale,Alp  )
@@ -45,9 +45,9 @@
       real gz1(len,nd),th1(len,nd),th1_wake(len,nd)
       real tra1(len,nd,ntra)
-      real h1(len,nd),lv1(len,nd),cpn1(len,nd)
+      real h1(len,nd),lv1(len,nd),lf1(len,nd),cpn1(len,nd)
       real p1(len,nd),ph1(len,nd+1),tv1(len,nd),tp1(len,nd)
       real tvp1(len,nd),clw1(len,nd)
       real h1_wake(len,nd),lv1_wake(len,nd),cpn1_wake(len,nd)
-      real tv1_wake(len,nd)
+      real tv1_wake(len,nd),lf1_wake(len,nd)
       real sig1(len,nd), w01(len,nd), ptop21(len)
       real Ale1(len),Alp1(len)
@@ -65,9 +65,9 @@
       real gz(len,nd),th(len,nd),th_wake(len,nd)
       real tra(len,nd,ntra)
-      real h(len,nd),lv(len,nd),cpn(len,nd)
+      real h(len,nd),lv(len,nd),lf(len,nd),cpn(len,nd)
       real p(len,nd),ph(len,nd+1),tv(len,nd),tp(len,nd)
       real tvp(len,nd),clw(len,nd)
       real h_wake(len,nd),lv_wake(len,nd),cpn_wake(len,nd)
-      real tv_wake(len,nd)
+      real tv_wake(len,nd),lf_wake(len,nd)
       real sig(len,nd), w0(len,nd), ptop2(len)
       real Ale(len),Alp(len)
@@ -99,4 +99,5 @@
         h(nn,k)=h1(i,k)
         lv(nn,k)=lv1(i,k)
+        lf(nn,k)=lf1(i,k)
         cpn(nn,k)=cpn1(i,k)
         p(nn,k)=p1(i,k)
@@ -108,4 +109,5 @@
         h_wake(nn,k)=h1_wake(i,k)
         lv_wake(nn,k)=lv1_wake(i,k)
+        lf_wake(nn,k)=lf1_wake(i,k)
         cpn_wake(nn,k)=cpn1_wake(i,k)
         tv_wake(nn,k)=tv1_wake(i,k)
Index: LMDZ5/branches/testing/libf/phylmd/cv_driver.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/cv_driver.F	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/cv_driver.F	(revision 1864)
@@ -341,9 +341,9 @@
 ! --- SET CONSTANTS AND PARAMETERS
 !-------------------------------------------------------------------
-      print *, '-> cv_driver'      !jyg
+!      print *, '-> cv_driver'      !jyg
 c -- set simulation flags:
 c   (common cvflag)
 
-       CALL cv_flag
+       CALL cv_flag(0)
 
 c -- set thermodynamical constants:
@@ -494,5 +494,5 @@
  400  continue
 
-         print*,'cv_driver : klon, ncum = ',len,ncum
+!         print*,'cv_driver : klon, ncum = ',len,ncum
 
       IF (ncum.gt.0) THEN
@@ -696,11 +696,15 @@
 9999  continue
 
-      print *, 'fin cv_driver ->'      !jyg
+!      print *, 'fin cv_driver ->'      !jyg
       return
       end
 
 !==================================================================
-      SUBROUTINE cv_flag
+      SUBROUTINE cv_flag(iflag_ice_thermo)
       implicit none
+
+c Argument : iflag_ice_thermo : ice thermodynamics is taken into account if
+c                               iflag_ice_thermo >=1
+      INTEGER iflag_ice_thermo
 
 #include "cvflag.h"
@@ -709,4 +713,5 @@
 c differente de 10.0 dans convect3: 
       cvflag_grav = .TRUE.
+      cvflag_ice = iflag_ice_thermo .GE. 1
 
       return
@@ -744,7 +749,9 @@
        cpv = RCPV
        cl  = RCW
+       ci  = RCS
        rrv = RV
        rrd = RD
        lv0 = RLVTT
+       lf0 = RLSTT-RLVTT
        g   = RG     ! not used in convect3
 c ori      t0  = RTT
@@ -758,4 +765,5 @@
       clmcpv=cl-cpv
       clmcpd=cl-cpd
+      clmci=cl-ci
       cpdmcp=cpd-cpv
       cpvmcpd=cpv-cpd
Index: LMDZ5/branches/testing/libf/phylmd/cva_driver.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/cva_driver.F	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/cva_driver.F	(revision 1864)
@@ -3,5 +3,5 @@
 !
       SUBROUTINE cva_driver(len,nd,ndp1,ntra,nloc,
-     &                   iflag_con,iflag_mix,
+     &                   iflag_con,iflag_mix,iflag_ice_thermo,
      &                   iflag_clos,delt,
      &                   t1,q1,qs1,t1_wake,q1_wake,qs1_wake,s1_wake,
@@ -52,4 +52,5 @@
 C      iflag_con     Integer        Input        version of convect (3/4)
 C      iflag_mix     Integer        Input        version of mixing  (0/1/2)
+C   iflag_ice_thermo Integer        Input        accounting for ice thermodynamics (0/1)
 C      iflag_clos    Integer        Input        version of closure (0/1)
 C      delt          Real           Input        time step
@@ -155,4 +156,5 @@
       integer iflag_con
       integer iflag_mix
+      integer iflag_ice_thermo
       integer iflag_clos
       real delt
@@ -381,4 +383,5 @@
       real buoybase1(klon)
 
+      real lf1(klon,klev) ,lf1_wake(klon,klev)
       real lv1(klon,klev) ,lv1_wake(klon,klev)
       real cpn1(klon,klev),cpn1_wake(klon,klev)
@@ -419,6 +422,6 @@
       real gz(nloc,klev),h(nloc,klev)     ,hm(nloc,klev)
       real               h_wake(nloc,klev),hm_wake(nloc,klev)
-      real lv(nloc,klev)     ,cpn(nloc,klev)
-      real lv_wake(nloc,klev),cpn_wake(nloc,klev)
+      real lv(nloc,klev), lf(nloc,klev), cpn(nloc,klev)
+      real lv_wake(nloc,klev), lf_wake(nloc,klev), cpn_wake(nloc,klev)
       real p(nloc,klev),ph(nloc,klev+1),tv(nloc,klev)    ,tp(nloc,klev)
       real                              tv_wake(nloc,klev)
@@ -430,5 +433,5 @@
       real sig(nloc,klev), w0(nloc,klev), ptop2(nloc)
       real hp(nloc,klev), ep(nloc,klev), sigp(nloc,klev)
-      real frac(nloc), buoy(nloc,klev)
+      real buoy(nloc,klev)
       real cape(nloc)
       real cin(nloc)
@@ -444,10 +447,12 @@
       real sigd(nloc)
 !      real mp(nloc,klev), qp(nloc,klev), up(nloc,klev), vp(nloc,klev)
-!      real wt(nloc,klev), water(nloc,klev), evap(nloc,klev)
+!      real wt(nloc,klev), water(nloc,klev), evap(nloc,klev), ice(nloc,klev)
 !      real b(nloc,klev), sigd(nloc)
 !      save mp,qp,up,vp,wt,water,evap,b
       real, save, allocatable :: mp(:,:),qp(:,:),up(:,:),vp(:,:)
-      real, save, allocatable :: wt(:,:),water(:,:),evap(:,:), b(:,:)
-c$OMP THREADPRIVATE(mp,qp,up,vp,wt,water,evap,b)
+      real, save, allocatable :: wt(:,:),water(:,:),evap(:,:)
+      real, save, allocatable :: ice(:,:),fondue(:,:), b(:,:)
+      real, save, allocatable :: frac(:,:), faci(:,:)
+c$OMP THREADPRIVATE(mp,qp,up,vp,wt,water,evap,ice,fondue,b,frac,faci)
       real  ft(nloc,klev), fq(nloc,klev)
       real ftd(nloc,klev), fqd(nloc,klev)
@@ -496,5 +501,7 @@
          allocate(mp(nloc,klev), qp(nloc,klev), up(nloc,klev))
          allocate(vp(nloc,klev), wt(nloc,klev), water(nloc,klev))
+         allocate(ice(nloc,klev), fondue(nloc,klev))
          allocate(evap(nloc,klev), b(nloc,klev))
+         allocate(frac(nloc,klev), faci(nloc,klev))
          first=.false.
        endif
@@ -502,5 +509,5 @@
 c   (common cvflag)
 
-       CALL cv_flag
+       CALL cv_flag(iflag_ice_thermo)
 
 c -- set thermodynamical constants:
@@ -610,9 +617,9 @@
 !       print*,'t1, q1 ',t1,q1
        CALL cv3_prelim(len,nd,ndp1,t1,q1,p1,ph1      ! nd->na
-     o               ,lv1,cpn1,tv1,gz1,h1,hm1,th1)
+     o               ,lv1,lf1,cpn1,tv1,gz1,h1,hm1,th1)
     
 c
        CALL cv3_prelim(len,nd,ndp1,t1_wake,q1_wake,p1,ph1 ! nd->na
-     o               ,lv1_wake,cpn1_wake,tv1_wake,gz1_wake
+     o               ,lv1_wake,lf1_wake,cpn1_wake,tv1_wake,gz1_wake
      o               ,h1_wake,bid,th1_wake)
     
@@ -755,6 +762,6 @@
      :    ,u1,v1,gz1,th1,th1_wake
      :    ,tra1
-     :    ,h1     ,lv1     ,cpn1   ,p1,ph1,tv1    ,tp1,tvp1,clw1
-     :    ,h1_wake,lv1_wake,cpn1_wake     ,tv1_wake
+     :    ,h1     ,lv1, lf1,cpn1   ,p1,ph1,tv1    ,tp1,tvp1,clw1
+     :    ,h1_wake,lv1_wake,lf1_wake,cpn1_wake     ,tv1_wake
      :    ,sig1,w01,ptop21
      :    ,Ale1,Alp1
@@ -765,6 +772,6 @@
      o    ,u,v,gz,th,th_wake
      o    ,tra
-     o    ,h     ,lv     ,cpn    ,p,ph,tv    ,tp,tvp,clw
-     o    ,h_wake,lv_wake,cpn_wake    ,tv_wake
+     o    ,h     ,lv, lf     ,cpn    ,p,ph,tv    ,tp,tvp,clw
+     o    ,h_wake,lv_wake,lf_wake,cpn_wake    ,tv_wake
      o    ,sig,w0,ptop2
      o    ,Ale,Alp  ) 
@@ -800,6 +807,7 @@
        CALL cv3_undilute2(nloc,ncum,nd,icb,icbs,nk        !na->nd
      :                        ,tnk,qnk,gznk,hnk,t,q,qs,gz
-     :                        ,p,h,tv,lv,pbase,buoybase,plcl
-     o                        ,inb,tp,tvp,clw,hp,ep,sigp,buoy)
+     :                        ,p,h,tv,lv,lf,pbase,buoybase,plcl
+     o                        ,inb,tp,tvp,clw,hp,ep,sigp,buoy
+     :                        ,frac)
    
       endif
@@ -816,4 +824,9 @@
 !-------------------------------------------------------------------
       IF (iflag_con .eq. 3) THEN
+       if ((iflag_ice_thermo.eq.1).and.(iflag_mix.ne.0)) then
+         write(*,*) " iflag_ice_thermo==1 requires iflag_mix==0",
+     &   " but iflag_mix=",iflag_mix, ". Might as well stop here."
+         stop
+       endif
        IF (iflag_mix .ge. 1 ) THEN
          CALL zilch(supmax,nloc*klev)    
@@ -877,5 +890,5 @@
         IF (iflag_mix.eq.0) THEN
          CALL cv3_mixing(nloc,ncum,nd,nd,ntra,icb,nk,inb    ! na->nd
-     :                       ,ph,t,q,qs,u,v,tra,h,lv,qnk
+     :                       ,ph,t,q,qs,u,v,tra,h,lv,lf,frac,qnk
      :                       ,unk,vnk,hp,tv,tvp,ep,clw,m,sig
      o   ,ment,qent,uent,vent,nent,sigij,elij,ments,qents,traent)
@@ -913,8 +926,9 @@
        CALL cv3_unsat(nloc,ncum,nd,nd,ntra,icb,inb,iflag    ! na->nd
      :               ,t_wake,q_wake,qs_wake,gz,u,v,tra,p,ph
-     :               ,th_wake,tv_wake,lv_wake,cpn_wake
+     :               ,th_wake,tv_wake,lv_wake,lf_wake,cpn_wake
      :               ,ep,sigp,clw
      :               ,m,ment,elij,delt,plcl,coef_clos
-     o          ,mp,qp,up,vp,trap,wt,water,evap,b,sigd
+     o          ,mp,qp,up,vp,trap,wt,water,evap,fondue,ice
+     :          ,faci,b,sigd
      o          ,wdtrainA,wdtrainM)   ! RomP
       endif
@@ -943,7 +957,7 @@
      :                     ,icb,inb,delt
      :                     ,t,q,t_wake,q_wake,s_wake,u,v,tra
-     :                     ,gz,p,ph,h,hp,lv,cpn,th,th_wake
+     :                     ,gz,p,ph,h,hp,lv,lf,cpn,th,th_wake
      :                     ,ep,clw,m,tp,mp,qp,up,vp,trap
-     :                     ,wt,water,evap,b,sigd
+     :                     ,wt,water,ice,evap,fondue,faci,b,sigd
      :                    ,ment,qent,hent,iflag_mix,uent,vent
      :                    ,nent,elij,traent,sig
@@ -1043,3 +1057,2 @@
       return
       end
-
Index: LMDZ5/branches/testing/libf/phylmd/cvflag.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/cvflag.h	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/cvflag.h	(revision 1864)
@@ -3,5 +3,6 @@
 !
       logical cvflag_grav
+      logical cvflag_ice
 
-      COMMON /cvflag/ cvflag_grav 
+      COMMON /cvflag/ cvflag_grav, cvflag_ice  
 c$OMP THREADPRIVATE(/cvflag/)
Index: LMDZ5/branches/testing/libf/phylmd/cvthermo.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/cvthermo.h	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/cvthermo.h	(revision 1864)
@@ -4,13 +4,13 @@
 c Thermodynamical constants for convectL:
 
-      real cpd, cpv, cl, rrv, rrd, lv0, g, rowl, t0
-      real clmcpv, clmcpd, cpdmcp, cpvmcpd, cpvmcl
+      real cpd, cpv, cl, ci, rrv, rrd, lv0, lf0, g, rowl, t0
+      real clmcpv, clmcpd, cpdmcp, cpvmcpd, cpvmcl, clmci
       real eps, epsi, epsim1
       real ginv, hrd
       real grav
 
-      COMMON /cvthermo/ cpd, cpv, cl, rrv, rrd, lv0, g, rowl, t0
-     :                 ,clmcpv, clmcpd, cpdmcp, cpvmcpd, cpvmcl 
-     :                 ,eps, epsi, epsim1, ginv, hrd, grav
+      COMMON /cvthermo/ cpd, cpv, cl, ci, rrv, rrd, lv0, lf0, g, rowl
+     :                 ,t0, clmcpv, clmcpd, cpdmcp, cpvmcpd, cpvmcl 
+     :                 ,clmci, eps, epsi, epsim1, ginv, hrd, grav
 
 c$OMP THREADPRIVATE(/cvthermo/)
Index: LMDZ5/branches/testing/libf/phylmd/declare_STDlev.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/declare_STDlev.h	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/declare_STDlev.h	(revision 1864)
@@ -1,10 +1,10 @@
 cIM for NMC files
-      real twriteSTD(klon,nlevSTD,nfiles)
-      real qwriteSTD(klon,nlevSTD,nfiles)
-      real rhwriteSTD(klon,nlevSTD,nfiles)
-      real phiwriteSTD(klon,nlevSTD,nfiles)
-      real uwriteSTD(klon,nlevSTD,nfiles)
-      real vwriteSTD(klon,nlevSTD,nfiles)
-      real wwriteSTD(klon,nlevSTD,nfiles)
+!      real twriteSTD(klon,nlevSTD,nfiles)
+!      real qwriteSTD(klon,nlevSTD,nfiles)
+!      real rhwriteSTD(klon,nlevSTD,nfiles)
+!      real phiwriteSTD(klon,nlevSTD,nfiles)
+!      real uwriteSTD(klon,nlevSTD,nfiles)
+!      real vwriteSTD(klon,nlevSTD,nfiles)
+!      real wwriteSTD(klon,nlevSTD,nfiles)
 
       real twriteSTD3(klon,nlevSTD3)
Index: LMDZ5/branches/testing/libf/phylmd/etat0_netcdf.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/etat0_netcdf.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/etat0_netcdf.F90	(revision 1864)
@@ -504,6 +504,6 @@
   zmax0(:) = 40.
   f0(:) = 1.e-5
-  ema_work1(:,:) = 0.
-  ema_work2(:,:) = 0.
+  sig1(:,:) = 0.
+  w01(:,:) = 0.
   wake_deltat(:,:) = 0.
   wake_deltaq(:,:) = 0.
Index: LMDZ5/branches/testing/libf/phylmd/fisrtilp.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/fisrtilp.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/fisrtilp.F90	(revision 1864)
@@ -8,5 +8,6 @@
      frac_impa, frac_nucl, beta,                        &
      prfl, psfl, rhcl, zqta, fraca,                     &
-     ztv, zpspsk, ztla, zthl, iflag_cldcon)
+     ztv, zpspsk, ztla, zthl, iflag_cldcon,             &
+     iflag_ice_thermo)
 
   !
@@ -51,6 +52,8 @@
   REAL zpspsk(klon,klev),ztla(klon,klev)
   REAL zthl(klon,klev)
+  REAL ztfondue, qsl, qsi
 
   logical lognormale(klon)
+  logical ice_thermo
 
   !AA
@@ -77,4 +80,5 @@
   INTEGER ncoreczq  
   INTEGER iflag_cldcon
+  INTEGER iflag_ice_thermo
   PARAMETER (ninter=5)
   LOGICAL evap_prec ! evaporation de la pluie
@@ -97,10 +101,14 @@
   INTEGER i, k, n, kk
   REAL zqs(klon), zdqs(klon), zdelta, zcor, zcvm5   
-  REAL zrfl(klon), zrfln(klon), zqev, zqevt
-  REAL zoliq(klon), zcond(klon), zq(klon), zqn(klon), zdelq
+  REAL zrfl(klon), zrfln(klon), zqev, zqevt 
+  REAL zifl(klon), zifln(klon), zqev0,zqevi, zqevti
+  REAL zoliq(klon), zcond(klon), zq(klon), zqn(klon), zdelq 
+  REAL zoliqp(klon), zoliqi(klon)
   REAL ztglace, zt(klon)
   INTEGER nexpo ! exponentiel pour glace/eau
   REAL zdz(klon),zrho(klon),ztot      , zrhol(klon)
   REAL zchau      ,zfroi      ,zfice(klon),zneb(klon)
+  REAL zmelt, zpluie, zice, zcondold
+  PARAMETER (ztfondue=278.15)
   !
   LOGICAL appel1er
@@ -145,4 +153,5 @@
   DATA appel1er /.TRUE./
   !ym
+  ice_thermo = iflag_ice_thermo .GE. 1
   zdelq=0.0
 
@@ -188,5 +197,13 @@
   !
   ztglace = RTT - 15.0
-  nexpo = 6
+!AJ<
+  IF (ice_thermo) THEN
+    nexpo = 2
+  ELSE
+    nexpo = 6
+  ENDIF
+!!  RLVTT = 2.501e6 ! pas de redefinition des constantes physiques (jyg)
+!!  RLSTT = 2.834e6 ! pas de redefinition des constantes physiques (jyg)
+!>AJ
   !cc      nexpo = 1
   !
@@ -223,4 +240,5 @@
      !     DO i = 1, klon
      zrfl(i) = 0.0
+     zifl(i) = 0.0
      zneb(i) = seuil_neb
   ENDDO
@@ -272,7 +290,14 @@
 
 
+     ! Calculer l'evaporation de la precipitation
+     !
+
+
      IF (evap_prec) THEN
         DO i = 1, klon
-           IF (zrfl(i) .GT.0.) THEN
+!AJ<
+!!           IF (zrfl(i) .GT.0.) THEN
+           IF (zrfl(i)+zifl(i).GT.0.) THEN
+!>AJ
               IF (thermcep) THEN
                  zdelta=MAX(0.,SIGN(1.,RTT-zt(i)))
@@ -288,29 +313,129 @@
                  ENDIF
               ENDIF
-              zqev = MAX (0.0, (zqs(i)-zq(i))*zneb(i) )
-              zqevt = coef_eva * (1.0-zq(i)/zqs(i)) * SQRT(zrfl(i)) &
-                   * (paprs(i,k)-paprs(i,k+1))/pplay(i,k)*zt(i)*RD/RG
-              zqevt = MAX(0.0,MIN(zqevt,zrfl(i))) &
-                   * RG*dtime/(paprs(i,k)-paprs(i,k+1))
-              zqev = MIN (zqev, zqevt)
-              zrfln(i) = zrfl(i) - zqev*(paprs(i,k)-paprs(i,k+1)) &
-                   /RG/dtime
-
-              ! pour la glace, on ré-évapore toute la précip dans la
-              ! couche du dessous
-              ! la glace venant de la couche du dessus est simplement
-              ! dans la couche du dessous.
-
-              IF (zt(i) .LT. t_coup.and.reevap_ice) zrfln(i)=0.
-
-              zq(i) = zq(i) - (zrfln(i)-zrfl(i)) &
-                   * (RG/(paprs(i,k)-paprs(i,k+1)))*dtime
-              zt(i) = zt(i) + (zrfln(i)-zrfl(i)) &
-                   * (RG/(paprs(i,k)-paprs(i,k+1)))*dtime &
-                   * RLVTT/RCPD/(1.0+RVTMP2*zq(i))
-              zrfl(i) = zrfln(i)
-           ENDIF
-        ENDDO
-     ENDIF
+           ENDIF ! (zrfl(i)+zifl(i).GT.0.)
+        ENDDO
+!AJ<
+       IF (.NOT. ice_thermo) THEN
+        DO i = 1, klon
+!AJ<
+!!           IF (zrfl(i) .GT.0.) THEN
+           IF (zrfl(i)+zifl(i).GT.0.) THEN
+!>AJ
+                zqev = MAX (0.0, (zqs(i)-zq(i))*zneb(i) )
+                zqevt = coef_eva * (1.0-zq(i)/zqs(i)) * SQRT(zrfl(i)) &
+                     * (paprs(i,k)-paprs(i,k+1))/pplay(i,k)*zt(i)*RD/RG
+                zqevt = MAX(0.0,MIN(zqevt,zrfl(i))) &
+                     * RG*dtime/(paprs(i,k)-paprs(i,k+1))
+                zqev = MIN (zqev, zqevt)
+                zrfln(i) = zrfl(i) - zqev*(paprs(i,k)-paprs(i,k+1)) &
+                     /RG/dtime
+       
+                ! pour la glace, on ré-évapore toute la précip dans la
+                ! couche du dessous
+                ! la glace venant de la couche du dessus est simplement
+                ! dans la couche du dessous.
+       
+                IF (zt(i) .LT. t_coup.and.reevap_ice) zrfln(i)=0.
+       
+                zq(i) = zq(i) - (zrfln(i)-zrfl(i)) &
+                     * (RG/(paprs(i,k)-paprs(i,k+1)))*dtime
+                zt(i) = zt(i) + (zrfln(i)-zrfl(i)) &
+                     * (RG/(paprs(i,k)-paprs(i,k+1)))*dtime &
+                     * RLVTT/RCPD/(1.0+RVTMP2*zq(i))
+                zrfl(i) = zrfln(i)
+                zifl(i) = 0.
+           ENDIF ! (zrfl(i)+zifl(i).GT.0.)
+        ENDDO
+!
+       ELSE ! (.NOT. ice_thermo) 
+!
+        DO i = 1, klon
+!AJ<
+!!           IF (zrfl(i) .GT.0.) THEN
+           IF (zrfl(i)+zifl(i).GT.0.) THEN
+!>AJ
+     !JAM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+     ! Modification de l'évaporation avec la glace
+     ! Différentiation entre précipitation liquide et solide 
+     ! On suppose que coef_evai=2*coef_eva
+     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  
+     
+         zqev0 = MAX (0.0, (zqs(i)-zq(i))*zneb(i) )
+     !    zqev0 = MAX (0.0, zqs(i)-zq(i) ) 
+
+     !JAM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+     ! On différencie qsat pour l'eau et la glace
+     ! Si zdelta=1. --> glace
+     ! Si zdelta=0. --> eau liquide
+     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+         
+         qsl= R2ES*FOEEW(zt(i),0.)/pplay(i,k)
+         qsl= MIN(0.5,qsl)
+         zcor= 1./(1.-RETV*qsl)
+         qsl= qsl*zcor
+         
+         zqevt = 1.*coef_eva*(1.0-zq(i)/qsl)*SQRT(zrfl(i)) &
+              *(paprs(i,k)-paprs(i,k+1))/pplay(i,k)*zt(i)*RD/RG
+         zqevt = MAX(0.0,MIN(zqevt,zrfl(i))) &
+              *RG*dtime/(paprs(i,k)-paprs(i,k+1)) 
+
+         qsi= R2ES*FOEEW(zt(i),1.)/pplay(i,k)
+         qsi= MIN(0.5,qsi)
+         zcor= 1./(1.-RETV*qsi)
+         qsi= qsi*zcor
+
+         zqevti = 1.*coef_eva*(1.0-zq(i)/qsi)*SQRT(zifl(i)) &
+              *(paprs(i,k)-paprs(i,k+1))/pplay(i,k)*zt(i)*RD/RG
+         zqevti = MAX(0.0,MIN(zqevti,zifl(i))) &
+              *RG*dtime/(paprs(i,k)-paprs(i,k+1))   
+
+              
+     !JAM!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+     ! Vérification sur l'évaporation
+     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+     
+         IF (zqevt+zqevti.GT.zqev0) THEN
+	          zqev=zqev0*zqevt/(zqevt+zqevti)
+	          zqevi=zqev0*zqevti/(zqevt+zqevti)
+             
+         ELSE
+             IF (zqevt+zqevti.GT.0.) THEN
+	          zqev=MIN(zqev0*zqevt/(zqevt+zqevti),zqevt)
+	          zqevi=MIN(zqev0*zqevti/(zqevt+zqevti),zqevti)
+             ELSE
+             zqev=0.
+             zqevi=0.
+             ENDIF
+         ENDIF
+     
+         zrfln(i) = Max(0.,zrfl(i) - zqev*(paprs(i,k)-paprs(i,k+1)) &
+                                 /RG/dtime)
+         zifln(i) = Max(0.,zifl(i) - zqevi*(paprs(i,k)-paprs(i,k+1)) &
+                                 /RG/dtime)
+         
+     ! Pour la glace, on révapore toute la précip dans la couche du dessous
+     ! la glace venant de la couche du dessus est simplement dans la couche
+     ! du dessous.
+     
+     !    IF (zt(i) .LT. t_coup.and.reevap_ice) zrfln(i)=0.
+!         print*,zrfl(i),zrfln(i),zqevt,zqevti,RLMLT,'fluxdeprecip'
+         zq(i) = zq(i) - (zrfln(i)+zifln(i)-zrfl(i)-zifl(i)) &
+                  * (RG/(paprs(i,k)-paprs(i,k+1)))*dtime
+         zt(i) = zt(i) + (zrfln(i)-zrfl(i)) &
+                  * (RG/(paprs(i,k)-paprs(i,k+1)))*dtime &
+                  * RLVTT/RCPD/(1.0+RVTMP2*zq(i)) &
+                  + (zifln(i)-zifl(i)) &
+                  * (RG/(paprs(i,k)-paprs(i,k+1)))*dtime &
+                  * RLSTT/RCPD/(1.0+RVTMP2*zq(i))
+     
+         zrfl(i) = zrfln(i)
+         zifl(i) = zifln(i)
+
+           ENDIF ! (zrfl(i)+zifl(i).GT.0.)
+        ENDDO
+
+      ENDIF ! (.NOT. ice_thermo) 
+     
+     ENDIF ! (evap_prec)
      !
      ! Calculer Qs et L/Cp*dQs/dT:
@@ -478,6 +603,21 @@
         zq(i) = zq(i) - zcond(i)
         !         zt(i) = zt(i) + zcond(i) * RLVTT/RCPD
-        zt(i) = zt(i) + zcond(i) * RLVTT/RCPD/(1.0+RVTMP2*zq(i))
-     ENDDO
+     ENDDO
+!AJ<
+     IF (.NOT. ice_thermo) THEN
+       DO i = 1, klon
+         zt(i) = zt(i) + zcond(i) * RLVTT/RCPD/(1.0+RVTMP2*zq(i))
+       ENDDO
+     ELSE
+       DO i = 1, klon
+         zfice(i) = 1.0 - (zt(i)-ztglace) / (273.15-ztglace)
+         zfice(i) = MIN(MAX(zfice(i),0.0),1.0)
+         zfice(i) = zfice(i)**nexpo
+         zt(i) = zt(i) + (1.-zfice(i))*zcond(i) * RLVTT/RCPD/(1.0+RVTMP2*zq(i)) &
+                       +zfice(i)*zcond(i) * RLSTT/RCPD/(1.0+RVTMP2*zq(i))
+!         print*,zt(i),zrfl(i),zifl(i),'temp1'
+       ENDDO
+     ENDIF
+!>AJ
      !
      ! Partager l'eau condensee en precipitation et eau liquide nuageuse
@@ -488,8 +628,23 @@
            zrho(i) = pplay(i,k) / zt(i) / RD
            zdz(i) = (paprs(i,k)-paprs(i,k+1)) / (zrho(i)*RG)
+        ENDIF
+     ENDDO
+!AJ<
+     IF (.NOT. ice_thermo) THEN
+     DO i = 1, klon
+        IF (rneb(i,k).GT.0.0) THEN
            zfice(i) = 1.0 - (zt(i)-ztglace) / (273.13-ztglace)
            zfice(i) = MIN(MAX(zfice(i),0.0),1.0)
            zfice(i) = zfice(i)**nexpo
+     !!      zfice(i)=0.
+        ENDIF
+     ENDDO
+     ENDIF
+     DO i = 1, klon
+        IF (rneb(i,k).GT.0.0) THEN
            zneb(i) = MAX(rneb(i,k), seuil_neb)
+     !      zt(i) = zt(i)+zcond(i)*zfice(i)*RLMLT/RCPD/(1.0+RVTMP2*zq(i))  
+!           print*,zt(i),'fractionglace'
+!>AJ
            radliq(i,k) = zoliq(i)/REAL(ninter+1)
         ENDIF
@@ -500,5 +655,7 @@
            IF (rneb(i,k).GT.0.0) THEN
               zrhol(i) = zrho(i) * zoliq(i) / zneb(i)
-
+              ! Initialization of zpluie and zice:
+              zpluie=0
+              zice=0
               IF (zneb(i).EQ.seuil_neb) THEN
                  ztot = 0.0
@@ -519,9 +676,23 @@
                  zchau    = zct   *dtime/REAL(ninter) * zoliq(i) &
                       *(1.0-EXP(-(zoliq(i)/zneb(i)/zcl   )**2)) *(1.-zfice(i))
-                 ztot    = zchau    + zfroi
+!AJ<
+                 IF (.NOT. ice_thermo) THEN
+                   ztot    = zchau + zfroi
+                 ELSE
+                   zpluie = MIN(MAX(zchau,0.0),zoliq(i)*(1.-zfice(i)))
+                   zice = MIN(MAX(zfroi,0.0),zoliq(i)*zfice(i)) 
+                   ztot    = zpluie    + zice
+                 ENDIF
+!>AJ
                  ztot    = MAX(ztot   ,0.0)
               ENDIF
               ztot    = MIN(ztot,zoliq(i))
+!AJ<
+     !         zoliqp = MAX(zoliq(i)*(1.-zfice(i))-1.*zpluie   , 0.0)
+     !         zoliqi = MAX(zoliq(i)*zfice(i)-1.*zice   , 0.0)
+              zoliqp(i) = MAX(zoliq(i)*(1.-zfice(i))-1.*zpluie  , 0.0)
+              zoliqi(i) = MAX(zoliq(i)*zfice(i)-1.*zice  , 0.0)
               zoliq(i) = MAX(zoliq(i)-ztot   , 0.0)
+!>AJ
               radliq(i,k) = radliq(i,k) + zoliq(i)/REAL(ninter+1)
            ENDIF
@@ -529,16 +700,67 @@
      ENDDO
      !
-     DO i = 1, klon
-        IF (rneb(i,k).GT.0.0) THEN
+         IF (.NOT. ice_thermo) THEN
+       DO i = 1, klon
+         IF (rneb(i,k).GT.0.0) THEN
            d_ql(i,k) = zoliq(i)
            zrfl(i) = zrfl(i)+ MAX(zcond(i)-zoliq(i),0.0) &
                 * (paprs(i,k)-paprs(i,k+1))/(RG*dtime)
-        ENDIF
-        IF (zt(i).LT.RTT) THEN
+         ENDIF
+       ENDDO
+     ELSE
+       DO i = 1, klon
+         IF (rneb(i,k).GT.0.0) THEN
+           d_ql(i,k) = zoliq(i)
+!AJ<
+           zrfl(i) = zrfl(i)+ MAX(zcond(i)*(1.-zfice(i))-zoliqp(i),0.0) &
+               *(paprs(i,k)-paprs(i,k+1))/(RG*dtime) 
+           zifl(i) = zifl(i)+ MAX(zcond(i)*zfice(i)-zoliqi(i),0.0) &
+                    *(paprs(i,k)-paprs(i,k+1))/(RG*dtime)  
+     !      zrfl(i) = zrfl(i)+  zpluie                         &
+     !          *(paprs(i,k)-paprs(i,k+1))/(RG*dtime) 
+     !      zifl(i) = zifl(i)+  zice                    &
+     !               *(paprs(i,k)-paprs(i,k+1))/(RG*dtime)                                    
+
+         ENDIF                      
+       ENDDO
+     ENDIF
+
+     IF (ice_thermo) THEN
+       DO i = 1, klon
+           zmelt = ((zt(i)-273.15)/(ztfondue-273.15))**2
+           zmelt = MIN(MAX(zmelt,0.),1.)
+           zrfl(i)=zrfl(i)+zmelt*zifl(i)
+           zifl(i)=zifl(i)*(1.-zmelt)
+!           print*,zt(i),'octavio1'
+           zt(i)=zt(i)-zifl(i)*zmelt*(RG*dtime)/(paprs(i,k)-paprs(i,k+1)) &
+                      *RLMLT/RCPD/(1.0+RVTMP2*zq(i))
+!           print*,zt(i),zrfl(i),zifl(i),zmelt,'octavio2'
+       ENDDO
+     ENDIF
+
+       
+     IF (.NOT. ice_thermo) THEN
+       DO i = 1, klon
+         IF (zt(i).LT.RTT) THEN
            psfl(i,k)=zrfl(i)
-        ELSE
+         ELSE
            prfl(i,k)=zrfl(i)
-        ENDIF
-     ENDDO
+         ENDIF
+       ENDDO
+     ELSE
+     ! JAM*************************************************
+     ! Revoir partie ci-dessous: à quoi servent psfl et prfl?
+     ! *****************************************************
+
+       DO i = 1, klon
+     !   IF (zt(i).LT.RTT) THEN
+           psfl(i,k)=zifl(i) 
+     !   ELSE
+           prfl(i,k)=zrfl(i)
+     !   ENDIF
+!>AJ
+       ENDDO
+     ENDIF
+     !
      !
      ! Calculer les tendances de q et de t:
@@ -604,5 +826,8 @@
   DO i = 1, klon
      IF ((t(i,1)+d_t(i,1)) .LT. RTT) THEN
-        snow(i) = zrfl(i)
+!AJ<
+!!        snow(i) = zrfl(i)
+        snow(i) = zrfl(i)+zifl(i)
+!>AJ
         zlh_solid(i) = RLSTT-RLVTT
      ELSE
Index: LMDZ5/branches/testing/libf/phylmd/hbtm.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/hbtm.F	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/hbtm.F	(revision 1864)
@@ -4,5 +4,5 @@
 
       SUBROUTINE HBTM(knon, paprs, pplay,
-     .                t2m,t10m,q2m,q10m,ustar,
+     .                t2m,t10m,q2m,q10m,ustar,wstar,
      .                flux_t,flux_q,u,v,t,q,
      .                pblh,cape,EauLiq,ctei,pblT,
@@ -54,4 +54,5 @@
       REAL q2m(klon), q10m(klon) ! q a 2 et 10m
       REAL ustar(klon)
+      REAL wstar(klon)       ! w*, convective velocity scale
       REAL paprs(klon,klev+1) ! pression a inter-couche (Pa)
       REAL pplay(klon,klev)   ! pression au milieu de couche (Pa)
@@ -158,5 +159,5 @@
       REAL fak1(klon)       ! k*ustar*pblh
       REAL fak2(klon)       ! k*wm*pblh
-      REAL fak3(klon)       ! fakn*wstr/wm
+      REAL fak3(klon)       ! fakn*wstar/wm
       REAL pblk(klon)       ! level eddy diffusivity for momentum
       REAL pr(klon)         ! Prandtl number for eddy diffusivities
@@ -164,5 +165,4 @@
       REAL zh(klon)         ! zmzp / pblh
       REAL zzh(klon)        ! (1-(zmzp/pblh))**2
-      REAL wstr(klon)       ! w*, convective velocity scale
       REAL zm(klon)         ! current level height
       REAL zp(klon)         ! current level height + one level up
@@ -625,6 +625,8 @@
           wm(i)      = ustar(i)*phiminv(i)
           fak2(i)    = wm(i)*pblh(i)*vk
-          wstr(i)    = (heatv(i)*RG*pblh(i)/zxt)**onet
-          fak3(i)    = fakn*wstr(i)/wm(i)
+          wstar(i)    = (heatv(i)*RG*pblh(i)/zxt)**onet
+          fak3(i)    = fakn*wstar(i)/wm(i)
+        ELSE
+          wstar(i)=0.
         ENDIF
 c Computes Theta_e for thermal (all cases : to be modified)
Index: LMDZ5/branches/testing/libf/phylmd/ini_histdayNMC.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/ini_histdayNMC.h	(revision 1796)
+++ 	(revision )
@@ -1,140 +1,0 @@
-!
-! $Header$
-!
-c$OMP MASTER
-      IF (ok_histNMC(2)) THEN
-c
-       zstophy = dtime
-       zstohf = ecrit_hf
-       zstomth = ecrit_mth
-       zout = freq_outNMC(2)
-c
-         idayref = day_ref
-         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
-c
-cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-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
-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_daynmc)
-
-         CALL histbeg_phy("histdayNMC",itau_phy, zjulian, dtime, 
-     .                 nhori, nid_daynmc)
-c
-        IF(lev_histdayNMC.EQ.nlevSTD) THEN 
-         CALL histvert(nid_daynmc, "plev", "pressure", "Pa",
-     .                 nlevSTD, rlevSTD, nvert,"down")
-        ELSE IF(lev_histdayNMC.EQ.nlevSTD8) THEN 
-         CALL histvert(nid_daynmc, "plev", "pressure", "Pa",
-     .                 nlevSTD8, rlevSTD8, nvert,"down")
-        ENDIF
-c
-cIM Astuce MAF: remplacer inst par ave pour les variables NMC pour avoir
-cIM             le time_counter et les bounds
-c
-ccc Champs 3D interpolles sur des niveaux de pression du NMC
-ccc
-c
-c ATTENTION : pour AMIP2 on interpole t,u,v,wphi,q,rh
-c             sur les niveaux du NMC et on somme & moyenne
-c             toutes les freq_moyNMC secondes par des routines undefSTD et
-c             moy_undefSTD pour eliminer les valeurs "undef"
-c             de la moyenne mensuelle
-c ======> le "inst(X)" ci-dessous est par consequence factice !
-c
-        IF(lev_histdayNMC.EQ.nlevSTD) THEN 
-          CALL histdef(nid_daynmc, "tnondef",
-     .                 "Valeurs non-definies","-",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "ta",
-     .                 "Air temperature","K",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-         CALL histdef(nid_daynmc, "zg",
-     .                "Geopotential height", "m",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "hus",
-     .                 "Specific humidity","1",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-         CALL histdef(nid_daynmc, "hur",
-     .                 "Relative humidity", "%",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "ua",
-     .                 "Eastward wind","m s-1",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "va",
-     .                 "Northward wind","m s-1",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "wap",
-     .                 "Lagrangian tendency of air pressure","Pa s-1",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-        ELSE IF(lev_histdayNMC.EQ.nlevSTD8) THEN 
-c
-          CALL histdef(nid_daynmc, "tnondef",
-     .                 "Valeurs non-definies","-",
-     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "ta",
-     .                 "Air temperature","K",
-     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-         CALL histdef(nid_daynmc, "zg",
-     .                "Geopotential height", "m",
-     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "hus",
-     .                 "Specific humidity","1",
-     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-         CALL histdef(nid_daynmc, "hur",
-     .                 "Relative humidity", "%",
-     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "ua",
-     .                 "Eastward wind","m s-1",
-     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "va",
-     .                 "Northward wind","m s-1",
-     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_daynmc, "wap",
-     .                 "Lagrangian tendency of air pressure","Pa s-1",
-     .                iim,jj_nb,nhori, nlevSTD8,1,nlevSTD8, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-        ENDIF
-c
-         CALL histend(nid_daynmc)
-c
-      ENDIF !(ok_histNMC(2)) THEN
-c$OMP END MASTER
Index: LMDZ5/branches/testing/libf/phylmd/ini_histhfNMC.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/ini_histhfNMC.h	(revision 1796)
+++ 	(revision )
@@ -1,152 +1,0 @@
-!
-! $Header$
-!
-c$OMP MASTER
-c
-      IF (ok_histNMC(3)) THEN
-c
-       zstophy = dtime
-       zstohf = ecrit_hf
-       zstomth = ecrit_mth
-c      zout = 6 * 3600.
-       zout = freq_outNMC(3)
-c
-         idayref = day_ref
-         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
-c
-cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-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
-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_hfnmc)
-
-         CALL histbeg_phy("histhfNMC",itau_phy, zjulian, dtime, 
-     .                 nhori, nid_hfnmc)
-c
-         CALL histvert(nid_hfnmc, "plev", "pressure", "Pa",
-     .                 nlevSTD3, rlevSTD3, nvert,"down")
-c
-cIM Astuce MAF: remplacer inst par ave pour les variables NMC pour avoir
-cIM             le time_counter et les bounds
-c
-ccc
-ccc Champs 3D interpolles sur des niveaux de pression du NMC
-ccc
-c
-c ATTENTION : pour AMIP2 on interpole t,u,v,wphi,q,rh
-c             sur les niveaux du NMC et on somme & moyenne
-c             toutes les freq_moyNMC secondes par des routines undefSTD et
-c             moy_undefSTD pour eliminer les valeurs "undef"
-c             de la moyenne mensuelle
-c ======> le "inst(X)" ci-dessous est par consequence factice !
-c
-          CALL histdef(nid_hfnmc, "tnondef",
-     .                 "Valeurs non-definies","-",
-     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "ta",
-     .                 "Air temperature","K",
-     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-         CALL histdef(nid_hfnmc, "zg",
-     .                "Geopotential height", "m",
-     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "hus",
-     .                 "Specific humidity","1",
-     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-         CALL histdef(nid_hfnmc, "hur",
-     .                 "Relative humidity", "%",
-     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "ua",
-     .                 "Eastward wind","m s-1",
-     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "va",
-     .                 "Northward wind","m s-1",
-     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "wap",
-     .                 "Lagrangian tendency of air pressure","Pa s-1",
-     .                iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "psbg",
-     .         "Pressure sfce below ground","%",
-     .         iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "uv",
-     .         "uv ",
-     .         "m2/s2",iim,jj_nb,nhori, nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "vq",
-     .         "vq ",
-     .         "m/s * (kg/kg)",iim,jj_nb,nhori, 
-     .          nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "vT",
-     .         "vT ", 
-     .         "mK/s",iim,jj_nb,nhori, 
-     .          nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "wq",
-     .         "wq ", 
-     .         "(Pa/s)*(kg/kg)",iim,jj_nb,nhori,
-     .          nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "vphi",
-     .         "vphi ", 
-     .         "m2/s",iim,jj_nb,nhori, 
-     .          nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "wT",
-     .         "wT ", 
-     .         "K*Pa/s",iim,jj_nb,nhori,
-     .          nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "uxu",
-     .         "u2 ", 
-     .         "m2/s2",iim,jj_nb,nhori,
-     .          nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "vxv",
-     .         "v2 ", 
-     .         "m2/s2",iim,jj_nb,nhori,
-     .          nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_hfnmc, "TxT",
-     .         "T2 ", 
-     .         "K2",iim,jj_nb,nhori,
-     .          nlevSTD3,1,nlevSTD3, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-         CALL histend(nid_hfnmc)
-c
-      ENDIF !(ok_histNMC(2)) THEN
-c
-c$OMP END MASTER
Index: LMDZ5/branches/testing/libf/phylmd/ini_histmthNMC.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/ini_histmthNMC.h	(revision 1796)
+++ 	(revision )
@@ -1,162 +1,0 @@
-!
-! $Id$
-!
-c$OMP MASTER
-c
-      IF (ok_histNMC(1)) THEN
-c
-       zout = freq_outNMC(1)
-c
-       idayref = day_ref
-       CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
-c
-cym         CALL gr_fi_ecrit(1,klon,iim,jjmp1,rlon,zx_lon)
-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)=REAL(ll)
-         ENDDO
-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_mthnmc)
-
-         CALL histbeg_phy("histmthNMC",itau_phy, zjulian, dtime, 
-     .                 nhori, nid_mthnmc)
-c
-         CALL histvert(nid_mthnmc, "plev", "pressure", "Pa",
-     .                 nlevSTD, rlevSTD, nvert,"down")
-c
-cIM Astuce MAF: remplacer inst par ave pour les variables NMC pour avoir
-cIM             le time_counter et les bounds
-cIM 
-ccc Champs 3D interpolles sur des niveaux de pression du NMC
-ccc
-c
-c ATTENTION : pour AMIP2 on interpole t,u,v,wphi,q,rh
-c             sur les niveaux du NMC et on somme & moyenne
-c             toutes les freq_moyNMC secondes par des routines undefSTD et
-c             moy_undefSTD pour eliminer les valeurs "undef"
-c             de la moyenne mensuelle
-c ======> le "inst(X)" ci-dessous est par consequence factice !
-c
-c
-          CALL histdef(nid_mthnmc, "tnondef",
-     .                 "Valeurs non-definies","-",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "ta",
-     .                 "Air temperature","K",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-         CALL histdef(nid_mthnmc, "zg",
-     .                "Geopotential height", "m",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "hus",
-     .                 "Specific humidity","1",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-         CALL histdef(nid_mthnmc, "hur",
-     .                 "Relative humidity", "%",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "ua",
-     .                 "Eastward wind","m s-1",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "va",
-     .                 "Northward wind","m s-1",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "wap",
-     .                 "Lagrangian tendency of air pressure","Pa s-1",
-     .                iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .                "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "psbg",
-     .         "Pressure sfce below ground","%",
-     .         iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "uv",
-     .         "uv ",
-     .         "m2/s2",iim,jj_nb,nhori, nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "vq",
-     .         "vq ",
-     .         "m/s * (kg/kg)",iim,jj_nb,nhori, 
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "vT",
-     .         "vT ", 
-     .         "mK/s",iim,jj_nb,nhori, 
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "wq",
-     .         "wq ", 
-     .         "(Pa/s)*(kg/kg)",iim,jj_nb,nhori,
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "vphi",
-     .         "vphi ", 
-     .         "m2/s",iim,jj_nb,nhori, 
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "wT",
-     .         "wT ", 
-     .         "K*Pa/s",iim,jj_nb,nhori,
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "uxu",
-     .         "u2 ", 
-     .         "m2/s2",iim,jj_nb,nhori,
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "vxv",
-     .         "v2 ", 
-     .         "m2/s2",iim,jj_nb,nhori,
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "TxT",
-     .         "T2 ", 
-     .         "K2",iim,jj_nb,nhori,
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          CALL histdef(nid_mthnmc, "tro3",
-     .         "Ozone mole fraction",
-     .         "1e-9",iim,jj_nb,nhori,
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-c
-          if (read_climoz == 2) THEN
-           CALL histdef(nid_mthnmc, "tro3_daylight",
-     .         "Daylight ozone mole fraction",
-     .         "1e-9",iim,jj_nb,nhori,
-     .          nlevSTD,1,nlevSTD, nvert, 32,
-     .         "ave(X)", zout,zout)
-          endif
-c
-         CALL histend(nid_mthnmc)
-c
-      ENDIF !(ok_histNMC(1)) THEN
-c
-c$OMP END MASTER
Index: LMDZ5/branches/testing/libf/phylmd/ini_histrac.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/ini_histrac.h	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/ini_histrac.h	(revision 1864)
@@ -147,5 +147,5 @@
 
 ! TD COUCHE-LIMITE
-      IF (couchelimite) THEN
+      IF (iflag_vdf_trac>=0) THEN
         CALL histdef(nid_tra, "d_tr_cl_"//tname(iiq),      &
              "tendance couche limite"// ttext(iiq), "?",   &
Index: LMDZ5/branches/testing/libf/phylmd/iniphysiq.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/iniphysiq.F	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/iniphysiq.F	(revision 1864)
@@ -14,5 +14,5 @@
      &                               klon_omp_end,klon_mpi_begin
       USE comgeomphy, only : airephy,cuphy,cvphy,rlond,rlatd
-
+      USE phyaqua_mod, only: iniaqua
       IMPLICIT NONE
 c
Index: LMDZ5/branches/testing/libf/phylmd/iophy.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/iophy.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/iophy.F90	(revision 1864)
@@ -2,8 +2,17 @@
 ! $Header$
 !
-module iophy
-  
-! abd  REAL,private,allocatable,dimension(:),save :: io_lat
-! abd  REAL,private,allocatable,dimension(:),save :: io_lon
+MODULE iophy
+
+  USE phys_output_var_mod
+#ifdef CPP_XIOS
+  USE wxios
+#endif
+
+#ifdef CPP_XIOS
+  USE wxios
+#endif
+
+! abd  REAL,private,allocatable,DIMENSION(:),save :: io_lat
+! abd  REAL,private,allocatable,DIMENSION(:),save :: io_lon
   REAL,ALLOCATABLE,DIMENSION(:),SAVE :: io_lat
   REAL,ALLOCATABLE,DIMENSION(:),SAVE :: io_lon
@@ -14,28 +23,42 @@
 
 !$OMP THREADPRIVATE(itau_iophy)
-  
+
+#ifdef CPP_XIOS
+  INTERFACE histwrite_phy
+    MODULE PROCEDURE histwrite2d_phy,histwrite3d_phy,histwrite2d_phy_old,histwrite3d_phy_old,histwrite2d_xios,histwrite3d_xios
+  END INTERFACE
+#else
   INTERFACE histwrite_phy
     MODULE PROCEDURE histwrite2d_phy,histwrite3d_phy,histwrite2d_phy_old,histwrite3d_phy_old
   END INTERFACE
+#endif
 
   INTERFACE histbeg_phy_all
-    MODULE PROCEDURE histbeg_phy,histbeg_phy_points
+    MODULE PROCEDURE histbeg_phy,histbeg_phyxios,histbeg_phy_points
   END INTERFACE
 
 
-contains
-
-  subroutine init_iophy_new(rlat,rlon)
+CONTAINS
+
+! ug Routine pour définir itau_iophy depuis phys_output_write_mod:
+  SUBROUTINE set_itau_iophy(ito)
+      IMPLICIT NONE
+      INTEGER, INTENT(IN) :: ito
+      itau_iophy = ito
+  END SUBROUTINE
+
+  SUBROUTINE init_iophy_new(rlat,rlon)
   USE dimphy
   USE mod_phys_lmdz_para
   USE mod_grid_phy_lmdz
   USE ioipsl
-  implicit none
-  include 'dimensions.h'   
-    real,dimension(klon),intent(in) :: rlon
-    real,dimension(klon),intent(in) :: rlat
-
-    REAL,dimension(klon_glo)        :: rlat_glo
-    REAL,dimension(klon_glo)        :: rlon_glo
+
+  IMPLICIT NONE
+  INCLUDE 'dimensions.h'   
+    REAL,DIMENSION(klon),INTENT(IN) :: rlon
+    REAL,DIMENSION(klon),INTENT(IN) :: rlat
+
+    REAL,DIMENSION(klon_glo)        :: rlat_glo
+    REAL,DIMENSION(klon_glo)        :: rlon_glo
     
     INTEGER,DIMENSION(2) :: ddid
@@ -47,4 +70,5 @@
     INTEGER,DIMENSION(2) :: dhe 
     INTEGER :: i    
+    INTEGER :: data_ibegin, data_iend
 
     CALL gather(rlat,rlat_glo)
@@ -65,4 +89,18 @@
     ALLOCATE(io_lon(iim))
     io_lon(:)=rlon_glo(2-1/(iim*jjm):iim+1-1/(iim*jjm))
+!! (I) dtnb   : total number of domains
+!! (I) dnb    : domain number
+!! (I) did(:) : distributed dimensions identifiers
+!!              (up to 5 dimensions are supported)
+!! (I) dsg(:) : total number of points for each dimension
+!! (I) dsl(:) : local number of points for each dimension
+!! (I) dpf(:) : position of first local point for each dimension
+!! (I) dpl(:) : position of last local point for each dimension
+!! (I) dhs(:) : start halo size for each dimension
+!! (I) dhe(:) : end halo size for each dimension
+!! (C) cdnm   : Model domain definition name.
+!!              The names actually supported are :
+!!              "BOX", "APPLE", "ORANGE".
+!!              These names are case insensitive.
 
     ddid=(/ 1,2 /)
@@ -72,25 +110,52 @@
     dpl=(/ iim, jj_end /)
     dhs=(/ ii_begin-1,0 /)
-    if (mpi_rank==mpi_size-1) then
+    IF (mpi_rank==mpi_size-1) THEN
       dhe=(/0,0/)
-    else
+    ELSE
       dhe=(/ iim-ii_end,0 /)  
-    endif
-    
-    call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
+    ENDIF
+
+#ifndef CPP_NO_IOIPSL    
+    CALL flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
                       'APPLE',phys_domain_id)
-
+#endif
+#ifdef CPP_XIOS
+    !Pour els soucis en MPI, réglage du masque:
+    IF (mpi_rank == 0) THEN
+        data_ibegin = 0
+    ELSE 
+        data_ibegin = ii_begin - 1
+    END IF
+
+    IF (mpi_rank == mpi_size-1) THEN
+        data_iend = nbp_lon
+    ELSE
+        data_iend = ii_end + 1
+    END IF
+
+    WRITE(*,*) "TOTO mpirank=",mpi_rank,"iibeg=",ii_begin , "jjbeg=",jj_begin,"jjnb=",jj_nb,"jjend=",jj_end
+
+    !On initialise le domaine xios, maintenant que tout est connu:
+    !SUBROUTINE wxios_domain_param(dom_id, is_sequential, ni, nj, ni_glo, nj_glo,        &
+    !                                ibegin, iend, jbegin, jend,                         &
+    !                                data_ni, data_ibegin,                               &
+    !                                io_lat, io_lon)
+    CALL wxios_domain_param("dom_glo", is_sequential, nbp_lon, jj_nb, nbp_lon, nbp_lat, &
+                            1, nbp_lon, ii_begin, ii_end, jj_begin, jj_end,             &
+                            klon_mpi+2*(nbp_lon-1), data_ibegin, data_iend,             &
+                            io_lat, io_lon)
+#endif
 !$OMP END MASTER
       
-  end subroutine init_iophy_new
-
-  subroutine init_iophy(lat,lon)
+  END SUBROUTINE init_iophy_new
+
+  SUBROUTINE init_iophy(lat,lon)
   USE dimphy
   USE mod_phys_lmdz_para
-  use ioipsl
-  implicit none
-  include 'dimensions.h'   
-    real,dimension(iim),intent(in) :: lon
-    real,dimension(jjm+1-1/(iim*jjm)),intent(in) :: lat
+  USE ioipsl
+  IMPLICIT NONE
+  INCLUDE 'dimensions.h'   
+    REAL,DIMENSION(iim),INTENT(IN) :: lon
+    REAL,DIMENSION(jjm+1-1/(iim*jjm)),INTENT(IN) :: lat
 
     INTEGER,DIMENSION(2) :: ddid
@@ -120,23 +185,26 @@
     endif
     
+#ifndef CPP_NO_IOIPSL 
     call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
                       'APPLE',phys_domain_id)
-
+#endif
 !$OMP END MASTER
       
-  end subroutine init_iophy
-  
-  subroutine histbeg_phy(name,itau0,zjulian,dtime,nhori,nid_day)
+  end SUBROUTINE init_iophy
+
+ SUBROUTINE histbeg_phyxios(name,itau0,zjulian,dtime,ffreq,lev,nhori,nid_day)
   USE dimphy
   USE mod_phys_lmdz_para
   use ioipsl
   use write_field
-  implicit none
+  IMPLICIT NONE
   include 'dimensions.h'
     
-    character*(*), intent(IN) :: name
-    integer, intent(in) :: itau0
-    real,intent(in) :: zjulian
-    real,intent(in) :: dtime
+    character*(*), INTENT(IN) :: name
+    integer, INTENT(IN) :: itau0
+    REAL,INTENT(IN) :: zjulian
+    REAL,INTENT(IN) :: dtime
+    character(LEN=*), INTENT(IN) :: ffreq
+    INTEGER,INTENT(IN) :: lev
     integer,intent(out) :: nhori
     integer,intent(out) :: nid_day
@@ -150,9 +218,47 @@
                    1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
     endif
+
+#ifdef CPP_XIOS
+    ! ug OMP en chantier...
+    IF((.NOT. is_using_mpi) .OR. is_mpi_root) THEN
+        ! ug Création du fichier
+        CALL wxios_add_file(name, ffreq, lev)
+    END IF
+#endif
 !$OMP END MASTER
   
-  end subroutine histbeg_phy
-
-  subroutine histbeg_phy_points(rlon,rlat,pim,tabij,ipt,jpt, &
+  END SUBROUTINE histbeg_phyxios
+  
+  SUBROUTINE histbeg_phy(name,itau0,zjulian,dtime,nhori,nid_day)
+  USE dimphy
+  USE mod_phys_lmdz_para
+  use ioipsl
+  use write_field
+  IMPLICIT NONE
+  include 'dimensions.h'
+    
+    character*(*), INTENT(IN) :: name
+    integer, INTENT(IN) :: itau0
+    REAL,INTENT(IN) :: zjulian
+    REAL,INTENT(IN) :: dtime
+    integer,intent(out) :: nhori
+    integer,intent(out) :: nid_day
+
+!$OMP MASTER    
+#ifndef CPP_NO_IOIPSL 
+    if (is_sequential) then
+      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
+                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day)
+    else
+      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
+                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
+    endif
+#endif
+!$OMP END MASTER
+  
+  END SUBROUTINE histbeg_phy
+
+
+  SUBROUTINE histbeg_phy_points(rlon,rlat,pim,tabij,ipt,jpt, &
              plon,plat,plon_bounds,plat_bounds, &
              nname,itau0,zjulian,dtime,nnhori,nnid_day)
@@ -162,23 +268,23 @@
   use ioipsl
   use write_field
-  implicit none
+  IMPLICIT NONE
   include 'dimensions.h' 
 
-    real,dimension(klon),intent(in) :: rlon
-    real,dimension(klon),intent(in) :: rlat
-    integer, intent(in) :: itau0
-    real,intent(in) :: zjulian
-    real,intent(in) :: dtime
-    integer, intent(in) :: pim
+    REAL,DIMENSION(klon),INTENT(IN) :: rlon
+    REAL,DIMENSION(klon),INTENT(IN) :: rlat
+    integer, INTENT(IN) :: itau0
+    REAL,INTENT(IN) :: zjulian
+    REAL,INTENT(IN) :: dtime
+    integer, INTENT(IN) :: pim
     integer, intent(out) :: nnhori
-    character(len=20), intent(in) :: nname
+    character(len=20), INTENT(IN) :: nname
     INTEGER, intent(out) :: nnid_day
     integer :: i
-    REAL,dimension(klon_glo)        :: rlat_glo
-    REAL,dimension(klon_glo)        :: rlon_glo
-    INTEGER, DIMENSION(pim), intent(in)  :: tabij
-    REAL,dimension(pim), intent(in) :: plat, plon
-    INTEGER,dimension(pim), intent(in) :: ipt, jpt
-    REAL,dimension(pim,2), intent(out) :: plat_bounds, plon_bounds
+    REAL,DIMENSION(klon_glo)        :: rlat_glo
+    REAL,DIMENSION(klon_glo)        :: rlon_glo
+    INTEGER, DIMENSION(pim), INTENT(IN)  :: tabij
+    REAL,DIMENSION(pim), INTENT(IN) :: plat, plon
+    INTEGER,DIMENSION(pim), INTENT(IN) :: ipt, jpt
+    REAL,DIMENSION(pim,2), intent(out) :: plat_bounds, plon_bounds
 
     INTEGER, SAVE :: tabprocbeg, tabprocend
@@ -187,8 +293,8 @@
     INTEGER, PARAMETER :: nip=1
     INTEGER :: npproc
-    REAL, allocatable, dimension(:) :: npplat, npplon
-    REAL, allocatable, dimension(:,:) :: npplat_bounds, npplon_bounds
+    REAL, allocatable, DIMENSION(:) :: npplat, npplon
+    REAL, allocatable, DIMENSION(:,:) :: npplat_bounds, npplon_bounds
     INTEGER, PARAMETER :: jjmp1=jjm+1-1/jjm
-    REAL, dimension(iim,jjmp1) :: zx_lon, zx_lat
+    REAL, DIMENSION(iim,jjmp1) :: zx_lon, zx_lat
 
     CALL gather(rlat,rlat_glo)
@@ -278,7 +384,9 @@
     ENDDO
 !    print*,'iophy is_sequential nname, nnhori, nnid_day=',trim(nname),nnhori,nnid_day
+#ifndef CPP_NO_IOIPSL 
      call histbeg(nname,pim,plon,plon_bounds, & 
                            plat,plat_bounds, &
                            itau0, zjulian, dtime, nnhori, nnid_day)
+#endif
     else
      npproc=0
@@ -317,16 +425,286 @@
       ENDIF
      ENDDO
+#ifndef CPP_NO_IOIPSL 
      call histbeg(nname,npstn,npplon,npplon_bounds, &
                             npplat,npplat_bounds, &
                             itau0,zjulian,dtime,nnhori,nnid_day,phys_domain_id)
+#endif
     endif
 !$OMP END MASTER
 
-  end subroutine histbeg_phy_points
+  end SUBROUTINE histbeg_phy_points
+
+
+  SUBROUTINE histdef2d_old (iff,lpoint,flag_var,nomvar,titrevar,unitvar)
+
+    USE ioipsl
+    USE dimphy
+    USE mod_phys_lmdz_para
+
+    IMPLICIT NONE
+
+    INCLUDE "dimensions.h"
+    INCLUDE "temps.h"
+    INCLUDE "clesphys.h"
+
+    INTEGER                          :: iff
+    LOGICAL                          :: lpoint
+    INTEGER, DIMENSION(nfiles)       :: flag_var
+    CHARACTER(LEN=20)                 :: nomvar
+    CHARACTER(LEN=*)                 :: titrevar
+    CHARACTER(LEN=*)                 :: unitvar
+
+    REAL zstophym
+
+    IF (type_ecri(iff)=='inst(X)'.OR.type_ecri(iff)=='once') THEN
+       zstophym=zoutm(iff)
+    ELSE
+       zstophym=zdtime_moy
+    ENDIF
+
+    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
+    CALL conf_physoutputs(nomvar,flag_var)
+
+    IF(.NOT.lpoint) THEN  
+       IF ( flag_var(iff)<=lev_files(iff) ) THEN
+          CALL histdef (nid_files(iff),nomvar,titrevar,unitvar, &
+               iim,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
+               type_ecri(iff), zstophym,zoutm(iff))                
+       ENDIF
+    ELSE
+       IF ( flag_var(iff)<=lev_files(iff) ) THEN
+          CALL histdef (nid_files(iff),nomvar,titrevar,unitvar, &
+               npstn,1,nhorim(iff), 1,1,1, -99, 32, &
+               type_ecri(iff), zstophym,zoutm(iff))                
+       ENDIF
+    ENDIF
+
+    ! Set swaero_diag=true if at least one of the concerned variables are defined 
+    IF (nomvar=='topswad' .OR. nomvar=='topswai' .OR. nomvar=='solswad' .OR. nomvar=='solswai' ) THEN
+       IF  ( flag_var(iff)<=lev_files(iff) ) THEN
+          swaero_diag=.TRUE.
+       END IF
+    END IF
+  END SUBROUTINE histdef2d_old
+
+
+
+  SUBROUTINE histdef3d_old (iff,lpoint,flag_var,nomvar,titrevar,unitvar)
+
+    USE ioipsl
+    USE dimphy
+    USE mod_phys_lmdz_para
+
+    IMPLICIT NONE
+
+    INCLUDE "dimensions.h"
+    INCLUDE "temps.h"
+!    INCLUDE "indicesol.h"
+    INCLUDE "clesphys.h"
+
+    INTEGER                          :: iff
+    LOGICAL                          :: lpoint
+    INTEGER, DIMENSION(nfiles)       :: flag_var
+    CHARACTER(LEN=20)                 :: nomvar
+    CHARACTER(LEN=*)                 :: titrevar
+    CHARACTER(LEN=*)                 :: unitvar
+
+    REAL zstophym
+
+    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
+    CALL conf_physoutputs(nomvar,flag_var)
+
+    IF (type_ecri(iff)=='inst(X)'.OR.type_ecri(iff)=='once') THEN
+       zstophym=zoutm(iff)
+    ELSE
+       zstophym=zdtime_moy
+    ENDIF
+
+    IF(.NOT.lpoint) THEN
+       IF ( flag_var(iff)<=lev_files(iff) ) THEN
+          CALL histdef (nid_files(iff), nomvar, titrevar, unitvar, &
+               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
+               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, type_ecri(iff), &
+               zstophym, zoutm(iff))
+       ENDIF
+    ELSE
+       IF ( flag_var(iff)<=lev_files(iff) ) THEN
+          CALL histdef (nid_files(iff), nomvar, titrevar, unitvar, &
+               npstn,1,nhorim(iff), klev, levmin(iff), &
+               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, &
+               type_ecri(iff), zstophym,zoutm(iff))
+       ENDIF
+    ENDIF
+  END SUBROUTINE histdef3d_old
+
+
+
+
+
+
+
+
+  SUBROUTINE histdef2d (iff,var)
+
+    USE ioipsl
+    USE dimphy
+    USE mod_phys_lmdz_para
+
+    IMPLICIT NONE
+
+    INCLUDE "dimensions.h"
+    INCLUDE "temps.h"
+    INCLUDE "clesphys.h"
+
+    INTEGER                          :: iff
+    TYPE(ctrl_out)                   :: var
+
+    REAL zstophym
+    CHARACTER(LEN=20) :: typeecrit
+
+
+    ! ug On récupère le type écrit de la structure:
+    !       Assez moche, à refaire si meilleure méthode...
+    IF (INDEX(var%type_ecrit(iff), "once") > 0) THEN
+       typeecrit = 'once'
+    ELSE IF(INDEX(var%type_ecrit(iff), "t_min") > 0) THEN
+       typeecrit = 't_min(X)'
+    ELSE IF(INDEX(var%type_ecrit(iff), "t_max") > 0) THEN
+       typeecrit = 't_max(X)'
+    ELSE IF(INDEX(var%type_ecrit(iff), "inst") > 0) THEN
+       typeecrit = 'inst(X)'
+    ELSE
+       typeecrit = type_ecri_files(iff)
+    ENDIF
+
+    IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN
+       zstophym=zoutm(iff)
+    ELSE
+       zstophym=zdtime_moy
+    ENDIF
+
+    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
+    CALL conf_physoutputs(var%name, var%flag)
+
+    IF(.NOT.clef_stations(iff)) THEN  
+
+#ifdef CPP_XIOS
+        CALL wxios_add_field_to_file(var%name, 2, iff, phys_out_filenames(iff), &
+        var%description, var%unit, var%flag(iff), typeecrit)
+#endif
+#ifndef CPP_NO_IOIPSL 
+
+       IF ( var%flag(iff)<=lev_files(iff) ) THEN
+          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
+               iim,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
+               typeecrit, zstophym,zoutm(iff))                
+       ENDIF
+    ELSE
+       IF ( var%flag(iff)<=lev_files(iff)) THEN
+          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
+               npstn,1,nhorim(iff), 1,1,1, -99, 32, &
+               typeecrit, zstophym,zoutm(iff))                
+       ENDIF
+#endif
+    ENDIF
+
+    ! Set swaero_diag=true if at least one of the concerned variables are defined 
+    IF (var%name=='topswad' .OR. var%name=='topswai' .OR. var%name=='solswad' .OR. var%name=='solswai' ) THEN
+       IF  ( var%flag(iff)<=lev_files(iff) ) THEN
+          swaero_diag=.TRUE.
+       END IF
+    END IF
+  END SUBROUTINE histdef2d
+  SUBROUTINE histdef3d (iff,var)
+
+    USE ioipsl
+    USE dimphy
+    USE mod_phys_lmdz_para
+
+    IMPLICIT NONE
+
+    INCLUDE "dimensions.h"
+    INCLUDE "temps.h"
+    INCLUDE "clesphys.h"
+
+    INTEGER                          :: iff
+    TYPE(ctrl_out)                   :: var
+
+    REAL zstophym
+    CHARACTER(LEN=20) :: typeecrit
+
+    ! ug On récupère le type écrit de la structure:
+    !       Assez moche, à refaire si meilleure méthode...
+    IF (INDEX(var%type_ecrit(iff), "once") > 0) THEN
+       typeecrit = 'once'
+    ELSE IF(INDEX(var%type_ecrit(iff), "t_min") > 0) THEN
+       typeecrit = 't_min(X)'
+    ELSE IF(INDEX(var%type_ecrit(iff), "t_max") > 0) THEN
+       typeecrit = 't_max(X)'
+    ELSE IF(INDEX(var%type_ecrit(iff), "inst") > 0) THEN
+       typeecrit = 'inst(X)'
+    ELSE
+       typeecrit = type_ecri_files(iff)
+    ENDIF
+
+
+    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
+    CALL conf_physoutputs(var%name,var%flag)
+
+    IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN
+       zstophym=zoutm(iff)
+    ELSE
+       zstophym=zdtime_moy
+    ENDIF
+
+    IF(.NOT.clef_stations(iff)) THEN
+
+#ifdef CPP_XIOS
+        CALL wxios_add_field_to_file(var%name, 3, iff, phys_out_filenames(iff), &
+        var%description, var%unit, var%flag(iff), typeecrit)
+#endif
+#ifndef CPP_NO_IOIPSL 
+
+       IF ( var%flag(iff)<=lev_files(iff) ) THEN
+          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
+               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
+               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, typeecrit, &
+               zstophym, zoutm(iff))
+       ENDIF
+    ELSE
+       IF ( var%flag(iff)<=lev_files(iff)) THEN
+          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
+               npstn,1,nhorim(iff), klev, levmin(iff), &
+               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, &
+               typeecrit, zstophym,zoutm(iff))
+       ENDIF
+#endif
+    ENDIF
+  END SUBROUTINE histdef3d
+
+  SUBROUTINE conf_physoutputs(nam_var,flag_var)
+!!! Lecture des noms et niveau de sortie des variables dans output.def
+    !   en utilisant les routines getin de IOIPSL  
+    use ioipsl
+
+    IMPLICIT NONE
+
+    include 'iniprint.h'
+
+    CHARACTER(LEN=20)                :: nam_var
+    INTEGER, DIMENSION(nfiles)      :: flag_var
+
+    IF(prt_level>10) WRITE(lunout,*)'Avant getin: nam_var flag_var ',nam_var,flag_var(:)
+    CALL getin('flag_'//nam_var,flag_var)
+    CALL getin('name_'//nam_var,nam_var)
+    IF(prt_level>10) WRITE(lunout,*)'Apres getin: nam_var flag_var ',nam_var,flag_var(:)
+
+  END SUBROUTINE conf_physoutputs
+
+
  
   SUBROUTINE histwrite2d_phy_old(nid,lpoint,name,itau,field)
   USE dimphy
   USE mod_phys_lmdz_para
-  USE phys_output_var_mod
   USE ioipsl
   IMPLICIT NONE
@@ -334,18 +712,18 @@
   include 'iniprint.h'
     
-    integer,intent(in) :: nid
-    logical,intent(in) :: lpoint 
-    character*(*), intent(IN) :: name
-    integer, intent(in) :: itau
-    real,dimension(:),intent(in) :: field
-    REAL,dimension(klon_mpi) :: buffer_omp
-    INTEGER, allocatable, dimension(:) :: index2d
+    integer,INTENT(IN) :: nid
+    logical,INTENT(IN) :: lpoint 
+    character*(*), INTENT(IN) :: name
+    integer, INTENT(IN) :: itau
+    REAL,DIMENSION(:),INTENT(IN) :: field
+    REAL,DIMENSION(klon_mpi) :: buffer_omp
+    INTEGER, allocatable, DIMENSION(:) :: index2d
     REAL :: Field2d(iim,jj_nb)
 
     integer :: ip
-    real,allocatable,dimension(:) :: fieldok
-
-
-    IF (size(field)/=klon) CALL abort_gcm('iophy::histwrite2d','Field first dimension not equal to klon',1)
+    REAL,allocatable,DIMENSION(:) :: fieldok
+
+
+    IF (size(field)/=klon) CALL abort_gcm('iophy::histwrite2d','Field first DIMENSION not equal to klon',1)
     
     CALL Gather_omp(field,buffer_omp)    
@@ -387,29 +765,28 @@
 
  
-  end subroutine histwrite2d_phy_old
-
-  subroutine histwrite3d_phy_old(nid,lpoint,name,itau,field)
+  end SUBROUTINE histwrite2d_phy_old
+
+  SUBROUTINE histwrite3d_phy_old(nid,lpoint,name,itau,field)
   USE dimphy
   USE mod_phys_lmdz_para
-  USE phys_output_var_mod
 
   use ioipsl
-  implicit none
+  IMPLICIT NONE
   include 'dimensions.h'
   include 'iniprint.h'
     
-    integer,intent(in) :: nid
-    logical,intent(in) :: lpoint
-    character*(*), intent(IN) :: name
-    integer, intent(in) :: itau
-    real,dimension(:,:),intent(in) :: field  ! --> field(klon,:)
-    REAL,dimension(klon_mpi,size(field,2)) :: buffer_omp
+    integer,INTENT(IN) :: nid
+    logical,INTENT(IN) :: lpoint
+    character*(*), INTENT(IN) :: name
+    integer, INTENT(IN) :: itau
+    REAL,DIMENSION(:,:),INTENT(IN) :: field  ! --> field(klon,:)
+    REAL,DIMENSION(klon_mpi,size(field,2)) :: buffer_omp
     REAL :: Field3d(iim,jj_nb,size(field,2))
     INTEGER :: ip, n, nlev
-    INTEGER, ALLOCATABLE, dimension(:) :: index3d
-    real,allocatable, dimension(:,:) :: fieldok
-
-
-    IF (size(field,1)/=klon) CALL abort_gcm('iophy::histwrite3d','Field first dimension not equal to klon',1)
+    INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d
+    REAL,allocatable, DIMENSION(:,:) :: fieldok
+
+
+    IF (size(field,1)/=klon) CALL abort_gcm('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
     nlev=size(field,2)
 
@@ -460,5 +837,7 @@
 !$OMP END MASTER    
 
-  end subroutine histwrite3d_phy_old
+  end SUBROUTINE histwrite3d_phy_old
+
+
 
 
@@ -468,34 +847,30 @@
   USE mod_phys_lmdz_para
   USE ioipsl
-!Pour avoir nfiles, nidfiles tout ça tout ça...
-  USE phys_output_var_mod
   
-  
+
 
 #ifdef CPP_XIOS
-!  USE WXIOS
-#endif
+  USE wxios
+#endif
+
 
   IMPLICIT NONE
-  include 'dimensions.h'
-    
-!    integer,intent(in) :: nid
-!    logical,intent(in) :: lpoint 
-!    character*(*), intent(IN) :: name
-!    integer, intent(in) :: itau
-!    real,dimension(:),intent(in) :: field
-
-      TYPE(ctrl_out), INTENT(IN) :: var
-      REAL, DIMENSION(:), INTENT(IN) :: field
-      INTEGER, INTENT(IN), OPTIONAL :: STD_iff ! ug RUSTINE POUR LES STD LEVS.....
+  INCLUDE 'dimensions.h'
+  INCLUDE 'iniprint.h'
+
+    TYPE(ctrl_out), INTENT(IN) :: var
+    REAL, DIMENSION(:), INTENT(IN) :: field
+    INTEGER, INTENT(IN), OPTIONAL :: STD_iff ! ug RUSTINE POUR LES STD LEVS.....
       
-      INTEGER :: iff, iff_beg, iff_end
+    INTEGER :: iff, iff_beg, iff_end
       
-    REAL,dimension(klon_mpi) :: buffer_omp
-    INTEGER, allocatable, dimension(:) :: index2d
+    REAL,DIMENSION(klon_mpi) :: buffer_omp
+    INTEGER, allocatable, DIMENSION(:) :: index2d
     REAL :: Field2d(iim,jj_nb)
 
     INTEGER :: ip
     REAL, ALLOCATABLE, DIMENSION(:) :: fieldok
+
+    IF (prt_level >= 9) WRITE(lunout,*)'Begin histrwrite2d ',var%name
 
 ! ug RUSTINE POUR LES STD LEVS.....
@@ -508,5 +883,18 @@
       END IF
 
-    IF (size(field)/=klon) CALL abort_gcm('iophy::histwrite2d','Field first dimension not equal to klon',1)
+  ! On regarde si on est dans la phase de définition ou d'écriture:
+  IF(.NOT.vars_defined) THEN
+!$OMP MASTER
+      !Si phase de définition.... on définit
+      DO iff=iff_beg, iff_end
+         IF (clef_files(iff)) THEN
+            CALL histdef2d(iff, var)
+         ENDIF
+      ENDDO
+!$OMP END MASTER
+  ELSE
+
+    !Et sinon on.... écrit
+    IF (SIZE(field)/=klon) CALL abort_gcm('iophy::histwrite2d','Field first DIMENSION not equal to klon',1)
     
     CALL Gather_omp(field,buffer_omp)    
@@ -521,10 +909,11 @@
                         ALLOCATE(index2d(iim*jj_nb))
                         ALLOCATE(fieldok(iim*jj_nb))
-     
+#ifndef CPP_NO_IOIPSL 
                         CALL histwrite(nid_files(iff),var%name,itau_iophy,Field2d,iim*jj_nb,index2d)
+#endif
 #ifdef CPP_XIOS
-!                        IF (iff .EQ. 1) THEN
-!                              CALL wxios_write_2D(var%name, Field2d)
-!                        ENDIF
+                        IF (iff == iff_beg) THEN
+                              CALL wxios_write_2D(var%name, Field2d)
+                        ENDIF
 #endif
                   ELSE 
@@ -533,6 +922,4 @@
 
                         IF (is_sequential) THEN
-!                            klon_mpi_begin=1
-!                             klon_mpi_end=klon
                               DO ip=1, npstn
                                     fieldok(ip)=buffer_omp(nptabij(ip))
@@ -540,5 +927,5 @@
                              ELSE
                               DO ip=1, npstn
-!                                   print*,'histwrite2d is_sequential npstn ip name nptabij',npstn,ip,name,nptabij(ip)
+                                PRINT*,'histwrite2d is_sequential npstn ip namenptabij',npstn,ip,var%name,nptabij(ip)
                                      IF(nptabij(ip).GE.klon_mpi_begin.AND. &
                                         nptabij(ip).LE.klon_mpi_end) THEN
@@ -547,6 +934,7 @@
                               ENDDO
                        ENDIF
-     
+#ifndef CPP_NO_IOIPSL 
                        CALL histwrite(nid_files(iff),var%name,itau_iophy,fieldok,npstn,index2d)
+#endif
                   ENDIF
                   
@@ -556,16 +944,14 @@
       ENDDO
 !$OMP END MASTER   
-
+  ENDIF ! vars_defined
+  IF (prt_level >= 9) WRITE(lunout,*)'End histrwrite2d ',var%name
   END SUBROUTINE histwrite2d_phy
 
 
 ! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE
-  SUBROUTINE histwrite3d_phy(var, field)
+  SUBROUTINE histwrite3d_phy(var, field, STD_iff)
   USE dimphy
   USE mod_phys_lmdz_para
-
-  use ioipsl
-!Pour avoir nfiles, nidfiles tout ça tout ça...
-  USE phys_output_var_mod  
+  USE ioipsl
   
 
@@ -576,30 +962,45 @@
 
   IMPLICIT NONE
-  include 'dimensions.h'
-    
-!    integer,intent(in) :: nid
-!    logical,intent(in) :: lpoint
-!    character*(*), intent(IN) :: name
-!    integer, intent(in) :: itau
-!    real,dimension(:,:),intent(in) :: field  ! --> field(klon,:)
-
-      TYPE(ctrl_out), INTENT(IN) :: var
-      REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:)
-
+  INCLUDE 'dimensions.h'
+  INCLUDE 'iniprint.h'
+
+    TYPE(ctrl_out), INTENT(IN) :: var
+    REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:)
+    INTEGER, INTENT(IN), OPTIONAL :: STD_iff ! ug RUSTINE POUR LES STD LEVS.....
+      
+    INTEGER :: iff, iff_beg, iff_end
 
     REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp
     REAL :: Field3d(iim,jj_nb,SIZE(field,2))
-    INTEGER :: ip, n, nlev, iff
+    INTEGER :: ip, n, nlev
     INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d
     REAL,ALLOCATABLE, DIMENSION(:,:) :: fieldok
 
-    IF (size(field,1)/=klon) CALL abort_gcm('iophy::histwrite3d','Field first dimension not equal to klon',1)
-    nlev=size(field,2)
-
-!   print*,'hist3d_phy mpi_rank npstn=',mpi_rank,npstn
-
-!   DO ip=1, npstn
-!    print*,'hist3d_phy mpi_rank nptabij',mpi_rank,nptabij(ip)
-!   ENDDO
+  IF (prt_level >= 9) write(lunout,*)'Begin histrwrite3d ',var%name
+
+! ug RUSTINE POUR LES STD LEVS.....
+      IF (PRESENT(STD_iff)) THEN
+            iff_beg = STD_iff
+            iff_end = STD_iff
+      ELSE
+            iff_beg = 1
+            iff_end = nfiles
+      END IF
+
+  ! On regarde si on est dans la phase de définition ou d'écriture:
+  IF(.NOT.vars_defined) THEN
+      !Si phase de définition.... on définit
+!$OMP MASTER
+      DO iff=iff_beg, iff_end
+        IF (clef_files(iff)) THEN
+          CALL histdef3d(iff, var)
+        ENDIF
+      ENDDO
+!$OMP END MASTER
+  ELSE
+    !Et sinon on.... écrit
+    IF (SIZE(field,1)/=klon) CALL abort_gcm('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
+    nlev=SIZE(field,2)
+
 
     CALL Gather_omp(field,buffer_omp)
@@ -609,14 +1010,18 @@
 
 ! BOUCLE SUR LES FICHIERS
-      DO iff=1, nfiles
+     DO iff=iff_beg, iff_end
             IF (var%flag(iff) <= lev_files(iff) .AND. clef_files(iff)) THEN
                 IF (.NOT.clef_stations(iff)) THEN
                         ALLOCATE(index3d(iim*jj_nb*nlev))
                         ALLOCATE(fieldok(iim*jj_nb,nlev))
+
+#ifndef CPP_NO_IOIPSL 
                         CALL histwrite(nid_files(iff),var%name,itau_iophy,Field3d,iim*jj_nb*nlev,index3d)
+#endif
+
 #ifdef CPP_XIOS
-!                        IF (iff .EQ. 1) THEN
-!                              CALL wxios_write_3D(var%name, Field3d(:,:,1:klev))
-!                        ENDIF
+                        IF (iff == 1) THEN
+                              CALL wxios_write_3D(var%name, Field3d(:,:,1:klev))
+                        ENDIF
 #endif
                         
@@ -627,6 +1032,4 @@
 
                         IF (is_sequential) THEN
-            !                  klon_mpi_begin=1
-            !                  klon_mpi_end=klon
                               DO n=1, nlev
                                     DO ip=1, npstn
@@ -644,5 +1047,7 @@
                               ENDDO
                         ENDIF
+#ifndef CPP_NO_IOIPSL 
                         CALL histwrite(nid_files(iff),var%name,itau_iophy,fieldok,npstn*nlev,index3d)
+#endif
                   ENDIF 
                   deallocate(index3d)
@@ -651,5 +1056,147 @@
       ENDDO
 !$OMP END MASTER   
+  ENDIF ! vars_defined
+  IF (prt_level >= 9) write(lunout,*)'End histrwrite3d ',var%name
   END SUBROUTINE histwrite3d_phy
   
+
+! VERSION DES HISTWRITE DEDIEES AU TOUT-XIOS-XML DEJA UTILISEE DANS PHYDEV
+#ifdef CPP_XIOS
+  SUBROUTINE histwrite2d_xios(field_name,field)
+  USE dimphy
+  USE mod_phys_lmdz_para
+  USE wxios
+
+
+  IMPLICIT NONE
+  INCLUDE 'dimensions.h'
+  INCLUDE 'iniprint.h'
+
+    CHARACTER(LEN=*), INTENT(IN) :: field_name
+    REAL, DIMENSION(:), INTENT(IN) :: field
+      
+    REAL,DIMENSION(klon_mpi) :: buffer_omp
+    INTEGER, allocatable, DIMENSION(:) :: index2d
+    REAL :: Field2d(iim,jj_nb)
+
+    INTEGER :: ip
+    REAL, ALLOCATABLE, DIMENSION(:) :: fieldok
+
+    IF (prt_level >= 9) WRITE(lunout,*)'Begin histrwrite2d_xios ',field_name
+
+    !Et sinon on.... écrit
+    IF (SIZE(field)/=klon) CALL abort_gcm('iophy::histwrite2d_xios','Field first DIMENSION not equal to klon',1)
+    
+    CALL Gather_omp(field,buffer_omp)    
+!$OMP MASTER
+    CALL grid1Dto2D_mpi(buffer_omp,Field2d)
+    
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!ATTENTION, STATIONS PAS GEREES !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    !IF(.NOT.clef_stations(iff)) THEN
+    IF (.TRUE.) THEN
+        ALLOCATE(index2d(iim*jj_nb))
+        ALLOCATE(fieldok(iim*jj_nb))
+
+
+        CALL wxios_write_2D(field_name, Field2d)
+
+    ELSE 
+        ALLOCATE(fieldok(npstn))
+        ALLOCATE(index2d(npstn))
+
+        IF (is_sequential) THEN
+            DO ip=1, npstn
+                fieldok(ip)=buffer_omp(nptabij(ip))
+            ENDDO
+        ELSE
+            DO ip=1, npstn
+                PRINT*,'histwrite2d_xios is_sequential npstn ip namenptabij',npstn,ip,field_name,nptabij(ip)
+                IF(nptabij(ip).GE.klon_mpi_begin.AND. &
+                nptabij(ip).LE.klon_mpi_end) THEN
+                    fieldok(ip)=buffer_omp(nptabij(ip)-klon_mpi_begin+1)
+                ENDIF
+            ENDDO
+        ENDIF
+
+    ENDIF
+                  
+    deallocate(index2d)
+    deallocate(fieldok)
+!$OMP END MASTER   
+
+  IF (prt_level >= 9) WRITE(lunout,*)'End histrwrite2d_xios ',field_name
+  END SUBROUTINE histwrite2d_xios
+
+
+! ug NOUVELLE VERSION DES WRITE AVEC LA BOUCLE DO RENTREE
+  SUBROUTINE histwrite3d_xios(field_name, field)
+  USE dimphy
+  USE mod_phys_lmdz_para
+  USE wxios
+
+
+  IMPLICIT NONE
+  INCLUDE 'dimensions.h'
+  INCLUDE 'iniprint.h'
+
+    CHARACTER(LEN=*), INTENT(IN) :: field_name
+    REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:)
+
+    REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp
+    REAL :: Field3d(iim,jj_nb,SIZE(field,2))
+    INTEGER :: ip, n, nlev
+    INTEGER, ALLOCATABLE, DIMENSION(:) :: index3d
+    REAL,ALLOCATABLE, DIMENSION(:,:) :: fieldok
+
+  IF (prt_level >= 9) write(lunout,*)'Begin histrwrite3d_xios ',field_name
+
+    !Et on.... écrit
+    IF (SIZE(field,1)/=klon) CALL abort_gcm('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
+    nlev=SIZE(field,2)
+
+
+    CALL Gather_omp(field,buffer_omp)
+!$OMP MASTER
+    CALL grid1Dto2D_mpi(buffer_omp,field3d)
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!ATTENTION, STATIONS PAS GEREES !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    !IF (.NOT.clef_stations(iff)) THEN
+    IF(.TRUE.)THEN
+        ALLOCATE(index3d(iim*jj_nb*nlev))
+        ALLOCATE(fieldok(iim*jj_nb,nlev))
+        CALL wxios_write_3D(field_name, Field3d(:,:,1:klev))
+                        
+    ELSE 
+        nlev=size(field,2)
+        ALLOCATE(index3d(npstn*nlev))
+        ALLOCATE(fieldok(npstn,nlev))
+
+        IF (is_sequential) THEN
+            DO n=1, nlev
+                DO ip=1, npstn
+                    fieldok(ip,n)=buffer_omp(nptabij(ip),n)
+                ENDDO
+            ENDDO
+        ELSE
+            DO n=1, nlev
+                DO ip=1, npstn
+                    IF(nptabij(ip).GE.klon_mpi_begin.AND. &
+                    nptabij(ip).LE.klon_mpi_end) THEN
+                        fieldok(ip,n)=buffer_omp(nptabij(ip)-klon_mpi_begin+1,n)
+                    ENDIF
+                ENDDO
+            ENDDO
+        ENDIF
+    ENDIF 
+    deallocate(index3d)
+    deallocate(fieldok)
+!$OMP END MASTER   
+
+  IF (prt_level >= 9) write(lunout,*)'End histrwrite3d_xios ',field_name
+  END SUBROUTINE histwrite3d_xios
+#endif
 end module iophy
Index: LMDZ5/branches/testing/libf/phylmd/mod_phys_lmdz_para.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/mod_phys_lmdz_para.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/mod_phys_lmdz_para.F90	(revision 1864)
@@ -32,5 +32,5 @@
        is_master=.FALSE.
      ENDIF
-    CALL Test_transfert
+     CALL Test_transfert
 !$OMP END PARALLEL    
      IF (is_using_mpi .OR. is_using_omp) THEN
Index: LMDZ5/branches/testing/libf/phylmd/pbl_surface_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/pbl_surface_mod.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/pbl_surface_mod.F90	(revision 1864)
@@ -174,5 +174,5 @@
        t,         q,         u,        v,             &
        pplay,     paprs,     pctsrf,                  &
-       ts,        alb1,      alb2,ustar, u10m, v10m,  &
+       ts,        alb1, alb2,ustar, u10m, v10m,wstar, &
        lwdown_m,  cdragh,    cdragm,   zu1,    zv1,   &
        alb1_m,    alb2_m,    zxsens,   zxevap,        &
@@ -294,4 +294,5 @@
     REAL, DIMENSION(klon, nbsrf), INTENT(INOUT)     :: alb2    ! albedo in near infra-red SW interval
     REAL, DIMENSION(klon, nbsrf), INTENT(INOUT)     :: ustar   ! u* (m/s)
+    REAL, DIMENSION(klon, nbsrf+1), INTENT(INOUT)   :: wstar   ! w* (m/s)
     REAL, DIMENSION(klon, nbsrf), INTENT(INOUT)     :: u10m    ! u speed at 10m
     REAL, DIMENSION(klon, nbsrf), INTENT(INOUT)     :: v10m    ! v speed at 10m
@@ -406,4 +407,5 @@
     REAL, DIMENSION(klon)              :: yt2m, yq2m, yu10m
     REAL, DIMENSION(klon)              :: yustar
+    REAL, DIMENSION(klon)              :: ywstar
     REAL, DIMENSION(klon)              :: ywindsp
     REAL, DIMENSION(klon)              :: yt10m, yq10m
@@ -1065,4 +1067,5 @@
        q2m(:,nsrf)    = 0.
        ustar(:,nsrf)   = 0.
+       wstar(:,nsrf)   = 0.
        u10m(:,nsrf)   = 0.
        v10m(:,nsrf)   = 0.
@@ -1145,6 +1148,6 @@
 
 !   print*,'OK pbl 5'
-       CALL HBTM(knon, ypaprs, ypplay, &
-            yt2m,yt10m,yq2m,yq10m,yustar, &
+       CALL hbtm(knon, ypaprs, ypplay, &
+            yt2m,yt10m,yq2m,yq10m,yustar,ywstar, &
             y_flux_t,y_flux_q,yu,yv,yt,yq, &
             ypblh,ycapCL,yoliqCL,ycteiCL,ypblT, &
@@ -1154,4 +1157,5 @@
           i = ni(j)
           pblh(i,nsrf)   = ypblh(j)
+          wstar(i,nsrf)  = ywstar(j)
           plcl(i,nsrf)   = ylcl(j)
           capCL(i,nsrf)  = ycapCL(j)
@@ -1215,4 +1219,5 @@
     s_therm(:) = 0.0 ; s_trmb1(:) = 0.0
     s_trmb2(:) = 0.0 ; s_trmb3(:) = 0.0
+    wstar(:,is_ave)=0.
     
 !   print*,'OK pbl 9'
@@ -1233,4 +1238,5 @@
           zq2m(i)  = zq2m(i)  + q2m(i,nsrf)  * pctsrf(i,nsrf)
           zustar(i) = zustar(i) + ustar(i,nsrf) * pctsrf(i,nsrf)
+          wstar(i,is_ave)=wstar(i,is_ave)+wstar(i,nsrf)*pctsrf(i,nsrf)
           zu10m(i) = zu10m(i) + u10m(i,nsrf) * pctsrf(i,nsrf)
           zv10m(i) = zv10m(i) + v10m(i,nsrf) * pctsrf(i,nsrf)
Index: LMDZ5/branches/testing/libf/phylmd/phyaqua.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phyaqua.F	(revision 1796)
+++ 	(revision )
@@ -1,909 +1,0 @@
-! Routines complementaires pour la physique planetaire.
-
-
-      subroutine iniaqua(nlon,latfi,lonfi,iflag_phys)
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!  Creation d'un etat initial et de conditions aux limites 
-!  (resp startphy.nc et limit.nc) pour des configurations idealisees 
-! du modele LMDZ dans sa version terrestre.
-!  iflag_phys est un parametre qui controle
-!  iflag_phys = N  
-!    de 100 a 199 : aqua planetes avec SST forcees
-!                 N-100 determine le type de SSTs
-!    de 200 a 299 : terra planetes avec Ts calcule
-!        
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      USE comgeomphy, only : rlatd,rlond
-      USE dimphy, only : klon
-      USE surface_data, only : type_ocean,ok_veget
-      USE pbl_surface_mod, only : pbl_surface_init
-      USE fonte_neige_mod, only : fonte_neige_init
-      USE phys_state_var_mod
-      USE control_mod, only : dayref,nday,iphysiq
-      USE indice_sol_mod
-
-      USE IOIPSL 
-      IMPLICIT NONE
-
-#include "dimensions.h"
-!   #include "dimphy.h"
-!   #include "YOMCST.h"
-#include "comconst.h"
-#include "clesphys.h"
-#include "dimsoil.h"
-#include "temps.h"
-
-      integer,intent(in) :: nlon,iflag_phys
-cIM ajout latfi, lonfi
-      real,intent(in) :: lonfi(nlon),latfi(nlon)
-
-      INTEGER type_profil,type_aqua
-
-c  Ajouts initialisation des surfaces
-      REAL :: run_off_lic_0(nlon)
-      REAL :: qsolsrf(nlon,nbsrf),snsrf(nlon,nbsrf)
-      REAL :: frugs(nlon,nbsrf)
-      REAL :: agesno(nlon,nbsrf)
-      REAL :: tsoil(nlon,nsoilmx,nbsrf)
-      REAL :: tslab(nlon), seaice(nlon)
-      REAL evap(nlon,nbsrf),fder(nlon)
-
-
-
-c    Arguments :
-c    -----------
-
-!      integer radpas  
-      integer it,unit,i,k,itap
-
-      real airefi,zcufi,zcvfi
-
-      real rugos,albedo
-      REAL tsurf
-      REAL time,timestep,day,day0
-      real qsol_f,qsol(nlon)
-      real rugsrel(nlon)
-!      real zmea(nlon),zstd(nlon),zsig(nlon)
-!      real zgam(nlon),zthe(nlon),zpic(nlon),zval(nlon)
-!      real rlon(nlon),rlat(nlon)
-      logical alb_ocean
-!      integer demih_pas
-
-      CHARACTER*80 ans,file_forctl, file_fordat, file_start
-      character*100 file,var
-      character*2 cnbl
-
-      REAL phy_nat(nlon,360)
-      REAL phy_alb(nlon,360)
-      REAL phy_sst(nlon,360)
-      REAL phy_bil(nlon,360)
-      REAL phy_rug(nlon,360)
-      REAL phy_ice(nlon,360)
-      REAL phy_fter(nlon,360)
-      REAL phy_foce(nlon,360)
-      REAL phy_fsic(nlon,360)
-      REAL phy_flic(nlon,360)
-
-      integer, save::  read_climoz=0 ! read ozone climatology
-
-! intermediate variables to use getin
-      integer :: nbapp_rad_omp
-      real :: co2_ppm_omp,solaire_omp
-      logical :: alb_ocean_omp
-      real :: rugos_omp
-!-------------------------------------------------------------------------
-!  declaration pour l'appel a phyredem
-!-------------------------------------------------------------------------
-
-!      real pctsrf(nlon,nbsrf),ftsol(nlon,nbsrf)
-      real falbe(nlon,nbsrf),falblw(nlon,nbsrf)
-!      real pbl_tke(nlon,llm,nbsrf)
-!      real rain_fall(nlon),snow_fall(nlon)
-!      real solsw(nlon), sollw(nlon),radsol(nlon)
-!      real t_ancien(nlon,llm),q_ancien(nlon,llm),rnebcon(nlon,llm)
-!      real ratqs(nlon,llm)
-!      real clwcon(nlon,llm)
-
-      INTEGER        longcles
-      PARAMETER    ( longcles = 20 )
-      REAL clesphy0( longcles )
-
-
-c-----------------------------------------------------------------------
-c   dynamial tendencies :
-c   ---------------------
-
-      INTEGER l,ierr,aslun
-
-      REAL longitude,latitude
-      REAL paire 
-
-      DATA latitude,longitude/48.,0./
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! INITIALISATIONS
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-!-----------------------------------------------------------------------
-!    Initialisations  des constantes
-!    -------------------------------
-
-
-      type_aqua=iflag_phys/100
-      type_profil=iflag_phys-type_aqua*100
-      print*,'iniaqua:type_aqua, type_profil',type_aqua, type_profil
-
-      if (klon.ne.nlon) then
-        write(*,*)"iniaqua: klon=",klon," nlon=",nlon
-        stop'probleme de dimensions dans iniaqua'
-      endif
-      call phys_state_var_init(read_climoz)
-
-
-      read_climoz=0
-      day0=217.
-      day=day0
-      it=0
-      time=0.
-
-cIM ajout latfi, lonfi
-      rlatd=latfi
-      rlond=lonfi
-      rlat=rlatd*180./pi
-      rlon=rlond*180./pi
-
-!-----------------------------------------------------------------------
-!  initialisations de la physique
-!-----------------------------------------------------------------------
-
-         day_ini=dayref
-         day_end=day_ini+nday
-         airefi=1.
-         zcufi=1.
-         zcvfi=1.
-!$OMP MASTER
-      nbapp_rad_omp=24
-      CALL getin('nbapp_rad',nbapp_rad_omp)
-!$OMP END MASTER
-!$OMP BARRIER
-      nbapp_rad=nbapp_rad_omp
-
-!---------------------------------------------------------------------
-c Creation des conditions aux limites:
-c ------------------------------------
-! Initialisations des constantes
-! Ajouter les manquants dans planete.def... (albedo etc)
-!$OMP MASTER
-      co2_ppm_omp=348.
-      CALL getin('co2_ppm',co2_ppm_omp)
-      solaire_omp=1365.
-      CALL getin('solaire',solaire_omp)
-!      CALL getin('albedo',albedo) ! albedo is set below, depending on type_aqua
-      alb_ocean_omp=.true.
-      CALL getin('alb_ocean',alb_ocean_omp)
-!$OMP END MASTER
-!$OMP BARRIER
-      co2_ppm=co2_ppm_omp
-      solaire=solaire_omp
-      alb_ocean=alb_ocean_omp
-
-      radsol=0.
-      qsol_f=10.
-
-c  Conditions aux limites:
-c  -----------------------
-
-      qsol(:)    = qsol_f
-      rugsrel = 0.0    ! (rugsrel = rugoro)
-      rugoro = 0.0
-      u_ancien = 0.0
-      v_ancien = 0.0
-      agesno  = 50.0
-! Relief plat
-      zmea = 0.
-      zstd = 0.
-      zsig = 0.
-      zgam = 0.
-      zthe = 0.
-      zpic = 0.
-      zval = 0.
-
-! Une seule surface
-      pctsrf=0.
-      if (type_aqua==1) then
-         rugos=1.e-4
-         albedo=0.19
-         pctsrf(:,is_oce)=1.
-      else if (type_aqua==2) then
-         rugos=0.03
-         albedo=0.1
-         pctsrf(:,is_ter)=1.
-      endif
-
-!$OMP MASTER
-      rugos_omp=rugos
-      CALL getin('rugos',rugos_omp)
-!$OMP END MASTER
-!$OMP BARRIER
-      rugos=rugos_omp
-      zmasq(:)=pctsrf(:,is_oce)
-
-! pctsrf_pot(:,is_oce) = 1. - zmasq(:)
-! pctsrf_pot(:,is_sic) = 1. - zmasq(:)
-
-! Si alb_ocean on calcule un albedo oceanique moyen
-!  if (alb_ocean) then
-! Voir pourquoi on avait ca.
-!          CALL ini_alb_oce(phy_alb)
-!      else 
-      phy_alb(:,:) = albedo ! albedo land only (old value condsurf_jyg=0.3)
-!      endif !alb_ocean
-      
-      do i=1,360
-cIM Terraplanete   phy_sst(:,i) = 260.+50.*cos(rlatd(:))**2
-cIM ajout calcul profil sst selon le cas considere (cf. FBr)
-
-      phy_nat(:,i) = 1.0    ! 0=ocean libre, 1=land, 2=glacier, 3=banquise
-      phy_bil(:,i) = 1.0    ! ne sert que pour les slab_ocean
-      phy_rug(:,i) = rugos  ! longueur rugosite utilisee sur land only 
-      phy_ice(:,i) = 0.0    ! fraction de glace (?)
-      phy_fter(:,i) = pctsrf(:,is_ter)  ! fraction de glace (?)
-      phy_foce(:,i) = pctsrf(:,is_oce)  ! fraction de glace (?)
-      phy_fsic(:,i) = pctsrf(:,is_sic)  ! fraction de glace (?)
-      phy_flic(:,i) = pctsrf(:,is_lic)  ! fraction de glace (?)
-      enddo
-cIM calcul profil sst
-      call profil_sst(nlon, rlatd, type_profil, phy_sst)
-
-      call writelim
-     s   (klon,phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,phy_ice,
-     s    phy_fter,phy_foce,phy_flic,phy_fsic)
-
-
-!---------------------------------------------------------------------
-c Ecriture de l'etat initial:
-c ---------------------------
-
-C
-C Ecriture etat initial physique
-C
-      timestep   = dtvr * FLOAT(iphysiq)
-      radpas    = NINT (daysec/timestep/ FLOAT(nbapp_rad) )
-
-      DO i = 1, longcles
-       clesphy0(i) = 0.
-      ENDDO
-      clesphy0(1) = FLOAT( iflag_con )
-      clesphy0(2) = FLOAT( nbapp_rad )
-c     IF( cycle_diurne  ) clesphy0(3) =  1. 
-      clesphy0(3)=1. ! cycle_diurne
-      clesphy0(4)=1. ! soil_model
-      clesphy0(5)=1. ! new_oliq
-      clesphy0(6)=0. ! ok_orodr
-      clesphy0(7)=0. ! ok_orolf
-      clesphy0(8)=0. ! ok_limitvrai
-
-
-c=======================================================================
-c  Profils initiaux
-c=======================================================================
-
-! On initialise les temperatures de surfaces comme les sst
-      do i=1,nlon
-         ftsol(i,:)=phy_sst(i,1)
-         tsoil(i,:,:)=phy_sst(i,1)
-         tslab(i)=phy_sst(i,1)
-      enddo
-
-      falbe(:,:)=albedo
-      falblw(:,:)=albedo
-      rain_fall(:)=0.
-      snow_fall(:)=0.
-      solsw(:)=0.
-      sollw(:)=0.
-      radsol(:)=0.
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!  intialisation bidon mais pas grave
-      t_ancien(:,:)=0.
-      q_ancien(:,:)=0.
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      rnebcon=0.
-      ratqs=0.
-      clwcon=0.
-      pbl_tke=1.e-8
-
-! variables supplementaires pour appel a plb_surface_init
-      fder(:)=0.
-      seaice(:)=0.
-      run_off_lic_0=0.
-      evap=0.
-
-
-! Initialisations necessaires avant phyredem
-      type_ocean = "force"
-      call fonte_neige_init(run_off_lic_0)
-      qsolsrf(:,:)=qsol(1) ! humidite du sol des sous surface
-      snsrf(:,:)=0.        ! couverture de neige des sous surface
-      frugs(:,:)=rugos        ! couverture de neige des sous surface
-
-
-      call pbl_surface_init(qsol, fder, snsrf, qsolsrf,
-     .     evap, frugs, agesno, tsoil)
-
-        print*,'iniaqua: before phyredem'
-
-      falb1=albedo
-      falb2=albedo
-      zmax0=0.
-      f0=0.
-      ema_work1=0.
-      ema_work2=0.
-      wake_deltat=0.
-      wake_deltaq=0.
-      wake_s=0.
-      wake_cstar=0.
-      wake_pe=0.
-      wake_fip=0.
-      fm_therm=0.
-      entr_therm=0.
-      detr_therm=0.
-
-
-      CALL phyredem ("startphy.nc")
-
-        print*,'iniaqua: after phyredem'
-      call phys_state_var_end
-
-      return
-      end
-
-
-c====================================================================
-c====================================================================
-      SUBROUTINE zenang_an(cycle_diurne,gmtime,rlat,rlon,rmu0,fract)
-      USE dimphy
-      IMPLICIT none
-c====================================================================
-c=============================================================
-c         CALL zenang(cycle_diurne,gmtime,rlat,rlon,rmu0,fract)
-c Auteur : A. Campoy et F. Hourdin
-c Objet  : calculer les valeurs moyennes du cos de l'angle zenithal
-c          et l'ensoleillement moyen entre gmtime1 et gmtime2 
-c          connaissant la declinaison, la latitude et la longitude.
-c 
-c   Dans cette version particuliere, on calcule le rayonnement
-c  moyen sur l'année à chaque latitude.
-c   angle zenithal calculé pour obtenir un 
-c   Fit polynomial de  l'ensoleillement moyen au sommet de l'atmosphere
-c   en moyenne annuelle.
-c   Spécifique de la terre. Utilisé pour les aqua planetes.
-c
-c Rque   : Different de la routine angle en ce sens que zenang 
-c          fournit des moyennes de pmu0 et non des valeurs 
-c          instantanees, du coup frac prend toutes les valeurs 
-c          entre 0 et 1.
-c Date   : premiere version le 13 decembre 1994
-c          revu pour  GCM  le 30 septembre 1996
-c===============================================================
-c longi----INPUT : la longitude vraie de la terre dans son plan
-c                  solaire a partir de l'equinoxe de printemps (degre)
-c gmtime---INPUT : temps universel en fraction de jour
-c pdtrad---INPUT : pas de temps du rayonnement (secondes)
-c lat------INPUT : latitude en degres
-c long-----INPUT : longitude en degres
-c pmu0-----OUTPUT: angle zenithal moyen entre gmtime et gmtime+pdtrad
-c frac-----OUTPUT: ensoleillement moyen entre gmtime et gmtime+pdtrad
-c================================================================
-#include "YOMCST.h"
-c================================================================
-      logical cycle_diurne
-      real  gmtime
-      real rlat(klon), rlon(klon), rmu0(klon), fract(klon)
-c================================================================
-      integer i
-      real gmtime1, gmtime2
-      real pi_local
-
-
-      real rmu0m(klon),rmu0a(klon)
-c
-
-      pi_local = 4.0 * ATAN(1.0)
-
-c================================================================
-c  Calcul de l'angle zenithal moyen sur la journee
-c================================================================
-
-      DO i=1,klon
-        fract(i)=1. 
-!  Calcule du flux moyen
-        IF (abs(rlat(i)).LE.28.75) THEN
-           rmu0m(i)=(210.1924+206.6059*cos(0.0174533*rlat(i))**2)/1365.
-        ELSEIF (abs(rlat(i)).LE.43.75) THEN
-          rmu0m(i)=(187.4562+236.1853*cos(0.0174533*rlat(i))**2)/1365.
-        ELSEIF (abs(rlat(i)).LE.71.25) THEN
-          rmu0m(i)=(162.4439+284.1192*cos(0.0174533*rlat(i))**2)/1365.
-        ELSE
-          rmu0m(i)=(172.8125+183.7673*cos(0.0174533*rlat(i))**2)/1365.
-        ENDIF
-      ENDDO
-
-c================================================================
-!  Avec ou sans cycle diurne
-c================================================================
-
-      IF (cycle_diurne) THEN
-
-!  On redecompose flux  au sommet suivant un cycle diurne idealise
-!  identique a toutes les latitudes.
-
-         DO i=1,klon
-           rmu0a(i)=2.*rmu0m(i)*sqrt(2.)*pi_local/(4.-pi_local)
-           rmu0(i)=rmu0a(i)*abs(sin(pi_local*gmtime+pi_local*
-     &      rlon(i)/360.))-rmu0a(i)/sqrt(2.)
-         ENDDO
-
-         DO i=1,klon
-           IF (rmu0(i).LE.0.) THEN
-              rmu0(i)=0.
-              fract(i)=0.
-           ELSE
-              fract(i)=1.
-           ENDIF
-         ENDDO
-
-!  Affichage de l'angel zenitale
-!     print*,'************************************'
-!     print*,'************************************'
-!     print*,'************************************'
-!     print*,'latitude=',rlat(i),'longitude=',rlon(i)
-!     print*,'rmu0m=',rmu0m(i)
-!     print*,'rmu0a=',rmu0a(i)
-!     print*,'rmu0=',rmu0(i)
-                                                               
-      ELSE
-
-        DO i=1,klon
-           fract(i)=0.5
-           rmu0(i)=rmu0m(i)*2.
-        ENDDO
-
-      ENDIF
-
-      RETURN
-      END
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      subroutine writelim
-     s   (klon,phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,phy_ice,
-     s    phy_fter,phy_foce,phy_flic,phy_fsic)
-c
-      use mod_phys_lmdz_para, only: is_mpi_root,is_omp_root
-      use mod_grid_phy_lmdz, only : klon_glo
-      use mod_phys_lmdz_transfert_para, only : gather
-!#include "dimensions.h"
-!#include "dimphy.h"
-#include "netcdf.inc"
- 
-      integer,intent(in) :: klon
-      real,intent(in) :: phy_nat(klon,360)
-      real,intent(in) :: phy_alb(klon,360)
-      real,intent(in) :: phy_sst(klon,360)
-      real,intent(in) :: phy_bil(klon,360)
-      real,intent(in) :: phy_rug(klon,360)
-      real,intent(in) :: phy_ice(klon,360)
-      real,intent(in) :: phy_fter(klon,360)
-      real,intent(in) :: phy_foce(klon,360)
-      real,intent(in) :: phy_flic(klon,360)
-      real,intent(in) :: phy_fsic(klon,360)
-
-      real :: phy_glo(klon_glo,360) ! temporary variable, to store phy_***(:)
-                                    ! on the whole physics grid 
-      INTEGER ierr
-      INTEGER dimfirst(3)
-      INTEGER dimlast(3)
-c
-      INTEGER nid, ndim, ntim
-      INTEGER dims(2), debut(2), epais(2)
-      INTEGER id_tim
-      INTEGER id_NAT, id_SST, id_BILS, id_RUG, id_ALB
-      INTEGER id_FTER,id_FOCE,id_FSIC,id_FLIC
- 
-      if (is_mpi_root.and.is_omp_root) then
-      
-        PRINT*, 'writelim: Ecriture du fichier limit'
-c
-        ierr = NF_CREATE ("limit.nc", NF_CLOBBER, nid)
-c
-        ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 30,
-     .                       "Fichier conditions aux limites")
-!!        ierr = NF_DEF_DIM (nid, "points_physiques", klon, ndim)
-        ierr = NF_DEF_DIM (nid, "points_physiques", klon_glo, ndim)
-        ierr = NF_DEF_DIM (nid, "time", NF_UNLIMITED, ntim)
-c
-        dims(1) = ndim
-        dims(2) = ntim
-c
-ccc      ierr = NF_DEF_VAR (nid, "TEMPS", NF_DOUBLE, 1,ntim, id_tim)
-        ierr = NF_DEF_VAR (nid, "TEMPS", NF_FLOAT, 1,ntim, id_tim)
-        ierr = NF_PUT_ATT_TEXT (nid, id_tim, "title", 17,
-     .                        "Jour dans l annee")
-ccc      ierr = NF_DEF_VAR (nid, "NAT", NF_DOUBLE, 2,dims, id_NAT)
-        ierr = NF_DEF_VAR (nid, "NAT", NF_FLOAT, 2,dims, id_NAT)
-        ierr = NF_PUT_ATT_TEXT (nid, id_NAT, "title", 23,
-     .                        "Nature du sol (0,1,2,3)")
-ccc      ierr = NF_DEF_VAR (nid, "SST", NF_DOUBLE, 2,dims, id_SST)
-        ierr = NF_DEF_VAR (nid, "SST", NF_FLOAT, 2,dims, id_SST)
-        ierr = NF_PUT_ATT_TEXT (nid, id_SST, "title", 35,
-     .                        "Temperature superficielle de la mer")
-ccc      ierr = NF_DEF_VAR (nid, "BILS", NF_DOUBLE, 2,dims, id_BILS)
-        ierr = NF_DEF_VAR (nid, "BILS", NF_FLOAT, 2,dims, id_BILS)
-        ierr = NF_PUT_ATT_TEXT (nid, id_BILS, "title", 32,
-     .                        "Reference flux de chaleur au sol")
-ccc      ierr = NF_DEF_VAR (nid, "ALB", NF_DOUBLE, 2,dims, id_ALB)
-        ierr = NF_DEF_VAR (nid, "ALB", NF_FLOAT, 2,dims, id_ALB)
-        ierr = NF_PUT_ATT_TEXT (nid, id_ALB, "title", 19,
-     .                        "Albedo a la surface")
-ccc      ierr = NF_DEF_VAR (nid, "RUG", NF_DOUBLE, 2,dims, id_RUG)
-        ierr = NF_DEF_VAR (nid, "RUG", NF_FLOAT, 2,dims, id_RUG)
-        ierr = NF_PUT_ATT_TEXT (nid, id_RUG, "title", 8,
-     .                        "Rugosite")
-
-        ierr = NF_DEF_VAR (nid, "FTER", NF_FLOAT, 2,dims, id_FTER)
-        ierr = NF_PUT_ATT_TEXT (nid, id_FTER, "title", 8,"Frac. Terre")
-        ierr = NF_DEF_VAR (nid, "FOCE", NF_FLOAT, 2,dims, id_FOCE)
-        ierr = NF_PUT_ATT_TEXT (nid, id_FOCE, "title", 8,"Frac. Terre")
-        ierr = NF_DEF_VAR (nid, "FSIC", NF_FLOAT, 2,dims, id_FSIC)
-        ierr = NF_PUT_ATT_TEXT (nid, id_FSIC, "title", 8,"Frac. Terre")
-        ierr = NF_DEF_VAR (nid, "FLIC", NF_FLOAT, 2,dims, id_FLIC)
-        ierr = NF_PUT_ATT_TEXT (nid, id_FLIC, "title", 8,"Frac. Terre")
-c
-        ierr = NF_ENDDEF(nid)
-c
-
-! write the 'times'
-        do k=1,360
-#ifdef NC_DOUBLE
-          ierr = NF_PUT_VAR1_DOUBLE (nid,id_tim,k,DBLE(k))
-#else
-          ierr = NF_PUT_VAR1_REAL (nid,id_tim,k,FLOAT(k))
-#endif
-        enddo
-
-      endif ! of if (is_mpi_root.and.is_omp_root)
-
-! write the fields, after having collected them on master
-
-      call gather(phy_nat,phy_glo)
-      if (is_mpi_root.and.is_omp_root) then
-#ifdef NC_DOUBLE
-        ierr=NF_PUT_VAR_DOUBLE(nid,id_NAT,phy_glo)
-#else
-        ierr=NF_PUT_VAR_REAL(nid,id_NAT,phy_glo)
-#endif
-        if(ierr.ne.NF_NOERR) then
-          write(*,*) "writelim error with phy_nat"
-          write(*,*) NF_STRERROR(ierr)
-        endif
-      endif
-
-      call gather(phy_sst,phy_glo)
-      if (is_mpi_root.and.is_omp_root) then
-#ifdef NC_DOUBLE
-        ierr=NF_PUT_VAR_DOUBLE(nid,id_SST,phy_glo)
-#else
-        ierr=NF_PUT_VAR_REAL(nid,id_SST,phy_glo)
-#endif
-        if(ierr.ne.NF_NOERR) then
-          write(*,*) "writelim error with phy_sst"
-          write(*,*) NF_STRERROR(ierr)
-        endif
-      endif
-
-      call gather(phy_bil,phy_glo)
-      if (is_mpi_root.and.is_omp_root) then
-#ifdef NC_DOUBLE
-        ierr=NF_PUT_VAR_DOUBLE(nid,id_BILS,phy_glo)
-#else
-        ierr=NF_PUT_VAR_REAL(nid,id_BILS,phy_glo)
-#endif
-        if(ierr.ne.NF_NOERR) then
-          write(*,*) "writelim error with phy_bil"
-          write(*,*) NF_STRERROR(ierr)
-        endif
-      endif
-
-      call gather(phy_alb,phy_glo)
-      if (is_mpi_root.and.is_omp_root) then
-#ifdef NC_DOUBLE
-        ierr=NF_PUT_VAR_DOUBLE(nid,id_ALB,phy_glo)
-#else
-        ierr=NF_PUT_VAR_REAL(nid,id_ALB,phy_glo)
-#endif
-        if(ierr.ne.NF_NOERR) then
-          write(*,*) "writelim error with phy_alb"
-          write(*,*) NF_STRERROR(ierr)
-        endif
-      endif
-
-      call gather(phy_rug,phy_glo)
-      if (is_mpi_root.and.is_omp_root) then
-#ifdef NC_DOUBLE
-        ierr=NF_PUT_VAR_DOUBLE(nid,id_RUG,phy_glo)
-#else
-        ierr=NF_PUT_VAR_REAL(nid,id_RUG,phy_glo)
-#endif
-        if(ierr.ne.NF_NOERR) then
-          write(*,*) "writelim error with phy_rug"
-          write(*,*) NF_STRERROR(ierr)
-        endif
-      endif
-
-      call gather(phy_fter,phy_glo)
-      if (is_mpi_root.and.is_omp_root) then
-#ifdef NC_DOUBLE
-        ierr=NF_PUT_VAR_DOUBLE(nid,id_FTER,phy_glo)
-#else
-        ierr=NF_PUT_VAR_REAL(nid,id_FTER,phy_glo)
-#endif
-        if(ierr.ne.NF_NOERR) then
-          write(*,*) "writelim error with phy_fter"
-          write(*,*) NF_STRERROR(ierr)
-        endif
-      endif
-
-      call gather(phy_foce,phy_glo)
-      if (is_mpi_root.and.is_omp_root) then
-#ifdef NC_DOUBLE
-        ierr=NF_PUT_VAR_DOUBLE(nid,id_FOCE,phy_glo)
-#else
-        ierr=NF_PUT_VAR_REAL(nid,id_FOCE,phy_glo)
-#endif
-        if(ierr.ne.NF_NOERR) then
-          write(*,*) "writelim error with phy_foce"
-          write(*,*) NF_STRERROR(ierr)
-        endif
-      endif
-
-      call gather(phy_fsic,phy_glo)
-      if (is_mpi_root.and.is_omp_root) then
-#ifdef NC_DOUBLE
-        ierr=NF_PUT_VAR_DOUBLE(nid,id_FSIC,phy_glo)
-#else
-        ierr=NF_PUT_VAR_REAL(nid,id_FSIC,phy_glo)
-#endif
-        if(ierr.ne.NF_NOERR) then
-          write(*,*) "writelim error with phy_fsic"
-          write(*,*) NF_STRERROR(ierr)
-        endif
-      endif
-
-      call gather(phy_flic,phy_glo)
-      if (is_mpi_root.and.is_omp_root) then
-#ifdef NC_DOUBLE
-        ierr=NF_PUT_VAR_DOUBLE(nid,id_FLIC,phy_glo)
-#else
-        ierr=NF_PUT_VAR_REAL(nid,id_FLIC,phy_glo)
-#endif
-        if(ierr.ne.NF_NOERR) then
-          write(*,*) "writelim error with phy_flic"
-          write(*,*) NF_STRERROR(ierr)
-        endif
-      endif
-
-!  close file:
-      if (is_mpi_root.and.is_omp_root) then
-        ierr = NF_CLOSE(nid)
-      endif
-
-      end
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-      SUBROUTINE profil_sst(nlon, rlatd, type_profil, phy_sst)
-      use dimphy
-      IMPLICIT none
-c
-      INTEGER nlon, type_profil, i, k, j
-      REAL :: rlatd(nlon), phy_sst(nlon, 360) 
-      INTEGER imn, imx, amn, amx, kmn, kmx
-      INTEGER p, pplus, nlat_max
-      parameter (nlat_max=72)
-      REAL x_anom_sst(nlat_max)
-c
-      if (klon.ne.nlon) stop'probleme de dimensions dans iniaqua'
-      do i=1,360
-c      phy_sst(:,i) = 260.+50.*cos(rlatd(:))**2
-
-c Rajout fbrlmd
-
-      if(type_profil.EQ.1)then
-c     Méthode 1 "Control" faible plateau à l'Equateur
-      do j=1,klon
-       phy_sst(j,i)=273.+27.*(1-sin(1.5*rlatd(j))**2)
-c        PI/3=1.047197551
-      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.
-        endif
-      enddo
-      endif
-      if(type_profil.EQ.2)then
-c     Méthode 2 "Flat" fort plateau à l'Equateur
-      do j=1,klon
-       phy_sst(j,i)=273.+27.*(1-sin(1.5*rlatd(j))**4)
-      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.
-        endif
-      enddo
-      endif
-
-
-      if (type_profil.EQ.3) then
-c     Méthode 3 "Qobs" plateau réel à l'Equateur
-      do j=1,klon
-        phy_sst(j,i)=273.+0.5*27.*(2-sin(1.5*rlatd(j))**2
-     &                 -sin(1.5*rlatd(j))**4)
-      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.
-        endif
-      enddo
-      endif
-
-      if (type_profil.EQ.4) then
-c     Méthode 4 : Méthode 3 + SST+2 "Qobs" plateau réel à l'Equateur
-      do j=1,klon
-        phy_sst(j,i)=273.+0.5*29.*(2-sin(1.5*rlatd(j))**2
-     &                 -sin(1.5*rlatd(j))**4)
-      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.
-        endif
-      enddo
-      endif
-
-      if (type_profil.EQ.5) then
-c     Méthode 5 : Méthode 3 + +2K "Qobs" plateau réel à l'Equateur
-      do j=1,klon
-        phy_sst(j,i)=273.+2.+0.5*27.*(2-sin(1.5*rlatd(j))**2
-     &                 -sin(1.5*rlatd(j))**4)
-      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.+2.
-        endif
-
-      enddo
-      endif
-
-      if(type_profil.EQ.6)then
-c     Méthode 6 "cst" valeur constante de SST
-      do j=1,klon
-       phy_sst(j,i)=288.
-      enddo
-      endif
-
-
-        if(type_profil.EQ.7)then
-c     Méthode 7 "cst" valeur constante de SST +2
-      do j=1,klon
-       phy_sst(j,i)=288.+2.
-      enddo
-      endif
-
-        p=0
-        if(type_profil.EQ.8)then
-c     Méthode 8 profil anomalies SST du modèle couplé AR4
-       do j=1,klon
-         if (rlatd(j).EQ.rlatd(j-1)) then
-       phy_sst(j,i)=273.+x_anom_sst(pplus)
-     &     +0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5*rlatd(j))**4)
-          if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-            phy_sst(j,i)=273.+x_anom_sst(pplus)
-          endif
-        else
-          p=p+1
-          pplus=73-p
-        phy_sst(j,i)=273.+x_anom_sst(pplus)
-     &     +0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5*rlatd(j))**4)
-          if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-            phy_sst(j,i)=273.+x_anom_sst(pplus)
-          endif
-          write (*,*) rlatd(j),x_anom_sst(pplus),phy_sst(j,i)
-        endif
-      enddo
-      endif
-
-      if (type_profil.EQ.9) then
-c     Méthode 5 : Méthode 3 + -2K "Qobs" plateau réel à l'Equateur
-      do j=1,klon
-        phy_sst(j,i)=273.-2.+0.5*27.*(2-sin(1.5*rlatd(j))**2
-     &                 -sin(1.5*rlatd(j))**4)
-      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.-2.
-        endif
-      enddo
-      endif
-
-
-      if (type_profil.EQ.10) then
-c     Méthode 10 : Méthode 3 + +4K "Qobs" plateau réel à l'Equateur
-      do j=1,klon
-        phy_sst(j,i)=273.+4.+0.5*27.*(2-sin(1.5*rlatd(j))**2
-     &                 -sin(1.5*rlatd(j))**4)
-        if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.+4.
-        endif
-      enddo
-      endif
-
-      if (type_profil.EQ.11) then
-c     Méthode 11 : Méthode 3 + 4CO2 "Qobs" plateau réel à l'Equateur
-      do j=1,klon
-        phy_sst(j,i)=273.+0.5*27.*(2-sin(1.5*rlatd(j))**2
-     &                 -sin(1.5*rlatd(j))**4)
-        if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.
-        endif
-      enddo
-      endif
-
-      if (type_profil.EQ.12) then
-c     Méthode 12 : Méthode 10 + 4CO2 "Qobs" plateau réel à l'Equateur
-      do j=1,klon
-        phy_sst(j,i)=273.+4.+0.5*27.*(2-sin(1.5*rlatd(j))**2
-     &                 -sin(1.5*rlatd(j))**4)
-        if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.+4.
-        endif
-      enddo
-      endif
-
-      if (type_profil.EQ.13) then
-c     Méthode 13 "Qmax" plateau réel à l'Equateur augmenté !
-      do j=1,klon
-        phy_sst(j,i)=273.+0.5*29.*(2-sin(1.5*rlatd(j))**2
-     &                 -sin(1.5*rlatd(j))**4)
-      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.
-        endif
-      enddo
-      endif
-
-      if (type_profil.EQ.14) then
-c     Méthode 13 "Qmax2K" plateau réel à l'Equateur augmenté +2K !
-      do j=1,klon
-        phy_sst(j,i)=273.+2.+0.5*29.*(2-sin(1.5*rlatd(j))**2
-     &                 -sin(1.5*rlatd(j))**4)
-      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
-         phy_sst(j,i)=273.
-        endif
-      enddo
-      endif
-
-      enddo
-
-cIM beg : verif profil SST: phy_sst
-       amn=MIN(phy_sst(1,1),1000.)
-       amx=MAX(phy_sst(1,1),-1000.)
-       DO k=1, 360
-       DO i=2, nlon
-        IF(phy_sst(i,k).LT.amn) THEN
-         amn=phy_sst(i,k)
-         imn=i
-         kmn=k
-        ENDIF
-        IF(phy_sst(i,k).GT.amx) THEN
-         amx=phy_sst(i,k)
-         imx=i
-         kmx=k
-        ENDIF
-       ENDDO
-       ENDDO
-c
-       PRINT*,' debut avant writelim min max phy_sst',imn,kmn,amn,
-     & imx,kmx,amx
-cIM end : verif profil SST: phy_sst
-
-       return 
-       end
Index: LMDZ5/branches/testing/libf/phylmd/phyaqua_mod.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phyaqua_mod.F	(revision 1864)
+++ LMDZ5/branches/testing/libf/phylmd/phyaqua_mod.F	(revision 1864)
@@ -0,0 +1,930 @@
+      module phyaqua_mod
+! Routines complementaires pour la physique planetaire.
+      implicit none
+
+      contains
+
+      subroutine iniaqua(nlon,latfi,lonfi,iflag_phys)
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!  Creation d'un etat initial et de conditions aux limites 
+!  (resp startphy.nc et limit.nc) pour des configurations idealisees 
+! du modele LMDZ dans sa version terrestre.
+!  iflag_phys est un parametre qui controle
+!  iflag_phys = N  
+!    de 100 a 199 : aqua planetes avec SST forcees
+!                 N-100 determine le type de SSTs
+!    de 200 a 299 : terra planetes avec Ts calcule
+!        
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+      USE comgeomphy, only : rlatd,rlond
+      USE dimphy, only : klon
+      USE surface_data, only : type_ocean,ok_veget
+      USE pbl_surface_mod, only : pbl_surface_init
+      USE fonte_neige_mod, only : fonte_neige_init
+      USE phys_state_var_mod
+      USE control_mod, only : dayref,nday,iphysiq
+      USE indice_sol_mod
+
+      USE IOIPSL 
+      IMPLICIT NONE
+
+#include "dimensions.h"
+!   #include "dimphy.h"
+!   #include "YOMCST.h"
+#include "comconst.h"
+#include "clesphys.h"
+#include "dimsoil.h"
+#include "temps.h"
+
+      integer,intent(in) :: nlon,iflag_phys
+cIM ajout latfi, lonfi
+      real,intent(in) :: lonfi(nlon),latfi(nlon)
+
+      INTEGER type_profil,type_aqua
+
+c  Ajouts initialisation des surfaces
+      REAL :: run_off_lic_0(nlon)
+      REAL :: qsolsrf(nlon,nbsrf),snsrf(nlon,nbsrf)
+      REAL :: frugs(nlon,nbsrf)
+      REAL :: agesno(nlon,nbsrf)
+      REAL :: tsoil(nlon,nsoilmx,nbsrf)
+      REAL :: tslab(nlon), seaice(nlon)
+      REAL evap(nlon,nbsrf),fder(nlon)
+
+
+
+c    Arguments :
+c    -----------
+
+!      integer radpas  
+      integer it,unit,i,k,itap
+
+      real airefi,zcufi,zcvfi
+
+      real rugos,albedo
+      REAL tsurf
+      REAL time,timestep,day,day0
+      real qsol_f,qsol(nlon)
+      real rugsrel(nlon)
+!      real zmea(nlon),zstd(nlon),zsig(nlon)
+!      real zgam(nlon),zthe(nlon),zpic(nlon),zval(nlon)
+!      real rlon(nlon),rlat(nlon)
+      logical alb_ocean
+!      integer demih_pas
+
+      CHARACTER*80 ans,file_forctl, file_fordat, file_start
+      character*100 file,var
+      character*2 cnbl
+
+      REAL phy_nat(nlon,360)
+      REAL phy_alb(nlon,360)
+      REAL phy_sst(nlon,360)
+      REAL phy_bil(nlon,360)
+      REAL phy_rug(nlon,360)
+      REAL phy_ice(nlon,360)
+      REAL phy_fter(nlon,360)
+      REAL phy_foce(nlon,360)
+      REAL phy_fsic(nlon,360)
+      REAL phy_flic(nlon,360)
+
+      integer, save::  read_climoz=0 ! read ozone climatology
+
+! intermediate variables to use getin (need to be "save" to be shared by all threads)
+      integer,save :: nbapp_rad_omp
+      real,save :: co2_ppm_omp,solaire_omp
+      logical,save :: alb_ocean_omp
+      real,save :: rugos_omp
+!-------------------------------------------------------------------------
+!  declaration pour l'appel a phyredem
+!-------------------------------------------------------------------------
+
+!      real pctsrf(nlon,nbsrf),ftsol(nlon,nbsrf)
+      real falbe(nlon,nbsrf),falblw(nlon,nbsrf)
+!      real pbl_tke(nlon,llm,nbsrf)
+!      real rain_fall(nlon),snow_fall(nlon)
+!      real solsw(nlon), sollw(nlon),radsol(nlon)
+!      real t_ancien(nlon,llm),q_ancien(nlon,llm),rnebcon(nlon,llm)
+!      real ratqs(nlon,llm)
+!      real clwcon(nlon,llm)
+
+      INTEGER        longcles
+      PARAMETER    ( longcles = 20 )
+      REAL clesphy0( longcles )
+
+
+c-----------------------------------------------------------------------
+c   dynamial tendencies :
+c   ---------------------
+
+      INTEGER l,ierr,aslun
+
+      REAL longitude,latitude
+      REAL paire 
+
+      DATA latitude,longitude/48.,0./
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! INITIALISATIONS
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!-----------------------------------------------------------------------
+!    Initialisations  des constantes
+!    -------------------------------
+
+
+      type_aqua=iflag_phys/100
+      type_profil=iflag_phys-type_aqua*100
+      print*,'iniaqua:type_aqua, type_profil',type_aqua, type_profil
+
+      if (klon.ne.nlon) then
+        write(*,*)"iniaqua: klon=",klon," nlon=",nlon
+        stop'probleme de dimensions dans iniaqua'
+      endif
+      call phys_state_var_init(read_climoz)
+
+
+      read_climoz=0
+      day0=217.
+      day=day0
+      it=0
+      time=0.
+
+cIM ajout latfi, lonfi
+      rlatd=latfi
+      rlond=lonfi
+      rlat=rlatd*180./pi
+      rlon=rlond*180./pi
+
+!-----------------------------------------------------------------------
+!  initialisations de la physique
+!-----------------------------------------------------------------------
+
+         day_ini=dayref
+         day_end=day_ini+nday
+         airefi=1.
+         zcufi=1.
+         zcvfi=1.
+!$OMP MASTER
+      nbapp_rad_omp=24
+      CALL getin('nbapp_rad',nbapp_rad_omp)
+!$OMP END MASTER
+!$OMP BARRIER
+      nbapp_rad=nbapp_rad_omp
+
+!---------------------------------------------------------------------
+c Creation des conditions aux limites:
+c ------------------------------------
+! Initialisations des constantes
+! Ajouter les manquants dans planete.def... (albedo etc)
+!$OMP MASTER
+      co2_ppm_omp=348.
+      CALL getin('co2_ppm',co2_ppm_omp)
+      solaire_omp=1365.
+      CALL getin('solaire',solaire_omp)
+!      CALL getin('albedo',albedo) ! albedo is set below, depending on type_aqua
+      alb_ocean_omp=.true.
+      CALL getin('alb_ocean',alb_ocean_omp)
+!$OMP END MASTER
+!$OMP BARRIER
+      co2_ppm=co2_ppm_omp
+      write(*,*)"iniaqua: co2_ppm=",co2_ppm
+      solaire=solaire_omp
+      write(*,*)"iniaqua: solaire=",solaire
+      alb_ocean=alb_ocean_omp
+      write(*,*)"iniaqua: alb_ocean=",alb_ocean
+
+      radsol=0.
+      qsol_f=10.
+
+c  Conditions aux limites:
+c  -----------------------
+
+      qsol(:)    = qsol_f
+      rugsrel = 0.0    ! (rugsrel = rugoro)
+      rugoro = 0.0
+      u_ancien = 0.0
+      v_ancien = 0.0
+      agesno  = 50.0
+! Relief plat
+      zmea = 0.
+      zstd = 0.
+      zsig = 0.
+      zgam = 0.
+      zthe = 0.
+      zpic = 0.
+      zval = 0.
+
+! Une seule surface
+      pctsrf=0.
+      if (type_aqua==1) then
+         rugos=1.e-4
+         albedo=0.19
+         pctsrf(:,is_oce)=1.
+      else if (type_aqua==2) then
+         rugos=0.03
+         albedo=0.1
+         pctsrf(:,is_ter)=1.
+      endif
+
+!$OMP MASTER
+      rugos_omp=rugos
+      CALL getin('rugos',rugos_omp)
+!$OMP END MASTER
+!$OMP BARRIER
+      rugos=rugos_omp
+      write(*,*) "iniaqua: rugos=",rugos
+      zmasq(:)=pctsrf(:,is_oce)
+
+! pctsrf_pot(:,is_oce) = 1. - zmasq(:)
+! pctsrf_pot(:,is_sic) = 1. - zmasq(:)
+
+! Si alb_ocean on calcule un albedo oceanique moyen
+!  if (alb_ocean) then
+! Voir pourquoi on avait ca.
+!          CALL ini_alb_oce(phy_alb)
+!      else 
+      phy_alb(:,:) = albedo ! albedo land only (old value condsurf_jyg=0.3)
+!      endif !alb_ocean
+      
+      do i=1,360
+cIM Terraplanete   phy_sst(:,i) = 260.+50.*cos(rlatd(:))**2
+cIM ajout calcul profil sst selon le cas considere (cf. FBr)
+
+      phy_nat(:,i) = 1.0    ! 0=ocean libre, 1=land, 2=glacier, 3=banquise
+      phy_bil(:,i) = 1.0    ! ne sert que pour les slab_ocean
+      phy_rug(:,i) = rugos  ! longueur rugosite utilisee sur land only 
+      phy_ice(:,i) = 0.0    ! fraction de glace (?)
+      phy_fter(:,i) = pctsrf(:,is_ter)  ! fraction de glace (?)
+      phy_foce(:,i) = pctsrf(:,is_oce)  ! fraction de glace (?)
+      phy_fsic(:,i) = pctsrf(:,is_sic)  ! fraction de glace (?)
+      phy_flic(:,i) = pctsrf(:,is_lic)  ! fraction de glace (?)
+      enddo
+cIM calcul profil sst
+      call profil_sst(nlon, rlatd, type_profil, phy_sst)
+
+      call writelim
+     s   (klon,phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,phy_ice,
+     s    phy_fter,phy_foce,phy_flic,phy_fsic)
+
+
+!---------------------------------------------------------------------
+c Ecriture de l'etat initial:
+c ---------------------------
+
+C
+C Ecriture etat initial physique
+C
+      timestep   = dtvr * FLOAT(iphysiq)
+      radpas    = NINT (daysec/timestep/ FLOAT(nbapp_rad) )
+
+      DO i = 1, longcles
+       clesphy0(i) = 0.
+      ENDDO
+      clesphy0(1) = FLOAT( iflag_con )
+      clesphy0(2) = FLOAT( nbapp_rad )
+c     IF( cycle_diurne  ) clesphy0(3) =  1. 
+      clesphy0(3)=1. ! cycle_diurne
+      clesphy0(4)=1. ! soil_model
+      clesphy0(5)=1. ! new_oliq
+      clesphy0(6)=0. ! ok_orodr
+      clesphy0(7)=0. ! ok_orolf
+      clesphy0(8)=0. ! ok_limitvrai
+
+
+c=======================================================================
+c  Profils initiaux
+c=======================================================================
+
+! On initialise les temperatures de surfaces comme les sst
+      do i=1,nlon
+         ftsol(i,:)=phy_sst(i,1)
+         tsoil(i,:,:)=phy_sst(i,1)
+         tslab(i)=phy_sst(i,1)
+      enddo
+
+      falbe(:,:)=albedo
+      falblw(:,:)=albedo
+      rain_fall(:)=0.
+      snow_fall(:)=0.
+      solsw(:)=0.
+      sollw(:)=0.
+      radsol(:)=0.
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!  intialisation bidon mais pas grave
+      t_ancien(:,:)=0.
+      q_ancien(:,:)=0.
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      rnebcon=0.
+      ratqs=0.
+      clwcon=0.
+      pbl_tke=1.e-8
+
+! variables supplementaires pour appel a plb_surface_init
+      fder(:)=0.
+      seaice(:)=0.
+      run_off_lic_0=0.
+      evap=0.
+
+
+! Initialisations necessaires avant phyredem
+      type_ocean = "force"
+      call fonte_neige_init(run_off_lic_0)
+      qsolsrf(:,:)=qsol(1) ! humidite du sol des sous surface
+      snsrf(:,:)=0.        ! couverture de neige des sous surface
+      frugs(:,:)=rugos        ! couverture de neige des sous surface
+
+
+      call pbl_surface_init(qsol, fder, snsrf, qsolsrf,
+     .     evap, frugs, agesno, tsoil)
+
+        print*,'iniaqua: before phyredem'
+
+      falb1=albedo
+      falb2=albedo
+      zmax0=0.
+      f0=0.
+      sig1=0.
+      w01=0.
+      wake_deltat=0.
+      wake_deltaq=0.
+      wake_s=0.
+      wake_cstar=0.
+      wake_pe=0.
+      wake_fip=0.
+      fm_therm=0.
+      entr_therm=0.
+      detr_therm=0.
+
+
+      CALL phyredem ("startphy.nc")
+
+        print*,'iniaqua: after phyredem'
+      call phys_state_var_end
+
+      return
+      end subroutine iniaqua
+
+
+c====================================================================
+c====================================================================
+      SUBROUTINE zenang_an(cycle_diurne,gmtime,rlat,rlon,rmu0,fract)
+      USE dimphy
+      IMPLICIT none
+c====================================================================
+c=============================================================
+c         CALL zenang(cycle_diurne,gmtime,rlat,rlon,rmu0,fract)
+c Auteur : A. Campoy et F. Hourdin
+c Objet  : calculer les valeurs moyennes du cos de l'angle zenithal
+c          et l'ensoleillement moyen entre gmtime1 et gmtime2 
+c          connaissant la declinaison, la latitude et la longitude.
+c 
+c   Dans cette version particuliere, on calcule le rayonnement
+c  moyen sur l'année à chaque latitude.
+c   angle zenithal calculé pour obtenir un 
+c   Fit polynomial de  l'ensoleillement moyen au sommet de l'atmosphere
+c   en moyenne annuelle.
+c   Spécifique de la terre. Utilisé pour les aqua planetes.
+c
+c Rque   : Different de la routine angle en ce sens que zenang 
+c          fournit des moyennes de pmu0 et non des valeurs 
+c          instantanees, du coup frac prend toutes les valeurs 
+c          entre 0 et 1.
+c Date   : premiere version le 13 decembre 1994
+c          revu pour  GCM  le 30 septembre 1996
+c===============================================================
+c longi----INPUT : la longitude vraie de la terre dans son plan
+c                  solaire a partir de l'equinoxe de printemps (degre)
+c gmtime---INPUT : temps universel en fraction de jour
+c pdtrad---INPUT : pas de temps du rayonnement (secondes)
+c lat------INPUT : latitude en degres
+c long-----INPUT : longitude en degres
+c pmu0-----OUTPUT: angle zenithal moyen entre gmtime et gmtime+pdtrad
+c frac-----OUTPUT: ensoleillement moyen entre gmtime et gmtime+pdtrad
+c================================================================
+#include "YOMCST.h"
+c================================================================
+      logical cycle_diurne
+      real  gmtime
+      real rlat(klon), rlon(klon), rmu0(klon), fract(klon)
+c================================================================
+      integer i
+      real gmtime1, gmtime2
+      real pi_local
+
+
+      real rmu0m(klon),rmu0a(klon)
+c
+
+      pi_local = 4.0 * ATAN(1.0)
+
+c================================================================
+c  Calcul de l'angle zenithal moyen sur la journee
+c================================================================
+
+      DO i=1,klon
+        fract(i)=1. 
+!  Calcule du flux moyen
+        IF (abs(rlat(i)).LE.28.75) THEN
+           rmu0m(i)=(210.1924+206.6059*cos(0.0174533*rlat(i))**2)/1365.
+        ELSEIF (abs(rlat(i)).LE.43.75) THEN
+          rmu0m(i)=(187.4562+236.1853*cos(0.0174533*rlat(i))**2)/1365.
+        ELSEIF (abs(rlat(i)).LE.71.25) THEN
+          rmu0m(i)=(162.4439+284.1192*cos(0.0174533*rlat(i))**2)/1365.
+        ELSE
+          rmu0m(i)=(172.8125+183.7673*cos(0.0174533*rlat(i))**2)/1365.
+        ENDIF
+      ENDDO
+
+c================================================================
+!  Avec ou sans cycle diurne
+c================================================================
+
+      IF (cycle_diurne) THEN
+
+!  On redecompose flux  au sommet suivant un cycle diurne idealise
+!  identique a toutes les latitudes.
+
+         DO i=1,klon
+           rmu0a(i)=2.*rmu0m(i)*sqrt(2.)*pi_local/(4.-pi_local)
+           rmu0(i)=rmu0a(i)*abs(sin(pi_local*gmtime+pi_local*
+     &      rlon(i)/360.))-rmu0a(i)/sqrt(2.)
+         ENDDO
+
+         DO i=1,klon
+           IF (rmu0(i).LE.0.) THEN
+              rmu0(i)=0.
+              fract(i)=0.
+           ELSE
+              fract(i)=1.
+           ENDIF
+         ENDDO
+
+!  Affichage de l'angel zenitale
+!     print*,'************************************'
+!     print*,'************************************'
+!     print*,'************************************'
+!     print*,'latitude=',rlat(i),'longitude=',rlon(i)
+!     print*,'rmu0m=',rmu0m(i)
+!     print*,'rmu0a=',rmu0a(i)
+!     print*,'rmu0=',rmu0(i)
+                                                               
+      ELSE
+
+        DO i=1,klon
+           fract(i)=0.5
+           rmu0(i)=rmu0m(i)*2.
+        ENDDO
+
+      ENDIF
+
+      RETURN
+      END subroutine zenang_an
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+      subroutine writelim
+     s   (klon,phy_nat,phy_alb,phy_sst,phy_bil,phy_rug,phy_ice,
+     s    phy_fter,phy_foce,phy_flic,phy_fsic)
+c
+      use mod_phys_lmdz_para, only: is_mpi_root,is_omp_root
+      use mod_grid_phy_lmdz, only : klon_glo
+      use mod_phys_lmdz_transfert_para, only : gather
+      implicit none
+!#include "dimensions.h"
+!#include "dimphy.h"
+#include "netcdf.inc"
+ 
+      integer,intent(in) :: klon
+      real,intent(in) :: phy_nat(klon,360)
+      real,intent(in) :: phy_alb(klon,360)
+      real,intent(in) :: phy_sst(klon,360)
+      real,intent(in) :: phy_bil(klon,360)
+      real,intent(in) :: phy_rug(klon,360)
+      real,intent(in) :: phy_ice(klon,360)
+      real,intent(in) :: phy_fter(klon,360)
+      real,intent(in) :: phy_foce(klon,360)
+      real,intent(in) :: phy_flic(klon,360)
+      real,intent(in) :: phy_fsic(klon,360)
+
+      real :: phy_glo(klon_glo,360) ! temporary variable, to store phy_***(:)
+                                    ! on the whole physics grid 
+      integer :: k
+      INTEGER ierr
+      INTEGER dimfirst(3)
+      INTEGER dimlast(3)
+c
+      INTEGER nid, ndim, ntim
+      INTEGER dims(2), debut(2), epais(2)
+      INTEGER id_tim
+      INTEGER id_NAT, id_SST, id_BILS, id_RUG, id_ALB
+      INTEGER id_FTER,id_FOCE,id_FSIC,id_FLIC
+ 
+      if (is_mpi_root.and.is_omp_root) then
+      
+        PRINT*, 'writelim: Ecriture du fichier limit'
+c
+        ierr = NF_CREATE ("limit.nc", NF_CLOBBER, nid)
+c
+        ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 30,
+     .                       "Fichier conditions aux limites")
+!!        ierr = NF_DEF_DIM (nid, "points_physiques", klon, ndim)
+        ierr = NF_DEF_DIM (nid, "points_physiques", klon_glo, ndim)
+        ierr = NF_DEF_DIM (nid, "time", NF_UNLIMITED, ntim)
+c
+        dims(1) = ndim
+        dims(2) = ntim
+c
+ccc      ierr = NF_DEF_VAR (nid, "TEMPS", NF_DOUBLE, 1,ntim, id_tim)
+        ierr = NF_DEF_VAR (nid, "TEMPS", NF_FLOAT, 1,ntim, id_tim)
+        ierr = NF_PUT_ATT_TEXT (nid, id_tim, "title", 17,
+     .                        "Jour dans l annee")
+ccc      ierr = NF_DEF_VAR (nid, "NAT", NF_DOUBLE, 2,dims, id_NAT)
+        ierr = NF_DEF_VAR (nid, "NAT", NF_FLOAT, 2,dims, id_NAT)
+        ierr = NF_PUT_ATT_TEXT (nid, id_NAT, "title", 23,
+     .                        "Nature du sol (0,1,2,3)")
+ccc      ierr = NF_DEF_VAR (nid, "SST", NF_DOUBLE, 2,dims, id_SST)
+        ierr = NF_DEF_VAR (nid, "SST", NF_FLOAT, 2,dims, id_SST)
+        ierr = NF_PUT_ATT_TEXT (nid, id_SST, "title", 35,
+     .                        "Temperature superficielle de la mer")
+ccc      ierr = NF_DEF_VAR (nid, "BILS", NF_DOUBLE, 2,dims, id_BILS)
+        ierr = NF_DEF_VAR (nid, "BILS", NF_FLOAT, 2,dims, id_BILS)
+        ierr = NF_PUT_ATT_TEXT (nid, id_BILS, "title", 32,
+     .                        "Reference flux de chaleur au sol")
+ccc      ierr = NF_DEF_VAR (nid, "ALB", NF_DOUBLE, 2,dims, id_ALB)
+        ierr = NF_DEF_VAR (nid, "ALB", NF_FLOAT, 2,dims, id_ALB)
+        ierr = NF_PUT_ATT_TEXT (nid, id_ALB, "title", 19,
+     .                        "Albedo a la surface")
+ccc      ierr = NF_DEF_VAR (nid, "RUG", NF_DOUBLE, 2,dims, id_RUG)
+        ierr = NF_DEF_VAR (nid, "RUG", NF_FLOAT, 2,dims, id_RUG)
+        ierr = NF_PUT_ATT_TEXT (nid, id_RUG, "title", 8,
+     .                        "Rugosite")
+
+        ierr = NF_DEF_VAR (nid, "FTER", NF_FLOAT, 2,dims, id_FTER)
+        ierr = NF_PUT_ATT_TEXT (nid, id_FTER, "title", 8,"Frac. Terre")
+        ierr = NF_DEF_VAR (nid, "FOCE", NF_FLOAT, 2,dims, id_FOCE)
+        ierr = NF_PUT_ATT_TEXT (nid, id_FOCE, "title", 8,"Frac. Terre")
+        ierr = NF_DEF_VAR (nid, "FSIC", NF_FLOAT, 2,dims, id_FSIC)
+        ierr = NF_PUT_ATT_TEXT (nid, id_FSIC, "title", 8,"Frac. Terre")
+        ierr = NF_DEF_VAR (nid, "FLIC", NF_FLOAT, 2,dims, id_FLIC)
+        ierr = NF_PUT_ATT_TEXT (nid, id_FLIC, "title", 8,"Frac. Terre")
+c
+        ierr = NF_ENDDEF(nid)
+        if (ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error: failed to end define mode"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+c
+
+! write the 'times'
+        do k=1,360
+#ifdef NC_DOUBLE
+          ierr = NF_PUT_VAR1_DOUBLE (nid,id_tim,k,DBLE(k))
+#else
+          ierr = NF_PUT_VAR1_REAL (nid,id_tim,k,FLOAT(k))
+#endif
+         if (ierr.ne.NF_NOERR) then
+           write(*,*) "writelim error with temps(k),k=",k
+           write(*,*) NF_STRERROR(ierr)
+         endif
+        enddo
+
+      endif ! of if (is_mpi_root.and.is_omp_root)
+
+! write the fields, after having collected them on master
+
+      call gather(phy_nat,phy_glo)
+      if (is_mpi_root.and.is_omp_root) then
+#ifdef NC_DOUBLE
+        ierr=NF_PUT_VAR_DOUBLE(nid,id_NAT,phy_glo)
+#else
+        ierr=NF_PUT_VAR_REAL(nid,id_NAT,phy_glo)
+#endif
+        if(ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error with phy_nat"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+      endif
+
+      call gather(phy_sst,phy_glo)
+      if (is_mpi_root.and.is_omp_root) then
+#ifdef NC_DOUBLE
+        ierr=NF_PUT_VAR_DOUBLE(nid,id_SST,phy_glo)
+#else
+        ierr=NF_PUT_VAR_REAL(nid,id_SST,phy_glo)
+#endif
+        if(ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error with phy_sst"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+      endif
+
+      call gather(phy_bil,phy_glo)
+      if (is_mpi_root.and.is_omp_root) then
+#ifdef NC_DOUBLE
+        ierr=NF_PUT_VAR_DOUBLE(nid,id_BILS,phy_glo)
+#else
+        ierr=NF_PUT_VAR_REAL(nid,id_BILS,phy_glo)
+#endif
+        if(ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error with phy_bil"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+      endif
+
+      call gather(phy_alb,phy_glo)
+      if (is_mpi_root.and.is_omp_root) then
+#ifdef NC_DOUBLE
+        ierr=NF_PUT_VAR_DOUBLE(nid,id_ALB,phy_glo)
+#else
+        ierr=NF_PUT_VAR_REAL(nid,id_ALB,phy_glo)
+#endif
+        if(ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error with phy_alb"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+      endif
+
+      call gather(phy_rug,phy_glo)
+      if (is_mpi_root.and.is_omp_root) then
+#ifdef NC_DOUBLE
+        ierr=NF_PUT_VAR_DOUBLE(nid,id_RUG,phy_glo)
+#else
+        ierr=NF_PUT_VAR_REAL(nid,id_RUG,phy_glo)
+#endif
+        if(ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error with phy_rug"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+      endif
+
+      call gather(phy_fter,phy_glo)
+      if (is_mpi_root.and.is_omp_root) then
+#ifdef NC_DOUBLE
+        ierr=NF_PUT_VAR_DOUBLE(nid,id_FTER,phy_glo)
+#else
+        ierr=NF_PUT_VAR_REAL(nid,id_FTER,phy_glo)
+#endif
+        if(ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error with phy_fter"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+      endif
+
+      call gather(phy_foce,phy_glo)
+      if (is_mpi_root.and.is_omp_root) then
+#ifdef NC_DOUBLE
+        ierr=NF_PUT_VAR_DOUBLE(nid,id_FOCE,phy_glo)
+#else
+        ierr=NF_PUT_VAR_REAL(nid,id_FOCE,phy_glo)
+#endif
+        if(ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error with phy_foce"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+      endif
+
+      call gather(phy_fsic,phy_glo)
+      if (is_mpi_root.and.is_omp_root) then
+#ifdef NC_DOUBLE
+        ierr=NF_PUT_VAR_DOUBLE(nid,id_FSIC,phy_glo)
+#else
+        ierr=NF_PUT_VAR_REAL(nid,id_FSIC,phy_glo)
+#endif
+        if(ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error with phy_fsic"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+      endif
+
+      call gather(phy_flic,phy_glo)
+      if (is_mpi_root.and.is_omp_root) then
+#ifdef NC_DOUBLE
+        ierr=NF_PUT_VAR_DOUBLE(nid,id_FLIC,phy_glo)
+#else
+        ierr=NF_PUT_VAR_REAL(nid,id_FLIC,phy_glo)
+#endif
+        if(ierr.ne.NF_NOERR) then
+          write(*,*) "writelim error with phy_flic"
+          write(*,*) NF_STRERROR(ierr)
+        endif
+      endif
+
+!  close file:
+      if (is_mpi_root.and.is_omp_root) then
+        ierr = NF_CLOSE(nid)
+      endif
+
+      end subroutine writelim 
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+      SUBROUTINE profil_sst(nlon, rlatd, type_profil, phy_sst)
+      use dimphy
+      IMPLICIT none
+c
+      INTEGER nlon, type_profil, i, k, j
+      REAL :: rlatd(nlon), phy_sst(nlon, 360) 
+      INTEGER imn, imx, amn, amx, kmn, kmx
+      INTEGER p, pplus, nlat_max
+      parameter (nlat_max=72)
+      REAL x_anom_sst(nlat_max)
+c
+      if (klon.ne.nlon) stop'probleme de dimensions dans iniaqua'
+      write(*,*)" profil_sst: type_profil=",type_profil
+      do i=1,360
+c      phy_sst(:,i) = 260.+50.*cos(rlatd(:))**2
+
+c Rajout fbrlmd
+
+      if(type_profil.EQ.1)then
+c     Méthode 1 "Control" faible plateau à l'Equateur
+      do j=1,klon
+       phy_sst(j,i)=273.+27.*(1-sin(1.5*rlatd(j))**2)
+c        PI/3=1.047197551
+      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.
+        endif
+      enddo
+      endif
+      if(type_profil.EQ.2)then
+c     Méthode 2 "Flat" fort plateau à l'Equateur
+      do j=1,klon
+       phy_sst(j,i)=273.+27.*(1-sin(1.5*rlatd(j))**4)
+      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.
+        endif
+      enddo
+      endif
+
+
+      if (type_profil.EQ.3) then
+c     Méthode 3 "Qobs" plateau réel à l'Equateur
+      do j=1,klon
+        phy_sst(j,i)=273.+0.5*27.*(2-sin(1.5*rlatd(j))**2
+     &                 -sin(1.5*rlatd(j))**4)
+      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.
+        endif
+      enddo
+      endif
+
+      if (type_profil.EQ.4) then
+c     Méthode 4 : Méthode 3 + SST+2 "Qobs" plateau réel à l'Equateur
+      do j=1,klon
+        phy_sst(j,i)=273.+0.5*29.*(2-sin(1.5*rlatd(j))**2
+     &                 -sin(1.5*rlatd(j))**4)
+      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.
+        endif
+      enddo
+      endif
+
+      if (type_profil.EQ.5) then
+c     Méthode 5 : Méthode 3 + +2K "Qobs" plateau réel à l'Equateur
+      do j=1,klon
+        phy_sst(j,i)=273.+2.+0.5*27.*(2-sin(1.5*rlatd(j))**2
+     &                 -sin(1.5*rlatd(j))**4)
+      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.+2.
+        endif
+
+      enddo
+      endif
+
+      if(type_profil.EQ.6)then
+c     Méthode 6 "cst" valeur constante de SST
+      do j=1,klon
+       phy_sst(j,i)=288.
+      enddo
+      endif
+
+
+        if(type_profil.EQ.7)then
+c     Méthode 7 "cst" valeur constante de SST +2
+      do j=1,klon
+       phy_sst(j,i)=288.+2.
+      enddo
+      endif
+
+        p=0
+        if(type_profil.EQ.8)then
+c     Méthode 8 profil anomalies SST du modèle couplé AR4
+       do j=1,klon
+         if (rlatd(j).EQ.rlatd(j-1)) then
+       phy_sst(j,i)=273.+x_anom_sst(pplus)
+     &     +0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5*rlatd(j))**4)
+          if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+            phy_sst(j,i)=273.+x_anom_sst(pplus)
+          endif
+        else
+          p=p+1
+          pplus=73-p
+        phy_sst(j,i)=273.+x_anom_sst(pplus)
+     &     +0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5*rlatd(j))**4)
+          if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+            phy_sst(j,i)=273.+x_anom_sst(pplus)
+          endif
+          write (*,*) rlatd(j),x_anom_sst(pplus),phy_sst(j,i)
+        endif
+      enddo
+      endif
+
+      if (type_profil.EQ.9) then
+c     Méthode 5 : Méthode 3 + -2K "Qobs" plateau réel à l'Equateur
+      do j=1,klon
+        phy_sst(j,i)=273.-2.+0.5*27.*(2-sin(1.5*rlatd(j))**2
+     &                 -sin(1.5*rlatd(j))**4)
+      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.-2.
+        endif
+      enddo
+      endif
+
+
+      if (type_profil.EQ.10) then
+c     Méthode 10 : Méthode 3 + +4K "Qobs" plateau réel à l'Equateur
+      do j=1,klon
+        phy_sst(j,i)=273.+4.+0.5*27.*(2-sin(1.5*rlatd(j))**2
+     &                 -sin(1.5*rlatd(j))**4)
+        if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.+4.
+        endif
+      enddo
+      endif
+
+      if (type_profil.EQ.11) then
+c     Méthode 11 : Méthode 3 + 4CO2 "Qobs" plateau réel à l'Equateur
+      do j=1,klon
+        phy_sst(j,i)=273.+0.5*27.*(2-sin(1.5*rlatd(j))**2
+     &                 -sin(1.5*rlatd(j))**4)
+        if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.
+        endif
+      enddo
+      endif
+
+      if (type_profil.EQ.12) then
+c     Méthode 12 : Méthode 10 + 4CO2 "Qobs" plateau réel à l'Equateur
+      do j=1,klon
+        phy_sst(j,i)=273.+4.+0.5*27.*(2-sin(1.5*rlatd(j))**2
+     &                 -sin(1.5*rlatd(j))**4)
+        if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.+4.
+        endif
+      enddo
+      endif
+
+      if (type_profil.EQ.13) then
+c     Méthode 13 "Qmax" plateau réel à l'Equateur augmenté !
+      do j=1,klon
+        phy_sst(j,i)=273.+0.5*29.*(2-sin(1.5*rlatd(j))**2
+     &                 -sin(1.5*rlatd(j))**4)
+      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.
+        endif
+      enddo
+      endif
+
+      if (type_profil.EQ.14) then
+c     Méthode 13 "Qmax2K" plateau réel à l'Equateur augmenté +2K !
+      do j=1,klon
+        phy_sst(j,i)=273.+2.+0.5*29.*(2-sin(1.5*rlatd(j))**2
+     &                 -sin(1.5*rlatd(j))**4)
+      if((rlatd(j).GT.1.0471975).OR.(rlatd(j).LT.-1.0471975))then
+         phy_sst(j,i)=273.
+        endif
+      enddo
+      endif
+
+      enddo
+
+cIM beg : verif profil SST: phy_sst
+       amn=MIN(phy_sst(1,1),1000.)
+       amx=MAX(phy_sst(1,1),-1000.)
+       imn=1 ; kmn=1 ; imx=1 ; kmx=1
+       DO k=1, 360
+       DO i=2, nlon
+        IF(phy_sst(i,k).LT.amn) THEN
+         amn=phy_sst(i,k)
+         imn=i
+         kmn=k
+        ENDIF
+        IF(phy_sst(i,k).GT.amx) THEN
+         amx=phy_sst(i,k)
+         imx=i
+         kmx=k
+        ENDIF
+       ENDDO
+       ENDDO
+c
+       PRINT*,'profil_sst: imn, kmn, phy_sst(imn,kmn) ',imn,kmn,amn
+       PRINT*,'profil_sst: imx, kmx, phy_sst(imx,kmx) ',imx,kmx,amx
+cIM end : verif profil SST: phy_sst
+
+       return 
+       end subroutine profil_sst
+     
+      end module phyaqua_mod
Index: LMDZ5/branches/testing/libf/phylmd/phyetat0.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phyetat0.F	(revision 1796)
+++ 	(revision )
@@ -1,1105 +1,0 @@
-!
-! $Id$
-!
-c
-c
-      SUBROUTINE phyetat0 (fichnom,
-     .           clesphy0,
-     .           tabcntr0)
-
-      USE dimphy
-      USE mod_grid_phy_lmdz
-      USE mod_phys_lmdz_para
-      USE iophy
-      USE ocean_cpl_mod,    ONLY : ocean_cpl_init
-      USE fonte_neige_mod,  ONLY : fonte_neige_init
-      USE pbl_surface_mod,  ONLY : pbl_surface_init
-      USE surface_data,     ONLY : type_ocean
-      USE phys_state_var_mod
-      USE iostart
-      USE write_field_phy
-      USE infotrac
-      USE traclmdz_mod,    ONLY : traclmdz_from_restart
-      USE carbon_cycle_mod,ONLY :
-     &     carbon_cycle_tr, carbon_cycle_cpl, co2_send
-      USE indice_sol_mod
-
-      IMPLICIT none
-c======================================================================
-c Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
-c Objet: Lecture de l'etat initial pour la physique
-c======================================================================
-#include "dimensions.h"
-#include "netcdf.inc"
-#include "dimsoil.h"
-#include "clesphys.h"
-#include "temps.h"
-#include "thermcell.h"
-#include "compbl.h"
-c======================================================================
-      CHARACTER*(*) fichnom
-
-c les variables globales lues dans le fichier restart
-
-      REAL tsoil(klon,nsoilmx,nbsrf)
-      REAL tslab(klon), seaice(klon)
-      REAL qsurf(klon,nbsrf)
-      REAL qsol(klon)
-      REAL snow(klon,nbsrf)
-      REAL evap(klon,nbsrf)
-      real fder(klon)
-      REAL frugs(klon,nbsrf)
-      REAL agesno(klon,nbsrf)
-      REAL run_off_lic_0(klon)
-      REAL fractint(klon)
-      REAL trs(klon,nbtr)
-
-      CHARACTER*6 ocean_in
-      LOGICAL ok_veget_in
-
-      INTEGER        longcles
-      PARAMETER    ( longcles = 20 )
-      REAL clesphy0( longcles )
-c
-      REAL xmin, xmax
-c
-      INTEGER nid, nvarid
-      INTEGER ierr, i, nsrf, isoil ,k
-      INTEGER length
-      PARAMETER (length=100)
-      INTEGER it, iiq
-      REAL tab_cntrl(length), tabcntr0(length)
-      CHARACTER*7 str7
-      CHARACTER*2 str2
-      LOGICAL :: found
-
-c FH1D
-c     real iolat(jjm+1)
-      real iolat(jjm+1-1/(iim*jjm))
-c
-c Ouvrir le fichier contenant l'etat initial:
-c
-
-     
-      CALL open_startphy(fichnom)
-      
-
-c
-c Lecture des parametres de controle:
-c
-      CALL get_var("controle",tab_cntrl)
-       
-c
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
-! Les constantes de la physiques sont lues dans la physique seulement.
-! Les egalites du type
-!             tab_cntrl( 5 )=clesphy0(1)
-! sont remplacees par
-!             clesphy0(1)=tab_cntrl( 5 )
-! On inverse aussi la logique.
-! On remplit les tab_cntrl avec les parametres lus dans les .def
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-         DO i = 1, length
-           tabcntr0( i ) = tab_cntrl( i )
-         ENDDO
-c
-         tab_cntrl(1)=dtime
-         tab_cntrl(2)=radpas
-
-c co2_ppm : value from the previous time step
-         IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
-            co2_ppm = tab_cntrl(3)
-            RCO2    = co2_ppm * 1.0e-06  * 44.011/28.97 
-c ELSE : keep value from .def
-         END IF
-
-c co2_ppm0 : initial value of atmospheric CO2 (from create_etat0_limit.e .def)
-         co2_ppm0   = tab_cntrl(16)
-
-         solaire_etat0      = tab_cntrl(4)
-         tab_cntrl(5)=iflag_con
-         tab_cntrl(6)=nbapp_rad
-
-         if (cycle_diurne) tab_cntrl( 7) =1.
-         if (soil_model) tab_cntrl( 8) =1.
-         if (new_oliq) tab_cntrl( 9) =1.
-         if (ok_orodr) tab_cntrl(10) =1.
-         if (ok_orolf) tab_cntrl(11) =1.
-         if (ok_limitvrai) tab_cntrl(12) =1.
-
-
-      itau_phy = tab_cntrl(15)
-
-       
-      clesphy0(1)=tab_cntrl( 5 )
-      clesphy0(2)=tab_cntrl( 6 )
-      clesphy0(3)=tab_cntrl( 7 )
-      clesphy0(4)=tab_cntrl( 8 )
-      clesphy0(5)=tab_cntrl( 9 )
-      clesphy0(6)=tab_cntrl( 10 )
-      clesphy0(7)=tab_cntrl( 11 )
-      clesphy0(8)=tab_cntrl( 12 )
-
-c
-c Lecture des latitudes (coordonnees):
-c
-      CALL get_field("latitude",rlat)
-
-c
-c Lecture des longitudes (coordonnees):
-c
-      CALL get_field("longitude",rlon)
-
-C
-C
-C Lecture du masque terre mer
-C
-      CALL get_field("masque",zmasq,found)
-      IF (.NOT. found) THEN
-        PRINT*, 'phyetat0: Le champ <masque> est absent'
-        PRINT *, 'fichier startphy non compatible avec phyetat0'
-      ENDIF
-
-       
-C Lecture des fractions pour chaque sous-surface
-C
-C initialisation des sous-surfaces
-C
-      pctsrf = 0.
-C
-C fraction de terre
-C
-
-      CALL get_field("FTER",pctsrf(:,is_ter),found)
-      IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FTER> est absent'
-
-C
-C fraction de glace de terre
-C
-      CALL get_field("FLIC",pctsrf(:,is_lic),found)
-      IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FLIC> est absent'
-
-C
-C fraction d'ocean
-C
-      CALL get_field("FOCE",pctsrf(:,is_oce),found)
-      IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FOCE> est absent'
-
-C
-C fraction glace de mer
-C
-      CALL get_field("FSIC",pctsrf(:,is_sic),found)
-      IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FSIC> est absent'
-
-C
-C  Verification de l'adequation entre le masque et les sous-surfaces
-C
-      fractint( 1 : klon) = pctsrf(1 : klon, is_ter) 
-     $    + pctsrf(1 : klon, is_lic)
-      DO i = 1 , klon
-        IF ( abs(fractint(i) - zmasq(i) ) .GT. EPSFRA ) THEN
-            WRITE(*,*) 'phyetat0: attention fraction terre pas ', 
-     $          'coherente ', i, zmasq(i), pctsrf(i, is_ter)
-     $          ,pctsrf(i, is_lic)
-            WRITE(*,*) 'Je force la coherence zmasq=fractint'
-            zmasq(i) = fractint(i)
-        ENDIF 
-      END DO 
-      fractint (1 : klon) =  pctsrf(1 : klon, is_oce) 
-     $    + pctsrf(1 : klon, is_sic)
-      DO i = 1 , klon
-        IF ( abs( fractint(i) - (1. - zmasq(i))) .GT. EPSFRA ) THEN
-            WRITE(*,*) 'phyetat0 attention fraction ocean pas ', 
-     $          'coherente ', i, zmasq(i) , pctsrf(i, is_oce)
-     $          ,pctsrf(i, is_sic)
-            WRITE(*,*) 'Je force la coherence zmasq=fractint'
-            zmasq(i) = fractint(i)
-        ENDIF 
-      END DO 
-
-C
-c Lecture des temperatures du sol:
-c
-
-       CALL get_field("TS",ftsol(:,1),found)
-       IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <TS> est absent'
-         PRINT*, '          Mais je vais essayer de lire TS**'
-         DO nsrf = 1, nbsrf
-           IF (nsrf.GT.99) THEN
-             PRINT*, "Trop de sous-mailles"
-             CALL abort
-           ENDIF
-           WRITE(str2,'(i2.2)') nsrf
-           CALL get_field("TS"//str2,ftsol(:,nsrf))
-
-           xmin = 1.0E+20
-           xmax = -1.0E+20
-           DO i = 1, klon
-              xmin = MIN(ftsol(i,nsrf),xmin)
-              xmax = MAX(ftsol(i,nsrf),xmax)
-           ENDDO
-           PRINT*,'Temperature du sol TS**:', nsrf, xmin, xmax
-         ENDDO
-      ELSE
-         PRINT*, 'phyetat0: Le champ <TS> est present'
-         PRINT*, '          J ignore donc les autres temperatures TS**'
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(ftsol(i,1),xmin)
-            xmax = MAX(ftsol(i,1),xmax)
-         ENDDO
-         PRINT*,'Temperature du sol <TS>', xmin, xmax
-         DO nsrf = 2, nbsrf
-         DO i = 1, klon
-            ftsol(i,nsrf) = ftsol(i,1)
-         ENDDO
-         ENDDO
-      ENDIF
-
-c
-c Lecture des temperatures du sol profond:
-c
-      DO nsrf = 1, nbsrf
-        DO isoil=1, nsoilmx
-          IF (isoil.GT.99 .AND. nsrf.GT.99) THEN
-            PRINT*, "Trop de couches ou sous-mailles"
-            CALL abort
-          ENDIF
-          WRITE(str7,'(i2.2,"srf",i2.2)') isoil, nsrf
-          
-          CALL get_field('Tsoil'//str7,tsoil(:,isoil,nsrf),found)
-          IF (.NOT. found) THEN
-            PRINT*, "phyetat0: Le champ <Tsoil"//str7//"> est absent"
-            PRINT*, "          Il prend donc la valeur de surface"
-            DO i=1, klon
-               tsoil(i,isoil,nsrf)=ftsol(i,nsrf)
-            ENDDO
-          ENDIF
-        ENDDO
-      ENDDO
-c
-c Lecture de l'humidite de l'air juste au dessus du sol:
-c
-
-      CALL get_field("QS",qsurf(:,1),found)
-      IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <QS> est absent'
-         PRINT*, '          Mais je vais essayer de lire QS**'
-         DO nsrf = 1, nbsrf
-           IF (nsrf.GT.99) THEN
-             PRINT*, "Trop de sous-mailles"
-             CALL abort
-           ENDIF
-           WRITE(str2,'(i2.2)') nsrf
-           CALL get_field("QS"//str2,qsurf(:,nsrf))
-           xmin = 1.0E+20
-           xmax = -1.0E+20
-           DO i = 1, klon
-              xmin = MIN(qsurf(i,nsrf),xmin)
-              xmax = MAX(qsurf(i,nsrf),xmax)
-           ENDDO
-           PRINT*,'Humidite pres du sol QS**:', nsrf, xmin, xmax
-         ENDDO
-      ELSE
-         PRINT*, 'phyetat0: Le champ <QS> est present'
-         PRINT*, '          J ignore donc les autres humidites QS**'
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(qsurf(i,1),xmin)
-            xmax = MAX(qsurf(i,1),xmax)
-         ENDDO
-         PRINT*,'Humidite pres du sol <QS>', xmin, xmax
-         DO nsrf = 2, nbsrf
-           DO i = 1, klon
-             qsurf(i,nsrf) = qsurf(i,1)
-           ENDDO
-         ENDDO
-      ENDIF
-
-C
-C Eau dans le sol (pour le modele de sol "bucket")
-C
-      CALL get_field("QSOL",qsol,found)
-      IF (.NOT. found) THEN
-        PRINT*, 'phyetat0: Le champ <QSOL> est absent'
-        PRINT*, '          Valeur par defaut nulle'
-          qsol(:)=0.
-      ENDIF
-
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-        xmin = MIN(qsol(i),xmin)
-        xmax = MAX(qsol(i),xmax)
-      ENDDO
-      PRINT*,'Eau dans le sol (mm) <QSOL>', xmin, xmax
-
-c
-c Lecture de neige au sol:
-c
-
-      CALL get_field("SNOW",snow(:,1),found)
-      IF (.NOT. found) THEN
-        PRINT*, 'phyetat0: Le champ <SNOW> est absent'
-        PRINT*, '          Mais je vais essayer de lire SNOW**'
-        DO nsrf = 1, nbsrf
-          IF (nsrf.GT.99) THEN
-            PRINT*, "Trop de sous-mailles"
-            CALL abort
-          ENDIF
-          WRITE(str2,'(i2.2)') nsrf
-          CALL get_field( "SNOW"//str2,snow(:,nsrf))
-          xmin = 1.0E+20
-          xmax = -1.0E+20
-          DO i = 1, klon
-            xmin = MIN(snow(i,nsrf),xmin)
-            xmax = MAX(snow(i,nsrf),xmax)
-          ENDDO
-          PRINT*,'Neige du sol SNOW**:', nsrf, xmin, xmax
-        ENDDO
-      ELSE
-         PRINT*, 'phyetat0: Le champ <SNOW> est present'
-         PRINT*, '          J ignore donc les autres neiges SNOW**'
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(snow(i,1),xmin)
-            xmax = MAX(snow(i,1),xmax)
-         ENDDO
-         PRINT*,'Neige du sol <SNOW>', xmin, xmax
-         DO nsrf = 2, nbsrf
-         DO i = 1, klon
-            snow(i,nsrf) = snow(i,1)
-         ENDDO
-         ENDDO
-      ENDIF
-c
-c Lecture de albedo de l'interval visible au sol:
-c
-      CALL get_field("ALBE",falb1(:,1),found)
-      IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <ALBE> est absent'
-         PRINT*, '          Mais je vais essayer de lire ALBE**'
-         DO nsrf = 1, nbsrf
-           IF (nsrf.GT.99) THEN
-             PRINT*, "Trop de sous-mailles"
-             CALL abort
-           ENDIF
-           WRITE(str2,'(i2.2)') nsrf
-           CALL get_field("ALBE"//str2,falb1(:,nsrf))
-           xmin = 1.0E+20
-           xmax = -1.0E+20
-           DO i = 1, klon
-              xmin = MIN(falb1(i,nsrf),xmin)
-              xmax = MAX(falb1(i,nsrf),xmax)
-           ENDDO
-           PRINT*,'Albedo du sol ALBE**:', nsrf, xmin, xmax
-         ENDDO
-      ELSE
-         PRINT*, 'phyetat0: Le champ <ALBE> est present'
-         PRINT*, '          J ignore donc les autres ALBE**'
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(falb1(i,1),xmin)
-            xmax = MAX(falb1(i,1),xmax)
-         ENDDO
-         PRINT*,'Neige du sol <ALBE>', xmin, xmax
-         DO nsrf = 2, nbsrf
-           DO i = 1, klon
-            falb1(i,nsrf) = falb1(i,1)
-           ENDDO
-         ENDDO
-      ENDIF
-
-c
-c Lecture de albedo au sol dans l'interval proche infra-rouge:
-c
-      CALL get_field("ALBLW",falb2(:,1),found)
-      IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <ALBLW> est absent'
-         PRINT*, '          Mais je vais prendre ALBE**'
-         DO nsrf = 1, nbsrf
-           DO i = 1, klon
-             falb2(i,nsrf) = falb1(i,nsrf)
-           ENDDO
-         ENDDO
-      ELSE
-         PRINT*, 'phyetat0: Le champ <ALBLW> est present'
-         PRINT*, '          J ignore donc les autres ALBLW**'
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(falb2(i,1),xmin)
-            xmax = MAX(falb2(i,1),xmax)
-         ENDDO
-         PRINT*,'Neige du sol <ALBLW>', xmin, xmax
-         DO nsrf = 2, nbsrf
-           DO i = 1, klon
-             falb2(i,nsrf) = falb2(i,1)
-           ENDDO
-         ENDDO
-      ENDIF
-c
-c Lecture de evaporation:  
-c
-      CALL get_field("EVAP",evap(:,1),found)
-      IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <EVAP> est absent'
-         PRINT*, '          Mais je vais essayer de lire EVAP**'
-         DO nsrf = 1, nbsrf
-           IF (nsrf.GT.99) THEN
-             PRINT*, "Trop de sous-mailles"
-             CALL abort
-           ENDIF
-           WRITE(str2,'(i2.2)') nsrf
-           CALL get_field("EVAP"//str2, evap(:,nsrf))
-           xmin = 1.0E+20
-           xmax = -1.0E+20
-           DO i = 1, klon
-              xmin = MIN(evap(i,nsrf),xmin)
-              xmax = MAX(evap(i,nsrf),xmax)
-           ENDDO
-           PRINT*,'evap du sol EVAP**:', nsrf, xmin, xmax
-         ENDDO
-      ELSE
-         PRINT*, 'phyetat0: Le champ <EVAP> est present'
-         PRINT*, '          J ignore donc les autres EVAP**'
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(evap(i,1),xmin)
-            xmax = MAX(evap(i,1),xmax)
-         ENDDO
-         PRINT*,'Evap du sol <EVAP>', xmin, xmax
-         DO nsrf = 2, nbsrf
-         DO i = 1, klon
-            evap(i,nsrf) = evap(i,1)
-         ENDDO
-         ENDDO
-      ENDIF
-c
-c Lecture precipitation liquide:
-c
-      CALL get_field("rain_f",rain_fall)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(rain_fall(i),xmin)
-         xmax = MAX(rain_fall(i),xmax)
-      ENDDO
-      PRINT*,'Precipitation liquide rain_f:', xmin, xmax
-c
-c Lecture precipitation solide:
-c
-      CALL get_field("snow_f",snow_fall)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(snow_fall(i),xmin)
-         xmax = MAX(snow_fall(i),xmax)
-      ENDDO
-      PRINT*,'Precipitation solide snow_f:', xmin, xmax
-c
-c Lecture rayonnement solaire au sol:
-c
-      CALL get_field("solsw",solsw,found)
-      IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <solsw> est absent'
-         PRINT*, 'mis a zero'
-         solsw(:) = 0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(solsw(i),xmin)
-         xmax = MAX(solsw(i),xmax)
-      ENDDO
-      PRINT*,'Rayonnement solaire au sol solsw:', xmin, xmax
-c
-c Lecture rayonnement IF au sol:
-c
-      CALL get_field("sollw",sollw,found)
-      IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <sollw> est absent'
-         PRINT*, 'mis a zero'
-         sollw = 0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(sollw(i),xmin)
-         xmax = MAX(sollw(i),xmax)
-      ENDDO
-      PRINT*,'Rayonnement IF au sol sollw:', xmin, xmax
-      
-c
-c Lecture derive des flux:
-c
-      CALL get_field("fder",fder,found)
-      IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <fder> est absent'
-         PRINT*, 'mis a zero'
-         fder = 0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(fder(i),xmin)
-         xmax = MAX(fder(i),xmax)
-      ENDDO
-      PRINT*,'Derive des flux fder:', xmin, xmax
-
-c
-c Lecture du rayonnement net au sol:
-c
-      CALL get_field("RADS",radsol)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(radsol(i),xmin)
-         xmax = MAX(radsol(i),xmax)
-      ENDDO
-      PRINT*,'Rayonnement net au sol radsol:', xmin, xmax
-c
-c Lecture de la longueur de rugosite 
-c
-c
-      CALL get_field("RUG",frugs(:,1),found)
-      IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <RUG> est absent'
-         PRINT*, '          Mais je vais essayer de lire RUG**'
-         DO nsrf = 1, nbsrf
-           IF (nsrf.GT.99) THEN
-             PRINT*, "Trop de sous-mailles"
-             CALL abort
-           ENDIF
-           WRITE(str2,'(i2.2)') nsrf
-           CALL get_field("RUG"//str2,frugs(:,nsrf))
-           xmin = 1.0E+20
-           xmax = -1.0E+20
-           DO i = 1, klon
-              xmin = MIN(frugs(i,nsrf),xmin)
-              xmax = MAX(frugs(i,nsrf),xmax)
-           ENDDO
-           PRINT*,'rugosite du sol RUG**:', nsrf, xmin, xmax
-         ENDDO
-      ELSE
-         PRINT*, 'phyetat0: Le champ <RUG> est present'
-         PRINT*, '          J ignore donc les autres RUG**'
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(frugs(i,1),xmin)
-            xmax = MAX(frugs(i,1),xmax)
-         ENDDO
-         PRINT*,'rugosite <RUG>', xmin, xmax
-         DO nsrf = 2, nbsrf
-         DO i = 1, klon
-            frugs(i,nsrf) = frugs(i,1)
-         ENDDO
-         ENDDO
-      ENDIF
-
-c
-c Lecture de l'age de la neige:
-c
-      CALL get_field("AGESNO",agesno(:,1),found)
-      IF (.NOT. found) THEN
-         PRINT*, 'phyetat0: Le champ <AGESNO> est absent'
-         PRINT*, '          Mais je vais essayer de lire AGESNO**'
-         DO nsrf = 1, nbsrf
-           IF (nsrf.GT.99) THEN
-             PRINT*, "Trop de sous-mailles"
-             CALL abort
-           ENDIF
-           WRITE(str2,'(i2.2)') nsrf
-           CALL get_field("AGESNO"//str2,agesno(:,nsrf),found)
-           IF (.NOT. found) THEN
-              PRINT*, "phyetat0: Le champ <AGESNO"//str2//"> est absent"
-              agesno = 50.0
-           ENDIF
-           xmin = 1.0E+20
-           xmax = -1.0E+20
-           DO i = 1, klon
-              xmin = MIN(agesno(i,nsrf),xmin)
-              xmax = MAX(agesno(i,nsrf),xmax)
-           ENDDO
-           PRINT*,'Age de la neige AGESNO**:', nsrf, xmin, xmax
-         ENDDO
-      ELSE
-         PRINT*, 'phyetat0: Le champ <AGESNO> est present'
-         PRINT*, '          J ignore donc les autres AGESNO**'
-         xmin = 1.0E+20
-         xmax = -1.0E+20
-         DO i = 1, klon
-            xmin = MIN(agesno(i,1),xmin)
-            xmax = MAX(agesno(i,1),xmax)
-         ENDDO
-         PRINT*,'Age de la neige <AGESNO>', xmin, xmax
-         DO nsrf = 2, nbsrf
-         DO i = 1, klon
-            agesno(i,nsrf) = agesno(i,1)
-         ENDDO
-         ENDDO
-      ENDIF
-
-c
-      CALL get_field("ZMEA", zmea)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zmea(i),xmin)
-         xmax = MAX(zmea(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zmea:', xmin, xmax
-c
-c
-      CALL get_field("ZSTD",zstd)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zstd(i),xmin)
-         xmax = MAX(zstd(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zstd:', xmin, xmax
-c
-c
-      CALL get_field("ZSIG",zsig)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zsig(i),xmin)
-         xmax = MAX(zsig(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zsig:', xmin, xmax
-c
-c
-      CALL get_field("ZGAM",zgam)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zgam(i),xmin)
-         xmax = MAX(zgam(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zgam:', xmin, xmax
-c
-c
-      CALL get_field("ZTHE",zthe)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zthe(i),xmin)
-         xmax = MAX(zthe(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zthe:', xmin, xmax
-c
-c
-      CALL get_field("ZPIC",zpic)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zpic(i),xmin)
-         xmax = MAX(zpic(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zpic:', xmin, xmax
-c
-      CALL get_field("ZVAL",zval)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(zval(i),xmin)
-         xmax = MAX(zval(i),xmax)
-      ENDDO
-      PRINT*,'OROGRAPHIE SOUS-MAILLE zval:', xmin, xmax
-c
-c
-      CALL get_field("RUGSREL",rugoro)
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      DO i = 1, klon
-         xmin = MIN(rugoro(i),xmin)
-         xmax = MAX(rugoro(i),xmax)
-      ENDDO
-      PRINT*,'Rugosite relief (ecart-type) rugsrel:', xmin, xmax
-c
-c
-     
-c
-      ancien_ok = .TRUE.
-
-      CALL get_field("TANCIEN",t_ancien,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <TANCIEN> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         ancien_ok = .FALSE.
-      ENDIF
-
-
-      CALL get_field("QANCIEN",q_ancien,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <QANCIEN> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         ancien_ok = .FALSE.
-      ENDIF
-
-      CALL get_field("UANCIEN",u_ancien,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <UANCIEN> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         ancien_ok = .FALSE.
-      ENDIF
-
-      CALL get_field("VANCIEN",v_ancien,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <VANCIEN> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         ancien_ok = .FALSE.
-      ENDIF
-
-      clwcon=0.
-      CALL get_field("CLWCON",clwcon,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ CLWCON est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(clwcon)
-      xmax = MAXval(clwcon)
-      PRINT*,'Eau liquide convective (ecart-type) clwcon:', xmin, xmax
-c
-      rnebcon = 0.
-      CALL get_field("RNEBCON",rnebcon,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ RNEBCON est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(rnebcon)
-      xmax = MAXval(rnebcon)
-      PRINT*,'Nebulosite convective (ecart-type) rnebcon:', xmin, xmax
-
-c
-c Lecture ratqs
-c
-      ratqs=0.
-      CALL get_field("RATQS",ratqs,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <RATQS> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(ratqs)
-      xmax = MAXval(ratqs)
-      PRINT*,'(ecart-type) ratqs:', xmin, xmax
-c
-c Lecture run_off_lic_0
-c
-      CALL get_field("RUNOFFLIC0",run_off_lic_0,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <RUNOFFLIC0> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         run_off_lic_0 = 0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(run_off_lic_0)
-      xmax = MAXval(run_off_lic_0)
-      PRINT*,'(ecart-type) run_off_lic_0:', xmin, xmax
-
-
-c Lecture de l'energie cinetique turbulente
-c
-
-      IF (iflag_pbl>1) then
-        DO nsrf = 1, nbsrf
-          IF (nsrf.GT.99) THEN
-            PRINT*, "Trop de sous-mailles"
-            CALL abort
-          ENDIF
-          WRITE(str2,'(i2.2)') nsrf
-          CALL get_field("TKE"//str2,pbl_tke(:,1:klev+1,nsrf),found)
-          IF (.NOT. found) THEN
-            PRINT*, "phyetat0: <TKE"//str2//"> est absent"
-            pbl_tke(:,:,nsrf)=1.e-8
-          ENDIF
-          xmin = 1.0E+20
-          xmax = -1.0E+20
-          DO k = 1, klev+1
-            DO i = 1, klon
-              xmin = MIN(pbl_tke(i,k,nsrf),xmin)
-              xmax = MAX(pbl_tke(i,k,nsrf),xmax)
-            ENDDO
-          ENDDO
-          PRINT*,'Temperature du sol TKE**:', nsrf, xmin, xmax
-        ENDDO
-      ENDIF
-c
-c zmax0
-      CALL get_field("ZMAX0",zmax0,found)
-      IF (.NOT. found) THEN
-        PRINT*, "phyetat0: Le champ <ZMAX0> est absent"
-        PRINT*, "Depart legerement fausse. Mais je continue"
-        zmax0=40.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(zmax0)
-      xmax = MAXval(zmax0)
-      PRINT*,'(ecart-type) zmax0:', xmin, xmax
-c
-c           f0(ig)=1.e-5
-c f0
-      CALL get_field("F0",f0,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <f0> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         f0=1.e-5
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(f0)
-      xmax = MAXval(f0)
-      PRINT*,'(ecart-type) f0:', xmin, xmax
-c
-c ema_work1
-c
-      CALL get_field("EMA_WORK1",ema_work1,found)
-      IF (.NOT. found) THEN
-        PRINT*, "phyetat0: Le champ <EMA_WORK1> est absent"
-        PRINT*, "Depart legerement fausse. Mais je continue"
-        ema_work1=0.
-      ELSE
-        xmin = 1.0E+20
-        xmax = -1.0E+20
-        DO k = 1, klev
-          DO i = 1, klon
-            xmin = MIN(ema_work1(i,k),xmin)
-            xmax = MAX(ema_work1(i,k),xmax)
-          ENDDO
-        ENDDO
-        PRINT*,'ema_work1:', xmin, xmax
-      ENDIF
-c
-c ema_work2
-c
-      CALL get_field("EMA_WORK2",ema_work2,found)
-      IF (.NOT. found) THEN
-        PRINT*, "phyetat0: Le champ <EMA_WORK2> est absent"
-        PRINT*, "Depart legerement fausse. Mais je continue"
-        ema_work2=0.
-      ELSE
-        xmin = 1.0E+20
-        xmax = -1.0E+20
-        DO k = 1, klev
-          DO i = 1, klon
-            xmin = MIN(ema_work2(i,k),xmin)
-            xmax = MAX(ema_work2(i,k),xmax)
-          ENDDO
-        ENDDO
-        PRINT*,'ema_work2:', xmin, xmax
-      ENDIF
-c
-c wake_deltat
-c
-      CALL get_field("WAKE_DELTAT",wake_deltat,found)
-      IF (.NOT. found) THEN
-        PRINT*, "phyetat0: Le champ <WAKE_DELTAT> est absent"
-        PRINT*, "Depart legerement fausse. Mais je continue"
-        wake_deltat=0.
-      ELSE
-        xmin = 1.0E+20
-        xmax = -1.0E+20
-        DO k = 1, klev
-          DO i = 1, klon
-            xmin = MIN(wake_deltat(i,k),xmin)
-            xmax = MAX(wake_deltat(i,k),xmax)
-          ENDDO
-        ENDDO
-        PRINT*,'wake_deltat:', xmin, xmax
-      ENDIF
-c
-c wake_deltaq
-c   
-      CALL get_field("WAKE_DELTAQ",wake_deltaq,found)
-      IF (.NOT. found) THEN
-        PRINT*, "phyetat0: Le champ <WAKE_DELTAQ> est absent"
-        PRINT*, "Depart legerement fausse. Mais je continue"
-        wake_deltaq=0.
-      ELSE
-        xmin = 1.0E+20
-        xmax = -1.0E+20
-        DO k = 1, klev
-          DO i = 1, klon
-            xmin = MIN(wake_deltaq(i,k),xmin)
-            xmax = MAX(wake_deltaq(i,k),xmax)
-          ENDDO
-        ENDDO
-        PRINT*,'wake_deltaq:', xmin, xmax
-      ENDIF
-c
-c wake_s
-c
-      CALL get_field("WAKE_S",wake_s,found)
-      IF (.NOT. found) THEN
-        PRINT*, "phyetat0: Le champ <WAKE_S> est absent"
-        PRINT*, "Depart legerement fausse. Mais je continue"
-        wake_s=0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(wake_s)
-      xmax = MAXval(wake_s)
-      PRINT*,'(ecart-type) wake_s:', xmin, xmax
-c
-c wake_cstar
-c
-      CALL get_field("WAKE_CSTAR",wake_cstar,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <WAKE_CSTAR> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         wake_cstar=0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(wake_cstar)
-      xmax = MAXval(wake_cstar)
-      PRINT*,'(ecart-type) wake_cstar:', xmin, xmax
-c
-c wake_pe
-c
-      CALL get_field("WAKE_PE",wake_pe,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <WAKE_PE> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         wake_pe=0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(wake_pe)
-      xmax = MAXval(wake_pe)
-      PRINT*,'(ecart-type) wake_pe:', xmin, xmax
-c
-c wake_fip
-c
-      CALL get_field("WAKE_FIP",wake_fip,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <WAKE_FIP> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         wake_fip=0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(wake_fip)
-      xmax = MAXval(wake_fip)
-      PRINT*,'(ecart-type) wake_fip:', xmin, xmax
-c
-c  thermiques
-c
-
-      CALL get_field("FM_THERM",fm_therm,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <fm_therm> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         fm_therm=0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(fm_therm)
-      xmax = MAXval(fm_therm)
-      PRINT*,'(ecart-type) fm_therm:', xmin, xmax
-
-      CALL get_field("ENTR_THERM",entr_therm,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <entr_therm> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         entr_therm=0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(entr_therm)
-      xmax = MAXval(entr_therm)
-      PRINT*,'(ecart-type) entr_therm:', xmin, xmax
-
-      CALL get_field("DETR_THERM",detr_therm,found)
-      IF (.NOT. found) THEN
-         PRINT*, "phyetat0: Le champ <detr_therm> est absent"
-         PRINT*, "Depart legerement fausse. Mais je continue"
-         detr_therm=0.
-      ENDIF
-      xmin = 1.0E+20
-      xmax = -1.0E+20
-      xmin = MINval(detr_therm)
-      xmax = MAXval(detr_therm)
-      PRINT*,'(ecart-type) detr_therm:', xmin, xmax
-
-
-
-c
-c Read and send field trs to traclmdz
-c
-      IF (type_trac == 'lmdz') THEN
-         DO it=1,nbtr
-            iiq=niadv(it+2)
-            CALL get_field("trs_"//tname(iiq),trs(:,it),found)
-            IF (.NOT. found) THEN
-               PRINT*, 
-     $           "phyetat0: Le champ <trs_"//tname(iiq)//"> est absent"
-               PRINT*, "Depart legerement fausse. Mais je continue"
-               trs(:,it) = 0.
-            ENDIF
-            xmin = 1.0E+20
-            xmax = -1.0E+20
-            xmin = MINval(trs(:,it))
-            xmax = MAXval(trs(:,it))
-            PRINT*,"(ecart-type) trs_"//tname(iiq)//" :", xmin, xmax
-
-         END DO
-         CALL traclmdz_from_restart(trs)
-
-         IF (carbon_cycle_cpl) THEN
-            ALLOCATE(co2_send(klon), stat=ierr)
-            IF (ierr /= 0) CALL abort_gcm
-     &           ('phyetat0','pb allocation co2_send',1)
-            CALL get_field("co2_send",co2_send,found)
-            IF (.NOT. found) THEN
-               PRINT*,"phyetat0: Le champ <co2_send> est absent"
-               PRINT*,"Initialisation uniforme a co2_ppm=",co2_ppm
-               co2_send(:) = co2_ppm
-            END IF
-         END IF
-      END IF
-
-
-c on ferme le fichier
-      CALL close_startphy
-
-      CALL init_iophy_new(rlat,rlon)
-      	
-
-c
-c Initialize module pbl_surface_mod 
-c
-      CALL pbl_surface_init(qsol, fder, snow, qsurf,
-     $     evap, frugs, agesno, tsoil)
-
-c Initialize module ocean_cpl_mod for the case of coupled ocean
-      IF ( type_ocean == 'couple' ) THEN
-         CALL ocean_cpl_init(dtime, rlon, rlat)
-      ENDIF
-c
-c Initilialize module fonte_neige_mod      
-c
-      CALL fonte_neige_init(run_off_lic_0)
-
-
-      RETURN
-      END
Index: LMDZ5/branches/testing/libf/phylmd/phyetat0.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phyetat0.F90	(revision 1864)
+++ LMDZ5/branches/testing/libf/phylmd/phyetat0.F90	(revision 1864)
@@ -0,0 +1,1049 @@
+! $Id$
+
+SUBROUTINE phyetat0 (fichnom, clesphy0, tabcntr0)
+
+  USE dimphy
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  USE iophy
+  USE ocean_cpl_mod,    ONLY : ocean_cpl_init
+  USE fonte_neige_mod,  ONLY : fonte_neige_init
+  USE pbl_surface_mod,  ONLY : pbl_surface_init
+  USE surface_data,     ONLY : type_ocean
+  USE phys_state_var_mod
+  USE iostart
+  USE write_field_phy
+  USE infotrac
+  USE traclmdz_mod,    ONLY : traclmdz_from_restart
+  USE carbon_cycle_mod, ONLY : carbon_cycle_tr, carbon_cycle_cpl, co2_send
+  USE indice_sol_mod
+
+  IMPLICIT none
+  !======================================================================
+  ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
+  ! Objet: Lecture de l'etat initial pour la physique
+  !======================================================================
+  include "dimensions.h"
+  include "netcdf.inc"
+  include "dimsoil.h"
+  include "clesphys.h"
+  include "temps.h"
+  include "thermcell.h"
+  include "compbl.h"
+  !======================================================================
+  CHARACTER*(*) fichnom
+
+  ! les variables globales lues dans le fichier restart
+
+  REAL tsoil(klon, nsoilmx, nbsrf)
+  REAL tslab(klon), seaice(klon)
+  REAL qsurf(klon, nbsrf)
+  REAL qsol(klon)
+  REAL snow(klon, nbsrf)
+  REAL evap(klon, nbsrf)
+  real fder(klon)
+  REAL frugs(klon, nbsrf)
+  REAL agesno(klon, nbsrf)
+  REAL run_off_lic_0(klon)
+  REAL fractint(klon)
+  REAL trs(klon, nbtr)
+
+  CHARACTER*6 ocean_in
+  LOGICAL ok_veget_in
+
+  INTEGER        longcles
+  PARAMETER    ( longcles = 20 )
+  REAL clesphy0( longcles )
+
+  REAL xmin, xmax
+
+  INTEGER nid, nvarid
+  INTEGER ierr, i, nsrf, isoil , k
+  INTEGER length
+  PARAMETER (length=100)
+  INTEGER it, iiq
+  REAL tab_cntrl(length), tabcntr0(length)
+  CHARACTER*7 str7
+  CHARACTER*2 str2
+  LOGICAL :: found
+
+  ! FH1D
+  !     real iolat(jjm+1)
+  real iolat(jjm+1-1/(iim*jjm))
+
+  ! Ouvrir le fichier contenant l'etat initial:
+
+  CALL open_startphy(fichnom)
+
+  ! Lecture des parametres de controle:
+
+  CALL get_var("controle", tab_cntrl)
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
+  ! Les constantes de la physiques sont lues dans la physique seulement.
+  ! Les egalites du type
+  !             tab_cntrl( 5 )=clesphy0(1)
+  ! sont remplacees par
+  !             clesphy0(1)=tab_cntrl( 5 )
+  ! On inverse aussi la logique.
+  ! On remplit les tab_cntrl avec les parametres lus dans les .def
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  DO i = 1, length
+     tabcntr0( i ) = tab_cntrl( i )
+  ENDDO
+
+  tab_cntrl(1)=dtime
+  tab_cntrl(2)=radpas
+
+  ! co2_ppm : value from the previous time step
+  IF (carbon_cycle_tr .OR. carbon_cycle_cpl) THEN
+     co2_ppm = tab_cntrl(3)
+     RCO2    = co2_ppm * 1.0e-06  * 44.011/28.97 
+     ! ELSE : keep value from .def
+  END IF
+
+  ! co2_ppm0 : initial value of atmospheric CO2 (from create_etat0_limit.e .def)
+  co2_ppm0   = tab_cntrl(16)
+
+  solaire_etat0      = tab_cntrl(4)
+  tab_cntrl(5)=iflag_con
+  tab_cntrl(6)=nbapp_rad
+
+  if (cycle_diurne) tab_cntrl( 7) =1.
+  if (soil_model) tab_cntrl( 8) =1.
+  if (new_oliq) tab_cntrl( 9) =1.
+  if (ok_orodr) tab_cntrl(10) =1.
+  if (ok_orolf) tab_cntrl(11) =1.
+  if (ok_limitvrai) tab_cntrl(12) =1.
+
+  itau_phy = tab_cntrl(15)
+
+  clesphy0(1)=tab_cntrl( 5 )
+  clesphy0(2)=tab_cntrl( 6 )
+  clesphy0(3)=tab_cntrl( 7 )
+  clesphy0(4)=tab_cntrl( 8 )
+  clesphy0(5)=tab_cntrl( 9 )
+  clesphy0(6)=tab_cntrl( 10 )
+  clesphy0(7)=tab_cntrl( 11 )
+  clesphy0(8)=tab_cntrl( 12 )
+
+  ! Lecture des latitudes (coordonnees):
+
+  CALL get_field("latitude", rlat)
+
+  ! Lecture des longitudes (coordonnees):
+
+  CALL get_field("longitude", rlon)
+
+  ! Lecture du masque terre mer
+
+  CALL get_field("masque", zmasq, found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <masque> est absent'
+     PRINT *, 'fichier startphy non compatible avec phyetat0'
+  ENDIF
+
+  ! Lecture des fractions pour chaque sous-surface
+
+  ! initialisation des sous-surfaces
+
+  pctsrf = 0.
+
+  ! fraction de terre
+
+  CALL get_field("FTER", pctsrf(:, is_ter), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FTER> est absent'
+
+  ! fraction de glace de terre
+
+  CALL get_field("FLIC", pctsrf(:, is_lic), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FLIC> est absent'
+
+  ! fraction d'ocean
+
+  CALL get_field("FOCE", pctsrf(:, is_oce), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FOCE> est absent'
+
+  ! fraction glace de mer
+
+  CALL get_field("FSIC", pctsrf(:, is_sic), found)
+  IF (.NOT. found) PRINT*, 'phyetat0: Le champ <FSIC> est absent'
+
+  !  Verification de l'adequation entre le masque et les sous-surfaces
+
+  fractint( 1 : klon) = pctsrf(1 : klon, is_ter)  &
+       + pctsrf(1 : klon, is_lic)
+  DO i = 1 , klon
+     IF ( abs(fractint(i) - zmasq(i) ) .GT. EPSFRA ) THEN
+        WRITE(*, *) 'phyetat0: attention fraction terre pas ',  &
+             'coherente ', i, zmasq(i), pctsrf(i, is_ter) &
+             , pctsrf(i, is_lic)
+        WRITE(*, *) 'Je force la coherence zmasq=fractint'
+        zmasq(i) = fractint(i)
+     ENDIF
+  END DO
+  fractint (1 : klon) =  pctsrf(1 : klon, is_oce)  &
+       + pctsrf(1 : klon, is_sic)
+  DO i = 1 , klon
+     IF ( abs( fractint(i) - (1. - zmasq(i))) .GT. EPSFRA ) THEN
+        WRITE(*, *) 'phyetat0 attention fraction ocean pas ',  &
+             'coherente ', i, zmasq(i) , pctsrf(i, is_oce) &
+             , pctsrf(i, is_sic)
+        WRITE(*, *) 'Je force la coherence zmasq=fractint'
+        zmasq(i) = fractint(i)
+     ENDIF
+  END DO
+
+  ! Lecture des temperatures du sol:
+
+  CALL get_field("TS", ftsol(:, 1), found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <TS> est absent'
+     PRINT*, '          Mais je vais essayer de lire TS**'
+     DO nsrf = 1, nbsrf
+        IF (nsrf.GT.99) THEN
+           PRINT*, "Trop de sous-mailles"
+           CALL abort
+        ENDIF
+        WRITE(str2, '(i2.2)') nsrf
+        CALL get_field("TS"//str2, ftsol(:, nsrf))
+
+        xmin = 1.0E+20
+        xmax = -1.0E+20
+        DO i = 1, klon
+           xmin = MIN(ftsol(i, nsrf), xmin)
+           xmax = MAX(ftsol(i, nsrf), xmax)
+        ENDDO
+        PRINT*, 'Temperature du sol TS**:', nsrf, xmin, xmax
+     ENDDO
+  ELSE
+     PRINT*, 'phyetat0: Le champ <TS> est present'
+     PRINT*, '          J ignore donc les autres temperatures TS**'
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO i = 1, klon
+        xmin = MIN(ftsol(i, 1), xmin)
+        xmax = MAX(ftsol(i, 1), xmax)
+     ENDDO
+     PRINT*, 'Temperature du sol <TS>', xmin, xmax
+     DO nsrf = 2, nbsrf
+        DO i = 1, klon
+           ftsol(i, nsrf) = ftsol(i, 1)
+        ENDDO
+     ENDDO
+  ENDIF
+
+  ! Lecture des temperatures du sol profond:
+
+  DO nsrf = 1, nbsrf
+     DO isoil=1, nsoilmx
+        IF (isoil.GT.99 .AND. nsrf.GT.99) THEN
+           PRINT*, "Trop de couches ou sous-mailles"
+           CALL abort
+        ENDIF
+        WRITE(str7, '(i2.2, "srf", i2.2)') isoil, nsrf
+
+        CALL get_field('Tsoil'//str7, tsoil(:, isoil, nsrf), found)
+        IF (.NOT. found) THEN
+           PRINT*, "phyetat0: Le champ <Tsoil"//str7//"> est absent"
+           PRINT*, "          Il prend donc la valeur de surface"
+           DO i=1, klon
+              tsoil(i, isoil, nsrf)=ftsol(i, nsrf)
+           ENDDO
+        ENDIF
+     ENDDO
+  ENDDO
+
+  ! Lecture de l'humidite de l'air juste au dessus du sol:
+
+  CALL get_field("QS", qsurf(:, 1), found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <QS> est absent'
+     PRINT*, '          Mais je vais essayer de lire QS**'
+     DO nsrf = 1, nbsrf
+        IF (nsrf.GT.99) THEN
+           PRINT*, "Trop de sous-mailles"
+           CALL abort
+        ENDIF
+        WRITE(str2, '(i2.2)') nsrf
+        CALL get_field("QS"//str2, qsurf(:, nsrf))
+        xmin = 1.0E+20
+        xmax = -1.0E+20
+        DO i = 1, klon
+           xmin = MIN(qsurf(i, nsrf), xmin)
+           xmax = MAX(qsurf(i, nsrf), xmax)
+        ENDDO
+        PRINT*, 'Humidite pres du sol QS**:', nsrf, xmin, xmax
+     ENDDO
+  ELSE
+     PRINT*, 'phyetat0: Le champ <QS> est present'
+     PRINT*, '          J ignore donc les autres humidites QS**'
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO i = 1, klon
+        xmin = MIN(qsurf(i, 1), xmin)
+        xmax = MAX(qsurf(i, 1), xmax)
+     ENDDO
+     PRINT*, 'Humidite pres du sol <QS>', xmin, xmax
+     DO nsrf = 2, nbsrf
+        DO i = 1, klon
+           qsurf(i, nsrf) = qsurf(i, 1)
+        ENDDO
+     ENDDO
+  ENDIF
+
+  ! Eau dans le sol (pour le modele de sol "bucket")
+
+  CALL get_field("QSOL", qsol, found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <QSOL> est absent'
+     PRINT*, '          Valeur par defaut nulle'
+     qsol(:)=0.
+  ENDIF
+
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(qsol(i), xmin)
+     xmax = MAX(qsol(i), xmax)
+  ENDDO
+  PRINT*, 'Eau dans le sol (mm) <QSOL>', xmin, xmax
+
+  ! Lecture de neige au sol:
+
+  CALL get_field("SNOW", snow(:, 1), found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <SNOW> est absent'
+     PRINT*, '          Mais je vais essayer de lire SNOW**'
+     DO nsrf = 1, nbsrf
+        IF (nsrf.GT.99) THEN
+           PRINT*, "Trop de sous-mailles"
+           CALL abort
+        ENDIF
+        WRITE(str2, '(i2.2)') nsrf
+        CALL get_field( "SNOW"//str2, snow(:, nsrf))
+        xmin = 1.0E+20
+        xmax = -1.0E+20
+        DO i = 1, klon
+           xmin = MIN(snow(i, nsrf), xmin)
+           xmax = MAX(snow(i, nsrf), xmax)
+        ENDDO
+        PRINT*, 'Neige du sol SNOW**:', nsrf, xmin, xmax
+     ENDDO
+  ELSE
+     PRINT*, 'phyetat0: Le champ <SNOW> est present'
+     PRINT*, '          J ignore donc les autres neiges SNOW**'
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO i = 1, klon
+        xmin = MIN(snow(i, 1), xmin)
+        xmax = MAX(snow(i, 1), xmax)
+     ENDDO
+     PRINT*, 'Neige du sol <SNOW>', xmin, xmax
+     DO nsrf = 2, nbsrf
+        DO i = 1, klon
+           snow(i, nsrf) = snow(i, 1)
+        ENDDO
+     ENDDO
+  ENDIF
+
+  ! Lecture de albedo de l'interval visible au sol:
+
+  CALL get_field("ALBE", falb1(:, 1), found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <ALBE> est absent'
+     PRINT*, '          Mais je vais essayer de lire ALBE**'
+     DO nsrf = 1, nbsrf
+        IF (nsrf.GT.99) THEN
+           PRINT*, "Trop de sous-mailles"
+           CALL abort
+        ENDIF
+        WRITE(str2, '(i2.2)') nsrf
+        CALL get_field("ALBE"//str2, falb1(:, nsrf))
+        xmin = 1.0E+20
+        xmax = -1.0E+20
+        DO i = 1, klon
+           xmin = MIN(falb1(i, nsrf), xmin)
+           xmax = MAX(falb1(i, nsrf), xmax)
+        ENDDO
+        PRINT*, 'Albedo du sol ALBE**:', nsrf, xmin, xmax
+     ENDDO
+  ELSE
+     PRINT*, 'phyetat0: Le champ <ALBE> est present'
+     PRINT*, '          J ignore donc les autres ALBE**'
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO i = 1, klon
+        xmin = MIN(falb1(i, 1), xmin)
+        xmax = MAX(falb1(i, 1), xmax)
+     ENDDO
+     PRINT*, 'Neige du sol <ALBE>', xmin, xmax
+     DO nsrf = 2, nbsrf
+        DO i = 1, klon
+           falb1(i, nsrf) = falb1(i, 1)
+        ENDDO
+     ENDDO
+  ENDIF
+
+  ! Lecture de albedo au sol dans l'interval proche infra-rouge:
+
+  CALL get_field("ALBLW", falb2(:, 1), found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <ALBLW> est absent'
+     PRINT*, '          Mais je vais prendre ALBE**'
+     DO nsrf = 1, nbsrf
+        DO i = 1, klon
+           falb2(i, nsrf) = falb1(i, nsrf)
+        ENDDO
+     ENDDO
+  ELSE
+     PRINT*, 'phyetat0: Le champ <ALBLW> est present'
+     PRINT*, '          J ignore donc les autres ALBLW**'
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO i = 1, klon
+        xmin = MIN(falb2(i, 1), xmin)
+        xmax = MAX(falb2(i, 1), xmax)
+     ENDDO
+     PRINT*, 'Neige du sol <ALBLW>', xmin, xmax
+     DO nsrf = 2, nbsrf
+        DO i = 1, klon
+           falb2(i, nsrf) = falb2(i, 1)
+        ENDDO
+     ENDDO
+  ENDIF
+
+  ! Lecture de evaporation:  
+
+  CALL get_field("EVAP", evap(:, 1), found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <EVAP> est absent'
+     PRINT*, '          Mais je vais essayer de lire EVAP**'
+     DO nsrf = 1, nbsrf
+        IF (nsrf.GT.99) THEN
+           PRINT*, "Trop de sous-mailles"
+           CALL abort
+        ENDIF
+        WRITE(str2, '(i2.2)') nsrf
+        CALL get_field("EVAP"//str2, evap(:, nsrf))
+        xmin = 1.0E+20
+        xmax = -1.0E+20
+        DO i = 1, klon
+           xmin = MIN(evap(i, nsrf), xmin)
+           xmax = MAX(evap(i, nsrf), xmax)
+        ENDDO
+        PRINT*, 'evap du sol EVAP**:', nsrf, xmin, xmax
+     ENDDO
+  ELSE
+     PRINT*, 'phyetat0: Le champ <EVAP> est present'
+     PRINT*, '          J ignore donc les autres EVAP**'
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO i = 1, klon
+        xmin = MIN(evap(i, 1), xmin)
+        xmax = MAX(evap(i, 1), xmax)
+     ENDDO
+     PRINT*, 'Evap du sol <EVAP>', xmin, xmax
+     DO nsrf = 2, nbsrf
+        DO i = 1, klon
+           evap(i, nsrf) = evap(i, 1)
+        ENDDO
+     ENDDO
+  ENDIF
+
+  ! Lecture precipitation liquide:
+
+  CALL get_field("rain_f", rain_fall)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(rain_fall(i), xmin)
+     xmax = MAX(rain_fall(i), xmax)
+  ENDDO
+  PRINT*, 'Precipitation liquide rain_f:', xmin, xmax
+
+  ! Lecture precipitation solide:
+
+  CALL get_field("snow_f", snow_fall)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(snow_fall(i), xmin)
+     xmax = MAX(snow_fall(i), xmax)
+  ENDDO
+  PRINT*, 'Precipitation solide snow_f:', xmin, xmax
+
+  ! Lecture rayonnement solaire au sol:
+
+  CALL get_field("solsw", solsw, found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <solsw> est absent'
+     PRINT*, 'mis a zero'
+     solsw(:) = 0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(solsw(i), xmin)
+     xmax = MAX(solsw(i), xmax)
+  ENDDO
+  PRINT*, 'Rayonnement solaire au sol solsw:', xmin, xmax
+
+  ! Lecture rayonnement IF au sol:
+
+  CALL get_field("sollw", sollw, found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <sollw> est absent'
+     PRINT*, 'mis a zero'
+     sollw = 0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(sollw(i), xmin)
+     xmax = MAX(sollw(i), xmax)
+  ENDDO
+  PRINT*, 'Rayonnement IF au sol sollw:', xmin, xmax
+
+  ! Lecture derive des flux:
+
+  CALL get_field("fder", fder, found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <fder> est absent'
+     PRINT*, 'mis a zero'
+     fder = 0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(fder(i), xmin)
+     xmax = MAX(fder(i), xmax)
+  ENDDO
+  PRINT*, 'Derive des flux fder:', xmin, xmax
+
+  ! Lecture du rayonnement net au sol:
+
+  CALL get_field("RADS", radsol)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(radsol(i), xmin)
+     xmax = MAX(radsol(i), xmax)
+  ENDDO
+  PRINT*, 'Rayonnement net au sol radsol:', xmin, xmax
+
+  ! Lecture de la longueur de rugosite 
+
+  CALL get_field("RUG", frugs(:, 1), found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <RUG> est absent'
+     PRINT*, '          Mais je vais essayer de lire RUG**'
+     DO nsrf = 1, nbsrf
+        IF (nsrf.GT.99) THEN
+           PRINT*, "Trop de sous-mailles"
+           CALL abort
+        ENDIF
+        WRITE(str2, '(i2.2)') nsrf
+        CALL get_field("RUG"//str2, frugs(:, nsrf))
+        xmin = 1.0E+20
+        xmax = -1.0E+20
+        DO i = 1, klon
+           xmin = MIN(frugs(i, nsrf), xmin)
+           xmax = MAX(frugs(i, nsrf), xmax)
+        ENDDO
+        PRINT*, 'rugosite du sol RUG**:', nsrf, xmin, xmax
+     ENDDO
+  ELSE
+     PRINT*, 'phyetat0: Le champ <RUG> est present'
+     PRINT*, '          J ignore donc les autres RUG**'
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO i = 1, klon
+        xmin = MIN(frugs(i, 1), xmin)
+        xmax = MAX(frugs(i, 1), xmax)
+     ENDDO
+     PRINT*, 'rugosite <RUG>', xmin, xmax
+     DO nsrf = 2, nbsrf
+        DO i = 1, klon
+           frugs(i, nsrf) = frugs(i, 1)
+        ENDDO
+     ENDDO
+  ENDIF
+
+  ! Lecture de l'age de la neige:
+
+  CALL get_field("AGESNO", agesno(:, 1), found)
+  IF (.NOT. found) THEN
+     PRINT*, 'phyetat0: Le champ <AGESNO> est absent'
+     PRINT*, '          Mais je vais essayer de lire AGESNO**'
+     DO nsrf = 1, nbsrf
+        IF (nsrf.GT.99) THEN
+           PRINT*, "Trop de sous-mailles"
+           CALL abort
+        ENDIF
+        WRITE(str2, '(i2.2)') nsrf
+        CALL get_field("AGESNO"//str2, agesno(:, nsrf), found)
+        IF (.NOT. found) THEN
+           PRINT*, "phyetat0: Le champ <AGESNO"//str2//"> est absent"
+           agesno = 50.0
+        ENDIF
+        xmin = 1.0E+20
+        xmax = -1.0E+20
+        DO i = 1, klon
+           xmin = MIN(agesno(i, nsrf), xmin)
+           xmax = MAX(agesno(i, nsrf), xmax)
+        ENDDO
+        PRINT*, 'Age de la neige AGESNO**:', nsrf, xmin, xmax
+     ENDDO
+  ELSE
+     PRINT*, 'phyetat0: Le champ <AGESNO> est present'
+     PRINT*, '          J ignore donc les autres AGESNO**'
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO i = 1, klon
+        xmin = MIN(agesno(i, 1), xmin)
+        xmax = MAX(agesno(i, 1), xmax)
+     ENDDO
+     PRINT*, 'Age de la neige <AGESNO>', xmin, xmax
+     DO nsrf = 2, nbsrf
+        DO i = 1, klon
+           agesno(i, nsrf) = agesno(i, 1)
+        ENDDO
+     ENDDO
+  ENDIF
+
+  CALL get_field("ZMEA", zmea)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(zmea(i), xmin)
+     xmax = MAX(zmea(i), xmax)
+  ENDDO
+  PRINT*, 'OROGRAPHIE SOUS-MAILLE zmea:', xmin, xmax
+
+  CALL get_field("ZSTD", zstd)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(zstd(i), xmin)
+     xmax = MAX(zstd(i), xmax)
+  ENDDO
+  PRINT*, 'OROGRAPHIE SOUS-MAILLE zstd:', xmin, xmax
+
+  CALL get_field("ZSIG", zsig)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(zsig(i), xmin)
+     xmax = MAX(zsig(i), xmax)
+  ENDDO
+  PRINT*, 'OROGRAPHIE SOUS-MAILLE zsig:', xmin, xmax
+
+  CALL get_field("ZGAM", zgam)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(zgam(i), xmin)
+     xmax = MAX(zgam(i), xmax)
+  ENDDO
+  PRINT*, 'OROGRAPHIE SOUS-MAILLE zgam:', xmin, xmax
+
+  CALL get_field("ZTHE", zthe)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(zthe(i), xmin)
+     xmax = MAX(zthe(i), xmax)
+  ENDDO
+  PRINT*, 'OROGRAPHIE SOUS-MAILLE zthe:', xmin, xmax
+
+  CALL get_field("ZPIC", zpic)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(zpic(i), xmin)
+     xmax = MAX(zpic(i), xmax)
+  ENDDO
+  PRINT*, 'OROGRAPHIE SOUS-MAILLE zpic:', xmin, xmax
+
+  CALL get_field("ZVAL", zval)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(zval(i), xmin)
+     xmax = MAX(zval(i), xmax)
+  ENDDO
+  PRINT*, 'OROGRAPHIE SOUS-MAILLE zval:', xmin, xmax
+
+  CALL get_field("RUGSREL", rugoro)
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  DO i = 1, klon
+     xmin = MIN(rugoro(i), xmin)
+     xmax = MAX(rugoro(i), xmax)
+  ENDDO
+  PRINT*, 'Rugosite relief (ecart-type) rugsrel:', xmin, xmax
+
+  ancien_ok = .TRUE.
+
+  CALL get_field("TANCIEN", t_ancien, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <TANCIEN> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     ancien_ok = .FALSE.
+  ENDIF
+
+  CALL get_field("QANCIEN", q_ancien, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <QANCIEN> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     ancien_ok = .FALSE.
+  ENDIF
+
+  CALL get_field("UANCIEN", u_ancien, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <UANCIEN> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     ancien_ok = .FALSE.
+  ENDIF
+
+  CALL get_field("VANCIEN", v_ancien, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <VANCIEN> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     ancien_ok = .FALSE.
+  ENDIF
+
+  clwcon=0.
+  CALL get_field("CLWCON", clwcon, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ CLWCON est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(clwcon)
+  xmax = MAXval(clwcon)
+  PRINT*, 'Eau liquide convective (ecart-type) clwcon:', xmin, xmax
+
+  rnebcon = 0.
+  CALL get_field("RNEBCON", rnebcon, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ RNEBCON est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(rnebcon)
+  xmax = MAXval(rnebcon)
+  PRINT*, 'Nebulosite convective (ecart-type) rnebcon:', xmin, xmax
+
+  ! Lecture ratqs
+
+  ratqs=0.
+  CALL get_field("RATQS", ratqs, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <RATQS> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(ratqs)
+  xmax = MAXval(ratqs)
+  PRINT*, '(ecart-type) ratqs:', xmin, xmax
+
+  ! Lecture run_off_lic_0
+
+  CALL get_field("RUNOFFLIC0", run_off_lic_0, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <RUNOFFLIC0> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     run_off_lic_0 = 0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(run_off_lic_0)
+  xmax = MAXval(run_off_lic_0)
+  PRINT*, '(ecart-type) run_off_lic_0:', xmin, xmax
+
+  ! Lecture de l'energie cinetique turbulente
+
+  IF (iflag_pbl>1) then
+     DO nsrf = 1, nbsrf
+        IF (nsrf.GT.99) THEN
+           PRINT*, "Trop de sous-mailles"
+           CALL abort
+        ENDIF
+        WRITE(str2, '(i2.2)') nsrf
+        CALL get_field("TKE"//str2, pbl_tke(:, 1:klev+1, nsrf), found)
+        IF (.NOT. found) THEN
+           PRINT*, "phyetat0: <TKE"//str2//"> est absent"
+           pbl_tke(:, :, nsrf)=1.e-8
+        ENDIF
+        xmin = 1.0E+20
+        xmax = -1.0E+20
+        DO k = 1, klev+1
+           DO i = 1, klon
+              xmin = MIN(pbl_tke(i, k, nsrf), xmin)
+              xmax = MAX(pbl_tke(i, k, nsrf), xmax)
+           ENDDO
+        ENDDO
+        PRINT*, 'Temperature du sol TKE**:', nsrf, xmin, xmax
+     ENDDO
+  ENDIF
+
+  ! zmax0
+  CALL get_field("ZMAX0", zmax0, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <ZMAX0> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     zmax0=40.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(zmax0)
+  xmax = MAXval(zmax0)
+  PRINT*, '(ecart-type) zmax0:', xmin, xmax
+
+  !           f0(ig)=1.e-5
+  ! f0
+  CALL get_field("F0", f0, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <f0> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     f0=1.e-5
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(f0)
+  xmax = MAXval(f0)
+  PRINT*, '(ecart-type) f0:', xmin, xmax
+
+  ! sig1 or ema_work1
+
+  CALL get_field("sig1", sig1, found)
+  IF (.NOT. found) CALL get_field("EMA_WORK1", sig1, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ sig1 est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     sig1=0.
+  ELSE
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO k = 1, klev
+        DO i = 1, klon
+           xmin = MIN(sig1(i, k), xmin)
+           xmax = MAX(sig1(i, k), xmax)
+        ENDDO
+     ENDDO
+     PRINT*, 'sig1:', xmin, xmax
+  ENDIF
+
+  ! w01 or ema_work2
+
+  CALL get_field("w01", w01, found)
+  IF (.NOT. found) CALL get_field("EMA_WORK2", w01, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ w01 est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     w01=0.
+  ELSE
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO k = 1, klev
+        DO i = 1, klon
+           xmin = MIN(w01(i, k), xmin)
+           xmax = MAX(w01(i, k), xmax)
+        ENDDO
+     ENDDO
+     PRINT*, 'w01:', xmin, xmax
+  ENDIF
+
+  ! wake_deltat
+
+  CALL get_field("WAKE_DELTAT", wake_deltat, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <WAKE_DELTAT> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     wake_deltat=0.
+  ELSE
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO k = 1, klev
+        DO i = 1, klon
+           xmin = MIN(wake_deltat(i, k), xmin)
+           xmax = MAX(wake_deltat(i, k), xmax)
+        ENDDO
+     ENDDO
+     PRINT*, 'wake_deltat:', xmin, xmax
+  ENDIF
+
+  ! wake_deltaq
+
+  CALL get_field("WAKE_DELTAQ", wake_deltaq, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <WAKE_DELTAQ> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     wake_deltaq=0.
+  ELSE
+     xmin = 1.0E+20
+     xmax = -1.0E+20
+     DO k = 1, klev
+        DO i = 1, klon
+           xmin = MIN(wake_deltaq(i, k), xmin)
+           xmax = MAX(wake_deltaq(i, k), xmax)
+        ENDDO
+     ENDDO
+     PRINT*, 'wake_deltaq:', xmin, xmax
+  ENDIF
+
+  ! wake_s
+
+  CALL get_field("WAKE_S", wake_s, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <WAKE_S> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     wake_s=0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(wake_s)
+  xmax = MAXval(wake_s)
+  PRINT*, '(ecart-type) wake_s:', xmin, xmax
+
+  ! wake_cstar
+
+  CALL get_field("WAKE_CSTAR", wake_cstar, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <WAKE_CSTAR> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     wake_cstar=0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(wake_cstar)
+  xmax = MAXval(wake_cstar)
+  PRINT*, '(ecart-type) wake_cstar:', xmin, xmax
+
+  ! wake_pe
+
+  CALL get_field("WAKE_PE", wake_pe, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <WAKE_PE> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     wake_pe=0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(wake_pe)
+  xmax = MAXval(wake_pe)
+  PRINT*, '(ecart-type) wake_pe:', xmin, xmax
+
+  ! wake_fip
+
+  CALL get_field("WAKE_FIP", wake_fip, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <WAKE_FIP> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     wake_fip=0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(wake_fip)
+  xmax = MAXval(wake_fip)
+  PRINT*, '(ecart-type) wake_fip:', xmin, xmax
+
+  !  thermiques
+
+  CALL get_field("FM_THERM", fm_therm, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <fm_therm> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     fm_therm=0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(fm_therm)
+  xmax = MAXval(fm_therm)
+  PRINT*, '(ecart-type) fm_therm:', xmin, xmax
+
+  CALL get_field("ENTR_THERM", entr_therm, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <entr_therm> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     entr_therm=0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(entr_therm)
+  xmax = MAXval(entr_therm)
+  PRINT*, '(ecart-type) entr_therm:', xmin, xmax
+
+  CALL get_field("DETR_THERM", detr_therm, found)
+  IF (.NOT. found) THEN
+     PRINT*, "phyetat0: Le champ <detr_therm> est absent"
+     PRINT*, "Depart legerement fausse. Mais je continue"
+     detr_therm=0.
+  ENDIF
+  xmin = 1.0E+20
+  xmax = -1.0E+20
+  xmin = MINval(detr_therm)
+  xmax = MAXval(detr_therm)
+  PRINT*, '(ecart-type) detr_therm:', xmin, xmax
+
+  ! Read and send field trs to traclmdz
+
+  IF (type_trac == 'lmdz') THEN
+     DO it=1, nbtr
+        iiq=niadv(it+2)
+        CALL get_field("trs_"//tname(iiq), trs(:, it), found)
+        IF (.NOT. found) THEN
+           PRINT*,  &
+                "phyetat0: Le champ <trs_"//tname(iiq)//"> est absent"
+           PRINT*, "Depart legerement fausse. Mais je continue"
+           trs(:, it) = 0.
+        ENDIF
+        xmin = 1.0E+20
+        xmax = -1.0E+20
+        xmin = MINval(trs(:, it))
+        xmax = MAXval(trs(:, it))
+        PRINT*, "(ecart-type) trs_"//tname(iiq)//" :", xmin, xmax
+
+     END DO
+     CALL traclmdz_from_restart(trs)
+
+     IF (carbon_cycle_cpl) THEN
+        ALLOCATE(co2_send(klon), stat=ierr)
+        IF (ierr /= 0) CALL abort_gcm &
+             ('phyetat0', 'pb allocation co2_send', 1)
+        CALL get_field("co2_send", co2_send, found)
+        IF (.NOT. found) THEN
+           PRINT*, "phyetat0: Le champ <co2_send> est absent"
+           PRINT*, "Initialisation uniforme a co2_ppm=", co2_ppm
+           co2_send(:) = co2_ppm
+        END IF
+     END IF
+  END IF
+
+  ! on ferme le fichier
+  CALL close_startphy
+
+  CALL init_iophy_new(rlat, rlon)
+
+  ! Initialize module pbl_surface_mod 
+
+  CALL pbl_surface_init(qsol, fder, snow, qsurf, &
+       evap, frugs, agesno, tsoil)
+
+  ! Initialize module ocean_cpl_mod for the case of coupled ocean
+  IF ( type_ocean == 'couple' ) THEN
+     CALL ocean_cpl_init(dtime, rlon, rlat)
+  ENDIF
+
+  ! Initilialize module fonte_neige_mod      
+
+  CALL fonte_neige_init(run_off_lic_0)
+
+END SUBROUTINE phyetat0
Index: LMDZ5/branches/testing/libf/phylmd/phyredem.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phyredem.F	(revision 1796)
+++ 	(revision )
@@ -1,356 +1,0 @@
-!
-! $Id$
-!
-c
-      SUBROUTINE phyredem (fichnom)
-
-      USE dimphy
-      USE mod_grid_phy_lmdz
-      USE mod_phys_lmdz_para
-      USE fonte_neige_mod,  ONLY : fonte_neige_final
-      USE pbl_surface_mod,  ONLY : pbl_surface_final
-      USE phys_state_var_mod
-      USE iostart
-      USE traclmdz_mod, ONLY : traclmdz_to_restart
-      USE infotrac
-      USE control_mod
-      USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send
-      USE indice_sol_mod
-
-      IMPLICIT none
-c======================================================================
-c Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
-c Objet: Ecriture de l'etat de redemarrage pour la physique
-c======================================================================
-#include "netcdf.inc"
-#include "dimsoil.h"
-#include "clesphys.h"
-#include "temps.h"
-#include "thermcell.h"
-#include "compbl.h"
-c======================================================================
-      CHARACTER*(*) fichnom
-
-c les variables globales ecrites dans le fichier restart
-
-      
-      REAL tsoil(klon,nsoilmx,nbsrf)
-      REAL tslab(klon), seaice(klon)
-      REAL qsurf(klon,nbsrf)
-      REAL qsol(klon)
-      REAL snow(klon,nbsrf)
-      REAL evap(klon,nbsrf)
-      real fder(klon)
-      REAL frugs(klon,nbsrf)
-      REAL agesno(klon,nbsrf)
-      REAL run_off_lic_0(klon)
-      REAL trs(klon,nbtr)
-c
-      INTEGER nid, nvarid, idim1, idim2, idim3
-      INTEGER ierr
-      INTEGER length
-      PARAMETER (length=100)
-      REAL tab_cntrl(length)
-c
-      INTEGER isoil, nsrf
-      CHARACTER (len=7) :: str7
-      CHARACTER (len=2) :: str2
-      INTEGER           :: it, iiq
-      
-c======================================================================
-c 
-c Get variables which will be written to restart file from module 
-c pbl_surface_mod
-      CALL pbl_surface_final(qsol, fder, snow, qsurf, 
-     $     evap, frugs, agesno, tsoil)
-
-c Get a variable calculated in module fonte_neige_mod
-      CALL fonte_neige_final(run_off_lic_0)
-
-c======================================================================
-
-      CALL open_restartphy(fichnom)
-      
-      DO ierr = 1, length
-         tab_cntrl(ierr) = 0.0
-      ENDDO
-      tab_cntrl(1) = dtime
-      tab_cntrl(2) = radpas
-c co2_ppm : current value of atmospheric CO2
-      tab_cntrl(3) = co2_ppm
-      tab_cntrl(4) = solaire
-      tab_cntrl(5) = iflag_con
-      tab_cntrl(6) = nbapp_rad
-
-      IF( cycle_diurne ) tab_cntrl( 7 ) = 1.
-      IF(   soil_model ) tab_cntrl( 8 ) = 1.
-      IF(     new_oliq ) tab_cntrl( 9 ) = 1.
-      IF(     ok_orodr ) tab_cntrl(10 ) = 1.
-      IF(     ok_orolf ) tab_cntrl(11 ) = 1.
-
-      tab_cntrl(13) = day_end
-      tab_cntrl(14) = annee_ref
-      tab_cntrl(15) = itau_phy
-
-c co2_ppm0 : initial value of atmospheric CO2
-      tab_cntrl(16) = co2_ppm0
-c
-      CALL put_var("controle","Parametres de controle",tab_cntrl)
-c
-
-      CALL put_field("longitude",
-     .               "Longitudes de la grille physique",rlon)
-     
-      CALL put_field("latitude","Latitudes de la grille physique",rlat)
-
-c
-C PB ajout du masque terre/mer
-C
-      CALL put_field("masque","masque terre mer",zmasq)
-
-c BP ajout des fraction de chaque sous-surface
-C
-C 1. fraction de terre 
-C
-      CALL put_field("FTER","fraction de continent",pctsrf(:,is_ter))
-C 
-C 2. Fraction de glace de terre
-C 
-      CALL put_field("FLIC","fraction glace de terre",pctsrf(:,is_lic))
-C
-C 3. fraction ocean
-C
-      CALL put_field("FOCE","fraction ocean",pctsrf(:,is_oce))
-C
-C 4. Fraction glace de mer
-C
-      CALL put_field("FSIC","fraction glace mer",pctsrf(:,is_sic))
-C
-C
-c
-      DO nsrf = 1, nbsrf
-        IF (nsrf.LE.99) THEN
-          WRITE(str2,'(i2.2)') nsrf
-          CALL put_field("TS"//str2,"Temperature de surface No."//str2,
-     .                    ftsol(:,nsrf))
-        ELSE
-          PRINT*, "Trop de sous-mailles"
-          CALL abort
-        ENDIF
-      ENDDO
-c
-      DO nsrf = 1, nbsrf
-        DO isoil=1, nsoilmx
-          IF (isoil.LE.99 .AND. nsrf.LE.99) THEN
-            WRITE(str7,'(i2.2,"srf",i2.2)') isoil,nsrf
-            CALL put_field("Tsoil"//str7,"Temperature du sol No."//str7,
-     .                     tsoil(:,isoil,nsrf))
-          ELSE
-            PRINT*, "Trop de couches"
-            CALL abort
-          ENDIF
-        ENDDO
-      ENDDO
-c
-      DO nsrf = 1, nbsrf
-        IF (nsrf.LE.99) THEN
-          WRITE(str2,'(i2.2)') nsrf
-          CALL put_field("QS"//str2,"Humidite de surface No."//str2,
-     .                   qsurf(:,nsrf))
-        ELSE
-          PRINT*, "Trop de sous-mailles"
-          CALL abort
-        ENDIF
-      END DO
-C
-      CALL put_field("QSOL","Eau dans le sol (mm)",qsol)
-c
-      DO nsrf = 1, nbsrf
-        IF (nsrf.LE.99) THEN
-          WRITE(str2,'(i2.2)') nsrf
-          CALL put_field("ALBE"//str2,"albedo de surface No."//str2,
-     .                   falb1(:,nsrf))
-        ELSE
-          PRINT*, "Trop de sous-mailles"
-          CALL abort
-        ENDIF
-      ENDDO
-
-      DO nsrf = 1, nbsrf
-        IF (nsrf.LE.99) THEN
-          WRITE(str2,'(i2.2)') nsrf
-          CALL put_field("ALBLW"//str2,"albedo LW de surface No."//str2,
-     .                   falb2(:,nsrf))
-        ELSE
-          PRINT*, "Trop de sous-mailles"
-          CALL abort
-        ENDIF
-      ENDDO
-c
-c
-      DO nsrf = 1, nbsrf
-        IF (nsrf.LE.99) THEN
-          WRITE(str2,'(i2.2)') nsrf
-          CALL put_field("EVAP"//str2,"Evaporation de surface No."//str2
-     .                   ,evap(:,nsrf))
-        ELSE
-          PRINT*, "Trop de sous-mailles"
-          CALL abort
-        ENDIF
-      ENDDO
-
-c
-      DO nsrf = 1, nbsrf
-        IF (nsrf.LE.99) THEN
-          WRITE(str2,'(i2.2)') nsrf
-          CALL put_field("SNOW"//str2,"Neige de surface No."//str2,
-     .                   snow(:,nsrf))
-        ELSE
-          PRINT*, "Trop de sous-mailles"
-          CALL abort
-        ENDIF
-      ENDDO
-
-c
-      CALL put_field("RADS","Rayonnement net a la surface",radsol)
-c
-      CALL put_field("solsw","Rayonnement solaire a la surface",solsw)
-c
-      CALL put_field("sollw","Rayonnement IF a la surface",sollw)
-c
-      CALL put_field("fder","Derive de flux",fder)
-c
-      CALL put_field("rain_f","precipitation liquide",rain_fall)
-c
-      CALL put_field("snow_f", "precipitation solide",snow_fall)
-c
-      DO nsrf = 1, nbsrf
-        IF (nsrf.LE.99) THEN
-        WRITE(str2,'(i2.2)') nsrf
-          CALL put_field("RUG"//str2,"rugosite de surface No."//str2,
-     .         frugs(:,nsrf))
-        ELSE
-          PRINT*, "Trop de sous-mailles"
-          CALL abort
-        ENDIF
-      ENDDO
-c
-      DO nsrf = 1, nbsrf
-        IF (nsrf.LE.99) THEN
-            WRITE(str2,'(i2.2)') nsrf
-            CALL put_field("AGESNO"//str2,
-     .                     "Age de la neige surface No."//str2,
-     .                     agesno(:,nsrf))
-        ELSE
-            PRINT*, "Trop de sous-mailles"
-            CALL abort
-        ENDIF
-      ENDDO
-c
-      CALL put_field("ZMEA","ZMEA",zmea)
-c
-      CALL put_field("ZSTD","ZSTD",zstd)
-      
-      CALL put_field("ZSIG","ZSIG",zsig)
-      
-      CALL put_field("ZGAM","ZGAM",zgam)
-      
-      CALL put_field("ZTHE","ZTHE",zthe)
-      
-      CALL put_field("ZPIC","ZPIC",zpic)
-      
-      CALL put_field("ZVAL","ZVAL",zval)
-      
-      CALL put_field("RUGSREL","RUGSREL",rugoro)
-      
-      CALL put_field("TANCIEN","TANCIEN",t_ancien)
-      
-      CALL put_field("QANCIEN","QANCIEN",q_ancien)
-
-      CALL put_field("UANCIEN","",u_ancien)
-
-      CALL put_field("VANCIEN","",v_ancien)
-
-      CALL put_field("RUGMER","Longueur de rugosite sur mer",
-     .               frugs(:,is_oce))
-      
-      CALL put_field("CLWCON","Eau liquide convective",clwcon)
-      
-      CALL put_field("RNEBCON","Nebulosite convective",rnebcon)
-      
-      CALL put_field("RATQS", "Ratqs",ratqs)
-c
-c run_off_lic_0
-c
-      CALL put_field("RUNOFFLIC0","Runofflic0",run_off_lic_0)
-c
-c
-!!!!!!!!!!!!!!!!!!!! DEB TKE PBL !!!!!!!!!!!!!!!!!!!!!!!!!
-c
-      IF (iflag_pbl>1) then
-        DO nsrf = 1, nbsrf
-          IF (nsrf.LE.99) THEN
-            WRITE(str2,'(i2.2)') nsrf
-            CALL put_field("TKE"//str2,"Energ. Cineti. Turb."//str2,
-     .                     pbl_tke(:,1:klev+1,nsrf))
-          ELSE
-            PRINT*, "Trop de sous-mailles"
-            CALL abort
-          ENDIF
-        ENDDO
-      ENDIF
-
-!!!!!!!!!!!!!!!!!!!! FIN TKE PBL !!!!!!!!!!!!!!!!!!!!!!!!!
-cIM ajout zmax0, f0, ema_work1, ema_work2
-cIM wake_deltat, wake_deltaq, wake_s, wake_cstar, wake_pe, wake_fip
-      
-      CALL put_field("ZMAX0","ZMAX0",zmax0)
-      
-      CALL put_field("F0","F0",f0)
-      
-      CALL put_field("EMA_WORK1","EMA_WORK1",ema_work1)
-      
-      CALL put_field("EMA_WORK2","EMA_WORK2",ema_work2)
-      
-c wake_deltat
-      CALL put_field("WAKE_DELTAT","WAKE_DELTAT",wake_deltat)
-
-      CALL put_field("WAKE_DELTAQ","WAKE_DELTAQ",wake_deltaq)
-      
-      CALL put_field("WAKE_S","WAKE_S",wake_s)
-      
-      CALL put_field("WAKE_CSTAR","WAKE_CSTAR",wake_cstar)
-      
-      CALL put_field("WAKE_PE","WAKE_PE",wake_pe)
-
-      CALL put_field("WAKE_FIP","WAKE_FIP",wake_fip)
-
-c thermiques
-
-      CALL put_field("FM_THERM","FM_THERM",fm_therm)
-
-      CALL put_field("ENTR_THERM","ENTR_THERM",entr_therm)
-
-      CALL put_field("DETR_THERM","DETR_THERM",detr_therm)
-
-! trs from traclmdz_mod
-      IF (type_trac == 'lmdz') THEN
-         CALL traclmdz_to_restart(trs)
-         DO it=1,nbtr
-            iiq=niadv(it+2)
-            CALL put_field("trs_"//tname(iiq),"",trs(:,it))
-         END DO
-         IF (carbon_cycle_cpl) THEN
-            IF (.NOT. ALLOCATED(co2_send)) THEN
-               ! This is the case of create_etat0_limit, ce0l
-               ALLOCATE(co2_send(klon))
-               co2_send(:) = co2_ppm0
-            END IF
-            CALL put_field("co2_send","co2_ppm for coupling",co2_send)
-         END IF
-      END IF
-
-      CALL close_restartphy
-!$OMP BARRIER
-      RETURN
-      END
Index: LMDZ5/branches/testing/libf/phylmd/phyredem.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phyredem.F90	(revision 1864)
+++ LMDZ5/branches/testing/libf/phylmd/phyredem.F90	(revision 1864)
@@ -0,0 +1,345 @@
+! $Id$
+
+SUBROUTINE phyredem (fichnom)
+
+  USE dimphy
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  USE fonte_neige_mod,  ONLY : fonte_neige_final
+  USE pbl_surface_mod,  ONLY : pbl_surface_final
+  USE phys_state_var_mod
+  USE iostart
+  USE traclmdz_mod, ONLY : traclmdz_to_restart
+  USE infotrac
+  USE control_mod
+  USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send
+  USE indice_sol_mod
+
+  IMPLICIT none
+  !======================================================================
+  ! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
+  ! Objet: Ecriture de l'etat de redemarrage pour la physique
+  !======================================================================
+  include "netcdf.inc"
+  include "dimsoil.h"
+  include "clesphys.h"
+  include "temps.h"
+  include "thermcell.h"
+  include "compbl.h"
+  !======================================================================
+  CHARACTER*(*) fichnom
+
+  ! les variables globales ecrites dans le fichier restart
+
+  REAL tsoil(klon, nsoilmx, nbsrf)
+  REAL tslab(klon), seaice(klon)
+  REAL qsurf(klon, nbsrf)
+  REAL qsol(klon)
+  REAL snow(klon, nbsrf)
+  REAL evap(klon, nbsrf)
+  real fder(klon)
+  REAL frugs(klon, nbsrf)
+  REAL agesno(klon, nbsrf)
+  REAL run_off_lic_0(klon)
+  REAL trs(klon, nbtr)
+
+  INTEGER nid, nvarid, idim1, idim2, idim3
+  INTEGER ierr
+  INTEGER length
+  PARAMETER (length=100)
+  REAL tab_cntrl(length)
+
+  INTEGER isoil, nsrf
+  CHARACTER (len=7) :: str7
+  CHARACTER (len=2) :: str2
+  INTEGER           :: it, iiq
+
+  !======================================================================
+
+  ! Get variables which will be written to restart file from module 
+  ! pbl_surface_mod
+  CALL pbl_surface_final(qsol, fder, snow, qsurf,  &
+       evap, frugs, agesno, tsoil)
+
+  ! Get a variable calculated in module fonte_neige_mod
+  CALL fonte_neige_final(run_off_lic_0)
+
+  !======================================================================
+
+  CALL open_restartphy(fichnom)
+
+  DO ierr = 1, length
+     tab_cntrl(ierr) = 0.0
+  ENDDO
+  tab_cntrl(1) = dtime
+  tab_cntrl(2) = radpas
+  ! co2_ppm : current value of atmospheric CO2
+  tab_cntrl(3) = co2_ppm
+  tab_cntrl(4) = solaire
+  tab_cntrl(5) = iflag_con
+  tab_cntrl(6) = nbapp_rad
+
+  IF( cycle_diurne ) tab_cntrl( 7 ) = 1.
+  IF(   soil_model ) tab_cntrl( 8 ) = 1.
+  IF(     new_oliq ) tab_cntrl( 9 ) = 1.
+  IF(     ok_orodr ) tab_cntrl(10 ) = 1.
+  IF(     ok_orolf ) tab_cntrl(11 ) = 1.
+
+  tab_cntrl(13) = day_end
+  tab_cntrl(14) = annee_ref
+  tab_cntrl(15) = itau_phy
+
+  ! co2_ppm0 : initial value of atmospheric CO2
+  tab_cntrl(16) = co2_ppm0
+
+  CALL put_var("controle", "Parametres de controle", tab_cntrl)
+
+  CALL put_field("longitude", &
+       "Longitudes de la grille physique", rlon)
+
+  CALL put_field("latitude", "Latitudes de la grille physique", rlat)
+
+  ! PB ajout du masque terre/mer
+
+  CALL put_field("masque", "masque terre mer", zmasq)
+
+  ! BP ajout des fraction de chaque sous-surface
+
+  ! 1. fraction de terre 
+
+  CALL put_field("FTER", "fraction de continent", pctsrf(:, is_ter))
+
+  ! 2. Fraction de glace de terre
+
+  CALL put_field("FLIC", "fraction glace de terre", pctsrf(:, is_lic))
+
+  ! 3. fraction ocean
+
+  CALL put_field("FOCE", "fraction ocean", pctsrf(:, is_oce))
+
+  ! 4. Fraction glace de mer
+
+  CALL put_field("FSIC", "fraction glace mer", pctsrf(:, is_sic))
+
+  DO nsrf = 1, nbsrf
+     IF (nsrf.LE.99) THEN
+        WRITE(str2, '(i2.2)') nsrf
+        CALL put_field("TS"//str2, "Temperature de surface No."//str2, &
+             ftsol(:, nsrf))
+     ELSE
+        PRINT*, "Trop de sous-mailles"
+        CALL abort
+     ENDIF
+  ENDDO
+
+  DO nsrf = 1, nbsrf
+     DO isoil=1, nsoilmx
+        IF (isoil.LE.99 .AND. nsrf.LE.99) THEN
+           WRITE(str7, '(i2.2, "srf", i2.2)') isoil, nsrf
+           CALL put_field("Tsoil"//str7, "Temperature du sol No."//str7, &
+                tsoil(:, isoil, nsrf))
+        ELSE
+           PRINT*, "Trop de couches"
+           CALL abort
+        ENDIF
+     ENDDO
+  ENDDO
+
+  DO nsrf = 1, nbsrf
+     IF (nsrf.LE.99) THEN
+        WRITE(str2, '(i2.2)') nsrf
+        CALL put_field("QS"//str2, "Humidite de surface No."//str2, &
+             qsurf(:, nsrf))
+     ELSE
+        PRINT*, "Trop de sous-mailles"
+        CALL abort
+     ENDIF
+  END DO
+
+  CALL put_field("QSOL", "Eau dans le sol (mm)", qsol)
+
+  DO nsrf = 1, nbsrf
+     IF (nsrf.LE.99) THEN
+        WRITE(str2, '(i2.2)') nsrf
+        CALL put_field("ALBE"//str2, "albedo de surface No."//str2, &
+             falb1(:, nsrf))
+     ELSE
+        PRINT*, "Trop de sous-mailles"
+        CALL abort
+     ENDIF
+  ENDDO
+
+  DO nsrf = 1, nbsrf
+     IF (nsrf.LE.99) THEN
+        WRITE(str2, '(i2.2)') nsrf
+        CALL put_field("ALBLW"//str2, "albedo LW de surface No."//str2, &
+             falb2(:, nsrf))
+     ELSE
+        PRINT*, "Trop de sous-mailles"
+        CALL abort
+     ENDIF
+  ENDDO
+
+  DO nsrf = 1, nbsrf
+     IF (nsrf.LE.99) THEN
+        WRITE(str2, '(i2.2)') nsrf
+        CALL put_field("EVAP"//str2, "Evaporation de surface No."//str2 &
+             , evap(:, nsrf))
+     ELSE
+        PRINT*, "Trop de sous-mailles"
+        CALL abort
+     ENDIF
+  ENDDO
+
+  DO nsrf = 1, nbsrf
+     IF (nsrf.LE.99) THEN
+        WRITE(str2, '(i2.2)') nsrf
+        CALL put_field("SNOW"//str2, "Neige de surface No."//str2, &
+             snow(:, nsrf))
+     ELSE
+        PRINT*, "Trop de sous-mailles"
+        CALL abort
+     ENDIF
+  ENDDO
+
+  CALL put_field("RADS", "Rayonnement net a la surface", radsol)
+
+  CALL put_field("solsw", "Rayonnement solaire a la surface", solsw)
+
+  CALL put_field("sollw", "Rayonnement IF a la surface", sollw)
+
+  CALL put_field("fder", "Derive de flux", fder)
+
+  CALL put_field("rain_f", "precipitation liquide", rain_fall)
+
+  CALL put_field("snow_f", "precipitation solide", snow_fall)
+
+  DO nsrf = 1, nbsrf
+     IF (nsrf.LE.99) THEN
+        WRITE(str2, '(i2.2)') nsrf
+        CALL put_field("RUG"//str2, "rugosite de surface No."//str2, &
+             frugs(:, nsrf))
+     ELSE
+        PRINT*, "Trop de sous-mailles"
+        CALL abort
+     ENDIF
+  ENDDO
+
+  DO nsrf = 1, nbsrf
+     IF (nsrf.LE.99) THEN
+        WRITE(str2, '(i2.2)') nsrf
+        CALL put_field("AGESNO"//str2, &
+             "Age de la neige surface No."//str2, &
+             agesno(:, nsrf))
+     ELSE
+        PRINT*, "Trop de sous-mailles"
+        CALL abort
+     ENDIF
+  ENDDO
+
+  CALL put_field("ZMEA", "ZMEA", zmea)
+
+  CALL put_field("ZSTD", "ZSTD", zstd)
+
+  CALL put_field("ZSIG", "ZSIG", zsig)
+
+  CALL put_field("ZGAM", "ZGAM", zgam)
+
+  CALL put_field("ZTHE", "ZTHE", zthe)
+
+  CALL put_field("ZPIC", "ZPIC", zpic)
+
+  CALL put_field("ZVAL", "ZVAL", zval)
+
+  CALL put_field("RUGSREL", "RUGSREL", rugoro)
+
+  CALL put_field("TANCIEN", "TANCIEN", t_ancien)
+
+  CALL put_field("QANCIEN", "QANCIEN", q_ancien)
+
+  CALL put_field("UANCIEN", "", u_ancien)
+
+  CALL put_field("VANCIEN", "", v_ancien)
+
+  CALL put_field("RUGMER", "Longueur de rugosite sur mer", &
+       frugs(:, is_oce))
+
+  CALL put_field("CLWCON", "Eau liquide convective", clwcon)
+
+  CALL put_field("RNEBCON", "Nebulosite convective", rnebcon)
+
+  CALL put_field("RATQS", "Ratqs", ratqs)
+
+  ! run_off_lic_0
+
+  CALL put_field("RUNOFFLIC0", "Runofflic0", run_off_lic_0)
+
+  ! DEB TKE PBL !
+
+  IF (iflag_pbl>1) then
+     DO nsrf = 1, nbsrf
+        IF (nsrf.LE.99) THEN
+           WRITE(str2, '(i2.2)') nsrf
+           CALL put_field("TKE"//str2, "Energ. Cineti. Turb."//str2, &
+                pbl_tke(:, 1:klev+1, nsrf))
+        ELSE
+           PRINT*, "Trop de sous-mailles"
+           CALL abort
+        ENDIF
+     ENDDO
+  ENDIF
+
+  ! FIN TKE PBL !
+  !IM ajout zmax0, f0, sig1, w01
+  !IM wake_deltat, wake_deltaq, wake_s, wake_cstar, wake_pe, wake_fip
+
+  CALL put_field("ZMAX0", "ZMAX0", zmax0)
+
+  CALL put_field("F0", "F0", f0)
+
+  CALL put_field("sig1", "sig1 Emanuel", sig1)
+
+  CALL put_field("w01", "w01 Emanuel", w01)
+
+  ! wake_deltat
+  CALL put_field("WAKE_DELTAT", "WAKE_DELTAT", wake_deltat)
+
+  CALL put_field("WAKE_DELTAQ", "WAKE_DELTAQ", wake_deltaq)
+
+  CALL put_field("WAKE_S", "WAKE_S", wake_s)
+
+  CALL put_field("WAKE_CSTAR", "WAKE_CSTAR", wake_cstar)
+
+  CALL put_field("WAKE_PE", "WAKE_PE", wake_pe)
+
+  CALL put_field("WAKE_FIP", "WAKE_FIP", wake_fip)
+
+  ! thermiques
+
+  CALL put_field("FM_THERM", "FM_THERM", fm_therm)
+
+  CALL put_field("ENTR_THERM", "ENTR_THERM", entr_therm)
+
+  CALL put_field("DETR_THERM", "DETR_THERM", detr_therm)
+
+  ! trs from traclmdz_mod
+  IF (type_trac == 'lmdz') THEN
+     CALL traclmdz_to_restart(trs)
+     DO it=1, nbtr
+        iiq=niadv(it+2)
+        CALL put_field("trs_"//tname(iiq), "", trs(:, it))
+     END DO
+     IF (carbon_cycle_cpl) THEN
+        IF (.NOT. ALLOCATED(co2_send)) THEN
+           ! This is the case of create_etat0_limit, ce0l
+           ALLOCATE(co2_send(klon))
+           co2_send(:) = co2_ppm0
+        END IF
+        CALL put_field("co2_send", "co2_ppm for coupling", co2_send)
+     END IF
+  END IF
+
+  CALL close_restartphy
+  !$OMP BARRIER
+
+END SUBROUTINE phyredem
Index: LMDZ5/branches/testing/libf/phylmd/phys_local_var_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phys_local_var_mod.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/phys_local_var_mod.F90	(revision 1864)
@@ -3,5 +3,4 @@
 !
       MODULE phys_local_var_mod
-
 ! Variables locales pour effectuer les appels en serie
 !======================================================================
@@ -187,4 +186,82 @@
 !$OMP THREADPRIVATE(topswcf_aerop, solswcf_aerop)
 
+
+!Ajout de celles nécessaires au phys_output_write_mod
+      REAL, SAVE, ALLOCATABLE :: slp(:)
+!$OMP THREADPRIVATE(slp)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: sens, flwp, fiwp 
+!$OMP THREADPRIVATE(sens, flwp, fiwp)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: ale_wake, alp_wake, bils
+!$OMP THREADPRIVATE(ale_wake, alp_wake, bils)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cdragm, cdragh
+!$OMP THREADPRIVATE(cdragm, cdragh)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: cldh, cldl, cldm, cldq, cldt, qsat2m, qsol
+!$OMP THREADPRIVATE(cldh, cldl, cldm, cldq, cldt, qsat2m, qsol)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: dthmin, evap, fder, plcl, plfc, prw
+!$OMP THREADPRIVATE(dthmin, evap, fder, plcl, plfc, prw)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zustar, zu10m, zv10m, rh2m
+!$OMP THREADPRIVATE(zustar, zu10m, zv10m, rh2m)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: s_lcl, s_pblh, s_pblt, s_therm
+!$OMP THREADPRIVATE(s_lcl, s_pblh, s_pblt, s_therm)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: slab_wfbils
+!$OMP THREADPRIVATE(slab_wfbils)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: tpot, tpote, ue, uq, ve, vq, zxffonte
+!$OMP THREADPRIVATE(tpot, tpote, ue, uq, ve, vq, zxffonte)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxfqcalving
+!$OMP THREADPRIVATE(zxfqcalving)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxfluxlat, zxrugs, zxtsol, snow_lsc, zxfqfonte
+!$OMP THREADPRIVATE(zxfluxlat, zxrugs, zxtsol, snow_lsc, zxfqfonte)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: zxqsurf, rain_lsc
+!$OMP THREADPRIVATE(zxqsurf, rain_lsc)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: wake_h, wbeff, zmax_th, zq2m, zt2m
+!$OMP THREADPRIVATE(wake_h, wbeff, zmax_th, zq2m, zt2m)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: weak_inversion
+!$OMP THREADPRIVATE(weak_inversion)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: ale_bl_stat,alp_bl_conv,alp_bl_det
+!$OMP THREADPRIVATE(ale_bl_stat,alp_bl_conv,alp_bl_det)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: alp_bl_fluct_m,alp_bl_fluct_tke
+!$OMP THREADPRIVATE(alp_bl_fluct_m,alp_bl_fluct_tke)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: alp_bl_stat, n2, s2
+!$OMP THREADPRIVATE(alp_bl_stat, n2, s2)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:) :: proba_notrig, random_notrig
+!$OMP THREADPRIVATE(proba_notrig, random_notrig)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: fsolsw, wfbils, wfbilo
+!$OMP THREADPRIVATE(fsolsw, wfbils, wfbilo)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:)  :: t2m, fevap, fluxlat, fsollw,evap_pot
+!$OMP THREADPRIVATE(t2m, fevap, fluxlat, fsollw,evap_pot)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: dnwd, dnwd0, upwd, omega
+!$OMP THREADPRIVATE(dnwd, dnwd0, upwd, omega)
+!      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: coefh, coefm, lambda_th
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: lambda_th
+!$OMP THREADPRIVATE(lambda_th)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: cldemi, cldfra, cldtau, fiwc, fl, re, flwc
+!$OMP THREADPRIVATE(cldemi, cldfra, cldtau, fiwc, fl, re, flwc)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: ref_liq, ref_ice, theta, zphi
+!$OMP THREADPRIVATE(ref_liq, ref_ice, theta, zphi)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: wake_omg, zx_rh
+!$OMP THREADPRIVATE(wake_omg, zx_rh)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: frugs, agesno
+!$OMP THREADPRIVATE(frugs, agesno)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: pmflxr, pmflxs, prfl, psfl, fraca
+!$OMP THREADPRIVATE(pmflxr, pmflxs, prfl, psfl, fraca)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: Vprecip, zw2
+!$OMP THREADPRIVATE(Vprecip, zw2)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: pmfd, pmfu
+!$OMP THREADPRIVATE(pmfd, pmfu)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: fluxt, fluxu, fluxv
+!$OMP THREADPRIVATE(fluxt, fluxu, fluxv)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: uwriteSTD, vwriteSTD, wwriteSTD
+!$OMP THREADPRIVATE(uwriteSTD, vwriteSTD, wwriteSTD)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:,:) :: phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD
+!$OMP THREADPRIVATE(phiwriteSTD, qwriteSTD, twriteSTD, rhwriteSTD)
+
+! ug et d'autres encore:
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: wdtrainA, wdtrainM
+!$OMP THREADPRIVATE(wdtrainA, wdtrainM)
+      REAL,ALLOCATABLE,SAVE,DIMENSION(:,:) :: beta_prec
+!$OMP THREADPRIVATE(beta_prec)
+      REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: rneb
+!$OMP THREADPRIVATE(rneb)
+
 CONTAINS
 
@@ -195,4 +272,6 @@
 USE aero_mod
 USE indice_sol_mod
+USE phys_output_var_mod
+USE phys_state_var_mod
 
 IMPLICIT NONE
@@ -279,4 +358,60 @@
       ALLOCATE(topswcf_aerop(klon,naero_grp), solswcf_aerop(klon,naero_grp))
 
+! FH Ajout de celles nécessaires au phys_output_write_mod
+
+      ALLOCATE(slp(klon))
+      ALLOCATE(ale_wake(klon), alp_wake(klon), bils(klon))
+      ALLOCATE(cdragm(klon), cdragh(klon), cldh(klon), cldl(klon))
+      ALLOCATE(cldm(klon), cldq(klon), cldt(klon), qsat2m(klon), qsol(klon))
+      ALLOCATE(dthmin(klon), evap(klon), fder(klon), plcl(klon), plfc(klon))
+      ALLOCATE(prw(klon), zustar(klon), zu10m(klon), zv10m(klon), rh2m(klon))
+      ALLOCATE(s_lcl(klon))
+      ALLOCATE(s_pblh(klon), s_pblt(klon), s_therm(klon))
+      ALLOCATE(slab_wfbils(klon), tpot(klon), tpote(klon), ue(klon))
+      ALLOCATE(uq(klon), ve(klon), vq(klon), zxffonte(klon))
+      ALLOCATE(zxfqcalving(klon), zxfluxlat(klon), zxrugs(klon))
+      ALLOCATE(zxtsol(klon), snow_lsc(klon), zxfqfonte(klon), zxqsurf(klon))
+      ALLOCATE(rain_lsc(klon), wake_h(klon), wbeff(klon), zmax_th(klon))
+      ALLOCATE(zq2m(klon), zt2m(klon), weak_inversion(klon))
+      ALLOCATE(sens(klon), flwp(klon), fiwp(klon))
+      ALLOCATE(ale_bl_stat(klon), alp_bl_conv(klon), alp_bl_det(klon))
+      ALLOCATE(alp_bl_fluct_m(klon), alp_bl_fluct_tke(klon))
+      ALLOCATE(alp_bl_stat(klon), n2(klon), s2(klon))
+      ALLOCATE(proba_notrig(klon), random_notrig(klon))
+
+      ALLOCATE(dnwd(klon, klev), dnwd0(klon, klev))
+!      ALLOCATE(upwd(klon, klev), omega(klon, klev), coefh(klon, klev))
+      ALLOCATE(upwd(klon, klev), omega(klon, klev))
+!      ALLOCATE(coefm(klon, klev), lambda_th(klon, klev), cldemi(klon, klev))
+      ALLOCATE(lambda_th(klon, klev), cldemi(klon, klev))
+      ALLOCATE(cldfra(klon, klev), cldtau(klon, klev), fiwc(klon, klev))
+      ALLOCATE(fl(klon, klev), re(klon, klev), flwc(klon, klev))
+      ALLOCATE(ref_liq(klon, klev), ref_ice(klon, klev), theta(klon, klev))
+      ALLOCATE(zphi(klon, klev), wake_omg(klon, klev), zx_rh(klon, klev))
+      ALLOCATE(pmfd(klon, klev), pmfu(klon, klev))
+
+      ALLOCATE(t2m(klon, nbsrf), fevap(klon, nbsrf), fluxlat(klon, nbsrf))
+      ALLOCATE(frugs(klon, nbsrf), agesno(klon, nbsrf), fsollw(klon, nbsrf))
+      ALLOCATE(fsolsw(klon, nbsrf), wfbils(klon, nbsrf), wfbilo(klon, nbsrf))
+      ALLOCATE(evap_pot(klon, nbsrf))
+
+      ALLOCATE(pmflxr(klon, klev+1), pmflxs(klon, klev+1), prfl(klon, klev+1))
+      ALLOCATE(psfl(klon, klev+1), fraca(klon, klev+1), Vprecip(klon, klev+1))
+      ALLOCATE(zw2(klon, klev+1))
+
+      ALLOCATE(fluxu(klon, klev, nbsrf), fluxv(klon, klev, nbsrf))
+      ALLOCATE(fluxt(klon, klev, nbsrf))
+
+      ALLOCATE(uwriteSTD(klon,nlevSTD,nfiles), vwriteSTD(klon,nlevSTD,nfiles))
+      ALLOCATE(wwriteSTD(klon,nlevSTD,nfiles), phiwriteSTD(klon,nlevSTD,nfiles))
+      ALLOCATE(qwriteSTD(klon,nlevSTD,nfiles), twriteSTD(klon,nlevSTD,nfiles))
+      ALLOCATE(rhwriteSTD(klon,nlevSTD,nfiles))
+
+! ug et d'autres encore:
+      ALLOCATE(wdtrainA(klon,klev),wdtrainM(klon,klev))
+      ALLOCATE(beta_prec(klon,klev))
+      ALLOCATE(rneb(klon,klev))
+
+
 END SUBROUTINE phys_local_var_init
 
@@ -368,4 +503,56 @@
       deallocate(topswcf_aerop, solswcf_aerop)
 
+
+! FH Ajout de celles nécessaires au phys_output_write_mod
+      DEALLOCATE(slp)
+      DEALLOCATE(ale_wake, alp_wake, bils)
+      DEALLOCATE(cdragm, cdragh, cldh, cldl)
+      DEALLOCATE(cldm, cldq, cldt, qsat2m, qsol)
+      DEALLOCATE(dthmin, evap, fder, plcl, plfc)
+      DEALLOCATE(prw, zustar, zu10m, zv10m, rh2m, s_lcl)
+      DEALLOCATE(s_pblh, s_pblt, s_therm)
+      DEALLOCATE(slab_wfbils, tpot, tpote, ue)
+      DEALLOCATE(uq, ve, vq, zxffonte)
+      DEALLOCATE(zxfqcalving, zxfluxlat, zxrugs)
+      DEALLOCATE(zxtsol, snow_lsc, zxfqfonte, zxqsurf)
+      DEALLOCATE(rain_lsc, wake_h, wbeff, zmax_th)
+      DEALLOCATE(zq2m, zt2m, weak_inversion)
+      DEALLOCATE(sens, flwp, fiwp)
+      DEALLOCATE(ale_bl_stat,alp_bl_conv,alp_bl_det)
+      DEALLOCATE(alp_bl_fluct_m,alp_bl_fluct_tke)
+      DEALLOCATE(alp_bl_stat, n2, s2)
+      DEALLOCATE(proba_notrig, random_notrig)
+
+      DEALLOCATE(dnwd, dnwd0)
+!      DEALLOCATE(upwd, omega, coefh)
+      DEALLOCATE(upwd, omega)
+!      DEALLOCATE(coefm, lambda_th, cldemi)
+      DEALLOCATE(lambda_th, cldemi)
+      DEALLOCATE(cldfra, cldtau, fiwc)
+      DEALLOCATE(fl, re, flwc)
+      DEALLOCATE(ref_liq, ref_ice, theta)
+      DEALLOCATE(zphi, wake_omg, zx_rh)
+      DEALLOCATE(pmfd, pmfu)
+
+      DEALLOCATE(t2m, fevap, fluxlat)
+      DEALLOCATE(frugs, agesno, fsollw, evap_pot)
+      DEALLOCATE(fsolsw, wfbils, wfbilo)
+
+      DEALLOCATE(pmflxr, pmflxs, prfl)
+      DEALLOCATE(psfl, fraca, Vprecip)
+      DEALLOCATE(zw2)
+
+      DEALLOCATE(fluxu, fluxv)
+      DEALLOCATE(fluxt)
+
+      DEALLOCATE(uwriteSTD, vwriteSTD)
+      DEALLOCATE(wwriteSTD, phiwriteSTD)
+      DEALLOCATE(qwriteSTD, twriteSTD, rhwriteSTD)
+
+! ug et d'autres encore:
+      DEALLOCATE(wdtrainA, wdtrainM)
+      DEALLOCATE(beta_prec)
+      DEALLOCATE(rneb)
+
 END SUBROUTINE phys_local_var_end
 
Index: LMDZ5/branches/testing/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 1864)
@@ -19,463 +19,477 @@
 !!! Comosantes de la coordonnee sigma-hybride
 !!! Ap et Bp
-  TYPE(ctrl_out), SAVE :: o_Ahyb = ctrl_out((/ 1, 1, 1, 1, 1, 1 /), &
-	'Ap', '', '', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_Bhyb = ctrl_out((/ 1, 1, 1, 1, 1, 1 /), &
-	'Bp', '', '', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_Alt = ctrl_out((/ 1, 1, 1, 1, 1, 1 /), &
-	'Alt', '', '', (/ ('', i=1, 6) /))
+  TYPE(ctrl_out), SAVE :: o_Ahyb = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11 /), &
+    'Ap', '', '', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Bhyb = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11 /), &
+    'Bp', '', '', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Alt = ctrl_out((/ 1, 1, 1, 1, 1, 1, 11, 11, 11 /), &
+    'Alt', '', '', (/ ('', i=1, 9) /))
 
 !!! 1D
-  TYPE(ctrl_out), SAVE :: o_phis = ctrl_out((/ 1, 1, 10, 5, 1, 1 /), &
-	'phis', 'Surface geop.height', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_aire = ctrl_out((/ 1, 1, 10,  10, 1, 1 /), &
-	'aire', 'Grid area', '-', (/ 'once', 'once', 'once', 'once', 'once', 'once' /))
-  TYPE(ctrl_out), SAVE :: o_contfracATM = ctrl_out((/ 10, 1,  1, 10, 10, 10 /), &
-	'contfracATM', '% sfce ter+lic', '-', &
-      (/ "once", "once", "once", "once", "once", "once" /))
-  TYPE(ctrl_out), SAVE :: o_contfracOR = ctrl_out((/ 10, 1,  1, 10, 10, 10 /), &
-	'contfracOR', '% sfce terre OR', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_aireTER = ctrl_out((/ 10, 10, 1, 10, 10, 10 /), &
-	'aireTER', 'Grid area CONT', '-', (/ ('', i=1, 6) /))
+  TYPE(ctrl_out), SAVE :: o_phis = ctrl_out((/ 1, 1, 10, 5, 1, 1, 11, 11, 11 /), &
+    'phis', 'Surface geop.height', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_aire = ctrl_out((/ 1, 1, 10,  10, 1, 1, 11, 11, 11 /), &
+    'aire', 'Grid area', '-', (/ 'once', 'once', 'once', 'once', 'once', 'once', &
+                                     'once', 'once', 'once' /))
+  TYPE(ctrl_out), SAVE :: o_contfracATM = ctrl_out((/ 10, 1,  1, 10, 10, 10, 11, 11, 11 /), &
+    'contfracATM', '% sfce ter+lic', '-', &
+       (/ 'once', 'once', 'once', 'once', 'once', 'once', 'once', 'once', 'once' /)) 
+  TYPE(ctrl_out), SAVE :: o_contfracOR = ctrl_out((/ 10, 1,  10, 10, 10, 10, 11, 11, 11 /), &
+    'contfracOR', '% sfce terre OR', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_aireTER = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'aireTER', 'Grid area CONT', '-', (/ ('', i=1, 9) /))
 
 !!! 2D
-  TYPE(ctrl_out), SAVE :: o_flat = ctrl_out((/ 5, 1, 10, 10, 5, 10 /), &
-	'flat', 'Latent heat flux', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_slp = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'slp', 'Sea Level Pressure', 'Pa', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tsol = ctrl_out((/ 1, 1, 1, 5, 10, 10 /), &
-	'tsol', 'Surface Temperature', 'K', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_t2m = ctrl_out((/ 1, 1, 1, 5, 10, 10 /), &
-	't2m', 'Temperature 2m', 'K', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_t2m_min = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	't2m_min', 'Temp 2m min', 'K', &
-      (/ "t_min(X)", "t_min(X)", "t_min(X)", "t_min(X)", "t_min(X)", "t_min(X)" /))
-  TYPE(ctrl_out), SAVE :: o_t2m_max = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	't2m_max', 'Temp 2m max', 'K', &
-      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /))
+  TYPE(ctrl_out), SAVE :: o_flat = ctrl_out((/ 5, 1, 10, 10, 5, 10, 11, 11, 11 /), &
+    'flat', 'Latent heat flux', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_slp = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'slp', 'Sea Level Pressure', 'Pa', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tsol = ctrl_out((/ 1, 1, 1, 5, 10, 10, 11, 11, 11 /), &
+    'tsol', 'Surface Temperature', 'K', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_t2m = ctrl_out((/ 1, 1, 1, 5, 10, 10, 11, 11, 11 /), &
+    't2m', 'Temperature 2m', 'K', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_t2m_min = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    't2m_min', 'Temp 2m min', 'K', &
+      (/ "t_min(X)", "t_min(X)", "t_min(X)", "t_min(X)", "t_min(X)", "t_min(X)", "t_min(X)", "t_min(X)", "t_min(X)" /))
+  TYPE(ctrl_out), SAVE :: o_t2m_max = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    't2m_max', 'Temp 2m max', 'K', &
+      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", &
+         "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /))
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_t2m_srf = (/ &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /), &
-	't2m_ter', "Temp 2m "//clnsurf(1), "K", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /), &
-	't2m_lic', "Temp 2m "//clnsurf(2), "K", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /), &
-	't2m_oce', "Temp 2m "//clnsurf(3), "K", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /), &
-	't2m_sic', "Temp 2m "//clnsurf(4), "K", (/ ('', i=1, 6) /)) /)
-
-  TYPE(ctrl_out), SAVE :: o_wind10m = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'wind10m', '10-m wind speed', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wind10max = ctrl_out((/ 10, 1, 10, 10, 10, 10 /), &
-	'wind10max', '10m wind speed max', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_sicf = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'sicf', 'Sea-ice fraction', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_q2m = ctrl_out((/ 1, 1, 1, 5, 10, 10 /), &
-	'q2m', 'Specific humidity 2m', 'kg/kg', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ustar = ctrl_out((/ 1, 1, 1, 5, 10, 10 /), &
-	'ustar', 'Friction velocity', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_u10m = ctrl_out((/ 1, 1, 1, 5, 10, 10 /), &
-	'u10m', 'Vent zonal 10m', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_v10m = ctrl_out((/ 1, 1, 1, 5, 10, 10 /), &
-	'v10m', 'Vent meridien 10m', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_psol = ctrl_out((/ 1, 1, 1, 5, 10, 10 /), &
-	'psol', 'Surface Pressure', 'Pa', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_qsurf = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'qsurf', 'Surface Air humidity', 'kg/kg', (/ ('', i=1, 6) /))
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    't2m_ter', "Temp 2m "//clnsurf(1), "K", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    't2m_lic', "Temp 2m "//clnsurf(2), "K", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    't2m_oce', "Temp 2m "//clnsurf(3), "K", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    't2m_sic', "Temp 2m "//clnsurf(4), "K", (/ ('', i=1, 9) /)) /)
+
+  TYPE(ctrl_out), SAVE :: o_wind10m = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'wind10m', '10-m wind speed', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wind10max = ctrl_out((/ 10, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'wind10max', '10m wind speed max', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_sicf = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'sicf', 'Sea-ice fraction', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_q2m = ctrl_out((/ 1, 1, 1, 5, 10, 10, 11, 11, 11 /), &
+    'q2m', 'Specific humidity 2m', 'kg/kg', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ustar = ctrl_out((/ 1, 1, 10, 5, 10, 10, 11, 11, 11 /), &
+    'ustar', 'Friction velocity', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_u10m = ctrl_out((/ 1, 1, 1, 5, 10, 10, 11, 11, 11 /), &
+    'u10m', 'Vent zonal 10m', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_v10m = ctrl_out((/ 1, 1, 1, 5, 10, 10, 11, 11, 11 /), &
+    'v10m', 'Vent meridien 10m', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_psol = ctrl_out((/ 1, 1, 1, 5, 10, 10, 11, 11, 11 /), &
+    'psol', 'Surface Pressure', 'Pa', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_qsurf = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'qsurf', 'Surface Air humidity', 'kg/kg', (/ ('', i=1, 9) /))
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_ustar_srf     = (/ &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'ustar_ter', &
-      "Friction velocity "//clnsurf(1),"m/s", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'ustar_lic', &
-      "Friction velocity "//clnsurf(2),"m/s", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'ustar_oce', &
-      "Friction velocity "//clnsurf(3),"m/s", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'ustar_sic', &
-      "Friction velocity "//clnsurf(4),"m/s", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'ustar_ter', &
+      "Friction velocity "//clnsurf(1),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'ustar_lic', &
+      "Friction velocity "//clnsurf(2),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'ustar_oce', &
+      "Friction velocity "//clnsurf(3),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'ustar_sic', &
+      "Friction velocity "//clnsurf(4),"m/s", (/ ('', i=1, 9) /)) /)
+
+  TYPE(ctrl_out), SAVE, DIMENSION(5) :: o_wstar         = (/ &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'wstar_ter', &
+      "Friction velocity "//clnsurf(1),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'wstar_lic', &
+      "Friction velocity "//clnsurf(2),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'wstar_oce', &
+      "Friction velocity "//clnsurf(3),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'wstar_sic', &
+      "Friction velocity "//clnsurf(4),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 5, 5, 10, 10, 10, 10, 11, 11, 11 /),'wstar', &
+      "w* convective velocity "//clnsurf(4),"m/s", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_u10m_srf     = (/ &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'u10m_ter', &
-      "Vent Zonal 10m "//clnsurf(1),"m/s", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'u10m_lic', &
-      "Vent Zonal 10m "//clnsurf(2),"m/s", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'u10m_oce', &
-      "Vent Zonal 10m "//clnsurf(3),"m/s", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'u10m_sic', &
-      "Vent Zonal 10m "//clnsurf(4),"m/s", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'u10m_ter', &
+      "Vent Zonal 10m "//clnsurf(1),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'u10m_lic', &
+      "Vent Zonal 10m "//clnsurf(2),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'u10m_oce', &
+      "Vent Zonal 10m "//clnsurf(3),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'u10m_sic', &
+      "Vent Zonal 10m "//clnsurf(4),"m/s", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_v10m_srf     = (/ &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'v10m_ter', &
-      "Vent meredien 10m "//clnsurf(1),"m/s", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'v10m_lic', &
-      "Vent meredien 10m "//clnsurf(2),"m/s", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'v10m_oce', &
-      "Vent meredien 10m "//clnsurf(3),"m/s", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 6, 10, 10, 10, 10 /),'v10m_sic', &
-      "Vent meredien 10m "//clnsurf(4),"m/s", (/ ('', i=1, 6) /)) /)
-
-  TYPE(ctrl_out), SAVE :: o_qsol = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'qsol', 'Soil watter content', 'mm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ndayrain = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'ndayrain', 'Number of dayrain(liq+sol)', '-', &
-      (/ "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)" /))
-  TYPE(ctrl_out), SAVE :: o_precip = ctrl_out((/ 1, 1, 1, 10, 5, 10 /), &
-	'precip', 'Precip Totale liq+sol', 'kg/(s*m2)', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_plul = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'plul', 'Large-scale Precip.', 'kg/(s*m2)', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_pluc = ctrl_out((/ 1, 1, 1, 10, 5, 10 /), &
-	'pluc', 'Convective Precip.', 'kg/(s*m2)', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_snow = ctrl_out((/ 1, 1, 10, 10, 5, 10 /), &
-	'snow', 'Snow fall', 'kg/(s*m2)', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_evap = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'evap', 'Evaporat', 'kg/(s*m2)', (/ ('', i=1, 6) /))
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'v10m_ter', &
+      "Vent meredien 10m "//clnsurf(1),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'v10m_lic', &
+      "Vent meredien 10m "//clnsurf(2),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'v10m_oce', &
+      "Vent meredien 10m "//clnsurf(3),"m/s", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 6, 10, 10, 10, 10, 11, 11, 11 /),'v10m_sic', &
+      "Vent meredien 10m "//clnsurf(4),"m/s", (/ ('', i=1, 9) /)) /)
+
+  TYPE(ctrl_out), SAVE :: o_qsol = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'qsol', 'Soil watter content', 'mm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ndayrain = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ndayrain', 'Number of dayrain(liq+sol)', '-', &
+      (/ "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)" /))
+  TYPE(ctrl_out), SAVE :: o_precip = ctrl_out((/ 1, 1, 1, 10, 5, 10, 11, 11, 11 /), &
+    'precip', 'Precip Totale liq+sol', 'kg/(s*m2)', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_plul = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'plul', 'Large-scale Precip.', 'kg/(s*m2)', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_pluc = ctrl_out((/ 1, 1, 1, 10, 5, 10, 11, 11, 11 /), &
+    'pluc', 'Convective Precip.', 'kg/(s*m2)', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_snow = ctrl_out((/ 1, 1, 10, 10, 5, 10, 11, 11, 11 /), &
+    'snow', 'Snow fall', 'kg/(s*m2)', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_evap = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'evap', 'Evaporat', 'kg/(s*m2)', (/ ('', i=1, 9) /))
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_evap_srf     = (/ &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'evap_ter', &
-      "evaporation at surface "//clnsurf(1),"kg/(s*m2)", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'evap_lic', &
-      "evaporation at surface "//clnsurf(2),"kg/(s*m2)", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'evap_oce', &
-      "evaporation at surface "//clnsurf(3),"kg/(s*m2)", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'evap_sic', &
-      "evaporation at surface "//clnsurf(4),"kg/(s*m2)", (/ ('', i=1, 6) /)) /)
-
-  TYPE(ctrl_out), SAVE :: o_msnow = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'msnow', 'Surface snow amount', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_fsnow = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'fsnow', 'Surface snow area fraction', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tops = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'tops', 'Solar rad. at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tops0 = ctrl_out((/ 1, 5, 10, 10, 10, 10 /), &
-	'tops0', 'CS Solar rad. at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_topl = ctrl_out((/ 1, 1, 10, 5, 10, 10 /), &
-	'topl', 'IR rad. at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_topl0 = ctrl_out((/ 1, 5, 10, 10, 10, 10 /), &
-	'topl0', 'IR rad. at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWupTOA = ctrl_out((/ 1, 4, 10, 10, 10, 10 /), &
-	'SWupTOA', 'SWup at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWupTOAclr = ctrl_out((/ 1, 4, 10, 10, 10, 10 /), &
-	'SWupTOAclr', 'SWup clear sky at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWdnTOA = ctrl_out((/ 1, 4, 10, 10, 10, 10 /), &
-	'SWdnTOA', 'SWdn at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWdnTOAclr = ctrl_out((/ 1, 4, 10, 10, 10, 10 /), &
-	'SWdnTOAclr', 'SWdn clear sky at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_nettop = ctrl_out((/ 1, 4, 10, 10, 10, 10 /), &
-	'nettop', 'Net dn radiatif flux at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWup200 = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'SWup200', 'SWup at 200mb', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWup200clr = ctrl_out((/ 10, 1, 10, 10, 10, 10 /), &
-	'SWup200clr', 'SWup clear sky at 200mb', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWdn200 = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'SWdn200', 'SWdn at 200mb', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWdn200clr = ctrl_out((/ 10, 1, 10, 10, 10, 10 /), &
-	'SWdn200clr', 'SWdn clear sky at 200mb', 'W/m2', (/ ('', i=1, 6) /))
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'evap_ter', &
+      "evaporation at surface "//clnsurf(1),"kg/(s*m2)", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'evap_lic', &
+      "evaporation at surface "//clnsurf(2),"kg/(s*m2)", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'evap_oce', &
+      "evaporation at surface "//clnsurf(3),"kg/(s*m2)", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'evap_sic', &
+      "evaporation at surface "//clnsurf(4),"kg/(s*m2)", (/ ('', i=1, 9) /)) /)
+
+  TYPE(ctrl_out), SAVE :: o_msnow = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'msnow', 'Surface snow amount', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_fsnow = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'fsnow', 'Surface snow area fraction', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tops = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tops', 'Solar rad. at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tops0 = ctrl_out((/ 1, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tops0', 'CS Solar rad. at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_topl = ctrl_out((/ 1, 1, 10, 5, 10, 10, 11, 11, 11 /), &
+    'topl', 'IR rad. at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_topl0 = ctrl_out((/ 1, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'topl0', 'IR rad. at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWupTOA = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWupTOA', 'SWup at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWupTOAclr = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWupTOAclr', 'SWup clear sky at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWdnTOA = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWdnTOA', 'SWdn at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWdnTOAclr = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWdnTOAclr', 'SWdn clear sky at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_nettop = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11 /), &
+    'nettop', 'Net dn radiatif flux at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWup200 = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWup200', 'SWup at 200mb', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWup200clr = ctrl_out((/ 10, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWup200clr', 'SWup clear sky at 200mb', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWdn200 = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWdn200', 'SWdn at 200mb', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWdn200clr = ctrl_out((/ 10, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWdn200clr', 'SWdn clear sky at 200mb', 'W/m2', (/ ('', i=1, 9) /))
 
   ! arajouter
-  !  type(ctrl_out),save :: o_LWupTOA     = ctrl_out((/ 1, 4, 10, 10, 10, 10 /),'LWupTOA', &
-  !	(/ ('', i=1, 6) /))
-  !  type(ctrl_out),save :: o_LWupTOAclr  = ctrl_out((/ 1, 4, 10, 10, 10, 10 /),'LWupTOAclr', &
-  !	(/ ('', i=1, 6) /))
-  !  type(ctrl_out),save :: o_LWdnTOA     = ctrl_out((/ 1, 4, 10, 10, 10, 10 /),'LWdnTOA', &
-  !	(/ ('', i=1, 6) /))
-  !  type(ctrl_out),save :: o_LWdnTOAclr  = ctrl_out((/ 1, 4, 10, 10, 10, 10 /),'LWdnTOAclr', &
-  !	(/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_LWup200 = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'LWup200', 'LWup at 200mb', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_LWup200clr = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'LWup200clr', 'LWup clear sky at 200mb', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_LWdn200 = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'LWdn200', 'LWdn at 200mb', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_LWdn200clr = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'LWdn200clr', 'LWdn clear sky at 200mb', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_sols = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'sols', 'Solar rad. at surf.', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_sols0 = ctrl_out((/ 1, 5, 10, 10, 10, 10 /), &
-	'sols0', 'Solar rad. at surf.', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_soll = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'soll', 'IR rad. at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_soll0 = ctrl_out((/ 1, 5, 10, 10, 10, 10 /), &
-	'soll0', 'IR rad. at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_radsol = ctrl_out((/ 1, 7, 10, 10, 10, 10 /), &
-	'radsol', 'Rayonnement au sol', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWupSFC = ctrl_out((/ 1, 4, 10, 10, 5, 10 /), &
-	'SWupSFC', 'SWup at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWupSFCclr = ctrl_out((/ 1, 4, 10, 10, 5, 10 /), &
-	'SWupSFCclr', 'SWup clear sky at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWdnSFC = ctrl_out((/ 1, 1, 10, 10, 5, 10 /), &
-	'SWdnSFC', 'SWdn at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWdnSFCclr = ctrl_out((/ 1, 4, 10, 10, 5, 10 /), &
-	'SWdnSFCclr', 'SWdn clear sky at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_LWupSFC = ctrl_out((/ 1, 4, 10, 10, 5, 10 /), &
-	'LWupSFC', 'Upwd. IR rad. at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_LWupSFCclr = ctrl_out((/ 1, 4, 10, 10, 5, 10 /), &
-	'LWupSFCclr', 'CS Upwd. IR rad. at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_LWdnSFC = ctrl_out((/ 1, 4, 10, 10, 5, 10 /), &
-	'LWdnSFC', 'Down. IR rad. at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_LWdnSFCclr = ctrl_out((/ 1, 4, 10, 10, 5, 10 /), &
-	'LWdnSFCclr', 'Down. CS IR rad. at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_bils = ctrl_out((/ 1, 2, 10, 5, 10, 10 /), &
-	'bils', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_bils_tke = ctrl_out((/ 1, 2, 10, 5, 10, 10 /), &
-	'bils_tke', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_bils_diss = ctrl_out((/ 1, 2, 10, 5, 10, 10 /), &
-	'bils_diss', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_bils_ec = ctrl_out((/ 1, 2, 10, 5, 10, 10 /), &
-	'bils_ec', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_bils_kinetic = ctrl_out((/ 1, 2, 10, 5, 10, 10 /), &
-	'bils_kinetic', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_bils_enthalp = ctrl_out((/ 1, 2, 10, 5, 10, 10 /), &
-	'bils_enthalp', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_bils_latent = ctrl_out((/ 1, 2, 10, 5, 10, 10 /), &
-	'bils_latent', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_sens = ctrl_out((/ 1, 1, 10, 10, 5, 10 /), &
-	'sens', 'Sensible heat flux', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_fder = ctrl_out((/ 1, 2, 10, 10, 10, 10 /), &
-	'fder', 'Heat flux derivation', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ffonte = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'ffonte', 'Thermal flux for snow melting', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_fqcalving = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'fqcalving', 'Ice Calving', 'kg/m2/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_fqfonte = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'fqfonte', 'Land ice melt', 'kg/m2/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_taux = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'taux', 'Zonal wind stress', 'Pa', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tauy = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'tauy', 'Meridional wind stress', 'Pa', (/ ('', i=1, 6) /))
+  !  type(ctrl_out),save :: o_LWupTOA     = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11 /),'LWupTOA', &
+  !    (/ ('', i=1, 9) /))
+  !  type(ctrl_out),save :: o_LWupTOAclr  = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11 /),'LWupTOAclr', &
+  !    (/ ('', i=1, 9) /))
+  !  type(ctrl_out),save :: o_LWdnTOA     = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11 /),'LWdnTOA', &
+  !    (/ ('', i=1, 9) /))
+  !  type(ctrl_out),save :: o_LWdnTOAclr  = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11 /),'LWdnTOAclr', &
+  !    (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_LWup200 = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'LWup200', 'LWup at 200mb', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_LWup200clr = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'LWup200clr', 'LWup clear sky at 200mb', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_LWdn200 = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'LWdn200', 'LWdn at 200mb', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_LWdn200clr = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'LWdn200clr', 'LWdn clear sky at 200mb', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_sols = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'sols', 'Solar rad. at surf.', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_sols0 = ctrl_out((/ 1, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'sols0', 'Solar rad. at surf.', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_soll = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'soll', 'IR rad. at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_soll0 = ctrl_out((/ 1, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'soll0', 'IR rad. at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_radsol = ctrl_out((/ 1, 7, 10, 10, 10, 10, 11, 11, 11 /), &
+    'radsol', 'Rayonnement au sol', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWupSFC = ctrl_out((/ 1, 4, 10, 10, 5, 10, 11, 11, 11 /), &
+    'SWupSFC', 'SWup at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWupSFCclr = ctrl_out((/ 1, 4, 10, 10, 5, 10, 11, 11, 11 /), &
+    'SWupSFCclr', 'SWup clear sky at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWdnSFC = ctrl_out((/ 1, 1, 10, 10, 5, 10, 11, 11, 11 /), &
+    'SWdnSFC', 'SWdn at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWdnSFCclr = ctrl_out((/ 1, 4, 10, 10, 5, 10, 11, 11, 11 /), &
+    'SWdnSFCclr', 'SWdn clear sky at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_LWupSFC = ctrl_out((/ 1, 4, 10, 10, 5, 10, 11, 11, 11 /), &
+    'LWupSFC', 'Upwd. IR rad. at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_LWupSFCclr = ctrl_out((/ 1, 4, 10, 10, 5, 10, 11, 11, 11 /), &
+    'LWupSFCclr', 'CS Upwd. IR rad. at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_LWdnSFC = ctrl_out((/ 1, 4, 10, 10, 5, 10, 11, 11, 11 /), &
+    'LWdnSFC', 'Down. IR rad. at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_LWdnSFCclr = ctrl_out((/ 1, 4, 10, 10, 5, 10, 11, 11, 11 /), &
+    'LWdnSFCclr', 'Down. CS IR rad. at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_bils = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
+    'bils', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_bils_tke = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
+    'bils_tke', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_bils_diss = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
+    'bils_diss', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_bils_ec = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
+    'bils_ec', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_bils_kinetic = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
+    'bils_kinetic', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_bils_enthalp = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
+    'bils_enthalp', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_bils_latent = ctrl_out((/ 1, 2, 10, 5, 10, 10, 11, 11, 11 /), &
+    'bils_latent', 'Surf. total heat flux', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_sens = ctrl_out((/ 1, 1, 10, 10, 5, 10, 11, 11, 11 /), &
+    'sens', 'Sensible heat flux', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_fder = ctrl_out((/ 1, 2, 10, 10, 10, 10, 11, 11, 11 /), &
+    'fder', 'Heat flux derivation', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ffonte = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ffonte', 'Thermal flux for snow melting', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_fqcalving = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'fqcalving', 'Ice Calving', 'kg/m2/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_fqfonte = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'fqfonte', 'Land ice melt', 'kg/m2/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_taux = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'taux', 'Zonal wind stress', 'Pa', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tauy = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tauy', 'Meridional wind stress', 'Pa', (/ ('', i=1, 9) /))
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_taux_srf = (/           &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'taux_ter',             &
-      "Zonal wind stress"//clnsurf(1), "Pa", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'taux_lic',             &
-      "Zonal wind stress"//clnsurf(2), "Pa", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'taux_oce',             &
-      "Zonal wind stress"//clnsurf(3), "Pa", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'taux_sic',             &
-      "Zonal wind stress"//clnsurf(4), "Pa", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'taux_ter',             &
+      "Zonal wind stress"//clnsurf(1), "Pa", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'taux_lic',             &
+      "Zonal wind stress"//clnsurf(2), "Pa", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'taux_oce',             &
+      "Zonal wind stress"//clnsurf(3), "Pa", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'taux_sic',             &
+      "Zonal wind stress"//clnsurf(4), "Pa", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_tauy_srf     = (/             &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'tauy_ter',                   &
-      "Meridional wind stress "//clnsurf(1),"Pa", (/ ('', i=1, 6) /)),  &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'tauy_lic',                   &
-      "Meridional wind stress "//clnsurf(2),"Pa", (/ ('', i=1, 6) /)),  &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'tauy_oce',                   &
-      "Meridional wind stress "//clnsurf(3),"Pa", (/ ('', i=1, 6) /)),  &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'tauy_sic',                   &
-      "Meridional wind stress "//clnsurf(4),"Pa", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'tauy_ter',                   &
+      "Meridional wind stress "//clnsurf(1),"Pa", (/ ('', i=1, 9) /)),  &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'tauy_lic',                   &
+      "Meridional wind stress "//clnsurf(2),"Pa", (/ ('', i=1, 9) /)),  &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'tauy_oce',                   &
+      "Meridional wind stress "//clnsurf(3),"Pa", (/ ('', i=1, 9) /)),  &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'tauy_sic',                   &
+      "Meridional wind stress "//clnsurf(4),"Pa", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_pourc_srf    = (/ &
-      ctrl_out((/ 1, 7, 10, 10, 10, 10 /),'pourc_ter',      &
-      "% "//clnsurf(1),"%", (/ ('', i=1, 6) /)),            &
-      ctrl_out((/ 1, 7, 10, 10, 10, 10 /),'pourc_lic',      &
-      "% "//clnsurf(2),"%", (/ ('', i=1, 6) /)),            &
-      ctrl_out((/ 1, 7, 10, 10, 10, 10 /),'pourc_oce',      &
-      "% "//clnsurf(3),"%", (/ ('', i=1, 6) /)),            &
-      ctrl_out((/ 1, 7, 10, 10, 10, 10 /),'pourc_sic',      &
-      "% "//clnsurf(4),"%", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 7, 10, 10, 10, 10, 11, 11, 11 /),'pourc_ter',      &
+      "% "//clnsurf(1),"%", (/ ('', i=1, 9) /)),            &
+      ctrl_out((/ 1, 7, 10, 10, 10, 10, 11, 11, 11 /),'pourc_lic',      &
+      "% "//clnsurf(2),"%", (/ ('', i=1, 9) /)),            &
+      ctrl_out((/ 1, 7, 10, 10, 10, 10, 11, 11, 11 /),'pourc_oce',      &
+      "% "//clnsurf(3),"%", (/ ('', i=1, 9) /)),            &
+      ctrl_out((/ 1, 7, 10, 10, 10, 10, 11, 11, 11 /),'pourc_sic',      &
+      "% "//clnsurf(4),"%", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_fract_srf    = (/ &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'fract_ter',      &
-      "Fraction "//clnsurf(1),"1", (/ ('', i=1, 6) /)),     &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'fract_lic',      &
-      "Fraction "//clnsurf(2),"1", (/ ('', i=1, 6) /)),     &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'fract_oce',      &
-      "Fraction "//clnsurf(3),"1", (/ ('', i=1, 6) /)),     &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'fract_sic',      &
-      "Fraction "//clnsurf(4),"1", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'fract_ter',      &
+      "Fraction "//clnsurf(1),"1", (/ ('', i=1, 9) /)),     &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'fract_lic',      &
+      "Fraction "//clnsurf(2),"1", (/ ('', i=1, 9) /)),     &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'fract_oce',      &
+      "Fraction "//clnsurf(3),"1", (/ ('', i=1, 9) /)),     &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'fract_sic',      &
+      "Fraction "//clnsurf(4),"1", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_tsol_srf     = (/ &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'tsol_ter',       &
-      "Temperature "//clnsurf(1),"K", (/ ('', i=1, 6) /)),  &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'tsol_lic',       &
-      "Temperature "//clnsurf(2),"K", (/ ('', i=1, 6) /)),  &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'tsol_oce',       &
-      "Temperature "//clnsurf(3),"K", (/ ('', i=1, 6) /)),  &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'tsol_sic',       &
-      "Temperature "//clnsurf(4),"K", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'tsol_ter',       &
+      "Temperature "//clnsurf(1),"K", (/ ('', i=1, 9) /)),  &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'tsol_lic',       &
+      "Temperature "//clnsurf(2),"K", (/ ('', i=1, 9) /)),  &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'tsol_oce',       &
+      "Temperature "//clnsurf(3),"K", (/ ('', i=1, 9) /)),  &
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'tsol_sic',       &
+      "Temperature "//clnsurf(4),"K", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_evappot_srf  = (/ &
-      ctrl_out((/ 1, 6, 10, 10, 10, 10 /),'evappot_ter',    &
-      "Temperature"//clnsurf(1),"K", (/ ('', i=1, 6) /)),   &
-      ctrl_out((/ 4, 6, 10, 10, 10, 10 /),'evappot_lic',    &
-      "Temperature"//clnsurf(2),"K", (/ ('', i=1, 6) /)),   &
-      ctrl_out((/ 4, 6, 10, 10, 10, 10 /),'evappot_oce',    &
-      "Temperature"//clnsurf(3),"K", (/ ('', i=1, 6) /)),   &
-      ctrl_out((/ 4, 6, 10, 10, 10, 10 /),'evappot_sic',    &
-      "Temperature"//clnsurf(4),"K", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 6, 10, 10, 10, 10, 11, 11, 11 /),'evappot_ter',    &
+      "Temperature"//clnsurf(1),"K", (/ ('', i=1, 9) /)),   &
+      ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /),'evappot_lic',    &
+      "Temperature"//clnsurf(2),"K", (/ ('', i=1, 9) /)),   &
+      ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /),'evappot_oce',    &
+      "Temperature"//clnsurf(3),"K", (/ ('', i=1, 9) /)),   &
+      ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /),'evappot_sic',    &
+      "Temperature"//clnsurf(4),"K", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_sens_srf     = (/          &
-      ctrl_out((/ 1, 6, 10, 7, 10, 10 /),'sens_ter',                 &
-      "Sensible heat flux "//clnsurf(1),"W/m2", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 7, 10, 10 /),'sens_lic',                 &
-      "Sensible heat flux "//clnsurf(2),"W/m2", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 7, 10, 10 /),'sens_oce',                 &
-      "Sensible heat flux "//clnsurf(3),"W/m2", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 7, 10, 10 /),'sens_sic',                 &
-      "Sensible heat flux "//clnsurf(4),"W/m2", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 6, 10, 7, 10, 10, 11, 11, 11 /),'sens_ter',                 &
+      "Sensible heat flux "//clnsurf(1),"W/m2", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 7, 10, 10, 11, 11, 11 /),'sens_lic',                 &
+      "Sensible heat flux "//clnsurf(2),"W/m2", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 7, 10, 10, 11, 11, 11 /),'sens_oce',                 &
+      "Sensible heat flux "//clnsurf(3),"W/m2", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 7, 10, 10, 11, 11, 11 /),'sens_sic',                 &
+      "Sensible heat flux "//clnsurf(4),"W/m2", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_lat_srf      = (/        &
-      ctrl_out((/ 1, 6, 10, 7, 10, 10 /),'lat_ter',                &
-      "Latent heat flux "//clnsurf(1),"W/m2", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 7, 10, 10 /),'lat_lic',                &
-      "Latent heat flux "//clnsurf(2),"W/m2", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 7, 10, 10 /),'lat_oce',                &
-      "Latent heat flux "//clnsurf(3),"W/m2", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 6, 10, 7, 10, 10 /),'lat_sic',                &
-      "Latent heat flux "//clnsurf(4),"W/m2", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 6, 10, 7, 10, 10, 11, 11, 11 /),'lat_ter',                &
+      "Latent heat flux "//clnsurf(1),"W/m2", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 7, 10, 10, 11, 11, 11 /),'lat_lic',                &
+      "Latent heat flux "//clnsurf(2),"W/m2", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 7, 10, 10, 11, 11, 11 /),'lat_oce',                &
+      "Latent heat flux "//clnsurf(3),"W/m2", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 6, 10, 7, 10, 10, 11, 11, 11 /),'lat_sic',                &
+      "Latent heat flux "//clnsurf(4),"W/m2", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_flw_srf      = (/ &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'flw_ter',       &
-      "LW "//clnsurf(1),"W/m2", (/ ('', i=1, 6) /)),        &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'flw_lic',       &
-      "LW "//clnsurf(2),"W/m2", (/ ('', i=1, 6) /)),        &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'flw_oce',       &
-      "LW "//clnsurf(3),"W/m2", (/ ('', i=1, 6) /)),        &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'flw_sic',       &
-      "LW "//clnsurf(4),"W/m2", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'flw_ter',       &
+      "LW "//clnsurf(1),"W/m2", (/ ('', i=1, 9) /)),        &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'flw_lic',       &
+      "LW "//clnsurf(2),"W/m2", (/ ('', i=1, 9) /)),        &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'flw_oce',       &
+      "LW "//clnsurf(3),"W/m2", (/ ('', i=1, 9) /)),        &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'flw_sic',       &
+      "LW "//clnsurf(4),"W/m2", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_fsw_srf      = (/ &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'fsw_ter',       &
-      "SW "//clnsurf(1),"W/m2", (/ ('', i=1, 6) /)),        &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'fsw_lic',       &
-      "SW "//clnsurf(2),"W/m2", (/ ('', i=1, 6) /)),        &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'fsw_oce',       &
-      "SW "//clnsurf(3),"W/m2", (/ ('', i=1, 6) /)),        &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'fsw_sic',       &
-      "SW "//clnsurf(4),"W/m2", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'fsw_ter',       &
+      "SW "//clnsurf(1),"W/m2", (/ ('', i=1, 9) /)),        &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'fsw_lic',       &
+      "SW "//clnsurf(2),"W/m2", (/ ('', i=1, 9) /)),        &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'fsw_oce',       &
+      "SW "//clnsurf(3),"W/m2", (/ ('', i=1, 9) /)),        &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'fsw_sic',       &
+      "SW "//clnsurf(4),"W/m2", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_wbils_srf    = (/ &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'wbils_ter',     &
-      "Bilan sol "//clnsurf(1),"W/m2", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'wbils_lic',     &
-      "Bilan sol "//clnsurf(2),"W/m2", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'wbils_oce',     &
-      "Bilan sol "//clnsurf(3),"W/m2", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'wbils_sic',     &
-      "Bilan sol "//clnsurf(4),"W/m2", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'wbils_ter',     &
+      "Bilan sol "//clnsurf(1),"W/m2", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'wbils_lic',     &
+      "Bilan sol "//clnsurf(2),"W/m2", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'wbils_oce',     &
+      "Bilan sol "//clnsurf(3),"W/m2", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'wbils_sic',     &
+      "Bilan sol "//clnsurf(4),"W/m2", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_wbilo_srf    = (/      &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'wbilo_ter',          &
-      "Bilan eau "//clnsurf(1),"kg/(m2*s)", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'wbilo_lic',          &
-      "Bilan eau "//clnsurf(2),"kg/(m2*s)", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'wbilo_oce',          &
-      "Bilan eau "//clnsurf(3),"kg/(m2*s)", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'wbilo_sic',          &
-      "Bilan eau "//clnsurf(4),"kg/(m2*s)", (/ ('', i=1, 6) /)) /)
-
-  TYPE(ctrl_out), SAVE :: o_cdrm = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'cdrm', 'Momentum drag coef.', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cdrh = ctrl_out((/ 1, 10, 10, 7, 10, 10 /), &
-	'cdrh', 'Heat drag coef.', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cldl = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'cldl', 'Low-level cloudiness', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cldm = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'cldm', 'Mid-level cloudiness', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cldh = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'cldh', 'High-level cloudiness', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cldt = ctrl_out((/ 1, 1, 2, 10, 5, 10 /), &
-	'cldt', 'Total cloudiness', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cldq = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'cldq', 'Cloud liquid water path', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_lwp = ctrl_out((/ 1, 5, 10, 10, 10, 10 /), &
-	'lwp', 'Cloud water path', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_iwp = ctrl_out((/ 1, 5, 10, 10, 10, 10 /), &
-	'iwp', 'Cloud ice water path', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ue = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'ue', 'Zonal energy transport', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ve = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	've', 'Merid energy transport', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_uq = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'uq', 'Zonal humidity transport', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_vq = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'vq', 'Merid humidity transport', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cape = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'cape', 'Conv avlbl pot ener', 'J/kg', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_pbase = ctrl_out((/ 1, 5, 10, 10, 10, 10 /), &
-	'pbase', 'Cld base pressure', 'Pa', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ptop = ctrl_out((/ 1, 5, 10, 10, 10, 10 /), &
-	'ptop', 'Cld top pressure', 'Pa', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_fbase = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'fbase', 'Cld base mass flux', 'kg/m2/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_plcl = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'plcl', 'Lifting Condensation Level', 'hPa', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_plfc = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'plfc', 'Level of Free Convection', 'hPa', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wbeff = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	'wbeff', 'Conv. updraft velocity at LFC (<100)', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_prw = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'prw', 'Precipitable water', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_s_pblh = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	's_pblh', 'Boundary Layer Height', 'm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_s_pblt = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	's_pblt', 't at Boundary Layer Height', 'K', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_s_lcl = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	's_lcl', 'Condensation level', 'm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_s_therm = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	's_therm', 'Exces du thermique', 'K', (/ ('', i=1, 6) /))
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'wbilo_ter',          &
+      "Bilan eau "//clnsurf(1),"kg/(m2*s)", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'wbilo_lic',          &
+      "Bilan eau "//clnsurf(2),"kg/(m2*s)", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'wbilo_oce',          &
+      "Bilan eau "//clnsurf(3),"kg/(m2*s)", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'wbilo_sic',          &
+      "Bilan eau "//clnsurf(4),"kg/(m2*s)", (/ ('', i=1, 9) /)) /)
+
+  TYPE(ctrl_out), SAVE :: o_cdrm = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cdrm', 'Momentum drag coef.', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cdrh = ctrl_out((/ 1, 10, 10, 7, 10, 10, 11, 11, 11 /), &
+    'cdrh', 'Heat drag coef.', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cldl = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cldl', 'Low-level cloudiness', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cldm = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cldm', 'Mid-level cloudiness', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cldh = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cldh', 'High-level cloudiness', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cldt = ctrl_out((/ 1, 1, 2, 10, 5, 10, 11, 11, 11 /), &
+    'cldt', 'Total cloudiness', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cldq = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cldq', 'Cloud liquid water path', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_lwp = ctrl_out((/ 1, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'lwp', 'Cloud water path', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_iwp = ctrl_out((/ 1, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'iwp', 'Cloud ice water path', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ue = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ue', 'Zonal energy transport', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ve = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    've', 'Merid energy transport', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_uq = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'uq', 'Zonal humidity transport', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_vq = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'vq', 'Merid humidity transport', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cape = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cape', 'Conv avlbl pot ener', 'J/kg', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_pbase = ctrl_out((/ 1, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'pbase', 'Cld base pressure', 'Pa', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ptop = ctrl_out((/ 1, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ptop', 'Cld top pressure', 'Pa', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_fbase = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'fbase', 'Cld base mass flux', 'kg/m2/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_plcl = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'plcl', 'Lifting Condensation Level', 'hPa', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_plfc = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'plfc', 'Level of Free Convection', 'hPa', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wbeff = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'wbeff', 'Conv. updraft velocity at LFC (<100)', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_prw = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'prw', 'Precipitable water', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_s_pblh = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    's_pblh', 'Boundary Layer Height', 'm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_s_pblt = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    's_pblt', 't at Boundary Layer Height', 'K', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_s_lcl = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    's_lcl', 'Condensation level', 'm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_s_therm = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    's_therm', 'Exces du thermique', 'K', (/ ('', i=1, 9) /))
   !IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
-  ! type(ctrl_out),save :: o_s_capCL      = ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'s_capCL', &
-!	(/ ('', i=1, 6) /))
-  ! type(ctrl_out),save :: o_s_oliqCL     = ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'s_oliqCL', &
-!	(/ ('', i=1, 6) /))
-  ! type(ctrl_out),save :: o_s_cteiCL     = ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'s_cteiCL', &
-!	(/ ('', i=1, 6) /))
-  ! type(ctrl_out),save :: o_s_trmb1      = ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'s_trmb1', &
-!	(/ ('', i=1, 6) /))
-  ! type(ctrl_out),save :: o_s_trmb2      = ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'s_trmb2', &
-!	(/ ('', i=1, 6) /))
-  ! type(ctrl_out),save :: o_s_trmb3      = ctrl_out((/ 1, 10, 10, 10, 10, 10 /),'s_trmb3', &
-	!(/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_slab_bils = ctrl_out((/ 1, 1, 10, 10, 10, 10 /), &
-	'slab_bils_oce', 'Bilan au sol sur ocean slab', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ale_bl = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'ale_bl', 'ALE BL', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_alp_bl = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'alp_bl', 'ALP BL', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ale_wk = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'ale_wk', 'ALE WK', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_alp_wk = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'alp_wk', 'ALP WK', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ale = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'ale', 'ALE', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_alp = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'alp', 'ALP', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cin = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'cin', 'Convective INhibition', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wape = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'wape', '', '', (/ ('', i=1, 6) /))
+  ! type(ctrl_out),save :: o_s_capCL      = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'s_capCL', &
+!    (/ ('', i=1, 9) /))
+  ! type(ctrl_out),save :: o_s_oliqCL     = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'s_oliqCL', &
+!    (/ ('', i=1, 9) /))
+  ! type(ctrl_out),save :: o_s_cteiCL     = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'s_cteiCL', &
+!    (/ ('', i=1, 9) /))
+  ! type(ctrl_out),save :: o_s_trmb1      = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'s_trmb1', &
+!    (/ ('', i=1, 9) /))
+  ! type(ctrl_out),save :: o_s_trmb2      = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'s_trmb2', &
+!    (/ ('', i=1, 9) /))
+  ! type(ctrl_out),save :: o_s_trmb3      = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /),'s_trmb3', &
+    !(/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_slab_bils = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'slab_bils_oce', 'Bilan au sol sur ocean slab', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ale_bl = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'ale_bl', 'ALE BL', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_alp_bl = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'alp_bl', 'ALP BL', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ale_wk = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'ale_wk', 'ALE WK', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_alp_wk = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'alp_wk', 'ALP WK', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ale = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'ale', 'ALE', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_alp = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'alp', 'ALP', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cin = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'cin', 'Convective INhibition', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wape = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'wape', '', '', (/ ('', i=1, 9) /))
 
 !!! nrlmd le 10/04/2012
 
 !-------Spectre de thermiques de type 2 au LCL
-  TYPE(ctrl_out), SAVE :: o_n2 = ctrl_out((/ 1, 1, 1, 6, 10, 10 /), &
-	'n2', 'Nombre de panaches de type 2', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_s2 = ctrl_out((/ 1, 1, 1, 6, 10, 10 /), &
-	's2', 'Surface moyenne des panaches de type 2', 'm2', (/ ('', i=1, 6) /))
+  TYPE(ctrl_out), SAVE :: o_n2 = ctrl_out((/ 1, 1, 1, 6, 10, 10, 11, 11, 11 /), &
+    'n2', 'Nombre de panaches de type 2', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_s2 = ctrl_out((/ 1, 1, 1, 6, 10, 10, 11, 11, 11 /), &
+    's2', 'Surface moyenne des panaches de type 2', 'm2', (/ ('', i=1, 9) /))
                                                                              
 !-------Déclenchement stochastique                                           
-  TYPE(ctrl_out), SAVE :: o_proba_notrig = ctrl_out((/ 1, 1, 1, 6, 10, 10 /), &
-	'proba_notrig', &
-                         'Probabilité de non-déclenchement', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_random_notrig = ctrl_out((/ 1, 1, 1, 6, 10, 10 /), &
-	'random_notrig', &
-                         'Tirage aléatoire de non-déclenchement', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ale_bl_stat = ctrl_out((/ 1, 1, 1, 6, 10, 10 /), &
-	'ale_bl_stat', &
-       'ALE_BL_STAT', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ale_bl_trig = ctrl_out((/ 1, 1, 1, 6, 10, 10 /), &
-	'ale_bl_trig', &
-       'ALE_BL_STAT + Condition P>Pseuil', 'm2/s2', (/ ('', i=1, 6) /))
+  TYPE(ctrl_out), SAVE :: o_proba_notrig = ctrl_out((/ 1, 1, 1, 6, 10, 10, 11, 11, 11 /), &
+    'proba_notrig', &
+                         'Probabilité de non-déclenchement', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_random_notrig = ctrl_out((/ 1, 1, 1, 6, 10, 10, 11, 11, 11 /), &
+    'random_notrig', &
+                         'Tirage aléatoire de non-déclenchement', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ale_bl_stat = ctrl_out((/ 1, 1, 1, 6, 10, 10, 11, 11, 11 /), &
+    'ale_bl_stat', &
+       'ALE_BL_STAT', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ale_bl_trig = ctrl_out((/ 1, 1, 1, 6, 10, 10, 11, 11, 11 /), &
+    'ale_bl_trig', &
+       'ALE_BL_STAT + Condition P>Pseuil', 'm2/s2', (/ ('', i=1, 9) /))
 
 !-------Fermeture statistique
-  TYPE(ctrl_out), SAVE :: o_alp_bl_det = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'alp_bl_det', 'ALP_BL_DET', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_alp_bl_fluct_m = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'alp_bl_fluct_m', 'ALP_BL_FLUCT_M', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_alp_bl_fluct_tke = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'alp_bl_fluct_tke', 'ALP_BL_FLUCT_TKE', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_alp_bl_conv = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'alp_bl_conv', 'ALP_BL_CONV', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_alp_bl_stat = ctrl_out((/ 1, 1, 1, 10, 10, 10 /), &
-	'alp_bl_stat', 'ALP_BL_STAT', 'W/m2', (/ ('', i=1, 6) /))
+  TYPE(ctrl_out), SAVE :: o_alp_bl_det = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'alp_bl_det', 'ALP_BL_DET', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_alp_bl_fluct_m = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'alp_bl_fluct_m', 'ALP_BL_FLUCT_M', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_alp_bl_fluct_tke = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'alp_bl_fluct_tke', 'ALP_BL_FLUCT_TKE', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_alp_bl_conv = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'alp_bl_conv', 'ALP_BL_CONV', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_alp_bl_stat = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11 /), &
+    'alp_bl_stat', 'ALP_BL_STAT', 'W/m2', (/ ('', i=1, 9) /))
 
 !!! fin nrlmd le 10/04/2012
@@ -484,636 +498,720 @@
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_uSTDlevs     = (/                    &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'u850', "Zonal wind 1hPa", "m/s",     &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'u700', "Zonal wind 2hPa", "m/s",     &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'u500', "Zonal wind 3hPa", "m/s",     &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'u200', "Zonal wind 4hPa", "m/s",     &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'u100', "Zonal wind 5hPa", "m/s",     &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'u50', "Zonal wind 6hPa", "m/s",     &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'u10', "Zonal wind 7hPa", "m/s",     &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'u850', "Zonal wind 1hPa", "m/s",     &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'u700', "Zonal wind 2hPa", "m/s",     &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'u500', "Zonal wind 3hPa", "m/s",     &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'u200', "Zonal wind 4hPa", "m/s",     &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'u100', "Zonal wind 5hPa", "m/s",     &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'u50', "Zonal wind 6hPa", "m/s",     &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'u10', "Zonal wind 7hPa", "m/s",     &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_vSTDlevs     = (/                     &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'v850', "Meridional wind 1hPa", "m/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'v700', "Meridional wind 2hPa", "m/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'v500', "Meridional wind 3hPa", "m/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'v200', "Meridional wind 4hPa", "m/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'v100', "Meridional wind 5hPa", "m/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'v50', "Meridional wind 6hPa", "m/s",  &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'v10', "Meridional wind 7hPa", "m/s",  &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'v850', "Meridional wind 1hPa", "m/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'v700', "Meridional wind 2hPa", "m/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'v500', "Meridional wind 3hPa", "m/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'v200', "Meridional wind 4hPa", "m/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'v100', "Meridional wind 5hPa", "m/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'v50', "Meridional wind 6hPa", "m/s",  &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)),  &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'v10', "Meridional wind 7hPa", "m/s",  &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_wSTDlevs     = (/                    &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'w850', "Vertical wind 1hPa", "Pa/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'w700', "Vertical wind 2hPa", "Pa/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'w500', "Vertical wind 3hPa", "Pa/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'w200', "Vertical wind 4hPa", "Pa/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'w100', "Vertical wind 5hPa", "Pa/s", &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'w50', "Vertical wind 6hPa", "Pa/s",  &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'w10', "Vertical wind 7hPa", "Pa/s",  &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w850', "Vertical wind 1hPa", "Pa/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w700', "Vertical wind 2hPa", "Pa/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w500', "Vertical wind 3hPa", "Pa/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w200', "Vertical wind 4hPa", "Pa/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w100', "Vertical wind 5hPa", "Pa/s", &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w50', "Vertical wind 6hPa", "Pa/s",  &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'w10', "Vertical wind 7hPa", "Pa/s",  &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_tSTDlevs     = (/                    &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'t850', "Temperature 1hPa", "K",      &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'t700', "Temperature 2hPa", "K",      &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'t500', "Temperature 3hPa", "K",      &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'t200', "Temperature 4hPa", "K",      &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'t100', "Temperature 5hPa", "K",      &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'t50',  "Temperature 6hPa", "K",      &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'t10',  "Temperature 7hPa", "K",      &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t850', "Temperature 1hPa", "K",      &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t700', "Temperature 2hPa", "K",      &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t500', "Temperature 3hPa", "K",      &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t200', "Temperature 4hPa", "K",      &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t100', "Temperature 5hPa", "K",      &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t50',  "Temperature 6hPa", "K",      &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'t10',  "Temperature 7hPa", "K",      &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_qSTDlevs     = (/                             &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'q850', "Specific humidity 1hPa",              &
-      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'q700', "Specific humidity 2hPa",              &
-      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'q500', "Specific humidity 3hPa",              &
-      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'q200', "Specific humidity 4hPa",              &
-      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'q100', "Specific humidity 5hPa",              &
-      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'q50', "Specific humidity 6hPa",               &
-      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'q10', "Specific humidity 7hPa",               &
-      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q850', "Specific humidity 1hPa", &
+      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q700', "Specific humidity 2hPa", &
+      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q500', "Specific humidity 3hPa", &
+      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q200', "Specific humidity 4hPa", &
+      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q100', "Specific humidity 5hPa", &
+      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q50', "Specific humidity 6hPa",  &
+      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'q10', "Specific humidity 7hPa", &
+      "kg/kg", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(7) :: o_zSTDlevs   = (/                           &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'z850', "Geopotential height 1hPa",        &
-      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'z700', "Geopotential height 2hPa",        &
-      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'z500', "Geopotential height 3hPa",        &
-      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'z200', "Geopotential height 4hPa",        &
-      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'z100', "Geopotential height 5hPa",        &
-      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'z50', "Geopotential height 6hPa",         &
-      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
-      ctrl_out((/ 1, 7, 7, 10, 10, 10 /),'z10', "Geopotential height 7hPa",         &
-      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
-
-  TYPE(ctrl_out), SAVE :: o_t_oce_sic = ctrl_out((/ 1, 10, 10, 10, 10, 10 /), &
-	't_oce_sic', 'Temp mixte oce-sic', 'K', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_weakinv = ctrl_out((/ 10, 1, 10, 10, 10, 10 /), &
-	'weakinv', 'Weak inversion', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dthmin = ctrl_out((/ 10, 1, 10, 10, 10, 10 /), &
-	'dthmin', 'dTheta mini', 'K/m', (/ ('', i=1, 6) /))
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z850', "Geopotential height 1hPa",        &
+      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z700', "Geopotential height 2hPa",        &
+      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z500', "Geopotential height 3hPa",        &
+      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z200', "Geopotential height 4hPa",        &
+      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z100', "Geopotential height 5hPa",        &
+      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z50', "Geopotential height 6hPa",         &
+      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)), &
+      ctrl_out((/ 1, 7, 7, 10, 10, 10, 11, 11, 11 /),'z10', "Geopotential height 7hPa",         &
+      "m", (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /)) /)
+
+  TYPE(ctrl_out), SAVE :: o_t_oce_sic = ctrl_out((/ 1, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    't_oce_sic', 'Temp mixte oce-sic', 'K', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_weakinv = ctrl_out((/ 10, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'weakinv', 'Weak inversion', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dthmin = ctrl_out((/ 10, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dthmin', 'dTheta mini', 'K/m', (/ ('', i=1, 9) /))
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_u10_srf      = (/ &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'u10_ter', "", "", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'u10_lic', "", "", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'u10_oce', "", "", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'u10_sic', "", "", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'u10_ter', "", "", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'u10_lic', "", "", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'u10_oce', "", "", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'u10_sic', "", "", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_v10_srf      = (/ &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'v10_ter', "", "", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'v10_lic', "", "", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'v10_oce', "", "", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'v10_sic', "", "", (/ ('', i=1, 6) /)) /)
-
-  TYPE(ctrl_out), SAVE :: o_cldtau = ctrl_out((/ 10, 5, 10, 10, 10, 10 /), &
-	'cldtau', 'Cloud optical thickness', '1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cldemi = ctrl_out((/ 10, 5, 10, 10, 10, 10 /), &
-	'cldemi', 'Cloud optical emissivity', '1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rh2m = ctrl_out((/ 5, 5, 10, 10, 10, 10 /), &
-	'rh2m', 'Relative humidity at 2m', '%', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rh2m_min = ctrl_out((/ 10, 5, 10, 10, 10, 10 /), &
-	'rh2m_min', 'Min Relative humidity at 2m', '%',                        &
-      (/ 't_min(X)', 't_min(X)', 't_min(X)', 't_min(X)', 't_min(X)', 't_min(X)' /))
-  TYPE(ctrl_out), SAVE :: o_rh2m_max = ctrl_out((/ 10, 5, 10, 10, 10, 10 /), &
-	'rh2m_max', 'Max Relative humidity at 2m', '%',                        &
-      (/ 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)' /))
-  TYPE(ctrl_out), SAVE :: o_qsat2m = ctrl_out((/ 10, 5, 10, 10, 10, 10 /), &
-	'qsat2m', 'Saturant humidity at 2m', '%', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tpot = ctrl_out((/ 10, 5, 10, 10, 10, 10 /), &
-	'tpot', 'Surface air potential temperature', 'K', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tpote = ctrl_out((/ 10, 5, 10, 10, 10, 10 /), &
-	'tpote', &
-      'Surface air equivalent potential temperature', 'K', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tke = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'tke ', 'TKE', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tke_max = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'tke_max', 'TKE max', 'm2/s2',                                        &
-      (/ 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)' /))
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'v10_ter', "", "", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'v10_lic', "", "", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'v10_oce', "", "", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'v10_sic', "", "", (/ ('', i=1, 9) /)) /)
+
+  TYPE(ctrl_out), SAVE :: o_cldtau = ctrl_out((/ 10, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cldtau', 'Cloud optical thickness', '1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cldemi = ctrl_out((/ 10, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cldemi', 'Cloud optical emissivity', '1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rh2m = ctrl_out((/ 5, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rh2m', 'Relative humidity at 2m', '%', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rh2m_min = ctrl_out((/ 10, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rh2m_min', 'Min Relative humidity at 2m', '%',                        &
+      (/ 't_min(X)', 't_min(X)', 't_min(X)', 't_min(X)', 't_min(X)', 't_min(X)', 't_min(X)', 't_min(X)', 't_min(X)' /))
+  TYPE(ctrl_out), SAVE :: o_rh2m_max = ctrl_out((/ 10, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rh2m_max', 'Max Relative humidity at 2m', '%',                        &
+      (/ 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', &
+         't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)' /))
+  TYPE(ctrl_out), SAVE :: o_qsat2m = ctrl_out((/ 10, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'qsat2m', 'Saturant humidity at 2m', '%', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tpot = ctrl_out((/ 10, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tpot', 'Surface air potential temperature', 'K', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tpote = ctrl_out((/ 10, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tpote', &
+      'Surface air equivalent potential temperature', 'K', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tke = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tke ', 'TKE', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tke_max = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tke_max', 'TKE max', 'm2/s2',                                        &
+      (/ 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', &
+         't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)' /))
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_tke_srf      = (/             &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'tke_ter',                   &
-      "Max Turb. Kinetic Energy "//clnsurf(1),"-", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'tke_lic',                   &
-      "Max Turb. Kinetic Energy "//clnsurf(2),"-", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'tke_oce',                   &
-      "Max Turb. Kinetic Energy "//clnsurf(3),"-", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'tke_sic',                   &
-      "Max Turb. Kinetic Energy "//clnsurf(4),"-", (/ ('', i=1, 6) /)) /)
-
-  TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_tke_max_srf  = (/                                  &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'tke_max_ter',                                    &
-      "Max Turb. Kinetic Energy "//clnsurf(1),"-",                                           &
-      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'tke_max_lic',                                    &
-      "Max Turb. Kinetic Energy "//clnsurf(2),"-",                                           &
-      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'tke_max_oce',                                    &
-      "Max Turb. Kinetic Energy "//clnsurf(3),"-",                                           &
-      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /)), &
-      ctrl_out((/ 10, 4, 10, 10, 10, 10 /),'tke_max_sic',                                    &
-      "Max Turb. Kinetic Energy "//clnsurf(4),"-",                                           &
-      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /)) /)
-
-  TYPE(ctrl_out), SAVE :: o_kz = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'kz', 'Kz melange', 'm2/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_kz_max = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'kz_max', 'Kz melange max', 'm2/s',                                  &
-      (/ 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)' /))
-  TYPE(ctrl_out), SAVE :: o_SWnetOR = ctrl_out((/ 10, 10, 2, 10, 10, 10 /), &
-	'SWnetOR', 'Sfce net SW radiation OR', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_SWdownOR = ctrl_out((/ 10, 10, 2, 10, 10, 10 /), &
-	'SWdownOR', 'Sfce incident SW radiation OR', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_LWdownOR = ctrl_out((/ 10, 10, 2, 10, 10, 10 /), &
-	'LWdownOR', 'Sfce incident LW radiation OR', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_snowl = ctrl_out((/ 10, 1, 10, 10, 10, 10 /), &
-	'snowl', 'Solid Large-scale Precip.', 'kg/(m2*s)', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cape_max = ctrl_out((/ 10, 1, 10, 10, 10, 10 /), &
-	'cape_max', 'CAPE max.', 'J/kg',                                       &
-      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /))
-  TYPE(ctrl_out), SAVE :: o_solldown = ctrl_out((/ 10, 1, 10, 10, 10, 10 /), &
-	'solldown', 'Down. IR rad. at surface', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtsvdfo = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'dtsvdfo', 'Boundary-layer dTs(o)', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtsvdft = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'dtsvdft', 'Boundary-layer dTs(t)', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtsvdfg = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'dtsvdfg', 'Boundary-layer dTs(g)', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtsvdfi = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'dtsvdfi', 'Boundary-layer dTs(g)', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rugs = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'rugs', 'rugosity', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_topswad = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'topswad', 'ADE at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_topswad0 = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'topswad0', 'ADE clear-sky at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_topswai = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'topswai', 'AIE at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_solswad = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'solswad', 'ADE at SRF', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_solswad0 = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'solswad0', 'ADE clear-sky at SRF', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_solswai = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'solswai', 'AIE at SFR', 'W/m2', (/ ('', i=1, 6) /))
-
-!  type(ctrl_out),save,dimension(10) :: o_tausumaero  = (/ ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_ASBCM', &
-!	(/ ('', i=1, 6) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'tke_ter',       &
+      "Max Turb. Kinetic Energy "//clnsurf(1),"-", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'tke_lic',       &
+      "Max Turb. Kinetic Energy "//clnsurf(2),"-", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'tke_oce',       &
+      "Max Turb. Kinetic Energy "//clnsurf(3),"-", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'tke_sic',       &
+      "Max Turb. Kinetic Energy "//clnsurf(4),"-", (/ ('', i=1, 9) /)) /)
+
+  TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_tke_max_srf  = (/                          &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'tke_max_ter',                &
+      "Max Turb. Kinetic Energy "//clnsurf(1),"-",                                   &
+      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", &
+         "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'tke_max_lic',                &
+      "Max Turb. Kinetic Energy "//clnsurf(2),"-",                                   &
+      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", &
+         "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'tke_max_oce',                &
+      "Max Turb. Kinetic Energy "//clnsurf(3),"-",                                   &
+      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", &
+         "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /)), &
+      ctrl_out((/ 10, 4, 10, 10, 10, 10, 11, 11, 11 /),'tke_max_sic',                &
+      "Max Turb. Kinetic Energy "//clnsurf(4),"-",                                   &
+      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", &
+         "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /)) /)
+
+  TYPE(ctrl_out), SAVE :: o_kz = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'kz', 'Kz melange', 'm2/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_kz_max = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'kz_max', 'Kz melange max', 'm2/s',                                  &
+      (/ 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', 't_max(X)', &
+         't_max(X)', "t_max(X)", "t_max(X)", "t_max(X)" /))
+  TYPE(ctrl_out), SAVE :: o_SWnetOR = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWnetOR', 'Sfce net SW radiation OR', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_SWdownOR = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'SWdownOR', 'Sfce incident SW radiation OR', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_LWdownOR = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'LWdownOR', 'Sfce incident LW radiation OR', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_snowl = ctrl_out((/ 10, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'snowl', 'Solid Large-scale Precip.', 'kg/(m2*s)', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cape_max = ctrl_out((/ 10, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cape_max', 'CAPE max.', 'J/kg',                                       &
+      (/ "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)", &
+         "t_max(X)", "t_max(X)", "t_max(X)", "t_max(X)" /))
+  TYPE(ctrl_out), SAVE :: o_solldown = ctrl_out((/ 10, 1, 10, 10, 10, 10, 11, 11, 11 /), &
+    'solldown', 'Down. IR rad. at surface', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtsvdfo = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtsvdfo', 'Boundary-layer dTs(o)', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtsvdft = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtsvdft', 'Boundary-layer dTs(t)', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtsvdfg = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtsvdfg', 'Boundary-layer dTs(g)', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtsvdfi = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtsvdfi', 'Boundary-layer dTs(g)', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rugs = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rugs', 'rugosity', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_topswad = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'topswad', 'ADE at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_topswad0 = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'topswad0', 'ADE clear-sky at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_topswai = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'topswai', 'AIE at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_solswad = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'solswad', 'ADE at SRF', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_solswad0 = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'solswad0', 'ADE clear-sky at SRF', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_solswai = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'solswai', 'AIE at SFR', 'W/m2', (/ ('', i=1, 9) /))
+
+!  type(ctrl_out),save,dimension(10) :: o_tausumaero  = (/ ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASBCM', &
+!    (/ ('', i=1, 9) /)), &
   type(ctrl_out),save,dimension(11) :: o_tausumaero  =                           & 
-    (/ ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_ASBCM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(1),"1", (/ ('', i=1, 6) /)), &
-       ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_ASPOMM',                       &
-      "Aerosol Optical depth at 550 nm "//name_aero(2),"1", (/ ('', i=1, 6) /)), &
-       ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_ASSO4M',                       &
-      "Aerosol Optical depth at 550 nm "//name_aero(3),"1", (/ ('', i=1, 6) /)), &
-       ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_CSSO4M',                       &
-      "Aerosol Optical depth at 550 nm "//name_aero(4),"1", (/ ('', i=1, 6) /)), &
-       ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_SSSSM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(5),"1", (/ ('', i=1, 6) /)), &
-       ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_ASSSM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(6),"1", (/ ('', i=1, 6) /)), &
-       ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_CSSSM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(7),"1", (/ ('', i=1, 6) /)), &
-       ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_CIDUSTM',                      &
-      "Aerosol Optical depth at 550 nm "//name_aero(8),"1", (/ ('', i=1, 6) /)), &
-       ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_AIBCM',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(9),"1", (/ ('', i=1, 6) /)), &
-       ctrl_out((/ 2, 6, 10, 10, 10, 10 /),'OD550_AIPOMM',                       &
-      "Aerosol Optical depth at 550 nm "//name_aero(10),"1", (/ ('', i=1, 6) /)),&
-       ctrl_out((/ 2, 2, 10, 10, 10, 10 /),'OD550_STRAT',                        &
-      "Aerosol Optical depth at 550 nm "//name_aero(11),"1", (/ ('', i=1, 6) /)) /)
-  TYPE(ctrl_out), SAVE :: o_od550aer = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'od550aer', 'Total aerosol optical depth at 550nm', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_od865aer = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'od865aer', 'Total aerosol optical depth at 870nm', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_absvisaer = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'absvisaer', 'Absorption aerosol visible optical depth', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_od550lt1aer = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'od550lt1aer', 'Fine mode optical depth', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_sconcso4 = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'sconcso4', 'Surface Concentration of Sulfate ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_sconcoa = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'sconcoa', 'Surface Concentration of Organic Aerosol ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_sconcbc = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'sconcbc', 'Surface Concentration of Black Carbon ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_sconcss = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'sconcss', 'Surface Concentration of Sea Salt ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_sconcdust = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'sconcdust', 'Surface Concentration of Dust ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_concso4 = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'concso4', 'Concentration of Sulfate ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_concoa = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'concoa', 'Concentration of Organic Aerosol ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_concbc = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'concbc', 'Concentration of Black Carbon ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_concss = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'concss', 'Concentration of Sea Salt ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_concdust = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'concdust', 'Concentration of Dust ', 'kg/m3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_loadso4 = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'loadso4', 'Column Load of Sulfate ', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_loadoa = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'loadoa', 'Column Load of Organic Aerosol ', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_loadbc = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'loadbc', 'Column Load of Black Carbon ', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_loadss = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'loadss', 'Column Load of Sea Salt ', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_loaddust = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'loaddust', 'Column Load of Dust ', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swtoaas_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swtoaas_nat', 'Natural aerosol radiative forcing all-sky at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swsrfas_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swsrfas_nat', 'Natural aerosol radiative forcing all-sky at SRF', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swtoacs_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swtoacs_nat', 'Natural aerosol radiative forcing clear-sky at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swsrfcs_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swsrfcs_nat', 'Natural aerosol radiative forcing clear-sky at SRF', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swtoaas_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swtoaas_ant', 'Anthropogenic aerosol radiative forcing all-sky at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swsrfas_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swsrfas_ant', 'Anthropogenic aerosol radiative forcing all-sky at SRF', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swtoacs_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swtoacs_ant', 'Anthropogenic aerosol radiative forcing clear-sky at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swsrfcs_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swsrfcs_ant', 'Anthropogenic aerosol radiative forcing clear-sky at SRF', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swtoacf_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swtoacf_nat', 'Natural aerosol impact on cloud radiative forcing at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swsrfcf_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swsrfcf_nat', 'Natural aerosol impact on cloud radiative forcing  at SRF', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swtoacf_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swtoacf_ant', 'Anthropogenic aerosol impact on cloud radiative forcing at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swsrfcf_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swsrfcf_ant', 'Anthropogenic aerosol impact on cloud radiative forcing at SRF', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swtoacf_zero = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swtoacf_zero', 'Cloud radiative forcing (allsky-clearsky fluxes) at TOA', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_swsrfcf_zero = ctrl_out((/ 4, 6, 10, 10, 10, 10 /), &
-	'swsrfcf_zero', 'Cloud radiative forcing (allsky-clearsky fluxes) at SRF', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cldncl = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'cldncl', 'CDNC at top of liquid water cloud', 'm-3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_reffclwtop = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'reffclwtop', 'Droplet effective radius at top of liquid water cloud', 'm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_cldnvi = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'cldnvi', 'Column Integrated Cloud Droplet Number', 'm-2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_lcc = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'lcc', 'Cloud liquid fraction at top of cloud', '1', (/ ('', i=1, 6) /))
+    (/ ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASBCM',                        &
+      "Aerosol Optical depth at 550 nm "//name_aero(1),"1", (/ ('', i=1, 9) /)), &
+       ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASPOMM',                       &
+      "Aerosol Optical depth at 550 nm "//name_aero(2),"1", (/ ('', i=1, 9) /)), &
+       ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASSO4M',                       &
+      "Aerosol Optical depth at 550 nm "//name_aero(3),"1", (/ ('', i=1, 9) /)), &
+       ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_CSSO4M',                       &
+      "Aerosol Optical depth at 550 nm "//name_aero(4),"1", (/ ('', i=1, 9) /)), &
+       ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_SSSSM',                        &
+      "Aerosol Optical depth at 550 nm "//name_aero(5),"1", (/ ('', i=1, 9) /)), &
+       ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_ASSSM',                        &
+      "Aerosol Optical depth at 550 nm "//name_aero(6),"1", (/ ('', i=1, 9) /)), &
+       ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_CSSSM',                        &
+      "Aerosol Optical depth at 550 nm "//name_aero(7),"1", (/ ('', i=1, 9) /)), &
+       ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_CIDUSTM',                      &
+      "Aerosol Optical depth at 550 nm "//name_aero(8),"1", (/ ('', i=1, 9) /)), &
+       ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_AIBCM',                        &
+      "Aerosol Optical depth at 550 nm "//name_aero(9),"1", (/ ('', i=1, 9) /)), &
+       ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /),'OD550_AIPOMM',                       &
+      "Aerosol Optical depth at 550 nm "//name_aero(10),"1", (/ ('', i=1, 9) /)),&
+       ctrl_out((/ 2, 2, 10, 10, 10, 10, 11, 11, 11 /),'OD550_STRAT',                        &
+      "Aerosol Optical depth at 550 nm "//name_aero(11),"1", (/ ('', i=1, 9) /)) /)
+  TYPE(ctrl_out), SAVE :: o_od550aer = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'od550aer', 'Total aerosol optical depth at 550nm', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_od865aer = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'od865aer', 'Total aerosol optical depth at 870nm', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_absvisaer = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'absvisaer', 'Absorption aerosol visible optical depth', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_od550lt1aer = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'od550lt1aer', 'Fine mode optical depth', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_sconcso4 = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'sconcso4', 'Surface Concentration of Sulfate ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_sconcoa = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'sconcoa', 'Surface Concentration of Organic Aerosol ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_sconcbc = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'sconcbc', 'Surface Concentration of Black Carbon ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_sconcss = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'sconcss', 'Surface Concentration of Sea Salt ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_sconcdust = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'sconcdust', 'Surface Concentration of Dust ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_concso4 = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'concso4', 'Concentration of Sulfate ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_concoa = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'concoa', 'Concentration of Organic Aerosol ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_concbc = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'concbc', 'Concentration of Black Carbon ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_concss = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'concss', 'Concentration of Sea Salt ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_concdust = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'concdust', 'Concentration of Dust ', 'kg/m3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_loadso4 = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'loadso4', 'Column Load of Sulfate ', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_loadoa = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'loadoa', 'Column Load of Organic Aerosol ', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_loadbc = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'loadbc', 'Column Load of Black Carbon ', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_loadss = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'loadss', 'Column Load of Sea Salt ', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_loaddust = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'loaddust', 'Column Load of Dust ', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swtoaas_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swtoaas_nat', 'Natural aerosol radiative forcing all-sky at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swsrfas_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swsrfas_nat', 'Natural aerosol radiative forcing all-sky at SRF', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swtoacs_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swtoacs_nat', 'Natural aerosol radiative forcing clear-sky at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swsrfcs_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swsrfcs_nat', 'Natural aerosol radiative forcing clear-sky at SRF', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swtoaas_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swtoaas_ant', 'Anthropogenic aerosol radiative forcing all-sky at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swsrfas_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swsrfas_ant', 'Anthropogenic aerosol radiative forcing all-sky at SRF', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swtoacs_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swtoacs_ant', 'Anthropogenic aerosol radiative forcing clear-sky at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swsrfcs_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swsrfcs_ant', 'Anthropogenic aerosol radiative forcing clear-sky at SRF', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swtoacf_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swtoacf_nat', 'Natural aerosol impact on cloud radiative forcing at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swsrfcf_nat = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swsrfcf_nat', 'Natural aerosol impact on cloud radiative forcing  at SRF', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swtoacf_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swtoacf_ant', 'Anthropogenic aerosol impact on cloud radiative forcing at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swsrfcf_ant = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swsrfcf_ant', 'Anthropogenic aerosol impact on cloud radiative forcing at SRF', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swtoacf_zero = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swtoacf_zero', 'Cloud radiative forcing (allsky-clearsky fluxes) at TOA', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_swsrfcf_zero = ctrl_out((/ 4, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'swsrfcf_zero', 'Cloud radiative forcing (allsky-clearsky fluxes) at SRF', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cldncl = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cldncl', 'CDNC at top of liquid water cloud', 'm-3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_reffclwtop = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'reffclwtop', 'Droplet effective radius at top of liquid water cloud', 'm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_cldnvi = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'cldnvi', 'Column Integrated Cloud Droplet Number', 'm-2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_lcc = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'lcc', 'Cloud liquid fraction at top of cloud', '1', (/ ('', i=1, 9) /))
 
 
 !!!!!!!!!!!!!!!!!!!!!! 3D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
-  TYPE(ctrl_out), SAVE :: o_ec550aer = ctrl_out((/ 2, 6, 10, 10, 10, 10 /), &
-	'ec550aer', 'Extinction at 550nm', 'm^-1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_lwcon = ctrl_out((/ 2, 5, 10, 10, 10, 10 /), &
-	'lwcon', 'Cloud liquid water content', 'kg/kg', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_iwcon = ctrl_out((/ 2, 5, 10, 10, 10, 10 /), &
-	'iwcon', 'Cloud ice water content', 'kg/kg', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_temp = ctrl_out((/ 2, 3, 4, 10, 10, 10 /), &
-	'temp', 'Air temperature', 'K', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_theta = ctrl_out((/ 2, 3, 4, 10, 10, 10 /), &
-	'theta', 'Potential air temperature', 'K', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ovap = ctrl_out((/ 2, 3, 4, 10, 10, 10 /), &
-	'ovap', 'Specific humidity', 'kg/kg', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ovapinit = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'ovapinit', 'Specific humidity (begin of timestep)', 'kg/kg', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_oliq = ctrl_out((/ 2, 3, 4, 10, 10, 10 /), &
-	'oliq', 'Condensed water', 'kg/kg', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wvapp = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'wvapp', '', '', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_geop = ctrl_out((/ 2, 3, 10, 10, 10, 10 /), &
-	'geop', 'Geopotential height', 'm2/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_vitu = ctrl_out((/ 2, 3, 4, 6, 10, 10 /), &
-	'vitu', 'Zonal wind', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_vitv = ctrl_out((/ 2, 3, 4, 6, 10, 10 /), &
-	'vitv', 'Meridional wind', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_vitw = ctrl_out((/ 2, 3, 10, 6, 10, 10 /), &
-	'vitw', 'Vertical wind', 'Pa/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_pres = ctrl_out((/ 2, 3, 10, 10, 10, 10 /), &
-	'pres', 'Air pressure', 'Pa', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_paprs = ctrl_out((/ 2, 3, 10, 10, 10, 10 /), &
-	'paprs', 'Air pressure Inter-Couches', 'Pa', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_mass = ctrl_out((/ 2, 3, 10, 10, 10, 10 /), &
-	'mass', 'Masse Couches', 'kg/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_zfull = ctrl_out((/ 2, 3, 10, 10, 10, 10 /), &
-	'zfull', 'Altitude of full pressure levels', 'm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_zhalf = ctrl_out((/ 2, 3, 10, 10, 10, 10 /), &
-	'zhalf', 'Altitude of half pressure levels', 'm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rneb = ctrl_out((/ 2, 5, 10, 10, 10, 10 /), &
-	'rneb', 'Cloud fraction', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rnebcon = ctrl_out((/ 2, 5, 10, 10, 10, 10 /), &
-	'rnebcon', 'Convective Cloud Fraction', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rnebls = ctrl_out((/ 2, 5, 10, 10, 10, 10 /), &
-	'rnebls', 'LS Cloud fraction', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rhum = ctrl_out((/ 2, 5, 10, 10, 10, 10 /), &
-	'rhum', 'Relative humidity', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ozone = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'ozone', 'Ozone mole fraction', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ozone_light = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'ozone_daylight', 'Daylight ozone mole fraction', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_upwd = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'upwd', 'saturated updraft', 'kg/m2/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtphy = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'dtphy', 'Physics dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqphy = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'dqphy', 'Physics dQ', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_pr_con_l = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'pr_con_l', 'Convective precipitation lic', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_pr_con_i = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'pr_con_i', 'Convective precipitation ice', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_pr_lsc_l = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'pr_lsc_l', 'Large scale precipitation lic', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_pr_lsc_i = ctrl_out((/ 2, 10, 10, 10, 10, 10 /), &
-	'pr_lsc_i', 'Large scale precipitation ice', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_re = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	're', 'Cloud droplet effective radius', 'um', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_fl = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'fl', 'Denominator of Cloud droplet effective radius', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_scdnc = ctrl_out((/ 2,  6, 10, 10, 10, 10 /), &
-	'scdnc', 'Cloud droplet number concentration', 'm-3', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_reffclws = ctrl_out((/ 2,  6, 10, 10, 10, 10 /), &
-	'reffclws', 'Stratiform Cloud Droplet Effective Radius (aerosol diags.)', 'm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_reffclwc = ctrl_out((/ 2,  6, 10, 10, 10, 10 /), &
-	'reffclwc', 'Convective Cloud Droplet Effective Radius (aerosol diags.)', 'm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_lcc3d = ctrl_out((/ 2,  6, 10, 10, 10, 10 /), &
-	'lcc3d', 'Cloud liquid fraction', '1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_lcc3dcon = ctrl_out((/ 2,  6, 10, 10, 10, 10 /), &
-	'lcc3dcon', 'Convective cloud liquid fraction', '1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_lcc3dstra = ctrl_out((/ 2,  6, 10, 10, 10, 10 /), &
-	'lcc3dstra', 'Stratiform cloud liquid fraction', '1', (/ ('', i=1, 6) /))
+  TYPE(ctrl_out), SAVE :: o_ec550aer = ctrl_out((/ 2, 6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ec550aer', 'Extinction at 550nm', 'm^-1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_lwcon = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'lwcon', 'Cloud liquid water content', 'kg/kg', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_iwcon = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'iwcon', 'Cloud ice water content', 'kg/kg', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_temp = ctrl_out((/ 2, 3, 4, 10, 10, 10, 11, 11, 11 /), &
+    'temp', 'Air temperature', 'K', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_theta = ctrl_out((/ 2, 3, 4, 10, 10, 10, 11, 11, 11 /), &
+    'theta', 'Potential air temperature', 'K', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ovap = ctrl_out((/ 2, 3, 4, 10, 10, 10, 11, 11, 11 /), &
+    'ovap', 'Specific humidity', 'kg/kg', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ovapinit = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ovapinit', 'Specific humidity (begin of timestep)', 'kg/kg', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_oliq = ctrl_out((/ 2, 3, 4, 10, 10, 10, 11, 11, 11 /), &
+    'oliq', 'Condensed water', 'kg/kg', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wvapp = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'wvapp', '', '', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_geop = ctrl_out((/ 2, 3, 10, 10, 10, 10, 11, 11, 11 /), &
+    'geop', 'Geopotential height', 'm2/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_vitu = ctrl_out((/ 2, 3, 4, 6, 10, 10, 11, 11, 11 /), &
+    'vitu', 'Zonal wind', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_vitv = ctrl_out((/ 2, 3, 4, 6, 10, 10, 11, 11, 11 /), &
+    'vitv', 'Meridional wind', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_vitw = ctrl_out((/ 2, 3, 10, 6, 10, 10, 11, 11, 11 /), &
+    'vitw', 'Vertical wind', 'Pa/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_pres = ctrl_out((/ 2, 3, 10, 10, 10, 10, 11, 11, 11 /), &
+    'pres', 'Air pressure', 'Pa', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_paprs = ctrl_out((/ 2, 3, 10, 10, 10, 10, 11, 11, 11 /), &
+    'paprs', 'Air pressure Inter-Couches', 'Pa', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_mass = ctrl_out((/ 2, 3, 10, 10, 10, 10, 11, 11, 11 /), &
+    'mass', 'Masse Couches', 'kg/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_zfull = ctrl_out((/ 2, 3, 10, 10, 10, 10, 11, 11, 11 /), &
+    'zfull', 'Altitude of full pressure levels', 'm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_zhalf = ctrl_out((/ 2, 3, 10, 10, 10, 10, 11, 11, 11 /), &
+    'zhalf', 'Altitude of half pressure levels', 'm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rneb = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rneb', 'Cloud fraction', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rnebcon = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rnebcon', 'Convective Cloud Fraction', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rnebls = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rnebls', 'LS Cloud fraction', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rhum = ctrl_out((/ 2, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rhum', 'Relative humidity', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ozone = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ozone', 'Ozone mole fraction', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ozone_light = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ozone_daylight', 'Daylight ozone mole fraction', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_upwd = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'upwd', 'saturated updraft', 'kg/m2/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtphy = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtphy', 'Physics dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqphy = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqphy', 'Physics dQ', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_pr_con_l = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'pr_con_l', 'Convective precipitation lic', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_pr_con_i = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'pr_con_i', 'Convective precipitation ice', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_pr_lsc_l = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'pr_lsc_l', 'Large scale precipitation lic', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_pr_lsc_i = ctrl_out((/ 2, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'pr_lsc_i', 'Large scale precipitation ice', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_re = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    're', 'Cloud droplet effective radius', 'um', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_fl = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'fl', 'Denominator of Cloud droplet effective radius', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_scdnc = ctrl_out((/ 2,  6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'scdnc', 'Cloud droplet number concentration', 'm-3', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_reffclws = ctrl_out((/ 2,  6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'reffclws', 'Stratiform Cloud Droplet Effective Radius (aerosol diags.)', 'm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_reffclwc = ctrl_out((/ 2,  6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'reffclwc', 'Convective Cloud Droplet Effective Radius (aerosol diags.)', 'm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_lcc3d = ctrl_out((/ 2,  6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'lcc3d', 'Cloud liquid fraction', '1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_lcc3dcon = ctrl_out((/ 2,  6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'lcc3dcon', 'Convective cloud liquid fraction', '1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_lcc3dstra = ctrl_out((/ 2,  6, 10, 10, 10, 10, 11, 11, 11 /), &
+    'lcc3dstra', 'Stratiform cloud liquid fraction', '1', (/ ('', i=1, 9) /))
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_albe_srf     = (/ &
-      ctrl_out((/ 3, 7, 10, 7, 10, 10 /),'albe_ter', "Albedo VIS surf. "//clnsurf(1),"-", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 3, 7, 10, 7, 10, 10 /),'albe_lic', "Albedo VIS surf. "//clnsurf(2),"-", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 3, 7, 10, 7, 10, 10 /),'albe_oce', "Albedo VIS surf. "//clnsurf(3),"-", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 3, 7, 10, 7, 10, 10 /),'albe_sic', "Albedo VIS surf. "//clnsurf(4),"-", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 3, 7, 10, 7, 10, 10, 11, 11, 11 /),'albe_ter', "Albedo VIS surf. "//clnsurf(1),"-", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 3, 7, 10, 7, 10, 10, 11, 11, 11 /),'albe_lic', "Albedo VIS surf. "//clnsurf(2),"-", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 3, 7, 10, 7, 10, 10, 11, 11, 11 /),'albe_oce', "Albedo VIS surf. "//clnsurf(3),"-", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 3, 7, 10, 7, 10, 10, 11, 11, 11 /),'albe_sic', "Albedo VIS surf. "//clnsurf(4),"-", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_ages_srf     = (/ &
-      ctrl_out((/ 10, 10, 10, 10, 10, 10 /),'ages_ter', "Snow age", "day", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 3, 10, 10, 10, 10, 10 /),'ages_lic', "Snow age", "day", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 10, 10, 10, 10, 10, 10 /),'ages_oce',"Snow age", "day", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 3, 10, 10, 10, 10, 10 /),'ages_sic',"Snow age", "day", (/ ('', i=1, 6) /)) /)
+      ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /),'ages_ter', "Snow age", "day", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 3, 10, 10, 10, 10, 10, 11, 11, 11 /),'ages_lic', "Snow age", "day", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /),'ages_oce',"Snow age", "day", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 3, 10, 10, 10, 10, 10, 11, 11, 11 /),'ages_sic',"Snow age", "day", (/ ('', i=1, 9) /)) /)
 
   TYPE(ctrl_out), SAVE, DIMENSION(4) :: o_rugs_srf     = (/ &
-      ctrl_out((/ 3, 6, 10, 10, 10, 10 /),'rugs_ter', "Surface roughness "//clnsurf(1),"m", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 3, 6, 10, 10, 10, 10 /),'rugs_lic', "Surface roughness "//clnsurf(2),"m", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 3, 6, 10, 10, 10, 10 /),'rugs_oce', "Surface roughness "//clnsurf(3),"m", (/ ('', i=1, 6) /)), &
-      ctrl_out((/ 3, 6, 10, 10, 10, 10 /),'rugs_sic', "Surface roughness "//clnsurf(4),"m", (/ ('', i=1, 6) /)) /)
-
-  TYPE(ctrl_out), SAVE :: o_alb1 = ctrl_out((/ 3, 10, 10, 10, 10, 10 /), &
-	'alb1', 'Surface VIS albedo', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_alb2 = ctrl_out((/ 3, 10, 10, 10, 10, 10 /), &
-	'alb2', 'Surface Near IR albedo', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_clwcon = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'clwcon', 'Convective Cloud Liquid water content', 'kg/kg', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_Ma = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'Ma', 'undilute adiab updraft', 'kg/m2/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dnwd = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dnwd', 'saturated downdraft', 'kg/m2/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dnwd0 = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dnwd0', 'unsat. downdraft', 'kg/m2/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_mc = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'mc', 'Convective mass flux', 'kg/m2/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ftime_con = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'ftime_con', 'Fraction of time convection Occurs', ' ',                 &
-      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /))
-  TYPE(ctrl_out), SAVE :: o_dtdyn = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtdyn', 'Dynamics dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqdyn = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dqdyn', 'Dynamics dQ', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dudyn = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dudyn', 'Dynamics dU', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dvdyn = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dvdyn', 'Dynamics dV', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtcon = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtcon', 'Convection dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ducon = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'ducon', 'Convection du', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dvcon = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dvcon', 'Convection dv', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqcon = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dqcon', 'Convection dQ', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtwak = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'dtwak', 'Wake dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqwak = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'dqwak', 'Wake dQ', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wake_h = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'wake_h', 'wake_h', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wake_s = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'wake_s', 'wake_s', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wake_deltat = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'wake_deltat', 'wake_deltat', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wake_deltaq = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'wake_deltaq', 'wake_deltaq', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wake_omg = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'wake_omg', 'wake_omg', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wdtrainA = ctrl_out((/ 4, 1, 10,  4,  1, 10 /), &
-	'wdtrainA', 'precipitation from AA', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_wdtrainM = ctrl_out((/ 4, 1, 10,  4,  1, 10 /), &
-	'wdtrainM', 'precipitation from mixture', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_Vprecip = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'Vprecip', 'precipitation vertical profile', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ftd = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'ftd', 'tend temp due aux descentes precip', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_fqd = ctrl_out((/ 4, 5, 10, 10, 10, 10 /), &
-	'fqd', 'tend vap eau due aux descentes precip', '-', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtlsc = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtlsc', 'Condensation dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtlschr = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtlschr', 'Large-scale condensational heating rate', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqlsc = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dqlsc', 'Condensation dQ', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_beta_prec = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'beta_prec', 'LS Conversion rate to prec', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtvdf = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtvdf', 'Boundary-layer dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtdis = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtdis', 'TKE dissipation dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqvdf = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dqvdf', 'Boundary-layer dQ', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dteva = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dteva', 'Reevaporation dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqeva = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dqeva', 'Reevaporation dQ', '(kg/kg)/s', (/ ('', i=1, 6) /))
+      ctrl_out((/ 3, 6, 10, 10, 10, 10, 11, 11, 11 /),'rugs_ter', "Surface roughness "//clnsurf(1),"m", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 3, 6, 10, 10, 10, 10, 11, 11, 11 /),'rugs_lic', "Surface roughness "//clnsurf(2),"m", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 3, 6, 10, 10, 10, 10, 11, 11, 11 /),'rugs_oce', "Surface roughness "//clnsurf(3),"m", (/ ('', i=1, 9) /)), &
+      ctrl_out((/ 3, 6, 10, 10, 10, 10, 11, 11, 11 /),'rugs_sic', "Surface roughness "//clnsurf(4),"m", (/ ('', i=1, 9) /)) /)
+
+  TYPE(ctrl_out), SAVE :: o_alb1 = ctrl_out((/ 3, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'alb1', 'Surface VIS albedo', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_alb2 = ctrl_out((/ 3, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'alb2', 'Surface Near IR albedo', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_clwcon = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'clwcon', 'Convective Cloud Liquid water content', 'kg/kg', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Ma = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'Ma', 'undilute adiab updraft', 'kg/m2/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dnwd = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dnwd', 'saturated downdraft', 'kg/m2/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dnwd0 = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dnwd0', 'unsat. downdraft', 'kg/m2/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_mc = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'mc', 'Convective mass flux', 'kg/m2/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ftime_con = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ftime_con', 'Fraction of time convection Occurs', ' ',                 &
+      (/ 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)', 'inst(X)' /))
+  TYPE(ctrl_out), SAVE :: o_dtdyn = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtdyn', 'Dynamics dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqdyn = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqdyn', 'Dynamics dQ', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dudyn = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dudyn', 'Dynamics dU', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dvdyn = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dvdyn', 'Dynamics dV', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtcon = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtcon', 'Convection dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ducon = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ducon', 'Convection du', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dvcon = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dvcon', 'Convection dv', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqcon = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqcon', 'Convection dQ', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtwak = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtwak', 'Wake dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqwak = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqwak', 'Wake dQ', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wake_h = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'wake_h', 'wake_h', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wake_s = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'wake_s', 'wake_s', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wake_deltat = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'wake_deltat', 'wake_deltat', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wake_deltaq = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'wake_deltaq', 'wake_deltaq', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wake_omg = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'wake_omg', 'wake_omg', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wdtrainA = ctrl_out((/ 4, 1, 10,  4,  1, 10, 11, 11, 110 /), &
+    'wdtrainA', 'precipitation from AA', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_wdtrainM = ctrl_out((/ 4, 1, 10,  4,  1, 10, 11, 11, 110 /), &
+    'wdtrainM', 'precipitation from mixture', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_Vprecip = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'Vprecip', 'precipitation vertical profile', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ftd = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ftd', 'tend temp due aux descentes precip', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_fqd = ctrl_out((/ 4, 5, 10, 10, 10, 10, 11, 11, 11 /), &
+    'fqd', 'tend vap eau due aux descentes precip', '-', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtlsc = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtlsc', 'Condensation dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtlschr = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtlschr', 'Large-scale condensational heating rate', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqlsc = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqlsc', 'Condensation dQ', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_beta_prec = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'beta_prec', 'LS Conversion rate to prec', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtvdf = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtvdf', 'Boundary-layer dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtdis = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtdis', 'TKE dissipation dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqvdf = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqvdf', 'Boundary-layer dQ', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dteva = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dteva', 'Reevaporation dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqeva = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqeva', 'Reevaporation dQ', '(kg/kg)/s', (/ ('', i=1, 9) /))
 
 !!!!!!!!!!!!!!!! Specifique thermiques
-  TYPE(ctrl_out), SAVE :: o_dqlscth = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'dqlscth', 'dQ therm.', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqlscst = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'dqlscst', 'dQ strat.', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtlscth = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'dtlscth', 'dQ therm.', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtlscst = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'dtlscst', 'dQ strat.', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_plulth = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'plulth', 'Rainfall therm.', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_plulst = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'plulst', 'Rainfall strat.', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_lmaxth = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'lmaxth', "Upper level thermals", "", (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ptconvth = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'ptconvth', 'POINTS CONVECTIFS therm.', ' ', (/ ('', i=1, 6) /))
+  TYPE(ctrl_out), SAVE :: o_dqlscth = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqlscth', 'dQ therm.', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqlscst = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqlscst', 'dQ strat.', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtlscth = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtlscth', 'dQ therm.', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtlscst = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtlscst', 'dQ strat.', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_plulth = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'plulth', 'Rainfall therm.', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_plulst = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'plulst', 'Rainfall strat.', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_lmaxth = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'lmaxth', "Upper level thermals", "", (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ptconvth = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ptconvth', 'POINTS CONVECTIFS therm.', ' ', (/ ('', i=1, 9) /))
 !!!!!!!!!!!!!!!!!!!!!!!!
-  TYPE(ctrl_out), SAVE :: o_ptconv = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'ptconv', 'POINTS CONVECTIFS', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ratqs = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'ratqs', 'RATQS', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtthe = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtthe', 'Thermal dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_f_th = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'f_th', 'Thermal plume mass flux', 'kg/(m2*s)', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_e_th = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'e_th', 'Thermal plume entrainment', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_w_th = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'w_th', 'Thermal plume vertical velocity', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_lambda_th = ctrl_out((/ 10, 10, 10, 10, 10, 10 /), &
-	'lambda_th', 'Thermal plume vertical velocity', 'm/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ftime_th = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'ftime_th', 'Fraction of time Shallow convection occurs', ' ', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_q_th = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'q_th', 'Thermal plume total humidity', 'kg/kg', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_a_th = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'a_th', "Thermal plume fraction", "", (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_d_th = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'd_th', 'Thermal plume detrainment', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_f0_th = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'f0_th', 'Thermal closure mass flux', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_zmax_th = ctrl_out((/ 4,  4,  4,  5, 10, 10 /), &
-	'zmax_th', 'Thermal plume height', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqthe = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dqthe', 'Thermal dQ', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtajs = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtajs', 'Dry adjust. dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dqajs = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dqajs', 'Dry adjust. dQ', '(kg/kg)/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtswr = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtswr', 'SW radiation dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtsw0 = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtsw0', 'CS SW radiation dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtlwr = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtlwr', 'LW radiation dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtlw0 = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtlw0', 'CS LW radiation dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtec = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtec', 'Cinetic dissip dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_duvdf = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'duvdf', 'Boundary-layer dU', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dvvdf = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dvvdf', 'Boundary-layer dV', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_duoro = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'duoro', 'Orography dU', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dvoro = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dvoro', 'Orography dV', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dulif = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dulif', 'Orography dU', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dvlif = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dvlif', 'Orography dV', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_duhin = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'duhin', 'Hines GWD dU', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dvhin = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dvhin', 'Hines GWD dV', 'm/s2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtoro = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtoro', 'Orography dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dtlif = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dtlif', 'Orography dT', 'K/s', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dthin = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dthin', 'Hines GWD dT', 'K/s', (/ ('', i=1, 6) /))
+  TYPE(ctrl_out), SAVE :: o_ptconv = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ptconv', 'POINTS CONVECTIFS', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ratqs = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ratqs', 'RATQS', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtthe = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtthe', 'Thermal dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_f_th = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'f_th', 'Thermal plume mass flux', 'kg/(m2*s)', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_e_th = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'e_th', 'Thermal plume entrainment', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_w_th = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'w_th', 'Thermal plume vertical velocity', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_lambda_th = ctrl_out((/ 10, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'lambda_th', 'Thermal plume vertical velocity', 'm/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ftime_th = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ftime_th', 'Fraction of time Shallow convection occurs', ' ', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_q_th = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'q_th', 'Thermal plume total humidity', 'kg/kg', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_a_th = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'a_th', "Thermal plume fraction", "", (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_d_th = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'd_th', 'Thermal plume detrainment', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_f0_th = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'f0_th', 'Thermal closure mass flux', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_zmax_th = ctrl_out((/ 4,  4,  4,  5, 10, 10, 11, 11, 11 /), &
+    'zmax_th', 'Thermal plume height', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqthe = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqthe', 'Thermal dQ', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtajs = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtajs', 'Dry adjust. dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dqajs = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dqajs', 'Dry adjust. dQ', '(kg/kg)/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtswr = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtswr', 'SW radiation dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtsw0 = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtsw0', 'CS SW radiation dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtlwr = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtlwr', 'LW radiation dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtlw0 = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtlw0', 'CS LW radiation dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtec = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtec', 'Cinetic dissip dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_duvdf = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'duvdf', 'Boundary-layer dU', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dvvdf = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dvvdf', 'Boundary-layer dV', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_duoro = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'duoro', 'Orography dU', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dvoro = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dvoro', 'Orography dV', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dulif = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dulif', 'Orography dU', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dvlif = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dvlif', 'Orography dV', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_duhin = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'duhin', 'Hines GWD dU', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dvhin = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dvhin', 'Hines GWD dV', 'm/s2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtoro = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtoro', 'Orography dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dtlif = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dtlif', 'Orography dT', 'K/s', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dthin = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dthin', 'Hines GWD dT', 'K/s', (/ ('', i=1, 9) /))
 
   TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_trac(:)
   TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_trac_cum(:)
-  TYPE(ctrl_out), SAVE :: o_rsu = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'rsu', 'SW upward radiation', 'W m-2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rsd = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'rsd', 'SW downward radiation', 'W m-2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rlu = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'rlu', 'LW upward radiation', 'W m-2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rld = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'rld', 'LW downward radiation', 'W m-2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rsucs = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'rsucs', 'SW CS upward radiation', 'W m-2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rsdcs = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'rsdcs', 'SW CS downward radiation', 'W m-2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rlucs = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'rlucs', 'LW CS upward radiation', 'W m-2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rldcs = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'rldcs', 'LW CS downward radiation', 'W m-2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tnt = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'tnt', 'Tendency of air temperature', 'K s-1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tntc = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'tntc', 'Tendency of air temperature due to Moist Convection', 'K s-1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tntr = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'tntr', 'Air temperature tendency due to Radiative heating', 'K s-1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tntscpbl = ctrl_out((/ 4, 10, 10, 10, 10, 10 /),                  &
-	'tntscpbl', 'Air temperature tendency due to St cloud and precipitation and BL mixing', &
-      'K s-1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tnhus = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'tnhus', 'Tendency of specific humidity', 's-1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tnhusc = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'tnhusc', 'Tendency of specific humidity due to convection', 's-1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_tnhusscpbl = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'tnhusscpbl', 'Tendency of Specific humidity due to ST cl, precip and BL mixing', 's-1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_evu = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'evu', 'Eddy viscosity coefficient for Momentum Variables', 'm2 s-1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_h2o = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'h2o', 'Mass Fraction of Water', '1', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_mcd = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'mcd', 'Downdraft COnvective Mass Flux', 'kg/(m2*s)', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_dmc = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'dmc', 'Deep COnvective Mass Flux', 'kg/(m2*s)', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ref_liq = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'ref_liq', 'Effective radius of convective cloud liquid water particle', 'm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_ref_ice = ctrl_out((/ 4, 10, 10, 10, 10, 10 /), &
-	'ref_ice', 'Effective radius of startiform cloud ice particle', 'm', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rsut4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rsut4co2', 'TOA Out SW in 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rlut4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rlut4co2', 'TOA Out LW in 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rsutcs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rsutcs4co2', 'TOA Out CS SW in 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rlutcs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rlutcs4co2', 'TOA Out CS LW in 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rsu4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rsu4co2', 'Upwelling SW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rlu4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rlu4co2', 'Upwelling LW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rsucs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rsucs4co2', 'Upwelling CS SW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rlucs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rlucs4co2', 'Upwelling CS LW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rsd4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rsd4co2', 'Downwelling SW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rld4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rld4co2', 'Downwelling LW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rsdcs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rsdcs4co2', 'Downwelling CS SW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
-  TYPE(ctrl_out), SAVE :: o_rldcs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10 /), &
-	'rldcs4co2', 'Downwelling CS LW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 6) /))
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_vdf(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_the(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_con(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_lessi_impa(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_lessi_nucl(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_insc(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_bcscav(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_evapls(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_ls(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_trsp(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_sscav(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_sat(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_uscav(:)
+  TYPE(ctrl_out), SAVE, ALLOCATABLE :: o_dtr_dry(:)
+
+  TYPE(ctrl_out), SAVE :: o_rsu = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsu', 'SW upward radiation', 'W m-2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rsd = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsd', 'SW downward radiation', 'W m-2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rlu = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rlu', 'LW upward radiation', 'W m-2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rld = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rld', 'LW downward radiation', 'W m-2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rsucs = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsucs', 'SW CS upward radiation', 'W m-2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rsdcs = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsdcs', 'SW CS downward radiation', 'W m-2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rlucs = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rlucs', 'LW CS upward radiation', 'W m-2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rldcs = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rldcs', 'LW CS downward radiation', 'W m-2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tnt = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tnt', 'Tendency of air temperature', 'K s-1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tntc = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tntc', 'Tendency of air temperature due to Moist Convection', 'K s-1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tntr = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tntr', 'Air temperature tendency due to Radiative heating', 'K s-1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tntscpbl = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /),                  &
+    'tntscpbl', 'Air temperature tendency due to St cloud and precipitation and BL mixing', &
+      'K s-1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tnhus = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tnhus', 'Tendency of specific humidity', 's-1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tnhusc = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tnhusc', 'Tendency of specific humidity due to convection', 's-1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_tnhusscpbl = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'tnhusscpbl', 'Tendency of Specific humidity due to ST cl, precip and BL mixing', 's-1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_evu = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'evu', 'Eddy viscosity coefficient for Momentum Variables', 'm2 s-1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_h2o = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'h2o', 'Mass Fraction of Water', '1', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_mcd = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'mcd', 'Downdraft COnvective Mass Flux', 'kg/(m2*s)', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_dmc = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'dmc', 'Deep COnvective Mass Flux', 'kg/(m2*s)', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ref_liq = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ref_liq', 'Effective radius of convective cloud liquid water particle', 'm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_ref_ice = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'ref_ice', 'Effective radius of startiform cloud ice particle', 'm', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rsut4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsut4co2', 'TOA Out SW in 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rlut4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rlut4co2', 'TOA Out LW in 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rsutcs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsutcs4co2', 'TOA Out CS SW in 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rlutcs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rlutcs4co2', 'TOA Out CS LW in 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rsu4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsu4co2', 'Upwelling SW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rlu4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rlu4co2', 'Upwelling LW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rsucs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsucs4co2', 'Upwelling CS SW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rlucs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rlucs4co2', 'Upwelling CS LW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rsd4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsd4co2', 'Downwelling SW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rld4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rld4co2', 'Downwelling LW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rsdcs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rsdcs4co2', 'Downwelling CS SW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+  TYPE(ctrl_out), SAVE :: o_rldcs4co2 = ctrl_out((/ 5, 10, 10, 10, 10, 10, 11, 11, 11 /), &
+    'rldcs4co2', 'Downwelling CS LW 4xCO2 atmosphere', 'W/m2', (/ ('', i=1, 9) /))
+
+!!!!!!!!!!!!! Sorties niveaux standards de pression NMC 
+  TYPE(ctrl_out), SAVE :: o_tnondef = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'tnondef', 'Undefined value of T', 'K', (/ "inst(X)", "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_ta = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'ta', 'Air temperature', 'K', (/ "inst(X)", "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_zg  = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'zg', 'Geopotential height', 'm', (/ "inst(X)", "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_hus = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'hus', 'Specific humidity', '1', (/ "inst(X)", "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))                                                                                    
+  TYPE(ctrl_out), SAVE :: o_hur = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'hur', 'Relative humidity', '%', (/ "inst(X)", "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_ua = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'ua', 'Eastward wind', 'm s-1', (/ "inst(X)", "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_va = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'va', 'Northward wind', 'm s-1', (/ ('', i=1, 9)/))
+  TYPE(ctrl_out), SAVE :: o_wap = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'wap', 'Lagrangian tendency of air pressure', 'Pa s-1', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_psbg = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'psbg', 'Lagrangian tendency of air pressure', 'Pa s-1', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_tro3 = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'tro3', 'Ozone mole fraction', '1e-9', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_tro3_daylight = ctrl_out((/ 11, 11, 11, 11, 11, 11, 5, 5, 5 /), &
+       'tro3_daylight', 'Daylight ozone mole fraction', '1e-9', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_uxv = ctrl_out((/ 11, 11, 11, 11, 11, 11, 6, 6, 6 /), &
+       'uv', 'uv', 'm2/s2', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))
+  TYPE(ctrl_out), SAVE :: o_vxq = ctrl_out((/ 11, 11, 11, 11, 11, 11, 6, 6, 6 /), &
+       'vq', 'vq', 'm/s * (kg/kg)', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))                                                                                                    
+  TYPE(ctrl_out), SAVE :: o_vxT = ctrl_out((/ 11, 11, 11, 11, 11, 11, 6, 6, 6 /), &
+       'vT', 'vT', 'mK/s', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))                                                                                      
+  TYPE(ctrl_out), SAVE :: o_wxq = ctrl_out((/ 11, 11, 11, 11, 11, 11, 6, 6, 6 /), &
+       'wq', 'wq', '(Pa/s)*(kg/kg)', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))                                                                                
+  TYPE(ctrl_out), SAVE :: o_vxphi = ctrl_out((/ 11, 11, 11, 11, 11, 11, 6, 6, 6 /), &
+       'vphi', 'vphi', 'm2/s', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))                                                                                 
+  TYPE(ctrl_out), SAVE :: o_wxT = ctrl_out((/ 11, 11, 11, 11, 11, 11, 6, 6, 6 /), &
+       'wT', 'wT', '"K*Pa/s', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))                                                                                     
+  TYPE(ctrl_out), SAVE :: o_uxu = ctrl_out((/ 11, 11, 11, 11, 11, 11, 6, 6, 6 /), &
+       'u2', 'u2', 'm2/s2', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))                                                                                                                                         
+  TYPE(ctrl_out), SAVE :: o_vxv = ctrl_out((/ 11, 11, 11, 11, 11, 11, 6, 6, 6 /), &
+       'v2', 'v2', 'm2/s2', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))                                                                               
+   TYPE(ctrl_out), SAVE :: o_TxT = ctrl_out((/ 11, 11, 11, 11, 11, 11, 6, 6, 6 /), &
+       'T2', 'T2', 'K2', (/ "inst(X)", "inst(X)", "inst(X)", &
+       "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)", "inst(X)"  /))                                                                                  
 
 END MODULE phys_output_ctrlout_mod
Index: LMDZ5/branches/testing/libf/phylmd/phys_output_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phys_output_mod.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/phys_output_mod.F90	(revision 1864)
@@ -1,4 +1,11 @@
 ! $Id$
 !
+
+MODULE phys_output_mod 
+  USE indice_sol_mod
+  USE phys_output_var_mod
+  USE aero_mod, only : naero_spc,name_aero
+  USE phys_output_write_mod, ONLY : phys_output_write
+
 ! Abderrahmane 12 2007
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -10,19 +17,4 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-MODULE phys_output_mod 
-  USE indice_sol_mod
-  USE phys_output_var_mod
-  USE phys_output_ctrlout_mod
-  USE aero_mod, only : naero_spc,name_aero
-
-  IMPLICIT NONE
-
-  PRIVATE histdef2d, histdef3d, conf_physoutputs
-
-  REAL, PRIVATE, SAVE                :: zdtime
-  !$OMP THREADPRIVATE(zdtime)
-
-
-
 CONTAINS
 
@@ -33,10 +25,12 @@
 
   SUBROUTINE phys_output_open(rlon,rlat,pim,tabij,ipt,jpt,plon,plat, &
-       jjmp1,nlevSTD,clevSTD,nbteta, &
+       jjmp1,nlevSTD,clevSTD,rlevSTD,nbteta, &
        ctetaSTD, dtime, ok_veget, &
        type_ocean, iflag_pbl,ok_mensuel,ok_journe, &
        ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, read_climoz, &
        phys_out_filestations, &
-       new_aod, aerosol_couple, flag_aerosol_strat)   
+       new_aod, aerosol_couple, flag_aerosol_strat, &
+       pdtphys, paprs, pphis, pplay, lmax_th, ptconv, ptconvth, ivap, &
+       d_t, qx, d_qx, zmasse, ok_sync)   
 
     USE iophy 
@@ -47,4 +41,10 @@
     USE mod_phys_lmdz_para
     USE aero_mod, only : naero_spc,name_aero
+    USE phys_output_ctrlout_mod
+
+#ifdef CPP_XIOS
+    ! ug Pour les sorties XIOS
+    USE wxios
+#endif
 
     IMPLICIT NONE
@@ -56,11 +56,24 @@
     include "iniprint.h"
 
-    real,dimension(klon),intent(in) :: rlon
-    real,dimension(klon),intent(in) :: rlat
-    INTEGER, intent(in)             :: pim
+    ! ug Nouveaux arguments nécessaires au histwrite_mod:
+    INTEGER, INTENT(IN)                         :: ivap
+    INTEGER, DIMENSION(klon), INTENT(IN)        :: lmax_th
+    LOGICAL, INTENT(IN)                         :: ok_sync
+    LOGICAL, DIMENSION(klon, klev), INTENT(IN)  :: ptconv, ptconvth
+    REAL, INTENT(IN)                            :: pdtphys
+    REAL, DIMENSION(klon), INTENT(IN)           :: pphis
+    REAL, DIMENSION(klon, klev), INTENT(IN)     :: pplay, d_t
+    REAL, DIMENSION(klon, klev+1), INTENT(IN)   :: paprs
+    REAL, DIMENSION(klon,klev,nqtot), INTENT(IN):: qx, d_qx
+    REAL, DIMENSION(klon, llm), INTENT(IN)      :: zmasse
+
+
+    REAL,DIMENSION(klon),INTENT(IN) :: rlon
+    REAL,DIMENSION(klon),INTENT(IN) :: rlat
+    INTEGER, INTENT(IN)             :: pim
     INTEGER, DIMENSION(pim)            :: tabij
-    INTEGER,dimension(pim), intent(in) :: ipt, jpt
-    REAL,dimension(pim), intent(in) :: plat, plon
-    REAL,dimension(pim,2) :: plat_bounds, plon_bounds
+    INTEGER,DIMENSION(pim), INTENT(IN) :: ipt, jpt
+    REAL,DIMENSION(pim), INTENT(IN) :: plat, plon
+    REAL,DIMENSION(pim,2) :: plat_bounds, plon_bounds
 
     INTEGER                               :: jjmp1
@@ -69,5 +82,5 @@
     LOGICAL                               :: ok_LES,ok_ade,ok_aie,flag_aerosol_strat
     LOGICAL                               :: new_aod, aerosol_couple
-    INTEGER, intent(in)::  read_climoz ! read ozone climatology
+    INTEGER, INTENT(IN)::  read_climoz ! read ozone climatology
     !     Allowed values are 0, 1 and 2
     !     0: do not read an ozone climatology
@@ -81,4 +94,5 @@
     REAL, DIMENSION(klev)                 :: Ahyb, Bhyb, Alt
     CHARACTER(LEN=4), DIMENSION(nlevSTD)  :: clevSTD
+    REAL, DIMENSION(nlevSTD)              :: rlevSTD
     INTEGER                               :: nsrf, k, iq, iiq, iff, i, j, ilev
     INTEGER                               :: naero
@@ -90,5 +104,4 @@
     CHARACTER(LEN=3)                      :: ctetaSTD(nbteta)
     REAL, DIMENSION(nfiles)               :: ecrit_files
-    CHARACTER(LEN=20), DIMENSION(nfiles)  :: phys_out_filenames
     INTEGER, DIMENSION(iim*jjmp1)         ::  ndex2d
     INTEGER, DIMENSION(iim*jjmp1*klev)    :: ndex3d
@@ -97,5 +110,6 @@
     INTEGER, DIMENSION(nfiles)            :: phys_out_levmin, phys_out_levmax
     INTEGER, DIMENSION(nfiles)            :: phys_out_filelevels
-    CHARACTER(LEN=20), DIMENSION(nfiles)  :: chtimestep   = (/ 'DefFreq', 'DefFreq','DefFreq', 'DefFreq', 'DefFreq', 'DefFreq' /)
+    CHARACTER(LEN=20), DIMENSION(nfiles)  :: chtimestep   = (/ '1mth', '1mth', '1mth', '1mth', '1mth', &
+                                                               '1mth', '1mth', '1mth', '1mth' /)
     LOGICAL, DIMENSION(nfiles)            :: phys_out_filekeys
     LOGICAL, DIMENSION(nfiles)            :: phys_out_filestations
@@ -104,9 +118,19 @@
     !                 entre [phys_out_lonmin,phys_out_lonmax] et [phys_out_latmin,phys_out_latmax]
 
-    LOGICAL, DIMENSION(nfiles), SAVE  :: phys_out_regfkey       = (/ .FALSE., .FALSE., .FALSE.,  .FALSE., .FALSE., .FALSE. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmin        = (/   -180.,   -180.,   -180.,    -180.,   -180.,   -180. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmax        = (/    180.,    180.,    180.,     180.,    180.,    180. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmin        = (/    -90.,    -90.,    -90.,     -90.,    -90.,    -90. /)
-    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmax        = (/     90.,     90.,     90.,     90.,     90.,     90. /)
+    LOGICAL, DIMENSION(nfiles), SAVE  :: phys_out_regfkey       = (/ .FALSE., .FALSE., .FALSE.,  .FALSE., &
+                                                                    .FALSE., .FALSE., .FALSE., .FALSE.,  .FALSE. /)
+    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmin        = (/   -180.,   -180.,   -180.,    -180., &
+                                                                     -180.,   -180., -180.,   -180.,    -180. /)
+    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmax        = (/    180.,    180.,    180.,     180., &
+                                                                      180.,    180., 180.,    180.,     180. /)
+    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmin        = (/    -90.,    -90.,    -90.,     -90., &
+                                                                    -90., -90., -90.,    -90.,     -90. /)
+    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmax        = (/  90.,     90.,     90.,     90., &
+                                                                    90., 90., 90., 90., 90. /)                        
+#ifdef CPP_XIOS
+    ! ug Variables utilisées pour récupérer le calendrier pour xios
+    INTEGER :: x_an, x_mois, x_jour
+    REAL :: x_heure
+#endif
 
     WRITE(lunout,*) 'Debut phys_output_mod.F90'
@@ -115,6 +139,12 @@
     IF (.NOT. ALLOCATED(o_trac)) ALLOCATE(o_trac(nqtot))
     IF (.NOT. ALLOCATED(o_trac_cum)) ALLOCATE(o_trac_cum(nqtot))
-
-    levmax = (/ klev, klev, klev, klev, klev, klev /)
+    ALLOCATE(o_dtr_the(nqtot),o_dtr_con(nqtot),o_dtr_lessi_impa(nqtot))
+    ALLOCATE(o_dtr_lessi_nucl(nqtot),o_dtr_insc(nqtot),o_dtr_bcscav(nqtot))
+    ALLOCATE(o_dtr_evapls(nqtot),o_dtr_ls(nqtot),o_dtr_trsp(nqtot))
+    ALLOCATE(o_dtr_sscav(nqtot),o_dtr_sat(nqtot),o_dtr_uscav(nqtot))
+    ALLOCATE(o_dtr_dry(nqtot),o_dtr_vdf(nqtot))
+
+
+    levmax = (/ klev, klev, klev, klev, klev, klev, nlevSTD, nlevSTD, nlevSTD /)
 
     phys_out_filenames(1) = 'histmth'
@@ -124,4 +154,7 @@
     phys_out_filenames(5) = 'histLES'
     phys_out_filenames(6) = 'histstn'
+    phys_out_filenames(7) = 'histmthNMC'
+    phys_out_filenames(8) = 'histdayNMC'
+    phys_out_filenames(9) = 'histhfNMC.nc'
 
     type_ecri(1) = 'ave(X)'
@@ -131,4 +164,7 @@
     type_ecri(5) = 'ave(X)'
     type_ecri(6) = 'inst(X)'
+    type_ecri(7) = 'inst(X)'
+    type_ecri(8) = 'inst(X)'
+    type_ecri(9) = 'inst(X)'
 
     clef_files(1) = ok_mensuel
@@ -138,4 +174,7 @@
     clef_files(5) = ok_LES
     clef_files(6) = ok_instan
+    clef_files(7) = ok_histNMC(1)
+    clef_files(8) = ok_histNMC(2)
+    clef_files(9) = ok_histNMC(3)
 
     !sortir des fichiers "stations" si clef_stations(:)=.TRUE.
@@ -146,4 +185,7 @@
     clef_stations(5) = .FALSE.
     clef_stations(6) = .FALSE.
+    clef_stations(7) = .FALSE.
+    clef_stations(8) = .FALSE.
+    clef_stations(9) = .FALSE.
 
     lev_files(1) = lev_histmth
@@ -153,4 +195,7 @@
     lev_files(5) = lev_histLES
     lev_files(6) = lev_histins
+    lev_files(7) = levout_histNMC(1)
+    lev_files(8) = levout_histNMC(2)
+    lev_files(9) = levout_histNMC(3)
 
     ecrit_files(1) = ecrit_mth
@@ -160,4 +205,7 @@
     ecrit_files(5) = ecrit_LES
     ecrit_files(6) = ecrit_ins
+    ecrit_files(7) = freq_outNMC(1)/86400.
+    ecrit_files(8) = freq_outNMC(2)/86400.
+    ecrit_files(9) = freq_outNMC(3)/86400.
 
     !! Lectures des parametres de sorties dans physiq.def
@@ -195,4 +243,12 @@
     WRITE(lunout,*)'phys_out_filelevels=',lev_files
 
+#ifdef CPP_XIOS
+    ! ug Réglage du calendrier xios
+    !Temps julian => an, mois, jour, heure
+    CALL ymds2ju(annee_ref, 1, day_ref, 0.0, zjulian)
+    CALL ju2ymds(zjulian, x_an, x_mois, x_jour, x_heure)
+    CALL wxios_set_cal(dtime, calend, x_an, x_mois, x_jour, x_heure)
+#endif
+
 !!!!!!!!!!!!!!!!!!!!!!! Boucle sur les fichiers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     ! Appel de histbeg et histvert pour creer le fichier et les niveaux verticaux !!
@@ -200,5 +256,5 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-    zdtime = dtime         ! Frequence ou l on moyenne
+    zdtime_moy = dtime         ! Frequence ou l on moyenne
 
     ! Calcul des Ahyb, Bhyb et Alt
@@ -226,4 +282,21 @@
        zoutm(iff) = ecrit_files(iff) ! Frequence ou l on ecrit en seconde
 
+
+#ifdef CPP_XIOS
+    ! ug déclaration des axes verticaux de chaque fichier:
+    CALL wxios_add_vaxis("presnivs", phys_out_filenames(iff), &
+            levmax(iff) - levmin(iff) + 1, presnivs(levmin(iff):levmax(iff)))
+    CALL wxios_add_vaxis("Ahyb", phys_out_filenames(iff), &
+            levmax(iff) - levmin(iff) + 1, Ahyb)
+    CALL wxios_add_vaxis("Bhyb", phys_out_filenames(iff), &
+            levmax(iff) - levmin(iff) + 1, Bhyb)
+    CALL wxios_add_vaxis("Ahyb", phys_out_filenames(iff), &
+            levmax(iff) - levmin(iff) + 1, Alt)
+
+    IF (clef_files(iff)) THEN
+         CALL wxios_add_file(phys_out_filenames(iff),chtimestep(iff),lev_files(iff))
+    END IF
+#endif 
+
        IF (clef_files(iff)) THEN
 
@@ -243,5 +316,4 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
           IF (phys_out_regfkey(iff)) then
-
              imin_ins=1
              imax_ins=iim
@@ -283,24 +355,14 @@
                   itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
           else
-             CALL histbeg_phy(phys_out_filenames(iff),itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
+             CALL histbeg_phy_all(phys_out_filenames(iff),itau_phy,zjulian,&
+                 dtime,nhorim(iff),nid_files(iff))
           endif
 
-          CALL histvert(nid_files(iff), "presnivs", "Vertical levels", "Pa", &
+#ifndef CPP_NO_IOIPSL 
+          if (iff.le.6) then
+             CALL histvert(nid_files(iff), "presnivs", "Vertical levels", "Pa", &  
                levmax(iff) - levmin(iff) + 1, &
                presnivs(levmin(iff):levmax(iff)), nvertm(iff),"down")
-
-!!!!!!!!!!!!! Traitement des champs 3D pour histhf !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!!!!!!!!!!!!!!! A Revoir plus tard !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-          !          IF (iff.eq.3.and.lev_files(iff).ge.4) THEN
-          !          CALL histbeg_phy("histhf3d",itau_phy, &
-          !     &                     zjulian, dtime, &
-          !     &                     nhorim, nid_hf3d)
-
-          !         CALL histvert(nid_hf3d, "presnivs", &
-          !     &                 "Vertical levels", "mb", &
-          !     &                 klev, presnivs/100., nvertm)
-          !          ENDIF
-          !
-!!!! Composentes de la coordonnee sigma-hybride 
+!!!! Composantes de la coordonnee sigma-hybride 
           CALL histvert(nid_files(iff), "Ahyb","Ahyb comp of Hyb Cord ", "Pa", &
                levmax(iff) - levmin(iff) + 1,Ahyb,nvertap(iff))
@@ -309,519 +371,97 @@
                levmax(iff) - levmin(iff) + 1,Bhyb,nvertbp(iff))
 
-          CALL histvert(nid_files(iff), "Alt","Height approx for scale heigh of 8km at levels", "Km", &
+          CALL histvert(nid_files(iff), "Alt","Height approx for scale heigh of 8km at levels", "Km", &                       
                levmax(iff) - levmin(iff) + 1,Alt,nvertAlt(iff))
 
-          !   CALL histvert(nid_files(iff), "preff","Reference pressure", "Pa", &
-          !                 1,preff,nvertp0(iff))
-!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    CALL histdef2d(iff,o_aire)
-    CALL histdef2d(iff,o_contfracATM)
-
-!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    CALL histdef2d(iff,o_phis)
-    CALL histdef2d(iff,o_contfracOR)
-    CALL histdef2d(iff,o_aireTER)
-    CALL histdef2d(iff,o_flat)
-    CALL histdef2d(iff,o_slp)
-    CALL histdef2d(iff,o_tsol)
-    CALL histdef2d(iff,o_t2m)
-    CALL histdef2d(iff,o_t2m_min)
-    CALL histdef2d(iff,o_t2m_max)
-    CALL histdef2d(iff,o_wind10m)
-    CALL histdef2d(iff,o_wind10max)
-    CALL histdef2d(iff,o_sicf)
-    CALL histdef2d(iff,o_q2m)
-    CALL histdef2d(iff,o_ustar)
-    CALL histdef2d(iff,o_u10m)
-    CALL histdef2d(iff,o_v10m)
-    CALL histdef2d(iff,o_psol)
-    CALL histdef2d(iff,o_qsurf)
-
-    IF (.NOT. ok_veget) THEN
-      CALL histdef2d(iff,o_qsol)
-    ENDIF
-    CALL histdef2d(iff,o_ndayrain)
-    CALL histdef2d(iff,o_precip)
-    CALL histdef2d(iff,o_plul)
-    CALL histdef2d(iff,o_pluc)
-    CALL histdef2d(iff,o_snow)
-    CALL histdef2d(iff,o_msnow)
-    CALL histdef2d(iff,o_fsnow)
-    CALL histdef2d(iff,o_evap)
-    CALL histdef2d(iff,o_tops)
-    CALL histdef2d(iff,o_tops0)
-    CALL histdef2d(iff,o_topl)
-    CALL histdef2d(iff,o_topl0)
-    CALL histdef2d(iff,o_SWupTOA)
-    CALL histdef2d(iff,o_SWupTOAclr)
-    CALL histdef2d(iff,o_SWdnTOA)
-    CALL histdef2d(iff,o_SWdnTOAclr)
-    CALL histdef2d(iff,o_nettop)
-    CALL histdef2d(iff,o_SWup200)
-    CALL histdef2d(iff,o_SWup200clr)
-    CALL histdef2d(iff,o_SWdn200)
-    CALL histdef2d(iff,o_SWdn200clr)
-    CALL histdef2d(iff,o_LWup200)
-    CALL histdef2d(iff,o_LWup200clr)
-    CALL histdef2d(iff,o_LWdn200)
-    CALL histdef2d(iff,o_LWdn200clr)
-    CALL histdef2d(iff,o_sols)
-    CALL histdef2d(iff,o_sols0)
-    CALL histdef2d(iff,o_soll)
-    CALL histdef2d(iff,o_radsol)
-    CALL histdef2d(iff,o_soll0)
-    CALL histdef2d(iff,o_SWupSFC)
-    CALL histdef2d(iff,o_SWupSFCclr)
-    CALL histdef2d(iff,o_SWdnSFC)
-    CALL histdef2d(iff,o_SWdnSFCclr)
-    CALL histdef2d(iff,o_LWupSFC)
-    CALL histdef2d(iff,o_LWdnSFC)
-    CALL histdef2d(iff,o_LWupSFCclr)
-    CALL histdef2d(iff,o_LWdnSFCclr)
-    CALL histdef2d(iff,o_bils)
-    CALL histdef2d(iff,o_bils_ec)
-    CALL histdef2d(iff,o_bils_tke)
-    CALL histdef2d(iff,o_bils_diss)
-    CALL histdef2d(iff,o_bils_kinetic)
-    CALL histdef2d(iff,o_bils_enthalp)
-    CALL histdef2d(iff,o_bils_latent)
-    CALL histdef2d(iff,o_sens)
-    CALL histdef2d(iff,o_fder)
-    CALL histdef2d(iff,o_ffonte)
-    CALL histdef2d(iff,o_fqcalving)
-    CALL histdef2d(iff,o_fqfonte)
-    CALL histdef2d(iff,o_taux)
-    CALL histdef2d(iff,o_tauy)
-
-    DO nsrf = 1, nbsrf
-      CALL histdef2d(iff,o_pourc_srf(nsrf))
-      CALL histdef2d(iff,o_fract_srf(nsrf))
-      CALL histdef2d(iff, o_taux_srf(nsrf))
-      CALL histdef2d(iff, o_tauy_srf(nsrf))
-      CALL histdef2d(iff, o_tsol_srf(nsrf))
-      CALL histdef2d(iff, o_evappot_srf(nsrf))
-      CALL histdef2d(iff, o_ustar_srf(nsrf))
-      CALL histdef2d(iff, o_u10m_srf(nsrf))
-      CALL histdef2d(iff, o_evap_srf(nsrf))
-      CALL histdef2d(iff, o_v10m_srf(nsrf))
-      CALL histdef2d(iff, o_t2m_srf(nsrf))
-      CALL histdef2d(iff, o_sens_srf(nsrf))
-      CALL histdef2d(iff, o_lat_srf(nsrf))
-      CALL histdef2d(iff, o_flw_srf(nsrf))
-      CALL histdef2d(iff, o_fsw_srf(nsrf))
-      CALL histdef2d(iff, o_wbils_srf(nsrf))
-      CALL histdef2d(iff, o_wbilo_srf(nsrf))
-      IF (iflag_pbl>1 ) then
-            CALL histdef2d(iff, o_tke_srf(nsrf))
-            CALL histdef2d(iff, o_tke_max_srf(nsrf))
-      ENDIF
-
-      CALL histdef2d(iff, o_albe_srf(nsrf))
-      CALL histdef2d(iff, o_rugs_srf(nsrf))
-      CALL histdef2d(iff, o_ages_srf(nsrf))
-    END DO
-
-    IF (new_aod .AND. (.NOT. aerosol_couple)) THEN
-      IF (ok_ade.OR.ok_aie) THEN
-          CALL histdef2d(iff,o_od550aer)
-          CALL histdef2d(iff,o_od865aer)
-          CALL histdef2d(iff,o_absvisaer)
-          CALL histdef2d(iff,o_od550lt1aer)
-          CALL histdef2d(iff,o_sconcso4)
-          CALL histdef2d(iff,o_sconcoa)
-          CALL histdef2d(iff,o_sconcbc)
-          CALL histdef2d(iff,o_sconcss)
-          CALL histdef2d(iff,o_sconcdust)
-          CALL histdef3d(iff,o_concso4)
-          CALL histdef3d(iff,o_concoa)
-          CALL histdef3d(iff,o_concbc)
-          CALL histdef3d(iff,o_concss)
-          CALL histdef3d(iff,o_concdust)
-          CALL histdef2d(iff,o_loadso4)
-          CALL histdef2d(iff,o_loadoa)
-          CALL histdef2d(iff,o_loadbc)
-          CALL histdef2d(iff,o_loadss)
-          CALL histdef2d(iff,o_loaddust)
-!--STRAT AER
-      ENDIF
-      IF (ok_ade.OR.ok_aie.OR.flag_aerosol_strat) THEN
-        DO naero = 1, naero_spc
-          CALL histdef2d(iff, o_tausumaero(naero))
-        END DO
-      ENDIF
-    ENDIF
-
-    IF (ok_ade) THEN
-      CALL histdef2d(iff,o_topswad)
-      CALL histdef2d(iff,o_topswad0)
-      CALL histdef2d(iff,o_solswad)
-      CALL histdef2d(iff,o_solswad0)
-      CALL histdef2d(iff,o_swtoaas_nat)
-      CALL histdef2d(iff,o_swsrfas_nat)
-      CALL histdef2d(iff,o_swtoacs_nat)
-      CALL histdef2d(iff,o_swsrfcs_nat)
-      CALL histdef2d(iff,o_swtoaas_ant)
-      CALL histdef2d(iff,o_swsrfas_ant)
-      CALL histdef2d(iff,o_swtoacs_ant)
-      CALL histdef2d(iff,o_swsrfcs_ant)
-
-      IF (.NOT. aerosol_couple) THEN 
-            CALL histdef2d(iff,o_swtoacf_nat)
-            CALL histdef2d(iff,o_swsrfcf_nat)
-            CALL histdef2d(iff,o_swtoacf_ant)
-            CALL histdef2d(iff,o_swsrfcf_ant)
-            CALL histdef2d(iff,o_swtoacf_zero)
-            CALL histdef2d(iff,o_swsrfcf_zero)
-      ENDIF
-    ENDIF
-
-    IF (ok_aie) THEN
-      CALL histdef2d(iff,o_topswai)
-      CALL histdef2d(iff,o_solswai)
-                  !Cloud droplet number concentration
-      CALL histdef3d(iff,o_scdnc)
-      CALL histdef2d(iff,o_cldncl)
-      CALL histdef3d(iff,o_reffclws)
-      CALL histdef3d(iff,o_reffclwc)
-      CALL histdef2d(iff,o_cldnvi)
-      CALL histdef3d(iff,o_lcc3d)
-      CALL histdef3d(iff,o_lcc3dcon)
-      CALL histdef3d(iff,o_lcc3dstra)
-      CALL histdef2d(iff,o_lcc)
-      CALL histdef2d(iff,o_reffclwtop)
-    ENDIF
-    CALL histdef2d(iff,o_alb1)
-    CALL histdef2d(iff,o_alb2)
-    CALL histdef2d(iff,o_cdrm)
-    CALL histdef2d(iff,o_cdrh)
-    CALL histdef2d(iff,o_cldl)
-    CALL histdef2d(iff,o_cldm)
-    CALL histdef2d(iff,o_cldh)
-    CALL histdef2d(iff,o_cldt)
-    CALL histdef2d(iff,o_cldq)
-    CALL histdef2d(iff,o_lwp)
-    CALL histdef2d(iff,o_iwp)
-    CALL histdef2d(iff,o_ue)
-    CALL histdef2d(iff,o_ve)
-    CALL histdef2d(iff,o_uq)
-    CALL histdef2d(iff,o_vq)
-
-    IF(iflag_con.GE.3) THEN ! sb
-      CALL histdef2d(iff,o_cape)
-      CALL histdef2d(iff,o_pbase)
-      CALL histdef2d(iff,o_ptop)
-      CALL histdef2d(iff,o_fbase)
-      IF (iflag_con /= 30) THEN
-            CALL histdef2d(iff,o_plcl)
-            CALL histdef2d(iff,o_plfc)
-            CALL histdef2d(iff,o_wbeff)
-      ENDIF
-      CALL histdef2d(iff,o_cape_max)
-      CALL histdef3d(iff,o_upwd)
-      CALL histdef3d(iff,o_Ma)
-      CALL histdef3d(iff,o_dnwd)
-      CALL histdef3d(iff,o_dnwd0)
-      CALL histdef3d(iff,o_mc)
-      CALL histdef2d(iff,o_ftime_con)
-    ENDIF !iflag_con .GE. 3
-    CALL histdef2d(iff,o_prw)
-    CALL histdef2d(iff,o_s_pblh)
-    CALL histdef2d(iff,o_s_pblt)
-    CALL histdef2d(iff,o_s_lcl)
-    CALL histdef2d(iff,o_s_therm)
-          !IM : Les champs suivants (s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
-          !CALL histdef2d(iff, &
-          !o_s_capCL%flag,o_s_capCL%name, "Conv avlbl pot enerfor ABL", "J/m2" )
-          !CALL histdef2d(iff, &
-          !o_s_oliqCL%flag,o_s_oliqCL%name, "Liq Water in BL", "kg/m2")
-          !CALL histdef2d(iff, &
-          !o_s_cteiCL%flag,o_s_cteiCL%name, "Instability criteria(ABL)", "K")
-          !CALL histdef2d(iff, &
-          !o_s_trmb1%flag,o_s_trmb1%name, "deep_cape(HBTM2)", "J/m2")
-          !CALL histdef2d(iff, &
-          !o_s_trmb2%flag,o_s_trmb2%name, "inhibition (HBTM2)", "J/m2")
-          !CALL histdef2d(iff, &
-          !o_s_trmb3%flag,o_s_trmb3%name, "Point Omega (HBTM2)", "m")
-
-          ! Champs interpolles sur des niveaux de pression
-
-          ! Attention a reverifier
-
-    ilev=0        
-    DO k=1, nlevSTD
-      bb2=clevSTD(k)
-      IF(bb2.EQ."850".OR.bb2.EQ."700".OR.bb2.EQ."500".OR.bb2.EQ."200" &
-                  .OR.bb2.EQ."100".OR.bb2.EQ."50".OR.bb2.EQ."10")THEN
-            ilev=ilev+1
-            !     print*,'ilev k bb2 flag name ',ilev,k, bb2,o_uSTDlevs(ilev)%flag,o_uSTDlevs(ilev)%name
-            CALL histdef2d(iff,o_uSTDlevs(ilev))
-            CALL histdef2d(iff,o_vSTDlevs(ilev))
-            CALL histdef2d(iff,o_wSTDlevs(ilev))
-            CALL histdef2d(iff,o_zSTDlevs(ilev))
-            CALL histdef2d(iff,o_qSTDlevs(ilev))
-            CALL histdef2d(iff,o_tSTDlevs(ilev))
-      ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR."500".OR.bb2.EQ."200".OR.bb2.EQ."50".OR.bb2.EQ."10")
-    ENDDO
-
-    CALL histdef2d(iff,o_t_oce_sic)
-
-    IF (type_ocean=='slab') THEN
-      CALL histdef2d(iff,o_slab_bils)
-    ENDIF
-
-    ! Couplage conv-CL
-    IF (iflag_con.GE.3) THEN
-      IF (iflag_coupl>=1) THEN
-            CALL histdef2d(iff,o_ale_bl)
-            CALL histdef2d(iff,o_alp_bl)
-      ENDIF
-    ENDIF !(iflag_con.GE.3)
-
-    CALL histdef2d(iff,o_weakinv)
-    CALL histdef2d(iff,o_dthmin)
-
-    CALL histdef2d(iff,o_rh2m)
-    CALL histdef2d(iff,o_rh2m_min)
-    CALL histdef2d(iff,o_rh2m_max)
-
-    CALL histdef2d(iff,o_qsat2m)
-    CALL histdef2d(iff,o_tpot)
-    CALL histdef2d(iff,o_tpote)
-    CALL histdef2d(iff,o_SWnetOR)
-    CALL histdef2d(iff,o_SWdownOR)
-    CALL histdef2d(iff,o_LWdownOR)
-    CALL histdef2d(iff,o_snowl)
-    CALL histdef2d(iff,o_solldown)
-    CALL histdef2d(iff,o_dtsvdfo)
-    CALL histdef2d(iff,o_dtsvdft)
-    CALL histdef2d(iff,o_dtsvdfg)
-    CALL histdef2d(iff,o_dtsvdfi)
-    CALL histdef2d(iff,o_rugs)
-
-          ! Champs 3D:
-    CALL histdef3d(iff,o_ec550aer)
-    CALL histdef3d(iff,o_lwcon)
-    CALL histdef3d(iff,o_iwcon)
-    CALL histdef3d(iff,o_temp)
-    CALL histdef3d(iff,o_theta)
-    CALL histdef3d(iff,o_ovap)
-    CALL histdef3d(iff,o_oliq)
-    CALL histdef3d(iff,o_ovapinit)
-    CALL histdef3d(iff,o_geop)
-    CALL histdef3d(iff,o_vitu)
-    CALL histdef3d(iff,o_vitv)
-    CALL histdef3d(iff,o_vitw)
-    CALL histdef3d(iff,o_pres)
-    CALL histdef3d(iff,o_paprs)
-    CALL histdef3d(iff,o_mass)
-    CALL histdef3d(iff,o_zfull)
-    CALL histdef3d(iff,o_zhalf)
-    CALL histdef3d(iff,o_rneb)
-    CALL histdef3d(iff,o_rnebcon)
-    CALL histdef3d(iff,o_rnebls)
-    CALL histdef3d(iff,o_rhum)
-    CALL histdef3d(iff,o_ozone)
-
-    IF (read_climoz == 2) THEN
-      CALL histdef3d(iff,o_ozone_light)
-    END IF
-
-    CALL histdef3d(iff,o_dtphy)
-    CALL histdef3d(iff,o_dqphy)
-    CALL histdef3d(iff,o_cldtau)
-    CALL histdef3d(iff,o_cldemi)
-!IM: bug ?? dimensionnement variables (klon,klev+1) pmflxr, pmflxs, prfl, psfl
-    CALL histdef3d(iff,o_pr_con_l)
-    CALL histdef3d(iff,o_pr_con_i)
-    CALL histdef3d(iff,o_pr_lsc_l)
-    CALL histdef3d(iff,o_pr_lsc_i)
-!Cloud droplet effective radius
-    CALL histdef3d(iff,o_re)
-    CALL histdef3d(iff,o_fl)
-!FH Sorties pour la couche limite
-    IF (iflag_pbl>1) THEN
-      CALL histdef3d(iff,o_tke)
-      CALL histdef3d(iff,o_tke_max)
-    ENDIF
-    CALL histdef3d(iff,o_kz)
-    CALL histdef3d(iff,o_kz_max)
-    CALL histdef3d(iff,o_clwcon)
-    CALL histdef3d(iff,o_dtdyn)
-    CALL histdef3d(iff,o_dqdyn)
-    CALL histdef3d(iff,o_dudyn)
-    CALL histdef3d(iff,o_dvdyn)
-    CALL histdef3d(iff,o_dtcon)
-    CALL histdef3d(iff,o_ducon)
-    CALL histdef3d(iff,o_dvcon)
-    CALL histdef3d(iff,o_dqcon)
-
-! Wakes
-    IF(iflag_con.EQ.3) THEN
-      IF (iflag_wake >= 1) THEN
-            CALL histdef2d(iff,o_ale_wk)
-            CALL histdef2d(iff,o_alp_wk)
-            CALL histdef2d(iff,o_ale)
-            CALL histdef2d(iff,o_alp)
-            CALL histdef2d(iff,o_cin)
-            CALL histdef2d(iff,o_wape)
-            CALL histdef2d(iff,o_wake_h)
-            CALL histdef2d(iff,o_wake_s)
-            CALL histdef3d(iff,o_dtwak)
-            CALL histdef3d(iff,o_dqwak)
-            CALL histdef3d(iff,o_wake_deltat)
-            CALL histdef3d(iff,o_wake_deltaq)
-            CALL histdef3d(iff,o_wake_omg)
-      ENDIF
-!!! RomP             CALL histdef3d(iff,o_Vprecip%flag,o_Vprecip%name, "precipitation vertical profile", "-")
-      CALL histdef3d(iff,o_ftd)
-      CALL histdef3d(iff,o_fqd)
-    ENDIF !(iflag_con.EQ.3)
-
-    IF(iflag_con.GE.3) THEN   !  RomP >>>
-      CALL histdef3d(iff,o_wdtrainA)
-      CALL histdef3d(iff,o_wdtrainM)
-      CALL histdef3d(iff,o_Vprecip)
-    ENDIF !(iflag_con.GE.3)   ! <<< RomP
-
-!!! nrlmd le 10/04/2012
-
-    IF (iflag_trig_bl>=1) THEN
-      CALL histdef2d(iff,o_n2)
-      CALL histdef2d(iff,o_s2)
-      CALL histdef2d(iff,o_proba_notrig)
-      CALL histdef2d(iff,o_random_notrig)
-      CALL histdef2d(iff,o_ale_bl_trig)
-      CALL histdef2d(iff,o_ale_bl_stat)
-    ENDIF  !(iflag_trig_bl>=1)
-
-    IF (iflag_clos_bl>=1) THEN
-      CALL histdef2d(iff,o_alp_bl_det)
-      CALL histdef2d(iff,o_alp_bl_fluct_m)
-      CALL histdef2d(iff,o_alp_bl_fluct_tke)
-      CALL histdef2d(iff,o_alp_bl_conv)
-      CALL histdef2d(iff,o_alp_bl_stat)
-    ENDIF  !(iflag_clos_bl>=1)
-
-!!! fin nrlmd le 10/04/2012
-    CALL histdef3d(iff,o_dtlsc)
-    CALL histdef3d(iff,o_dtlschr)
-    CALL histdef3d(iff,o_dqlsc)
-    CALL histdef3d(iff,o_beta_prec)
-    CALL histdef3d(iff,o_dtvdf)
-    CALL histdef3d(iff,o_dtdis)
-    CALL histdef3d(iff,o_dqvdf)
-    CALL histdef3d(iff,o_dteva)
-    CALL histdef3d(iff,o_dqeva)
-    CALL histdef3d(iff,o_ptconv)
-    CALL histdef3d(iff,o_ratqs)
-    CALL histdef3d(iff,o_dtthe)
-
-    IF (iflag_thermals.ge.1) THEN
-      CALL histdef3d(iff,o_dqlscth)
-      CALL histdef3d(iff,o_dqlscst)
-      CALL histdef3d(iff,o_dtlscth)
-      CALL histdef3d(iff,o_dtlscst)
-      CALL histdef2d(iff,o_plulth)
-      CALL histdef2d(iff,o_plulst)
-      CALL histdef2d(iff,o_lmaxth)
-      CALL histdef3d(iff,o_ptconvth)
-      CALL histdef3d(iff,o_f_th)
-      CALL histdef3d(iff,o_e_th)
-      CALL histdef3d(iff,o_w_th)
-      CALL histdef3d(iff,o_lambda_th)
-      CALL histdef2d(iff,o_ftime_th)
-      CALL histdef3d(iff,o_q_th)
-      CALL histdef3d(iff,o_a_th)
-      CALL histdef3d(iff,o_d_th)
-      CALL histdef2d(iff,o_f0_th)
-      CALL histdef2d(iff,o_zmax_th)
-      CALL histdef3d(iff,o_dqthe)
-    ENDIF !iflag_thermals.ge.1
-
-    CALL histdef3d(iff,o_dtajs)
-    CALL histdef3d(iff,o_dqajs)
-    CALL histdef3d(iff,o_dtswr)
-    CALL histdef3d(iff,o_dtsw0)
-    CALL histdef3d(iff,o_dtlwr)
-    CALL histdef3d(iff,o_dtlw0)
-    CALL histdef3d(iff,o_dtec)
-    CALL histdef3d(iff,o_duvdf)
-    CALL histdef3d(iff,o_dvvdf)
-
-    IF (ok_orodr) THEN
-      CALL histdef3d(iff,o_duoro)
-      CALL histdef3d(iff,o_dvoro)
-      CALL histdef3d(iff,o_dtoro)
-    ENDIF
-
-    IF (ok_orolf) THEN
-      CALL histdef3d(iff,o_dulif)
-      CALL histdef3d(iff,o_dvlif)
-      CALL histdef3d(iff,o_dtlif)
-    ENDIF
-
-    IF (ok_hines) then
-      CALL histdef3d(iff,o_duhin)
-      CALL histdef3d(iff,o_dvhin)
-      CALL histdef3d(iff,o_dthin)
-    ENDIF
-
-    CALL histdef3d(iff,o_rsu)
-    CALL histdef3d(iff,o_rsd)
-    CALL histdef3d(iff,o_rlu)
-    CALL histdef3d(iff,o_rld)
-    CALL histdef3d(iff,o_rsucs)
-    CALL histdef3d(iff,o_rsdcs)
-    CALL histdef3d(iff,o_rlucs)
-    CALL histdef3d(iff,o_rldcs)
-    CALL histdef3d(iff,o_tnt)
-    CALL histdef3d(iff,o_tntc)
-    CALL histdef3d(iff,o_tntr)
-    CALL histdef3d(iff,o_tntscpbl)
-    CALL histdef3d(iff,o_tnhus)
-    CALL histdef3d(iff,o_tnhusc)
-    CALL histdef3d(iff,o_tnhusscpbl)
-    CALL histdef3d(iff,o_evu)
-    CALL histdef3d(iff,o_h2o)
-    CALL histdef3d(iff,o_mcd)
-    CALL histdef3d(iff,o_dmc)
-    CALL histdef3d(iff,o_ref_liq)
-    CALL histdef3d(iff,o_ref_ice)
-
-    IF (RCO2_per.NE.RCO2_act.OR.RCH4_per.NE.RCH4_act.OR. &
-               RN2O_per.NE.RN2O_act.OR.RCFC11_per.NE.RCFC11_act.OR. &
-               RCFC12_per.NE.RCFC12_act) THEN
-      CALL histdef2d(iff,o_rsut4co2)
-      CALL histdef2d(iff,o_rlut4co2)
-      CALL histdef2d(iff,o_rsutcs4co2)
-      CALL histdef2d(iff,o_rlutcs4co2)
-      CALL histdef3d(iff,o_rsu4co2)
-      CALL histdef3d(iff,o_rlu4co2)
-      CALL histdef3d(iff,o_rsucs4co2)
-      CALL histdef3d(iff,o_rlucs4co2)
-      CALL histdef3d(iff,o_rsd4co2)
-      CALL histdef3d(iff,o_rld4co2)
-      CALL histdef3d(iff,o_rsdcs4co2)
-      CALL histdef3d(iff,o_rldcs4co2)
-
-    ENDIF
-
+          else
+             CALL histvert(nid_files(iff), "plev", "pressure", "Pa", &
+               levmax(iff) - levmin(iff) + 1, &
+              rlevSTD(levmin(iff):levmax(iff)), nvertm(iff), "down")
+          endif
+#endif
 
       IF (nqtot>=3) THEN
             DO iq=3,nqtot  
             iiq=niadv(iq)
-            o_trac(iq-2) = ctrl_out((/ 4, 5, 1, 1, 1, 10 /),tname(iiq),'Tracer '//ttext(iiq), "-",&
-                  (/ '', '', '', '', '', '' /))
-            CALL histdef3d(iff, o_trac(iq-2))
-            o_trac_cum(iq-2) = ctrl_out((/ 3, 4, 10, 10, 10, 10 /),'cum'//tname(iiq),&
-                  'Cumulated tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /))
-            CALL histdef2d(iff, o_trac_cum(iq-2))
+            o_trac(iq-2) = ctrl_out((/ 4, 5, 1, 1, 1, 10, 11, 11, 11 /), &
+                           tname(iiq),'Tracer '//ttext(iiq), "-",  &
+                           (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_vdf(iq-2) = ctrl_out((/ 5, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                              'd'//trim(tname(iq))//'_vdf',  &
+                              'Tendance tracer '//ttext(iiq), "-" , &
+                              (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_the(iq-2) = ctrl_out((/ 5, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                              'd'//trim(tname(iq))//'_the', &
+                              'Tendance tracer '//ttext(iiq), "-", &
+                              (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_con(iq-2) = ctrl_out((/ 5, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                              'd'//trim(tname(iq))//'_con', &
+                              'Tendance tracer '//ttext(iiq), "-", &
+                              (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_lessi_impa(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                                     'd'//trim(tname(iq))//'_lessi_impa', &
+                                     'Tendance tracer '//ttext(iiq), "-", &
+                                     (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_lessi_nucl(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                                     'd'//trim(tname(iq))//'_lessi_nucl', &
+                                     'Tendance tracer '//ttext(iiq), "-", &
+                                     (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_insc(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                               'd'//trim(tname(iq))//'_insc', &
+                               'Tendance tracer '//ttext(iiq), "-", &
+                               (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_bcscav(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                                 'd'//trim(tname(iq))//'_bcscav', &
+                                 'Tendance tracer '//ttext(iiq), "-", &
+                                 (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_evapls(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                                 'd'//trim(tname(iq))//'_evapls', &
+                                 'Tendance tracer '//ttext(iiq), "-", &
+                                 (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_ls(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                             'd'//trim(tname(iq))//'_ls', &
+                             'Tendance tracer '//ttext(iiq), "-", &
+                             (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_trsp(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                               'd'//trim(tname(iq))//'_trsp', &
+                               'Tendance tracer '//ttext(iiq), "-", &
+                               (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_sscav(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                                'd'//trim(tname(iq))//'_sscav', &
+                                'Tendance tracer '//ttext(iiq), "-", &
+                                (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_sat(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                               'd'//trim(tname(iq))//'_sat', &
+                               'Tendance tracer '//ttext(iiq), "-", &
+                               (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_uscav(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                                'd'//trim(tname(iq))//'_uscav', &
+                                'Tendance tracer '//ttext(iiq), "-", &
+                                 (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_dtr_dry(iq-2) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11 /), &
+                              'cum'//'d'//trim(tname(iq))//'_dry', &
+                              'tracer tendency dry deposition'//ttext(iiq), "-", &
+                              (/ '', '', '', '', '', '', '', '', '' /))
+
+            o_trac_cum(iq-2) = ctrl_out((/ 3, 4, 10, 10, 10, 10, 11, 11, 11 /), &
+                               'cum'//tname(iiq),&
+                               'Cumulated tracer '//ttext(iiq), "-", &
+                               (/ '', '', '', '', '', '', '', '', '' /))
             ENDDO
       ENDIF
-
-      CALL histend(nid_files(iff))
-
-      ndex2d = 0
-      ndex3d = 0
 
     ENDIF ! clef_files
@@ -837,4 +477,7 @@
     ecrit_LES = ecrit_files(5)
     ecrit_ins = ecrit_files(6)
+    freq_outNMC(1) = ecrit_files(7)*86400.
+    freq_outNMC(2) = ecrit_files(8)*86400.
+    freq_outNMC(3) = ecrit_files(9)*86400.
 
     WRITE(lunout,*)'swaero_diag=',swaero_diag
@@ -842,248 +485,5 @@
   end SUBROUTINE phys_output_open
 
-  SUBROUTINE histdef2d_old (iff,lpoint,flag_var,nomvar,titrevar,unitvar)
-
-    USE ioipsl
-    USE dimphy
-    USE mod_phys_lmdz_para
-    USE iophy
-
-    IMPLICIT NONE
-
-    INCLUDE "dimensions.h"
-    INCLUDE "temps.h"
-    INCLUDE "clesphys.h"
-
-    INTEGER                          :: iff
-    LOGICAL                          :: lpoint
-    INTEGER, DIMENSION(nfiles)       :: flag_var
-    CHARACTER(LEN=20)                 :: nomvar
-    CHARACTER(LEN=*)                 :: titrevar
-    CHARACTER(LEN=*)                 :: unitvar
-
-    REAL zstophym
-
-    IF (type_ecri(iff)=='inst(X)'.OR.type_ecri(iff)=='once') THEN
-       zstophym=zoutm(iff)
-    ELSE
-       zstophym=zdtime
-    ENDIF
-
-    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
-    CALL conf_physoutputs(nomvar,flag_var)
-
-    IF(.NOT.lpoint) THEN  
-       IF ( flag_var(iff)<=lev_files(iff) ) THEN
-          CALL histdef (nid_files(iff),nomvar,titrevar,unitvar, &
-               iim,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
-               type_ecri(iff), zstophym,zoutm(iff))                
-       ENDIF
-    ELSE
-       IF ( flag_var(iff)<=lev_files(iff) ) THEN
-          CALL histdef (nid_files(iff),nomvar,titrevar,unitvar, &
-               npstn,1,nhorim(iff), 1,1,1, -99, 32, &
-               type_ecri(iff), zstophym,zoutm(iff))                
-       ENDIF
-    ENDIF
-
-    ! Set swaero_diag=true if at least one of the concerned variables are defined 
-    IF (nomvar=='topswad' .OR. nomvar=='topswai' .OR. nomvar=='solswad' .OR. nomvar=='solswai' ) THEN
-       IF  ( flag_var(iff)<=lev_files(iff) ) THEN
-          swaero_diag=.TRUE.
-       END IF
-    END IF
-  END SUBROUTINE histdef2d_old
-
-  SUBROUTINE histdef2d (iff,var)
-
-    USE ioipsl
-    USE dimphy
-    USE mod_phys_lmdz_para
-    USE iophy
-
-    IMPLICIT NONE
-
-    INCLUDE "dimensions.h"
-    INCLUDE "temps.h"
-    INCLUDE "clesphys.h"
-
-    INTEGER                          :: iff
-    TYPE(ctrl_out)                   :: var
-
-    REAL zstophym
-    CHARACTER(LEN=20) :: typeecrit
-
-    ! ug On récupère le type écrit de la structure:
-    !       Assez moche, à refaire si meilleure méthode...
-    IF (INDEX(var%type_ecrit(iff), "once") > 0) THEN
-       typeecrit = 'once'
-    ELSE IF(INDEX(var%type_ecrit(iff), "t_min") > 0) THEN
-       typeecrit = 't_min(X)'
-    ELSE IF(INDEX(var%type_ecrit(iff), "t_max") > 0) THEN
-       typeecrit = 't_max(X)'
-    ELSE IF(INDEX(var%type_ecrit(iff), "inst") > 0) THEN
-       typeecrit = 'inst(X)'
-    ELSE
-       typeecrit = type_ecri_files(iff)
-    ENDIF
-
-    IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN
-       zstophym=zoutm(iff)
-    ELSE
-       zstophym=zdtime
-    ENDIF
-
-    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
-    CALL conf_physoutputs(var%name, var%flag)
-
-    IF(.NOT.clef_stations(iff)) THEN  
-       IF ( var%flag(iff)<=lev_files(iff) ) THEN
-          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
-               iim,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
-               typeecrit, zstophym,zoutm(iff))                
-       ENDIF
-    ELSE
-       IF ( var%flag(iff)<=lev_files(iff)) THEN
-          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
-               npstn,1,nhorim(iff), 1,1,1, -99, 32, &
-               typeecrit, zstophym,zoutm(iff))                
-       ENDIF
-    ENDIF
-
-    ! Set swaero_diag=true if at least one of the concerned variables are defined 
-    IF (var%name=='topswad' .OR. var%name=='topswai' .OR. var%name=='solswad' .OR. var%name=='solswai' ) THEN
-       IF  ( var%flag(iff)<=lev_files(iff) ) THEN
-          swaero_diag=.TRUE.
-       END IF
-    END IF
-  END SUBROUTINE histdef2d
-
-  SUBROUTINE histdef3d_old (iff,lpoint,flag_var,nomvar,titrevar,unitvar)
-
-    USE ioipsl
-    USE dimphy
-    USE mod_phys_lmdz_para
-    USE iophy
-
-    IMPLICIT NONE
-
-    INCLUDE "dimensions.h"
-    INCLUDE "temps.h"
-!    INCLUDE "indicesol.h"
-    INCLUDE "clesphys.h"
-
-    INTEGER                          :: iff
-    LOGICAL                          :: lpoint
-    INTEGER, DIMENSION(nfiles)       :: flag_var
-    CHARACTER(LEN=20)                 :: nomvar
-    CHARACTER(LEN=*)                 :: titrevar
-    CHARACTER(LEN=*)                 :: unitvar
-
-    REAL zstophym
-
-    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
-    CALL conf_physoutputs(nomvar,flag_var)
-
-    IF (type_ecri(iff)=='inst(X)'.OR.type_ecri(iff)=='once') THEN
-       zstophym=zoutm(iff)
-    ELSE
-       zstophym=zdtime
-    ENDIF
-
-    IF(.NOT.lpoint) THEN
-       IF ( flag_var(iff)<=lev_files(iff) ) THEN
-          CALL histdef (nid_files(iff), nomvar, titrevar, unitvar, &
-               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
-               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, type_ecri(iff), &
-               zstophym, zoutm(iff))
-       ENDIF
-    ELSE
-       IF ( flag_var(iff)<=lev_files(iff) ) THEN
-          CALL histdef (nid_files(iff), nomvar, titrevar, unitvar, &
-               npstn,1,nhorim(iff), klev, levmin(iff), &
-               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, &
-               type_ecri(iff), zstophym,zoutm(iff))
-       ENDIF
-    ENDIF
-  END SUBROUTINE histdef3d_old
-
-  SUBROUTINE histdef3d (iff,var)
-
-    USE ioipsl
-    USE dimphy
-    USE mod_phys_lmdz_para
-    USE iophy
-
-    IMPLICIT NONE
-
-    INCLUDE "dimensions.h"
-    INCLUDE "temps.h"
-    INCLUDE "clesphys.h"
-
-    INTEGER                          :: iff
-    TYPE(ctrl_out)                   :: var
-
-    REAL zstophym
-    CHARACTER(LEN=20) :: typeecrit
-
-    ! ug On récupère le type écrit de la structure:
-    !       Assez moche, à refaire si meilleure méthode...
-    IF (INDEX(var%type_ecrit(iff), "once") > 0) THEN
-       typeecrit = 'once'
-    ELSE IF(INDEX(var%type_ecrit(iff), "t_min") > 0) THEN
-       typeecrit = 't_min(X)'
-    ELSE IF(INDEX(var%type_ecrit(iff), "t_max") > 0) THEN
-       typeecrit = 't_max(X)'
-    ELSE IF(INDEX(var%type_ecrit(iff), "inst") > 0) THEN
-       typeecrit = 'inst(X)'
-    ELSE
-       typeecrit = type_ecri_files(iff)
-    ENDIF
-
-
-    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
-    CALL conf_physoutputs(var%name,var%flag)
-
-    IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN
-       zstophym=zoutm(iff)
-    ELSE
-       zstophym=zdtime
-    ENDIF
-
-    IF(.NOT.clef_stations(iff)) THEN
-       IF ( var%flag(iff)<=lev_files(iff) ) THEN
-          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
-               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
-               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, typeecrit, &
-               zstophym, zoutm(iff))
-       ENDIF
-    ELSE
-       IF ( var%flag(iff)<=lev_files(iff)) THEN
-          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
-               npstn,1,nhorim(iff), klev, levmin(iff), &
-               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, &
-               typeecrit, zstophym,zoutm(iff))
-       ENDIF
-    ENDIF
-  END SUBROUTINE histdef3d
-
-  SUBROUTINE conf_physoutputs(nam_var,flag_var)
-!!! Lecture des noms et niveau de sortie des variables dans output.def
-    !   en utilisant les routines getin de IOIPSL  
-    use ioipsl
-
-    IMPLICIT NONE
-
-    include 'iniprint.h'
-
-    CHARACTER(LEN=20)                :: nam_var
-    INTEGER, DIMENSION(nfiles)      :: flag_var
-
-    IF(prt_level>10) WRITE(lunout,*)'Avant getin: nam_var flag_var ',nam_var,flag_var(:)
-    CALL getin('flag_'//nam_var,flag_var)
-    CALL getin('name_'//nam_var,nam_var)
-    IF(prt_level>10) WRITE(lunout,*)'Apres getin: nam_var flag_var ',nam_var,flag_var(:)
-
-  END SUBROUTINE conf_physoutputs
+
 
   SUBROUTINE convers_timesteps(str,dtime,timestep)
Index: LMDZ5/branches/testing/libf/phylmd/phys_output_var_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phys_output_var_mod.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/phys_output_var_mod.F90	(revision 1864)
@@ -25,5 +25,5 @@
 
 ! ug Plein de variables venues de phys_output_mod
-      INTEGER, PARAMETER                           :: nfiles = 6
+      INTEGER, PARAMETER                           :: nfiles = 9
       LOGICAL, DIMENSION(nfiles), SAVE             :: clef_files
       LOGICAL, DIMENSION(nfiles), SAVE             :: clef_stations
@@ -41,4 +41,6 @@
       CHARACTER(LEN=20), DIMENSION(nfiles), SAVE  :: type_ecri_files, phys_out_filetypes
 !$OMP THREADPRIVATE(type_ecri_files, phys_out_filetypes)
+    CHARACTER(LEN=20), DIMENSION(nfiles), SAVE  :: phys_out_filenames
+!$OMP THREADPRIVATE(phys_out_filenames)
 
  ! swaero_diag : flag indicates if it is necessary to do calculation for some aerosol diagnostics
@@ -49,4 +51,9 @@
       INTEGER, SAVE:: levmax(nfiles)
 !$OMP THREADPRIVATE(levmin, levmax)
+
+      REAL, SAVE                :: zdtime_moy
+!$OMP THREADPRIVATE(zdtime_moy)
+
+      LOGICAL, SAVE :: vars_defined = .FALSE. ! ug PAS THREADPRIVATE ET C'EST NORMAL
 
   TYPE ctrl_out
Index: LMDZ5/branches/testing/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phys_output_write_mod.F90	(revision 1864)
+++ LMDZ5/branches/testing/libf/phylmd/phys_output_write_mod.F90	(revision 1864)
@@ -0,0 +1,1108 @@
+!
+! $Header$
+!
+MODULE phys_output_write_mod
+
+    USE phytrac_mod, ONLY : d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
+        d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
+        d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav
+
+
+! Author: Abderrahmane IDELKADI (original include file)
+! Author: Laurent FAIRHEAD (transformation to module/subroutine)
+! Author: Ulysse GERARD (effective implementation)
+
+
+   CONTAINS 
+     
+! ug Routine pour définir (los du premier passageà) ET sortir les variables
+    SUBROUTINE phys_output_write(itap, pdtphys, paprs, pphis, &
+   &                  pplay, lmax_th, aerosol_couple,         &
+   &                  ok_ade, ok_aie, ivap, new_aod, ok_sync, &
+   &                  ptconv, read_climoz, clevSTD, freq_moyNMC, ptconvth, &
+   &                  d_t, qx, d_qx, zmasse, flag_aerosol_strat)
+
+! This subroutine does the actual writing of diagnostics that were
+! defined and initialised in phys_output_mod.F90
+
+    USE dimphy
+    USE control_mod
+    USE phys_output_ctrlout_mod 
+    USE phys_state_var_mod
+    USE phys_local_var_mod
+    USE indice_sol_mod
+    USE infotrac
+    USE comgeomphy
+    USE surface_data,     ONLY : type_ocean, ok_veget
+    USE aero_mod
+    USE ioipsl
+    USE write_field_phy
+    USE iophy
+    USE mod_phys_lmdz_para
+    USE netcdf,  ONLY : nf90_fill_real
+
+#ifdef CPP_XIOS
+    ! ug Pour les sorties XIOS
+	USE wxios
+    USE xios
+#endif
+
+    IMPLICIT NONE
+
+    INCLUDE "temps.h"
+    INCLUDE "clesphys.h"
+    INCLUDE "thermcell.h"
+    INCLUDE "compbl.h"
+    INCLUDE "YOMCST.h"
+    INCLUDE "dimensions.h"
+
+! Input
+    INTEGER :: itap, ivap, read_climoz
+    INTEGER, DIMENSION(klon) :: lmax_th
+    LOGICAL :: aerosol_couple, ok_sync
+    LOGICAL :: ok_ade, ok_aie, new_aod
+    LOGICAL, DIMENSION(klon, klev) :: ptconv, ptconvth
+    REAL :: pdtphys
+    CHARACTER (LEN=4), DIMENSION(nlevSTD) :: clevSTD
+    REAL, DIMENSION(klon) :: pphis
+    REAL, DIMENSION(klon, klev) :: pplay, d_t
+    REAL, DIMENSION(klon, klev+1) :: paprs
+    REAL, DIMENSION(klon,klev,nqtot) :: qx, d_qx
+    REAL, DIMENSION(klon, llm) :: zmasse
+    LOGICAL :: flag_aerosol_strat
+    REAL, DIMENSION(3) :: freq_moyNMC
+
+! Local
+    INTEGER, PARAMETER :: jjmp1=jjm+1-1/jjm
+    INTEGER :: itau_w
+    INTEGER :: i, iinit, iinitend=1, iff, iq, nsrf, k, ll, naero
+    REAL, DIMENSION (klon) :: zx_tmp_fi2d
+    REAL, DIMENSION (klon,klev) :: zx_tmp_fi3d, zpt_conv
+    REAL, DIMENSION (klon,klev+1) :: zx_tmp_fi3d1
+    CHARACTER (LEN=4)              :: bb2
+    INTEGER, DIMENSION(iim*jjmp1)  :: ndex2d
+    INTEGER, DIMENSION(iim*jjmp1*klev) :: ndex3d
+    REAL, PARAMETER :: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
+    REAL, PARAMETER :: missing_val=nf90_fill_real
+
+     ! On calcul le nouveau tau:
+     itau_w = itau_phy + itap + start_time * day_step / iphysiq
+     ! On le donne à iophy pour que les histwrite y aient accès:
+     CALL set_itau_iophy(itau_w)
+    
+    IF(.NOT.vars_defined) THEN
+        iinitend = 2
+    ELSE
+        iinitend = 1
+    ENDIF
+    
+! ug la boucle qui suit ne sert qu'une fois, pour l'initialisation, sinon il n'y a toujours qu'un seul passage:
+DO iinit=1, iinitend
+#ifdef CPP_XIOS
+IF (vars_defined) THEN
+     CALL wxios_update_calendar(itau_w)
+END IF
+#endif
+! On procède à l'écriture ou à la définition des nombreuses variables:
+!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      CALL histwrite_phy(o_phis, pphis)
+      CALL histwrite_phy(o_aire, airephy)
+
+IF (vars_defined) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
+      ENDDO
+ENDIF
+
+      CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
+      CALL histwrite_phy(o_contfracOR, pctsrf(:,is_ter))
+      CALL histwrite_phy(o_aireTER, paire_ter)
+!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      CALL histwrite_phy(o_flat, zxfluxlat)
+      CALL histwrite_phy(o_slp, slp)
+      CALL histwrite_phy(o_tsol, zxtsol)
+      CALL histwrite_phy(o_t2m, zt2m)
+      CALL histwrite_phy(o_t2m_min, zt2m)
+      CALL histwrite_phy(o_t2m_max, zt2m)
+
+IF (vars_defined) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      DO i = 1, klon
+         zx_tmp_fi2d(i) = pctsrf(i,is_sic)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_sicf, zx_tmp_fi2d)
+      CALL histwrite_phy(o_q2m, zq2m)
+      CALL histwrite_phy(o_ustar, zustar)
+      CALL histwrite_phy(o_u10m, zu10m)
+      CALL histwrite_phy(o_v10m, zv10m)
+
+IF (vars_defined) THEN
+      DO i = 1, klon
+         zx_tmp_fi2d(i) = paprs(i,1)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_psol, zx_tmp_fi2d)
+      CALL histwrite_phy(o_mass, zmasse)
+      CALL histwrite_phy(o_qsurf, zxqsurf)
+
+IF (.NOT. ok_veget) THEN
+      CALL histwrite_phy(o_qsol, qsol)
+ENDIF
+
+IF (vars_defined) THEN
+       DO i = 1, klon
+         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
+       ENDDO
+ENDIF
+
+      CALL histwrite_phy(o_precip, zx_tmp_fi2d)
+      CALL histwrite_phy(o_ndayrain, nday_rain)
+
+IF (vars_defined) THEN
+       DO i = 1, klon
+         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
+       ENDDO
+ENDIF
+      CALL histwrite_phy(o_plul, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      DO i = 1, klon
+         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
+      CALL histwrite_phy(o_snow, snow_fall)
+      CALL histwrite_phy(o_msnow, snow_o)
+      CALL histwrite_phy(o_fsnow, zfra_o)
+      CALL histwrite_phy(o_evap, evap)
+      CALL histwrite_phy(o_tops, topsw)
+      CALL histwrite_phy(o_tops0, topsw0)
+      CALL histwrite_phy(o_topl, toplw)
+      CALL histwrite_phy(o_topl0, toplw0)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
+ENDIF
+      CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
+ENDIF
+      CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
+ENDIF
+      CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
+ENDIF
+      CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(:) = topsw(:)-toplw(:)
+ENDIF
+      CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
+      CALL histwrite_phy(o_SWup200, SWup200)
+      CALL histwrite_phy(o_SWup200clr, SWup200clr)
+      CALL histwrite_phy(o_SWdn200, SWdn200)
+      CALL histwrite_phy(o_SWdn200clr, SWdn200clr)
+      CALL histwrite_phy(o_LWup200, LWup200)
+      CALL histwrite_phy(o_LWup200clr, LWup200clr)
+      CALL histwrite_phy(o_LWdn200, LWdn200)
+      CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
+      CALL histwrite_phy(o_sols, solsw)
+      CALL histwrite_phy(o_sols0, solsw0)
+      CALL histwrite_phy(o_soll, sollw)
+      CALL histwrite_phy(o_radsol, radsol)
+      CALL histwrite_phy(o_soll0, sollw0)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
+ENDIF
+      CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
+ENDIF
+      CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
+ENDIF
+      CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
+ENDIF
+      CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
+ENDIF
+      CALL histwrite_phy(o_LWupSFC, zx_tmp_fi2d)
+      CALL histwrite_phy(o_LWdnSFC, sollwdown)
+
+IF (vars_defined) THEN
+       sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
+      zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
+ENDIF
+      CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
+      CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
+      CALL histwrite_phy(o_bils, bils)
+      CALL histwrite_phy(o_bils_diss, bils_diss)
+      CALL histwrite_phy(o_bils_ec, bils_ec)
+      CALL histwrite_phy(o_bils_tke, bils_tke)
+      CALL histwrite_phy(o_bils_kinetic, bils_kinetic)
+      CALL histwrite_phy(o_bils_latent, bils_latent)
+      CALL histwrite_phy(o_bils_enthalp, bils_enthalp)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
+ENDIF
+      CALL histwrite_phy(o_sens, zx_tmp_fi2d)
+      CALL histwrite_phy(o_fder, fder)
+      CALL histwrite_phy(o_ffonte, zxffonte)
+      CALL histwrite_phy(o_fqcalving, zxfqcalving)
+      CALL histwrite_phy(o_fqfonte, zxfqfonte)
+IF (vars_defined) THEN
+      zx_tmp_fi2d=0.
+      DO nsrf=1,nbsrf
+        zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxu(:,1,nsrf)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_taux, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      zx_tmp_fi2d=0.
+      DO nsrf=1,nbsrf
+          zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxv(:,1,nsrf)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
+
+
+         DO nsrf = 1, nbsrf
+IF (vars_defined)             zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
+      CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)           zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
+      CALL histwrite_phy(o_fract_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
+      CALL histwrite_phy(o_taux_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
+      CALL histwrite_phy(o_tauy_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
+      CALL histwrite_phy(o_tsol_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)         zx_tmp_fi2d(1 : klon) = evap_pot( 1 : klon, nsrf)
+      CALL histwrite_phy(o_evappot_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)       zx_tmp_fi2d(1 : klon) = ustar(1 : klon, nsrf)
+      CALL histwrite_phy(o_ustar_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
+      CALL histwrite_phy(o_u10m_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
+      CALL histwrite_phy(o_v10m_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
+      CALL histwrite_phy(o_t2m_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)       zx_tmp_fi2d(1 : klon) = fevap(1 : klon, nsrf)
+      CALL histwrite_phy(o_evap_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)        zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
+      CALL histwrite_phy(o_sens_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
+      CALL histwrite_phy(o_lat_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
+      CALL histwrite_phy(o_flw_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
+      CALL histwrite_phy(o_fsw_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
+      CALL histwrite_phy(o_wbils_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
+      CALL histwrite_phy(o_wbilo_srf(nsrf), zx_tmp_fi2d)
+
+      IF (iflag_pbl > 1) THEN
+      CALL histwrite_phy(o_tke_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
+      CALL histwrite_phy(o_tke_max_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
+      ENDIF
+
+      ENDDO
+      DO nsrf=1,nbsrf+1
+         CALL histwrite_phy(o_wstar(nsrf), wstar(1 : klon, nsrf))
+      ENDDO
+
+      CALL histwrite_phy(o_cdrm, cdragm)
+      CALL histwrite_phy(o_cdrh, cdragh)
+      CALL histwrite_phy(o_cldl, cldl)
+      CALL histwrite_phy(o_cldm, cldm)
+      CALL histwrite_phy(o_cldh, cldh)
+      CALL histwrite_phy(o_cldt, cldt)
+      CALL histwrite_phy(o_cldq, cldq)
+IF (vars_defined)       zx_tmp_fi2d(1:klon) = flwp(1:klon)
+      CALL histwrite_phy(o_lwp, zx_tmp_fi2d)
+IF (vars_defined)       zx_tmp_fi2d(1:klon) = fiwp(1:klon)
+      CALL histwrite_phy(o_iwp, zx_tmp_fi2d)
+      CALL histwrite_phy(o_ue, ue)
+      CALL histwrite_phy(o_ve, ve)
+      CALL histwrite_phy(o_uq, uq)
+      CALL histwrite_phy(o_vq, vq)
+      IF(iflag_con.GE.3) THEN ! sb
+      CALL histwrite_phy(o_cape, cape)
+      CALL histwrite_phy(o_pbase, ema_pcb)
+      CALL histwrite_phy(o_ptop, ema_pct)
+      CALL histwrite_phy(o_fbase, ema_cbmf)
+        if (iflag_con /= 30) then
+      CALL histwrite_phy(o_plcl, plcl)
+      CALL histwrite_phy(o_plfc, plfc)
+      CALL histwrite_phy(o_wbeff, wbeff)
+        end if
+
+      CALL histwrite_phy(o_cape_max, cape)
+
+      CALL histwrite_phy(o_upwd, upwd)
+      CALL histwrite_phy(o_Ma, Ma)
+      CALL histwrite_phy(o_dnwd, dnwd)
+      CALL histwrite_phy(o_dnwd0, dnwd0)
+IF (vars_defined)         zx_tmp_fi2d=float(itau_con)/float(itap)
+      CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
+IF (vars_defined) THEN
+      IF(iflag_thermals>=1)THEN
+         zx_tmp_fi3d=dnwd+dnwd0+upwd+fm_therm(:,1:klev)
+      ELSE
+         zx_tmp_fi3d=dnwd+dnwd0+upwd
+      ENDIF
+ENDIF
+      CALL histwrite_phy(o_mc, zx_tmp_fi3d)
+      ENDIF !iflag_con .GE. 3
+      CALL histwrite_phy(o_prw, prw)
+      CALL histwrite_phy(o_s_pblh, s_pblh)
+      CALL histwrite_phy(o_s_pblt, s_pblt)
+      CALL histwrite_phy(o_s_lcl, s_lcl)
+      CALL histwrite_phy(o_s_therm, s_therm)
+!IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
+!       IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_capCL%name,itau_w,s_capCL)
+!       ENDIF
+!       IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_oliqCL%name,itau_w,s_oliqCL)
+!       ENDIF
+!       IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_cteiCL%name,itau_w,s_cteiCL)
+!       ENDIF
+!       IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_trmb1%name,itau_w,s_trmb1)
+!       ENDIF
+!       IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_trmb2%name,itau_w,s_trmb2)
+!       ENDIF
+!       IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
+!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+!    $o_s_trmb3%name,itau_w,s_trmb3)
+!       ENDIF
+
+
+
+! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
+! Champs interpolles sur des niveaux de pression
+      DO iff=1, nfiles
+        ll=0
+        DO k=1, nlevSTD
+         bb2=clevSTD(k) 
+         IF(bb2.EQ."850".OR.bb2.EQ."700".OR. &
+            bb2.EQ."500".OR.bb2.EQ."200".OR. &
+            bb2.EQ."100".OR. &
+            bb2.EQ."50".OR.bb2.EQ."10") THEN
+
+! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+          ll=ll+1
+      CALL histwrite_phy(o_uSTDlevs(ll),uwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_vSTDlevs(ll),vwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_wSTDlevs(ll),wwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_zSTDlevs(ll),phiwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_qSTDlevs(ll),qwriteSTD(:,k,iff), iff)
+      CALL histwrite_phy(o_tSTDlevs(ll),twriteSTD(:,k,iff), iff)
+
+       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
+       ENDDO
+       ENDDO
+
+
+
+IF (vars_defined) THEN
+      DO i=1, klon
+       IF (pctsrf(i,is_oce).GT.epsfra.OR. &
+           pctsrf(i,is_sic).GT.epsfra) THEN
+        zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+ &
+                         ftsol(i, is_sic) * pctsrf(i,is_sic))/ &
+                         (pctsrf(i,is_oce)+pctsrf(i,is_sic))
+       ELSE
+        zx_tmp_fi2d(i) = 273.15
+       ENDIF
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
+
+! Couplage convection-couche limite
+      IF (iflag_con.GE.3) THEN
+      IF (iflag_coupl>=1) THEN
+      CALL histwrite_phy(o_ale_bl, ale_bl)
+      CALL histwrite_phy(o_alp_bl, alp_bl)
+      ENDIF !iflag_coupl>=1
+      ENDIF !(iflag_con.GE.3)
+! Wakes
+      IF (iflag_con.EQ.3) THEN
+      IF (iflag_wake>=1) THEN
+      CALL histwrite_phy(o_ale_wk, ale_wake)
+      CALL histwrite_phy(o_alp_wk, alp_wake)
+      CALL histwrite_phy(o_ale, ale)
+      CALL histwrite_phy(o_alp, alp)
+      CALL histwrite_phy(o_cin, cin)
+      CALL histwrite_phy(o_WAPE, wake_pe)
+      CALL histwrite_phy(o_wake_h, wake_h)
+      CALL histwrite_phy(o_wake_s, wake_s)
+      CALL histwrite_phy(o_wake_deltat, wake_deltat)
+      CALL histwrite_phy(o_wake_deltaq, wake_deltaq)
+      CALL histwrite_phy(o_wake_omg, wake_omg)
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev) &
+                                              /pdtphys
+      CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
+      ENDIF ! iflag_wake>=1
+      CALL histwrite_phy(o_Vprecip, Vprecip)
+      CALL histwrite_phy(o_ftd, ftd)
+      CALL histwrite_phy(o_fqd, fqd)
+      ELSEIF (iflag_con.EQ.30) THEN
+! sortie RomP convection descente insaturee iflag_con=30
+      CALL histwrite_phy(o_Vprecip, Vprecip)
+      CALL histwrite_phy(o_wdtrainA, wdtrainA)
+      CALL histwrite_phy(o_wdtrainM, wdtrainM)
+      ENDIF !(iflag_con.EQ.3.or.iflag_con.EQ.30)
+!!! nrlmd le 10/04/2012
+        IF (iflag_trig_bl>=1) THEN
+      CALL histwrite_phy(o_n2, n2)
+      CALL histwrite_phy(o_s2, s2)
+      CALL histwrite_phy(o_proba_notrig, proba_notrig)
+      CALL histwrite_phy(o_random_notrig, random_notrig)
+      CALL histwrite_phy(o_ale_bl_stat, ale_bl_stat)
+      CALL histwrite_phy(o_ale_bl_trig, ale_bl_trig)
+       ENDIF  !(iflag_trig_bl>=1)
+        IF (iflag_clos_bl>=1) THEN
+      CALL histwrite_phy(o_alp_bl_det, alp_bl_det)
+      CALL histwrite_phy(o_alp_bl_fluct_m, alp_bl_fluct_m)
+      CALL histwrite_phy(o_alp_bl_fluct_tke,  &
+       alp_bl_fluct_tke)
+      CALL histwrite_phy(o_alp_bl_conv, alp_bl_conv)
+      CALL histwrite_phy(o_alp_bl_stat, alp_bl_stat)
+       ENDIF  !(iflag_clos_bl>=1)
+!!! fin nrlmd le 10/04/2012
+      IF (type_ocean=='slab ') THEN
+      CALL histwrite_phy(o_slab_bils, slab_wfbils)
+      ENDIF !type_ocean == force/slab
+      CALL histwrite_phy(o_weakinv, weak_inversion)
+      CALL histwrite_phy(o_dthmin, dthmin)
+      CALL histwrite_phy(o_cldtau, cldtau)
+      CALL histwrite_phy(o_cldemi, cldemi)
+      CALL histwrite_phy(o_pr_con_l, pmflxr(:,1:klev))
+      CALL histwrite_phy(o_pr_con_i, pmflxs(:,1:klev))
+      CALL histwrite_phy(o_pr_lsc_l, prfl(:,1:klev))
+      CALL histwrite_phy(o_pr_lsc_i, psfl(:,1:klev))
+      CALL histwrite_phy(o_re, re)
+      CALL histwrite_phy(o_fl, fl)
+IF (vars_defined) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_rh2m_min, zx_tmp_fi2d)
+
+IF (vars_defined) THEN
+      DO i=1, klon
+       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_rh2m_max, zx_tmp_fi2d)
+
+      CALL histwrite_phy(o_qsat2m, qsat2m)
+      CALL histwrite_phy(o_tpot, tpot)
+      CALL histwrite_phy(o_tpote, tpote)
+IF (vars_defined) zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
+      CALL histwrite_phy(o_SWnetOR,  zx_tmp_fi2d)
+IF (vars_defined) zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
+      CALL histwrite_phy(o_SWdownOR,  zx_tmp_fi2d)
+      CALL histwrite_phy(o_LWdownOR, sollwdown)
+      CALL histwrite_phy(o_snowl, snow_lsc)
+      CALL histwrite_phy(o_solldown, sollwdown)
+      CALL histwrite_phy(o_dtsvdfo, d_ts(:,is_oce))
+      CALL histwrite_phy(o_dtsvdft, d_ts(:,is_ter))
+      CALL histwrite_phy(o_dtsvdfg,  d_ts(:,is_lic))
+      CALL histwrite_phy(o_dtsvdfi, d_ts(:,is_sic))
+      CALL histwrite_phy(o_rugs, zxrugs)
+! OD550 per species
+      IF (new_aod .and. (.not. aerosol_couple)) THEN
+          IF (ok_ade.OR.ok_aie) THEN
+      CALL histwrite_phy(o_od550aer, od550aer)
+      CALL histwrite_phy(o_od865aer, od865aer)
+      CALL histwrite_phy(o_absvisaer, absvisaer)
+      CALL histwrite_phy(o_od550lt1aer, od550lt1aer)
+      CALL histwrite_phy(o_sconcso4, sconcso4)
+      CALL histwrite_phy(o_sconcoa, sconcoa)
+      CALL histwrite_phy(o_sconcbc, sconcbc)
+      CALL histwrite_phy(o_sconcss, sconcss)
+      CALL histwrite_phy(o_sconcdust, sconcdust)
+      CALL histwrite_phy(o_concso4, concso4)
+      CALL histwrite_phy(o_concoa, concoa)
+      CALL histwrite_phy(o_concbc, concbc)
+      CALL histwrite_phy(o_concss, concss)
+      CALL histwrite_phy(o_concdust, concdust)
+      CALL histwrite_phy(o_loadso4, loadso4)
+      CALL histwrite_phy(o_loadoa, loadoa)
+      CALL histwrite_phy(o_loadbc, loadbc)
+      CALL histwrite_phy(o_loadss, loadss)
+      CALL histwrite_phy(o_loaddust, loaddust)
+!--STRAT AER
+          ENDIF
+          IF (ok_ade.OR.ok_aie.OR.flag_aerosol_strat) THEN
+          DO naero = 1, naero_spc
+      CALL histwrite_phy(o_tausumaero(naero), &
+       tausum_aero(:,2,naero) )
+          END DO
+          ENDIF
+      ENDIF
+       IF (ok_ade) THEN
+      CALL histwrite_phy(o_topswad, topswad_aero)
+      CALL histwrite_phy(o_topswad0, topswad0_aero)
+      CALL histwrite_phy(o_solswad, solswad_aero)
+      CALL histwrite_phy(o_solswad0, solswad0_aero)
+!====MS forcing diagnostics
+        if (new_aod) then
+      CALL histwrite_phy(o_swtoaas_nat, topsw_aero(:,1))
+      CALL histwrite_phy(o_swsrfas_nat, solsw_aero(:,1))
+      CALL histwrite_phy(o_swtoacs_nat, topsw0_aero(:,1))
+      CALL histwrite_phy(o_swsrfcs_nat, solsw0_aero(:,1))
+!ant
+      CALL histwrite_phy(o_swtoaas_ant, topsw_aero(:,2))
+      CALL histwrite_phy(o_swsrfas_ant, solsw_aero(:,2))
+      CALL histwrite_phy(o_swtoacs_ant, topsw0_aero(:,2))
+      CALL histwrite_phy(o_swsrfcs_ant, solsw0_aero(:,2))
+!cf
+        if (.not. aerosol_couple) then
+      CALL histwrite_phy(o_swtoacf_nat, topswcf_aero(:,1))
+      CALL histwrite_phy(o_swsrfcf_nat, solswcf_aero(:,1))
+      CALL histwrite_phy(o_swtoacf_ant, topswcf_aero(:,2))
+      CALL histwrite_phy(o_swsrfcf_ant, solswcf_aero(:,2))
+      CALL histwrite_phy(o_swtoacf_zero,topswcf_aero(:,3))
+      CALL histwrite_phy(o_swsrfcf_zero,solswcf_aero(:,3))
+        endif
+    endif ! new_aod
+!====MS forcing diagnostics
+       ENDIF
+       IF (ok_aie) THEN
+      CALL histwrite_phy(o_topswai, topswai_aero)
+      CALL histwrite_phy(o_solswai, solswai_aero)
+      CALL histwrite_phy(o_scdnc, scdnc)
+      CALL histwrite_phy(o_cldncl, cldncl)
+      CALL histwrite_phy(o_reffclws, reffclws)
+      CALL histwrite_phy(o_reffclwc, reffclwc)
+      CALL histwrite_phy(o_cldnvi, cldnvi)
+      CALL histwrite_phy(o_lcc, lcc)
+      CALL histwrite_phy(o_lcc3d, lcc3d)
+      CALL histwrite_phy(o_lcc3dcon, lcc3dcon)
+      CALL histwrite_phy(o_lcc3dstra, lcc3dstra)
+      CALL histwrite_phy(o_reffclwtop, reffclwtop)
+       ENDIF
+! Champs 3D:
+       IF (ok_ade .OR. ok_aie) then
+      CALL histwrite_phy(o_ec550aer, ec550aer)
+       ENDIF
+      CALL histwrite_phy(o_lwcon, flwc)
+      CALL histwrite_phy(o_iwcon, fiwc)
+      CALL histwrite_phy(o_temp, t_seri)
+      CALL histwrite_phy(o_theta, theta)
+      CALL histwrite_phy(o_ovapinit, qx(:,:,ivap))
+      CALL histwrite_phy(o_ovap, q_seri)
+      CALL histwrite_phy(o_oliq, ql_seri)
+      CALL histwrite_phy(o_geop, zphi)
+      CALL histwrite_phy(o_vitu, u_seri)
+      CALL histwrite_phy(o_vitv, v_seri)
+      CALL histwrite_phy(o_vitw, omega)
+      CALL histwrite_phy(o_pres, pplay)
+      CALL histwrite_phy(o_paprs, paprs(:,1:klev))
+IF (vars_defined) THEN
+         DO i=1, klon
+          zx_tmp_fi3d1(i,1)= pphis(i)/RG
+!020611   zx_tmp_fi3d(i,1)= pphis(i)/RG
+         ENDDO
+         DO k=1, klev
+!020611        DO k=1, klev-1
+         DO i=1, klon
+!020611         zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - (t_seri(i,k) *RD * 
+          zx_tmp_fi3d1(i,k+1)= zx_tmp_fi3d1(i,k) - (t_seri(i,k) *RD *  &
+          (paprs(i,k+1) - paprs(i,k))) / ( pplay(i,k) * RG ) 
+         ENDDO
+         ENDDO
+ENDIF
+      CALL histwrite_phy(o_zfull,zx_tmp_fi3d1(:,2:klevp1))
+!020611    $o_zfull%name,itau_w,zx_tmp_fi3d)
+
+IF (vars_defined)  THEN
+         DO i=1, klon
+          zx_tmp_fi3d(i,1)= pphis(i)/RG - ( &
+          (t_seri(i,1)+zxtsol(i))/2. *RD * &
+          (pplay(i,1) - paprs(i,1)))/( (paprs(i,1)+pplay(i,1))/2.* RG)
+         ENDDO
+         DO k=1, klev-1
+         DO i=1, klon
+          zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - ( &
+          (t_seri(i,k)+t_seri(i,k+1))/2. *RD *  &
+          (pplay(i,k+1) - pplay(i,k))) / ( paprs(i,k) * RG ) 
+         ENDDO
+         ENDDO
+ENDIF
+      CALL histwrite_phy(o_zhalf, zx_tmp_fi3d)
+      CALL histwrite_phy(o_rneb, cldfra)
+      CALL histwrite_phy(o_rnebcon, rnebcon)
+      CALL histwrite_phy(o_rnebls, rneb)
+      CALL histwrite_phy(o_rhum, zx_rh)
+      CALL histwrite_phy(o_ozone, &
+       wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
+
+      IF (read_climoz == 2) THEN
+      CALL histwrite_phy(o_ozone_light, &
+       wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
+      ENDIF
+
+      CALL histwrite_phy(o_dtphy, d_t)
+      CALL histwrite_phy(o_dqphy,  d_qx(:,:,ivap))
+        DO nsrf=1, nbsrf
+IF (vars_defined) zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
+      CALL histwrite_phy(o_albe_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined) zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
+      CALL histwrite_phy(o_rugs_srf(nsrf), zx_tmp_fi2d)
+IF (vars_defined) zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
+      CALL histwrite_phy(o_ages_srf(nsrf), zx_tmp_fi2d)
+        ENDDO !nsrf=1, nbsrf
+      CALL histwrite_phy(o_alb1, albsol1)
+      CALL histwrite_phy(o_alb2, albsol2)
+!FH Sorties pour la couche limite
+      if (iflag_pbl>1) then
+      zx_tmp_fi3d=0.
+IF (vars_defined) THEN
+      do nsrf=1,nbsrf
+         do k=1,klev
+          zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k) &
+          +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
+         enddo
+      enddo
+ENDIF
+      CALL histwrite_phy(o_tke, zx_tmp_fi3d)
+
+      CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)
+      ENDIF
+
+      CALL histwrite_phy(o_kz, coefh(:,:,is_ave))
+
+      CALL histwrite_phy(o_kz_max, coefh(:,:,is_ave))
+
+      CALL histwrite_phy(o_clwcon, clwcon0)
+      CALL histwrite_phy(o_dtdyn, d_t_dyn)
+      CALL histwrite_phy(o_dqdyn, d_q_dyn)
+      CALL histwrite_phy(o_dudyn, d_u_dyn)
+      CALL histwrite_phy(o_dvdyn, d_v_dyn)
+
+IF (vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
+      if(iflag_thermals.eq.1)then
+IF (vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
+                                 d_t_ajsb(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
+      else if(iflag_thermals.gt.1.and.iflag_wake.EQ.1)then
+IF (vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
+                                 d_t_ajs(1:klon,1:klev)/pdtphys + &
+                                 d_t_wake(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
+      endif
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_con(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
+
+      IF(iflag_thermals.EQ.1) THEN
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
+        CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
+      ELSE IF(iflag_thermals.GT.1.AND.iflag_wake.EQ.1) THEN
+IF (vars_defined) THEN
+         zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys + &
+                                     d_q_ajs(1:klon,1:klev)/pdtphys + &
+                                     d_q_wake(1:klon,1:klev)/pdtphys
+ENDIF
+         CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
+      ENDIF
+
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtlsc, zx_tmp_fi3d)
+IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+ &
+                                 d_t_eva(1:klon,1:klev))/pdtphys
+      CALL histwrite_phy(o_dtlschr, zx_tmp_fi3d)
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqlsc, zx_tmp_fi3d)
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=beta_prec(1:klon,1:klev)
+      CALL histwrite_phy(o_beta_prec, zx_tmp_fi3d)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! Sorties specifiques a la separation thermiques/non thermiques
+       if (iflag_thermals>=1) then
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscth(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscst(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscth(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscst(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
+      CALL histwrite_phy(o_plulth, plul_th)
+      CALL histwrite_phy(o_plulst, plul_st)
+IF (vars_defined) THEN
+      do k=1,klev
+      do i=1,klon
+          if (ptconvth(i,k)) then
+           zx_tmp_fi3d(i,k)=1.
+          else
+           zx_tmp_fi3d(i,k)=0.
+          endif
+      enddo
+      enddo
+ENDIF
+      CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
+IF (vars_defined) THEN
+      do i=1,klon
+           zx_tmp_fi2d(1:klon)=lmax_th(:)
+      enddo
+ENDIF
+      CALL histwrite_phy(o_lmaxth, zx_tmp_fi2d)
+      endif ! iflag_thermals>=1
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtvdf, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_diss(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtdis, zx_tmp_fi3d)
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dteva, zx_tmp_fi3d)
+IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
+      zpt_conv = 0.
+      WHERE (ptconv) zpt_conv = 1.
+      CALL histwrite_phy(o_ptconv, zpt_conv)
+      CALL histwrite_phy(o_ratqs, ratqs)
+IF (vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys - &
+                                 d_t_ajsb(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_dtthe, zx_tmp_fi3d)
+       IF (iflag_thermals>=1) THEN
+! Pour l instant 0 a y reflichir pour les thermiques
+         zx_tmp_fi2d=0. 
+      CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
+      CALL histwrite_phy(o_f_th, fm_therm)
+      CALL histwrite_phy(o_e_th, entr_therm)
+      CALL histwrite_phy(o_w_th, zw2)
+      CALL histwrite_phy(o_q_th, zqasc)
+      CALL histwrite_phy(o_a_th, fraca)
+      CALL histwrite_phy(o_d_th, detr_therm)
+      CALL histwrite_phy(o_f0_th, f0)
+      CALL histwrite_phy(o_zmax_th, zmax_th)
+IF (vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys - &
+                                 d_q_ajsb(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_dqthe, zx_tmp_fi3d)
+      ENDIF !iflag_thermals
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtajs, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY
+      CALL histwrite_phy(o_dtswr, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
+      CALL histwrite_phy(o_dtsw0, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
+      CALL histwrite_phy(o_dtlwr, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
+      CALL histwrite_phy(o_dtlw0, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtec, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_duvdf, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvvdf, zx_tmp_fi3d)
+       IF (ok_orodr) THEN
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_oro(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
+       ENDIF
+        IF (ok_orolf) THEN
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
+       ENDIF
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
+
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lif(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
+
+       IF (ok_hines) THEN
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_hin(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_duhin, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_hin(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dvhin, zx_tmp_fi3d)
+IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
+      CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
+        ENDIF
+      CALL histwrite_phy(o_rsu, swup)
+      CALL histwrite_phy(o_rsd, swdn)
+      CALL histwrite_phy(o_rlu, lwup)
+      CALL histwrite_phy(o_rld, lwdn)
+      CALL histwrite_phy(o_rsucs, swup0)
+      CALL histwrite_phy(o_rsdcs, swdn0)
+      CALL histwrite_phy(o_rlucs, lwup0)
+      CALL histwrite_phy(o_rldcs, lwdn0)
+IF(vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_t(1:klon,1:klev)+ &
+      d_t_dyn(1:klon,1:klev)
+ENDIF
+      CALL histwrite_phy(o_tnt, zx_tmp_fi3d)
+IF(vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY - &
+      cool(1:klon,1:klev)/RDAY
+ENDIF
+      CALL histwrite_phy(o_tntr, zx_tmp_fi3d)
+IF(vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)= (d_t_lsc(1:klon,1:klev)+ &
+                                   d_t_eva(1:klon,1:klev)+ &
+                                   d_t_vdf(1:klon,1:klev))/pdtphys
+ENDIF
+      CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d)
+IF(vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_qx(1:klon,1:klev,ivap)+ &
+      d_q_dyn(1:klon,1:klev)
+ENDIF
+      CALL histwrite_phy(o_tnhus, zx_tmp_fi3d)
+IF(vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys+ &
+                                 d_q_eva(1:klon,1:klev)/pdtphys
+ENDIF
+      CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d)
+      CALL histwrite_phy(o_evu, coefm(:,:,is_ave))
+IF(vars_defined) THEN
+      zx_tmp_fi3d(1:klon,1:klev)=q_seri(1:klon,1:klev)+ &
+                                 ql_seri(1:klon,1:klev) 
+ENDIF
+      CALL histwrite_phy(o_h2o, zx_tmp_fi3d)
+       if (iflag_con >= 3) then
+IF(vars_defined) THEN
+             zx_tmp_fi3d(1:klon,1:klev)=-1 * (dnwd(1:klon,1:klev)+ &
+                  dnwd0(1:klon,1:klev)) 
+ENDIF
+      CALL histwrite_phy(o_mcd, zx_tmp_fi3d)
+IF(vars_defined) THEN
+             zx_tmp_fi3d(1:klon,1:klev)=upwd(1:klon,1:klev) + &
+                  dnwd(1:klon,1:klev)+ dnwd0(1:klon,1:klev) 
+ENDIF
+      CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
+       else if (iflag_con == 2) then
+      CALL histwrite_phy(o_mcd,  pmfd)
+      CALL histwrite_phy(o_dmc,  pmfu + pmfd)
+       end if
+      CALL histwrite_phy(o_ref_liq, ref_liq)
+      CALL histwrite_phy(o_ref_ice, ref_ice)
+      if (RCO2_per.NE.RCO2_act.OR.RCH4_per.NE.RCH4_act.OR. &
+       RN2O_per.NE.RN2O_act.OR.RCFC11_per.NE.RCFC11_act.OR. &
+       RCFC12_per.NE.RCFC12_act) THEN
+IF(vars_defined) zx_tmp_fi2d(1 : klon) = swupp ( 1 : klon, klevp1 )
+      CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
+IF(vars_defined) zx_tmp_fi2d(1 : klon) = lwupp ( 1 : klon, klevp1 )
+      CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
+IF(vars_defined) zx_tmp_fi2d(1 : klon) = swup0p ( 1 : klon, klevp1 )
+      CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
+IF(vars_defined) zx_tmp_fi2d(1 : klon) = lwup0p ( 1 : klon, klevp1 )
+      CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
+      CALL histwrite_phy(o_rsu4co2, swupp)
+      CALL histwrite_phy(o_rlu4co2, lwupp)
+      CALL histwrite_phy(o_rsucs4co2, swup0p)
+      CALL histwrite_phy(o_rlucs4co2, lwup0p)
+      CALL histwrite_phy(o_rsd4co2, swdnp)
+      CALL histwrite_phy(o_rld4co2, lwdnp)
+      CALL histwrite_phy(o_rsdcs4co2, swdn0p)
+      CALL histwrite_phy(o_rldcs4co2, lwdn0p)
+      ENDIF
+!!!!!!!!!!!! Sorties niveaux de pression NMC !!!!!!!!!!!!!!!!!!!!
+DO iff=7, nfiles
+
+      CALL histwrite_phy(o_tnondef,tnondef(:,:,iff-6),iff)
+      CALL histwrite_phy(o_ta,twriteSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_zg,phiwriteSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_hus,qwriteSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_hur,rhwriteSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_ua,uwriteSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_va,vwriteSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_wap,wwriteSTD(:,:,iff-6),iff)
+IF(vars_defined) THEN
+       DO k=1, nlevSTD
+        DO i=1, klon
+         IF(tnondef(i,k,iff-6).NE.missing_val) THEN
+          zx_tmp_fi3d(i,k) = (100.*tnondef(i,k,iff-6))/freq_moyNMC(iff-6)
+         ELSE
+          zx_tmp_fi3d(i,k) = missing_val
+         ENDIF
+        ENDDO
+      ENDDO
+ENDIF
+      CALL histwrite_phy(o_psbg,zx_tmp_fi3d,iff)
+IF(vars_defined) THEN
+       DO k=1, nlevSTD
+        DO i=1, klon
+         IF(O3sumSTD(i,k,iff-6).NE.missing_val) THEN
+          zx_tmp_fi3d(i,k) = O3sumSTD(i,k,iff-6) * 1.e+9
+         ELSE
+          zx_tmp_fi3d(i,k) = missing_val
+         ENDIF
+        ENDDO
+       ENDDO !k=1, nlevSTD
+ENDIF
+      CALL histwrite_phy(o_tro3,zx_tmp_fi3d,iff)
+       if (read_climoz == 2) THEN
+IF(vars_defined) THEN
+       DO k=1, nlevSTD
+        DO i=1, klon
+         IF(O3daysumSTD(i,k,iff-6).NE.missing_val) THEN
+          zx_tmp_fi3d(i,k) = O3daysumSTD(i,k,iff-6) * 1.e+9
+         ELSE
+          zx_tmp_fi3d(i,k) = missing_val
+         ENDIF
+        ENDDO
+       ENDDO !k=1, nlevSTD
+ENDIF
+      CALL histwrite_phy(o_tro3_daylight,zx_tmp_fi3d,iff)
+      endif
+      CALL histwrite_phy(o_uxv,uvsumSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_vxq,vqsumSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_vxT,vTsumSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_wxq,wqsumSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_vxphi,vphisumSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_wxT,wTsumSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_uxu,u2sumSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_vxv,v2sumSTD(:,:,iff-6),iff)
+      CALL histwrite_phy(o_TxT,T2sumSTD(:,:,iff-6),iff)
+ENDDO !nfiles
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+        IF (nqtot.GE.3) THEN
+         DO iq=3,nqtot
+             CALL histwrite_phy(o_trac(iq-2), qx(:,:,iq))
+             CALL histwrite_phy(o_dtr_vdf(iq-2),d_tr_cl(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_the(iq-2),d_tr_th(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_con(iq-2),d_tr_cv(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_lessi_impa(iq-2),d_tr_lessi_impa(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_lessi_nucl(iq-2),d_tr_lessi_nucl(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_insc(iq-2),d_tr_insc(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_bcscav(iq-2),d_tr_bcscav(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_evapls(iq-2),d_tr_evapls(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_ls(iq-2),d_tr_ls(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_trsp(iq-2),d_tr_trsp(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_sscav(iq-2),d_tr_sscav(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_sat(iq-2),d_tr_sat(:,:,iq-2))
+             CALL histwrite_phy(o_dtr_uscav(iq-2),d_tr_uscav(:,:,iq-2))
+         zx_tmp_fi2d=0.
+IF(vars_defined) THEN
+         DO k=1,klev
+            zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*qx(:,k,iq)
+         ENDDO
+ENDIF
+            CALL histwrite_phy(o_trac_cum(iq-2), zx_tmp_fi2d)
+         ENDDO
+        ENDIF
+
+
+        IF(.NOT.vars_defined) THEN
+!$OMP MASTER
+#ifndef CPP_NO_IOIPSL 
+            DO iff=1,nfiles
+                IF (clef_files(iff)) THEN
+                  CALL histend(nid_files(iff))
+                  ndex2d = 0
+                  ndex3d = 0
+
+                ENDIF ! clef_files
+            ENDDO !  iff
+#endif
+#ifdef CPP_XIOS
+            !On finalise l'initialisation:
+            CALL wxios_closedef()
+#endif
+
+!$OMP END MASTER
+!$OMP BARRIER
+            vars_defined = .TRUE.
+
+
+        END IF
+
+    END DO
+
+    IF(vars_defined) THEN
+! On synchronise les fichiers pour IOIPSL
+#ifndef CPP_NO_IOIPSL 
+!$OMP MASTER
+      DO iff=1,nfiles
+          IF (ok_sync .AND. clef_files(iff)) THEN
+              CALL histsync(nid_files(iff))
+          ENDIF
+      END DO
+!$OMP END MASTER
+#endif
+    ENDIF
+
+      
+
+
+    END SUBROUTINE phys_output_write
+
+
+
+  END MODULE phys_output_write_mod
+
Index: LMDZ5/branches/testing/libf/phylmd/phys_output_write_new.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phys_output_write_new.h	(revision 1796)
+++ 	(revision )
@@ -1,788 +1,0 @@
-      itau_w = itau_phy + itap + start_time * day_step / iphysiq
-      ! ug On transmet le pas de temps à iophy pour que les méthodes histwrite y aient accès:
-      itau_iophy = itau_w
-
-             ndex2d = 0
-             ndex3d = 0
-!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      CALL histwrite_phy(o_phis, pphis)
-      CALL histwrite_phy(o_aire, airephy)
-
-      DO i=1, klon
-            zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
-      ENDDO
-      CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
-      CALL histwrite_phy(o_contfracOR, pctsrf(:,is_ter))
-      CALL histwrite_phy(o_aireTER, paire_ter)
-!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      CALL histwrite_phy(o_flat, zxfluxlat)
-      CALL histwrite_phy(o_slp, slp)
-      CALL histwrite_phy(o_tsol, zxtsol)
-      CALL histwrite_phy(o_t2m, zt2m)
-      CALL histwrite_phy(o_t2m_min, zt2m)
-      CALL histwrite_phy(o_t2m_max, zt2m)
-
-      DO i=1, klon
-       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
-      ENDDO
-      CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
-
-      DO i=1, klon
-       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
-      ENDDO
-      CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
-
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = pctsrf(i,is_sic)
-      ENDDO
-      CALL histwrite_phy(o_sicf, zx_tmp_fi2d)
-      CALL histwrite_phy(o_q2m, zq2m)
-      CALL histwrite_phy(o_ustar, zustar)
-      CALL histwrite_phy(o_u10m, zu10m)
-      CALL histwrite_phy(o_v10m, zv10m)
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = paprs(i,1)
-      ENDDO
-      CALL histwrite_phy(o_psol, zx_tmp_fi2d)
-      CALL histwrite_phy(o_mass, zmasse)
-      CALL histwrite_phy(o_qsurf, zxqsurf)
-
-      IF (.NOT. ok_veget) THEN
-            CALL histwrite_phy(o_qsol, qsol)
-      ENDIF
-
-       DO i = 1, klon
-         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
-       ENDDO
-      CALL histwrite_phy(o_precip, zx_tmp_fi2d)
-      CALL histwrite_phy(o_ndayrain, nday_rain)
-       DO i = 1, klon
-         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
-       ENDDO
-      CALL histwrite_phy(o_plul, zx_tmp_fi2d)
-      DO i = 1, klon
-         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
-      ENDDO
-      CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
-      CALL histwrite_phy(o_snow, snow_fall)
-      CALL histwrite_phy(o_msnow, snow_o)
-      CALL histwrite_phy(o_fsnow, zfra_o)
-      CALL histwrite_phy(o_evap, evap)
-      CALL histwrite_phy(o_tops, topsw)
-      CALL histwrite_phy(o_tops0, topsw0)
-      CALL histwrite_phy(o_topl, toplw)
-      CALL histwrite_phy(o_topl0, toplw0)
-      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
-      CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
-      CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
-      CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
-      CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
-      zx_tmp_fi2d(:) = topsw(:)-toplw(:)
-      CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
-      CALL histwrite_phy(o_SWup200, SWup200)
-      CALL histwrite_phy(o_SWup200clr, SWup200clr)
-      CALL histwrite_phy(o_SWdn200, SWdn200)
-      CALL histwrite_phy(o_SWdn200clr, SWdn200clr)
-      CALL histwrite_phy(o_LWup200, LWup200)
-      CALL histwrite_phy(o_LWup200clr, LWup200clr)
-      CALL histwrite_phy(o_LWdn200, LWdn200)
-      CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
-      CALL histwrite_phy(o_sols, solsw)
-      CALL histwrite_phy(o_sols0, solsw0)
-      CALL histwrite_phy(o_soll, sollw)
-      CALL histwrite_phy(o_radsol, radsol)
-      CALL histwrite_phy(o_soll0, sollw0)
-      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
-      CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
-      CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
-      CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
-      CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
-      zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
-      CALL histwrite_phy(o_LWupSFC, zx_tmp_fi2d)
-      CALL histwrite_phy(o_LWdnSFC, sollwdown)
-
-       sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
-      zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
-      CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
-      CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
-
-      CALL histwrite_phy(o_bils, bils)
-      CALL histwrite_phy(o_bils_diss, bils_diss)
-      CALL histwrite_phy(o_bils_ec, bils_ec)
-      CALL histwrite_phy(o_bils_tke, bils_tke)
-      CALL histwrite_phy(o_bils_kinetic, bils_kinetic)
-      CALL histwrite_phy(o_bils_latent, bils_latent)
-      CALL histwrite_phy(o_bils_enthalp, bils_enthalp)
-
-      zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
-      CALL histwrite_phy(o_sens, zx_tmp_fi2d)
-      CALL histwrite_phy(o_fder, fder)
-      CALL histwrite_phy(o_ffonte, zxffonte)
-      CALL histwrite_phy(o_fqcalving, zxfqcalving)
-      CALL histwrite_phy(o_fqfonte, zxfqfonte)
-         zx_tmp_fi2d=0.
-         do nsrf=1,nbsrf
-          zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxu(:,1,nsrf)
-         enddo
-      CALL histwrite_phy(o_taux, zx_tmp_fi2d)
-         zx_tmp_fi2d=0.
-         do nsrf=1,nbsrf
-          zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxv(:,1,nsrf)
-         enddo
-      CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
-         DO nsrf = 1, nbsrf
-!           IF(nsrf.GE.2) THEN
-            zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
-      CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
-          zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
-      CALL histwrite_phy(o_fract_srf(nsrf), zx_tmp_fi2d)
-!         ENDIF !nsrf.GT.2
-        zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
-      CALL histwrite_phy(o_taux_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
-      CALL histwrite_phy(o_tauy_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
-      CALL histwrite_phy(o_tsol_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = evap_pot( 1 : klon, nsrf)
-      CALL histwrite_phy(o_evappot_srf(nsrf), zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = ustar(1 : klon, nsrf)
-      CALL histwrite_phy(o_ustar_srf(nsrf), zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
-      CALL histwrite_phy(o_u10m_srf(nsrf), zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
-      CALL histwrite_phy(o_v10m_srf(nsrf), zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
-      CALL histwrite_phy(o_t2m_srf(nsrf), zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = fevap(1 : klon, nsrf)
-      CALL histwrite_phy(o_evap_srf(nsrf), zx_tmp_fi2d)
-       zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
-      CALL histwrite_phy(o_sens_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
-      CALL histwrite_phy(o_lat_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
-      CALL histwrite_phy(o_flw_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
-      CALL histwrite_phy(o_fsw_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
-      CALL histwrite_phy(o_wbils_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
-      CALL histwrite_phy(o_wbilo_srf(nsrf), zx_tmp_fi2d)
-
-      IF (iflag_pbl>1) THEN
-       CALL histwrite_phy(o_tke_srf(nsrf), pbl_tke(:,1:klev,nsrf))
-       CALL histwrite_phy(o_tke_max_srf(nsrf), pbl_tke(:,1:klev,nsrf))
-      ENDIF
-
-      ENDDO
-      CALL histwrite_phy(o_cdrm, cdragm)
-      CALL histwrite_phy(o_cdrh, cdragh)
-      CALL histwrite_phy(o_cldl, cldl)
-      CALL histwrite_phy(o_cldm, cldm)
-      CALL histwrite_phy(o_cldh, cldh)
-      CALL histwrite_phy(o_cldt, cldt)
-      CALL histwrite_phy(o_cldq, cldq)
-      zx_tmp_fi2d(1:klon) = flwp(1:klon)
-      CALL histwrite_phy(o_lwp, zx_tmp_fi2d)
-      zx_tmp_fi2d(1:klon) = fiwp(1:klon)
-      CALL histwrite_phy(o_iwp, zx_tmp_fi2d)
-      CALL histwrite_phy(o_ue, ue)
-      CALL histwrite_phy(o_ve, ve)
-      CALL histwrite_phy(o_uq, uq)
-      CALL histwrite_phy(o_vq, vq)
-      IF(iflag_con.GE.3) THEN ! sb
-            CALL histwrite_phy(o_cape, cape)
-            CALL histwrite_phy(o_pbase, ema_pcb)
-            CALL histwrite_phy(o_ptop, ema_pct)
-            CALL histwrite_phy(o_fbase, ema_cbmf)
-
-            IF (iflag_con /= 30) THEN
-                  CALL histwrite_phy(o_plcl, plcl)
-                  CALL histwrite_phy(o_plfc, plfc)
-                  CALL histwrite_phy(o_wbeff, wbeff)
-            ENDIF
-
-            CALL histwrite_phy(o_cape_max, cape)
-            CALL histwrite_phy(o_upwd, upwd)
-            CALL histwrite_phy(o_Ma, Ma)
-            CALL histwrite_phy(o_dnwd, dnwd)
-            CALL histwrite_phy(o_dnwd0, dnwd0)
-              zx_tmp_fi2d=float(itau_con)/float(itap)
-            CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
-
-            IF (iflag_thermals>=1) THEN
-               zx_tmp_fi3d=dnwd+dnwd0+upwd+fm_therm(:,1:klev)
-            ELSE
-               zx_tmp_fi3d=dnwd+dnwd0+upwd
-            ENDIF
-            CALL histwrite_phy(o_mc, zx_tmp_fi3d)
-      ENDIF !iflag_con .GE. 3
-
-      CALL histwrite_phy(o_prw, prw)
-      CALL histwrite_phy(o_s_pblh, s_pblh)
-      CALL histwrite_phy(o_s_pblt, s_pblt)
-      CALL histwrite_phy(o_s_lcl, s_lcl)
-      CALL histwrite_phy(o_s_therm, s_therm)
-
-
-! ANCIENNE METHODE
-        DO iff=1,nfiles
-              ll=0
-        DO k=1, nlevSTD
-         bb2=clevSTD(k) 
-         IF(bb2.EQ."850".OR.bb2.EQ."700".OR.
-     $      bb2.EQ."500".OR.bb2.EQ."200".OR.
-     $      bb2.EQ."100".OR.
-     $      bb2.EQ."50".OR.bb2.EQ."10") THEN
-
-! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-          ll=ll+1
-      CALL histwrite_phy(o_uSTDlevs(ll),uwriteSTD(:,k,iff), iff)
-      CALL histwrite_phy(o_vSTDlevs(ll),vwriteSTD(:,k,iff), iff)
-      CALL histwrite_phy(o_wSTDlevs(ll),wwriteSTD(:,k,iff), iff)
-      CALL histwrite_phy(o_zSTDlevs(ll),phiwriteSTD(:,k,iff), iff)
-      CALL histwrite_phy(o_qSTDlevs(ll),qwriteSTD(:,k,iff), iff)
-      CALL histwrite_phy(o_tSTDlevs(ll),twriteSTD(:,k,iff), iff)
-!       IF (o_uSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
-!       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-!     $o_uSTDlevs(ll)%name,
-!     &                    itau_w,uwriteSTD(:,k,iff))
-!       ENDIF
-
- !      IF (o_vSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
-!      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-!     $o_vSTDlevs(ll)%name,  
-!     &                   itau_w,vwriteSTD(:,k,iff))
-!       ENDIF
-
-!       IF (o_wSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
-!      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-!     $o_wSTDlevs(ll)%name,
-!     &                    itau_w,wwriteSTD(:,k,iff))
-!       ENDIF
-
-!       IF (o_zSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
-!      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-!     $o_zSTDlevs(ll)%name,
-!     &               itau_w,phiwriteSTD(:,k,iff))
-!      ENDIF
-
- !      IF (o_qSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
-!      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-!     $o_qSTDlevs(ll)%name,
-!     &                   itau_w, qwriteSTD(:,k,iff))
-!       ENDIF
-
- !      IF (o_tSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
-!      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-!     $o_tSTDlevs(ll)%name,
-!     &                   itau_w, twriteSTD(:,k,iff))
- !      ENDIF
-
-       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
-       ENDDO
-   	   ENDDO
-! /ANCIENNE METHODE       
-
-
-      DO i=1, klon
-       IF (pctsrf(i,is_oce).GT.epsfra.OR.
-     $     pctsrf(i,is_sic).GT.epsfra) THEN
-        zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+
-     $                   ftsol(i, is_sic) * pctsrf(i,is_sic))/
-     $                   (pctsrf(i,is_oce)+pctsrf(i,is_sic))
-       ELSE
-        zx_tmp_fi2d(i) = 273.15
-       ENDIF
-      ENDDO
-      CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
-! Couplage convection-couche limite
-      IF (iflag_con.GE.3) THEN
-            IF (iflag_coupl>=1) THEN
-                  CALL histwrite_phy(o_ale_bl, ale_bl)
-                  CALL histwrite_phy(o_alp_bl, alp_bl)
-            ENDIF !iflag_coupl>=1
-      ENDIF !(iflag_con.GE.3)
-! Wakes
-      IF (iflag_con.EQ.3) THEN
-            IF (iflag_wake>=1) THEN
-            CALL histwrite_phy(o_ale_wk, ale_wake)
-            CALL histwrite_phy(o_alp_wk, alp_wake)
-            CALL histwrite_phy(o_ale, ale)
-            CALL histwrite_phy(o_alp, alp)
-            CALL histwrite_phy(o_cin, cin)
-            CALL histwrite_phy(o_WAPE, wake_pe)
-            CALL histwrite_phy(o_wake_h, wake_h)
-            CALL histwrite_phy(o_wake_s, wake_s)
-            CALL histwrite_phy(o_wake_deltat, wake_deltat)
-            CALL histwrite_phy(o_wake_deltaq, wake_deltaq)
-            CALL histwrite_phy(o_wake_omg, wake_omg)
-                  zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev)
-     &                                        /pdtphys
-            CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
-                  zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)
-     &                                        /pdtphys
-            CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
-            ENDIF ! iflag_wake>=1
-            CALL histwrite_phy(o_Vprecip, Vprecip)
-            CALL histwrite_phy(o_ftd, ftd)
-            CALL histwrite_phy(o_fqd, fqd)
-      ELSEIF (iflag_con.EQ.30) THEN
-! sortie RomP convection descente insaturee iflag_con=30
-            CALL histwrite_phy(o_Vprecip, Vprecip)
-            CALL histwrite_phy(o_wdtrainA, wdtrainA)
-            CALL histwrite_phy(o_wdtrainM, wdtrainM)
-      ENDIF !(iflag_con.EQ.3.or.iflag_con.EQ.30)
-
-!!! nrlmd le 10/04/2012
-      IF (iflag_trig_bl>=1) THEN
-            CALL histwrite_phy(o_n2, n2)
-            CALL histwrite_phy(o_s2, s2)
-            CALL histwrite_phy(o_proba_notrig, proba_notrig)
-            CALL histwrite_phy(o_random_notrig, random_notrig)
-            CALL histwrite_phy(o_ale_bl_stat, ale_bl_stat)
-            CALL histwrite_phy(o_ale_bl_trig, ale_bl_trig)
-      ENDIF  !(iflag_trig_bl>=1)
-      
-      IF (iflag_clos_bl>=1) THEN
-            CALL histwrite_phy(o_alp_bl_det, alp_bl_det)
-            CALL histwrite_phy(o_alp_bl_fluct_m, alp_bl_fluct_m)
-            CALL histwrite_phy(o_alp_bl_fluct_tke, alp_bl_fluct_tke)
-            CALL histwrite_phy(o_alp_bl_conv, alp_bl_conv)
-            CALL histwrite_phy(o_alp_bl_stat, alp_bl_stat)
-      ENDIF  !(iflag_clos_bl>=1)
-!!! fin nrlmd le 10/04/2012
-
-      IF (type_ocean=='slab ') THEN
-            CALL histwrite_phy(o_slab_bils, slab_wfbils)
-      ENDIF !type_ocean == force/slab
-
-      CALL histwrite_phy(o_weakinv, weak_inversion)
-      CALL histwrite_phy(o_dthmin, dthmin)
-      CALL histwrite_phy(o_cldtau, cldtau)
-      CALL histwrite_phy(o_cldemi, cldemi)
-      CALL histwrite_phy(o_pr_con_l, pmflxr(:,1:klev))
-      CALL histwrite_phy(o_pr_con_i, pmflxs(:,1:klev))
-      CALL histwrite_phy(o_pr_lsc_l, prfl(:,1:klev))
-      CALL histwrite_phy(o_pr_lsc_i, psfl(:,1:klev))
-      CALL histwrite_phy(o_re, re)
-      CALL histwrite_phy(o_fl, fl)
-      DO i=1, klon
-       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
-      ENDDO
-      CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
-
-      DO i=1, klon
-       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
-      ENDDO
-      CALL histwrite_phy(o_rh2m_min, zx_tmp_fi2d)
-      DO i=1, klon
-       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
-      ENDDO
-      CALL histwrite_phy(o_rh2m_max, zx_tmp_fi2d)
-
-      CALL histwrite_phy(o_qsat2m, qsat2m)
-      CALL histwrite_phy(o_tpot, tpot)
-      CALL histwrite_phy(o_tpote, tpote)
-      zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
-      CALL histwrite_phy(o_SWnetOR,  zx_tmp_fi2d)
-      zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
-      CALL histwrite_phy(o_SWdownOR,  zx_tmp_fi2d)
-      CALL histwrite_phy(o_LWdownOR, sollwdown)
-      CALL histwrite_phy(o_snowl, snow_lsc)
-      CALL histwrite_phy(o_solldown, sollwdown)
-      CALL histwrite_phy(o_dtsvdfo, d_ts(:,is_oce))
-      CALL histwrite_phy(o_dtsvdft, d_ts(:,is_ter))
-      CALL histwrite_phy(o_dtsvdfg,  d_ts(:,is_lic))
-      CALL histwrite_phy(o_dtsvdfi, d_ts(:,is_sic))
-      CALL histwrite_phy(o_rugs, zxrugs)
-! OD550 per species
-      IF (new_aod .and. (.not. aerosol_couple)) THEN
-          IF (ok_ade.OR.ok_aie) THEN
-      CALL histwrite_phy(o_od550aer, od550aer)
-      CALL histwrite_phy(o_od865aer, od865aer)
-      CALL histwrite_phy(o_absvisaer, absvisaer)
-      CALL histwrite_phy(o_od550lt1aer, od550lt1aer)
-      CALL histwrite_phy(o_sconcso4, sconcso4)
-      CALL histwrite_phy(o_sconcoa, sconcoa)
-      CALL histwrite_phy(o_sconcbc, sconcbc)
-      CALL histwrite_phy(o_sconcss, sconcss)
-      CALL histwrite_phy(o_sconcdust, sconcdust)
-      CALL histwrite_phy(o_concso4, concso4)
-      CALL histwrite_phy(o_concoa, concoa)
-      CALL histwrite_phy(o_concbc, concbc)
-      CALL histwrite_phy(o_concss, concss)
-      CALL histwrite_phy(o_concdust, concdust)
-      CALL histwrite_phy(o_loadso4, loadso4)
-      CALL histwrite_phy(o_loadoa, loadoa)
-      CALL histwrite_phy(o_loadbc, loadbc)
-      CALL histwrite_phy(o_loadss, loadss)
-      CALL histwrite_phy(o_loaddust, loaddust)
-          DO naero = 1, naero_spc
-      CALL histwrite_phy(o_tausumaero(naero),
-     & tausum_aero(:,2,naero) )
-          END DO
-          endif
-      ENDIF
-       IF (ok_ade) THEN
-      CALL histwrite_phy(o_topswad, topswad_aero)
-      CALL histwrite_phy(o_topswad0, topswad0_aero)
-      CALL histwrite_phy(o_solswad, solswad_aero)
-      CALL histwrite_phy(o_solswad0, solswad0_aero)
-!====MS forcing diagnostics
-        if (new_aod) then	       
-      CALL histwrite_phy(o_swtoaas_nat, topsw_aero(:,1))
-      CALL histwrite_phy(o_swsrfas_nat, solsw_aero(:,1))
-      CALL histwrite_phy(o_swtoacs_nat, topsw0_aero(:,1))
-      CALL histwrite_phy(o_swsrfcs_nat, solsw0_aero(:,1))
-!ant
-      CALL histwrite_phy(o_swtoaas_ant, topsw_aero(:,2))
-      CALL histwrite_phy(o_swsrfas_ant, solsw_aero(:,2))
-      CALL histwrite_phy(o_swtoacs_ant, topsw0_aero(:,2))
-      CALL histwrite_phy(o_swsrfcs_ant, solsw0_aero(:,2))
-!cf
-        if (.not. aerosol_couple) then
-      CALL histwrite_phy(o_swtoacf_nat, topswcf_aero(:,1))
-      CALL histwrite_phy(o_swsrfcf_nat, solswcf_aero(:,1))
-      CALL histwrite_phy(o_swtoacf_ant, topswcf_aero(:,2))
-      CALL histwrite_phy(o_swsrfcf_ant, solswcf_aero(:,2))
-      CALL histwrite_phy(o_swtoacf_zero,topswcf_aero(:,3))
-      CALL histwrite_phy(o_swsrfcf_zero,solswcf_aero(:,3))
-        endif
-	endif ! new_aod
-!====MS forcing diagnostics
-       ENDIF
-       IF (ok_aie) THEN
-      CALL histwrite_phy(o_topswai, topswai_aero)
-      CALL histwrite_phy(o_solswai, solswai_aero)
-      CALL histwrite_phy(o_scdnc, scdnc)
-      CALL histwrite_phy(o_cldncl, cldncl)
-      CALL histwrite_phy(o_reffclws, reffclws)
-      CALL histwrite_phy(o_reffclwc, reffclwc)
-      CALL histwrite_phy(o_cldnvi, cldnvi)
-      CALL histwrite_phy(o_lcc, lcc)
-      CALL histwrite_phy(o_lcc3d, lcc3d)
-      CALL histwrite_phy(o_lcc3dcon, lcc3dcon)
-      CALL histwrite_phy(o_lcc3dstra, lcc3dstra)
-      CALL histwrite_phy(o_reffclwtop, reffclwtop)
-       ENDIF
-! Champs 3D:
-       IF (ok_ade .OR. ok_aie) then
-      CALL histwrite_phy(o_ec550aer, ec550aer)
-       ENDIF
-      CALL histwrite_phy(o_lwcon, flwc)
-      CALL histwrite_phy(o_iwcon, fiwc)
-      CALL histwrite_phy(o_temp, t_seri)
-      CALL histwrite_phy(o_theta, theta)
-      CALL histwrite_phy(o_ovapinit, qx(:,:,ivap))
-      CALL histwrite_phy(o_ovap, q_seri)
-      CALL histwrite_phy(o_oliq, ql_seri)
-      CALL histwrite_phy(o_geop, zphi)
-      CALL histwrite_phy(o_vitu, u_seri)
-      CALL histwrite_phy(o_vitv, v_seri)
-      CALL histwrite_phy(o_vitw, omega)
-      CALL histwrite_phy(o_pres, pplay)
-      CALL histwrite_phy(o_paprs, paprs(:,1:klev))
-         DO i=1, klon
-          zx_tmp_fi3d1(i,1)= pphis(i)/RG
-!020611   zx_tmp_fi3d(i,1)= pphis(i)/RG
-         ENDDO
-         DO k=1, klev
-!020611        DO k=1, klev-1
-         DO i=1, klon
-!020611         zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - (t_seri(i,k) *RD * 
-          zx_tmp_fi3d1(i,k+1)= zx_tmp_fi3d1(i,k) - (t_seri(i,k) *RD * 
-     $    (paprs(i,k+1) - paprs(i,k))) / ( pplay(i,k) * RG ) 
-         ENDDO
-         ENDDO
-      CALL histwrite_phy(o_zfull,zx_tmp_fi3d1(:,2:klevp1))
-!020611    $o_zfull%name,itau_w,zx_tmp_fi3d)
-         DO i=1, klon
-          zx_tmp_fi3d(i,1)= pphis(i)/RG - (
-     $    (t_seri(i,1)+zxtsol(i))/2. *RD *
-     $    (pplay(i,1) - paprs(i,1)))/((paprs(i,1)+pplay(i,1))/2. * RG)
-         ENDDO
-         DO k=1, klev-1
-         DO i=1, klon
-          zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - (
-     $    (t_seri(i,k)+t_seri(i,k+1))/2. *RD * 
-     $    (pplay(i,k+1) - pplay(i,k))) / ( paprs(i,k) * RG ) 
-         ENDDO
-         ENDDO
-      CALL histwrite_phy(o_zhalf, zx_tmp_fi3d)
-      CALL histwrite_phy(o_rneb, cldfra)
-      CALL histwrite_phy(o_rnebcon, rnebcon)
-      CALL histwrite_phy(o_rnebls, rneb)
-      CALL histwrite_phy(o_rhum, zx_rh)
-      CALL histwrite_phy(o_ozone, wo(:, :, 1)
-     & * dobson_u * 1e3 / zmasse / rmo3 * rmd)
-      IF (read_climoz == 2) THEN
-      CALL histwrite_phy(o_ozone_light, wo(:, :, 2)
-     & * dobson_u * 1e3 / zmasse / rmo3 * rmd)
-      ENDIF
-      CALL histwrite_phy(o_dtphy, d_t)
-      CALL histwrite_phy(o_dqphy,  d_qx(:,:,ivap))
-        DO nsrf=1, nbsrf
-        zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
-      CALL histwrite_phy(o_albe_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
-      CALL histwrite_phy(o_rugs_srf(nsrf), zx_tmp_fi2d)
-        zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
-      CALL histwrite_phy(o_ages_srf(nsrf), zx_tmp_fi2d)
-        ENDDO !nsrf=1, nbsrf
-      CALL histwrite_phy(o_alb1, albsol1)
-      CALL histwrite_phy(o_alb2, albsol2)
-!FH Sorties pour la couche limite
-      if (iflag_pbl>1) then
-      zx_tmp_fi3d=0.
-      do nsrf=1,nbsrf
-         do k=1,klev
-          zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k)
-     $    +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
-         enddo
-      enddo
-      CALL histwrite_phy(o_tke, zx_tmp_fi3d)
-
-      CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)
-
-      endif
-      CALL histwrite_phy(o_kz, coefh(:,:,is_ave))
-
-      CALL histwrite_phy(o_kz_max, coefh(:,:,is_ave))
-
-      CALL histwrite_phy(o_clwcon, clwcon0)
-      CALL histwrite_phy(o_dtdyn, d_t_dyn)
-      CALL histwrite_phy(o_dqdyn, d_q_dyn)
-      CALL histwrite_phy(o_dudyn, d_u_dyn)
-      CALL histwrite_phy(o_dvdyn, d_v_dyn)
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
-      if(iflag_thermals.eq.1)then
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys +
-     $                           d_t_ajsb(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
-      else if(iflag_thermals.gt.1.and.iflag_wake.EQ.1)then
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys +
-     $                           d_t_ajs(1:klon,1:klev)/pdtphys +
-     $                           d_t_wake(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
-      endif
-      zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_v_con(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
-      if(iflag_thermals.eq.1)then
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
-      else if(iflag_thermals.gt.1.and.iflag_wake.EQ.1)then
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys +
-     $                           d_q_ajs(1:klon,1:klev)/pdtphys +
-     $                           d_q_wake(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
-      endif
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtlsc, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+
-     $                           d_t_eva(1:klon,1:klev))/pdtphys
-      CALL histwrite_phy(o_dtlschr, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dqlsc, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=beta_prec(1:klon,1:klev)
-      CALL histwrite_phy(o_beta_prec, zx_tmp_fi3d)
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! Sorties specifiques a la separation thermiques/non thermiques
-       if (iflag_thermals>=1) then
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_lscth(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_lscst(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_lscth(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_lscst(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
-      CALL histwrite_phy(o_plulth, plul_th)
-      CALL histwrite_phy(o_plulst, plul_st)
-      do k=1,klev
-      do i=1,klon
-          if (ptconvth(i,k)) then
-           zx_tmp_fi3d(i,k)=1.
-          else
-           zx_tmp_fi3d(i,k)=0.
-          endif
-      enddo
-      enddo
-      CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
-      do i=1,klon
-           zx_tmp_fi2d(1:klon)=lmax_th(:)
-      enddo
-      CALL histwrite_phy(o_lmaxth, zx_tmp_fi2d)
-      endif ! iflag_thermals>=1
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtvdf, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_diss(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtdis, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dteva, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
-      zpt_conv = 0.
-      where (ptconv) zpt_conv = 1.
-      CALL histwrite_phy(o_ptconv, zpt_conv)
-      CALL histwrite_phy(o_ratqs, ratqs)
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys -
-     $                           d_t_ajsb(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtthe, zx_tmp_fi3d)
-       IF (iflag_thermals>=1) THEN
-! Pour l instant 0 a y reflichir pour les thermiques
-         zx_tmp_fi2d=0. 
-      CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
-      CALL histwrite_phy(o_f_th, fm_therm)
-      CALL histwrite_phy(o_e_th, entr_therm)
-      CALL histwrite_phy(o_w_th, zw2)
-      CALL histwrite_phy(o_q_th, zqasc)
-      CALL histwrite_phy(o_a_th, fraca)
-      CALL histwrite_phy(o_d_th, detr_therm)
-      CALL histwrite_phy(o_f0_th, f0)
-      CALL histwrite_phy(o_zmax_th, zmax_th)
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys -
-     $                           d_q_ajsb(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dqthe, zx_tmp_fi3d)
-      ENDIF !iflag_thermals
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtajs, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY
-      CALL histwrite_phy(o_dtswr, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
-      CALL histwrite_phy(o_dtsw0, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
-      CALL histwrite_phy(o_dtlwr, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
-      CALL histwrite_phy(o_dtlw0, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtec, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_duvdf, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dvvdf, zx_tmp_fi3d)
-       IF (ok_orodr) THEN
-      zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_oro(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
-       ENDIF
-       
-        IF (ok_orolf) THEN
-      zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
-       ENDIF
-       
-      zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
-      
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_lif(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
-      
-       IF (ok_hines) THEN
-      zx_tmp_fi3d(1:klon,1:klev)=d_u_hin(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_duhin, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_v_hin(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dvhin, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
-        ENDIF
-      CALL histwrite_phy(o_rsu, swup)
-      CALL histwrite_phy(o_rsd, swdn)
-      CALL histwrite_phy(o_rlu, lwup)
-      CALL histwrite_phy(o_rld, lwdn)
-      CALL histwrite_phy(o_rsucs, swup0)
-      CALL histwrite_phy(o_rsdcs, swdn0)
-      CALL histwrite_phy(o_rlucs, lwup0)
-      CALL histwrite_phy(o_rldcs, lwdn0)
-      zx_tmp_fi3d(1:klon,1:klev)=d_t(1:klon,1:klev)+
-     $d_t_dyn(1:klon,1:klev)
-      CALL histwrite_phy(o_tnt, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY -
-     $cool(1:klon,1:klev)/RDAY
-      CALL histwrite_phy(o_tntr, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)= (d_t_lsc(1:klon,1:klev)+
-     $                             d_t_eva(1:klon,1:klev)+
-     $                             d_t_vdf(1:klon,1:klev))/pdtphys
-      CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_qx(1:klon,1:klev,ivap)+
-     $d_q_dyn(1:klon,1:klev)
-      CALL histwrite_phy(o_tnhus, zx_tmp_fi3d)
-      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys+
-     $                           d_q_eva(1:klon,1:klev)/pdtphys
-      CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d)
-      CALL histwrite_phy(o_evu, coefm(:,:,is_ave))
-      zx_tmp_fi3d(1:klon,1:klev)=q_seri(1:klon,1:klev)+
-     $                           ql_seri(1:klon,1:klev) 
-      CALL histwrite_phy(o_h2o, zx_tmp_fi3d)
-       if (iflag_con >= 3) then
-             zx_tmp_fi3d(1:klon,1:klev)=-1 * (dnwd(1:klon,1:klev)+
-     $            dnwd0(1:klon,1:klev)) 
-      CALL histwrite_phy(o_mcd, zx_tmp_fi3d)
-             zx_tmp_fi3d(1:klon,1:klev)=upwd(1:klon,1:klev) +
-     $            dnwd(1:klon,1:klev)+ dnwd0(1:klon,1:klev) 
-      CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
-       else if (iflag_con == 2) then
-      CALL histwrite_phy(o_mcd,  pmfd)
-      CALL histwrite_phy(o_dmc,  pmfu + pmfd)
-       end if
-      CALL histwrite_phy(o_ref_liq, ref_liq)
-      CALL histwrite_phy(o_ref_ice, ref_ice)
-      if (RCO2_per.NE.RCO2_act.OR.RCH4_per.NE.RCH4_act.OR.
-     $ RN2O_per.NE.RN2O_act.OR.RCFC11_per.NE.RCFC11_act.OR.
-     $ RCFC12_per.NE.RCFC12_act) THEN
-      zx_tmp_fi2d(1 : klon) = swupp ( 1 : klon, klevp1 )
-      CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = lwupp ( 1 : klon, klevp1 )
-      CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = swup0p ( 1 : klon, klevp1 )
-      CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
-      zx_tmp_fi2d(1 : klon) = lwup0p ( 1 : klon, klevp1 )
-      CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
-      CALL histwrite_phy(o_rsu4co2, swupp)
-      CALL histwrite_phy(o_rlu4co2, lwupp)
-      CALL histwrite_phy(o_rsucs4co2, swup0p)
-      CALL histwrite_phy(o_rlucs4co2, lwup0p)
-      CALL histwrite_phy(o_rsd4co2, swdnp)
-      CALL histwrite_phy(o_rld4co2, lwdnp)
-      CALL histwrite_phy(o_rsdcs4co2, swdn0p)
-      CALL histwrite_phy(o_rldcs4co2, lwdn0p)
-      endif
-        if (nqtot.GE.3) THEN
-         DO iq=3,nqtot
-      CALL histwrite_phy(o_trac(iq-2), qx(:,:,iq))
-         ENDDO
-         DO iq=3,nqtot
-         zx_tmp_fi2d=0.
-         do k=1,klev
-            zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*qx(:,k,iq)
-         enddo
-      CALL histwrite_phy(o_trac_cum(iq-2), zx_tmp_fi2d)
-         ENDDO
-        endif
-!       ENDIF ! clef_files
-
-      DO iff=1,nfiles
-          IF (ok_sync .AND. clef_files(iff)) THEN
-c$OMP MASTER
-              CALL histsync(nid_files(iff))
-c$OMP END MASTER
-          ENDIF
-      END DO
Index: LMDZ5/branches/testing/libf/phylmd/phys_state_var_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phys_state_var_mod.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/phys_state_var_mod.F90	(revision 1864)
@@ -68,6 +68,6 @@
       REAL, ALLOCATABLE, SAVE :: zmax0(:), f0(:) ! 
 !$OMP THREADPRIVATE(zmax0,f0)
-      REAL, ALLOCATABLE, SAVE :: ema_work1(:,:), ema_work2(:,:)
-!$OMP THREADPRIVATE(ema_work1,ema_work2)
+      REAL, ALLOCATABLE, SAVE :: sig1(:,:), w01(:,:)
+!$OMP THREADPRIVATE(sig1,w01)
       REAL, ALLOCATABLE, SAVE :: entr_therm(:,:), fm_therm(:,:)
 !$OMP THREADPRIVATE(entr_therm,fm_therm)
@@ -332,6 +332,6 @@
       REAL,SAVE,ALLOCATABLE :: newsst(:)
 !$OMP THREADPRIVATE(newsst)
-      REAL,SAVE,ALLOCATABLE :: ustar(:,:),u10m(:,:), v10m(:,:)
-!$OMP THREADPRIVATE(ustar,u10m,v10m)
+      REAL,SAVE,ALLOCATABLE :: ustar(:,:),u10m(:,:), v10m(:,:),wstar(:,:)
+!$OMP THREADPRIVATE(ustar,u10m,v10m,wstar)
 !
 ! ok_ade=T -ADE=topswad-topsw
@@ -400,5 +400,5 @@
       ALLOCATE(coefm(klon,klev+1,nbsrf+1))
       ALLOCATE(zmax0(klon), f0(klon))
-      ALLOCATE(ema_work1(klon,klev), ema_work2(klon,klev))
+      ALLOCATE(sig1(klon,klev), w01(klon,klev))
       ALLOCATE(entr_therm(klon,klev), fm_therm(klon,klev+1))
       ALLOCATE(detr_therm(klon,klev))
@@ -508,5 +508,5 @@
       ALLOCATE(rlonPOS(klon))
       ALLOCATE(newsst(klon))
-      ALLOCATE(ustar(klon,nbsrf),u10m(klon,nbsrf), v10m(klon,nbsrf))
+      ALLOCATE(ustar(klon,nbsrf),u10m(klon,nbsrf), v10m(klon,nbsrf),wstar(klon,nbsrf+1))
       ALLOCATE(topswad(klon), solswad(klon))
       ALLOCATE(topswai(klon), solswai(klon))
@@ -536,5 +536,5 @@
       deallocate(ratqs, pbl_tke,coefh,coefm)
       deallocate(zmax0, f0)
-      deallocate(ema_work1, ema_work2)
+      deallocate(sig1, w01)
       deallocate(entr_therm, fm_therm)
       deallocate(detr_therm)
@@ -619,5 +619,5 @@
       deallocate(rlonPOS)
       deallocate(newsst)
-      deallocate(ustar,u10m, v10m)
+      deallocate(ustar,u10m, v10m,wstar)
       deallocate(topswad, solswad)
       deallocate(topswai, solswai)
Index: LMDZ5/branches/testing/libf/phylmd/physiq.F
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/physiq.F	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/physiq.F	(revision 1864)
@@ -29,4 +29,5 @@
       USE phys_state_var_mod ! Variables sauvegardees de la physique
       USE phys_output_var_mod ! Variables pour les ecritures des sorties
+      USE phys_output_write_mod
       USE fonte_neige_mod, ONLY  : fonte_neige_get_vars
       USE phys_output_mod
@@ -44,4 +45,5 @@
       use conf_phys_m, only: conf_phys
       use radlwsw_m, only: radlwsw
+      use phyaqua_mod, only: zenang_an
       USE control_mod
 #ifdef REPROBUS
@@ -49,4 +51,5 @@
 #endif
       USE indice_sol_mod
+      USE phytrac_mod, ONLY : phytrac
 
 !IM stations CFMIP
@@ -173,5 +176,4 @@
       PARAMETER (ok_region=.FALSE.)
 c======================================================================
-      real weak_inversion(klon),dthmin(klon)
       real seuil_inversion
       save seuil_inversion
@@ -184,5 +186,4 @@
       REAL zz,znum,zden
       REAL wmax_th(klon)
-      REAL zmax_th(klon)
       REAL tau_overturning_th(klon)
 
@@ -220,5 +221,5 @@
       REAL u(klon,klev)
       REAL v(klon,klev)
-      REAL t(klon,klev),theta(klon,klev),thetal(klon,klev)
+      REAL t(klon,klev),thetal(klon,klev)
 c thetal: ligne suivante a decommenter si vous avez les fichiers     MPL 20130625
 c fth_fonctions.F90 et parkind1.F90
@@ -227,5 +228,4 @@
       REAL qx(klon,klev,nqtot)
       REAL flxmass_w(klon,klev)
-      REAL omega(klon,klev) ! vitesse verticale en Pa/s
       REAL d_u(klon,klev)
       REAL d_v(klon,klev)
@@ -242,5 +242,4 @@
       real clw(klon,klev),elij(klon,klev,klev)
       real epmlmMm(klon,klev,klev),eplaMm(klon,klev)
-      real wdtrainA(klon,klev),wdtrainM(klon,klev)
 ! RomP <<<
 !IM definition dynamique o_trac dans phys_output_open
@@ -281,6 +280,4 @@
 c
 c
-c prw: precipitable water
-      real prw(klon)
 
       REAL convliq(klon,klev)  ! eau liquide nuageuse convective
@@ -295,6 +292,4 @@
 c flwp, fiwp = Liquid Water Path & Ice Water Path (kg/m2)
 c flwc, fiwc = Liquid Water Content & Ice Water Content (kg/kg)
-      REAL flwp(klon), fiwp(klon)
-      REAL flwc(klon,klev), fiwc(klon,klev)
       REAL flwp_c(klon), fiwp_c(klon)
       REAL flwc_c(klon,klev), fiwc_c(klon,klev)
@@ -302,5 +297,4 @@
       REAL flwc_s(klon,klev), fiwc_s(klon,klev)
 
-      REAL evap_pot(klon,nbsrf)
 
 cIM ISCCP simulator v3.4
@@ -528,10 +522,4 @@
 c$OMP THREADPRIVATE(itap)
 c
-      real slp(klon) ! sea level pressure
-c
-      REAL fevap(klon,nbsrf)
-      REAL fluxlat(klon,nbsrf)
-c
-      REAL qsol(klon)
       REAL,save ::  solarlong0
 c$OMP THREADPRIVATE(solarlong0)
@@ -544,6 +532,4 @@
 c
       INTEGER igwd,idx(klon),itest(klon)
-c
-      REAL agesno(klon,nbsrf)
 c
 c      REAL,allocatable,save :: run_off_lic_0(:)
@@ -565,5 +551,4 @@
 
       REAL mip(klon,klev)  ! mass flux shed by the adiab ascent at each level
-      REAL Vprecip(klon,klev+1)   ! precipitation vertical profile
 c
       REAL wape_prescr, fip_prescr
@@ -589,6 +574,4 @@
 c$OMP THREADPRIVATE(wake_s_min_lsp)
 
-      real ale_wake(klon)
-      real alp_wake(klon)
 
       real ok_wk_lsp(klon)
@@ -609,5 +592,4 @@
       REAL wake_dtPBL(klon,klev)      ! Wake : differential heating (wake - unpertubed) PBL
       REAL wake_dqPBL(klon,klev)      ! Wake : differential moistening (wake - unpertubed) PBL
-      REAL wake_omg(klon,klev)        ! Wake : velocity difference (wake - unpertubed)
       REAL wake_ddeltat(klon,klev),wake_ddeltaq(klon,klev)
       REAL wake_dp_deltomg(klon,klev) ! Wake : gradient vertical de wake_omg
@@ -615,5 +597,4 @@
 c
 cpourquoi y'a pas de save??
-      REAL wake_h(klon)               ! Wake : hauteur de la poche froide
 c
       INTEGER wake_k(klon)            ! Wake sommet
@@ -645,7 +626,5 @@
 cRR:fin declarations poches froides
 c=======================================================================================================
-
-      REAL zw2(klon,klev+1)
-      REAL fraca(klon,klev+1)        
+        
       REAL ztv(klon,klev),ztva(klon,klev)
       REAL zpspsk(klon,klev)
@@ -665,12 +644,6 @@
       real env_tke_max0(klon)                                ! TKE dans l'environnement au LCL 
 
-c---Spectre de thermiques de type 2 au LCL
-      real n2(klon),s2(klon)
-      real ale_bl_stat(klon)
-
 c---D\'eclenchement stochastique
       integer :: tau_trig(klon)
-      real proba_notrig(klon)
-      real random_notrig(klon)
 
 c--------Statistical Boundary Layer Closure: ALP_BL--------
@@ -680,10 +653,4 @@
       real env_tke_max(klon,klev)                            ! Profil de TKE dans l'environnement
 
-c---Fermeture statistique
-      real alp_bl_det(klon)                                     ! ALP d\'terministe du thermique unique
-      real alp_bl_fluct_m(klon)                                 ! ALP li\'ee aux fluctuations de flux de masse sous-nuageux
-      real alp_bl_fluct_tke(klon)                               ! ALP li\'ee aux fluctuations d'\'energie cin\'etique sous-nuageuse 
-      real alp_bl_conv(klon)                                    ! ALP li\'ee \`a grande \'echelle
-      real alp_bl_stat(klon)                                    ! ALP totale
 
 ccc fin nrlmd le 10/04/2012
@@ -697,12 +664,8 @@
 c Variables locales:
 c
-      REAL cdragh(klon) ! drag coefficient pour T and Q
-      REAL cdragm(klon) ! drag coefficient pour vent
 cAA
 cAA  Pour phytrac 
       REAL u1(klon)             ! vents dans la premiere couche U
       REAL v1(klon)             ! vents dans la premiere couche V
-
-      REAL zxffonte(klon), zxfqcalving(klon),zxfqfonte(klon)
 
 c@$$      LOGICAL offline           ! Controle du stockage ds "physique"
@@ -713,5 +676,4 @@
 ! RomP >>> 
       REAL beta_prec_fisrt(klon,klev) ! taux de conv de l'eau cond (fisrt)
-      REAL beta_prec(klon,klev)       ! taux de conv de l'eau cond (utilise)
 ! RomP <<<
       INTEGER       :: iii
@@ -722,23 +684,7 @@
 c
 cIM 050204 END
-      REAL evap(klon), devap(klon) ! evaporation et sa derivee
-      REAL sens(klon), dsens(klon) ! chaleur sensible et sa derivee
-
-      REAL bils(klon) ! bilan de chaleur au sol
-
-      REAL wfbilo(klon,nbsrf) ! bilan d'eau, pour chaque
-C                             ! type de sous-surface et pondere par la fraction
-      REAL wfbils(klon,nbsrf) ! bilan de chaleur au sol, pour chaque
-C                             ! type de sous-surface et pondere par la fraction
-      REAL slab_wfbils(klon)  ! bilan de chaleur au sol pour le cas de slab, sur les points d'ocean
-
-      REAL fder(klon)         
-      REAL ve(klon) ! integr. verticale du transport meri. de l'energie
-      REAL vq(klon) ! integr. verticale du transport meri. de l'eau
-      REAL ue(klon) ! integr. verticale du transport zonal de l'energie
-      REAL uq(klon) ! integr. verticale du transport zonal de l'eau
-c
-      REAL frugs(klon,nbsrf)
-      REAL zxrugs(klon) ! longueur de rugosite
+      REAL devap(klon) ! evaporation et sa derivee
+      REAL dsens(klon) ! chaleur sensible et sa derivee
+
 c
 c Conditions aux limites
@@ -804,13 +750,7 @@
       REAL diafra(klon,klev)  ! fraction nuageuse
       REAL cldliq(klon,klev)  ! eau liquide nuageuse
-      REAL cldfra(klon,klev)  ! fraction nuageuse
-      REAL cldtau(klon,klev)  ! epaisseur optique
-      REAL cldemi(klon,klev)  ! emissivite infrarouge
 c
 CXXX PB 
       REAL fluxq(klon,klev, nbsrf)   ! flux turbulent d'humidite
-      REAL fluxt(klon,klev, nbsrf)   ! flux turbulent de chaleur
-      REAL fluxu(klon,klev, nbsrf)   ! flux turbulent de vitesse u
-      REAL fluxv(klon,klev, nbsrf)   ! flux turbulent de vitesse v
 c
       REAL zxfluxt(klon, klev)
@@ -818,8 +758,5 @@
       REAL zxfluxu(klon, klev)
       REAL zxfluxv(klon, klev)
-CXXX
-c
-      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
@@ -834,9 +771,7 @@
       REAL conv_q(klon,klev) ! convergence de l'humidite (kg/kg/s)
       REAL conv_t(klon,klev) ! convergence de la temperature(K/s)
-c
-      REAL cldl(klon),cldm(klon),cldh(klon) !nuages bas, moyen et haut
-      REAL cldt(klon),cldq(klon) !nuage total, eau liquide integree
-c
-      REAL zxtsol(klon), zxqsurf(klon), zxsnow(klon), zxfluxlat(klon)
+
+c
+      REAL zxsnow(klon)
       REAL zxsnow_dummy(klon)
 c
@@ -857,6 +792,5 @@
       REAL t_coup
       PARAMETER (t_coup=234.0)
-c
-      REAL zphi(klon,klev)
+
 cym A voir plus tard !!
 cym      REAL zx_relief(iim,jjmp1)
@@ -864,18 +798,12 @@
 c
 c Grandeurs de sorties
-      REAL s_pblh(klon), s_lcl(klon), s_capCL(klon)
-      REAL s_oliqCL(klon), s_cteiCL(klon), s_pblt(klon)
-      REAL s_therm(klon), s_trmb1(klon), s_trmb2(klon)
+      REAL s_capCL(klon)
+      REAL s_oliqCL(klon), s_cteiCL(klon)
+      REAL s_trmb1(klon), s_trmb2(klon)
       REAL s_trmb3(klon)
 cKE43
 c Variables locales pour la convection de K. Emanuel (sb):
-c
-      REAL upwd(klon,klev)      ! saturated updraft mass flux
-      REAL dnwd(klon,klev)      ! saturated downdraft mass flux
-      REAL dnwd0(klon,klev)     ! unsaturated downdraft mass flux
+
       REAL tvp(klon,klev)       ! virtual temp of lifted parcel
-      REAL plcl(klon)           ! Lifting Condensation Level
-      REAL plfc(klon)           ! Level of Free Convection
-      REAL wbeff(klon)          ! saturated updraft velocity at LFC
       CHARACTER*40 capemaxcels  !max(CAPE)
 
@@ -902,5 +830,4 @@
 c eva: evaporation de l'eau liquide nuageuse
 c vdf: couche limite (Vertical DiFfusion)
-      REAL rneb(klon,klev)
 
 ! tendance nulles
@@ -914,13 +841,7 @@
 cIM 081204 END
 c
-      REAL pmfu(klon,klev), pmfd(klon,klev)
       REAL pen_u(klon,klev), pen_d(klon,klev)
       REAL pde_u(klon,klev), pde_d(klon,klev)
       INTEGER kcbot(klon), kctop(klon), kdtop(klon)
-      REAL pmflxr(klon,klev+1), pmflxs(klon,klev+1)
-      REAL prfl(klon,klev+1), psfl(klon,klev+1)
-c
-      REAL rain_lsc(klon)
-      REAL snow_lsc(klon)
 c
       REAL ratqsc(klon,klev)
@@ -935,5 +856,4 @@
       logical ok_newmicro
       save ok_newmicro
-      real ref_liq(klon,klev), ref_ice(klon,klev)
 c$OMP THREADPRIVATE(ok_newmicro)
       save fact_cldcon,facttemps
@@ -973,8 +893,5 @@
 c Variables locales pour effectuer les appels en serie
 c
-      REAL zx_rh(klon,klev)
 cIM RH a 2m (la surface)
-      REAL rh2m(klon), qsat2m(klon)
-      REAL tpot(klon), tpote(klon)
       REAL Lheat
 
@@ -1091,16 +1008,11 @@
       REAL ZRCPD
 c-jld ec_conser
-      REAL t2m(klon,nbsrf)  ! temperature a 2m
       REAL q2m(klon,nbsrf)  ! humidite a 2m
 
 cIM: t2m, q2m, ustar, u10m, v10m et t2mincels, t2maxcels
-      REAL zt2m(klon), zq2m(klon)             !temp., hum. 2m moyenne s/ 1 maille
-      REAL zustar(klon),zu10m(klon), zv10m(klon)  ! u* et vents a 10m moyennes s/1 maille
       CHARACTER*40 t2mincels, t2maxcels       !t2m min., t2m max
       CHARACTER*40 tinst, tave, typeval
       REAL cldtaupi(klon,klev)  ! Cloud optical thickness for pre-industrial (pi) aerosols
 
-      REAL re(klon, klev)       ! Cloud droplet effective radius
-      REAL fl(klon, klev)  ! denominator of re
 
       REAL re_top(klon), fl_top(klon) ! CDR at top of liquid water clouds
@@ -1228,6 +1140,5 @@
 ! Utilise notamment en 1D mais peut etre active egalement en 3D
 ! en imposant la valeur de igout.
-c======================================================================
-
+c======================================================================d
       if (prt_level.ge.1) then
           igout=klon/2+1/klon
@@ -1250,15 +1161,4 @@
 
 c======================================================================
-
-cym => necessaire pour iflag_con != 2    
-      pmfd(:,:) = 0.
-      pen_u(:,:) = 0.
-      pen_d(:,:) = 0.
-      pde_d(:,:) = 0.
-      pde_u(:,:) = 0.
-      aam=0.
-
-      torsfc=0.
-      forall (k=1: llm) zmasse(:, k) = (paprs(:, k)-paprs(:, k+1)) / rg
 
       if (first) then 
@@ -1301,4 +1201,17 @@
 
       endif  ! first
+
+cym => necessaire pour iflag_con != 2    
+      pmfd(:,:) = 0.
+      pen_u(:,:) = 0.
+      pen_d(:,:) = 0.
+      pde_d(:,:) = 0.
+      pde_u(:,:) = 0.
+      aam=0.
+
+      torsfc=0.
+      forall (k=1: llm) zmasse(:, k) = (paprs(:, k)-paprs(:, k+1)) / rg
+
+
 
        modname = 'physiq'
@@ -1600,5 +1513,5 @@
        call phys_output_open(rlon,rlat,nCFMIP,tabijGCM,
      &                       iGCM,jGCM,lonGCM,latGCM,
-     &                       jjmp1,nlevSTD,clevSTD,
+     &                       jjmp1,nlevSTD,clevSTD,rlevSTD,
      &                       nbteta, ctetaSTD, dtime,ok_veget,
      &                       type_ocean,iflag_pbl,ok_mensuel,ok_journe,
@@ -1606,16 +1519,13 @@
      &                       read_climoz, phys_out_filestations,
      &                       new_aod, aerosol_couple,
-     &                       flag_aerosol_strat )
+     &                       flag_aerosol_strat, pdtphys, paprs, pphis, 
+     &                       pplay, lmax_th, ptconv, ptconvth, ivap, 
+     &                       d_t, qx, d_qx, zmasse, ok_sync)
 c$OMP END MASTER
 c$OMP BARRIER
 
+#undef histISCCP
 #ifdef histISCCP
 #include "ini_histISCCP.h"
-#endif
-
-#ifdef histNMC
-#include "ini_histhfNMC.h"
-#include "ini_histdayNMC.h"
-#include "ini_histmthNMC.h"
 #endif
 
@@ -1969,6 +1879,13 @@
       DO i = 1, klon
          zlvdcp=RLVTT/RCPD/(1.0+RVTMP2*q_seri(i,k))
-c        zlsdcp=RLSTT/RCPD/(1.0+RVTMP2*q_seri(i,k))
-         zlsdcp=RLVTT/RCPD/(1.0+RVTMP2*q_seri(i,k))
+cjyg<
+c      Attention : Arnaud a propose des formules completement differentes
+c                  A verifier !!!
+         zlsdcp=RLSTT/RCPD/(1.0+RVTMP2*q_seri(i,k))
+         IF (iflag_ice_thermo .EQ. 0) THEN
+           zlsdcp=zlvdcp
+         ENDIF 
+c>jyg
+
          zdelta = MAX(0.,SIGN(1.,RTT-t_seri(i,k)))
          zb = MAX(0.0,ql_seri(i,k))
@@ -2083,5 +2000,5 @@
      e     t_seri,    q_seri,    u_seri,  v_seri,   
      e     pplay,     paprs,     pctsrf,            
-     +     ftsol,     falb1,     falb2,   ustar, u10m,   v10m,
+     +     ftsol,falb1,falb2,ustar,u10m,v10m,wstar,
      s     sollwdown, cdragh,    cdragm,  u1,    v1,
      s     albsol1,   albsol2,   sens,    evap,  
@@ -2354,10 +2271,12 @@
                 nbtr_tmp=nbtr
              END IF
-          CALL concvl (iflag_con,iflag_clos,
+cjyg   iflag_con est dans clesphys
+cc          CALL concvl (iflag_con,iflag_clos,
+          CALL concvl (iflag_clos,
      .        dtime,paprs,pplay,t_undi,q_undi,
      .        t_wake,q_wake,wake_s,
      .        u_seri,v_seri,tr_seri,nbtr_tmp,
      .        ALE,ALP,
-     .        ema_work1,ema_work2,
+     .        sig1,w01,
      .        d_t_con,d_q_con,d_u_con,d_v_con,d_tr,
      .        rain_con, snow_con, ibas_con, itop_con, sigd,
@@ -2392,5 +2311,5 @@
      .        paprs,pplay,t_seri,q_seri,
      .        u_seri,v_seri,tr_seri,ntra,
-     .        ema_work1,ema_work2,
+     .        sig1,w01,
      .        d_t_con,d_q_con,d_u_con,d_v_con,d_tr,
      .        rain_con, snow_con, ibas_con, itop_con,
@@ -2856,5 +2775,6 @@
      .           frac_impa, frac_nucl, beta_prec_fisrt,
      .           prfl, psfl, rhcl, 
-     .           zqasc, fraca,ztv,zpspsk,ztla,zthl,iflag_cldcon )
+     .           zqasc, fraca,ztv,zpspsk,ztla,zthl,iflag_cldcon,
+     .           iflag_ice_thermo)
 
       WHERE (rain_lsc < 0) rain_lsc = 0.
@@ -3729,7 +3649,8 @@
      I     paprs,    pplay,     pmfu,     pmfd,
      I     pen_u,    pde_u,     pen_d,    pde_d,
-     I     cdragh,   coefh(:,:,is_ave),     fm_therm, entr_therm,
+     I     cdragh,   coefh(:,:,is_ave),   fm_therm, entr_therm,
      I     u1,       v1,        ftsol,    pctsrf,
-     I     ustar,     u10m,      v10m,
+     I     zustar,   zu10m,     zv10m,
+     I     wstar(:,is_ave),    ale_bl,         ale_wake,
      I     rlat,     rlon,
      I     frac_impa,frac_nucl, beta_prec_fisrt,beta_prec,
@@ -4031,5 +3952,13 @@
       endif
 
-#include "phys_output_write_new.h"
+
+!On effectue les sorties:
+
+      CALL phys_output_write(itap, pdtphys, paprs, pphis,               &
+     &                  pplay, lmax_th, aerosol_couple,                 &
+     &                  ok_ade, ok_aie, ivap, new_aod, ok_sync,         &
+     &                  ptconv, read_climoz, clevSTD, freq_moyNMC,      &
+     &                  ptconvth, d_t, qx, d_qx, zmasse,                &
+     &                  flag_aerosol_strat)
 
 
@@ -4038,10 +3967,4 @@
 #ifdef histISCCP
 #include "write_histISCCP.h"
-#endif
-
-#ifdef histNMC
-#include "write_histhfNMC.h"
-#include "write_histdayNMC.h"
-#include "write_histmthNMC.h"
 #endif
 
Index: LMDZ5/branches/testing/libf/phylmd/phytrac.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phytrac.F90	(revision 1796)
+++ 	(revision )
@@ -1,701 +1,0 @@
-!$Id $
-
-SUBROUTINE phytrac(                            &
-     nstep,     julien,   gmtime,   debutphy,  &
-     lafin,     pdtphys,  u, v,     t_seri,    &
-     paprs,     pplay,    pmfu,     pmfd,      &
-     pen_u,     pde_u,    pen_d,    pde_d,     &
-     cdragh,    coefh,    fm_therm, entr_therm,&
-     yu1,       yv1,      ftsol,    pctsrf,    &
-     ustar,     u10m,      v10m,               &
-     xlat,      xlon,                          &
-     frac_impa,frac_nucl,beta_fisrt,beta_v1,   &
-     presnivs,  pphis,    pphi,     albsol,    &
-     sh,        rh,       cldfra,   rneb,      &
-     diafra,    cldliq,   itop_con, ibas_con,  &
-     pmflxr,    pmflxs,   prfl,     psfl,      &
-     da,        phi,      mp,       upwd,      &
-     phi2,      d1a,      dam,      sij,       &   ! RomP
-     wdtrainA,  wdtrainM, sigd,     clw,elij,  &   ! RomP 
-     evap,      ep,       epmlmMm,  eplaMm,    &   ! RomP
-     dnwd,      aerosol_couple,     flxmass_w, &
-     tau_aero,  piz_aero,  cg_aero, ccm,       &
-     rfname,                                   &
-     d_tr_dyn,                                 &   ! RomP
-     tr_seri)         
-!
-!======================================================================
-! Auteur(s) FH
-! Objet: Moniteur general des tendances traceurs
-! Modification R. Pilon 01 janvier 2012 transport+scavenging KE scheme : cvltr
-! Modification R. Pilon 10 octobre 2012 large scale scavenging incloud_scav + bc_scav
-!======================================================================
-
-  USE ioipsl
-  USE phys_cal_mod, only : hour
-  USE phys_output_mod, only : convers_timesteps
-  USE dimphy
-  USE infotrac
-  USE mod_grid_phy_lmdz
-  USE mod_phys_lmdz_para
-  USE comgeomphy
-  USE iophy
-  USE traclmdz_mod
-  USE tracinca_mod
-  USE tracreprobus_mod
-  USE control_mod
-  USE indice_sol_mod
-
-  IMPLICIT NONE
-
-  INCLUDE "YOMCST.h"
-  INCLUDE "dimensions.h"
-  INCLUDE "clesphys.h"
-  INCLUDE "temps.h"
-  INCLUDE "paramet.h"
-  INCLUDE "thermcell.h"
-  INCLUDE "iniprint.h"
-!==========================================================================
-!                   -- ARGUMENT DESCRIPTION --
-!==========================================================================
-
-! Input arguments
-!----------------
-!Configuration grille,temps:
-  INTEGER,INTENT(IN) :: nstep      ! Appel physique
-  INTEGER,INTENT(IN) :: julien     ! Jour julien
-  REAL,INTENT(IN)    :: gmtime     ! Heure courante
-  REAL,INTENT(IN)    :: pdtphys    ! Pas d'integration pour la physique (seconde)
-  LOGICAL,INTENT(IN) :: debutphy   ! le flag de l'initialisation de la physique
-  LOGICAL,INTENT(IN) :: lafin      ! le flag de la fin de la physique
-  
-  REAL,DIMENSION(klon),INTENT(IN) :: xlat    ! latitudes pour chaque point 
-  REAL,DIMENSION(klon),INTENT(IN) :: xlon    ! longitudes pour chaque point 
-!
-!Physique: 
-!--------
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: t_seri  ! Temperature
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: u       ! variable not used 
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: v       ! variable not used 
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: sh      ! humidite specifique
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: rh      ! humidite relative
-  REAL,DIMENSION(klon,klev+1),INTENT(IN) :: paprs   ! pression pour chaque inter-couche (en Pa)
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: pplay   ! pression pour le mileu de chaque couche (en Pa)
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: pphi    ! geopotentiel
-  REAL,DIMENSION(klon),INTENT(IN)        :: pphis
-  REAL,DIMENSION(klev),INTENT(IN)        :: presnivs 
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldliq  ! eau liquide nuageuse
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldfra  ! fraction nuageuse (tous les nuages)
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: diafra  ! fraction nuageuse (convection ou stratus artificiels)
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: rneb    ! fraction nuageuse (grande echelle)
-!
-  REAL                                   :: ql_incl ! contenu en eau liquide nuageuse dans le nuage ! ql_incl=oliq/rneb
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: beta_fisrt ! taux de conversion de l'eau cond (de fisrtilp)
-  REAL,DIMENSION(klon,klev),INTENT(out)  :: beta_v1    ! -- (originale version)
-
-!
-  INTEGER,DIMENSION(klon),INTENT(IN)     :: itop_con
-  INTEGER,DIMENSION(klon),INTENT(IN)     :: ibas_con
-  REAL,DIMENSION(klon),INTENT(IN)        :: albsol  ! albedo surface
-!
-!Dynamique
-!--------
-  REAL,DIMENSION(klon,klev,nbtr),INTENT(IN)    :: d_tr_dyn
-!
-!Convection:
-!----------
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: pmfu  ! flux de masse dans le panache montant
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: pmfd  ! flux de masse dans le panache descendant
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: pen_u ! flux entraine dans le panache montant
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: pde_u ! flux detraine dans le panache montant
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: pen_d ! flux entraine dans le panache descendant
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: pde_d ! flux detraine dans le panache descendant
-
-!...Tiedke     
-  REAL,DIMENSION(klon,klev+1),INTENT(IN)   :: pmflxr, pmflxs ! Flux precipitant de pluie, neige aux interfaces [convection]
-  REAL,DIMENSION(klon,klev+1),INTENT(IN)   :: prfl, psfl ! Flux precipitant de pluie, neige aux interfaces [large-scale]
-
-  LOGICAL,INTENT(IN)                       :: aerosol_couple
-  REAL,DIMENSION(klon,klev),INTENT(IN)     :: flxmass_w
-  REAL,DIMENSION(klon,klev,9,2),INTENT(IN) :: tau_aero
-  REAL,DIMENSION(klon,klev,9,2),INTENT(IN) :: piz_aero
-  REAL,DIMENSION(klon,klev,9,2),INTENT(IN) :: cg_aero
-  CHARACTER(len=4),DIMENSION(9),INTENT(IN) :: rfname 
-  REAL,DIMENSION(klon,klev,2),INTENT(IN)   :: ccm 
-!... K.Emanuel
-  REAL,DIMENSION(klon,klev),INTENT(IN)     :: da
-  REAL,DIMENSION(klon,klev,klev),INTENT(IN):: phi
-! RomP >>>
-  REAL,DIMENSION(klon,klev),INTENT(IN)      :: d1a,dam
-  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: phi2
-!
-  REAL,DIMENSION(klon,klev),INTENT(IN)      :: wdtrainA
-  REAL,DIMENSION(klon,klev),INTENT(IN)      :: wdtrainM
-  REAL,DIMENSION(klon),INTENT(IN)           :: sigd
-! ---- RomP flux entraine, detraine et precipitant kerry Emanuel
-  REAL,DIMENSION(klon,klev),INTENT(IN)      :: evap
-  REAL,DIMENSION(klon,klev),INTENT(IN)      :: ep
-  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: sij
-  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: elij
-  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: epmlmMm
-  REAL,DIMENSION(klon,klev),INTENT(IN)      :: eplaMm
-  REAL,DIMENSION(klon,klev),INTENT(IN)      :: clw
-! RomP <<<
-
-!
-  REAL,DIMENSION(klon,klev),INTENT(IN)     :: mp
-  REAL,DIMENSION(klon,klev),INTENT(IN)     :: upwd      ! saturated updraft mass flux
-  REAL,DIMENSION(klon,klev),INTENT(IN)     :: dnwd      ! saturated downdraft mass flux
-!
-!Thermiques:
-!----------
-  REAL,DIMENSION(klon,klev+1),INTENT(IN)   :: fm_therm
-  REAL,DIMENSION(klon,klev),INTENT(IN)     :: entr_therm
-!
-!Couche limite:
-!--------------
-!
-  REAL,DIMENSION(klon),INTENT(IN)      :: cdragh ! coeff drag pour T et Q
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: coefh  ! coeff melange CL (m**2/s)
-  REAL,DIMENSION(klon),INTENT(IN)      :: ustar,u10m,v10m ! u* & vent a 10m (m/s)
-  REAL,DIMENSION(klon),INTENT(IN)      :: yu1    ! vents au premier niveau
-  REAL,DIMENSION(klon),INTENT(IN)      :: yv1    ! vents au premier niveau
-!
-!Lessivage:
-!----------
-!
-! pour le ON-LINE
-!
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: frac_impa ! fraction d'aerosols non impactes
-  REAL,DIMENSION(klon,klev),INTENT(IN) :: frac_nucl ! fraction d'aerosols non nuclees
-
-! Arguments necessaires pour les sources et puits de traceur:
-  REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: ftsol  ! Temperature du sol (surf)(Kelvin)
-  REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: pctsrf ! Pourcentage de sol (nature du sol)
-
-
-! Output argument
-!----------------
-  REAL,DIMENSION(klon,klev,nbtr),INTENT(INOUT) :: tr_seri ! Concentration Traceur [U/KgA]
-  REAL,DIMENSION(klon,klev)                    :: sourceBE 
-!=======================================================================================
-!                        -- LOCAL VARIABLES --
-!=======================================================================================
-
-  INTEGER :: i, k, it
-  INTEGER :: nsplit
-
-!Sources et Reservoirs de traceurs (ex:Radon):
-!--------------------------------------------
-!
-  REAL,DIMENSION(:,:),ALLOCATABLE,SAVE :: source  ! a voir lorsque le flux de surface est prescrit
-!$OMP THREADPRIVATE(source)
-
-!
-!Entrees/Sorties: (cf ini_histrac.h et write_histrac.h)  
-!---------------
-  INTEGER                   :: iiq, ierr
-  INTEGER                   :: nhori, nvert
-  REAL                      :: zsto, zout, zjulian
-  INTEGER,SAVE              :: nid_tra     ! pointe vers le fichier histrac.nc         
-!$OMP THREADPRIVATE(nid_tra)
-  REAL,DIMENSION(klon)      :: zx_tmp_fi2d ! variable temporaire grille physique
-  INTEGER                   :: itau_w      ! pas de temps ecriture = nstep + itau_phy
-  LOGICAL,PARAMETER         :: ok_sync=.TRUE.
-  CHARACTER(len=20),save    :: chtratimestep,chtratimestep_omp
-!$OMP THREADPRIVATE(chtratimestep)
-!
-! Nature du traceur
-!------------------
-  LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: aerosol  ! aerosol(it) = true  => aerosol => lessivage
-!$OMP THREADPRIVATE(aerosol)                        ! aerosol(it) = false => gaz
-  REAL,DIMENSION(klon,klev)             :: delp     ! epaisseur de couche (Pa)
-!
-! Tendances de traceurs (Td) et flux de traceurs:
-!------------------------
-  REAL,DIMENSION(klon,klev)      :: d_tr     ! Td dans l'atmosphere
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_cl  ! Td couche limite/traceur
-  REAL,DIMENSION(klon,nbtr)      :: d_tr_dry ! Td depot sec/traceur (1st layer)  jyg
-  REAL,DIMENSION(klon,nbtr)      :: flux_tr_dry ! depot sec/traceur (surface)    jyg
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_dec                            !RomP
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_cv  ! Td convection/traceur
-! RomP >>>
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_insc
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_bcscav
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_evapls
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_ls
-  REAL,DIMENSION(klon,nbtr)      :: qPrls      !jyg: concentration tra dans pluie LS a la surf.
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_trsp
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_sscav
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_sat
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_uscav
-  REAL,DIMENSION(klon,klev,nbtr) :: qPr,qDi ! concentration tra dans pluie,air descente insaturee
-  REAL,DIMENSION(klon,klev,nbtr) :: qPa,qMel
-  REAL,DIMENSION(klon,klev,nbtr) :: qTrdi,dtrcvMA ! conc traceur descente air insaturee et td convective MA
-  REAL,DIMENSION(klon,klev)      :: Mint
-  REAL,DIMENSION(klon,klev,nbtr) :: zmfd1a
-  REAL,DIMENSION(klon,klev,nbtr) :: zmfdam
-  REAL,DIMENSION(klon,klev,nbtr) :: zmfphi2
-! RomP <<<
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_th  ! Td thermique
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_lessi_impa ! Td du lessivage par impaction
-  REAL,DIMENSION(klon,klev,nbtr) :: d_tr_lessi_nucl ! Td du lessivage par nucleation
-!
-! Physique
-!---------- 
-  REAL,DIMENSION(klon,klev,nbtr) :: flestottr ! flux de lessivage dans chaque couche 
-  REAL,DIMENSION(klon,klev)      :: zmasse    ! densité atmosphérique Kg/m2
-  REAL,DIMENSION(klon,klev)      :: ztra_th
-!PhH
-  REAL,DIMENSION(klon,klev)      :: zrho
-  REAL,DIMENSION(klon,klev)      :: zdz
-  REAL                           :: evaplsc,dx,beta ! variable pour lessivage Genthon
-  REAL,DIMENSION(klon)           :: his_dh          ! ---
-! in-cloud scav variables
-  REAL           :: ql_incloud_ref     ! ref value of in-cloud condensed water content
-  
-!Controles:
-!---------
-  LOGICAL,SAVE :: couchelimite=.TRUE.
-  LOGICAL,SAVE :: convection=.TRUE.
-  LOGICAL,SAVE :: lessivage
-!$OMP THREADPRIVATE(couchelimite,convection,lessivage)
-
-  CHARACTER(len=8),DIMENSION(nbtr) :: solsym
-!RomP >>>
-  INTEGER,SAVE  :: iflag_lscav_omp,iflag_lscav
-  LOGICAL,SAVE  :: convscav_omp,convscav
-!$OMP THREADPRIVATE(iflag_lscav,convscav)
-!RomP <<<
-!######################################################################
-!                    -- INITIALIZATION --
-!######################################################################
-  DO k=1,klev
-     DO i=1,klon
-      sourceBE(i,k)=0.
-      Mint(i,k)=0.
-      zrho(i,k)=0.
-      zdz(i,k)=0.
-     END DO
-  END DO
-
-  DO it=1, nbtr
-   DO k=1,klev
-    DO i=1,klon
-    d_tr_insc(i,k,it)=0.
-    d_tr_bcscav(i,k,it)=0.
-    d_tr_evapls(i,k,it)=0.
-    d_tr_ls(i,k,it)=0.
-    d_tr_cv(i,k,it)=0.
-    d_tr_cl(i,k,it)=0.
-    d_tr_trsp(i,k,it)=0.
-    d_tr_sscav(i,k,it)=0.
-    d_tr_sat(i,k,it)=0.
-    d_tr_uscav(i,k,it)=0.
-    d_tr_lessi_impa(i,k,it)=0.
-    d_tr_lessi_nucl(i,k,it)=0.
-    qDi(i,k,it)=0.
-    qPr(i,k,it)=0.
-    qPa(i,k,it)=0.
-    qMel(i,k,it)=0.
-    qTrdi(i,k,it)=0.
-    dtrcvMA(i,k,it)=0.
-    zmfd1a(i,k,it)=0.
-    zmfdam(i,k,it)=0.
-    zmfphi2(i,k,it)=0.
-    END DO
-   END DO
-  END DO
-  IF (debutphy) THEN
-!!jyg
-!$OMP MASTER
-   chtratimestep_omp='DefFreq'
-   CALL getin('tra_time_step',chtratimestep_omp)
-!$OMP END MASTER
-!$OMP BARRIER
-   chtratimestep=chtratimestep_omp
-   IF (chtratimestep .NE. 'DefFreq') THEN
-     call convers_timesteps(chtratimestep,pdtphys,ecrit_tra)
-   ENDIF
-!RomP >>>
-!
-!Config Key  = convscav
-!Config Desc = Convective scavenging switch: 0=off, 1=on.
-!Config Def  = .false.
-!Config Help = 
-!
-!$OMP MASTER
-  convscav_omp=.false.
-  call getin('convscav', convscav_omp)
-!$OMP END MASTER
-!$OMP BARRIER
-  convscav=convscav_omp
-  print*,'phytrac passage dans routine conv avec lessivage', convscav
-!
-!Config Key  = iflag_lscav
-!Config Desc = Large scale scavenging parametrization: 0=none, 1=old(Genthon92),
-!              2=1+PHeinrich, 3=Reddy_Boucher2004, 4=3+RPilon.
-!Config Def  = 1
-!Config Help = 
-!
-!$OMP MASTER
-  iflag_lscav_omp=1
-  call getin('iflag_lscav', iflag_lscav_omp)
-!$OMP END MASTER
-!$OMP BARRIER
-  iflag_lscav=iflag_lscav_omp
-!
-  SELECT CASE(iflag_lscav)
-  CASE(0)
-   PRINT*, 'Large scale scavenging: none'
-  CASE(1)
-   PRINT*, 'Large scale scavenging: C. Genthon, Tellus(1992), 44B, 371-389'
-  CASE(2)
-   PRINT*, 'Large scale scavenging: C. Genthon, modified P. Heinrich'
-  CASE(3)
-   PRINT*, 'Large scale scavenging: M. Shekkar Reddy and O. Boucher, JGR(2004), 109, D14202'
-  CASE(4)
-   PRINT*, 'Large scale scavenging: Reddy and Boucher, modified R. Pilon'
-  END SELECT
-!RomP <<<
-     WRITE(*,*) 'FIRST TIME IN PHYTRAC : pdtphys(sec) = ',pdtphys,'ecrit_tra (sec) = ',ecrit_tra
-     ALLOCATE( source(klon,nbtr), stat=ierr)
-     IF (ierr /= 0) CALL abort_gcm('phytrac', 'pb in allocation 1',1)
-     
-     ALLOCATE( aerosol(nbtr), stat=ierr)
-     IF (ierr /= 0) CALL abort_gcm('phytrac', 'pb in allocation 2',1)
-     
-
-     ! Initialize module for specific tracers
-     SELECT CASE(type_trac)
-     CASE('lmdz')
-        CALL traclmdz_init(pctsrf, xlat, xlon, ftsol, tr_seri, t_seri, pplay, sh, pdtphys, aerosol, lessivage)
-     CASE('inca')
-        source(:,:)=0.
-        CALL tracinca_init(aerosol,lessivage)
-     CASE('repr')
-        source(:,:)=0.
-     END SELECT
-!
-! Initialize diagnostic output
-! ----------------------------
-#ifdef CPP_IOIPSL
-     INCLUDE "ini_histrac.h"
-#endif
-  END IF ! of IF (debutphy)
-!############################################ END INITIALIZATION #######
-
-  DO k=1,klev
-     DO i=1,klon
-        zmasse(i,k)=(paprs(i,k)-paprs(i,k+1))/rg
-     END DO
-  END DO
-!
-  IF (id_be .GT. 0) THEN
-  DO k=1,klev
-     DO i=1,klon
-        sourceBE(i,k)=srcbe(i,k)       !RomP  -> pour sortie histrac
-     END DO
-  END DO
-  ENDIF
-
-!===============================================================================
-!    -- Do specific treatment according to chemestry model or local LMDZ tracers
-!      
-!===============================================================================
-  SELECT CASE(type_trac)
-  CASE('lmdz')
-     !    -- Traitement des traceurs avec traclmdz
-     CALL traclmdz(nstep, julien, gmtime, pdtphys, t_seri, paprs, pplay, &
-          cdragh,  coefh, yu1, yv1, ftsol, pctsrf, xlat, xlon,couchelimite,sh, &
-          rh, pphi, ustar, u10m, v10m, &
-!!          tr_seri, source, solsym, d_tr_cl, zmasse)                      !RomP
-          tr_seri, source, solsym, d_tr_cl,d_tr_dec, zmasse)               !RomP
-  CASE('inca')
-     !    -- CHIMIE INCA  config_inca = aero or chem --
-
-     CALL tracinca(&
-          nstep,    julien,   gmtime,         lafin,     &
-          pdtphys,  t_seri,   paprs,          pplay,     &
-          pmfu,     ftsol,    pctsrf,         pphis,     &
-          pphi,     albsol,   sh,             rh,        &
-          cldfra,   rneb,     diafra,         cldliq,    &
-          itop_con, ibas_con, pmflxr,         pmflxs,    &
-          prfl,     psfl,     aerosol_couple, flxmass_w, &
-          tau_aero, piz_aero, cg_aero,        ccm,       &
-          rfname,                                        &
-          tr_seri,  source,   solsym)      
-
-  CASE('repr')
-     !   -- CHIMIE REPROBUS --
-
-     CALL tracreprobus(pdtphys, gmtime, debutphy, julien, &
-          presnivs, xlat, xlon, pphis, pphi, &
-          t_seri, pplay, paprs, sh , &
-          tr_seri, solsym)
-     
-  END SELECT
-!======================================================================
-!       -- Calcul de l'effet de la convection --
-!======================================================================
-
-  IF (convection) THEN
-     DO it=1, nbtr
-        IF ( conv_flg(it) == 0 ) CYCLE
-        IF (iflag_con.LT.2) THEN
-           d_tr_cv(:,:,it)=0.
-        ELSE IF (iflag_con.EQ.2) THEN
-!..Tiedke
-           CALL nflxtr(pdtphys, pmfu, pmfd, pen_u, pde_u, pen_d, pde_d, &
-                pplay, paprs, tr_seri(:,:,it), d_tr_cv(:,:,it))
-! RomP >>>                
-        ELSE   
-!..K.Emanuel                  !RomP modif arg
-        if (convscav.and.aerosol(it)) then    ! lessivage convectif pour aerosol
-!
-          CALL cvltr(pdtphys, da, phi,phi2,d1a,dam, mp,ep,              &
-               sigd,sij,clw,elij,epmlmMm,eplaMm,                        &
-               pmflxr,pmflxs,evap,t_seri,wdtrainA,wdtrainM,             &   
-               paprs,it,tr_seri,upwd,dnwd,itop_con,ibas_con,            &
-               d_tr_cv,d_tr_trsp,d_tr_sscav,d_tr_sat,d_tr_uscav,qDi,qPr,&
-               qPa,qMel,qTrdi,dtrcvMA,Mint,                             &
-               zmfd1a,zmfphi2,zmfdam)
-        else  !pas de lessivage convectif ou n'est pas un aerosol
-           CALL cvltrorig(it,pdtphys, da, phi,mp,paprs,pplay,tr_seri,&
-                    upwd,dnwd,d_tr_cv)
-        endif
-        END IF
-! RomP <<<
-
-        DO k = 1, klev
-           DO i = 1, klon        
-              tr_seri(i,k,it) = tr_seri(i,k,it) + d_tr_cv(i,k,it)
-           END DO
-        END DO
-
-        CALL minmaxqfi(tr_seri(:,:,it),0.,1.e33,'convection it = '//solsym(it))
-             
-     END DO ! nbtr
-  END IF ! convection
-
-!======================================================================
-!    -- Calcul de l'effet des thermiques --
-!======================================================================
-
-  DO it=1,nbtr
-     DO k=1,klev
-        DO i=1,klon
-           d_tr_th(i,k,it)=0.
-           tr_seri(i,k,it)=MAX(tr_seri(i,k,it),0.)
-           tr_seri(i,k,it)=MIN(tr_seri(i,k,it),1.e10)
-        END DO
-     END DO
-  END DO
-  
-  IF (iflag_thermals.GT.0) THEN   
-     nsplit=10
-     DO it=1, nbtr
-        DO isplit=1,nsplit
-
-           CALL dqthermcell(klon,klev,pdtphys/nsplit, &
-                fm_therm,entr_therm,zmasse, &
-                tr_seri(1:klon,1:klev,it),d_tr,ztra_th)
-
-           DO k=1,klev
-              DO i=1,klon
-                 d_tr(i,k)=pdtphys*d_tr(i,k)/nsplit
-                 d_tr_th(i,k,it)=d_tr_th(i,k,it)+d_tr(i,k)
-                 tr_seri(i,k,it)=MAX(tr_seri(i,k,it)+d_tr(i,k),0.)
-              END DO
-           END DO
-        END DO ! nsplit
-     END DO ! it
-  END IF ! Thermiques
-
-!======================================================================
-!     -- Calcul de l'effet de la couche limite --
-!======================================================================
-
-  IF (couchelimite) THEN
-
-     DO k = 1, klev
-        DO i = 1, klon
-           delp(i,k) = paprs(i,k)-paprs(i,k+1)
-        END DO
-     END DO
-
-     DO it=1, nbtr
-        
-        IF( pbl_flg(it) /= 0 ) THEN
-        
-           CALL cltrac(pdtphys, coefh,t_seri,       &
-                tr_seri(:,:,it), source(:,it),      &
-                paprs, pplay, delp,                 &
-                d_tr_cl(:,:,it),d_tr_dry(:,it),flux_tr_dry(:,it))
-           
-           DO k = 1, klev
-              DO i = 1, klon
-                 tr_seri(i,k,it) = tr_seri(i,k,it) + d_tr_cl(i,k,it)
-              END DO
-           END DO
-        END IF
-
-     END DO
-     
-  END IF ! couche limite
-
-
-!======================================================================
-!   Calcul de l'effet de la precipitation grande echelle
-!======================================================================
-  IF (lessivage) THEN
-
-   ql_incloud_ref = 10.e-4
-   ql_incloud_ref =  5.e-4
-
-
-! calcul du contenu en eau liquide au sein du nuage
-     ql_incl = ql_incloud_ref
-! choix du lessivage
-!
-  IF (iflag_lscav .EQ. 3 .OR. iflag_lscav .EQ. 4) THEN
-! ********  Olivier Boucher version (3) possibly with modified ql_incl (4)
-!
-   DO it = 1, nbtr
-!  incloud scavenging and removal by large scale rain ! orig : ql_incl was replaced by 0.5e-3 kg/kg
-! the value 0.5e-3 kg/kg is from Giorgi and Chameides (1986), JGR
-! Liu (2001) proposed to use 1.5e-3 kg/kg
-
-    CALL lsc_scav(pdtphys,it,iflag_lscav,ql_incl,prfl,psfl,rneb,beta_fisrt,  &
-                  beta_v1,pplay,paprs,t_seri,tr_seri,d_tr_insc,   &
-                  d_tr_bcscav,d_tr_evapls,qPrls)
-
-!large scale scavenging tendency
-   DO k = 1, klev
-    DO i = 1, klon
-    d_tr_ls(i,k,it)=d_tr_insc(i,k,it)+d_tr_bcscav(i,k,it)+d_tr_evapls(i,k,it)
-    tr_seri(i,k,it)=tr_seri(i,k,it)+d_tr_ls(i,k,it)
-    ENDDO
-   ENDDO
-     CALL minmaxqfi(tr_seri(:,:,it),0.,1.e33,'lsc scav it = '//solsym(it))
-   END DO  !tr
-
- ELSE IF (iflag_lscav .EQ. 2) THEN ! frac_impa, frac_nucl
-! *********   modified  old version
-
-     d_tr_lessi_nucl(:,:,:) = 0. 
-     d_tr_lessi_impa(:,:,:) = 0.
-     flestottr(:,:,:) = 0. 
-! Tendance des aerosols nuclees et impactes 
-     DO it = 1, nbtr
-        IF (aerosol(it)) THEN
-        his_dh(:)=0.
-           DO k = 1, klev
-              DO i = 1, klon
-!PhH
-              zrho(i,k)=pplay(i,k)/t_seri(i,k)/RD
-              zdz(i,k)=(paprs(i,k)-paprs(i,k+1))/zrho(i,k)/RG
-!
-              END DO
-           END DO
-
-          DO k=klev-1, 1, -1
-            DO i=1, klon
-!             d_tr_ls(i,k,it)=tr_seri(i,k,it)*(frac_impa(i,k)*frac_nucl(i,k)-1.)
-             dx=d_tr_ls(i,k,it)
-             his_dh(i)=his_dh(i)-dx*zrho(i,k)*zdz(i,k)/pdtphys !  kg/m2/s
-             evaplsc = prfl(i,k) - prfl(i,k+1) + psfl(i,k) - psfl(i,k+1)
-! Evaporation Partielle -> Liberation Partielle 0.5*evap
-            IF ( evaplsc .LT.0..and.abs(prfl(i,k+1)+psfl(i,k+1)).gt.1.e-10) THEN
-                evaplsc = (-evaplsc)/(prfl(i,k+1)+psfl(i,k+1))
-! evaplsc est donc positif, his_dh(i) est positif
-!--------------  
-             d_tr_evapls(i,k,it)=0.5*evaplsc*(d_tr_lessi_nucl(i,k+1,it) &
-                                  +d_tr_lessi_impa(i,k+1,it))
-!-------------   d_tr_evapls(i,k,it)=-0.5*evaplsc*(d_tr_lsc(i,k+1,it))
-             beta=0.5*evaplsc
-              if ((prfl(i,k)+psfl(i,k)).lt.1.e-10) THEN
-               beta=1.0*evaplsc
-              endif
-            dx=beta*his_dh(i)/zrho(i,k)/zdz(i,k)*pdtphys
-            his_dh(i)=(1.-beta)*his_dh(i)   ! tracer from
-            d_tr_evapls(i,k,it)=dx
-            ENDIF
-            d_tr_ls(i,k,it)=tr_seri(i,k,it)*(frac_impa(i,k)*frac_nucl(i,k)-1.) &
-                            +d_tr_evapls(i,k,it)
-
-!--------------
-                 d_tr_lessi_nucl(i,k,it) = d_tr_lessi_nucl(i,k,it) +    &
-                      ( 1 - frac_nucl(i,k) )*tr_seri(i,k,it)
-                 d_tr_lessi_impa(i,k,it) = d_tr_lessi_impa(i,k,it) +    &
-                      ( 1 - frac_impa(i,k) )*tr_seri(i,k,it)
-!
-! Flux lessivage total 
-                 flestottr(i,k,it) = flestottr(i,k,it) -   &
-                      ( d_tr_lessi_nucl(i,k,it)   +        &
-                      d_tr_lessi_impa(i,k,it) ) *          &
-                      ( paprs(i,k)-paprs(i,k+1) ) /        &
-                      (RG * pdtphys)
-!! Mise a jour des traceurs due a l'impaction,nucleation 
-!                 tr_seri(i,k,it)=tr_seri(i,k,it)*frac_impa(i,k)*frac_nucl(i,k)
-!!  calcul de la tendance liee au lessivage stratiforme
-!                 d_tr_ls(i,k,it)=tr_seri(i,k,it)*&
-!                                (1.-1./(frac_impa(i,k)*frac_nucl(i,k)))
-!--------------
-              END DO
-           END DO
-        END IF
-     END DO
-! *********   end modified old version
-
- ELSE IF (iflag_lscav .EQ. 1) THEN ! frac_impa, frac_nucl
-! *********    old version
-
-     d_tr_lessi_nucl(:,:,:) = 0. 
-     d_tr_lessi_impa(:,:,:) = 0.
-     flestottr(:,:,:) = 0. 
-!=========================
-! LESSIVAGE LARGE SCALE : 
-!=========================
-
-! Tendance des aerosols nuclees et impactes 
-! -----------------------------------------
-     DO it = 1, nbtr
-        IF (aerosol(it)) THEN
-           DO k = 1, klev
-              DO i = 1, klon
-                 d_tr_lessi_nucl(i,k,it) = d_tr_lessi_nucl(i,k,it) +    &
-                      ( 1 - frac_nucl(i,k) )*tr_seri(i,k,it)
-                 d_tr_lessi_impa(i,k,it) = d_tr_lessi_impa(i,k,it) +    &
-                      ( 1 - frac_impa(i,k) )*tr_seri(i,k,it)
-
-!
-! Flux lessivage total 
-! ------------------------------------------------------------
-                 flestottr(i,k,it) = flestottr(i,k,it) -   &
-                      ( d_tr_lessi_nucl(i,k,it)   +        &
-                      d_tr_lessi_impa(i,k,it) ) *          &
-                      ( paprs(i,k)-paprs(i,k+1) ) /        &
-                      (RG * pdtphys)
-!
-! Mise a jour des traceurs due a l'impaction,nucleation 
-! ----------------------------------------------------------------------
-                 tr_seri(i,k,it)=tr_seri(i,k,it)*frac_impa(i,k)*frac_nucl(i,k)
-              END DO
-           END DO
-        END IF
-     END DO
-     
-! *********   end old version
-  ENDIF  !  iflag_lscav . EQ. 1, 2, 3 or 4
-!
-  END IF !  lessivage
-
-!=============================================================
-!   Ecriture des sorties
-!=============================================================
-#ifdef CPP_IOIPSL
-  INCLUDE "write_histrac.h"
-#endif
-
-END SUBROUTINE phytrac
Index: LMDZ5/branches/testing/libf/phylmd/phytrac_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/phytrac_mod.F90	(revision 1864)
+++ LMDZ5/branches/testing/libf/phylmd/phytrac_mod.F90	(revision 1864)
@@ -0,0 +1,759 @@
+!$Id $
+!$Id $
+MODULE phytrac_mod
+!=================================================================================
+! Interface between the LMDZ physical package and tracer computation.
+! Chemistry modules (INCA, Reprobus or the more specific traclmdz routine)
+! are called from phytrac.
+!
+!======================================================================
+! Auteur(s) FH
+! Objet: Moniteur general des tendances traceurs
+!
+! iflag_vdf_trac : Options for activating transport by vertical diffusion :
+!     1. notmal
+!     0. emission is injected in the first layer only, without diffusion
+!    -1  no emission & no diffusion
+! Modification 2013/07/22 : transformed into a module to pass tendencies to
+!     physics outputs. Additional keys for controling activation of sub processes.
+! Modification R. Pilon 10 octobre 2012 large scale scavenging incloud_scav + bc_scav
+! Modification R. Pilon 01 janvier 2012 transport+scavenging KE scheme : cvltr
+!=================================================================================
+
+!
+! Tracer tendencies, for outputs
+!-------------------------------
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_cl  ! Td couche limite/traceur
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_dec                            !RomP
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_cv  ! Td convection/traceur
+! RomP >>>
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_insc
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_bcscav
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_evapls
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_ls
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_trsp
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_sscav
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_sat
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_uscav
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: qPr,qDi ! concentration tra dans pluie,air descente insaturee
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: qPa,qMel
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: qTrdi,dtrcvMA ! conc traceur descente air insaturee et td convective MA
+! RomP <<<
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_th  ! Td thermique
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_lessi_impa ! Td du lessivage par impaction
+  REAL,DIMENSION(:,:,:),ALLOCATABLE,SAVE :: d_tr_lessi_nucl ! Td du lessivage par nucleation
+  REAL,DIMENSION(:,:),ALLOCATABLE,SAVE      :: qPrls      !jyg: concentration tra dans pluie LS a la surf.
+  REAL,DIMENSION(:,:),ALLOCATABLE,SAVE      :: d_tr_dry ! Td depot sec/traceur (1st layer),ALLOCATABLE,SAVE  jyg
+  REAL,DIMENSION(:,:),ALLOCATABLE,SAVE      :: flux_tr_dry ! depot sec/traceur (surface),ALLOCATABLE,SAVE    jyg
+
+!$OMP THREADPRIVATE(qPa,qMel,qTrdi,dtrcvMA,d_tr_th,d_tr_lessi_impa,d_tr_lessi_nucl)
+!$OMP THREADPRIVATE(d_tr_trsp,d_tr_sscav,d_tr_sat,d_tr_uscav,qPr,qDi)
+!$OMP THREADPRIVATE(d_tr_insc,d_tr_bcscav,d_tr_evapls,d_tr_ls,qPrls)
+!$OMP THREADPRIVATE(d_tr,d_tr_cl,d_tr_dry,flux_tr_dry,d_tr_dec,d_tr_cv)
+
+
+CONTAINS
+
+SUBROUTINE phytrac(                            &
+     nstep,     julien,   gmtime,   debutphy,  &
+     lafin,     pdtphys,  u, v,     t_seri,    &
+     paprs,     pplay,    pmfu,     pmfd,      &
+     pen_u,     pde_u,    pen_d,    pde_d,     &
+     cdragh,    coefh,    fm_therm, entr_therm,&
+     yu1,       yv1,      ftsol,    pctsrf,    &
+     ustar,     u10m,      v10m,               &
+     wstar,     ale_bl,      ale_wake,         &
+     xlat,      xlon,                          &
+     frac_impa,frac_nucl,beta_fisrt,beta_v1,   &
+     presnivs,  pphis,    pphi,     albsol,    &
+     sh,        rh,       cldfra,   rneb,      &
+     diafra,    cldliq,   itop_con, ibas_con,  &
+     pmflxr,    pmflxs,   prfl,     psfl,      &
+     da,        phi,      mp,       upwd,      &
+     phi2,      d1a,      dam,      sij,       &   ! RomP
+     wdtrainA,  wdtrainM, sigd,     clw,elij,  &   ! RomP 
+     evap,      ep,       epmlmMm,  eplaMm,    &   ! RomP
+     dnwd,      aerosol_couple,     flxmass_w, &
+     tau_aero,  piz_aero,  cg_aero, ccm,       &
+     rfname,                                   &
+     d_tr_dyn,                                 &   ! RomP
+     tr_seri)         
+!
+!======================================================================
+! Auteur(s) FH
+! Objet: Moniteur general des tendances traceurs
+! Modification R. Pilon 01 janvier 2012 transport+scavenging KE scheme : cvltr
+! Modification R. Pilon 10 octobre 2012 large scale scavenging incloud_scav + bc_scav
+!======================================================================
+
+  USE ioipsl
+  USE phys_cal_mod, only : hour
+  USE dimphy
+  USE infotrac
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  USE comgeomphy
+  USE iophy
+  USE traclmdz_mod
+  USE tracinca_mod
+  USE tracreprobus_mod
+  USE control_mod
+  USE indice_sol_mod
+
+  IMPLICIT NONE
+
+  INCLUDE "YOMCST.h"
+  INCLUDE "dimensions.h"
+  INCLUDE "clesphys.h"
+  INCLUDE "temps.h"
+  INCLUDE "paramet.h"
+  INCLUDE "thermcell.h"
+  INCLUDE "iniprint.h"
+!==========================================================================
+!                   -- ARGUMENT DESCRIPTION --
+!==========================================================================
+
+! Input arguments
+!----------------
+!Configuration grille,temps:
+  INTEGER,INTENT(IN) :: nstep      ! Appel physique
+  INTEGER,INTENT(IN) :: julien     ! Jour julien
+  REAL,INTENT(IN)    :: gmtime     ! Heure courante
+  REAL,INTENT(IN)    :: pdtphys    ! Pas d'integration pour la physique (seconde)
+  LOGICAL,INTENT(IN) :: debutphy   ! le flag de l'initialisation de la physique
+  LOGICAL,INTENT(IN) :: lafin      ! le flag de la fin de la physique
+  
+  REAL,DIMENSION(klon),INTENT(IN) :: xlat    ! latitudes pour chaque point 
+  REAL,DIMENSION(klon),INTENT(IN) :: xlon    ! longitudes pour chaque point 
+!
+!Physique: 
+!--------
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: t_seri  ! Temperature
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: u       ! variable not used 
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: v       ! variable not used 
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: sh      ! humidite specifique
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: rh      ! humidite relative
+  REAL,DIMENSION(klon,klev+1),INTENT(IN) :: paprs   ! pression pour chaque inter-couche (en Pa)
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: pplay   ! pression pour le mileu de chaque couche (en Pa)
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: pphi    ! geopotentiel
+  REAL,DIMENSION(klon),INTENT(IN)        :: pphis
+  REAL,DIMENSION(klev),INTENT(IN)        :: presnivs 
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldliq  ! eau liquide nuageuse
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: cldfra  ! fraction nuageuse (tous les nuages)
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: diafra  ! fraction nuageuse (convection ou stratus artificiels)
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: rneb    ! fraction nuageuse (grande echelle)
+!
+  REAL                                   :: ql_incl ! contenu en eau liquide nuageuse dans le nuage ! ql_incl=oliq/rneb
+  REAL,DIMENSION(klon,klev),INTENT(IN)   :: beta_fisrt ! taux de conversion de l'eau cond (de fisrtilp)
+  REAL,DIMENSION(klon,klev),INTENT(out)  :: beta_v1    ! -- (originale version)
+
+!
+  INTEGER,DIMENSION(klon),INTENT(IN)     :: itop_con
+  INTEGER,DIMENSION(klon),INTENT(IN)     :: ibas_con
+  REAL,DIMENSION(klon),INTENT(IN)        :: albsol  ! albedo surface
+!
+!Dynamique
+!--------
+  REAL,DIMENSION(klon,klev,nbtr),INTENT(IN)    :: d_tr_dyn
+!
+!Convection:
+!----------
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pmfu  ! flux de masse dans le panache montant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pmfd  ! flux de masse dans le panache descendant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pen_u ! flux entraine dans le panache montant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pde_u ! flux detraine dans le panache montant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pen_d ! flux entraine dans le panache descendant
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: pde_d ! flux detraine dans le panache descendant
+
+!...Tiedke     
+  REAL,DIMENSION(klon,klev+1),INTENT(IN)   :: pmflxr, pmflxs ! Flux precipitant de pluie, neige aux interfaces [convection]
+  REAL,DIMENSION(klon,klev+1),INTENT(IN)   :: prfl, psfl ! Flux precipitant de pluie, neige aux interfaces [large-scale]
+
+  LOGICAL,INTENT(IN)                       :: aerosol_couple
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: flxmass_w
+  REAL,DIMENSION(klon,klev,9,2),INTENT(IN) :: tau_aero
+  REAL,DIMENSION(klon,klev,9,2),INTENT(IN) :: piz_aero
+  REAL,DIMENSION(klon,klev,9,2),INTENT(IN) :: cg_aero
+  CHARACTER(len=4),DIMENSION(9),INTENT(IN) :: rfname 
+  REAL,DIMENSION(klon,klev,2),INTENT(IN)   :: ccm 
+!... K.Emanuel
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: da
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN):: phi
+! RomP >>>
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: d1a,dam
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: phi2
+!
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: wdtrainA
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: wdtrainM
+  REAL,DIMENSION(klon),INTENT(IN)           :: sigd
+! ---- RomP flux entraine, detraine et precipitant kerry Emanuel
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: evap
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: ep
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: sij
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: elij
+  REAL,DIMENSION(klon,klev,klev),INTENT(IN) :: epmlmMm
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: eplaMm
+  REAL,DIMENSION(klon,klev),INTENT(IN)      :: clw
+! RomP <<<
+
+!
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: mp
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: upwd      ! saturated updraft mass flux
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: dnwd      ! saturated downdraft mass flux
+!
+!Thermiques:
+!----------
+  REAL,DIMENSION(klon,klev+1),INTENT(IN)   :: fm_therm
+  REAL,DIMENSION(klon,klev),INTENT(IN)     :: entr_therm
+!
+!Couche limite:
+!--------------
+!
+!
+  REAL,DIMENSION(:),INTENT(IN)   :: cdragh          ! (klon) coeff drag pour T et Q
+  REAL,DIMENSION(:,:),INTENT(IN) :: coefh           ! (klon,klev) coeff melange CL (m**2/s)
+  REAL,DIMENSION(:),INTENT(IN)   :: ustar,u10m,v10m ! (klon) u* & vent a 10m (m/s)
+  REAL,DIMENSION(:),INTENT(IN)   :: wstar,ale_bl,ale_wake ! (klon) w* and Avail. Lifting Ener.
+  REAL,DIMENSION(:),INTENT(IN)   :: yu1             ! (klon) vents au premier niveau
+  REAL,DIMENSION(:),INTENT(IN)   :: yv1             ! (klon) vents au premier niveau
+
+!
+!Lessivage:
+!----------
+!
+! pour le ON-LINE
+!
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: frac_impa ! fraction d'aerosols non impactes
+  REAL,DIMENSION(klon,klev),INTENT(IN) :: frac_nucl ! fraction d'aerosols non nuclees
+
+! Arguments necessaires pour les sources et puits de traceur:
+  REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: ftsol  ! Temperature du sol (surf)(Kelvin)
+  REAL,DIMENSION(klon,nbsrf),INTENT(IN) :: pctsrf ! Pourcentage de sol (nature du sol)
+
+
+! Output argument
+!----------------
+  REAL,DIMENSION(klon,klev,nbtr),INTENT(INOUT) :: tr_seri ! Concentration Traceur [U/KgA]
+  REAL,DIMENSION(klon,klev)                    :: sourceBE 
+!=======================================================================================
+!                        -- LOCAL VARIABLES --
+!=======================================================================================
+
+  INTEGER :: i, k, it
+  INTEGER :: nsplit
+
+!Sources et Reservoirs de traceurs (ex:Radon):
+!--------------------------------------------
+!
+  REAL,DIMENSION(:,:),ALLOCATABLE,SAVE :: source  ! a voir lorsque le flux de surface est prescrit
+!$OMP THREADPRIVATE(source)
+
+!
+!Entrees/Sorties: (cf ini_histrac.h et write_histrac.h)  
+!---------------
+  INTEGER                   :: iiq, ierr
+  INTEGER                   :: nhori, nvert
+  REAL                      :: zsto, zout, zjulian
+  INTEGER,SAVE              :: nid_tra     ! pointe vers le fichier histrac.nc         
+!$OMP THREADPRIVATE(nid_tra)
+  REAL,DIMENSION(klon)      :: zx_tmp_fi2d ! variable temporaire grille physique
+  INTEGER                   :: itau_w      ! pas de temps ecriture = nstep + itau_phy
+  LOGICAL,PARAMETER         :: ok_sync=.TRUE.
+
+!
+! Nature du traceur
+!------------------
+  LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: aerosol  ! aerosol(it) = true  => aerosol => lessivage
+!$OMP THREADPRIVATE(aerosol)                        ! aerosol(it) = false => gaz
+  REAL,DIMENSION(klon,klev)             :: delp     ! epaisseur de couche (Pa)
+!
+! Tendances de traceurs (Td) et flux de traceurs:
+!------------------------
+  REAL,DIMENSION(klon,klev)      :: d_tr     ! Td dans l'atmosphere
+  REAL,DIMENSION(klon,klev)      :: Mint
+  REAL,DIMENSION(klon,klev,nbtr) :: zmfd1a
+  REAL,DIMENSION(klon,klev,nbtr) :: zmfdam
+  REAL,DIMENSION(klon,klev,nbtr) :: zmfphi2
+! Physique
+!---------- 
+  REAL,DIMENSION(klon,klev,nbtr) :: flestottr ! flux de lessivage dans chaque couche 
+  REAL,DIMENSION(klon,klev)      :: zmasse    ! densité atmosphérique Kg/m2
+  REAL,DIMENSION(klon,klev)      :: ztra_th
+!PhH
+  REAL,DIMENSION(klon,klev)      :: zrho
+  REAL,DIMENSION(klon,klev)      :: zdz
+  REAL                           :: evaplsc,dx,beta ! variable pour lessivage Genthon
+  REAL,DIMENSION(klon)           :: his_dh          ! ---
+! in-cloud scav variables
+  REAL           :: ql_incloud_ref     ! ref value of in-cloud condensed water content
+  
+!Controles:
+!---------
+  INTEGER,SAVE :: iflag_vdf_trac,iflag_con_trac,iflag_the_trac
+  INTEGER,SAVE  :: iflag_con_trac_omp, iflag_vdf_trac_omp,iflag_the_trac_omp
+!$OMP THREADPRIVATE(iflag_vdf_trac,iflag_con_trac,iflag_the_trac)
+
+  LOGICAL,SAVE :: lessivage
+!$OMP THREADPRIVATE(lessivage)
+
+  CHARACTER(len=8),DIMENSION(nbtr) :: solsym
+!RomP >>>
+  INTEGER,SAVE  :: iflag_lscav_omp,iflag_lscav
+  LOGICAL,SAVE  :: convscav_omp,convscav
+!$OMP THREADPRIVATE(iflag_lscav)
+!$OMP THREADPRIVATE(convscav)
+!RomP <<<
+!######################################################################
+!                    -- INITIALIZATION --
+!######################################################################
+IF (debutphy) THEN
+ALLOCATE(d_tr_cl(klon,klev,nbtr),d_tr_dry(klon,nbtr))
+ALLOCATE(flux_tr_dry(klon,nbtr),d_tr_dec(klon,klev,nbtr),d_tr_cv(klon,klev,nbtr))
+ALLOCATE(d_tr_insc(klon,klev,nbtr),d_tr_bcscav(klon,klev,nbtr))
+ALLOCATE(d_tr_evapls(klon,klev,nbtr),d_tr_ls(klon,klev,nbtr))
+ALLOCATE(qPrls(klon,nbtr),d_tr_trsp(klon,klev,nbtr))
+ALLOCATE(d_tr_sscav(klon,klev,nbtr),d_tr_sat(klon,klev,nbtr))
+ALLOCATE(d_tr_uscav(klon,klev,nbtr),qPr(klon,klev,nbtr),qDi(klon,klev,nbtr))
+ALLOCATE(qPa(klon,klev,nbtr),qMel(klon,klev,nbtr))
+ALLOCATE(qTrdi(klon,klev,nbtr),dtrcvMA(klon,klev,nbtr))
+ALLOCATE(d_tr_th(klon,klev,nbtr))
+ALLOCATE(d_tr_lessi_impa(klon,klev,nbtr),d_tr_lessi_nucl(klon,klev,nbtr))
+ENDIF
+
+  DO k=1,klev
+     DO i=1,klon
+      sourceBE(i,k)=0.
+      Mint(i,k)=0.
+      zrho(i,k)=0.
+      zdz(i,k)=0.
+     END DO
+  END DO
+
+  DO it=1, nbtr
+   DO k=1,klev
+    DO i=1,klon
+    d_tr_insc(i,k,it)=0.
+    d_tr_bcscav(i,k,it)=0.
+    d_tr_evapls(i,k,it)=0.
+    d_tr_ls(i,k,it)=0.
+    d_tr_cv(i,k,it)=0.
+    d_tr_cl(i,k,it)=0.
+    d_tr_trsp(i,k,it)=0.
+    d_tr_sscav(i,k,it)=0.
+    d_tr_sat(i,k,it)=0.
+    d_tr_uscav(i,k,it)=0.
+    d_tr_lessi_impa(i,k,it)=0.
+    d_tr_lessi_nucl(i,k,it)=0.
+    qDi(i,k,it)=0.
+    qPr(i,k,it)=0.
+    qPa(i,k,it)=0.
+    qMel(i,k,it)=0.
+    qTrdi(i,k,it)=0.
+    dtrcvMA(i,k,it)=0.
+    zmfd1a(i,k,it)=0.
+    zmfdam(i,k,it)=0.
+    zmfphi2(i,k,it)=0.
+    END DO
+   END DO
+  END DO
+  IF (debutphy) THEN
+!!jyg
+!$OMP BARRIER
+   ecrit_tra=86400. ! frequence de stokage en dur
+                    ! obsolete car remplace par des ecritures dans phys_output_write
+!RomP >>>
+!
+!Config Key  = convscav
+!Config Desc = Convective scavenging switch: 0=off, 1=on.
+!Config Def  = .false.
+!Config Help = 
+!
+!$OMP MASTER
+  convscav_omp=.false.
+  call getin('convscav', convscav_omp)
+  iflag_vdf_trac_omp=1
+  call getin('iflag_vdf_trac', iflag_vdf_trac_omp)
+  iflag_con_trac_omp=1
+  call getin('iflag_con_trac', iflag_con_trac_omp)
+  iflag_the_trac_omp=1
+  call getin('iflag_the_trac', iflag_the_trac_omp)
+!$OMP END MASTER
+!$OMP BARRIER
+  convscav=convscav_omp
+  iflag_vdf_trac=iflag_vdf_trac_omp
+  iflag_con_trac=iflag_con_trac_omp
+  iflag_the_trac=iflag_the_trac_omp
+  print*,'phytrac passage dans routine conv avec lessivage', convscav
+!
+!Config Key  = iflag_lscav
+!Config Desc = Large scale scavenging parametrization: 0=none, 1=old(Genthon92),
+!              2=1+PHeinrich, 3=Reddy_Boucher2004, 4=3+RPilon.
+!Config Def  = 1
+!Config Help = 
+!
+!$OMP MASTER
+  iflag_lscav_omp=1
+  call getin('iflag_lscav', iflag_lscav_omp)
+!$OMP END MASTER
+!$OMP BARRIER
+  iflag_lscav=iflag_lscav_omp
+!
+  SELECT CASE(iflag_lscav)
+  CASE(0)
+   PRINT*, 'Large scale scavenging: none'
+  CASE(1)
+   PRINT*, 'Large scale scavenging: C. Genthon, Tellus(1992), 44B, 371-389'
+  CASE(2)
+   PRINT*, 'Large scale scavenging: C. Genthon, modified P. Heinrich'
+  CASE(3)
+   PRINT*, 'Large scale scavenging: M. Shekkar Reddy and O. Boucher, JGR(2004), 109, D14202'
+  CASE(4)
+   PRINT*, 'Large scale scavenging: Reddy and Boucher, modified R. Pilon'
+  END SELECT
+!RomP <<<
+     WRITE(*,*) 'FIRST TIME IN PHYTRAC : pdtphys(sec) = ',pdtphys,'ecrit_tra (sec) = ',ecrit_tra
+     ALLOCATE( source(klon,nbtr), stat=ierr)
+     IF (ierr /= 0) CALL abort_gcm('phytrac', 'pb in allocation 1',1)
+     
+     ALLOCATE( aerosol(nbtr), stat=ierr)
+     IF (ierr /= 0) CALL abort_gcm('phytrac', 'pb in allocation 2',1)
+     
+
+     ! Initialize module for specific tracers
+     SELECT CASE(type_trac)
+     CASE('lmdz')
+        CALL traclmdz_init(pctsrf, xlat, xlon, ftsol, tr_seri, t_seri, pplay, sh, pdtphys, aerosol, lessivage)
+     CASE('inca')
+        source(:,:)=0.
+        CALL tracinca_init(aerosol,lessivage)
+     CASE('repr')
+        source(:,:)=0.
+     END SELECT
+!
+! Initialize diagnostic output
+! ----------------------------
+#ifdef CPP_IOIPSL
+!     INCLUDE "ini_histrac.h"
+#endif
+  END IF ! of IF (debutphy)
+!############################################ END INITIALIZATION #######
+
+  DO k=1,klev
+     DO i=1,klon
+        zmasse(i,k)=(paprs(i,k)-paprs(i,k+1))/rg
+     END DO
+  END DO
+!
+  IF (id_be .GT. 0) THEN
+  DO k=1,klev
+     DO i=1,klon
+        sourceBE(i,k)=srcbe(i,k)       !RomP  -> pour sortie histrac
+     END DO
+  END DO
+  ENDIF
+
+!===============================================================================
+!    -- Do specific treatment according to chemestry model or local LMDZ tracers
+!      
+!===============================================================================
+  SELECT CASE(type_trac)
+  CASE('lmdz')
+     !    -- Traitement des traceurs avec traclmdz
+     CALL traclmdz(nstep, julien, gmtime, pdtphys, t_seri, paprs, pplay, &
+          cdragh,  coefh, yu1, yv1, ftsol, pctsrf, xlat, xlon,iflag_vdf_trac>=0,sh, &
+           rh, pphi, ustar, wstar, ale_bl, ale_wake,  u10m, v10m, &
+           tr_seri, source, solsym, d_tr_cl,d_tr_dec, zmasse)               !RomP
+
+  CASE('inca')
+     !    -- CHIMIE INCA  config_inca = aero or chem --
+
+     CALL tracinca(&
+          nstep,    julien,   gmtime,         lafin,     &
+          pdtphys,  t_seri,   paprs,          pplay,     &
+          pmfu,     ftsol,    pctsrf,         pphis,     &
+          pphi,     albsol,   sh,             rh,        &
+          cldfra,   rneb,     diafra,         cldliq,    &
+          itop_con, ibas_con, pmflxr,         pmflxs,    &
+          prfl,     psfl,     aerosol_couple, flxmass_w, &
+          tau_aero, piz_aero, cg_aero,        ccm,       &
+          rfname,                                        &
+          tr_seri,  source,   solsym)      
+
+  CASE('repr')
+     !   -- CHIMIE REPROBUS --
+
+     CALL tracreprobus(pdtphys, gmtime, debutphy, julien, &
+          presnivs, xlat, xlon, pphis, pphi, &
+          t_seri, pplay, paprs, sh , &
+          tr_seri, solsym)
+     
+  END SELECT
+!======================================================================
+!       -- Calcul de l'effet de la convection --
+!======================================================================
+
+  IF (iflag_con_trac==1) THEN
+     DO it=1, nbtr
+        IF ( conv_flg(it) == 0 ) CYCLE
+        IF (iflag_con.LT.2) THEN
+           d_tr_cv(:,:,it)=0.
+        ELSE IF (iflag_con.EQ.2) THEN
+!..Tiedke
+           CALL nflxtr(pdtphys, pmfu, pmfd, pen_u, pde_u, pen_d, pde_d, &
+                pplay, paprs, tr_seri(:,:,it), d_tr_cv(:,:,it))
+! RomP >>>                
+        ELSE   
+!..K.Emanuel                  !RomP modif arg
+        if (convscav.and.aerosol(it)) then    ! lessivage convectif pour aerosol
+!
+          CALL cvltr(pdtphys, da, phi,phi2,d1a,dam, mp,ep,              &
+               sigd,sij,clw,elij,epmlmMm,eplaMm,                        &
+               pmflxr,pmflxs,evap,t_seri,wdtrainA,wdtrainM,             &   
+               paprs,it,tr_seri,upwd,dnwd,itop_con,ibas_con,            &
+               d_tr_cv,d_tr_trsp,d_tr_sscav,d_tr_sat,d_tr_uscav,qDi,qPr,&
+               qPa,qMel,qTrdi,dtrcvMA,Mint,                             &
+               zmfd1a,zmfphi2,zmfdam)
+        else  !pas de lessivage convectif ou n'est pas un aerosol
+           CALL cvltrorig(it,pdtphys, da, phi,mp,paprs,pplay,tr_seri,&
+                    upwd,dnwd,d_tr_cv)
+        endif
+        END IF
+! RomP <<<
+
+        DO k = 1, klev
+           DO i = 1, klon        
+              tr_seri(i,k,it) = tr_seri(i,k,it) + d_tr_cv(i,k,it)
+           END DO
+        END DO
+
+        CALL minmaxqfi(tr_seri(:,:,it),0.,1.e33,'convection it = '//solsym(it))
+             
+     END DO ! nbtr
+  END IF ! convection
+
+!======================================================================
+!    -- Calcul de l'effet des thermiques --
+!======================================================================
+
+  DO it=1,nbtr
+     DO k=1,klev
+        DO i=1,klon
+           d_tr_th(i,k,it)=0.
+           tr_seri(i,k,it)=MAX(tr_seri(i,k,it),0.)
+           tr_seri(i,k,it)=MIN(tr_seri(i,k,it),1.e10)
+        END DO
+     END DO
+  END DO
+  
+  IF (iflag_thermals.GT.0.AND.iflag_the_trac>0) THEN   
+     nsplit=10
+     DO it=1, nbtr
+        DO isplit=1,nsplit
+
+           CALL dqthermcell(klon,klev,pdtphys/nsplit, &
+                fm_therm,entr_therm,zmasse, &
+                tr_seri(1:klon,1:klev,it),d_tr,ztra_th)
+
+           DO k=1,klev
+              DO i=1,klon
+                 d_tr(i,k)=pdtphys*d_tr(i,k)/nsplit
+                 d_tr_th(i,k,it)=d_tr_th(i,k,it)+d_tr(i,k)
+                 tr_seri(i,k,it)=MAX(tr_seri(i,k,it)+d_tr(i,k),0.)
+              END DO
+           END DO
+        END DO ! nsplit
+     END DO ! it
+  END IF ! Thermiques
+
+!======================================================================
+!     -- Calcul de l'effet de la couche limite --
+!======================================================================
+
+  DO k = 1, klev
+     DO i = 1, klon
+        delp(i,k) = paprs(i,k)-paprs(i,k+1)
+     END DO
+  END DO
+
+  IF (iflag_vdf_trac==1) THEN
+     DO it=1, nbtr
+        if (prt_level > 20) write(lunout,*)'trac pbl ',it,pbl_flg(it)
+        IF( pbl_flg(it) /= 0 ) THEN
+           CALL cltrac(pdtphys, coefh,t_seri,       &
+                tr_seri(:,:,it), source(:,it),      &
+                paprs, pplay, delp,                 &
+                d_tr_cl(:,:,it),d_tr_dry(:,it),flux_tr_dry(:,it))
+           tr_seri(:,:,it)=tr_seri(:,:,it)+d_tr_cl(:,:,it)
+        END IF
+     END DO
+  ELSE IF (iflag_vdf_trac==0) THEN
+!   Injection of source in the first model layer
+    DO it=1,nbtr
+       d_tr_cl(:,1,it)=source(:,it)*rg/delp(:,1)*pdtphys
+    ENDDO
+    tr_seri(:,1,it)=tr_seri(:,1,it)+d_tr_cl(:,1,it)
+    d_tr_cl(:,2:klev,1:nbtr)=0.
+  ELSE IF (iflag_vdf_trac==-1) THEN
+    d_tr_cl=0.
+  ELSE
+    CALL abort_gcm('iflag_vdf_trac', 'cas non prevu',1)
+  END IF ! couche limite
+
+
+
+!======================================================================
+!   Calcul de l'effet de la precipitation grande echelle
+!======================================================================
+  IF (lessivage) THEN
+
+   ql_incloud_ref = 10.e-4
+   ql_incloud_ref =  5.e-4
+
+
+! calcul du contenu en eau liquide au sein du nuage
+     ql_incl = ql_incloud_ref
+! choix du lessivage
+!
+  IF (iflag_lscav .EQ. 3 .OR. iflag_lscav .EQ. 4) THEN
+! ********  Olivier Boucher version (3) possibly with modified ql_incl (4)
+!
+   DO it = 1, nbtr
+!  incloud scavenging and removal by large scale rain ! orig : ql_incl was replaced by 0.5e-3 kg/kg
+! the value 0.5e-3 kg/kg is from Giorgi and Chameides (1986), JGR
+! Liu (2001) proposed to use 1.5e-3 kg/kg
+
+    CALL lsc_scav(pdtphys,it,iflag_lscav,ql_incl,prfl,psfl,rneb,beta_fisrt,  &
+                  beta_v1,pplay,paprs,t_seri,tr_seri,d_tr_insc,   &
+                  d_tr_bcscav,d_tr_evapls,qPrls)
+
+!large scale scavenging tendency
+   DO k = 1, klev
+    DO i = 1, klon
+    d_tr_ls(i,k,it)=d_tr_insc(i,k,it)+d_tr_bcscav(i,k,it)+d_tr_evapls(i,k,it)
+    tr_seri(i,k,it)=tr_seri(i,k,it)+d_tr_ls(i,k,it)
+    ENDDO
+   ENDDO
+     CALL minmaxqfi(tr_seri(:,:,it),0.,1.e33,'lsc scav it = '//solsym(it))
+   END DO  !tr
+
+ ELSE IF (iflag_lscav .EQ. 2) THEN ! frac_impa, frac_nucl
+! *********   modified  old version
+
+     d_tr_lessi_nucl(:,:,:) = 0. 
+     d_tr_lessi_impa(:,:,:) = 0.
+     flestottr(:,:,:) = 0. 
+! Tendance des aerosols nuclees et impactes 
+     DO it = 1, nbtr
+        IF (aerosol(it)) THEN
+        his_dh(:)=0.
+           DO k = 1, klev
+              DO i = 1, klon
+!PhH
+              zrho(i,k)=pplay(i,k)/t_seri(i,k)/RD
+              zdz(i,k)=(paprs(i,k)-paprs(i,k+1))/zrho(i,k)/RG
+!
+              END DO
+           END DO
+
+          DO k=klev-1, 1, -1
+            DO i=1, klon
+!             d_tr_ls(i,k,it)=tr_seri(i,k,it)*(frac_impa(i,k)*frac_nucl(i,k)-1.)
+             dx=d_tr_ls(i,k,it)
+             his_dh(i)=his_dh(i)-dx*zrho(i,k)*zdz(i,k)/pdtphys !  kg/m2/s
+             evaplsc = prfl(i,k) - prfl(i,k+1) + psfl(i,k) - psfl(i,k+1)
+! Evaporation Partielle -> Liberation Partielle 0.5*evap
+            IF ( evaplsc .LT.0..and.abs(prfl(i,k+1)+psfl(i,k+1)).gt.1.e-10) THEN
+                evaplsc = (-evaplsc)/(prfl(i,k+1)+psfl(i,k+1))
+! evaplsc est donc positif, his_dh(i) est positif
+!--------------  
+             d_tr_evapls(i,k,it)=0.5*evaplsc*(d_tr_lessi_nucl(i,k+1,it) &
+                                  +d_tr_lessi_impa(i,k+1,it))
+!-------------   d_tr_evapls(i,k,it)=-0.5*evaplsc*(d_tr_lsc(i,k+1,it))
+             beta=0.5*evaplsc
+              if ((prfl(i,k)+psfl(i,k)).lt.1.e-10) THEN
+               beta=1.0*evaplsc
+              endif
+            dx=beta*his_dh(i)/zrho(i,k)/zdz(i,k)*pdtphys
+            his_dh(i)=(1.-beta)*his_dh(i)   ! tracer from
+            d_tr_evapls(i,k,it)=dx
+            ENDIF
+            d_tr_ls(i,k,it)=tr_seri(i,k,it)*(frac_impa(i,k)*frac_nucl(i,k)-1.) &
+                            +d_tr_evapls(i,k,it)
+
+!--------------
+                 d_tr_lessi_nucl(i,k,it) = d_tr_lessi_nucl(i,k,it) +    &
+                      ( 1 - frac_nucl(i,k) )*tr_seri(i,k,it)
+                 d_tr_lessi_impa(i,k,it) = d_tr_lessi_impa(i,k,it) +    &
+                      ( 1 - frac_impa(i,k) )*tr_seri(i,k,it)
+!
+! Flux lessivage total 
+                 flestottr(i,k,it) = flestottr(i,k,it) -   &
+                      ( d_tr_lessi_nucl(i,k,it)   +        &
+                      d_tr_lessi_impa(i,k,it) ) *          &
+                      ( paprs(i,k)-paprs(i,k+1) ) /        &
+                      (RG * pdtphys)
+!! Mise a jour des traceurs due a l'impaction,nucleation 
+!                 tr_seri(i,k,it)=tr_seri(i,k,it)*frac_impa(i,k)*frac_nucl(i,k)
+!!  calcul de la tendance liee au lessivage stratiforme
+!                 d_tr_ls(i,k,it)=tr_seri(i,k,it)*&
+!                                (1.-1./(frac_impa(i,k)*frac_nucl(i,k)))
+!--------------
+              END DO
+           END DO
+        END IF
+     END DO
+! *********   end modified old version
+
+ ELSE IF (iflag_lscav .EQ. 1) THEN ! frac_impa, frac_nucl
+! *********    old version
+
+     d_tr_lessi_nucl(:,:,:) = 0. 
+     d_tr_lessi_impa(:,:,:) = 0.
+     flestottr(:,:,:) = 0. 
+!=========================
+! LESSIVAGE LARGE SCALE : 
+!=========================
+
+! Tendance des aerosols nuclees et impactes 
+! -----------------------------------------
+     DO it = 1, nbtr
+        IF (aerosol(it)) THEN
+           DO k = 1, klev
+              DO i = 1, klon
+                 d_tr_lessi_nucl(i,k,it) = d_tr_lessi_nucl(i,k,it) +    &
+                      ( 1 - frac_nucl(i,k) )*tr_seri(i,k,it)
+                 d_tr_lessi_impa(i,k,it) = d_tr_lessi_impa(i,k,it) +    &
+                      ( 1 - frac_impa(i,k) )*tr_seri(i,k,it)
+
+!
+! Flux lessivage total 
+! ------------------------------------------------------------
+                 flestottr(i,k,it) = flestottr(i,k,it) -   &
+                      ( d_tr_lessi_nucl(i,k,it)   +        &
+                      d_tr_lessi_impa(i,k,it) ) *          &
+                      ( paprs(i,k)-paprs(i,k+1) ) /        &
+                      (RG * pdtphys)
+!
+! Mise a jour des traceurs due a l'impaction,nucleation 
+! ----------------------------------------------------------------------
+                 tr_seri(i,k,it)=tr_seri(i,k,it)*frac_impa(i,k)*frac_nucl(i,k)
+              END DO
+           END DO
+        END IF
+     END DO
+     
+! *********   end old version
+  ENDIF  !  iflag_lscav . EQ. 1, 2, 3 or 4
+!
+  END IF !  lessivage
+
+!=============================================================
+!   Ecriture des sorties
+!=============================================================
+#ifdef CPP_IOIPSL
+! INCLUDE "write_histrac.h"
+#endif
+
+END SUBROUTINE phytrac
+
+END MODULE
Index: LMDZ5/branches/testing/libf/phylmd/radlwsw_m.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/radlwsw_m.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/radlwsw_m.F90	(revision 1864)
@@ -334,4 +334,5 @@
 !===== iflag_rrtm ================================================
 !      
+    print*,'iflag_rrtm = ', iflag_rrtm
     IF (iflag_rrtm == 0) THEN
        ! Old radiation scheme, used for AR4 runs
Index: LMDZ5/branches/testing/libf/phylmd/readaerosolstrato.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/readaerosolstrato.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/readaerosolstrato.F90	(revision 1864)
@@ -33,4 +33,5 @@
     integer i, k, band, wave
     integer, save :: mth_pre
+!$OMP THREADPRIVATE(mth_pre)
 
     real, allocatable, dimension(:,:), save :: tau_aer_strat
@@ -41,5 +42,4 @@
     real, allocatable:: tauaerstrat_mois(:, :, :)
     real, allocatable:: tauaerstrat_mois_glo(:, :)
-    real, allocatable:: tauaerstrat_mois_glo_bands(:,:,:)
 
 ! For NetCDF:
@@ -61,7 +61,8 @@
     IF (.not.ALLOCATED(tau_aer_strat)) ALLOCATE(tau_aer_strat(klon,klev))
 
+!--only read file if beginning of run or start of new month
+    IF (debut.OR.mth_cur.NE.mth_pre) THEN
+
     IF (is_mpi_root) THEN
-
-    IF (debut.OR.mth_cur.NE.mth_pre) THEN
 
     IF (nbands.NE.2) THEN 
@@ -107,8 +108,7 @@
     ENDIF
 
-    ALLOCATE(tauaerstrat(n_lon, n_lat, n_lev, n_month))
-    ALLOCATE(tauaerstrat_mois(n_lon, n_lat, n_lev))
-    ALLOCATE(tauaerstrat_mois_glo(klon_glo, n_lev))
-    ALLOCATE(tauaerstrat_mois_glo_bands(klon_glo, n_lev,nbands))
+    IF (.not.ALLOCATED(tauaerstrat))          ALLOCATE(tauaerstrat(n_lon, n_lat, n_lev, n_month))
+    IF (.not.ALLOCATED(tauaerstrat_mois))     ALLOCATE(tauaerstrat_mois(n_lon, n_lat, n_lev))
+    IF (.not.ALLOCATED(tauaerstrat_mois_glo)) ALLOCATE(tauaerstrat_mois_glo(klon_glo, n_lev))
 
 !--reading stratospheric AOD at 550 nm
@@ -128,21 +128,23 @@
     CALL grid2dTo1d_glo(tauaerstrat_mois,tauaerstrat_mois_glo)
 
+!    DEALLOCATE(tauaerstrat)
+!    DEALLOCATE(tauaerstrat_mois)
+!    DEALLOCATE(tauaerstrat_mois_glo)
+  
+    ENDIF !--is_mpi_root
+
 !--scatter on all proc
     CALL scatter(tauaerstrat_mois_glo,tau_aer_strat)
 
-    DEALLOCATE(tauaerstrat)
-    DEALLOCATE(tauaerstrat_mois)
-    DEALLOCATE(tauaerstrat_mois_glo)
-  
+!--keep memory of previous month
     mth_pre=mth_cur
 
     ENDIF !--debut ou nouveau mois
 
-    ENDIF !--is_mpi_root
-
 !--total vertical aod at the 5 wavelengths
     DO wave=1, nwave
     DO k=1, klev
-    tausum_aero(:,wave,id_strat)=tausum_aero(:,wave,id_strat)+tau_aer_strat(:,k)*alpha_strat_wave(wave)/alpha_strat_wave(2)
+    tausum_aero(:,wave,id_STRAT)=tausum_aero(:,wave,id_STRAT)+tau_aer_strat(:,k)*alpha_strat_wave(wave)/alpha_strat_wave(2)
+!    tausum_aero(:,wave,id_ASBCM)=tausum_aero(:,wave,id_ASBCM)+tau_aer_strat(:,k)*alpha_strat_wave(wave)/alpha_strat_wave(2)
     ENDDO
     ENDDO
Index: LMDZ5/branches/testing/libf/phylmd/traclmdz_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/traclmdz_mod.F90	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/traclmdz_mod.F90	(revision 1864)
@@ -337,5 +337,5 @@
   SUBROUTINE traclmdz(nstep, julien, gmtime, pdtphys, t_seri, paprs, pplay, &
        cdragh,  coefh, yu1, yv1, ftsol, pctsrf, xlat, xlon, couchelimite, sh, &
-       rh, pphi, ustar, zu10m, zv10m, &
+       rh, pphi, ustar, wstar, ale_bl, ale_wake,  zu10m, zv10m, &
 !!          tr_seri, source, solsym, d_tr_cl, zmasse)                      !RomP
           tr_seri, source, solsym, d_tr_cl,d_tr_dec, zmasse)               !RomP
@@ -385,4 +385,5 @@
     REAL,DIMENSION(klon,klev),INTENT(IN) :: pphi    ! geopotentie
     REAL,DIMENSION(klon),INTENT(IN)      :: ustar   ! ustar (m/s)
+    REAL,DIMENSION(klon),INTENT(IN)      :: wstar,ale_bl,ale_wake   ! wstar (m/s) and Avail. Lifti. Energ.
     REAL,DIMENSION(klon),INTENT(IN)      :: zu10m   ! vent zonal 10m (m/s)
     REAL,DIMENSION(klon),INTENT(IN)      :: zv10m   ! vent zonal 10m (m/s)
Index: LMDZ5/branches/testing/libf/phylmd/write_histdayNMC.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/write_histdayNMC.h	(revision 1796)
+++ 	(revision )
@@ -1,58 +1,0 @@
-!
-! $Header$
-!
-      IF (ok_histNMC(2)) THEN
-c
-       ndex3d = 0
-       itau_w = itau_phy + itap + start_time * day_step / iphysiq
-ccc
-c  Champs interpolles sur des niveaux de pression du NMC
-c
-c     PARAMETER(nout=3) 
-c nout=1 : in=pdtphys,    out=mth
-c nout=2 : in=pdtphys,    out=day
-c nout=3 : in=pdtphys,    out=hf
-ccc
-      IF(lev_histdayNMC.EQ.nlevSTD) THEN
-       CALL histwrite_phy(nid_daynmc,lNMC,"tnondef",itau_w,
-     $tnondef(:,:,2))
-       CALL histwrite_phy(nid_daynmc,lNMC,"ta",itau_w,
-     $twriteSTD(:,:,2))
-       CALL histwrite_phy(nid_daynmc,lNMC,"zg",itau_w,
-     $phiwriteSTD(:,:,2))
-       CALL histwrite_phy(nid_daynmc,lNMC,"hus",itau_w,
-     $qwriteSTD(:,:,2))
-       CALL histwrite_phy(nid_daynmc,lNMC,"hur",itau_w,
-     $rhwriteSTD(:,:,2))
-       CALL histwrite_phy(nid_daynmc,lNMC,"ua",itau_w,
-     $uwriteSTD(:,:,2))
-       CALL histwrite_phy(nid_daynmc,lNMC,"va",itau_w,
-     $vwriteSTD(:,:,2))
-       CALL histwrite_phy(nid_daynmc,lNMC,"wap",itau_w,
-     $wwriteSTD(:,:,2))
-      ELSE IF(lev_histdayNMC.EQ.nlevSTD8) THEN
-       CALL histwrite_phy(nid_daynmc,lNMC,"tnondef",itau_w,
-     $tnondefSTD8)
-       CALL histwrite_phy(nid_daynmc,lNMC,"ta",itau_w,
-     $twriteSTD8)
-       CALL histwrite_phy(nid_daynmc,lNMC,"zg",itau_w,
-     $phiwriteSTD8)
-       CALL histwrite_phy(nid_daynmc,lNMC,"hus",itau_w,
-     $qwriteSTD8)
-       CALL histwrite_phy(nid_daynmc,lNMC,"hur",itau_w,
-     $rhwriteSTD8)
-       CALL histwrite_phy(nid_daynmc,lNMC,"ua",itau_w,
-     $uwriteSTD8)
-       CALL histwrite_phy(nid_daynmc,lNMC,"va",itau_w,
-     $vwriteSTD8)
-       CALL histwrite_phy(nid_daynmc,lNMC,"wap",itau_w,
-     $wwriteSTD8)
-      ENDIF
-c
-      if (ok_sync) then
-c$OMP MASTER
-        call histsync(nid_daynmc)
-c$OMP END MASTER
-      endif
-c
-      ENDIF ! (ok_histNMC(2)) THEN
Index: LMDZ5/branches/testing/libf/phylmd/write_histhfNMC.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/write_histhfNMC.h	(revision 1796)
+++ 	(revision )
@@ -1,90 +1,0 @@
-!
-! $Header$
-!
-      IF (ok_histNMC(3)) THEN
-c
-       ndex3d = 0
-       itau_w = itau_phy + itap + start_time * day_step / iphysiq
-ccc
-c  Champs interpolles sur des niveaux de pression du NMC
-c
-c     PARAMETER(nout=3) 
-c nout=1 : in=pdtphys,    out=mth
-c nout=2 : in=pdtphys,    out=day
-c nout=3 : in=pdtphys,    out=hf
-ccc
-      CALL histwrite_phy(nid_hfnmc,lNMC,"tnondef",itau_w,
-     $tnondef(:,:,3))
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"ta",itau_w,
-     $twriteSTD3)
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"zg",itau_w,
-     $phiwriteSTD3)
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"hus",itau_w,
-     $qwriteSTD3)
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"hur",itau_w,
-     $rhwriteSTD3)
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"ua",itau_w,
-     $uwriteSTD3)
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"va",itau_w,
-     $vwriteSTD3)
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"wap",itau_w,
-     $wwriteSTD3)
-c
-       IF (1.EQ.0) THEN
-c
-       DO k=1, nlevSTD
-        DO i=1, klon
-         IF(tnondef(i,k,3).NE.missing_val) THEN
-          zx_tmp_fiNC(i,k) = (100.*tnondef(i,k,3))/freq_moyNMC(3)
-         ELSE
-          zx_tmp_fiNC(i,k) = missing_val
-         ENDIF
-        ENDDO
-       ENDDO !k=1, nlevSTD
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"psbg",itau_w,
-     $zx_tmp_fiNC)
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"uv",itau_w,
-     $uvsumSTD(:,:,3))
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"vq",itau_w,
-     $vqsumSTD(:,:,3))
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"vT",itau_w,
-     $vTsumSTD(:,:,3))
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"wq",itau_w,
-     $wqsumSTD(:,:,3))
-c
-      CALL histwrite_phy(nid_hfnmc,lNMC,"vphi",itau_w,
-     $vphisumSTD(:,:,3))
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"wT",itau_w,
-     $wTsumSTD(:,:,3))
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"uxu",itau_w,
-     $u2sumSTD(:,:,3))
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"vxv",itau_w,
-     $v2sumSTD(:,:,3))
-c
-       CALL histwrite_phy(nid_hfnmc,lNMC,"TxT",itau_w,
-     $T2sumSTD(:,:,3))
-c
-       ENDIF !(1.EQ.0) THEN
-c
-      if (ok_sync) then
-c$OMP MASTER
-        call histsync(nid_hfnmc)
-c$OMP END MASTER
-      endif
-c
-      ENDIF !      (ok_histNMC(3)) THEN
Index: LMDZ5/branches/testing/libf/phylmd/write_histmthNMC.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/write_histmthNMC.h	(revision 1796)
+++ 	(revision )
@@ -1,113 +1,0 @@
-!
-! $Id$
-!
-      IF (ok_histNMC(1)) THEN
-c
-       ndex3d = 0
-       itau_w = itau_phy + itap + start_time * day_step / iphysiq
-ccc
-c  Champs interpolles sur des niveaux de pression du NMC
-c
-c     PARAMETER(nout=3) 
-c nout=1 : in=pdtphys,    out=mth
-c nout=2 : in=pdtphys,    out=day
-c nout=3 : in=pdtphys,    out=hf
-ccc
-      CALL histwrite_phy(nid_mthnmc,lNMC,"tnondef",itau_w,
-     $tnondef(:,:,1))
-c
-      CALL histwrite_phy(nid_mthnmc,lNMC,"ta",itau_w,
-     $twriteSTD(:,:,1))
-c
-      CALL histwrite_phy(nid_mthnmc,lNMC,"zg",itau_w,
-     $phiwriteSTD(:,:,1))
-c
-       CALL histwrite_phy(nid_mthnmc,lNMC,"hus",itau_w,
-     $qwriteSTD(:,:,1))
-c
-       CALL histwrite_phy(nid_mthnmc,lNMC,"hur",itau_w,
-     $rhwriteSTD(:,:,1))
-c
-       CALL histwrite_phy(nid_mthnmc,lNMC,"ua",itau_w,
-     $uwriteSTD(:,:,1))
-c
-       CALL histwrite_phy(nid_mthnmc,lNMC,"va",itau_w,
-     $vwriteSTD(:,:,1))
-c
-       CALL histwrite_phy(nid_mthnmc,lNMC,"wap",itau_w,
-     $wwriteSTD(:,:,1))
-c
-       DO k=1, nlevSTD
-        DO i=1, klon
-         IF(tnondef(i,k,1).NE.missing_val) THEN
-          zx_tmp_fiNC(i,k) = (100.*tnondef(i,k,1))/freq_moyNMC(1)
-         ELSE
-          zx_tmp_fiNC(i,k) = missing_val
-         ENDIF
-        ENDDO
-       ENDDO !k=1, nlevSTD
-c
-      CALL histwrite_phy(nid_mthnmc,lNMC,"psbg",itau_w,
-     $zx_tmp_fiNC)
-c
-      CALL histwrite_phy(nid_mthnmc,lNMC,"uv",itau_w,
-     $uvsumSTD(:,:,1))
-c
-      CALL histwrite_phy(nid_mthnmc,lNMC,"vq",itau_w,
-     $vqsumSTD(:,:,1))
-c
-      CALL histwrite_phy(nid_mthnmc,lNMC,"vT",itau_w,
-     $vTsumSTD(:,:,1))
-c
-      CALL histwrite_phy(nid_mthnmc,lNMC,"wq",itau_w,
-     $wqsumSTD(:,:,1))
-c
-      CALL histwrite_phy(nid_mthnmc,lNMC,"vphi",itau_w,
-     $vphisumSTD(:,:,1))
-c
-       CALL histwrite_phy(nid_mthnmc,lNMC,"wT",itau_w,
-     $wTsumSTD(:,:,1))
-c
-       CALL histwrite_phy(nid_mthnmc,lNMC,"uxu",itau_w,
-     $u2sumSTD(:,:,1))
-c
-       CALL histwrite_phy(nid_mthnmc,lNMC,"vxv",itau_w,
-     $v2sumSTD(:,:,1))
-c
-       CALL histwrite_phy(nid_mthnmc,lNMC,"TxT",itau_w,
-     $T2sumSTD(:,:,1))
-c
-       DO k=1, nlevSTD
-        DO i=1, klon
-         IF(O3sumSTD(i,k,1).NE.missing_val) THEN
-          zx_tmp_fiNC(i,k) = O3sumSTD(i,k,1) * 1.e+9
-         ELSE
-          zx_tmp_fiNC(i,k) = missing_val
-         ENDIF
-        ENDDO
-       ENDDO !k=1, nlevSTD
-       CALL histwrite_phy(nid_mthnmc,lNMC,"tro3",itau_w,
-     $ zx_tmp_fiNC)
-c
-       if (read_climoz == 2) THEN
-       DO k=1, nlevSTD
-        DO i=1, klon
-         IF(O3daysumSTD(i,k,1).NE.missing_val) THEN
-          zx_tmp_fiNC(i,k) = O3daysumSTD(i,k,1) * 1.e+9
-         ELSE
-          zx_tmp_fiNC(i,k) = missing_val
-         ENDIF
-        ENDDO
-       ENDDO !k=1, nlevSTD
-c
-        CALL histwrite_phy(nid_mthnmc,lNMC,"tro3_daylight",
-     $itau_w, zx_tmp_fiNC)
-       endif 
-c
-      if (ok_sync) then
-c$OMP MASTER
-        call histsync(nid_mthnmc)
-c$OMP END MASTER
-      endif
-c
-      ENDIF !(ok_histNMC(1)) THEN
Index: LMDZ5/branches/testing/libf/phylmd/write_histrac.h
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/write_histrac.h	(revision 1796)
+++ LMDZ5/branches/testing/libf/phylmd/write_histrac.h	(revision 1864)
@@ -45,5 +45,5 @@
 
 ! TD COUCHE-LIMITE
-      IF (couchelimite) THEN
+      IF (iflag_vdf_trac>=0) THEN
         CALL histwrite_phy(nid_tra,.FALSE.,"d_tr_cl_"//tname(iiq),itau_w,d_tr_cl(:,:,it))
         CALL histwrite_phy(nid_tra,.FALSE.,"d_tr_dry_"//tname(iiq),itau_w,d_tr_dry(:,it))
