Index: /LMDZ6/trunk/libf/phylmd/radlwsw_m.F90
===================================================================
--- /LMDZ6/trunk/libf/phylmd/radlwsw_m.F90	(revision 3950)
+++ /LMDZ6/trunk/libf/phylmd/radlwsw_m.F90	(revision 3951)
@@ -302,4 +302,5 @@
 ! ATTENTION les dimensions klon, kdlon ???
 ! INPUTS
+  REAL, DIMENSION(kdlon,kflev+1) :: ZSWFT0_ii, ZLWFT0_ii
   REAL(KIND=8) ZEMISW(klon), &              ! LW emissivity inside the window region
                ZEMIS(klon)                  ! LW emissivity outside the window region
@@ -313,6 +314,6 @@
                ZCFC12(klon,klev), &         ! CFC12
                ZHCFC22(klon,klev), &        ! HCFC22
-               ZCCL4(klon,klev), &          ! CCL4
-               ZO3_DP(klon,klev), ZO3_DP_i(klon,klev)            ! Ozone
+               ZCCL4(klon,klev)           ! CCL4
+!               ZO3_DP(klon,klev), ZO3_DP_i(klon,klev)            ! Ozone
   REAL(KIND=8) ZQ_RAIN(klon,klev), &        ! Rain cloud mass mixing ratio (kg/kg) ?
                ZQ_SNOW(klon,klev)           ! Snow cloud mass mixing ratio (kg/kg) ?
@@ -567,7 +568,4 @@
         POZON(i,k, :) = wo(iof+i, k, :) * RG * dobson_u * 1e3 &
              / (paprs(iof+i, k) - paprs(iof+i, k+1))
-#ifdef CPP_ECRAD
-        ZO3_DP(i,k) = wo(iof+i, k, 1) * RG * dobson_u * 1e3
-#endif
 !       A activer pour CCMVAL on prend l'ozone impose (MPL 07042010)
 !       POZON(i,k,:) = wo(i,k,:)  
@@ -897,5 +895,4 @@
 ! RII0 = RIP0M15 ! =rip0m if Morcrette non-each time step call.
          RII0=solaire/zdist/zdist
-!print*,'+++ radlwsw: solaire ,RII0',solaire,RII0
 !  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 ! Ancien appel a RECMWF (celui du cy25)
