Index: LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_interface.F90
===================================================================
--- LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_interface.F90	(revision 4175)
+++ LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_interface.F90	(revision 4727)
@@ -67,4 +67,5 @@
   use ioipsl
   use iophy
+  use lmdz_xios, ONLY : using_xios
   use lmdz_cosp_output_mod
   use lmdz_cosp_output_write_mod
@@ -262,9 +263,9 @@
 
 ! Clefs Outputs initialisation
-#ifdef CPP_XIOS
-  call cosp_outputkeys_init(cfg)
-#else
+ IF (using_xios) THEN
+   call cosp_outputkeys_init(cfg)
+ ELSE
    call read_cosp_output_nl(itap,cosp_output_nl,cfg)
-#endif
+ ENDIF
 
   print*,' Cles des differents simulateurs cosp a itap :',itap
@@ -278,29 +279,29 @@
     endif
 
-#ifdef CPP_XIOS
-   print*,'On passe par ifdef CPP_XIOS'
-#else
-if (cosp_init_flag .eq. 0) then
-
-    ! Initialize the distributional parameters for hydrometeors in radar simulator.
-    ! In COSPv1.4, this was declared in cosp_defs.f.
-    if (cloudsat_micro_scheme == 'MMF_v3.5_two_moment')  then
-       ldouble = .true. 
-       lsingle = .false.
+ IF (using_xios) THEN
+   print*,'On passe par using_xios'
+ ELSE
+   if (cosp_init_flag .eq. 0) then
+
+      ! Initialize the distributional parameters for hydrometeors in radar simulator.
+      ! In COSPv1.4, this was declared in cosp_defs.f.
+      if (cloudsat_micro_scheme == 'MMF_v3.5_two_moment')  then
+         ldouble = .true. 
+         lsingle = .false.
+      endif
+      call hydro_class_init(lsingle,ldouble,sd)
+      call quickbeam_optics_init()
+
+      print*,' just before call COSP_INIT, cosp_init_flag =', cosp_init_flag
+      call COSP_INIT(cfg%Lisccp, cfg%Lmodis, cfg%Lmisr, cfg%Lcloudsat, cfg%Lcalipso, &
+         cfg%LgrLidar532, cfg%Latlid, cfg%Lparasol, cfg%Lrttov,          &
+         cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs,         &
+         cloudsat_do_ray, isccp_topheight, isccp_topheight_direction,    &
+         surface_radar, rcfg_cloudsat, use_vgrid_in, csat_vgrid_in,      &
+         niv_sorties, Nlevels, cloudsat_micro_scheme)
+      cosp_init_flag = 1
+      print*,' just after call COSP_INIT, cosp_init_flag =', cosp_init_flag
     endif
-    call hydro_class_init(lsingle,ldouble,sd)
-    call quickbeam_optics_init()
-
-  print*,' just before call COSP_INIT, cosp_init_flag =', cosp_init_flag
-  call COSP_INIT(cfg%Lisccp, cfg%Lmodis, cfg%Lmisr, cfg%Lcloudsat, cfg%Lcalipso, &
-        cfg%LgrLidar532, cfg%Latlid, cfg%Lparasol, cfg%Lrttov,          &
-        cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs,         &
-        cloudsat_do_ray, isccp_topheight, isccp_topheight_direction,    &
-        surface_radar, rcfg_cloudsat, use_vgrid_in, csat_vgrid_in,      &
-        niv_sorties, Nlevels, cloudsat_micro_scheme)
-  cosp_init_flag = 1
- print*,' just after call COSP_INIT, cosp_init_flag =', cosp_init_flag
-endif
-#endif
+  ENDIF
 
   print*,'Fin lecture Namelists, debut_cosp =',debut_cosp
@@ -311,7 +312,5 @@
 !!! Ici on modifie les cles logiques pour les outputs selon les champs actives dans les .xml
   if ((itap.ge.1).and.(first_write))then
-#ifdef CPP_XIOS
-    call read_xiosfieldactive(cfg)
-#endif
+    IF (using_xios) call read_xiosfieldactive(cfg)
     first_write=.false.
 
Index: LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_output_mod.F90
===================================================================
--- LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_output_mod.F90	(revision 4175)
+++ LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_output_mod.F90	(revision 4727)
@@ -326,9 +326,6 @@
   USE time_phylmdz_mod, ONLY: day_ref, annee_ref, day_ini, start_time, itau_phy
   USE print_control_mod, ONLY: lunout
