Index: trunk/LMDZ.MARS/libf/phymars/iniwrite.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/iniwrite.F	(revision 2544)
+++ trunk/LMDZ.MARS/libf/phymars/iniwrite.F	(revision 2545)
@@ -10,4 +10,5 @@
       USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
       USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
+      use phyetat0_mod, only: tab_cntrl_mod
       IMPLICIT NONE
 
@@ -41,7 +42,7 @@
 c   Local:
 c   ------
-      INTEGER length,l
-      parameter (length = 100)
-      REAL tab_cntrl(length) ! run parameters are stored in this array
+!      INTEGER length,l
+!      parameter (length = 100)
+!      REAL tab_cntrl(length) ! run parameters are stored in this array
       INTEGER ierr
       REAl,ALLOCATABLE :: lon_reg_ext(:) ! extended longitudes
@@ -61,18 +62,18 @@
       ENDIF
 
-      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
+!      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(12) = etot0
 !      tab_cntrl(13) = ptot0
@@ -81,5 +82,5 @@
 !      tab_cntrl(16) = ang0
 
-      tab_cntrl(27) = hour_ini
+!      tab_cntrl(27) = hour_ini
 c
 c    ..........    P.Le Van  ( ajout le 8/04/96 )    .........
@@ -110,5 +111,5 @@
       ierr = NF_REDEF (nid)
 
-      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
+      ierr = NF_DEF_DIM (nid, "index", SIZE(tab_cntrl_mod), idim_index)
 !      ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu)
       ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu)
@@ -138,7 +139,7 @@
       ierr = NF_ENDDEF(nid)
 #ifdef NC_DOUBLE
-      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
-#else
-      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl_mod)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl_mod)
 #endif
 
Index: trunk/LMDZ.MARS/libf/phymars/phyetat0_mod.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/phyetat0_mod.F90	(revision 2544)
+++ trunk/LMDZ.MARS/libf/phymars/phyetat0_mod.F90	(revision 2545)
@@ -2,4 +2,5 @@
 
 implicit none
+  real,save :: tab_cntrl_mod(100)
 
 contains
@@ -342,4 +343,7 @@
      DEALLOCATE(time)
    endif ! of if Time not found in file
+
+   call ini_tab_controle_dyn_xios(day_ini)
+
 else
   indextime = 1
@@ -664,3 +668,40 @@
 end subroutine phyetat0
 
+
+subroutine ini_tab_controle_dyn_xios(idayref)
+
+      USE comcstfi_h, only: g, mugaz, omeg, rad, rcp
+      USE time_phylmdz_mod, ONLY: hour_ini, 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(27) = hour_ini
+
+      tab_cntrl_mod = tab_cntrl
+
+end subroutine ini_tab_controle_dyn_xios
+
 end module phyetat0_mod
Index: trunk/LMDZ.MARS/libf/phymars/physiq_mod.F
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 2544)
+++ trunk/LMDZ.MARS/libf/phymars/physiq_mod.F	(revision 2545)
@@ -74,5 +74,4 @@
       use compute_dtau_mod, only: compute_dtau
       use nonoro_gwd_ran_mod, only: nonoro_gwd_ran
-      use check_fields_mod, only: check_physics_fields
 #ifdef MESOSCALE
       use comsoil_h, only: mlayer,layer
@@ -83,5 +82,5 @@
      &                          planetwide_sumval
       use phyredem, only: physdem0, physdem1
-      use phyetat0_mod, only: phyetat0
+      use phyetat0_mod, only: phyetat0, tab_cntrl_mod
       use eofdump_mod, only: eofdump
       USE vertical_layers_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt
@@ -97,5 +96,4 @@
 #endif
       USE mod_grid_phy_lmdz, ONLY: grid_type, unstructured
-      use ioipsl_getin_p_mod, only: getin_p
 
       IMPLICIT NONE
@@ -398,7 +396,7 @@
       REAL mdusttot(ngrid)      ! Total mass of dust tracer (kg/m2)
       REAL icetot(ngrid)        ! Total mass of water ice (kg/m2)
