Index: /trunk/LMDZ.GENERIC/libf/phystd/phyetat0_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/phyetat0_mod.F90	(revision 3521)
+++ /trunk/LMDZ.GENERIC/libf/phystd/phyetat0_mod.F90	(revision 3522)
@@ -2,4 +2,8 @@
 
 implicit none
+
+real, save :: tab_cntrl_mod(100)
+
+!$OMP THREADPRIVATE(tab_cntrl_mod)
 
 contains
@@ -50,10 +54,10 @@
   real,intent(out) :: emis(ngrid) ! surface emissivity
   real,intent(out) :: albedo(ngrid,L_NSPECTV) ! albedo of the surface
-  real,intent(out) :: q2(ngrid,nlayer+1) ! 
+  real,intent(out) :: q2(ngrid,nlayer+1) !
   real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface
 ! real co2ice(ngrid) ! co2 ice cover
   real,intent(out) :: cloudfrac(ngrid,nlayer)
   real,intent(out) :: hice(ngrid), totcloudfrac(ngrid)
-  real,intent(out) :: pctsrf_sic(ngrid),tslab(ngrid,nslay)  
+  real,intent(out) :: pctsrf_sic(ngrid),tslab(ngrid,nslay)
   real,intent(out) :: tsea_ice(ngrid),sea_ice(ngrid)
   real,intent(out) :: rnat(ngrid)
@@ -72,5 +76,5 @@
       INTEGER nid, nvarid
       INTEGER ierr, i, nsrf
-!      integer isoil 
+!      integer isoil
 !      INTEGER length
 !      PARAMETER (length=100)
@@ -86,8 +90,8 @@
       integer :: count
       character(len=30) :: txt ! to store some text
-      
+
       INTEGER :: indextime=1 ! index of selected time, default value=1
       logical :: found
-      
+
       character(len=8) :: modname="phyetat0"
 
@@ -314,5 +318,5 @@
         else
           rnat(ig)=1.
-        endif      
+        endif
       enddo
   endif ! of if (.not.found)
@@ -434,5 +438,5 @@
 endif ! of if (startphy_file)
 
-! Non-orographic gravity waves 
+! Non-orographic gravity waves
 if (startphy_file) then
    call get_field("du_nonoro_gwd",du_nonoro_gwd,found,indextime)
@@ -486,3 +490,37 @@
 end subroutine phyetat0
 
+!======================================================================
+subroutine ini_tab_controle_dyn_xios(idayref)
+
+use comcstfi_mod,        only: g, mugaz, omeg, rad, rcp
+use time_phylmdz_mod,  only: daysec, dtphys
+use mod_grid_phy_lmdz, only: nbp_lon, nbp_lat, nbp_lev
+
+implicit none
+
+integer*4, intent(in) :: idayref ! date (initial date for this run)
+
+integer :: length, l
+parameter (length = 100)
+real    :: tab_cntrl(length) ! run parameters are stored in this array
+
+do l = 1,length
+    tab_cntrl(l) = 0.
+enddo
+tab_cntrl(1)  = real(nbp_lon)
+tab_cntrl(2)  = real(nbp_lat-1)
+tab_cntrl(3)  = real(nbp_lev)
+tab_cntrl(4)  = real(idayref)
+tab_cntrl(5)  = rad
+tab_cntrl(6)  = omeg
+tab_cntrl(7)  = g
+tab_cntrl(8)  = mugaz
+tab_cntrl(9)  = rcp
+tab_cntrl(10) = daysec
+tab_cntrl(11) = dtphys
+
+tab_cntrl_mod = tab_cntrl
+
+end subroutine ini_tab_controle_dyn_xios
+
 end module phyetat0_mod
Index: /trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90	(revision 3521)
+++ /trunk/LMDZ.GENERIC/libf/phystd/physiq_mod.F90	(revision 3522)
@@ -38,5 +38,5 @@
                           igcm_co2_ice, nesp, is_chim, is_condensable,constants_epsi_generic
       use time_phylmdz_mod, only: ecritphy, iphysiq, nday
-      use phyetat0_mod, only: phyetat0
+      use phyetat0_mod, only: phyetat0,tab_cntrl_mod
       use surfini_mod, only: surfini
       use wstats_mod, only: callstats, wstats, mkstats
@@ -90,7 +90,7 @@
       use datafile_mod, only: datadir
       use newton_cooling_hotJ, only: newtcool_MOCHA ! LT, adding for MOCHA protocol
-      
+
 #ifndef MESOSCALE
-      use vertical_layers_mod, only: presnivs, pseudoalt
+      USE vertical_layers_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt
       use mod_phys_lmdz_omp_data, ONLY: is_omp_master
 #else
@@ -113,4 +113,5 @@
       use wxios, only: wxios_context_init, xios_context_finalize
 #endif
+      use write_output_mod, only: write_output
 
       implicit none
@@ -315,5 +316,5 @@
       real zdtsdif(ngrid)     ! Turbdiff/vdifc routines.
       real zdtsurf_hyd(ngrid) ! Hydrol routine.
-      
+
       ! For Thermosphere : (K/s)
       real zdtconduc(ngrid,nlayer)
@@ -462,5 +463,5 @@
       real int_dtaui1(ngrid,nlayer,L_NSPECTI),int_dtauv1(ngrid,nlayer,L_NSPECTV) ! For optical thickness diagnostics.
       real tf, ntf
-      
+
       real net_fluxsurf_lw(ngrid) ! net longwave flux at the surface (for diagnostics only)
 
@@ -468,5 +469,5 @@
 
       real muvar(ngrid,nlayer+1) ! For Runaway Greenhouse 1D study. By RW
-      
+
       ! For fixed variable molar mass
       real, dimension(:),allocatable,save :: p_var
@@ -535,7 +536,7 @@
          zdtlw(:,:) = 0.0
          zdtconduc(:,:) = 0.0
-         
+
 !        Initialize fixed variable mu
-!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
          if(varspec) then
@@ -546,5 +547,5 @@
            mu_var = 0.0
            frac_var = 0.0
-           muvari = 0.0 
+           muvari = 0.0
            dt_file=TRIM(varspec_data)
            open(33,file=dt_file,form='formatted',status='old',iostat=ios)
@@ -557,5 +558,5 @@
              do k=1,nvarlayer
                read(33,*) p_var(k), mu_var(k),frac_var(k,1:ngasmx)
