Index: LMDZ6/branches/Portage_acc/libf/phylmd/cosp/cosp_output_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/cosp/cosp_output_mod.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/cosp/cosp_output_mod.F90	(revision 4743)
@@ -235,9 +235,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
@@ -263,11 +260,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 cosp_output_mod.F90'
@@ -316,39 +311,39 @@
     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
-          Cosp_fill_value=0.
-         print*,'Cosp_fill_value=',Cosp_fill_value
-!    if (use_vgrid) then
-!      print*,'vgrid%Nlvgrid, vgrid%z = ',vgrid%Nlvgrid, vgrid%z
-        CALL wxios_add_vaxis("height", vgrid%Nlvgrid, vgrid%z)
-     print*,'wxios_add_vaxis '
-!    else
-!         WRITE(lunout,*) 'wxios_add_vaxis "presnivs", vgrid%Nlvgrid ',vgrid%Nlvgrid
-!        CALL wxios_add_vaxis("presnivs", vgrid%Nlvgrid, presnivs)
-!    endif
-    WRITE(lunout,*) 'wxios_add_vaxis height_mlev, Nlevlmdz ',Nlevlmdz
-    CALL wxios_add_vaxis("height_mlev", Nlevlmdz, vgrid%mz)
-    WRITE(lunout,*) 'wxios_add_vaxis sza, PARASOL_NREFL ',PARASOL_NREFL
-    CALL wxios_add_vaxis("sza", PARASOL_NREFL, PARASOL_SZA)
-    WRITE(lunout,*) 'wxios_add_vaxis pressure2 ',7
-    CALL wxios_add_vaxis("pressure2", 7, ISCCP_PC)
-    WRITE(lunout,*) 'wxios_add_vaxis column ',Ncolumns
-    CALL wxios_add_vaxis("column", Ncolumns, column_ax)
-
-! AI nov 2015
-   CALL wxios_add_vaxis("temp", LIDAR_NTEMP, LIDAR_PHASE_TEMP)
-   CALL wxios_add_vaxis("cth", MISR_N_CTH, MISR_CTH)
-   CALL wxios_add_vaxis("dbze", DBZE_BINS, dbze_ax) 
-   CALL wxios_add_vaxis("scatratio", SR_BINS, sratio_ax)
-   CALL wxios_add_vaxis("ReffIce", numMODISReffIceBins, reffICE_binCenters)
-   CALL wxios_add_vaxis("ReffLiq", numMODISReffLiqBins, reffLIQ_binCenters)
-   print*,'reffICE_binCenters=',reffICE_binCenters
-   CALL wxios_add_vaxis("tau", 7, ISCCP_TAU)
-
-#endif
+  ! 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
+  !    if (use_vgrid) then
+  !      print*,'vgrid%Nlvgrid, vgrid%z = ',vgrid%Nlvgrid, vgrid%z
+          CALL wxios_add_vaxis("height", vgrid%Nlvgrid, vgrid%z)
+       print*,'wxios_add_vaxis '
+  !    else
+  !         WRITE(lunout,*) 'wxios_add_vaxis "presnivs", vgrid%Nlvgrid ',vgrid%Nlvgrid
+  !        CALL wxios_add_vaxis("presnivs", vgrid%Nlvgrid, presnivs)
+  !    endif
+      WRITE(lunout,*) 'wxios_add_vaxis height_mlev, Nlevlmdz ',Nlevlmdz
+      CALL wxios_add_vaxis("height_mlev", Nlevlmdz, vgrid%mz)
+      WRITE(lunout,*) 'wxios_add_vaxis sza, PARASOL_NREFL ',PARASOL_NREFL
+      CALL wxios_add_vaxis("sza", PARASOL_NREFL, PARASOL_SZA)
+      WRITE(lunout,*) 'wxios_add_vaxis pressure2 ',7
+      CALL wxios_add_vaxis("pressure2", 7, ISCCP_PC)
+      WRITE(lunout,*) 'wxios_add_vaxis column ',Ncolumns
+      CALL wxios_add_vaxis("column", Ncolumns, column_ax)
+
+  ! AI nov 2015
+     CALL wxios_add_vaxis("temp", LIDAR_NTEMP, LIDAR_PHASE_TEMP)
+     CALL wxios_add_vaxis("cth", MISR_N_CTH, MISR_CTH)
+     CALL wxios_add_vaxis("dbze", DBZE_BINS, dbze_ax) 
+     CALL wxios_add_vaxis("scatratio", SR_BINS, sratio_ax)
+     CALL wxios_add_vaxis("ReffIce", numMODISReffIceBins, reffICE_binCenters)
+     CALL wxios_add_vaxis("ReffLiq", numMODISReffLiqBins, reffLIQ_binCenters)
+     print*,'reffICE_binCenters=',reffICE_binCenters
+     CALL wxios_add_vaxis("tau", 7, ISCCP_TAU)
+
+  ENDIF
    
     zdtimemoy_cosp = freq_COSP         ! Frequence ou l on moyenne
