Index: /LMDZ5/trunk/DefLists/field_def_lmdz.xml
===================================================================
--- /LMDZ5/trunk/DefLists/field_def_lmdz.xml	(revision 2991)
+++ /LMDZ5/trunk/DefLists/field_def_lmdz.xml	(revision 2992)
@@ -460,4 +460,8 @@
         <field id="dqthe2d"    long_name="Thermal dQ"    unit="(kg/m2)/s" />
         <field id="dqajs2d"    long_name="Dry ajdust dQ"    unit="(kg/m2)/s" />
+        <field id="tatp"    long_name="Dry ajdust dQ"    unit="(kg/m2)/s" />
+        <field id="p_tropopause"  long_name="Tropopause pressure" unit="Pa"   detect_missing_value=".true."  />
+        <field id="z_tropopause"  long_name="Tropopause height" unit="m"      detect_missing_value=".true."  />
+        <field id="t_tropopause"  long_name="Tropopause temperature" unit="K" detect_missing_value=".true."  />
     </field_group>
 
@@ -680,5 +684,4 @@
         <field id="OD1020_strat_only"  long_name="Stratospheric Aerosol Optical depth at 1020 nm "       unit="1" />
         <field id="surf_PM25_sulf"     long_name="Sulfate PM2.5 concentration at the surface"            unit="ug/m3" />
-        <field id="p_tropopause"       long_name="Tropopause pressure"                                   unit="Pa" />
         <field id="budg_dep_dry_h2so4" long_name="H2SO4 dry deposition flux"                             unit="kg(S)/m2/s" />
         <field id="budg_dep_wet_h2so4" long_name="H2SO4 wet deposition flux"                             unit="kg(S)/m2/s" />
Index: /LMDZ5/trunk/libf/phylmd/phys_local_var_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/phys_local_var_mod.F90	(revision 2991)
+++ /LMDZ5/trunk/libf/phylmd/phys_local_var_mod.F90	(revision 2992)
@@ -430,4 +430,7 @@
 !$OMP THREADPRIVATE(sissnow,runoff,albsol3_lic)
 
+      REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: p_tropopause, z_tropopause, t_tropopause
+!$OMP THREADPRIVATE(p_tropopause, z_tropopause, t_tropopause)
+
 #ifdef CPP_StratAer
 !
@@ -461,6 +464,4 @@
       REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: surf_PM25_sulf
 !$OMP THREADPRIVATE(surf_PM25_sulf)
-      REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: p_tropopause
-!$OMP THREADPRIVATE(p_tropopause)
       REAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: vsed_aer
 !$OMP THREADPRIVATE(vsed_aer)
@@ -499,6 +500,4 @@
 !$OMP THREADPRIVATE(budg_sed_part)
 #endif
-      REAL, ALLOCATABLE, SAVE, DIMENSION(:) :: pr_tropopause
-!$OMP THREADPRIVATE(pr_tropopause)
 
 CONTAINS
@@ -749,4 +748,8 @@
       ALLOCATE (sissnow(klon),runoff(klon),albsol3_lic(klon))
 
+      ALLOCATE (p_tropopause(klon))
+      ALLOCATE (z_tropopause(klon))
+      ALLOCATE (t_tropopause(klon))
+
 #ifdef CPP_StratAer
       ALLOCATE (R2SO4(klon,klev))
@@ -782,8 +785,6 @@
       ALLOCATE (budg_sed_part(klon))
       ALLOCATE (surf_PM25_sulf(klon))
-      ALLOCATE (p_tropopause(klon))
       ALLOCATE (vsed_aer(klon,klev))
 #endif
-      ALLOCATE (pr_tropopause(klon))
 
 END SUBROUTINE phys_local_var_init
@@ -1012,4 +1013,8 @@
       DEALLOCATE (zxsnow,snowhgt,qsnow,to_ice,sissnow,runoff,albsol3_lic)
 
+      DEALLOCATE (p_tropopause)
+      DEALLOCATE (z_tropopause)
+      DEALLOCATE (t_tropopause)
+
 #ifdef CPP_StratAer
 ! variables for strat. aerosol CK