-
-#ifdef CPP_XIOS
-    ! ug Pour les sorties XIOS
-    USE wxios
-#endif
+  ! ug Pour les sorties XIOS
+  USE wxios
 
   IMPLICIT NONE
@@ -350,11 +347,9 @@
 !!! Variables d'entree
 
-#ifdef CPP_XIOS
-    ! ug Variables utilisées pour récupérer le calendrier pour xios
-    INTEGER :: x_an, x_mois, x_jour
-    REAL :: x_heure
-    INTEGER :: ini_an, ini_mois, ini_jour
-    REAL :: ini_heure
-#endif
+  ! ug Variables utilisées pour récupérer le calendrier pour xios
+  INTEGER :: x_an, x_mois, x_jour
+  REAL :: x_heure
+  INTEGER :: ini_an, ini_mois, ini_jour
+  REAL :: ini_heure
 
     WRITE(lunout,*) 'Debut lmdz_cosp_output_mod.F90'
@@ -401,9 +396,10 @@
     CALL ymds2ju(annee_ref, 1, day_ini, start_time, zjulian_start)
 
-#ifdef CPP_XIOS
+  IF (using_xios) THEN
+
     
-! recuperer la valeur indefine Xios
-!    CALL xios_get_field_attr("clcalipso",default_value=Cosp_fill_value)
-!         Cosp_fill_value=missing_val
+  ! recuperer la valeur indefine Xios
+  !    CALL xios_get_field_attr("clcalipso",default_value=Cosp_fill_value)
+  !         Cosp_fill_value=missing_val
           Cosp_fill_value=0.
          print*,'Cosp_fill_value=',Cosp_fill_value
@@ -426,33 +422,33 @@
     CALL wxios_add_vaxis("column", Ncolumns, column_ax)
 
-   WRITE(lunout,*) 'wxios_add_vaxis temp LIDAR_NTEMP, LIDAR_PHASE_TEMP ', &
-                    LIDAR_NTEMP, LIDAR_PHASE_TEMP
-   CALL wxios_add_vaxis("temp", LIDAR_NTEMP, LIDAR_PHASE_TEMP)
-
-   WRITE(lunout,*) 'wxios_add_vaxis cth16 numMISRHgtBins, misr_histHgtCenters ', & 
+    WRITE(lunout,*) 'wxios_add_vaxis temp LIDAR_NTEMP, LIDAR_PHASE_TEMP ', &
+                     LIDAR_NTEMP, LIDAR_PHASE_TEMP
+    CALL wxios_add_vaxis("temp", LIDAR_NTEMP, LIDAR_PHASE_TEMP)
+
+    WRITE(lunout,*) 'wxios_add_vaxis cth16 numMISRHgtBins, misr_histHgtCenters ', & 
                     numMISRHgtBins, misr_histHgtCenters 
-   CALL wxios_add_vaxis("cth", numMISRHgtBins, misr_histHgtCenters)
-
-   WRITE(lunout,*) 'wxios_add_vaxis dbze CLOUDSAT_DBZE_BINS, cloudsat_binCenters ', &
+    CALL wxios_add_vaxis("cth", numMISRHgtBins, misr_histHgtCenters)
+
+    WRITE(lunout,*) 'wxios_add_vaxis dbze CLOUDSAT_DBZE_BINS, cloudsat_binCenters ', &
                     CLOUDSAT_DBZE_BINS, cloudsat_binCenters
-   CALL wxios_add_vaxis("dbze", CLOUDSAT_DBZE_BINS, cloudsat_binCenters) 
-
-   WRITE(lunout,*) 'wxios_add_vaxis scatratio SR_BINS, calipso_binCenters', &
+    CALL wxios_add_vaxis("dbze", CLOUDSAT_DBZE_BINS, cloudsat_binCenters) 
+
+    WRITE(lunout,*) 'wxios_add_vaxis scatratio SR_BINS, calipso_binCenters', &
                    SR_BINS, calipso_binCenters
-   CALL wxios_add_vaxis("scatratio", SR_BINS, calipso_binCenters)
-
-   WRITE(lunout,*) 'wxios_add_vaxis ReffIce numMODISReffIceBins, &
+    CALL wxios_add_vaxis("scatratio", SR_BINS, calipso_binCenters)
+
+    WRITE(lunout,*) 'wxios_add_vaxis ReffIce numMODISReffIceBins, &
                    reffICE_binCenters',numMODISReffIceBins, reffICE_binCenters