-      REAL mtotco2(ngrid)      ! Total mass of co2, including ice at the surface (kg/m2)
-      REAL vaptotco2(ngrid)     ! Total mass of co2 vapor (kg/m2)
-      REAL icetotco2(ngrid)     ! Total mass of co2 ice (kg/m2)
+      REAL mtotco2       ! Total mass of co2, including ice at the surface (kg/m2)
+      REAL vaptotco2     ! Total mass of co2 vapor (kg/m2)
+      REAL icetotco2     ! Total mass of co2 ice (kg/m2)
       REAL Nccntot(ngrid)       ! Total number of ccn (nbr/m2)
       REAL NccnCO2tot(ngrid)    ! Total number of ccnCO2 (nbr/m2)
@@ -436,4 +434,6 @@
       REAL dsotop(ngrid,nlayer) ! density scaled opacity for topdust
 
+      REAL nccnco2(ngrid,nlayer)   ! true n ccnco2 (kg/kg)
+      REAL qccnco2(ngrid,nlayer)  ! true q ccnco2 (kg/kg)
 
 c Test 1d/3d scavenging
@@ -509,7 +509,5 @@
       integer iloop
 
-      ! flags to trigger extra sanity checks
-      logical,save :: check_physics_inputs=.false.
-      logical,save :: check_physics_outputs=.false.
+!      LOGICAL startphy_file
 
 c=======================================================================
@@ -522,7 +520,4 @@
 
       IF (firstcall) THEN
-
-         call getin_p("check_physics_inputs",check_physics_inputs)
-         call getin_p("check_physics_outputs",check_physics_outputs)
 
 c        variables set to 0
@@ -741,9 +736,4 @@
       ENDIF        !  (end of "if firstcall")
 
-      if (check_physics_inputs) then
-        ! Check the validity of input fields coming from the dynamics
-        call check_physics_fields("begin physiq:",pt,pu,pv,pplev)
-      endif
-
 c ---------------------------------------------------
 c 1.2   Initializations done at every physical timestep:
@@ -1665,5 +1655,5 @@
                pdt(1:ngrid,1:nlayer) = 
      &              pdt(1:ngrid,1:nlayer) + 
-     &              zdtcloudco2(1:ngrid,1:nlayer)
+     &              zdtcloudco2(1:ngrid,1:nlayer)! --> in co2condens
             
 
@@ -1960,5 +1950,6 @@
      $                  zdtc,zdtsurfc,pdpsrf,zduc,zdvc,zdqc,
      $                  fluxsurf_sw,zls,
-     $                  zdqssed_co2,zcondicea_co2microp)
+     $                  zdqssed_co2,zcondicea_co2microp,
+     &                  zdtcloudco2)
          ! no scavenging yet
          zdqsc(:,:) = 0.
@@ -1971,5 +1962,5 @@
      $              fluxsurf_sw,zls,
      $              zdqssed_co2,zcondicea_co2microp,
-     &              zdqsc)
+     &              zdtcloudco2,zdqsc)
            DO iq=1, nq
            DO ig=1,ngrid
@@ -1977,5 +1968,5 @@
            ENDDO  ! (ig)
            ENDDO    ! (iq)
-        end if ! co2clouds
+        end if
         DO l=1,nlayer
            DO ig=1,ngrid
@@ -2422,4 +2413,12 @@
            endif !(rdstorm)
 
+           if (co2clouds) then
+              do ig=1,ngrid 
+                 nccnco2(ig,:) =
+     &                zq(ig,:,igcm_ccnco2_number)*tauscaling(ig)
+                 qccnco2(ig,:) =
+     &                zq(ig,:,igcm_ccnco2_mass)*tauscaling(ig)
+              enddo
+           endif ! of if (co2clouds)
                               
            if (water) then
@@ -2518,22 +2517,4 @@
 
            endif ! of if (water)
-
-
-          if (co2clouds) then
-            mtotco2(1:ngrid) = 0.
-            icetotco2(1:ngrid) = 0.
-            vaptotco2(1:ngrid) = 0.
-            do ig=1,ngrid
-              do l=1,nlayer
-                vaptotco2(ig) = vaptotco2(ig) + 
-     &                          zq(ig,l,igcm_co2) * 
-     &                          (zplev(ig,l) - zplev(ig,l+1)) / g
-                icetotco2(ig) = icetot(ig) + 
-     &                          zq(ig,l,igcm_co2_ice) * 
-     &                          (zplev(ig,l) - zplev(ig,l+1)) / g
-              end do
-              mtotco2(ig) = icetotco2(ig) + vaptotco2(ig)
-            end do
-          end if
         endif                   ! of if (tracer)
 #ifndef MESOSCALE
