Index: LMDZ5/trunk/libf/phylmd/StratAer/interp_sulf_input.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/StratAer/interp_sulf_input.F90	(revision 2703)
+++ LMDZ5/trunk/libf/phylmd/StratAer/interp_sulf_input.F90	(revision 2704)
@@ -71,5 +71,5 @@
 !$OMP THREADPRIVATE(OCS_clim,SO2_clim)
 !
-  INTEGER i, k, kk, ilon, ilev, j
+  INTEGER i, k, kk, j
   REAL p_bound
 
@@ -89,9 +89,4 @@
   5.53084382e+01,   3.35462635e+01,   0.0           /)
 !
-  REAL, PARAMETER :: epsilon_OCS=1.0e-20     ! minimum OCS concentration [kg/kgA] for weighting of lifetime
-  REAL, PARAMETER :: epsilon_SO2=1.0e-20     ! minimum SO2 concentration [kg/kgA] for weighting of lifetime
-  REAL, PARAMETER :: min_OCS_lifetime= 3600. !minimum OCS lifetime [sec]
-  REAL, PARAMETER :: min_SO2_lifetime=86400. !minimum SO2 lifetime [sec]
-
  IF (.NOT.ALLOCATED(OCS_clim)) ALLOCATE(OCS_clim(klon,klev))
  IF (.NOT.ALLOCATED(SO2_clim)) ALLOCATE(SO2_clim(klon,klev))
@@ -183,5 +178,5 @@
 
   !---regrid weighted lifetime and climatologies
-  DO i=1, klon
+  DO i=1, klon_glo
     DO k=1, klev
      OCS_lifetime_glo(i,k)=0.0
@@ -206,5 +201,5 @@
   ENDDO
 
-  ENDIF ! is_mpi_root
+  ENDIF !--is_mpi_root and is_omp_root
 
 !--keep memory of previous month
@@ -255,8 +250,8 @@
 
   !convert SO2_backgr_tend from kg(SO2)/kgA to kg(S)/m2/layer/s for saving as diagnostic