-               !The order of columns in frac_var must correspond to order of molecules gases.def 
+               !The order of columns in frac_var must correspond to order of molecules gases.def
                !The format of your file must be:
                ! pressure(k) molar_mass(k), molar_fraction_of_gas_1(k), molar_fraction_of_gas_2(k),..., molar_fraction_of_gas_ngasmx(k)
@@ -675,5 +676,5 @@
            call ocean_slab_get_vars(ngrid, tslab, tice, sea_ice, flux_g, &
                       dt_hdiff, dt_ekman, dt_gm)
-           
+
          endif ! end of 'ok_slab_ocean'.
 
@@ -1723,9 +1724,9 @@
                dqmoist(1:ngrid,1:nlayer,1:nq)=0.
                dtmoist(1:ngrid,1:nlayer)=0.
-               
+
                ! Moist Convective Adjustment.
                ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                call moistadj_generic(ngrid,nlayer,nq,pt,pq,pdq,pplev,pplay,dtmoist,dqmoist,ptimestep,rneb_man)
-            
+
                pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq)     &
                                                   + dqmoist(1:ngrid,1:nlayer,1:nq)
@@ -1738,9 +1739,9 @@
                   call planetwide_minval(dtmoist(:,:),dtmoist_min)
                   madjdEz(:,:)=cpp*mass(:,:)*dtmoist(:,:)
-                  
+
                   do ig=1,ngrid
                      madjdE(ig) = cpp*SUM(mass(:,:)*dtmoist(:,:))
                   enddo
-                  
+
                   if (is_master) then
                      print*,'In moistadj_generic atmospheric energy change   =',dEtot,' W m-2'
@@ -1753,5 +1754,5 @@
                                          massarea(:,:)*dqmoist(:,:,2)*ptimestep/totarea_planet,dWtot)
                   if (is_master) print*,'In moistadj_generic atmospheric GCS change    =',dWtot,' kg m-2'
-               
+
                endif ! end of 'enertest'
             else
@@ -1997,6 +1998,6 @@
                       tsea_ice, -zdqsdif(:,igcm_h2o_vap), taux, tauy, zmasq)
 
-            call ocean_slab_frac(pctsrf_sic, zmasq) 
-             
+            call ocean_slab_frac(pctsrf_sic, zmasq)
+
             call ocean_slab_get_vars(ngrid, tslab, tice, sea_ice, flux_g, &
                       dt_hdiff, dt_ekman, dt_gm)
@@ -2004,5 +2005,5 @@
 !!!            call ocean_slab_get_vars(ngrid, tslab, tsea_ice, sea_ice, flux_g, &
 !!!                      dt_hdiff, dt_ekman, dt_gm)
-		      
+
 !! sea_ice defines the sea ice thickness in kg/m2
 !! pctsrf_sic defines the percentage of the oceanic grid that is covered by sea ice (between 0 and **almost** 1)
@@ -2398,5 +2399,5 @@
          if (ngrid.ne.1) then
             write(*,*)'PHYSIQ: for physdem ztime_fin =',ztime_fin
-            
+
             if (ok_slab_ocean) then
               ! fetch "ocean variables" to ensure they are stored
@@ -2520,52 +2521,55 @@
 !-----------------------------------------------------------------------------------------------------
 
-      call writediagfi(ngrid,"Ls","solar longitude","deg",0,zls*180./pi)
-      call writediagfi(ngrid,"Lss","sub solar longitude","deg",0,zlss*180./pi)
-      call writediagfi(ngrid,"RA","right ascension","deg",0,right_ascen*180./pi)
-      call writediagfi(ngrid,"Declin","solar declination","deg",0,declin*180./pi)
-      call writediagfi(ngrid,"tsurf","Surface temperature","K",2,tsurf)
-      call writediagfi(ngrid,"ps","Surface pressure","Pa",2,ps)
-      call writediagfi(ngrid,"temp","temperature","K",3,zt)
-      call writediagfi(ngrid,"teta","potential temperature","K",3,zh)
-      call writediagfi(ngrid,"u","Zonal wind","m.s-1",3,zu)
-      call writediagfi(ngrid,"v","Meridional wind","m.s-1",3,zv)
-      call writediagfi(ngrid,"w","Vertical wind","m.s-1",3,pw)
-      call writediagfi(ngrid,"p","Pressure","Pa",3,pplay)
+      call write_output("Ls","solar longitude","deg",zls*180./pi)
+      call write_output("Lss","sub solar longitude","deg",zlss*180./pi)
+      call write_output("RA","right ascension","deg",right_ascen*180./pi)
+      call write_output("Declin","solar declination","deg",declin*180./pi)
+      call write_output("dist_star","dist_star","AU",dist_star)
+
+      call write_output("tsurf","Surface temperature","K",tsurf)
+      call write_output("ps","Surface pressure","Pa",ps)
+      call write_output("emis","Emissivity","",emis)
+      call write_output("temperature","temperature","K",zt)
+      call write_output("teta","potential temperature","K",zh)
+      call write_output("u","Zonal wind","m.s-1",zu)
+      call write_output("v","Meridional wind","m.s-1",zv)
+      call write_output("w","Vertical wind","m.s-1",pw)
+      call write_output("p","Pressure","Pa",pplay)
+      call write_output("omega","omega","Pa/s",omega)
 
 !     Subsurface temperatures
 !        call writediagsoil(ngrid,"tsurf","Surface temperature","K",2,tsurf)
-!        call writediagsoil(ngrid,"temp","temperature","K",3,tsoil)
 
       ! Oceanic layers
       if(ok_slab_ocean) then