@@ -363,10 +358,10 @@
 !                    nhoricosp(iff),cosp_nidfiles(iff)
 
-#ifdef CPP_XIOS
-        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
+         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
 
 #ifndef CPP_IOIPSL_NO_OUTPUT 
Index: LMDZ6/branches/Portage_acc/libf/phylmd/cosp/cosp_output_write_mod.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 4743)
@@ -26,9 +26,6 @@
     USE time_phylmdz_mod, ONLY: itau_phy, start_time, day_step_phy
     USE print_control_mod, ONLY: lunout,prt_level
-
-#ifdef CPP_XIOS
     USE wxios, only: wxios_closedef
-    USE xios, only: xios_update_calendar, xios_field_is_active
-#endif
+    USE lmdz_xios, only: xios_update_calendar, xios_field_is_active, using_xios
   IMPLICIT NONE  
 !!! Variables d'entree
@@ -58,9 +55,9 @@
   real, dimension(Npoints,MISR_N_CTH,7) :: tmp_fi4da_misr
 
-#ifdef CPP_XIOS
-  missing_val=missing_cosp
-#else
-  missing_val=0.
-#endif
+  IF (using_xios) THEN
+    missing_val=missing_cosp
+  ELSE
+    missing_val=0.
+  ENDIF
 
   Nlevout = vgrid%Nlvgrid
@@ -90,5 +87,5 @@
 !   endif
 
-!!#ifdef CPP_XIOS
+!!IF (using_xios) THEN
 ! !$OMP MASTER
 !IF (cosp_varsdefined) THEN
@@ -101,5 +98,5 @@
 !  !$OMP END MASTER
 !  !$OMP BARRIER
-!!#endif
+!!ENDIF
 
 !!!! Sorties Calipso
@@ -163,23 +160,24 @@
    if (cfg%Lproftemp) CALL histwrite3d_cosp(o_proftemp,stlidar%proftemp,nvert)                    !TIBO
 
-#ifdef CPP_XIOS
-   do icl=1,SR_BINS
-      tmp_fi4da_cfadL(:,:,icl)=stlidar%cfad_sr(:,icl,:)
-   enddo
-!   if (cfg%LcfadLidarsr532) CALL histwrite4d_cosp(o_cfad_lidarsr532,stlidar%cfad_sr)
-   if (cfg%LcfadLidarsr532) CALL histwrite4d_cosp(o_cfad_lidarsr532,tmp_fi4da_cfadL)
-   if (cfg%LprofSR) CALL histwrite4d_cosp(o_profSR,stlidar%profSR)                              !TIBO
-#else
-   if (cfg%LcfadLidarsr532) then
+   IF (using_xios) THEN
      do icl=1,SR_BINS
-        CALL histwrite3d_cosp(o_cfad_lidarsr532,stlidar%cfad_sr(:,icl,:),nvert,icl)
+        tmp_fi4da_cfadL(:,:,icl)=stlidar%cfad_sr(:,icl,:)
      enddo