@@ -2660,16 +2641,5 @@
 
              endif ! of if (water)
-
-             if (co2clouds) then
-               call wstats(ngrid,"mtotco2",
-     &                    "total mass atm of co2","kg/m2",
-     &                    2,mtotco2)
-               call wstats(ngrid,"icetotco2",
-     &                    "total mass atm of co2 ice","kg/m2",
-     &                    2,icetotco2)
-               call wstats(ngrid,"vaptotco2",
-     &                    "total mass atm of co2 vapor","kg/m2",
-     &                    2,icetotco2)
-             end if
+             
              
            if (dustbin.ne.0) then
@@ -2954,25 +2924,27 @@
 
       if (tracer.and.(igcm_co2.ne.0)) then
+!       call WRITEDIAGFI(ngrid,"co2_l1","co2 mix. ratio in 1st layer",
+!    &                   "kg/kg",2,zq(1,1,igcm_co2))
         call WRITEDIAGFI(ngrid,"co2","co2 mass mixing ratio",
-     &                   "kg.kg-1",3,zq(:,:,igcm_co2))
+     &                   "kg/kg",3,zq(:,:,igcm_co2))
 
         if (co2clouds) then
-          call WRITEDIAGFI(ngrid,'ccnqco2','CCNco2 mmr',
-     &                     'kg.kg-1',3,zq(:,:,igcm_ccnco2_mass))
+          call WRITEDIAGFI(ngrid,'zdtcloudco2',
+     &                     'temperature variation of CO2 latent heat',
+     &                     'K/s',3,zdtcloudco2)
+ 
+          call WRITEDIAGFI(ngrid,'ccnqco2','CCNco2 mass mr',
+     &                     'kg/kg',3,qccnco2)
 
           call WRITEDIAGFI(ngrid,'ccnNco2','CCNco2 number',
-     &                     'part.kg-1',3,zq(:,:,igcm_ccnco2_number))
-
-          call WRITEDIAGFI(ngrid,'co2_ice','co2_ice mmr in atm',
-     &                     'kg.kg-1', 3, zq(:,:,igcm_co2_ice))
-
-         call WRITEDIAGFI(ngrid,"mtotco2","total mass atm of co2",
-     &                    "kg.m-2",2, mtotco2)
-         call WRITEDIAGFI(ngrid,"icetotco2","total mass atm of co2 ice",
-     &                    "kg.m-2", 2, icetotco2)
-         call WRITEDIAGFI(ngrid,"vaptotco2","total mass atm of co2
-     &                    vapor","kg.m-2", 2, vaptotco2)
-         call WRITEDIAGFI(ngrid,"emis","Surface emissivity","w.m-1",2,
-     &                  emis)
+     &                     'part/kg',3,nccnco2)
+
+          call WRITEDIAGFI(ngrid,'co2_ice','co2_ice','kg/kg',
+     &                     3,zq(:,:,igcm_co2_ice))
+
+          call WRITEDIAGFI(ngrid,'precip_co2_ice',
+     &                     'surface deposition of co2 ice',
+     &                     'kg.m-2.s-1',2,
+     &                     zdqssed(1:ngrid,igcm_co2_ice))
         end if ! of if (co2clouds)
       end if ! of if (tracer.and.(igcm_co2.ne.0))
@@ -3794,5 +3766,5 @@
            rave2=max(rave2/max(totrave2,1.e-30),1.e-30)
           CALL WRITEDIAGFI(ngrid,'rmoym',
-     &                     'reffice',
+     &                      'reffice',
      &                      'm',0,rave2)
 
@@ -3829,5 +3801,16 @@
 
         ENDIF ! of IF (water)
-        
+
+
+      ! co2clouds
+      if (co2clouds) then
+        call WRITEDIAGFI(ngrid,'zdtcloudco2',
+     &                   'temperature variation of CO2 latent heat',
+     &                   'K/s',3,zdtcloudco2)
+         call WRITEDIAGFI(ngrid,"emis","Surface emissivity","w.m-1",2,
+     &                  emis)
+
+      end if
+         
 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