-         call writediagfi(ngrid,"pctsrf_sic","pct ice/sea","",2,pctsrf_sic)
-         call writediagfi(ngrid,"tsea_ice","top layer temp, snow/ice","K",2,tsea_ice)
-!         call writediagfi(ngrid,"tice","sea ice temperature","K",2,tice)
-         call writediagfi(ngrid,"sea_ice","sea ice","kg/m2",2,sea_ice)
-         call writediagfi(ngrid,"tslab1","tslab1","K",2,tslab(:,1))
-         call writediagfi(ngrid,"tslab2","tslab2","K",2,tslab(:,2))
-         call writediagfi(ngrid,"dt_hdiff1","dt_hdiff1","W m-2",2,dt_hdiff(:,1))
-         call writediagfi(ngrid,"dt_hdiff2","dt_hdiff2","W m-2",2,dt_hdiff(:,2))
-         call writediagfi(ngrid,"dt_ekman1","dt_ekman1","W m-2",2,dt_ekman(:,1))
-         call writediagfi(ngrid,"dt_ekman2","dt_ekman2","W m-2",2,dt_ekman(:,2))
-         call writediagfi(ngrid,"dt_gm1","dt_gm1","W m-2",2,dt_gm(:,1))
-         call writediagfi(ngrid,"dt_gm2","dt_gm2","W m-2",2,dt_gm(:,2))
-         call writediagfi(ngrid,"rnat","nature of the surface","",2,rnat)
-         call writediagfi(ngrid,"sensibFlux","sensible heat flux","w.m^-2",2,sensibFlux)
-         call writediagfi(ngrid,"latentFlux","latent heat flux","w.m^-2",2,zdqsdif(:,igcm_h2o_vap)*RLVTT)
+         call write_output("pctsrf_sic","pct ice/sea","",pctsrf_sic)
+         call write_output("tsea_ice","top layer temp, snow/ice","K",tsea_ice)
+!         call write_output("tice","sea ice temperature","K",tice)
+         call write_output("sea_ice","sea ice","kg/m2",sea_ice)
+         call write_output("tslab1","tslab1","K",tslab(:,1))
+         call write_output("tslab2","tslab2","K",tslab(:,2))
+         call write_output("dt_hdiff1","dt_hdiff1","W m-2",dt_hdiff(:,1))
+         call write_output("dt_hdiff2","dt_hdiff2","W m-2",dt_hdiff(:,2))
+         call write_output("dt_ekman1","dt_ekman1","W m-2",dt_ekman(:,1))
+         call write_output("dt_ekman2","dt_ekman2","W m-2",dt_ekman(:,2))
+         call write_output("dt_gm1","dt_gm1","W m-2",dt_gm(:,1))
+         call write_output("dt_gm2","dt_gm2","W m-2",dt_gm(:,2))
+         call write_output("rnat","nature of the surface","",rnat)
+         call write_output("sensibFlux","sensible heat flux","w.m^-2",sensibFlux)
+         call write_output("latentFlux","latent heat flux","w.m^-2",zdqsdif(:,igcm_h2o_vap)*RLVTT)
       endif
 
       ! Thermal plume model
       if (calltherm) then
-         call writediagfi(ngrid,'entr','Entrainment','kg m$^{-2}$ s$^{-1}$', 3, entr)
-         call writediagfi(ngrid,'detr','Detrainment','kg m$^{-2}$ s$^{-1}$', 3, detr)
-         call writediagfi(ngrid,'fm','Mass flux','kg m$^{-2}$ s$^{-1}$', 3, fm_bis)
-         call writediagfi(ngrid,'w_plm','Squared vertical velocity','m s$^{-1}$', 3, zw2_bis)
-         call writediagfi(ngrid,'fraca','Updraft fraction','', 3, fraca)
-         call writediagfi(ngrid,"zdttherm","dt due to plumes","K-1 s-1",3,zdttherm) !ALS24
+         call write_output('entr','Entrainment','kg m$^{-2}$ s$^{-1}$', entr)
+         call write_output('detr','Detrainment','kg m$^{-2}$ s$^{-1}$', detr)
+         call write_output('fm','Mass flux','kg m$^{-2}$ s$^{-1}$', fm_bis)
+         call write_output('w_plm','Squared vertical velocity','m s$^{-1}$', zw2_bis)
+         call write_output('fraca','Updraft fraction','', fraca)
+         call write_output("zdttherm","dt due to plumes","K-1 s-1",zdttherm) !ALS24
          IF (tracer) THEN
