Index: LMDZ6/trunk/libf/phylmd/radlwsw_m.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/radlwsw_m.F90	(revision 4045)
+++ LMDZ6/trunk/libf/phylmd/radlwsw_m.F90	(revision 4116)
@@ -40,5 +40,5 @@
    toplwad_aero, sollwad_aero,&
    toplwai_aero, sollwai_aero, &
-   toplwad0_aero, sollwad0_aero,&
+   toplwad0_aero, sollwad0_aero, &
 !-end
    ZLWFT0_i, ZFLDN0, ZFLUP0,&
@@ -224,4 +224,5 @@
   REAL,    INTENT(in)  :: piz_aero_sw_rrtm(KLON,KLEV,2,NSW)                 ! aerosol optical properties RRTM
   REAL,    INTENT(in)  :: cg_aero_sw_rrtm(KLON,KLEV,2,NSW)                  ! aerosol optical properties RRTM
+! AI
 !--OB fin
 
@@ -335,5 +336,18 @@
   REAL(KIND=8) ZSWDIFFUSEBAND(klon,NSW), &  ! SW DN flux in diffuse albedo band 
                ZSWDIRECTBAND(klon,NSW)      ! SW DN flux in direct albedo band
+  REAL(KIND=8) SOLARIRAD
   REAL(KIND=8) seuilmach
+! AI 10 mars 22 : Pour les tests Offline
+  logical   :: lldebug_for_offline = .false.
+  REAL(KIND=8) solaire_off(klon), &
+               ZCO2_off(klon,klev), &
+               ZCH4_off(klon,klev), &           ! CH4 mass mixing ratios on full levels
+               ZN2O_off(klon,klev), &           ! N2O mass mixing ratios on full levels
+               ZNO2_off(klon,klev), &           ! NO2 mass mixing ratios on full levels
+               ZCFC11_off(klon,klev), &         ! CFC11
+               ZCFC12_off(klon,klev), &         ! CFC12
+               ZHCFC22_off(klon,klev), &        ! HCFC22
+               ZCCL4_off(klon,klev), &          ! CCL4
+               ZO2_off(klon,klev)               ! O2#endif
 #endif
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1169,4 +1183,5 @@
 !      DO i = 1, kdlon
 !      DO k = 1, kflev
+!      DO kk= 1, naero_tot 
 !      DO kk=1, NSW
 !
@@ -1178,4 +1193,5 @@
 !      PPIZA_NAT(i,kflev+1-k,kk)=piz_aero_sw_rrtm(i,k,1,kk)
 !      PCGA_NAT(i,kflev+1-k,kk)=cg_aero_sw_rrtm(i,k,1,kk)
+!       ZAEROSOL(i,kflev+1-k,kk)=m_allaer(i,k,kk)
 !
 !      ENDDO
@@ -1282,34 +1298,28 @@
          ENDDO
 
-! AI ATTENTION TESTS
-!      PALBD_NEW = 0.0
-!      PALBP_NEW = 0.0
-!      ZCO2 = RCO2
-!      ZCH4 = RCH4
-!      ZN2O = RN2O
-!      ZNO2 = 0.0
-!      ZCFC11 = RCFC11
-!      ZCFC12 = RCFC12
-!      ZHCFC22 = 0.0
-!      ZO2 = 0.0
-!      ZCCL4 = 0.0
 
       print *,'RADLWSW: avant RADIATION_SCHEME '
-!      print*,'RCFC11=',RCFC11
-!      print*,'RCFC12=',RCFC12
-
-      IF (lldebug) THEN
+    
+! AI mars 2022
+    SOLARIRAD = solaire/zdist/zdist
+!! diagnos pour la comparaison a la version offline
+!!! - Gas en VMR pour offline et MMR pour online
+!!! - on utilise pour solarirrad une valeur constante
+    if (lldebug_for_offline) then
+       SOLARIRAD = 1366.0896
+       ZCH4_off = CH4_ppb*1e-9
+       ZN2O_off = N2O_ppb*1e-9
+       ZNO2_off = 0.0
+       ZCFC11_off = CFC11_ppt*1e-12
+       ZCFC12_off = CFC12_ppt*1e-12
+       ZHCFC22_off = 0.0
+       ZCCL4_off = 0.0
+       ZO2_off = 0.0 
+       ZCO2_off = co2_ppm*1e-6
+
         CALL writefield_phy('rmu0',rmu0,1)
         CALL writefield_phy('tsol',tsol,1)
         CALL writefield_phy('emissiv_out',ZEMIS,1)