@@ -3864,5 +3847,4 @@
      &                     '%',0,(co2totA-co2totB)/co2totA)
       endif ! of if (igcm_co2_ice.ne.0)
-
 ! XIOS outputs
 #ifdef CPP_XIOS      
@@ -3870,4 +3852,15 @@
       ! <field id="..." /> in context_lmdz_physics.xml to be correctly used)
       CALL send_xios_field("ls",zls*180./pi)
+
+      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)
+
+      CALL send_xios_field("phisinit",phisfi)
+
+! ap,bp (interlayer),aps,bps (altitude)
       
       CALL send_xios_field("ps",ps)
@@ -3882,12 +3875,38 @@
       CALL send_xios_field("co2ice",co2ice)
       
-      CALL send_xios_field("temperature",zt)
+      CALL send_xios_field("temp",zt)
       CALL send_xios_field("u",zu)
       CALL send_xios_field("v",zv)
 
+      CALL send_xios_field("rho",rho)
+      ! Orographic Gravity waves tendencies
+      if (calllott) then
+      CALL send_xios_field("dugw",zdugw/ptimestep)
+      CALL send_xios_field("dvgw",zdvgw/ptimestep)
+      CALL send_xios_field("dtgw",zdtgw/ptimestep)
+      endif
       !CREATE IF CO2CYCLE
       if (tracer.and.(igcm_co2.ne.0)) then
          CALL send_xios_field("co2",zq(:,:,igcm_co2))
       endif
+      ! Water cycle
+      if (water) then
+         CALL send_xios_field("watercap",watercap)
+         !CALL send_xios_field("watercaptag",watercaptag)
+         CALL send_xios_field("mtot",mtot)
+         CALL send_xios_field("icetot",icetot)
+         if (igcm_h2o_vap.ne.0 .and. igcm_h2o_ice.ne.0) then
+            CALL send_xios_field("h2o_vap",zq(:,:,igcm_h2o_vap))
+            CALL send_xios_field("h2o_ice",zq(:,:,igcm_h2o_ice))
+         endif
+      endif
+            if (.not.activice) then
+!      CALL send_xios_field("tauTESap",tauTES)
+             else
+      CALL send_xios_field("tauTES",taucloudtes)
+             endif
+
+      CALL send_xios_field("h2o_ice_s",qsurf(:,igcm_h2o_ice))
+
 
       if (lastcall.and.is_omp_master) then
@@ -3897,8 +3916,4 @@
 #endif
 
-      if (check_physics_outputs) then
-        ! Check the validity of updated fields at the end of the physics step
-        call check_physics_fields("end of physiq:",zt,zu,zv,zplev)
-      endif
 
       icount=icount+1
Index: trunk/LMDZ.MARS/libf/phymars/xios_output_mod.F90
===================================================================
--- trunk/LMDZ.MARS/libf/phymars/xios_output_mod.F90	(revision 2544)
+++ trunk/LMDZ.MARS/libf/phymars/xios_output_mod.F90	(revision 2545)
@@ -11,5 +11,5 @@
 
  INTERFACE send_xios_field
-    MODULE PROCEDURE histwrite0d_xios,histwrite2d_xios,histwrite3d_xios
+    MODULE PROCEDURE histwrite0d_xios,histwrite1d_xios,histwrite2d_xios,histwrite3d_xios
  END INTERFACE
  
@@ -57,4 +57,6 @@
     CALL xios_set_axis_attr("altitude", n_glo=size(pseudoalt), value=pseudoalt,&
                             unit="km",positive="up")
+    CALL xios_set_axis_attr("interlayer", n_glo=size(pseudoalt)+1,&
+                            unit="km",positive="up")
     IF (prt_level>=10) WRITE(lunout,*) "initialize_xios_output: call xios_set_axis_attr for soil"
     CALL xios_set_axis_attr("soil_layers", n_glo=size(mlayer), value=mlayer,&
@@ -194,5 +196,4 @@
     
     IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite0d_xios ',trim(field_name)
-    
 !$OMP MASTER
     CALL xios_send_field(field_name,field)
@@ -202,4 +203,23 @@
     
   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
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -221,5 +241,4 @@
 
     IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite2d_xios ',trim(field_name)
-
     IF (SIZE(field)/=klon) CALL abort_physic('iophy::histwrite2d_xios','Field first DIMENSION not equal to klon',1)
     