@@ -1028,5 +1033,4 @@
       DEALLOCATE (tausum_strat)
       DEALLOCATE (surf_PM25_sulf)
-      DEALLOCATE (p_tropopause)
       DEALLOCATE (vsed_aer)
       DEALLOCATE (budg_3D_ocs_to_so2)
@@ -1049,5 +1053,4 @@
       DEALLOCATE (budg_sed_part)
 #endif
-      DEALLOCATE (pr_tropopause)
 
 END SUBROUTINE phys_local_var_end
Index: /LMDZ5/trunk/libf/phylmd/phys_output_ctrlout_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 2991)
+++ /LMDZ5/trunk/libf/phylmd/phys_output_ctrlout_mod.F90	(revision 2992)
@@ -1225,4 +1225,14 @@
     'lcc', 'Cloud liquid fraction at top of cloud', '1', (/ ('', i=1, 10) /))
 
+!--tropopause pressure
+  TYPE(ctrl_out), SAVE :: o_p_tropopause = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
+    'p_tropopause', 'Tropopause pressure', 'Pa', (/ ('', i=1, 10) /))
+!--tropopause height
+  TYPE(ctrl_out), SAVE :: o_z_tropopause = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
+    'z_tropopause', 'Tropopause height', 'm', (/ ('', i=1, 10) /))
+!--tropopause temperature
+  TYPE(ctrl_out), SAVE :: o_t_tropopause = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
+    't_tropopause', 'Tropopause temperature', 'K', (/ ('', i=1, 10) /))
+
 #ifdef CPP_StratAer
 !--extinction coefficient
@@ -1285,7 +1295,4 @@
   TYPE(ctrl_out), SAVE :: o_budg_sed_part = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
     'budg_sed_part', 'Ground sedimentation flux of strat. particles', 'kg(S)/m2/s', (/ ('', i=1, 10) /))
-!--tropopause height
-  TYPE(ctrl_out), SAVE :: o_p_tropopause = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
-    'p_tropopause', 'Tropopause pressure', 'Pa', (/ ('', i=1, 10) /))
 !--surface PM25 due to strat aerosol
   TYPE(ctrl_out), SAVE :: o_surf_PM25_sulf = ctrl_out((/ 11, 11, 11, 11, 11, 11, 11, 11, 11, 1/), &
Index: /LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 2991)
+++ /LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 2992)
@@ -184,5 +184,7 @@
          o_map_emis_Anv, o_map_pcld_Anv, o_map_tcld_Anv, &
          o_map_ntot, o_map_hc,o_map_hist,o_map_Cb,o_map_ThCi,o_map_Anv, &
-         o_alt_tropo
+         o_alt_tropo, & 
+! Tropopause
+         o_p_tropopause, o_z_tropopause, o_t_tropopause
 
 #ifdef CPP_StratAer
@@ -196,5 +198,5 @@
          o_budg_ocs_to_so2, o_budg_so2_to_h2so4, o_budg_h2so4_to_part, &
          o_surf_PM25_sulf, o_ext_strat_550, o_tau_strat_550, &
-         o_p_tropopause, o_vsed_aer, o_tau_strat_1020, o_ext_strat_1020, o_f_r_wet
+         o_vsed_aer, o_tau_strat_1020, o_ext_strat_1020, o_f_r_wet
 #endif
 
@@ -287,5 +289,6 @@
          east_gwstress, west_gwstress, &
          d_q_ch4, pmfd, pmfu, ref_liq, ref_ice, rhwriteSTD, &
-         ep, epmax_diag ! epmax_cape
+         ep, epmax_diag, &  ! epmax_cape
+         p_tropopause, t_tropopause, z_tropopause
 
 #ifdef CPP_StratAer 
@@ -298,5 +301,5 @@
          budg_emi_ocs, budg_emi_so2, budg_emi_h2so4, budg_emi_part, & 
          budg_ocs_to_so2, budg_so2_to_h2so4, budg_h2so4_to_part, & 