-  DO ilon=1, klon
-    DO ilev=1, klev
-      SO2_backgr_tend(ilon,ilev)=SO2_backgr_tend(ilon,ilev)*mSatom/mSO2mol*(paprs(ilon,ilev)-paprs(ilon,ilev+1))/RG/pdtphys
-      OCS_backgr_tend(ilon,ilev)=OCS_backgr_tend(ilon,ilev)*mSatom/mOCSmol*(paprs(ilon,ilev)-paprs(ilon,ilev+1))/RG/pdtphys
+  DO i=1, klon
+    DO k=1, klev
+      SO2_backgr_tend(i,k)=SO2_backgr_tend(i,k)*mSatom/mSO2mol*(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
+      OCS_backgr_tend(i,k)=OCS_backgr_tend(i,k)*mSatom/mOCSmol*(paprs(i,k)-paprs(i,k+1))/RG/pdtphys
     ENDDO
   ENDDO
Index: LMDZ5/trunk/libf/phylmd/StratAer/miecalc_aer.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/StratAer/miecalc_aer.F90	(revision 2703)
+++ LMDZ5/trunk/libf/phylmd/StratAer/miecalc_aer.F90	(revision 2704)
@@ -24,4 +24,5 @@
   USE mod_grid_phy_lmdz, ONLY : klon_glo
   USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+  USE print_control_mod, ONLY: prt_level, lunout
 
   IMPLICIT NONE
@@ -70,7 +71,4 @@
   PARAMETER (Nbin=10)
 
-!--has to be consistent with dataset
-  INTEGER nb_lambda_h2so4
-  PARAMETER (nb_lambda_h2so4=62) !61, 235
 
 !---wavelengths STREAMER
@@ -131,5 +129,5 @@
   REAL final_w(1:NwvmaxSW+nwave_sw+nwave_lw+NwvmaxLW)
 
-  INTEGER band, bandSW, bandLW
+  INTEGER band, bandSW, bandLW, wavenumber
 
 !---wavelengths SW RRTM
@@ -156,10 +154,75 @@
   REAL ss_g(nbands_sw_rrtm+nbands_lw_rrtm+nwave_sw+nwave_lw)
 
-  REAL wavenumber
-  REAL, DIMENSION(nb_lambda_h2so4,4) :: ref_ind
-
+  INTEGER, PARAMETER :: nb_lambda_h2so4=62
+  REAL, DIMENSION (nb_lambda_h2so4,4) :: ref_ind
+  !-- fichier h2so4_0.75_300.00_hummel_1988_p_q.dat
+  ! -- wavenumber (cm-1), wavelength (um), n_r, n_i
+  DATA ref_ind /                                &
+   200.000,   50.0000,   2.01000,   6.5000E-01, &
+   250.000,   40.0000,   1.94000,   6.3000E-01, & 
+   285.714,   35.0000,   1.72000,   5.2000E-01, & 
+   333.333,   30.0000,   1.73000,   2.9000E-01, & 
+   358.423,   27.9000,   1.78000,   2.5000E-01, & 
+   400.000,   25.0000,   1.84000,   2.4000E-01, &
+   444.444,   22.5000,   1.82000,   2.9000E-01, &
+   469.484,   21.3000,   1.79000,   2.5000E-01, &
+   500.000,   20.0000,   1.81000,   2.3000E-01, &
+   540.541,   18.5000,   1.92700,   3.0200E-01, &
+   555.556,   18.0000,   1.95000,   4.1000E-01, &
+   581.395,   17.2000,   1.72400,   5.9000E-01, &
+   609.756,   16.4000,   1.52000,   4.1400E-01, &
+   666.667,   15.0000,   1.59000,   2.1100E-01, &
+   675.676,   14.8000,   1.61000,   2.0500E-01, &
+   714.286,   14.0000,   1.64000,   1.9500E-01, &
+   769.231,   13.0000,   1.69000,   1.9500E-01, &
+   800.000,   12.5000,   1.74000,   1.9800E-01, &
+   869.565,   11.5000,   1.89000,   3.7400E-01, &
+   909.091,   11.0000,   1.67000,   4.8500E-01, &
+   944.198,   10.5910,   1.72000,   3.4000E-01, &
+  1000.000,   10.0000,   1.89000,   4.5500E-01, &
+  1020.408,    9.8000,   1.91000,   6.8000E-01, &
+  1052.632,    9.5000,   1.67000,   7.5000E-01, &
+  1086.957,    9.2000,   1.60000,   5.8600E-01, &
+  1111.111,    9.0000,   1.65000,   6.3300E-01, &
+  1149.425,    8.7000,   1.53000,   7.7200E-01, &
+  1176.471,    8.5000,   1.37000,   7.5500E-01, &
+  1219.512,    8.2000,   1.20000,   6.4500E-01, &
+  1265.823,    7.9000,   1.14000,   4.8800E-01, &
+  1388.889,    7.2000,   1.21000,   1.7600E-01, &
+  1538.462,    6.5000,   1.37000,   1.2800E-01, &
+  1612.903,    6.2000,   1.42400,   1.6500E-01, &
+  1666.667,    6.0000,   1.42500,   1.9500E-01, &
+  1818.182,    5.5000,   1.33700,   1.8300E-01, &
+  2000.000,    5.0000,   1.36000,   1.2100E-01, &
+  2222.222,    4.5000,   1.38500,   1.2000E-01, &
+  2500.000,    4.0000,   1.39800,   1.2600E-01, &
+  2666.667,    3.7500,   1.39600,   1.3100E-01, &
+  2857.143,    3.5000,   1.37600,   1.5800E-01, &
+  2948.113,    3.3920,   1.35200,   1.5900E-01, &
+  3125.000,    3.2000,   1.31100,   1.3500E-01, &
+  3333.333,    3.0000,   1.29300,   9.5500E-02, &
+  3703.704,    2.7000,   1.30300,   5.7000E-03, &
+  4000.000,    2.5000,   1.34400,   3.7600E-03, &
+  4444.444,    2.2500,   1.37000,   1.8000E-03, &
+  5000.000,    2.0000,   1.38400,   1.2600E-03, &
+  5555.556,    1.8000,   1.39000,   5.5000E-04, &
+  6510.417,    1.5360,   1.40300,   1.3700E-04, &
+  7692.308,    1.3000,   1.41000,   1.0000E-05, &
+  9433.962,    1.0600,   1.42000,   1.5000E-06, &
+ 11627.907,    0.8600,   1.42500,   1.7900E-07, &
+ 14409.222,    0.6940,   1.42800,   1.9900E-08, &
+ 15797.788,    0.6330,   1.42900,   1.4700E-08, &
+ 18181.818,    0.5500,   1.43000,   1.0000E-08, &
+ 19417.476,    0.5150,   1.43100,   1.0000E-08, &
+ 20491.803,    0.4880,   1.43200,   1.0000E-08, &
+ 25000.000,    0.4000,   1.44000,   1.0000E-08, &
+ 29673.591,    0.3370,   1.45900,   1.0000E-08, &
+ 33333.333,    0.3000,   1.46900,   1.0000E-08, &
+ 40000.000,    0.2500,   1.48400,   1.0000E-08, &
+ 50000.000,    0.2000,   1.49800,   1.0000E-08 /
 !---------------------------------------------------------
 
   IF (debut) THEN   
+
   !--initialising dry diameters to geometrically spaced mass/volume (see Jacobson 1994)
       mdw(1)=mdwmin
@@ -176,10 +239,4 @@
       PRINT *,'init mdw=', mdw
 
-!$OMP MASTER
-
-!    CALL gather(tr_seri, tr_seri_glo)
-!    IF (is_mpi_root) THEN
-!    IF (MAXVAL(tr_seri_glo).LT.1e-30) THEN
-
     !--compute particle radius for a composition of 75% H2SO4 / 25% H2O at T=293K
     DO bin_number=1, nbtr_bin
@@ -225,10 +282,6 @@
       &  lambda_int(NwvmaxSW+nwave_sw+nwave_lw+Nwv)
 
-      OPEN (unit=11,file='h2so4_0.75_300.00_hummel_1988_p_q.dat')
-
       IF (refr_ind_interpol) THEN
-        DO nb=1,nb_lambda_h2so4
-          READ(11,*) ref_ind(nb,:)
-        ENDDO
+
         ilambda_max=ref_ind(1,2)/1.e6 !--in m
         ilambda_min=ref_ind(nb_lambda_h2so4,2)/1.e6 !--in m
@@ -259,17 +312,18 @@
           ENDIF
         ENDDO
-      ELSE
-        DO nb=1,nb_lambda_h2so4
-          READ(11,*) wavenumber, ilambda, n_r_h2so4, n_i_h2so4
-          ilambda=1000.*ilambda !wavelength in nm
-          DO Nwv=1, NwvmaxSW+nwave_sw+nwave_lw+NwvmaxLW
-            IF (ilambda/1.e9.GT.lambda_int(Nwv)) THEN !--- step function
-              n_r(Nwv)=n_r_h2so4
-              n_i(Nwv)=n_i_h2so4 
+
+      ELSE  !-- no refr_ind_interpol, closest neighbour from upper wavelength
+
+        DO Nwv=1, NwvmaxSW+nwave_sw+nwave_lw+NwvmaxLW
+          n_r(Nwv)=ref_ind(1,3)
+          n_i(Nwv)=ref_ind(1,4)
+          DO nb=2,nb_lambda_h2so4
+            IF (ref_ind(nb,2)/1.e6.GT.lambda_int(Nwv)) THEN !--- step function
+              n_r(Nwv)=ref_ind(nb,3)
+              n_i(Nwv)=ref_ind(nb,4)
             ENDIF  
           ENDDO
         ENDDO
       ENDIF
-      CLOSE(11)
 
     !---Loop on wavelengths
@@ -400,5 +454,4 @@
 
       ENDDO  !--loop on wavelength
-
 
     !---averaging over LMDZ wavebands
@@ -491,20 +544,13 @@
         piz_bin(nb,bin_number)=ss_w(nb)
         cg_bin(nb,bin_number)=ss_g(nb)
-
       ENDDO
 
     ENDDO !loop over tracer bins
 
-!    ENDIF !mpi_root
-
-!$OMP END MASTER
-  CALL bcast(alpha_bin)
-  CALL bcast(piz_bin)
-  CALL bcast(cg_bin)
-!$OMP BARRIER
-
-!    CALL scatter(alpha_bin, alpha_bin)
-!    CALL scatter(piz_bin, piz_bin)
-!    CALL scatter(cg_bin, cg_bin)
+!!$OMP END MASTER
+!  CALL bcast(alpha_bin)
+!  CALL bcast(piz_bin)
+!  CALL bcast(cg_bin)
+!!$OMP BARRIER
 
     !set to default values at first time step (tr_seri still zero)
@@ -515,7 +561,5 @@
     tau_strat_wave(:,:,:)=1.e-15
 
-  ELSE
-
-!    CALL gather(tr_seri, tr_seri_glo)
+  ELSE  !-- not debut
 
   !--compute optical properties of actual size distribution (from tr_seri)
Index: LMDZ5/trunk/libf/phylmd/StratAer/traccoag_mod.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/StratAer/traccoag_mod.F90	(revision 2703)
+++ LMDZ5/trunk/libf/phylmd/StratAer/traccoag_mod.F90	(revision 2704)
@@ -73,8 +73,4 @@
     REAL,PARAMETER    :: xlat_sai=0.0           ! latitude of SAI in degree
     REAL,PARAMETER    :: xlon_sai=120.35        ! longitude of SAI in degree
-
-!--be careful - this needs to be changed with resolution - here for 96x95 - seems to work for 48x36 as well
-    REAL,PARAMETER    :: dlat=0.9474   ! d latitude in degree
-    REAL,PARAMETER    :: dlon=1.875    ! d longitude in degree
 
 !--other local variables
@@ -95,8 +91,12 @@
     REAL                                   :: zdz                 ! thickness of atm. model layer in m
     REAL,DIMENSION(klon,klev)              :: dens_aer            ! density of aerosol particles [kg/m3 aerosol] with default H2SO4 mass fraction
+    REAL                                   :: dlat, dlon          ! d latitude and d longitude of grid in degree
 
     IF (is_mpi_root) THEN
       PRINT *,'in traccoag: date from phys_cal_mod =',year_cur,'-',mth_cur,'-',day_cur,'-',hour
     ENDIF
+
+    dlat=180./2./FLOAT(nbp_lat)   ! d latitude in degree
+    dlon=360./2./FLOAT(nbp_lon)   ! d longitude in degree
 
     DO it=1, nbtr_bin
@@ -168,6 +168,6 @@
         DO i=1,klon
           !Pinatubo eruption at 15.14N, 120.35E
-          IF  ( xlat(i).GT.xlat_vol-dlat .AND. xlat(i).LT.xlat_vol+dlat .AND. &
-                xlon(i).GT.xlon_vol-dlon .AND. xlon(i).LT.xlon_vol+dlon ) THEN
+          IF  ( xlat(i).GE.xlat_vol-dlat .AND. xlat(i).LT.xlat_vol+dlat .AND. &
+                xlon(i).GE.xlon_vol-dlon .AND. xlon(i).LT.xlon_vol+dlon ) THEN
 !         compute altLMDz
             altLMDz(:)=0.0
@@ -209,6 +209,6 @@
 !       IF  ((mth_cur==4 .AND. &
 !       SAI continuous emission o
-        IF  ( xlat(i).GT.xlat_sai-dlat .AND. xlat(i).LT.xlat_sai+dlat .AND. &
-          &   xlon(i).GT.xlon_sai-dlon .AND. xlon(i).LT.xlon_sai+dlon ) THEN
+        IF  ( xlat(i).GE.xlat_sai-dlat .AND. xlat(i).LT.xlat_sai+dlat .AND. &
+          &   xlon(i).GE.xlon_sai-dlon .AND. xlon(i).LT.xlon_sai+dlon ) THEN
 !         compute altLMDz
           altLMDz(:)=0.0
Index: LMDZ5/trunk/libf/phylmd/conf_phys_m.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/conf_phys_m.F90	(revision 2703)
+++ LMDZ5/trunk/libf/phylmd/conf_phys_m.F90	(revision 2704)
@@ -117,7 +117,7 @@
     INTEGER, SAVE       :: iflag_ratqs_omp
 
-    Real, SAVE          :: f_cdrag_ter_omp,f_cdrag_oce_omp
-    Real, SAVE          :: f_rugoro_omp   , z0min_omp
-    Real, SAVE          :: z0m_seaice_omp,z0h_seaice_omp
+    REAL, SAVE          :: f_cdrag_ter_omp,f_cdrag_oce_omp
+    REAL, SAVE          :: f_rugoro_omp   , z0min_omp
+    REAL, SAVE          :: z0m_seaice_omp,z0h_seaice_omp
     REAL, SAVE          :: min_wind_speed_omp,f_gust_wk_omp,f_gust_bl_omp,f_qsat_oce_omp, f_z0qh_oce_omp
     INTEGER, SAVE       :: iflag_gusts_omp,iflag_z0_oce_omp
@@ -186,5 +186,5 @@
     INTEGER,SAVE :: iflag_pbl_split_omp
     INTEGER,SAVE :: iflag_order2_sollw_omp
-    Integer, SAVE :: lev_histins_omp, lev_histLES_omp 
+    INTEGER, SAVE :: lev_histins_omp, lev_histLES_omp 
     INTEGER, SAVE :: lev_histdayNMC_omp
     INTEGER, SAVE :: levout_histNMC_omp(3)
Index: LMDZ5/trunk/libf/phylmd/phys_output_mod.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/phys_output_mod.F90	(revision 2703)
+++ LMDZ5/trunk/libf/phylmd/phys_output_mod.F90	(revision 2704)
@@ -41,5 +41,5 @@
     USE mod_phys_lmdz_para
     USE aero_mod, only : naero_spc,name_aero
-	!Martin
+    !Martin
     USE surface_data, ONLY : ok_snow
     USE phys_output_ctrlout_mod
@@ -265,5 +265,5 @@
          CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
          CALL ymds2ju(annee_ref, 1, day_ini, start_time*rday, zjulian_start)
-     END IF
+     ENDIF
 
 #ifdef CPP_XIOS
@@ -293,5 +293,5 @@
     WRITE(lunout,*)'Bp Hybrid = ',Bhyb(1:klev)
     WRITE(lunout,*)'Alt approx des couches pour une haut d echelle de 8km = ',Alt(1:klev)
-    !          endif
+    !          ENDIF
 
   ecrit_files(7) = ecrit_files(1)
@@ -302,13 +302,13 @@
 
        ! Calculate ecrit_files for all files
-      IF ( chtimestep(iff).eq.'Default' ) then
+      IF ( chtimestep(iff).eq.'Default' ) THEN
           ! Par defaut ecrit_files = (ecrit_mensuel ecrit_jour ecrit_hf
           ! ...)*86400.
           ecrit_files(iff)=ecrit_files(iff)*86400.
-      ELSE IF (chtimestep(iff).eq.'-1') then
+      ELSE IF (chtimestep(iff).eq.'-1') THEN
           PRINT*,'ecrit_files(',iff,') < 0 so IOIPSL work on different'
           PRINT*,'months length'
           ecrit_files(iff)=-1.
-      else
+      ELSE
        CALL convers_timesteps(chtimestep(iff),dtime,ecrit_files(iff)) 
       ENDIF
@@ -320,16 +320,16 @@
 #ifdef CPP_XIOS
 !!! Ouverture de chaque fichier XIOS !!!!!!!!!!!
-    IF (.not. ok_all_xml) then
-      if (prt_level >= 10) then
+    IF (.not. ok_all_xml) THEN
+      IF (prt_level >= 10) THEN
         print*,'phys_output_open: call wxios_add_file with phys_out_filenames(iff)=',trim(phys_out_filenames(iff))    
-      endif
+      ENDIF
       CALL wxios_add_file(phys_out_filenames(iff),chtimestep(iff),lev_files(iff))  
     ENDIF
 
 !!! Declaration des axes verticaux de chaque fichier:
-    if (prt_level >= 10) then
+    IF (prt_level >= 10) THEN
       print*,'phys_output_open: Declare vertical axes for each file'
-    endif
-   if (iff.le.6) then
+    ENDIF
+   IF (iff.le.6) THEN
     CALL wxios_add_vaxis("presnivs", &
             levmax(iff) - levmin(iff) + 1, presnivs(levmin(iff):levmax(iff)))
@@ -340,9 +340,9 @@
     CALL wxios_add_vaxis("Alt", &
             levmax(iff) - levmin(iff) + 1, Alt)
-   else
+   ELSE
     ! NMC files
     CALL wxios_add_vaxis("plev", &
             levmax(iff) - levmin(iff) + 1, rlevSTD(levmin(iff):levmax(iff)))
-   endif
+   ENDIF
 #endif 
 
@@ -350,5 +350,5 @@
 !!!!!!!!!!!!!!!!! Traitement dans le cas ou l'on veut stocker sur un domaine limite !!
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-          IF (phys_out_regfkey(iff)) then
+          IF (phys_out_regfkey(iff)) THEN
              imin_ins=1
              imax_ins=nbp_lon
@@ -357,15 +357,15 @@
 
              ! correction abderr        
-             do i=1,nbp_lon
+             DO i=1,nbp_lon
                 WRITE(lunout,*)'io_lon(i)=',io_lon(i)
                 IF (io_lon(i).le.phys_out_lonmin(iff)) imin_ins=i
                 IF (io_lon(i).le.phys_out_lonmax(iff)) imax_ins=i+1
-             enddo
-
-             do j=1,jjmp1
+             ENDDO
+
+             DO j=1,jjmp1
                 WRITE(lunout,*)'io_lat(j)=',io_lat(j)
                 IF (io_lat(j).ge.phys_out_latmin(iff)) jmax_ins=j+1
                 IF (io_lat(j).ge.phys_out_latmax(iff)) jmin_ins=j
-             enddo
+             ENDDO
 
              WRITE(lunout,*)'On stoke le fichier histoire numero ',iff,' sur ', &
@@ -382,20 +382,20 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
              !IM fichiers stations
-          else IF (clef_stations(iff)) THEN
-
-             if (prt_level >= 10) then
+          ELSE IF (clef_stations(iff)) THEN
+
+             IF (prt_level >= 10) THEN
              WRITE(lunout,*)'phys_output_open: iff=',iff,'  phys_out_filenames(iff)=',phys_out_filenames(iff)
-             endif
+             ENDIF
              
              CALL histbeg_phy_all(rlon,rlat,pim,tabij,ipt,jpt,plon,plat,plon_bounds,plat_bounds, &
                   phys_out_filenames(iff), &
                   itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
-          else
+          ELSE
              CALL histbeg_phy_all(phys_out_filenames(iff),itau_phy,zjulian,&
                  dtime,nhorim(iff),nid_files(iff))
-          endif
+          ENDIF
 
 #ifndef CPP_IOIPSL_NO_OUTPUT 
-          if (iff.le.6) then
+          IF (iff.le.6) THEN
              CALL histvert(nid_files(iff), "presnivs", "Vertical levels", "Pa", &  
                levmax(iff) - levmin(iff) + 1, &
@@ -411,18 +411,15 @@
                levmax(iff) - levmin(iff) + 1,Alt,nvertAlt(iff))
 
-          else
+          ELSE
              CALL histvert(nid_files(iff), "plev", "pressure", "Pa", &
                levmax(iff) - levmin(iff) + 1, &
               rlevSTD(levmin(iff):levmax(iff)), nvertm(iff), "down")
-          endif
+          ENDIF
 #endif
 
      ENDIF ! clef_files
 
-!CR: ajout d'une variable eau
-!      IF (nqtot>=3) THEN
-
        IF (nqtot>=nqo+1) THEN
-!            DO iq=3,nqtot  
+!
             DO iq=nqo+1,nqtot 
             iiq=niadv(iq)
@@ -507,5 +504,4 @@
       ENDIF
 
-
    ENDDO !  iff
 
@@ -519,12 +515,10 @@
     ecrit_ins = ecrit_files(6)
 
-    if (prt_level >= 10) then
+    IF (prt_level >= 10) THEN
       WRITE(lunout,*)'swaero_diag=',swaero_diag
       WRITE(lunout,*)'phys_output_open: ends here'
-    endif
-
-  end SUBROUTINE phys_output_open
-
-
+    ENDIF
+
+  END SUBROUTINE phys_output_open
 
   SUBROUTINE convers_timesteps(str,dtime,timestep)
@@ -548,5 +542,5 @@
     WRITE(lunout,*) "ipos = ", ipos
     WRITE(lunout,*) "il = ", il
-    if (ipos == 0) call abort_physic("convers_timesteps", "bad str", 1)
+    IF (ipos == 0) CALL abort_physic("convers_timesteps", "bad str", 1)
     read(str(1:ipos),*) ttt
     WRITE(lunout,*)ttt
@@ -554,13 +548,13 @@
 
 
-    IF ( il == ipos ) then
+    IF ( il == ipos ) THEN
        type='day'
-    endif
+    ENDIF
 
     IF ( type == 'day'.or.type == 'days'.or.type == 'jours'.or.type == 'jour' ) timestep = ttt * dayseconde
-    IF ( type == 'mounths'.or.type == 'mth'.or.type == 'mois' ) then
+    IF ( type == 'mounths'.or.type == 'mth'.or.type == 'mois' ) THEN
        WRITE(lunout,*)'annee_ref,day_ref mon_len',annee_ref,day_ref,mth_len
        timestep = ttt * dayseconde * mth_len
-    endif
+    ENDIF
     IF ( type == 'hours'.or.type == 'hr'.or.type == 'heurs') timestep = ttt * dayseconde / 24.
     IF ( type == 'mn'.or.type == 'minutes'  ) timestep = ttt * 60.
@@ -575,4 +569,2 @@
 
 END MODULE phys_output_mod
-
-
Index: LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 2703)
+++ LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90	(revision 2704)
@@ -6,5 +6,5 @@
   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
+       d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav, flux_tr_dry
 
   ! Author: Abderrahmane IDELKADI (original include file)
@@ -24,9 +24,10 @@
     ! defined and initialised in phys_output_mod.F90
 
-    USE dimphy, only: klon, klev, klevp1
+    USE dimphy, ONLY: klon, klev, klevp1
+    USE infotrac, ONLY: nbtr
     USE mod_phys_lmdz_para, ONLY: is_north_pole_phy,is_south_pole_phy
     USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
-    USE time_phylmdz_mod, only: day_step_phy, start_time, itau_phy
-    USE phys_output_ctrlout_mod, only: o_phis, o_aire, is_ter, is_lic, is_oce, &
+    USE time_phylmdz_mod, ONLY: day_step_phy, start_time, itau_phy
+    USE phys_output_ctrlout_mod, ONLY: o_phis, o_aire, is_ter, is_lic, is_oce, &
          is_ave, is_sic, o_contfracATM, o_contfracOR, &
          o_aireTER, o_flat, o_slp, o_ptstar, o_pt0, o_tsol, &
@@ -163,5 +164,5 @@
          o_dtr_lessi_impa, o_dtr_lessi_nucl, &
          o_dtr_insc, o_dtr_bcscav, o_dtr_evapls, &
-         o_dtr_ls, o_dtr_trsp, o_dtr_sscav, &
+         o_dtr_ls, o_dtr_trsp, o_dtr_sscav, o_dtr_dry, &
          o_dtr_sat, o_dtr_uscav, o_trac_cum, o_du_gwd_rando, o_dv_gwd_rando, &
          o_ustr_gwd_hines,o_vstr_gwd_hines,o_ustr_gwd_rando,o_vstr_gwd_rando, &
@@ -183,5 +184,5 @@
 
 #ifdef CPP_StratAer
-    USE phys_output_ctrlout_mod, only:  & 
+    USE phys_output_ctrlout_mod, ONLY:  & 
          o_sulf_convert, o_sulf_nucl, o_sulf_cond_evap, o_ocs_convert, &
          o_sfluxaer, o_R2SO4, o_OCS_lifetime, o_SO2_lifetime, &
@@ -191,5 +192,5 @@
 #endif
 
-    USE phys_state_var_mod, only: pctsrf, paire_ter, rain_fall, snow_fall, &
+    USE phys_state_var_mod, ONLY: pctsrf, paire_ter, rain_fall, snow_fall, &
          qsol, z0m, z0h, fevap, agesno, &
          nday_rain, rain_con, snow_con, &
@@ -218,5 +219,5 @@
          vphiSTD, wTSTD, u2STD, v2STD, T2STD, missing_val_nf90
 
-    USE phys_local_var_mod, only: zxfluxlat, slp, ptstar, pt0, zxtsol, zt2m, &
+    USE phys_local_var_mod, ONLY: zxfluxlat, slp, ptstar, pt0, zxtsol, zt2m, &
          t2m_min_mon, t2m_max_mon, evap, &
          l_mixmin,l_mix, &
@@ -282,5 +283,5 @@
 
 #ifdef CPP_StratAer 
-    USE phys_local_var_mod, only:  &
+    USE phys_local_var_mod, ONLY:  &
          sulf_convert, sulf_nucl, sulf_cond_evap, ocs_convert, &
          sfluxaer, R2SO4, OCS_lifetime, SO2_lifetime, &
@@ -290,5 +291,5 @@
 #endif
 
-    USE phys_output_var_mod, only: vars_defined, snow_o, zfra_o, bils_diss, &
+    USE phys_output_var_mod, ONLY: vars_defined, snow_o, zfra_o, bils_diss, &
          bils_ec,bils_ech, bils_tke, bils_kinetic, bils_latent, bils_enthalp, &
          itau_con, nfiles, clef_files, nid_files, &
@@ -309,16 +310,16 @@
          alt_tropo
 
-    USE ocean_slab_mod, only: nslay, tslab, slab_bils, slab_bilg, tice, &
+    USE ocean_slab_mod, ONLY: nslay, tslab, slab_bils, slab_bilg, tice, &
         seaice, slab_ekman,slab_hdiff, dt_ekman, dt_hdiff
-    USE pbl_surface_mod, only: snow
-    USE indice_sol_mod, only: nbsrf
-    USE infotrac_phy, only: nqtot, nqo, type_trac
-    USE geometry_mod, only: cell_area
-    USE surface_data, only: type_ocean, version_ocean, ok_veget, ok_snow
-!    USE aero_mod, only: naero_spc
-    USE aero_mod, only: naero_tot, id_STRAT_phy
-    USE ioipsl, only: histend, histsync
-    USE iophy, only: set_itau_iophy, histwrite_phy
-    USE netcdf, only: nf90_fill_real
+    USE pbl_surface_mod, ONLY: snow
+    USE indice_sol_mod, ONLY: nbsrf
+    USE infotrac_phy, ONLY: nqtot, nqo, type_trac, tname, niadv
+    USE geometry_mod, ONLY: cell_area
+    USE surface_data, ONLY: type_ocean, version_ocean, ok_veget, ok_snow
+!    USE aero_mod, ONLY: naero_spc
+    USE aero_mod, ONLY: naero_tot, id_STRAT_phy
+    USE ioipsl, ONLY: histend, histsync
+    USE iophy, ONLY: set_itau_iophy, histwrite_phy
+    USE netcdf, ONLY: nf90_fill_real
     USE print_control_mod, ONLY: prt_level,lunout
 
@@ -326,8 +327,8 @@
 #ifdef CPP_XIOS
     ! ug Pour les sorties XIOS
-    USE xios, ONLY: xios_update_calendar
-    USE wxios, only: wxios_closedef, missing_val
-#endif
-    USE phys_cal_mod, only : mth_len
+    USE xios
+    USE wxios, ONLY: wxios_closedef, missing_val
+#endif
+    USE phys_cal_mod, ONLY : mth_len
 
 #ifdef CPP_RRTM
@@ -336,5 +337,4 @@
 
     IMPLICIT NONE
-
 
     INCLUDE "clesphys.h"
@@ -364,5 +364,5 @@
     ! Local
     INTEGER :: itau_w
-    INTEGER :: i, iinit, iinitend=1, iff, iq, nsrf, k, ll, naero
+    INTEGER :: i, iinit, iinitend=1, iff, iq, iiq, nsrf, k, ll, naero
     REAL, DIMENSION (klon) :: zx_tmp_fi2d
     REAL, DIMENSION (klon,klev) :: zx_tmp_fi3d, zpt_conv
@@ -379,4 +379,10 @@
     INTEGER ISW
     CHARACTER*1 ch1
+    CHARACTER*20 varname
+
+#ifdef CPP_XIOS
+    TYPE(xios_fieldgroup) :: group_handle
+    TYPE(xios_field) :: child
+#endif
 
     ! On calcul le nouveau tau:
@@ -390,4 +396,73 @@
        iinitend = 1
     ENDIF
+
+#ifdef CPP_XIOS
+#ifdef CPP_StratAer
+    IF (.NOT.vars_defined) THEN
+          !On ajoute les variables 3D traceurs par l interface fortran 
+          CALL xios_get_handle("fields_strataer_trac_3D", group_handle)
+          ! On boucle sur les traceurs pour les ajouter au groupe puis fixer les attributs
+          DO iq=nqo+1, nqtot
+            iiq=niadv(iq)
+            varname=trim(tname(iiq))
+            WRITE (lunout,*) 'XIOS var=', nqo, iq, varname
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1")
+            varname='d'//trim(tname(iiq))//'_vdf'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_the'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_con'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_lessi_impa'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_lessi_nucl'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_insc'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_bcscav'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_evapls'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_ls'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_trsp'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_sscav'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_sat'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+            varname='d'//trim(tname(iiq))//'_uscav'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg kg-1 s-1")
+          ENDDO
+          !On ajoute les variables 2D traceurs par l interface fortran 
+          CALL xios_get_handle("fields_strataer_trac_2D", group_handle)
+          ! On boucle sur les traceurs pour les ajouter au groupe puis fixer les attributs
+          DO iq=nqo+1, nqtot
+            iiq=niadv(iq)
+            varname='cum'//trim(tname(iiq))
+            WRITE (lunout,*) 'XIOS var=', iq, varname
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg m-2")
+            varname='cumd'//trim(tname(iiq))//'_dry'
+            CALL xios_add_child(group_handle, child, varname)
+            CALL xios_set_attr(child, name=varname, unit="kg m-2 s-1")
+          ENDDO
+    ENDIF
+#endif
+#endif
 
     ! ug la boucle qui suit ne sert qu'une fois, pour l'initialisation, sinon il n'y a toujours qu'un seul passage:
@@ -1785,7 +1860,8 @@
 #endif
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-        IF (nqtot.GE.nqo+1) THEN
-          DO iq=nqo+1,nqtot
+       IF (nqtot.GE.nqo+1) THEN
+          DO iq=nqo+1, nqtot
             IF (type_trac == 'lmdz' .OR. type_trac == 'repr' .OR. type_trac == 'coag') THEN
+             !--3D fields
              CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
              CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
@@ -1802,4 +1878,6 @@
              CALL histwrite_phy(o_dtr_sat(iq-nqo),d_tr_sat(:,:,iq-nqo))
              CALL histwrite_phy(o_dtr_uscav(iq-nqo),d_tr_uscav(:,:,iq-nqo))
+             !--2D fields
+             CALL histwrite_phy(o_dtr_dry(iq-nqo), flux_tr_dry(:,iq-nqo))
              zx_tmp_fi2d=0.
              IF (vars_defined) THEN
@@ -1821,5 +1899,4 @@
                 ndex2d = 0
                 ndex3d = 0
-
              ENDIF ! clef_files
           ENDDO !  iff
@@ -1832,5 +1909,6 @@
           !$OMP BARRIER
           vars_defined = .TRUE.
-       ENDIF
+
+       ENDIF !--.NOT.vars_defined
 
     ENDDO
