Index: /LMDZ6/trunk/libf/phylmd/physiq_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 3987)
+++ /LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 3988)
@@ -1743,5 +1743,5 @@
             ENDDO
           ENDDO
-        ELSE
+       ELSE
           pbl_tke(:,:,is_ave) = 0. !ym missing init : maybe must be initialized in the same way that for klon_glo==1 ??
 !>jyg
@@ -1923,14 +1923,52 @@
        !$OMP BARRIER
        missing_val=missing_val_omp
+       ! 
+       ! Now we activate some double radiation call flags only if some
+       ! diagnostics are requested, otherwise there is no point in doing this
+       IF (is_master) THEN
+         !--setting up swaero_diag to TRUE in XIOS case 
+         IF (xios_field_is_active("topswad").OR.xios_field_is_active("topswad0").OR. & 
+            xios_field_is_active("solswad").OR.xios_field_is_active("solswad0").OR. & 
+            xios_field_is_active("topswai").OR.xios_field_is_active("solswai").OR.  & 
+              (iflag_rrtm==1.AND.(xios_field_is_active("toplwad").OR.xios_field_is_active("toplwad0").OR. & 
+                                  xios_field_is_active("sollwad").OR.xios_field_is_active("sollwad0"))))  & 
+            !!!--for now these fields are not in the XML files so they are omitted 
+            !!!  xios_field_is_active("toplwai").OR.xios_field_is_active("sollwai") !))) & 
+            swaero_diag=.TRUE. 
+ 
+         !--setting up swaerofree_diag to TRUE in XIOS case 
+         IF (xios_field_is_active("SWdnSFCcleanclr").OR.xios_field_is_active("SWupSFCcleanclr").OR. &
+            xios_field_is_active("SWupTOAcleanclr").OR.xios_field_is_active("rsucsaf").OR.   &
+            xios_field_is_active("rsdcsaf") .OR. xios_field_is_active("LWdnSFCcleanclr").OR. &
+            xios_field_is_active("LWupTOAcleanclr")) &
+            swaerofree_diag=.TRUE. 
+ 
+         !--setting up dryaod_diag to TRUE in XIOS case 
+         DO naero = 1, naero_tot-1
+          IF (xios_field_is_active("dryod550_"//name_aero_tau(naero))) dryaod_diag=.TRUE. 
+         ENDDO
+         !
+         !--setting up ok_4xCO2atm to TRUE in XIOS case 
+         IF (xios_field_is_active("rsut4co2").OR.xios_field_is_active("rlut4co2").OR. & 
+            xios_field_is_active("rsutcs4co2").OR.xios_field_is_active("rlutcs4co2").OR. &
+            xios_field_is_active("rsu4co2").OR.xios_field_is_active("rsucs4co2").OR. &
+            xios_field_is_active("rsd4co2").OR.xios_field_is_active("rsdcs4co2").OR. &
+            xios_field_is_active("rlu4co2").OR.xios_field_is_active("rlucs4co2").OR. &
+            xios_field_is_active("rld4co2").OR.xios_field_is_active("rldcs4co2")) &
+            ok_4xCO2atm=.TRUE. 
+       ENDIF
+       !$OMP BARRIER
+       CALL bcast(swaero_diag)
+       CALL bcast(swaerofree_diag)
+       CALL bcast(dryaod_diag)
+       CALL bcast(ok_4xCO2atm)
+       WRITE (lunout,*)'ok_4xCO2atm= ',swaero_diag, swaerofree_diag, dryaod_diag, ok_4xCO2atm
 #endif 
-
-
+       !
        CALL printflag( tabcntr0,radpas,ok_journe, &
             ok_instan, ok_region )
        !
        !
-       !
        ! Prescrire l'ozone dans l'atmosphere
-       !
        !
        !c         DO i = 1, klon
@@ -1988,4 +2026,5 @@
 #endif
        ENDIF
+       !
        IF (type_trac == 'repr') THEN
 #ifdef REPROBUS
@@ -2036,6 +2075,4 @@
           SFRWL(6)=3.02191470E-02
        END SELECT
-
-
        !albedo SB <<<
 
@@ -2160,5 +2197,4 @@
       ! RomP <<<
     ENDIF
-
     !
     ! Ne pas affecter les valeurs entrees de u, v, h, et q
@@ -5173,54 +5209,4 @@
 #endif
 
-! Pour XIOS : On remet des variables a .false. apres un premier appel
-    IF (debut) THEN
-#ifdef CPP_XIOS
-      swaero_diag=.FALSE.
-      swaerofree_diag=.FALSE.
-      dryaod_diag=.FALSE.
-      ok_4xCO2atm= .FALSE.
-!      write (lunout,*)'ok_4xCO2atm= ',swaero_diag, swaerofree_diag, dryaod_diag, ok_4xCO2atm
-
-      IF (is_master) THEN
-        !--setting up swaero_diag to TRUE in XIOS case 
-        IF (xios_field_is_active("topswad").OR.xios_field_is_active("topswad0").OR. & 
-           xios_field_is_active("solswad").OR.xios_field_is_active("solswad0").OR. & 
-           xios_field_is_active("topswai").OR.xios_field_is_active("solswai").OR.  & 
-             (iflag_rrtm==1.AND.(xios_field_is_active("toplwad").OR.xios_field_is_active("toplwad0").OR. & 
-                                 xios_field_is_active("sollwad").OR.xios_field_is_active("sollwad0"))))  & 
-           !!!--for now these fields are not in the XML files so they are omitted 
-           !!!  xios_field_is_active("toplwai").OR.xios_field_is_active("sollwai") !))) & 
-           swaero_diag=.TRUE. 
-
-        !--setting up swaerofree_diag to TRUE in XIOS case 
-        IF (xios_field_is_active("SWdnSFCcleanclr").OR.xios_field_is_active("SWupSFCcleanclr").OR. &
-           xios_field_is_active("SWupTOAcleanclr").OR.xios_field_is_active("rsucsaf").OR.   &
-           xios_field_is_active("rsdcsaf") .OR. xios_field_is_active("LWdnSFCcleanclr").OR. &
-           xios_field_is_active("LWupTOAcleanclr")) &
-           swaerofree_diag=.TRUE. 
-
-        !--setting up dryaod_diag to TRUE in XIOS case 
-        DO naero = 1, naero_tot-1
-         IF (xios_field_is_active("dryod550_"//name_aero_tau(naero))) dryaod_diag=.TRUE. 
-        ENDDO
-        !
-        !--setting up ok_4xCO2atm to TRUE in XIOS case 
-        IF (xios_field_is_active("rsut4co2").OR.xios_field_is_active("rlut4co2").OR. & 
-           xios_field_is_active("rsutcs4co2").OR.xios_field_is_active("rlutcs4co2").OR. &
-           xios_field_is_active("rsu4co2").OR.xios_field_is_active("rsucs4co2").OR. &
-           xios_field_is_active("rsd4co2").OR.xios_field_is_active("rsdcs4co2").OR. &
-           xios_field_is_active("rlu4co2").OR.xios_field_is_active("rlucs4co2").OR. &
-           xios_field_is_active("rld4co2").OR.xios_field_is_active("rldcs4co2")) &
-           ok_4xCO2atm=.TRUE. 
-      ENDIF
-      !$OMP BARRIER
-      CALL bcast(swaero_diag)
-      CALL bcast(swaerofree_diag)
-      CALL bcast(dryaod_diag)
-      CALL bcast(ok_4xCO2atm)
-!      write (lunout,*)'ok_4xCO2atm= ',swaero_diag, swaerofree_diag, dryaod_diag, ok_4xCO2atm
-#endif
-    ENDIF
-
     !====================================================================
     ! Arret du modele apres hgardfou en cas de detection d'un