-   endif
-   if (cfg%LprofSR) then
-     do icl=1,Ncolumns                                                              !TIBO
-        CALL histwrite3d_cosp(o_profSR,stlidar%profSR(:,icl,:),nvert,icl)           !TIBO
-     enddo                                                                          !TIBO
-   endif
-#endif
+  !   if (cfg%LcfadLidarsr532) CALL histwrite4d_cosp(o_cfad_lidarsr532,stlidar%cfad_sr)
+     if (cfg%LcfadLidarsr532) CALL histwrite4d_cosp(o_cfad_lidarsr532,tmp_fi4da_cfadL)
+     if (cfg%LprofSR) CALL histwrite4d_cosp(o_profSR,stlidar%profSR)                              !TIBO
+   ELSE
+     if (cfg%LcfadLidarsr532) then
+       do icl=1,SR_BINS
+          CALL histwrite3d_cosp(o_cfad_lidarsr532,stlidar%cfad_sr(:,icl,:),nvert,icl)
+       enddo
+     endif
+     if (cfg%LprofSR) then
+       do icl=1,Ncolumns                                                              !TIBO
+          CALL histwrite3d_cosp(o_profSR,stlidar%profSR(:,icl,:),nvert,icl)           !TIBO
+       enddo                                                                          !TIBO
+      endif
+   ENDIF
+
    if (cfg%LparasolRefl) CALL histwrite3d_cosp(o_parasol_refl,stlidar%parasolrefl,nvertp)
 
@@ -201,13 +199,13 @@
   endif
 
-#ifdef CPP_XIOS
-   if (cfg%Latb532) CALL histwrite4d_cosp(o_atb532,sglidar%beta_tot)
-#else
-   if (cfg%Latb532) then  
-     do icl=1,Ncolumns 
-        CALL histwrite3d_cosp(o_atb532,sglidar%beta_tot(:,icl,:),nvertmcosp,icl)
-     enddo
-   endif 
-#endif
+   IF (using_xios) THEN
+     if (cfg%Latb532) CALL histwrite4d_cosp(o_atb532,sglidar%beta_tot)
+   ELSE
+     if (cfg%Latb532) then  
+       do icl=1,Ncolumns 
+          CALL histwrite3d_cosp(o_atb532,sglidar%beta_tot(:,icl,:),nvertmcosp,icl)
+       enddo
+     endif 
+   ENDIF
 
    if (cfg%LlidarBetaMol532) CALL histwrite3d_cosp(o_beta_mol532,sglidar%beta_mol,nvertmcosp) 
@@ -219,23 +217,23 @@
 
    where(stradar%cfad_ze == R_UNDEF) stradar%cfad_ze = missing_val
-#ifdef CPP_XIOS
-   do icl=1,DBZE_BINS
-     tmp_fi4da_cfadR(:,:,icl)=stradar%cfad_ze(:,icl,:)
-   enddo
-   if (cfg%Ldbze94) CALL histwrite4d_cosp(o_dbze94,sgradar%Ze_tot)
-!   if (cfg%LcfadDbze94) CALL histwrite4d_cosp(o_cfadDbze94,stradar%cfad_ze)
-   if (cfg%LcfadDbze94) CALL histwrite4d_cosp(o_cfadDbze94,tmp_fi4da_cfadR)
-#else
-   if (cfg%Ldbze94) then
-    do icl=1,Ncolumns
-       CALL histwrite3d_cosp(o_dbze94,sgradar%Ze_tot(:,icl,:),nvert,icl)
-    enddo
-   endif
-   if (cfg%LcfadDbze94) then
-    do icl=1,DBZE_BINS
-    CALL histwrite3d_cosp(o_cfadDbze94,stradar%cfad_ze(:,icl,:),nvert,icl)
-    enddo
-   endif
-#endif
+   IF (using_xios) THEN
+     do icl=1,DBZE_BINS
+       tmp_fi4da_cfadR(:,:,icl)=stradar%cfad_ze(:,icl,:)
+     enddo
+     if (cfg%Ldbze94) CALL histwrite4d_cosp(o_dbze94,sgradar%Ze_tot)
+  !  if (cfg%LcfadDbze94) CALL histwrite4d_cosp(o_cfadDbze94,stradar%cfad_ze)
+     if (cfg%LcfadDbze94) CALL histwrite4d_cosp(o_cfadDbze94,tmp_fi4da_cfadR)
+   ELSE
+     if (cfg%Ldbze94) then
+       do icl=1,Ncolumns
+         CALL histwrite3d_cosp(o_dbze94,sgradar%Ze_tot(:,icl,:),nvert,icl)
+       enddo
+     endif
+     if (cfg%LcfadDbze94) then
+       do icl=1,DBZE_BINS
+         CALL histwrite3d_cosp(o_cfadDbze94,stradar%cfad_ze(:,icl,:),nvert,icl)
+       enddo
+     endif
+   ENDIF
  endif
 ! endif pour radar