-            call writediagfi(ngrid,"zdqtherm","dq due to plumes, iq = 1","kg kg-1 s-1",3, &
+            call write_output("zdqtherm","dq due to plumes, iq = 1","kg kg-1 s-1",&
                    zdqtherm(1:ngrid,1:nlayer,1)) !ALS24
-            call writediagfi(ngrid,"zdqtherm2","dq due to plumes; iq = 2","kg kg-1 s-1",3, &
+            call write_output("zdqtherm2","dq due to plumes; iq = 2","kg kg-1 s-1",&
                    zdqtherm(1:ngrid,1:nlayer,2)) !ALS24
          ENDIF
@@ -2574,6 +2578,6 @@
 !        GW non-oro outputs
       if (calllott_nonoro) then
-         call WRITEDIAGFI(ngrid,"dugwno","GW non-oro dU","m/s2", 3,d_u_hin)
-         call WRITEDIAGFI(ngrid,"dvgwno","GW non-oro dV","m/s2", 3,d_v_hin)
+         call write_output("dugwno","GW non-oro dU","m/s2", d_u_hin)
+         call write_output("dvgwno","GW non-oro dV","m/s2", d_v_hin)
       endif
 
@@ -2581,11 +2585,10 @@
       if(callrad.and.(.not.newtonian))then
 
-         call writediagfi(ngrid,"ALB","Surface albedo"," ",2,albedo_equivalent)
-         !call writediagfi(ngrid,"ALB_1st","First Band Surface albedo"," ",2,albedo(:,1))
-         call writediagfi(ngrid,"ISR","incoming stellar rad.","W m-2",2,fluxtop_dn)
-         call writediagfi(ngrid,"ASR","absorbed stellar rad.","W m-2",2,fluxabs_sw)
-         call writediagfi(ngrid,"OLR","outgoing longwave rad.","W m-2",2,fluxtop_lw)
-         call writediagfi(ngrid,"shad","rings"," ", 2, fract)
-
+         call write_output("ALB","Surface albedo"," ",albedo_equivalent)
+         call write_output("ASR","absorbed stellar rad.","W m-2",fluxabs_sw)
+         call write_output("ISR","incoming stellar rad.","W m-2",fluxtop_dn)
+         call write_output("OLR","outgoing longwave rad.","W m-2",fluxtop_lw)
+         call write_output("DYN","dynamical heat input","W m-2",fluxdyn)
+         call write_output("shad","rings"," ", fract)
 !           call writediagfi(ngrid,"ASRcs","absorbed stellar rad (cs).","W m-2",2,fluxabs_sw1)
 !           call writediagfi(ngrid,"OLRcs","outgoing longwave rad (cs).","W m-2",2,fluxtop_lw1)
@@ -2597,11 +2600,8 @@
 
          if(ok_slab_ocean) then
-            call writediagfi(ngrid,"GND","heat flux from ground","W m-2",2,fluxgrdocean)
+            call write_output("GND","heat flux from ground","W m-2",fluxgrdocean)
          else
-            call writediagfi(ngrid,"GND","heat flux from ground","W m-2",2,fluxgrd)
-         endif
-
-         call writediagfi(ngrid,"DYN","dynamical heat input","W m-2",2,fluxdyn)
-
+            call write_output("GND","heat flux from ground","W m-2",fluxgrd)
+         endif
       endif ! end of 'callrad'
 
@@ -2609,38 +2609,30 @@
 
          if (calldifv) then
-
-            call writediagfi(ngrid,"q2","turbulent kinetic energy","J.kg^-1",3,q2)
-            call writediagfi(ngrid,"sensibFlux","sensible heat flux","w.m^-2",2,sensibFlux)
-
+            call write_output("q2","turbulent kinetic energy","J.kg^-1",q2)
+            call write_output("sensibFlux","sensible heat flux","w.m^-2",sensibFlux)
 !             call writediagfi(ngrid,"dEzdiff","turbulent diffusion heating (-sensible flux)","w.m^-2",3,dEzdiff)
 !             call writediagfi(ngrid,"dEdiff","integrated turbulent diffusion heating (-sensible flux)","w.m^-2",2,dEdiff)
 !             call writediagfi(ngrid,"dEdiffs","In TurbDiff (correc rad+latent heat) surf nrj change","w.m^-2",2,dEdiffs)
-
          endif
 
          if (corrk) then
-            call writediagfi(ngrid,"dEzradsw","radiative heating","w.m^-2",3,dEzradsw)
-            call writediagfi(ngrid,"dEzradlw","radiative heating","w.m^-2",3,dEzradlw)
+            call write_output("dEzradsw","radiative heating","w.m^-2",dEzradsw)
+            call write_output("dEzradlw","radiative heating","w.m^-2",dEzradlw)
          endif
 
          if(watercond) then
-
-            call writediagfi(ngrid,"lscaledE","heat from largescale","W m-2",2,lscaledE)
+            call write_output("lscaledE","heat from largescale","W m-2",lscaledE)
             if ((.not.calltherm).and.moistadjustment) then
-               call writediagfi(ngrid,"madjdE","heat from moistadj","W m-2",2,madjdE)
+               call write_output("madjdE","heat from moistadj","W m-2",madjdE)
             endif
-            call writediagfi(ngrid,"qsatatm","atm qsat"," ",3,qsat)
-
-!            call writediagfi(ngrid,"lscaledEz","heat from largescale","W m-2",3,lscaledEz)
-!            call writediagfi(ngrid,"madjdEz","heat from moistadj","W m-2",3,madjdEz)
-!             call writediagfi(ngrid,"h2o_max_col","maximum H2O column amount","kg.m^-2",2,H2Omaxcol)
-
+            call write_output("qsatatm","atm qsat"," ",qsat)
+!            call write_output("lscaledEz","heat from largescale","W m-2",lscaledEz)
+!            call write_output("madjdEz","heat from moistadj","W m-2",madjdEz)
+!            call write_output("h2o_max_col","maximum H2O column amount","kg.m^-2",H2Omaxcol)
          endif
 
          if (generic_condensation) then
-
-            call writediagfi(ngrid,"genericconddE","heat from generic condensation","W m-2",2,genericconddE)
-            call writediagfi(ngrid,"dt_generic_condensation","heating from generic condensation","K s-1",3,dt_generic_condensation)
-
+            call write_output("genericconddE","heat from generic condensation","W m-2",genericconddE)
+            call write_output("dt_generic_condensation","heating from generic condensation","K s-1",dt_generic_condensation)
          endif
 
@@ -2652,21 +2644,20 @@
           do nw=1,L_NSPECTV
             write(str2,'(i2.2)') nw
-            call writediagfi(ngrid,'dtauv'//str2,'Layer optical thickness attenuation in VI band '//str2,'',1,int_dtauv(:,nlayer:1:-1,nw))
+            call write_output('dtauv'//str2,'Layer optical thickness attenuation in VI band '//str2,'',int_dtauv(:,nlayer:1:-1,nw))
           enddo
           do nw=1,L_NSPECTI
             write(str2,'(i2.2)') nw
-            call writediagfi(ngrid,'dtaui'//str2,'Layer optical thickness attenuation in IR band '//str2,'',1,int_dtaui(:,nlayer:1:-1,nw))
+            call write_output('dtaui'//str2,'Layer optical thickness attenuation in IR band '//str2,'',int_dtaui(:,nlayer:1:-1,nw))
           enddo
         endif
 
-
         ! Temporary inclusions for heating diagnostics.
-        call writediagfi(ngrid,"zdtsw","SW heating","T s-1",3,zdtsw)
-        call writediagfi(ngrid,"zdtlw","LW heating","T s-1",3,zdtlw)
-        call writediagfi(ngrid,"dtrad","radiative heating","K s-1",3,dtrad)
-        call writediagfi(ngrid,"zdtdyn","Dyn. heating","T s-1",3,zdtdyn)
-
-        if (tracer .or. water) call writediagfi(ngrid,"dtmoistadj","moist adj heating","K s-1",3,dtmoist)
-        if (calladj) call writediagfi(ngrid,"dtdryadj","dry adj heating","K s-1",3,zdtadj)
+         call write_output("zdtsw","SW heating","T s-1",zdtsw)
+         call write_output("zdtlw","LW heating","T s-1",zdtlw)
+         call write_output("dtrad","radiative heating","K s-1",dtrad)
+         call write_output("zdtdyn","Dyn. heating","T s-1",zdtdyn)
+
+        if (tracer .or. water) call write_output("dtmoistadj","moist adj heating","K s-1",dtmoist)
+        if (calladj) call write_output("dtdryadj","dry adj heating","K s-1",zdtadj)
 
         ! For Debugging.
@@ -2677,11 +2668,11 @@
       ! Output aerosols.
       if (igcm_co2_ice.ne.0.and.iaero_co2.ne.0) &
-         call writediagfi(ngrid,'CO2ice_reff','CO2ice_reff','m',3,reffrad(1,1,iaero_co2))
+         call write_output('CO2ice_reff','CO2ice_reff','m',reffrad(1,1,iaero_co2))
       if (igcm_h2o_ice.ne.0.and.iaero_h2o.ne.0) &
-         call writediagfi(ngrid,'H2Oice_reff','H2Oice_reff','m',3,reffrad(:,:,iaero_h2o))
+         call write_output('H2Oice_reff','H2Oice_reff','m',reffrad(:,:,iaero_h2o))
       if (igcm_co2_ice.ne.0.and.iaero_co2.ne.0) &
-         call writediagfi(ngrid,'CO2ice_reffcol','CO2ice_reffcol','um kg m^-2',2,reffcol(1,iaero_co2))
+         call write_output('CO2ice_reffcol','CO2ice_reffcol','um kg m^-2',reffcol(1,iaero_co2))
       if (igcm_h2o_ice.ne.0.and.iaero_h2o.ne.0) &
-         call writediagfi(ngrid,'H2Oice_reffcol','H2Oice_reffcol','um kg m^-2',2,reffcol(1,iaero_h2o))
+         call write_output('H2Oice_reffcol','H2Oice_reffcol','um kg m^-2',reffcol(1,iaero_h2o))
 
       ! Output tracers.
@@ -2689,52 +2680,52 @@
 
          do iq=1,nq
-            call writediagfi(ngrid,noms(iq),noms(iq),'kg/kg',3,zq(1,1,iq))
-            call writediagfi(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
-                             'kg m^-2',2,qsurf_hist(1,iq) )
-            call writediagfi(ngrid,trim(noms(iq))//'_col',trim(noms(iq))//'_col',    &
-                            'kg m^-2',2,qcol(1,iq) )
-!          call writediagfi(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
-!                          'kg m^-2',2,qsurf(1,iq) )
+            call write_output(noms(iq),noms(iq),'kg/kg',zq(:,:,iq))
+            call write_output(trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
+                            'kg m^-2',qsurf_hist(1,iq) )
+            call write_output(trim(noms(iq))//'_col',trim(noms(iq))//'_col',    &
+                           'kg m^-2',qcol(:,iq) )
+            ! call write_output(trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
+            !              'kg m^-2',qsurf(:,iq) )
 
             if(watercond.or.CLFvarying)then
-               call writediagfi(ngrid,"rneb_man","H2O cloud fraction (conv)"," ",3,rneb_man)
-               call writediagfi(ngrid,"rneb_lsc","H2O cloud fraction (large scale)"," ",3,rneb_lsc)
-               call writediagfi(ngrid,"CLF","H2O cloud fraction"," ",3,cloudfrac)
-               call writediagfi(ngrid,"CLFt","H2O column cloud fraction"," ",2,totcloudfrac)
-               call writediagfi(ngrid,"RH","relative humidity"," ",3,RH)
-               call writediagfi(ngrid,"vteta","virtual potential temperature","K",3,zh * (1.+(1./epsi-1.) * &
+               call write_output("rneb_man","H2O cloud fraction (conv)"," ",rneb_man)
+               call write_output("rneb_lsc","H2O cloud fraction (large scale)"," ",rneb_lsc)
+               call write_output("CLF","H2O cloud fraction"," ",cloudfrac)
+               call write_output("CLFt","H2O column cloud fraction"," ",totcloudfrac)
+               call write_output("RH","relative humidity"," ",RH)
+               call write_output("vteta","virtual potential temperature","K",zh * (1.+(1./epsi-1.) * &
                        zq(1:ngrid,1:nlayer,1)))
             endif
 
             if(waterrain)then
-               call writediagfi(ngrid,"rain","rainfall","kg m-2 s-1",2,zdqsrain)
-               call writediagfi(ngrid,"snow","snowfall","kg m-2 s-1",2,zdqssnow)
-               call writediagfi(ngrid,"reevap","reevaporation of precipitation","kg m-2 s-1",2,reevap_precip)
+               call write_output("rain","rainfall","kg m-2 s-1",zdqsrain)
+               call write_output("snow","snowfall","kg m-2 s-1",zdqssnow)
+               call write_output("reevap","reevaporation of precipitation","kg m-2 s-1",reevap_precip)
             endif
 
             if(generic_condensation)then
+               call write_output("CLF","GCS cloud fraction"," ",cloudfrac)
+               !AF24: TODO fix rneb_generic and RH_generic failure with write_output()
+               ! call write_output("rneb_generic","GCS cloud fraction (generic condensation)"," ",rneb_generic)
+               ! call write_output("RH_generic","GCS relative humidity"," ",RH_generic)
                call writediagfi(ngrid,"rneb_generic","GCS cloud fraction (generic condensation)"," ",3,rneb_generic)
-               call writediagfi(ngrid,"CLF","GCS cloud fraction"," ",3,cloudfrac)
                call writediagfi(ngrid,"RH_generic","GCS relative humidity"," ",3,RH_generic)
-               call writediagfi(ngrid,"vteta","virtual potential temperature","K",3,zh * (1.+(1./epsi_generic-1.) * &
+               call write_output("vteta","virtual potential temperature","K",zh * (1.+(1./epsi_generic-1.) * &
                        zq(1:ngrid,1:nlayer,1) ))
             endif
 
             if(generic_rain)then
-               call writediagfi(ngrid,"rain","generic rainfall","kg m-2 s-1",2,zdqsrain_generic)
-               call writediagfi(ngrid,"snow","generic snowfall","kg m-2 s-1",2,zdqssnow_generic)
-               call writediagfi(ngrid,"reevap","generic reevaporation of precipitation","kg m-2 s-1",2,reevap_precip_generic)
+               call write_output("rain","generic rainfall","kg m-2 s-1",zdqsrain_generic)
+               call write_output("snow","generic snowfall","kg m-2 s-1",zdqssnow_generic)
+               call write_output("reevap","generic reevaporation of precipitation","kg m-2 s-1",reevap_precip_generic)
             endif
 
             if((hydrology).and.(.not.ok_slab_ocean))then
-               call writediagfi(ngrid,"hice","oceanic ice height","m",2,hice)
+               call write_output("hice","oceanic ice height","m",hice)
             endif
 
-            call writediagfi(ngrid,"tau_col","Total aerosol optical depth","[]",2,tau_col)
-
+            call write_output("tau_col","Total aerosol optical depth","[]",tau_col)
          enddo ! end of 'nq' loop
-
        endif ! end of 'tracer'
-
 
       ! Output spectrum.
@@ -2835,36 +2826,15 @@
       ! Send fields to XIOS: (NB these fields must also be defined as
       ! <field id="..." /> in context_lmdz_physics.xml to be correctly used)
-      CALL send_xios_field("ls",zls)
-
-      CALL send_xios_field("ps",ps)
-      CALL send_xios_field("area",cell_area)
-      CALL send_xios_field("p",pplay)
-      CALL send_xios_field("temperature",zt)
-      CALL send_xios_field("u",zu)
-      CALL send_xios_field("v",zv)
-      CALL send_xios_field("omega",omega)
-
-      IF (calltherm) THEN
-         CALL send_xios_field('w_plm',zw2_bis)
-         CALL send_xios_field('entr',entr)
-         CALL send_xios_field('detr',detr)
-!         CALL send_xios_field('fm',fm_bis)
-!         CALL send_xios_field('fraca',fraca)
-      ENDIF
+      CALL send_xios_field("controle",tab_cntrl_mod,1)
+
+      CALL send_xios_field("ap",ap,1)
+      CALL send_xios_field("bp",bp,1)
+      CALL send_xios_field("aps",aps,1)
+      CALL send_xios_field("bps",bps,1)
 
       IF (water) THEN
-         CALL send_xios_field('h2o_vap',zq(:,:,igcm_h2o_vap))
-         CALL send_xios_field('h2o_ice',zq(:,:,igcm_h2o_ice))
-
          CALL send_xios_field('h2o_layer1',zq(:,1,igcm_h2o_vap))
          CALL send_xios_field('co2_layer1',zq(:,1,igcm_co2_ice))
-         CALL send_xios_field('tsurf',tsurf)
-         CALL send_xios_field('co2ice',qsurf(1:ngrid,igcm_co2_ice))
-         CALL send_xios_field('h2o_ice_s',qsurf(1:ngrid,igcm_h2o_ice))
       ENDIF
-
-      CALL send_xios_field("ISR",fluxtop_dn)
-      CALL send_xios_field("OLR",fluxtop_lw)
-      CALL send_xios_field("ASR",fluxabs_sw)
 
       if (specOLR .and. corrk) then
Index: /trunk/LMDZ.GENERIC/libf/phystd/write_output_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/write_output_mod.F90	(revision 3522)
+++ /trunk/LMDZ.GENERIC/libf/phystd/write_output_mod.F90	(revision 3522)
@@ -0,0 +1,343 @@
+MODULE write_output_mod
+
+implicit none
+
+private
+
+INTERFACE write_output
+    MODULE PROCEDURE write_output_d0, write_output_d1, write_output_d2, &
+                     write_output_i0, write_output_i1, write_output_i2, &
+                     write_output_l0, write_output_l1, write_output_l2
+END INTERFACE write_output
+
+public write_output
+
+!-----------------------------------------------------------------------
+contains
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_d0(field_name,title,units,field)
+! For a scalar
+
+#ifdef CPP_XIOS
+    ! use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*), intent(in) :: field_name
+character(*), intent(in) :: title
+character(*), intent(in) :: units
+real,         intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+call writediagfi(ngrid,field_name,title,units,0,(/field/))
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field)
+#endif
+
+END SUBROUTINE write_output_d0
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_d1(field_name,title,units,field)
+! For a surface field
+
+#ifdef CPP_XIOS
+    ! use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),       intent(in) :: field_name
+character(*),       intent(in) :: title
+character(*),       intent(in) :: units
+real, dimension(:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+call writediagfi(ngrid,field_name,title,units,2,field)
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field)
+#endif
+
+END SUBROUTINE write_output_d1
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_d2(field_name,title,units,field)
+! For a "3D" horizontal-vertical field
+
+#ifdef CPP_XIOS
+    ! use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+use comsoil_h,         only: nsoilmx
+use writediagsoil_mod, only: writediagsoil
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),         intent(in) :: field_name
+character(*),         intent(in) :: title
+character(*),         intent(in) :: units
+real, dimension(:,:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+if (size(field,2) == nsoilmx) then
+    call writediagsoil(ngrid,field_name,title,units,3,field)
+else
+    call writediagfi(ngrid,field_name,title,units,3,field)
+endif
+
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field)
+#endif
+
+END SUBROUTINE write_output_d2
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_i0(field_name,title,units,field)
+! For a scalar
+
+#ifdef CPP_XIOS
+    ! use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*), intent(in) :: field_name
+character(*), intent(in) :: title
+character(*), intent(in) :: units
+integer,      intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+call writediagfi(ngrid,field_name,title,units,0,(/real(field)/))
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,(/real(field)/))
+#endif
+
+END SUBROUTINE write_output_i0
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_i1(field_name,title,units,field)
+! For a surface field
+
+#ifdef CPP_XIOS
+    ! use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),          intent(in) :: field_name
+character(*),          intent(in) :: title
+character(*),          intent(in) :: units
+integer, dimension(:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+call writediagfi(ngrid,field_name,title,units,2,real(field))
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,real(field))
+#endif
+
+END SUBROUTINE write_output_i1
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_i2(field_name,title,units,field)
+! For a "3D" horizontal-vertical field
+
+#ifdef CPP_XIOS
+    ! use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+use comsoil_h,         only: nsoilmx
+use writediagsoil_mod, only: writediagsoil
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),            intent(in) :: field_name
+character(*),            intent(in) :: title
+character(*),            intent(in) :: units
+integer, dimension(:,:), intent(in) :: field
+
+logical :: is_active ! For XIOS, should this field be sent or not
+
+if (size(field,2) == nsoilmx) then
+    call writediagsoil(ngrid,field_name,title,units,3,real(field))
+else
+    call writediagfi(ngrid,field_name,title,units,3,real(field))
+endif
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,real(field))
+#endif
+
+END SUBROUTINE write_output_i2
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_l0(field_name,title,units,field)
+! For a scalar
+
+#ifdef CPP_XIOS
+    ! use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*), intent(in) :: field_name
+character(*), intent(in) :: title
+character(*), intent(in) :: units
+logical,      intent(in) :: field
+! Local argument used to convert logical to real array
+real, dimension(1) :: field_real
+logical :: is_active ! For XIOS, should this field be sent or not
+
+field_real = 0.
+if (field) field_real = 1.
+
+call writediagfi(ngrid,field_name,title,units,0,field_real)
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field_real)
+#endif
+
+END SUBROUTINE write_output_l0
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_l1(field_name,title,units,field)
+! For a surface field
+
+#ifdef CPP_XIOS
+    ! use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),          intent(in) :: field_name
+character(*),          intent(in) :: title
+character(*),          intent(in) :: units
+logical, dimension(:), intent(in) :: field
+! Local argument used to convert logical to real
+real, dimension(ngrid) :: field_real
+logical :: is_active ! For XIOS, should this field be sent or not
+
+field_real = 0.
+where (field) field_real = 1.
+
+call writediagfi(ngrid,field_name,title,units,2,field_real)
+#ifdef CPP_XIOS
+!is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field_real)
+#endif
+
+END SUBROUTINE write_output_l1
+
+!-----------------------------------------------------------------------
+
+SUBROUTINE write_output_l2(field_name,title,units,field)
+! For a "3D" horizontal-vertical field
+
+#ifdef CPP_XIOS
+    ! use xios_output_mod, only: xios_is_active_field
+    use xios_output_mod, only: send_xios_field
+#endif
+
+use comsoil_h,         only: nsoilmx
+use writediagsoil_mod, only: writediagsoil
+
+implicit none
+
+include "dimensions.h"
+
+integer, parameter :: ngrid = 2 + (jjm - 1)*iim - 1/jjm
+character(*),            intent(in) :: field_name
+character(*),            intent(in) :: title
+character(*),            intent(in) :: units
+logical, dimension(:,:), intent(in) :: field
+! Local argument used to convert logical to real
+real, allocatable, dimension(:,:) :: field_real
+logical :: is_active ! For XIOS, should this field be sent or not
+
+allocate(field_real(size(field,1),size(field,2)))
+field_real = 0.
+where (field) field_real = 1.
+
+if (size(field,2) == nsoilmx) then
+    call writediagsoil(ngrid,field_name,title,units,3,field_real)
+else
+    call writediagfi(ngrid,field_name,title,units,3,field_real)
+endif
+
+#ifdef CPP_XIOS
+! is_active=xios_is_active_field(field_name)
+is_active=.true.
+    ! only send the field to xios if the user asked for it
+    if (is_active) call send_xios_field(field_name,field_real)
+#endif
+
+deallocate(field_real)
+
+END SUBROUTINE write_output_l2
+
+END MODULE write_output_mod
Index: /trunk/LMDZ.GENERIC/libf/phystd/writediagsoil.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/writediagsoil.F90	(revision 3521)
+++ /trunk/LMDZ.GENERIC/libf/phystd/writediagsoil.F90	(revision 3522)
@@ -1,2 +1,8 @@
+module writediagsoil_mod
+
+implicit none
+
+contains
+
 subroutine writediagsoil(ngrid,name,title,units,dimpx,px)
 