@@ -928,35 +925,19 @@
 ! Nouvel appel a RECMWF (celui du cy32t0)
          CALL RECMWF_AERO (ist , iend, klon , ktdia  , klev   , kmode ,&
-!                          KST,  KEND, KPROMA, KTDIA , KLEV,  KMODE
          PALBD_NEW,PALBP_NEW, paprs_i , pplay_i , RCO2   , cldfra_i,&
-!        PALBD ,   PALBP ,    PAPRS ,   PAPRSF ,  PCCO2 , PCLFR
          POZON_i  , PAER_i  , PDP_i   , PEMIS   , rmu0   ,&
-!        PQO3  ,    PAER  ,   PDP   ,   PEMIS  , PMU0
-          q_i     , qsat_i  , fiwc_i  , flwc_i  , zmasq  , t_i  ,tsol,&
-!         PQ       , PQS   , PQIWP ,     PQLWP , PSLM   , PT    , PTS, 
+         q_i     , qsat_i  , fiwc_i  , flwc_i  , zmasq  , t_i  ,tsol,&
          ref_liq_i, ref_ice_i, &
-!        PREF_LIQ, PREF_ICE
          ref_liq_pi_i, ref_ice_pi_i, &   ! rajoute par OB pour diagnostiquer effet indirect
-!        PREF_LIQ_PI, PREF_ICE_PI
          ZEMTD_i  , ZEMTU_i , ZTRSO_i ,&
-!        PEMTD , PEMTU , PTRSO
          ZTH_i    , ZCTRSO  , ZCEMTR  , ZTRSOD  ,&
-!        PTH   ,     PCTRSO,   PCEMTR, PTRSOD
          ZLWFC    , ZLWFT_i , ZSWFC   , ZSWFT_i ,&
-!        PLWFC,     PLWFT,    PSWFC,    PSWFT, 
          PSFSWDIR , PSFSWDIF, PFSDNN  , PFSDNV  ,&
-!        PSFSWDIR,  PSFSWDIF, PFSDNN,    PFSDNV
          PPIZA_TOT, PCGA_TOT,PTAU_TOT,&
-!        PPIZA_TOT, PCGA_TOT,PTAU_TOT
          PPIZA_NAT, PCGA_NAT,PTAU_NAT,           &  ! rajoute par OB pour diagnostiquer effet direct
-!        PPIZA_NAT,PCGA_NAT,PTAU_NAT
          PTAU_LW_TOT, PTAU_LW_NAT,               &  ! rajoute par C. Kleinschmitt
-!        PTAU_LW_TOT, PTAU_LW_NAT,
          ZFLUX_i  , ZFLUC_i ,&
-!        PFLUX,      PFLUC
          ZFSDWN_i , ZFSUP_i , ZFCDWN_i, ZFCUP_i, ZFCCDWN_i, ZFCCUP_i, ZFLCCDWN_i, ZFLCCUP_i, &
-!        PFSDN ,    PFSUP ,   PFSCDN , PFSCUP,   PFSCCDN,   PFSCCUP,  PFLCCDN,    PFLCCUP
          ZTOPSWADAERO,ZSOLSWADAERO,&  ! rajoute par OB pour diagnostics
-!        PTOPSWADAERO,PSOLSWADAERO
          ZTOPSWAD0AERO,ZSOLSWAD0AERO,&
          ZTOPSWAIAERO,ZSOLSWAIAERO, &
@@ -1010,28 +991,5 @@
         CALL writefield_phy('zfcup_i',ZFCUP_i,klev+1)
       ENDIF
-! --------- output RECMWFL
-!  ZEMTD        (KPROMA,KLEV+1)  ; TOTAL DOWNWARD LONGWAVE EMISSIVITY
-!  ZEMTU        (KPROMA,KLEV+1)  ; TOTAL UPWARD   LONGWAVE EMISSIVITY
-!  ZTRSO        (KPROMA,KLEV+1)  ; TOTAL SHORTWAVE TRANSMISSIVITY
-!  ZTH          (KPROMA,KLEV+1)  ; HALF LEVEL TEMPERATURE
-!  ZCTRSO       (KPROMA,2)       ; CLEAR-SKY SHORTWAVE TRANSMISSIVITY
-!  ZCEMTR       (KPROMA,2)       ; CLEAR-SKY NET LONGWAVE EMISSIVITY
-!  ZTRSOD       (KPROMA)         ; TOTAL-SKY SURFACE SW TRANSMISSITY
-!  ZLWFC        (KPROMA,2)       ; CLEAR-SKY LONGWAVE FLUXES
-!  ZLWFT        (KPROMA,KLEV+1)  ; TOTAL-SKY LONGWAVE FLUXES
-!  ZSWFC        (KPROMA,2)       ; CLEAR-SKY SHORTWAVE FLUXES
-!  ZSWFT        (KPROMA,KLEV+1)  ; TOTAL-SKY SHORTWAVE FLUXES
-!  PPIZA_TOT    (KPROMA,KLEV,NSW); Single scattering albedo of total aerosols 
-!  PCGA_TOT     (KPROMA,KLEV,NSW); Assymetry factor for total aerosols 
-!  PTAU_TOT     (KPROMA,KLEV,NSW); Optical depth of total aerosols 
-!  PPIZA_NAT    (KPROMA,KLEV,NSW); Single scattering albedo of natural aerosols 
-!  PCGA_NAT     (KPROMA,KLEV,NSW); Assymetry factor for natural aerosols 
-!  PTAU_NAT     (KPROMA,KLEV,NSW); Optical depth of natiral aerosols
-!  PTAU_LW_TOT  (KPROMA,KLEV,NLW); LW Optical depth of total aerosols  
-!  PTAU_LW_NAT  (KPROMA,KLEV,NLW); LW Optical depth of natural aerosols  
-!  PSFSWDIR     (KPROMA,NSW)     ;
-!  PSFSWDIF     (KPROMA,NSW)     ;
-!  PFSDNN       (KPROMA)         ;
-!  PFSDNV       (KPROMA)         ;
+
 ! ---------
 ! ---------
@@ -1091,9 +1049,4 @@
       ZSOLSWCF_AERO(:,3)=ZSOLSWCF_AERO(:,3)*fract(:)
 
-!     print*,'SW_RRTM ZFSDN0 1 , klev:',ZFSDN0(1:klon,1),ZFSDN0(1:klon,klev)
-!     print*,'SW_RRTM ZFSUP0 1 , klev:',ZFSUP0(1:klon,1),ZFSUP0(1:klon,klev)
-!     print*,'SW_RRTM ZFSDN  1 , klev:',ZFSDN(1:klon,1),ZFSDN(1:klon,klev)
-!     print*,'SW_RRTM ZFSUP  1 , klev:',ZFSUP(1:klon,1),ZFSUP(1:klon,klev)	
-!     print*,'OK1'
 ! ---------
 ! ---------
@@ -1198,5 +1151,5 @@
       ENDDO
 !
-! Aerosols A REVOIR
+! AI ATTENTION Aerosols A REVOIR
 !      DO i = 1, kdlon
 !      DO k = 1, kflev
@@ -1267,11 +1220,12 @@
          ENDDO
          DO k=1,kflev
-            ZO3_DP_i(1:klon,k)=ZO3_DP(1:klon,kflev+1-k)
-            DO i=1,6
-            PAER_i(1:klon,k,i)=PAER(1:klon,kflev+1-k,i)
-            ENDDO
+            POZON_i(1:klon,k,:)=POZON(1:klon,kflev+1-k,:)
+!            ZO3_DP_i(1:klon,k)=ZO3_DP(1:klon,kflev+1-k)
+!            DO i=1,6
+            PAER_i(1:klon,k,:)=PAER(1:klon,kflev+1-k,:)
+!            ENDDO
          ENDDO
 ! AI 02.2021
-! Calcul of ZTH_i
+! Calcul de ZTH_i (temp aux interfaces 1:klev+1)
          DO K=2,KLEV
             ZTH_i(:,K)=&
@@ -1306,5 +1260,5 @@
         CALL writefield_phy('palbd_new',PALBD_NEW,NSW)
         CALL writefield_phy('palbp_new',PALBP_NEW,NSW)
-        CALL writefield_phy('ZO3_DP',ZO3_DP,klev)
+!        CALL writefield_phy('ZO3_DP',ZO3_DP,klev)
       ENDIF
 
@@ -1316,5 +1270,5 @@
       & rmu0, tsol, PALBD_NEW,PALBP_NEW, &   
 !       PEMIS_WINDOW (???), &
-      &  ZEMIS, ZEMISW, &
+      & ZEMIS, ZEMISW, &
 !       PCCN_LAND, PCCN_SEA, & ???
       & pctsrf(:,is_ter), pctsrf(:,is_oce), &
@@ -1326,6 +1280,6 @@
       & paprs_i, ZTH_i, q_i, qsat_i, & 
 !       Gas
-      & ZCO2, ZCH4, ZN2O, ZNO2, ZCFC11, ZCFC12, ZHCFC22, ZCCL4, ZO3_DP_i, &
-!       
+       & ZCO2, ZCH4, ZN2O, ZNO2, ZCFC11, ZCFC12, ZHCFC22, ZCCL4, POZON_i(:,:,1), &
+!       nuages :
       & cldfra_i, flwc_i, fiwc_i, ZQ_RAIN, ZQ_SNOW, &  
       & ref_liq_i, ref_ice_i, &
@@ -1333,11 +1287,11 @@
       & ZAEROSOL_OLD, ZAEROSOL, &
 ! Outputs
-!       Net flux
-      & ZSWFT_i, ZLWFT_i, ZSWFT0_i, ZLWFT0_i, &
-!       DN flux
+!       Net flux :
+      & ZSWFT_i, ZLWFT_i, ZSWFT0_ii, ZLWFT0_ii, &
+!       DWN flux :
       & ZFSDWN_i, ZFLUX_i(:,2,:), ZFCDWN_i, ZFLUC_i(:,2,:), &
-!       UP flux
+!       UP flux :
       & ZFSUP_i, ZFLUX_i(:,1,:), ZFCUP_i, ZFLUC_i(:,1,:), &
-!       Surf Direct flux
+!       Surf Direct flux : ATTENTION
       & ZFLUX_DIR, ZFLUX_DIR_CLEAR, ZFLUX_DIR_INTO_SUN, &
 !       UV and para flux
@@ -1348,43 +1302,19 @@
 
       print *,'========= RADLWSW: apres RADIATION_SCHEME ==================== '
-  IF (lldebug) THEN
-    if (0.eq.0) then
-      print *,' Net Flux '
-      print *,'ZSWFT_i =', ZSWFT_i
-      print *,'ZLWFT_i =', ZLWFT_i
-      print *,'ZSWFT0_i =', ZSWFT0_i
-      print*,'ZLWFT0_i =', ZLWFT0_i
-
-      print*,'DN Flux '
-      print*,'ZFSDWN_i =', ZFSDWN_i
-      print*,'ZFLUX_i(:,2,:)', ZFLUX_i(:,2,:)
-      print*,'ZFCDWN_i =', ZFCDWN_i
-      print*,'ZFLUC_i(:,2,:) =', ZFLUC_i(:,2,:) 
-
-      print*,'UP Flux '
-      print*,'ZFSUP_i =', ZFSUP_i 
-      print*,'ZFLUX_i(:,1,:) =', ZFLUX_i(:,1,:)
-      print*,'ZFCUP_i =', ZFCUP_i
-      print*,'ZFLUC_i(:,1,:) =', ZFLUC_i(:,1,:)
-
-      print*,'UV and para flux '
-      print*,'ZFLUX_DIR =', ZFLUX_DIR
-      print*,'ZFLUX_DIR_CLEAR', ZFLUX_DIR_CLEAR
-      print*,'ZFLUX_DIR_INTO_SUN', ZFLUX_DIR_INTO_SUN
-    endif
-   ENDIF
 
       IF (lldebug) THEN
         CALL writefield_phy('zlwft_i',ZLWFT_i,klev+1)
-        CALL writefield_phy('zlwft0_i',ZLWFT0_i,klev+1)
+        CALL writefield_phy('zlwft0_ii',ZLWFT0_ii,klev+1)
         CALL writefield_phy('zswft_i',ZSWFT_i,klev+1)
-        CALL writefield_phy('zswft0_i',ZSWFT0_i,klev+1)
+        CALL writefield_phy('zswft0_i',ZSWFT0_ii,klev+1)
+        CALL writefield_phy('zfsdwn_i',ZFSDWN_i,klev+1)
+        CALL writefield_phy('zflux2_i',ZFLUX_i(:,2,:),klev+1)
+        CALL writefield_phy('zfcdwn_i',ZFCDWN_i,klev+1)
+        CALL writefield_phy('zfluc2_i',ZFLUC_i(:,2,:),klev+1)
         CALL writefield_phy('psfswdir',PSFSWDIR,6)
         CALL writefield_phy('psfswdif',PSFSWDIF,6)
-        CALL writefield_phy('zflux_i',ZFLUX_i,klev+1)
-        CALL writefield_phy('zfluc_i',ZFLUC_i,klev+1)
-        CALL writefield_phy('zfsdwn_i',ZFSDWN_i,klev+1)
+        CALL writefield_phy('zflux1_i',ZFLUX_i(:,1,:),klev+1)
+        CALL writefield_phy('zfluc1_i',ZFLUC_i(:,1,:),klev+1)
         CALL writefield_phy('zfsup_i',ZFSUP_i,klev+1)
-        CALL writefield_phy('zfcdwn_i',ZFCDWN_i,klev+1)
         CALL writefield_phy('zfcup_i',ZFCUP_i,klev+1)
       ENDIF
@@ -1394,6 +1324,6 @@
 ! avec l ancien rayonnement AR4. Si nuit, fract=0 donc pas de 
 ! rayonnement SW. (MPL 260609)
-      print*,'On retablit ordre des niveaux verticaux'
-      print*,'On multiplie les flux SW par fract ?'
+      print*,'On retablit l ordre des niveaux verticaux pour LMDZ'
+      print*,'On multiplie les flux SW par fract et LW dwn par -1'
       DO k=0,klev
          DO i=1,klon
@@ -1405,10 +1335,11 @@
           ZLWFT(i,k+1)  = ZLWFT_i(i,klev+1-k)
           ZSWFT(i,k+1)  = ZSWFT_i(i,klev+1-k)*fract(i)
-          ZSWFT0_i(i,k+1) = ZSWFT0_i(i,klev+1-k)*fract(i)
+          ZSWFT0_i(i,k+1) = ZSWFT0_ii(i,klev+1-k)*fract(i)
+          ZLWFT0_i(i,k+1) = ZLWFT0_ii(i,klev+1-k)
 !
          ZFLUP(i,k+1)  = ZFLUX_i(i,1,klev+1-k)
-         ZFLDN(i,k+1)  = ZFLUX_i(i,2,klev+1-k)
+         ZFLDN(i,k+1)  = -1.*ZFLUX_i(i,2,klev+1-k)
          ZFLUP0(i,k+1) = ZFLUC_i(i,1,klev+1-k)
-         ZFLDN0(i,k+1) = ZFLUC_i(i,2,klev+1-k)
+         ZFLDN0(i,k+1) = -1.*ZFLUC_i(i,2,klev+1-k)
          ZFSDN(i,k+1)  = ZFSDWN_i(i,klev+1-k)*fract(i)
          ZFSDN0(i,k+1) = ZFCDWN_i(i,klev+1-k)*fract(i)
@@ -1417,5 +1348,5 @@
          ZFSUP0(i,k+1) = ZFCUP_i(i,klev+1-k)*fract(i)
          ZFSUPC0(i,k+1)= ZFCCUP_i(i,klev+1-k)*fract(i)
-         ZFLDNC0(i,k+1)= ZFLCCDWN_i(i,klev+1-k)
+         ZFLDNC0(i,k+1)= -1.*ZFLCCDWN_i(i,klev+1-k)
          ZFLUPC0(i,k+1)= ZFLCCUP_i(i,klev+1-k)
          IF (ok_volcan) THEN
@@ -1596,17 +1527,39 @@
  ENDDO ! j = 1, nb_gr
 
-!IF (lldebug) THEN
-! print*,'================== Sortie de radlw ================='
-! print*,'cool = ', cool
-! print*,'heat = ', heat
-! print*,'topsw = ', topsw
-! print*,'toplw = ', toplw
-! print*,'sollw = ', sollw
-! print*,'solsw = ', solsw
-! print*,'lwdn = ', lwdn
-! print*,'lwup = ', lwup
-! print*,'swdn = ', swdn
-! print*,'swup =', swup
-!ENDIF
+IF (lldebug) THEN
+ if (0.eq.1) then
+! Verifs dans le cas 1D
+ print*,'================== Sortie de radlw ================='
+ print*,'******** LW LW LW *******************'
+ print*,'ZLWFT =',ZLWFT
+ print*,'ZLWFT0_i =',ZLWFT0_i
+ print*,'ZFLUP0 =',ZFLUP0
+ print*,'ZFLDN0 =',ZFLDN0
+ print*,'ZFLDNC0 =',ZFLDNC0
+ print*,'ZFLUPC0 =',ZFLUPC0
+
+ print*,'******** SW SW SW *******************'
+ print*,'ZSWFT =',ZSWFT
+ print*,'ZSWFT0_i =',ZSWFT0_i
+ print*,'ZFSDN =',ZFSDN
+ print*,'ZFSDN0 =',ZFSDN0
+ print*,'ZFSDNC0 =',ZFSDNC0
+ print*,'ZFSUP =',ZFSUP
+ print*,'ZFSUP0 =',ZFSUP0
+ print*,'ZFSUPC0 =',ZFSUPC0
+
+ print*,'******** LMDZ  *******************'
+ print*,'cool = ', cool
+ print*,'heat = ', heat
+ print*,'topsw = ', topsw
+ print*,'toplw = ', toplw
+ print*,'sollw = ', sollw
+ print*,'solsw = ', solsw
+ print*,'lwdn = ', lwdn
+ print*,'lwup = ', lwup
+ print*,'swdn = ', swdn
+ print*,'swup =', swup
+ endif
+ENDIF
 
 END SUBROUTINE radlwsw