-!        CALL writefield_phy('emissiv_in',ZEMISW,1)
-!        CALL writefield_phy('pctsrf_ter',pctsrf(:,is_ter),1)
-!        CALL writefield_phy('pctsrf_oce',pctsrf(:,is_oce),1)
-!        CALL writefield_phy('ZGELAM',ZGELAM,1)
-!        CALL writefield_phy('ZGEMU',ZGEMU,1)
-!        CALL writefield_phy('zmasq',zmasq,1)
         CALL writefield_phy('paprs_i',paprs_i,klev+1)
-!        CALL writefield_phy('pplay_i',pplay_i,klev)
-!        CALL writefield_phy('t_i',t_i,klev)
         CALL writefield_phy('ZTH_i',ZTH_i,klev+1)
         CALL writefield_phy('cldfra_i',cldfra_i,klev)
@@ -1320,16 +1330,17 @@
         CALL writefield_phy('palbp_new',PALBP_NEW,NSW)
         CALL writefield_phy('POZON',POZON_i(:,:,1),klev)
-!        CALL writefield_phy('ZCO2',ZCO2,klev)
-!        CALL writefield_phy('ZCH4',ZCH4,klev)
-!        CALL writefield_phy('ZN2O',ZN2O,klev)
-!        CALL writefield_phy('ZO2',ZO2,klev)
-!        CALL writefield_phy('ZNO2',ZNO2,klev)
-!        CALL writefield_phy('ZCFC11',ZCFC11,klev)
-!        CALL writefield_phy('ZCFC12',ZCFC12,klev)
-!        CALL writefield_phy('ZHCFC22',ZHCFC22,klev)
-!        CALL writefield_phy('ZCCL4',ZCCL4,klev)
+        CALL writefield_phy('ZCO2',ZCO2_off,klev)
+        CALL writefield_phy('ZCH4',ZCH4_off,klev)
+        CALL writefield_phy('ZN2O',ZN2O_off,klev)
+        CALL writefield_phy('ZO2',ZO2_off,klev)
+        CALL writefield_phy('ZNO2',ZNO2_off,klev)
+        CALL writefield_phy('ZCFC11',ZCFC11_off,klev)
+        CALL writefield_phy('ZCFC12',ZCFC12_off,klev)
+        CALL writefield_phy('ZHCFC22',ZHCFC22_off,klev)
+        CALL writefield_phy('ZCCL4',ZCCL4_off,klev)
         CALL writefield_phy('ref_liq_i',ref_liq_i,klev)
         CALL writefield_phy('ref_ice_i',ref_ice_i,klev)
-      ENDIF
+      endif
+! lldebug_for_offline
  
       CALL RADIATION_SCHEME &
@@ -1337,7 +1348,9 @@
 ! ??? naero_tot
       & day_cur, current_time, & 
-      & PSCT, &
-      & rmu0, tsol, PALBD_NEW,PALBP_NEW, &   
-!       PEMIS_WINDOW (???), &
+      & SOLARIRAD, &
+      & rmu0, tsol, &
+!       Albedo diffuse et directe
+      & PALBD_NEW,PALBP_NEW, &   
+!       Emessivite : PEMIS_WINDOW (???), &
       & ZEMIS, ZEMISW, &
 !       PCCN_LAND, PCCN_SEA, & ???
@@ -1374,5 +1387,5 @@
       print *,'========= RADLWSW: apres RADIATION_SCHEME ==================== '
 
-      IF (lldebug) THEN
+     if (lldebug_for_offline) then
         CALL writefield_phy('FLUX_LW',ZLWFT_i,klev+1)
         CALL writefield_phy('FLUX_LW_CLEAR',ZLWFT0_ii,klev+1)
@@ -1389,5 +1402,6 @@
         CALL writefield_phy('FLUX_UP_SW',ZFSUP_i,klev+1)
         CALL writefield_phy('FLUX_UP_SW_CLEAR',ZFCUP_i,klev+1)
-      ENDIF
+      endif
+
 ! ---------
 ! On retablit l'ordre des niveaux lmd pour les tableaux de sortie