@@ -86,9 +92,9 @@
     stop
   endif
-  
+
   ! Set output sample rate
   isample=int(ecritphy) ! same as for diagfi outputs
   ! Note ecritphy is known from control.h
-  
+
   ! Create output NetCDF file
   if (is_master) then
@@ -129,5 +135,5 @@
     enddo
    endif
-   
+
    ! write "header" of file (longitudes, latitudes, geopotential, ...)
    if (klon_glo>1) then ! general 3D case
@@ -138,8 +144,8 @@
 
   endif ! of if (is_master)
-  
+
   ! set zitau to -1 to be compatible with zitau incrementation step below
   zitau=-1
-  
+
 else
   ! If not an initialization call, simply open the NetCDF file
@@ -164,5 +170,5 @@
     date=float(zitau+1)/float(day_step)
     ! Note: day_step is known from control.h
-    
+
     if (is_master) then
      ! Get NetCDF ID for "time"
@@ -176,5 +182,5 @@
      if (ierr.ne.NF_NOERR) then
       write(*,*)"writediagsoil: Failed writing date to time variable"
-      stop 
+      stop
      endif
     endif ! of if (is_master)
@@ -217,5 +223,5 @@
   endif
 #endif
-  
+
   ! B. Write (append) the variable to the NetCDF file
   if (is_master) then