@@ -264,13 +262,13 @@
 
    CALL histwrite2d_cosp(o_sunlit,gbx%sunlit)
-#ifdef CPP_XIOS
-  if (cfg%Lclisccp) CALL histwrite4d_cosp(o_clisccp2,isccp%fq_isccp)
-#else
-   if (cfg%Lclisccp) then
-     do icl=1,7
-       CALL histwrite3d_cosp(o_clisccp2,isccp%fq_isccp(:,icl,:),nvertisccp,icl) 
-     enddo
-   endif
-#endif
+   IF (using_xios) THEN
+     if (cfg%Lclisccp) CALL histwrite4d_cosp(o_clisccp2,isccp%fq_isccp)
+   ELSE
+     if (cfg%Lclisccp) then
+       do icl=1,7
+         CALL histwrite3d_cosp(o_clisccp2,isccp%fq_isccp(:,icl,:),nvertisccp,icl) 
+       enddo
+     endif
+   ENDIF
 
    if (cfg%Lboxtauisccp) CALL histwrite3d_cosp(o_boxtauisccp,isccp%boxtau,nvertcol)
@@ -288,17 +286,17 @@
    where(misr%fq_MISR == R_UNDEF) misr%fq_MISR = missing_val
 
-#ifdef CPP_XIOS
-   do icl=1,MISR_N_CTH
-      tmp_fi4da_misr(:,icl,:)=misr%fq_MISR(:,:,icl)
-   enddo
-!   if (cfg%LclMISR) CALL histwrite4d_cosp(o_clMISR,misr%fq_MISR)
-   if (cfg%LclMISR) CALL histwrite4d_cosp(o_clMISR,tmp_fi4da_misr)
-#else
-   if (cfg%LclMISR) then
-    do icl=1,7 
-      CALL histwrite3d_cosp(o_clMISR,misr%fq_MISR(:,icl,:),nvertmisr,icl)
-    enddo
-   endif
-#endif
+   IF (using_xios) THEN
+     do icl=1,MISR_N_CTH
+        tmp_fi4da_misr(:,icl,:)=misr%fq_MISR(:,:,icl)
+     enddo
+  !   if (cfg%LclMISR) CALL histwrite4d_cosp(o_clMISR,misr%fq_MISR)
+     if (cfg%LclMISR) CALL histwrite4d_cosp(o_clMISR,tmp_fi4da_misr)
+   ELSE
+     if (cfg%LclMISR) then
+      do icl=1,7 
+        CALL histwrite3d_cosp(o_clMISR,misr%fq_MISR(:,icl,:),nvertmisr,icl)
+      enddo
+     endif
+   ENDIF
  endif
 ! endif pour Misr
@@ -365,14 +363,14 @@
           modis%Optical_Thickness_vs_Cloud_Top_Pressure = missing_val
 
