Index: LMDZ6/trunk/libf/phylmd/cosp/cosp_output_write_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 3057)
+++ LMDZ6/trunk/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 3152)
@@ -83,16 +83,16 @@
    endif
 
-!#ifdef CPP_XIOS
-! !$OMP MASTER
-!IF (cosp_varsdefined) THEN
-!   if (prt_level >= 10) then
-!         WRITE(lunout,*)'Apell xios_update_calendar cosp_varsdefined iinitend ', &
-!                         cosp_varsdefined,iinitend
-!   endif 
-!    CALL xios_update_calendar(itau_wcosp)
-!ENDIF
-!  !$OMP END MASTER
-!  !$OMP BARRIER
-!#endif
+#ifdef CPP_XIOS
+ !$OMP MASTER
+IF (cosp_varsdefined) THEN
+   if (prt_level >= 10) then
+         WRITE(lunout,*)'Apell xios_update_calendar cosp_varsdefined iinitend ', &
+                         cosp_varsdefined,iinitend
+   endif 
+    CALL xios_update_calendar(itau_wcosp)
+ENDIF
+  !$OMP END MASTER
+  !$OMP BARRIER
+#endif
 
  if (cfg%Llidar_sim) then
Index: LMDZ6/trunk/libf/phylmd/cosp/read_cosp_output_nl.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/cosp/read_cosp_output_nl.F90	(revision 3057)
+++ LMDZ6/trunk/libf/phylmd/cosp/read_cosp_output_nl.F90	(revision 3152)
@@ -6,4 +6,9 @@
   USE MOD_COSP_TYPES
   USE mod_phys_lmdz_para
+
+#ifdef CPP_XIOS
+    USE xios, ONLY: xios_get_field_attr, xios_field_is_active
+#endif
+
   character(len=*),intent(in) :: cosp_nl
   type(cosp_config),intent(out) :: cfg
@@ -67,4 +72,5 @@
   enddo
   
+! Lecture du fichier namelist
   IF (is_master) THEN
     open(10,file=cosp_nl,status='old')
@@ -73,4 +79,187 @@
   ENDIF
   