@@ -235,5 +241,5 @@
     call def_var(nid,name,title,units,4,id,varid,ierr)
   endif ! of if (ierr.ne.NF_NOERR)
-  
+
   ! B.2. Prepare things to be able to write/append the variable
   corners(1)=1
@@ -241,5 +247,5 @@
   corners(3)=1
   corners(4)=ntime
-  
+
   if (klon_glo==1) then
     edges(1)=1
@@ -250,5 +256,5 @@
   edges(3)=nsoilmx
   edges(4)=1
-  
+
   ! B.3. Write the slab of data
 !#ifdef NC_DOUBLE
@@ -324,5 +330,5 @@
   corners(2)=1
   corners(3)=ntime
-  
+
   if (klon_glo==1) then
     edges(1)=1
@@ -332,5 +338,5 @@
   edges(2)=nbp_lat
   edges(3)=1
-  
+
   ! B.3. Write the slab of data
 !#ifdef NC_DOUBLE
@@ -373,5 +379,5 @@
   ! B.2. Prepare things to be able to write/append the variable
   corners(1)=ntime
-  
+
   edges(1)=1
 
@@ -396,2 +402,4 @@
 
 end subroutine writediagsoil
+
+end module writediagsoil_mod
Index: /trunk/LMDZ.GENERIC/libf/phystd/xios_output_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/xios_output_mod.F90	(revision 3521)
+++ /trunk/LMDZ.GENERIC/libf/phystd/xios_output_mod.F90	(revision 3522)
@@ -2,16 +2,16 @@
 
  IMPLICIT NONE