-#ifdef CPP_XIOS
-   if (cfg%Lclmodis) CALL histwrite4d_cosp(o_clmodis,modis%Optical_Thickness_vs_Cloud_Top_Pressure)
-#else
-  if (cfg%Lclmodis) then
-   do icl=1,7
-   CALL histwrite3d_cosp(o_clmodis, &
-     modis%Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl)           
-   enddo
-  endif 
-#endif
+   IF (using_xios) THEN
+     if (cfg%Lclmodis) CALL histwrite4d_cosp(o_clmodis,modis%Optical_Thickness_vs_Cloud_Top_Pressure)
+   ELSE
+     if (cfg%Lclmodis) then
+       do icl=1,7
+         CALL histwrite3d_cosp(o_clmodis, &
+         modis%Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl)           
+       enddo
+      endif 
+   ENDIF
 
     where(modis%Optical_Thickness_vs_ReffIce == R_UNDEF) &
@@ -382,21 +380,21 @@
           modis%Optical_Thickness_vs_ReffLiq = missing_val
 
-#ifdef CPP_XIOS
-  if (cfg%Lcrimodis) CALL histwrite4d_cosp(o_crimodis,modis%Optical_Thickness_vs_ReffIce)
-  if (cfg%Lcrlmodis) CALL histwrite4d_cosp(o_crlmodis,modis%Optical_Thickness_vs_ReffLiq)
-#else
-  if (cfg%Lcrimodis) then
-    do icl=1,7
-     CALL histwrite3d_cosp(o_crimodis, &
-          modis%Optical_Thickness_vs_ReffIce(:,icl,:),nvertReffIce,icl)
-    enddo
-  endif
-  if (cfg%Lcrlmodis) then
-    do icl=1,7 
-     CALL histwrite3d_cosp(o_crlmodis, &
-          modis%Optical_Thickness_vs_ReffLiq(:,icl,:),nvertReffLiq,icl)
-    enddo
-  endif 
-#endif
+   IF (using_xios) THEN
+     if (cfg%Lcrimodis) CALL histwrite4d_cosp(o_crimodis,modis%Optical_Thickness_vs_ReffIce)
+     if (cfg%Lcrlmodis) CALL histwrite4d_cosp(o_crlmodis,modis%Optical_Thickness_vs_ReffLiq)
+   ELSE
+     if (cfg%Lcrimodis) then
+       do icl=1,7
+         CALL histwrite3d_cosp(o_crimodis, &
+            modis%Optical_Thickness_vs_ReffIce(:,icl,:),nvertReffIce,icl)
+       enddo
+     endif
+     if (cfg%Lcrlmodis) then
+       do icl=1,7 
+         CALL histwrite3d_cosp(o_crlmodis, &
+            modis%Optical_Thickness_vs_ReffLiq(:,icl,:),nvertReffLiq,icl)
+       enddo
+     endif 
+   ENDIF
  endif !modis
 
@@ -410,9 +408,4 @@
             ENDDO !  iff
 #endif
-! Fermeture dans phys_output_write
-!#ifdef CPP_XIOS
-            !On finalise l'initialisation:
-            !CALL wxios_closedef()
-!#endif
 
 !$OMP END MASTER
@@ -451,7 +444,5 @@
     USE mod_grid_phy_lmdz, ONLY: nbp_lon
     USE print_control_mod, ONLY: lunout,prt_level
-#ifdef CPP_XIOS
-  USE wxios
-#endif
+    USE wxios
 
     IMPLICIT NONE
@@ -485,15 +476,15 @@
     ENDIF
 
