Index: LMDZ6/trunk/libf/phylmd/output_physiqex_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/output_physiqex_mod.F90	(revision 4540)
+++ LMDZ6/trunk/libf/phylmd/output_physiqex_mod.F90	(revision 4547)
@@ -5,5 +5,5 @@
 CONTAINS 
 
-SUBROUTINE output_physiqex(debut,zjulian,pdtphys,presnivs,paprs,u,v,t)
+SUBROUTINE output_physiqex(debut,zjulian,pdtphys,presnivs,paprs,u,v,t,qx,cf,zqr,zqs,zqg,ptke,theta)
 
       USE dimphy, only : klon,klev
@@ -15,4 +15,5 @@
       USE iophy, ONLY : init_iophy_new
       USE geometry_mod, ONLY: latitude_deg, longitude_deg
+      USE infotrac_phy, only : nqtot
 
 
@@ -25,5 +26,12 @@
 real,intent(in) :: v(klon,klev) ! northward meridional wind (m/s)
 real,intent(in) :: t(klon,klev) ! temperature (K)
+real,intent(in) :: theta(klon,klev) ! temperature (K)
 real,intent(in) :: paprs(klon,klev+1) ! interlayer pressure (Pa)
+real,intent(in) :: qx(klon,klev,nqtot) !tracers
+real,intent(in) :: cf(klon,klev) !cloud fraction
+real,intent(in) :: zqr(klon,klev) !rain specifiq content
+real,intent(in) :: zqs(klon,klev) !snow specifiq content
+real,intent(in) :: zqg(klon,klev) !graupel specifiq content
+real,intent(in) :: ptke(klon,klev) !tke
 
 real :: t_ops ! frequency of the IOIPSL operations (eg average over...)
@@ -48,64 +56,9 @@
 
    call getin_p("iwrite_phys",iwrite_phys)
-   call getin_p("ioex",ioex)
-
-   if ( ioex == 1 ) then
-      CALL iophys_ini(pdtphys)
-   else if ( ioex == 2 ) then
-
-      CALL init_iophy_new(latitude_deg,longitude_deg)
-      dtime=pdtphys
-      itau=0
-      call histbeg_phy("histins.nc",itau,zjulian,dtime,nhori,nid_hist)
-      print*,'NNNNNNN ',nid_hist,debut
-      print*,'NNNNNNN OK0'
-      t_ops=pdtphys*iwrite_phys ! frequency of the IOIPSL operation
-      t_wrt=pdtphys*iwrite_phys ! frequency of the outputs in the file
-      print*,'NNNNNNN OK1'
 
    !$OMP MASTER
-
-#ifndef CPP_IOIPSL_NO_OUTPUT 
-       ! IOIPSL
-       ! define vertical coordinate
-       call histvert(nid_hist,"presnivs","Vertical levels","Pa",klev, &
-                     presnivs,zvertid,'down')
-       ! define variables which will be written in "histins.nc" file
-       call histdef(nid_hist,'Temp','Atmospheric temperature','K', &
-                    nbp_lon,jj_nb,nhori,klev,1,klev,zvertid,32, &
-                    'inst(X)',t_ops,t_wrt)
-       print*,'NNNNNNN OK2a',nid_hist,t_ops,t_wrt
-       call histdef(nid_hist,'u','Eastward Zonal Wind','m/s', &
-                    nbp_lon,jj_nb,nhori,klev,1,klev,zvertid,32, &
-                    'inst(X)',t_ops,t_wrt)
-       print*,'NNNNNNN OK2b',nid_hist,t_ops,t_wrt
-       call histdef(nid_hist,'v','Northward Meridional Wind','m/s', &
-                    nbp_lon,jj_nb,nhori,klev,1,klev,zvertid,32, &
-                    'inst(X)',t_ops,t_wrt)
-       print*,'NNNNNNN OK2c',nid_hist,t_ops,t_wrt
-       call histdef(nid_hist,'ps','Surface Pressure','Pa', &
-                    nbp_lon,jj_nb,nhori,1,1,1,zvertid,32, &
-                    'inst(X)',t_ops,t_wrt)
-       ! end definition sequence
-       print*,'NNNNNNN OK2',nid_hist,t_ops,t_wrt
-       call histend(nid_hist)
-       print*,'NNNNNNN OK3'
-#endif
-
-#ifdef CPP_XIOS
-      !XIOS
-          ! Declare available vertical axes to be used in output files:    
-          CALL wxios_add_vaxis("presnivs", klev, presnivs)
-      
-          ! Declare calendar and time step
-          CALL wxios_set_cal(dtime,"earth_360d",1,1,1,0.0,1,1,1,0.0)
-          
-          !Finalize the context:
-          CALL wxios_closedef()
-#endif
-
-      !$OMP END MASTER
-      !$OMP BARRIER
-   endif
+   CALL iophys_ini(pdtphys)
+   !$OMP END MASTER
+   !$OMP BARRIER
 
 endif