- 
+
  INTEGER,PRIVATE,SAVE :: time_it=0 ! store number of iterations with calls to XIOS since start
 ! does not need to be threadprivate; managed by omp master
 
  CHARACTER(LEN=*), PARAMETER :: context_id= "LMDZ" ! same as in context_lmdz_physics.xml
- 
+
 #ifdef CPP_XIOS
 
  INTERFACE send_xios_field
-    MODULE PROCEDURE histwrite0d_xios,histwrite2d_xios,histwrite3d_xios!,histwrite1d_xios
+    MODULE PROCEDURE histwrite0d_xios,histwrite1d_xios,histwrite2d_xios,histwrite3d_xios
  END INTERFACE
- 
+
 
 CONTAINS
@@ -36,5 +36,5 @@
   USE wxios, ONLY: wxios_domain_param, wxios_domain_param_unstructured, wxios_closedef
   IMPLICIT NONE
-  
+
   REAL,INTENT(IN) :: day ! Number of elapsed sols since reference Ls=0.
   REAL,INTENT(IN) :: timeofday ! "Universal time", given as fraction of sol (e.g.: 0.5 for noon).
@@ -46,10 +46,10 @@
   REAL,INTENT(IN) :: wnoi(:) ! Array of wavenumbers at the spectral interval centers for the infrared.
   real,intent(in) :: wnov (:) !Array of wavenumbers at the spectral interval centers for the visible.