-#ifdef CPP_XIOS
-     IF (.not. ok_all_xml) then
-       IF ( var%cles(iff) ) THEN
-         if (prt_level >= 10) then
-              WRITE(lunout,*)'Appel wxios_add_field_to_file var%name =',var%name 
-         endif
-        CALL wxios_add_field_to_file(var%name, 2, cosp_nidfiles(iff), cosp_outfilenames(iff), &
+    IF (using_xios) THEN
+      IF (.not. ok_all_xml) then
+        IF ( var%cles(iff) ) THEN
+          if (prt_level >= 10) then
+            WRITE(lunout,*)'Appel wxios_add_field_to_file var%name =',var%name 
+          endif
+          CALL wxios_add_field_to_file(var%name, 2, cosp_nidfiles(iff), cosp_outfilenames(iff), &
                                      var%description, var%unit, 1, typeecrit)
-       ENDIF
-     ENDIF
-#endif
+        ENDIF
+      ENDIF
+    ENDIF
 
 #ifndef CPP_IOIPSL_NO_OUTPUT 
@@ -514,9 +505,5 @@
     USE mod_grid_phy_lmdz, ONLY: nbp_lon
     USE print_control_mod, ONLY: lunout,prt_level
-
-#ifdef CPP_XIOS
-  USE wxios
-#endif
-
+    USE wxios
 
     IMPLICIT NONE
@@ -591,5 +578,5 @@
     ENDIF
 
-#ifdef CPP_XIOS
+    IF (using_xios) THEN
       IF (.not. ok_all_xml) then
         IF ( var%cles(iff) ) THEN
@@ -601,5 +588,5 @@
         ENDIF
       ENDIF
-#endif
+    ENDIF
 
 #ifndef CPP_IOIPSL_NO_OUTPUT
@@ -621,8 +608,5 @@
   USE mod_grid_phy_lmdz, ONLY: nbp_lon
   USE print_control_mod, ONLY: lunout,prt_level
-
-#ifdef CPP_XIOS
-  USE xios, only: xios_send_field
-#endif
+  USE lmdz_xios, only: xios_send_field, using_xios
 
   IMPLICIT NONE
@@ -672,6 +656,6 @@
         CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,nbp_lon*jj_nb,index2d) 
 #endif
-                deallocate(index2d)
-#ifdef CPP_XIOS
+            deallocate(index2d)
+            IF (using_xios) THEN
               IF (.not. ok_all_xml) then
                  if (firstx) then
@@ -683,9 +667,9 @@
                  endif
               ENDIF
-#endif
-           ENDIF
+            ENDIF
+          ENDIF
       ENDDO 
 
-#ifdef CPP_XIOS
+    IF (using_xios) THEN
       IF (ok_all_xml) THEN
         if (prt_level >= 1) then
@@ -694,5 +678,5 @@
        CALL xios_send_field(var%name, Field2d)
       ENDIF
-#endif
+    ENDIF
 
 !$OMP END MASTER   
@@ -710,9 +694,5 @@
   USE mod_grid_phy_lmdz, ONLY: nbp_lon
   USE print_control_mod, ONLY: lunout,prt_level
-
-#ifdef CPP_XIOS
-  USE xios, only: xios_send_field
-#endif
-
+  USE lmdz_xios, only: xios_send_field, using_xios
 
   IMPLICIT NONE
@@ -776,5 +756,5 @@
 #endif
 
-#ifdef CPP_XIOS
+        IF (using_xios) THEN
           IF (.not. ok_all_xml) then
            IF (firstx) THEN
@@ -784,14 +764,15 @@
            ENDIF
           ENDIF
-#endif
+        ENDIF
          deallocate(index3d)
         ENDIF
       ENDDO
-#ifdef CPP_XIOS
+
+  IF (using_xios) THEN
     IF (ok_all_xml) THEN
      CALL xios_send_field(nom, Field3d(:,:,1:nlev))
      IF (prt_level >= 1) WRITE(lunout,*)'xios_send_field ',var%name
     ENDIF
-#endif
+  ENDIF
 
 !$OMP END MASTER   
@@ -809,9 +790,5 @@
   USE mod_grid_phy_lmdz, ONLY: nbp_lon
   USE print_control_mod, ONLY: lunout,prt_level
-
-#ifdef CPP_XIOS
-  USE xios, only: xios_send_field
-#endif
-
+  USE lmdz_xios, only: xios_send_field, using_xios
 
   IMPLICIT NONE