-         surf_PM25_sulf, tau_strat_550, p_tropopause, tausum_strat, &
+         surf_PM25_sulf, tau_strat_550, tausum_strat, &
          vsed_aer, tau_strat_1020, f_r_wet
 #endif
@@ -1220,4 +1223,9 @@
           ENDIF
        ENDIF
+
+       CALL histwrite_phy(o_p_tropopause, p_tropopause)
+       CALL histwrite_phy(o_t_tropopause, t_tropopause)
+       CALL histwrite_phy(o_z_tropopause, z_tropopause)
+
 #ifdef CPP_StratAer
        IF (type_trac=='coag') THEN
@@ -1244,5 +1252,4 @@
           CALL histwrite_phy(o_budg_sed_part,        budg_sed_part)
           CALL histwrite_phy(o_surf_PM25_sulf, surf_PM25_sulf)
-          CALL histwrite_phy(o_p_tropopause, p_tropopause)
           CALL histwrite_phy(o_vsed_aer, vsed_aer)
           CALL histwrite_phy(o_f_r_wet, f_r_wet)
Index: /LMDZ5/trunk/libf/phylmd/physiq_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/physiq_mod.F90	(revision 2991)
+++ /LMDZ5/trunk/libf/phylmd/physiq_mod.F90	(revision 2992)
@@ -3496,5 +3496,5 @@
              CALL readaerosolstrato1_rrtm(debut)
             ELSEIF (flag_aerosol_strat.EQ.2) THEN
-             CALL stratosphere_mask(t_seri, pplay, latitude_deg)
+             CALL stratosphere_mask(missing_val, t_seri, pplay, latitude_deg)
              CALL readaerosolstrato2_rrtm(debut)
             ELSE
@@ -3514,5 +3514,5 @@
 #ifdef CPP_StratAer
        !--compute stratospheric mask
-       CALL stratosphere_mask(t_seri, pplay, latitude_deg)
+       CALL stratosphere_mask(missing_val, t_seri, pplay, latitude_deg)
        !--interactive strat aerosols
        CALL calcaerosolstrato_rrtm(pplay,t_seri,paprs,debut)
Index: /LMDZ5/trunk/libf/phylmd/stratosphere_mask.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/stratosphere_mask.F90	(revision 2991)
+++ /LMDZ5/trunk/libf/phylmd/stratosphere_mask.F90	(revision 2992)
@@ -2,5 +2,5 @@
 ! $Id$
 !
-SUBROUTINE stratosphere_mask(t_seri, pplay, xlat)
+SUBROUTINE stratosphere_mask(missing_val, t_seri, pplay, xlat)
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -22,8 +22,9 @@
 !       gamma           tropopause criterion, e.g. -0.002 K/m
 !
-! output:   tp(nlon, nlat)      tropopause pressure in Pa, -999. if undefined
-!           ttp(nlon, nlat)     tropopause temperature in K, -999. if undefined
-!           ztp(nlon, nlat)     tropopause height in m, -999. if undefined
-!       tperr           # of undetermined values
+! output:   p_tropopause(klon)     tropopause pressure in Pa with missing values
+!           t_tropopause(klon)     tropopause temperature in K with missing values
+!           z_tropopause(klon)     tropopause height in m with missing values
+!           stratomask             stratospheric mask withtout missing values
+!           ifil                  # of undetermined values
 !
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -31,11 +32,10 @@
 USE dimphy
 USE phys_local_var_mod, ONLY: stratomask
-#ifdef CPP_StratAer
-USE phys_local_var_mod, ONLY: p_tropopause
-#endif
+USE phys_local_var_mod, ONLY: p_tropopause, z_tropopause, t_tropopause
 USE print_control_mod, ONLY: lunout, prt_level
 
 IMPLICIT NONE
 
+REAL, INTENT(IN)                       :: missing_val ! missing value, also XIOS
 REAL,DIMENSION(klon,klev),INTENT(IN)   :: t_seri  ! Temperature
 REAL,DIMENSION(klon,klev),INTENT(IN)   :: pplay   ! pression pour le mileu de chaque couche (en Pa)