-  
+
   INTEGER :: data_ibegin, data_iend
   TYPE(xios_duration) :: timestep
   TYPE(xios_date) :: time_origin
   TYPE(xios_date) :: start_date
-  
+
 !$OMP BARRIER
 !$OMP MASTER
@@ -74,5 +74,5 @@
 !    IF (mpi_rank == 0) THEN
 !        data_ibegin = 0
-!    ELSE 
+!    ELSE
 !        data_ibegin = ii_begin - 1
 !    END IF
@@ -129,5 +129,5 @@
     !NB: it would make more sense to define months and their length in the
     ! xml files and not to have them hard coded here.... to be improved...
-    
+
     ! time origin of the simulation (default: 1st year/1st month/1st day, Ls=0)
     time_origin=xios_date(1,1,1,0,0,0)
@@ -151,5 +151,5 @@
 !$OMP END MASTER
 !$OMP BARRIER
-  
+
   END SUBROUTINE initialize_xios_output
 
@@ -159,10 +159,10 @@
   USE xios
   IMPLICIT NONE
-!$OMP BARRIER    
+!$OMP BARRIER
 !$OMP MASTER
     CALL xios_context_finalize
-!$OMP END MASTER    
-!$OMP BARRIER    
-  
+!$OMP END MASTER
+!$OMP BARRIER
+
   END SUBROUTINE finalize_xios_output
 
@@ -176,5 +176,5 @@
     time_it=time_it+1
     CALL xios_update_calendar(time_it)
-!$OMP END MASTER    
+!$OMP END MASTER
   END SUBROUTINE update_xios_timestep
 
@@ -189,5 +189,5 @@
     CALL xios_get_handle(context_id,ctx_hdl)
     CALL xios_set_current_context(ctx_hdl)
-!$OMP END MASTER    
+!$OMP END MASTER
   END SUBROUTINE set_xios_context
 
@@ -198,17 +198,36 @@
   USE print_control_mod, ONLY: prt_level, lunout
   IMPLICIT NONE
-  
+
     CHARACTER(LEN=*), INTENT(IN) :: field_name
     REAL, INTENT(IN) :: field
-    
+
     IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite0d_xios ',trim(field_name)
-    
+
 !$OMP MASTER
     CALL xios_send_field(field_name,field)
 !$OMP END MASTER
-    
+
     IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite0d_xios ',trim(field_name)
-    
+
   END SUBROUTINE histwrite0d_xios
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE histwrite1d_xios(field_name,field,dimens)
+  USE xios, ONLY: xios_send_field
+  USE print_control_mod, ONLY: prt_level, lunout
+  IMPLICIT NONE
+
+    CHARACTER(LEN=*), INTENT(IN) :: field_name
+    REAL, DIMENSION(:), INTENT(IN) :: field
+    INTEGER, INTENT(IN) :: dimens
+    IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite1d_xios ',trim(field_name)
+!$OMP MASTER
+    CALL xios_send_field(field_name,field)
+!$OMP END MASTER
+
+    IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite1d_xios ',trim(field_name)
+
+  END SUBROUTINE histwrite1d_xios
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -226,11 +245,11 @@
     CHARACTER(LEN=*), INTENT(IN) :: field_name
     REAL, DIMENSION(:), INTENT(IN) :: field
-      
+
     REAL,DIMENSION(klon_mpi) :: buffer_omp
     REAL :: Field2d(nbp_lon,jj_nb)
 
     IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite2d_xios ',trim(field_name)
-    if ((size(field) .eq. L_NSPECTI) .or. (size(field) .eq. L_NSPECTV)) then 
-!$OMP MASTER 
+    if ((size(field) .eq. L_NSPECTI) .or. (size(field) .eq. L_NSPECTV)) then
+!$OMP MASTER
       ! only for spectral stuff: IR_Bandwidth and VI_Bandwidth
       call xios_send_field(field_name,field)
@@ -239,11 +258,11 @@
     endif
     IF (SIZE(field)/=klon) CALL abort_physic('iophy::histwrite2d_xios','Field first DIMENSION not equal to klon',1)
-    
-    CALL Gather_omp(field,buffer_omp)    
+
+    CALL Gather_omp(field,buffer_omp)
 !$OMP MASTER
     CALL grid1Dto2D_mpi(buffer_omp,Field2d)
-    
+
     CALL xios_send_field(field_name, Field2d)
-!$OMP END MASTER   
+!$OMP END MASTER
 
     IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite2d_xios ',trim(field_name)
@@ -281,5 +300,5 @@
 
     CALL xios_send_field(field_name, Field3d(:,:,1:nlev))
-!$OMP END MASTER   
+!$OMP END MASTER
 
     IF (prt_level >= 10) write(lunout,*)'End histrwrite3d_xios ',trim(field_name)
Index: /trunk/LMDZ.PLUTO/libf/phypluto/physiq_mod.F90
===================================================================
--- /trunk/LMDZ.PLUTO/libf/phypluto/physiq_mod.F90	(revision 3521)
+++ /trunk/LMDZ.PLUTO/libf/phypluto/physiq_mod.F90	(revision 3522)
@@ -2390,4 +2390,5 @@
          call write_output("w","Vertical wind","m.s-1",pw)
          call write_output("p","Pressure","Pa",pplay)
+         call write_output("omega","omega","Pa/s",omega)
       endif
 
@@ -2450,5 +2451,5 @@
             ! call write_output(trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
          !                    'kg m^-2',qsurf_hist(1,iq) )
-           call write_output(trim(noms(iq))//'_col',trim(noms(iq))//'_col',    &
+            call write_output(trim(noms(iq))//'_col',trim(noms(iq))//'_col',    &
                            'kg m^-2',qcol(:,iq) )
             call write_output(trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  &