@@ -842,10 +819,10 @@
     CALL grid1Dto2D_mpi(buffer_omp,field4d)
 
-#ifdef CPP_XIOS
+   IF (using_xios) THEN
 !    IF (ok_all_xml) THEN
      CALL xios_send_field(var%name, Field4d(:,:,1:nlev,1:nlev2))
      IF (prt_level >= 1) WRITE(lunout,*)'xios_send_field ',var%name
 !    ENDIF
-#endif
+   ENDIF
 
 !$OMP END MASTER   
Index: LMDZ6/branches/Portage_acc/libf/phylmd/cosp/cosp_read_otputkeys.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/cosp/cosp_read_otputkeys.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/cosp/cosp_read_otputkeys.F90	(revision 4743)
@@ -226,8 +226,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
@@ -746,12 +743,8 @@
     USE MOD_COSP_CONSTANTS
     USE MOD_COSP_TYPES
-#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(out) :: cfg
   integer :: i
-
-#ifdef CPP_XIOS
 
  logical :: Lradar_sim,Llidar_sim,Lisccp_sim,Lmodis_sim,Lmisr_sim,Lrttov_sim, Lstats, &
@@ -776,7 +769,9 @@
   character(len=32) :: out_list(N_OUT_LIST)
 
-  do i=1,N_OUT_LIST
-    cfg%out_list(i)=''
-  enddo
+  IF (using_xios) THEN
+    
+    do i=1,N_OUT_LIST
+      cfg%out_list(i)=''
+    enddo
 
     LcfadDbze94   = .false.
@@ -1232,5 +1227,5 @@
   cfg%Lrttov_sim = Lrttov_sim
 
-#endif
+ ENDIF ! using_xios
 
   END SUBROUTINE read_xiosfieldactive
Index: LMDZ6/branches/Portage_acc/libf/phylmd/cosp/mod_cosp_constants.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/cosp/mod_cosp_constants.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/cosp/mod_cosp_constants.F90	(revision 4743)
@@ -33,5 +33,5 @@
 ! 
 
-#include "cosp_defs.h"
+#INCLUDE "cosp_defs.h"
 MODULE MOD_COSP_CONSTANTS
     IMPLICIT NONE
Index: LMDZ6/branches/Portage_acc/libf/phylmd/cosp/phys_cosp.F90
===================================================================
--- LMDZ6/branches/Portage_acc/libf/phylmd/cosp/phys_cosp.F90	(revision 4446)
+++ LMDZ6/branches/Portage_acc/libf/phylmd/cosp/phys_cosp.F90	(revision 4743)
@@ -84,7 +84,5 @@
   use cosp_output_write_mod
 !  use MOD_COSP_Modis_Simulator, only : cosp_modis 
-#ifdef CPP_XIOS
-    USE xios, ONLY: xios_field_is_active
-#endif
+  USE lmdz_xios, ONLY: xios_field_is_active, using_xios
   use cosp_read_otputkeys
 
@@ -183,9 +181,10 @@
 
 ! Clefs Outputs initialisation
-#ifdef CPP_XIOS
-  call cosp_outputkeys_init(cfg)
-#else
-  call read_cosp_output_nl(itap,cosp_output_nl,cfg)
-#endif
+  IF (using_xios) THEN
+    call cosp_outputkeys_init(cfg)
+  ELSE
+    call read_cosp_output_nl(itap,cosp_output_nl,cfg)
+  ENDIF
+
 !!!   call cosp_outputkeys_test(cfg)
   print*,' Cles des differents simulateurs cosp a itap :',itap
@@ -203,7 +202,7 @@
 !!! Ici on modifie les cles logiques pour les outputs selon les champs actives dans les .xml
   if ((itap.gt.1).and.(first_write))then
-#ifdef CPP_XIOS
-    call read_xiosfieldactive(cfg)
-#endif
+   
+    IF (using_xios) call read_xiosfieldactive(cfg)
+  
     first_write=.false.
 