@@ -46,12 +46,12 @@
 REAL, PARAMETER                        :: gamma=-0.002
 LOGICAL, PARAMETER                     :: dofill=.true.
-REAL,DIMENSION(klon)                   :: tp, ttp, ztp
+REAL,DIMENSION(klon)                   :: tp
 REAL,DIMENSION(klev)                   :: t, p
-INTEGER                                :: tperr, i, k, invert, ifil
+INTEGER                                :: i, k, ifil
 REAL                                   :: ptrp, ttrp, ztrp, psrf, zsrf, pi
 
 pi     = 4.*ATAN(1.)
 
-tperr = 0
+!--computing tropopause
 DO i=1,klon
   DO k=1,klev 
@@ -61,18 +61,16 @@
   psrf=pplay(i,1)
   zsrf=0.0
-  call twmo(klev, t, p, psrf, zsrf, plimu, pliml, gamma, ptrp, ttrp, ztrp)
+  call twmo(missing_val, klev, t, p, psrf, zsrf, plimu, pliml, gamma, ptrp, ttrp, ztrp)
   tp(i)=ptrp
-  ttp(i)=ttrp
-  ztp(i)=ztrp
-  IF (ptrp.lt.0.0) THEN 
-    tperr = tperr+1 
-  ENDIF
+  p_tropopause(i)=ptrp
+  z_tropopause(i)=ztrp
+  t_tropopause(i)=ttrp
 ENDDO
 
-! fill holes
+!--filling holes in tp but not in p_tropopause
 IF (dofill) THEN
   ifil=0
   DO i=1,klon
-  IF (tp(i).lt.-990.) THEN
+  IF (ABS(tp(i)/missing_val-1.0).LT.0.01) THEN
     !set missing values to very simple profile (neighbour averaging too expensive in LMDZ)
     tp(i)=50000.-20000.*cos(xlat(i)/360.*2.*pi)
@@ -81,7 +79,4 @@
   ENDDO
 !
-  IF (ifil.ne.tperr) THEN
-    CALL abort_physic('stratosphere_mask', 'inconsistency',1)
-  ENDIF
 ENDIF
 !
@@ -96,11 +91,5 @@
 ENDDO
 
-!--this is only diagnosedd in the case of StratAer
-!--but it could be useful to LMDz
-#ifdef CPP_StratAer
-p_tropopause(:)=tp(:)
-#endif
-
-IF (ifil.gt.0 .and. prt_level >5) THEN
+IF (ifil.GT.0 .AND. prt_level >5) THEN
   write(lunout,*)'Tropopause: number of undetermined values =', ifil
 ENDIF
@@ -113,5 +102,5 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-subroutine twmo(level, t, p, ps, zs, plimu, pliml, gamma, ptrp, ttrp, ztrp)
+subroutine twmo(missing_val, level, t, p, ps, zs, plimu, pliml, gamma, ptrp, ttrp, ztrp)
 
 implicit none
@@ -120,4 +109,5 @@
 
 integer,intent(in)              :: level
+real,intent(in)                 :: missing_val
 real,intent(in),dimension(level):: t, p
 real,intent(in)                 :: plimu, pliml, gamma, ps, zs
@@ -134,7 +124,7 @@
 integer  :: icount, jj, j
 
-ptrp=-999.0             
-ttrp=-999.0                 
-ztrp=-999.0                 
+ptrp=missing_val
+ttrp=missing_val
+ztrp=missing_val
 
 faktor = -RG/R
Index: /LMDZ5/trunk/libf/phylmd/tropopause_m.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/tropopause_m.F90	(revision 2991)
+++ /LMDZ5/trunk/libf/phylmd/tropopause_m.F90	(revision 2992)
@@ -1,5 +1,4 @@
 MODULE tropopause_m
 
-!  USE phys_local_var_mod, ONLY: ptrop => pr_tropopause
   IMPLICIT NONE
   PRIVATE