+! VEREFIER LES CHAMPS DEMANDES DANS .XML
+! 2. Si champs active dans .xml alors mettre la cles de sortie en true
+#ifdef CPP_XIOS
+   IF (xios_field_is_active("cllcalipso")) Lcllcalipso=.TRUE.
+             IF (xios_field_is_active("clmcalipso")) Lclmcalipso=.TRUE.
+             IF (xios_field_is_active("clhcalipso")) Lclhcalipso=.TRUE.
+             IF (xios_field_is_active("cltcalipso")) Lcltcalipso=.TRUE.
+             IF (xios_field_is_active("pcllcalipso")) Lcllcalipso=.TRUE.
+             IF (xios_field_is_active("pclmcalipso")) Lclmcalipso=.TRUE.
+             IF (xios_field_is_active("pclhcalipso")) Lclhcalipso=.TRUE.
+             IF (xios_field_is_active("pcltcalipso")) Lcltcalipso=.TRUE.
+             IF (xios_field_is_active("cllcalipsoice")) Lcllcalipsoice=.TRUE.
+             IF (xios_field_is_active("clmcalipsoice")) Lclmcalipsoice=.TRUE.
+             IF (xios_field_is_active("clhcalipsoice")) Lclhcalipsoice=.TRUE.
+             IF (xios_field_is_active("cltcalipsoice")) Lcltcalipsoice=.TRUE.
+             IF (xios_field_is_active("cllcalipsoliq")) Lcllcalipsoliq=.TRUE.
+             IF (xios_field_is_active("clmcalipsoliq")) Lclmcalipsoliq=.TRUE.
+             IF (xios_field_is_active("clhcalipsoliq")) Lclhcalipsoliq=.TRUE.
+             IF (xios_field_is_active("cltcalipsoliq")) Lcltcalipsoliq=.TRUE.
+             IF (xios_field_is_active("cllcalipsoun")) Lcllcalipsoun=.TRUE.
+             IF (xios_field_is_active("clmcalipsoun")) Lclmcalipsoun=.TRUE.
+             IF (xios_field_is_active("clhcalipsoun")) Lclhcalipsoun=.TRUE.
+             IF (xios_field_is_active("cltcalipsoun")) Lcltcalipsoun=.TRUE.
+             IF (xios_field_is_active("clcalipso")) Lclcalipso=.TRUE.
+             IF (xios_field_is_active("pclcalipso")) Lclcalipso=.TRUE.
+             IF (xios_field_is_active("clcalipsoice")) Lclcalipsoice=.TRUE.
+             IF (xios_field_is_active("clcalipsoliq")) Lclcalipsoliq=.TRUE.
+             IF (xios_field_is_active("clcalipsoun")) Lclcalipsoun=.TRUE.
+             IF (xios_field_is_active("clcalipsotmp")) Lclcalipsotmp=.TRUE.
+             IF (xios_field_is_active("clcalipsotmpice")) Lclcalipsotmpice=.TRUE.
+             IF (xios_field_is_active("clcalipsotmpliq")) Lclcalipsotmpliq=.TRUE.
+             IF (xios_field_is_active("clcalipsotmpun")) Lclcalipsotmpun=.TRUE.
+             IF (xios_field_is_active("parasol_refl")) Lparasol_refl=.TRUE.
+             IF (xios_field_is_active("parasol_crefl")) Lparasol_refl=.TRUE.
+             IF (xios_field_is_active("Ncrefl")) Lparasol_refl=.TRUE.
+             IF (xios_field_is_active("cfad_lidarsr532")) LcfadLidarsr532=.TRUE. 
+             IF (xios_field_is_active("atb532")) Latb532=.TRUE.
+             IF (xios_field_is_active("beta_mol532")) Lbeta_mol532=.TRUE.
+             IF (xios_field_is_active("clopaquecalipso")) Lclopaquecalipso=.TRUE.
+             IF (xios_field_is_active("clthincalipso")) Lclthincalipso=.TRUE. 
+             IF (xios_field_is_active("clzopaquecalipso")) Lclzopaquecalipso=.TRUE. 
+             IF (xios_field_is_active("clcalipsoopaque")) Lclcalipsoopaque=.TRUE. 
+             IF (xios_field_is_active("clcalipsothin")) Lclcalipsothin=.TRUE.
+             IF (xios_field_is_active("clcalipsozopaque")) Lclcalipsozopaque=.TRUE.
+             IF (xios_field_is_active("clcalipsoopacity")) Lclcalipsoopacity=.TRUE. 
+             IF (xios_field_is_active("proftemp")) Lproftemp=.TRUE.
+             IF (xios_field_is_active("profSR")) LprofSR=.TRUE.
+
+   IF (xios_field_is_active("cfadDbze94")) LcfadDbze94=.TRUE.
+             IF (xios_field_is_active("dbze94")) Ldbze94=.TRUE.
+             IF (xios_field_is_active("cltlidarradar")) Lcltlidarradar=.TRUE.
+             IF (xios_field_is_active("clcalipso2")) Lclcalipso2=.TRUE.
+
+   IF (xios_field_is_active("clisccp2")) Lclisccp2=.TRUE.
+             IF (xios_field_is_active("boxtauisccp")) Lboxtauisccp=.TRUE.
+             IF (xios_field_is_active("boxptopisccp")) Lboxptopisccp=.TRUE.
+             IF (xios_field_is_active("tclisccp")) Ltclisccp=.TRUE.
+             IF (xios_field_is_active("ctpisccp")) Lctpisccp=.TRUE.
+             IF (xios_field_is_active("tauisccp")) Ltauisccp=.TRUE.
+             IF (xios_field_is_active("albisccp")) Lalbisccp=.TRUE.
+             IF (xios_field_is_active("meantbisccp")) Lmeantbisccp=.TRUE.
+             IF (xios_field_is_active("meantbclrisccp")) Lmeantbclrisccp=.TRUE.
+
+   IF (xios_field_is_active("clMISR")) LclMISR=.TRUE.
+
+             IF (xios_field_is_active("cllmodis")) Lcllmodis=.TRUE.
+             IF (xios_field_is_active("clmmodis")) Lclmmodis=.TRUE.
+             IF (xios_field_is_active("clhmodis")) Lclhmodis=.TRUE.
+             IF (xios_field_is_active("cltmodis")) Lcltmodis=.TRUE.
+             IF (xios_field_is_active("clwmodis")) Lclwmodis=.TRUE.
+             IF (xios_field_is_active("climodis")) Lclimodis=.TRUE.
+             IF (xios_field_is_active("tautmodis")) Ltautmodis=.TRUE.
+             IF (xios_field_is_active("tauwmodis")) Ltauwmodis=.TRUE.
+             IF (xios_field_is_active("tauimodis")) Ltauimodis=.TRUE.
+             IF (xios_field_is_active("tautlogmodis")) Ltautlogmodis=.TRUE.
+             IF (xios_field_is_active("tauilogmodis")) Ltauilogmodis=.TRUE.
+             IF (xios_field_is_active("tauwlogmodis")) Ltauwlogmodis=.TRUE.
+             IF (xios_field_is_active("reffclwmodis")) Lreffclwmodis=.TRUE.
+             IF (xios_field_is_active("reffclimodis")) Lreffclimodis=.TRUE.
+             IF (xios_field_is_active("pctmodis")) Lpctmodis=.TRUE.
+             IF (xios_field_is_active("lwpmodis")) Llwpmodis=.TRUE.
+             IF (xios_field_is_active("iwpmodis")) Liwpmodis=.TRUE.
+             IF (xios_field_is_active("clmodis")) Lclmodis=.TRUE.
+!             IF (xios_field_is_active("jpdftaureicemodis")) Lcrimodis=.TRUE.
+             IF (xios_field_is_active("crimodis")) Lcrimodis=.TRUE.
+!             IF (xios_field_is_active("jpdftaureliqmodis")) Lcrlmodis=.TRUE.
+             IF (xios_field_is_active("crlmodis")) Lcrlmodis=.TRUE.
+
+! 2.  si champs demande alors activer le simulateur correspondant
+   IF (xios_field_is_active("cllcalipso").OR. &
+                xios_field_is_active("clmcalipso").OR. &
+                xios_field_is_active("clhcalipso").OR. &
+                xios_field_is_active("cltcalipso").OR. &
+                xios_field_is_active("pcllcalipso").OR. &
+                xios_field_is_active("pclmcalipso").OR. &
+                xios_field_is_active("pclhcalipso").OR. &
+                xios_field_is_active("pcltcalipso").OR. &
+                xios_field_is_active("cllcalipsoice").OR. &
+                xios_field_is_active("clmcalipsoice").OR. &
+                xios_field_is_active("clhcalipsoice").OR. &
+                xios_field_is_active("cltcalipsoice").OR. &
+                xios_field_is_active("cllcalipsoliq").OR. &
+                xios_field_is_active("clmcalipsoliq").OR. &
+                xios_field_is_active("clhcalipsoliq").OR. &
+                xios_field_is_active("cltcalipsoliq").OR. &
+                xios_field_is_active("cllcalipsoun").OR. &
+                xios_field_is_active("clmcalipsoun").OR. &
+                xios_field_is_active("clhcalipsoun").OR. &
+                xios_field_is_active("cltcalipsoun").OR. &
+                xios_field_is_active("clcalipso").OR. &
+                xios_field_is_active("pclcalipso").OR. &
+                xios_field_is_active("clcalipsoice").OR. &
+                xios_field_is_active("clcalipsoliq").OR. &
+                xios_field_is_active("clcalipsoun").OR. &
+                xios_field_is_active("clcalipsotmp").OR. &
+                xios_field_is_active("clcalipsotmpice").OR. &
+                xios_field_is_active("clcalipsotmpliq").OR. &
+                xios_field_is_active("clcalipsotmpun").OR. &
+                xios_field_is_active("parasol_refl").OR. &
+                xios_field_is_active("parasol_crefl").OR. &
+                xios_field_is_active("Ncrefl").OR. &
+                xios_field_is_active("cfad_lidarsr532").OR. &
+                xios_field_is_active("atb532").OR. &
+                xios_field_is_active("beta_mol532").OR. &
+                xios_field_is_active("clopaquecalipso").OR. &
+                xios_field_is_active("clthincalipso").OR. &
+                xios_field_is_active("clzopaquecalipso").OR. &
+                xios_field_is_active("clcalipsoopaque").OR. &
+                xios_field_is_active("clcalipsothin").OR. &
+                xios_field_is_active("clcalipsozopaque").OR. &
+                xios_field_is_active("clcalipsoopacity").OR. &
+                xios_field_is_active("proftemp").OR. &
+                xios_field_is_active("profSR")) &
+                Llidar_sim=.TRUE.
+
+    IF (xios_field_is_active("cfadDbze94").OR. &
+               xios_field_is_active("dbze94")) &
+               Lradar_sim=.TRUE.
+
+    IF (xios_field_is_active("cltlidarradar").OR. &
+               xios_field_is_active("clcalipso2")) THEN
+               Lradar_sim=.TRUE.
+               Llidar_sim=.TRUE.
+    ENDIF
+
+    IF (xios_field_is_active("clisccp2").OR. &
+                xios_field_is_active("boxtauisccp").OR. &
+                xios_field_is_active("boxptopisccp").OR. &
+                xios_field_is_active("tclisccp").OR. &
+                xios_field_is_active("ctpisccp").OR. &
+                xios_field_is_active("tauisccp").OR. &
+                xios_field_is_active("albisccp").OR. &
+                xios_field_is_active("meantbisccp").OR. &
+                xios_field_is_active("meantbclrisccp")) &
+                Lisccp_sim=.TRUE.
+
+    IF (xios_field_is_active("clMISR")) Lmisr_sim=.TRUE.
+
+    IF (xios_field_is_active("cllmodis").OR. &
+                xios_field_is_active("clmmodis").OR. &
+                xios_field_is_active("clhmodis").OR. &
+                xios_field_is_active("cltmodis").OR. &
+                xios_field_is_active("clwmodis").OR. &
+                xios_field_is_active("climodis").OR. &
+                xios_field_is_active("tautmodis").OR. &
+                xios_field_is_active("tauwmodis").OR. &
+                xios_field_is_active("tauimodis").OR. &
+                xios_field_is_active("tautlogmodis").OR. &
+                xios_field_is_active("tauilogmodis").OR. &
+                xios_field_is_active("tauwlogmodis").OR. &
+                xios_field_is_active("reffclwmodis").OR. &
+                xios_field_is_active("reffclimodis").OR. &
+                xios_field_is_active("pctmodis").OR. &
+                xios_field_is_active("lwpmodis").OR. &
+                xios_field_is_active("iwpmodis").OR. &
+                xios_field_is_active("clmodis").OR. &
+                xios_field_is_active("crimodis").OR. &
+                xios_field_is_active("crlmodis")) &
+                Lmodis_sim=.TRUE.
+
+#endif 
+
+
   CALL bcast(Lradar_sim)
   CALL bcast(Llidar_sim)