-   CALL wxios_add_vaxis("ReffIce", numMODISReffIceBins, reffICE_binCenters)
-
-   WRITE(lunout,*) 'wxios_add_vaxis ReffLiq numMODISReffLiqBins, &
+    CALL wxios_add_vaxis("ReffIce", numMODISReffIceBins, reffICE_binCenters)
+
+    WRITE(lunout,*) 'wxios_add_vaxis ReffLiq numMODISReffLiqBins, &
                     reffLIQ_binCenters', numMODISReffLiqBins, reffLIQ_binCenters
-   CALL wxios_add_vaxis("ReffLiq", numMODISReffLiqBins, reffLIQ_binCenters)
-
-   WRITE(lunout,*) 'wxios_add_vaxis 7, tau_binCenters', &
+    CALL wxios_add_vaxis("ReffLiq", numMODISReffLiqBins, reffLIQ_binCenters)
+
+    WRITE(lunout,*) 'wxios_add_vaxis 7, tau_binCenters', &
                     7, tau_binCenters
-   CALL wxios_add_vaxis("tau", 7, tau_binCenters)
-
-#endif
+    CALL wxios_add_vaxis("tau", 7, tau_binCenters)
+
+  ENDIF
    
     zdtimemoy_cosp = freq_COSP         ! Frequence ou l on moyenne
@@ -467,10 +463,10 @@
 !                    nhoricosp(iff),cosp_nidfiles(iff)
 
-#ifdef CPP_XIOS
+ IF (using_xios) THEN
         IF (.not. ok_all_xml) then
          WRITE(lunout,*) 'wxios_add_file ',cosp_outfilenames(iff)
          CALL wxios_add_file(cosp_outfilenames(iff),chfreq(iff),10)
         ENDIF
-#endif
+ ENDIF
 
 #ifndef CPP_IOIPSL_NO_OUTPUT 
Index: LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_output_write_mod.F90
===================================================================
--- LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_output_write_mod.F90	(revision 4175)
+++ LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_output_write_mod.F90	(revision 4727)
@@ -42,5 +42,5 @@
 
     USE wxios, only: wxios_closedef
-    USE xios, only: xios_update_calendar, xios_field_is_active
+    USE lmdz_xios, only: xios_update_calendar, xios_field_is_active
   IMPLICIT NONE  
 !!! Variables d'entree
@@ -807,5 +807,5 @@
   USE print_control_mod, ONLY: lunout,prt_level
 
-  USE xios, only: xios_send_field
+  USE lmdz_xios, only: xios_send_field
 
   IMPLICIT NONE
@@ -889,5 +889,5 @@
   USE print_control_mod, ONLY: lunout,prt_level
 
-  USE xios, only: xios_send_field
+  USE lmdz_xios, only: xios_send_field
 
 
@@ -980,5 +980,5 @@
   USE print_control_mod, ONLY: lunout,prt_level
 
-  USE xios, only: xios_send_field
+  USE lmdz_xios, only: xios_send_field
 
 
Index: LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_read_outputkeys.F90
===================================================================
--- LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_read_outputkeys.F90	(revision 4175)
+++ LMDZ6/branches/LMDZ_ECRad/libf/phylmd/cospv2/lmdz_cosp_read_outputkeys.F90	(revision 4727)
@@ -422,8 +422,5 @@
 
  SUBROUTINE READ_COSP_OUTPUT_NL(itap,cosp_nl,cfg)
-
-#ifdef CPP_XIOS
-    USE xios, ONLY: xios_field_is_active
-#endif
+  USE lmdz_xios, ONLY: xios_field_is_active, using_xios
   implicit none
   character(len=*),intent(in) :: cosp_nl
@@ -1020,13 +1017,8 @@
 
  SUBROUTINE read_xiosfieldactive(cfg)
-
-#ifdef CPP_XIOS
-    USE xios, ONLY: xios_field_is_active
-#endif
+  USE lmdz_xios, ONLY: xios_field_is_active, using_xios
   implicit none
   type(cosp_config),intent(inout) :: cfg
   integer :: i
-
-#ifdef CPP_XIOS
 
 !COSPv2 local variables
@@ -1067,4 +1059,6 @@
         
   character(len=32) :: out_list(107)
+
+ IF (using_xios) THEN
 
   do i=1,107
@@ -1717,5 +1711,5 @@
  endif 
 
-#endif
+ ENDIF !using_xios
 
   END SUBROUTINE read_xiosfieldactive