@@ -114,41 +67,19 @@
 itau=itau+1
 
-! write some outputs:
-! IOIPSL
-#ifndef CPP_IOIPSL_NO_OUTPUT 
 if (modulo(itau,iwrite_phys)==0) then
-  if ( ioex == 1 ) then
      call iophys_ecrit('temp',klev,'Temperature','K',t)
-     call iophys_ecrit('u',klev,'zonal wind','m/s',t)
-     call iophys_ecrit('v',klev,'meridinal wind','m/s',t)
+     call iophys_ecrit('u',klev,'zonal wind','m/s',u)
+     call iophys_ecrit('v',klev,'meridinal wind','m/s',v)
      call iophys_ecrit('ps',1,'Surface pressure','Pa',paprs(:,1))
-  else if ( ioex == 2 ) then
-     call histwrite_phy(nid_hist,.false.,"Temp",itau,t)
-     call histwrite_phy(nid_hist,.false.,"u",itau,u)
-     call histwrite_phy(nid_hist,.false.,"v",itau,v)
-     call histwrite_phy(nid_hist,.false.,"ps",itau,paprs(:,1))
-     !$OMP MASTER
-     CALL histsync(nid_hist)
-     !$OMP END MASTER
-  endif
+     call iophys_ecrit('qv',klev,'Water vapor specifiq content', 'kg/kg', qx(:,:,1))
+     call iophys_ecrit('qc',klev,'Cloud liquid water specifiq content', 'kg/kg', qx(:,:,2))
+     call iophys_ecrit('qi',klev,'Cloud solid water specifiq content', 'kg/kg', qx(:,:,3))
+     call iophys_ecrit('CF',klev,'Cloud fraction', '0-1', cf)
+     call iophys_ecrit('qr',klev,'Rain specifiq content', 'kg/kg', zqr)
+     call iophys_ecrit('qs',klev,'Snow specifiq content', 'kg/kg', zqs)
+     call iophys_ecrit('qg',klev,'Graupel specifiq content', 'kg/kg', zqg)
+     call iophys_ecrit('TKE',klev,'TKE', 'm2/s2', ptke)
+     call iophys_ecrit('theta',klev,'Temperature potentielle', 'K', theta)
 endif
-#endif
-
-!XIOS
-#ifdef CPP_XIOS
-   !$OMP MASTER
-       !Increment XIOS time
-       CALL xios_update_calendar(itau)
-   !$OMP END MASTER
-   !$OMP BARRIER
-   
-       !Send fields to XIOS: (NB these fields must also be defined as
-       ! <field id="..." /> in iodef.xml to be correctly used
-       CALL histwrite_phy("Temp",t)
-       CALL histwrite_phy("temp_newton",temp_newton)
-       CALL histwrite_phy("u",u)
-       CALL histwrite_phy("v",v)
-       CALL histwrite_phy("ps",paprs(:,1))
-#endif
 
 
