Index: LMDZ6/branches/LMDZ-tracers/libf/phylmd/radlwsw_m.F90
===================================================================
--- LMDZ6/branches/LMDZ-tracers/libf/phylmd/radlwsw_m.F90	(revision 3725)
+++ LMDZ6/branches/LMDZ-tracers/libf/phylmd/radlwsw_m.F90	(revision 3851)
@@ -26,5 +26,5 @@
    heat,heat0,cool,cool0,albpla,&
    heat_volc, cool_volc,&
-   topsw,toplw,solsw,sollw,&
+   topsw,toplw,solsw,solswfdiff,sollw,&
    sollwdown,&
    topsw0,toplw0,solsw0,sollw0,&
@@ -117,4 +117,5 @@
   ! toplw----output-R- ray. IR montant au sommet de l'atmosphere
   ! solsw----output-R- flux solaire net a la surface
+  ! solswfdiff----output-R- fraction de rayonnement diffus pour le flux solaire descendant a la surface
   ! sollw----output-R- ray. IR montant a la surface
   ! solswad---output-R- ray. solaire net absorbe a la surface (aerosol dir)
@@ -188,5 +189,5 @@
   REAL,    INTENT(in)  :: tsol(KLON)
   REAL,    INTENT(in) :: alb_dir(KLON,NSW),alb_dif(KLON,NSW)
-  real, intent(in) :: SFRWL(6)
+  REAL,    INTENT(in) :: SFRWL(6)
 !albedo SB <<<
   REAL,    INTENT(in)  :: t(KLON,KLEV), q(KLON,KLEV)
@@ -235,5 +236,5 @@
   REAL,    INTENT(out) :: heat_volc(KLON,KLEV), cool_volc(KLON,KLEV) !NL
   REAL,    INTENT(out) :: topsw(KLON), toplw(KLON)
-  REAL,    INTENT(out) :: solsw(KLON), sollw(KLON), albpla(KLON)
+  REAL,    INTENT(out) :: solsw(KLON), sollw(KLON), albpla(KLON), solswfdiff(KLON)
   REAL,    INTENT(out) :: topsw0(KLON), toplw0(KLON), solsw0(KLON), sollw0(KLON)
   REAL,    INTENT(out) :: sollwdown(KLON)
@@ -286,5 +287,5 @@
   REAL(KIND=8) PWV(kdlon,kflev), PQS(kdlon,kflev)
 
-  real(kind=8) POZON(kdlon, kflev, size(wo, 3)) ! mass fraction of ozone
+  REAL(kind=8) POZON(kdlon, kflev, size(wo, 3)) ! mass fraction of ozone
   ! "POZON(:, :, 1)" is for the average day-night field, 
   ! "POZON(:, :, 2)" is for daylight time.
@@ -302,5 +303,5 @@
   REAL(KIND=8) zheat_volc(kdlon,kflev), zcool_volc(kdlon,kflev) !NL
   REAL(KIND=8) ztopsw(kdlon), ztoplw(kdlon)
-  REAL(KIND=8) zsolsw(kdlon), zsollw(kdlon), zalbpla(kdlon)
+  REAL(KIND=8) zsolsw(kdlon), zsollw(kdlon), zalbpla(kdlon), zsolswfdiff(kdlon)
   REAL(KIND=8) zsollwdown(kdlon)
   REAL(KIND=8) ztopsw0(kdlon), ztoplw0(kdlon)
@@ -329,74 +330,76 @@
 !MPL input supplementaires pour RECMWFL
 ! flwc, fiwc = Liquid Water Content & Ice Water Content (kg/kg)
-      REAL(KIND=8) GEMU(klon)
+  REAL(KIND=8) GEMU(klon)
 !MPL input RECMWFL: 
 ! Tableaux aux niveaux inverses pour respecter convention Arpege
-      REAL(KIND=8) ref_liq_i(klon,klev) ! cloud droplet radius present-day from newmicro (inverted)
-      REAL(KIND=8) ref_ice_i(klon,klev) ! ice crystal radius present-day from newmicro (inverted)
+  REAL(KIND=8) ref_liq_i(klon,klev) ! cloud droplet radius present-day from newmicro (inverted)
+  REAL(KIND=8) ref_ice_i(klon,klev) ! ice crystal radius present-day from newmicro (inverted)
 !--OB
-      REAL(KIND=8) ref_liq_pi_i(klon,klev) ! cloud droplet radius pre-industrial from newmicro (inverted)
-      REAL(KIND=8) ref_ice_pi_i(klon,klev) ! ice crystal radius pre-industrial from newmicro (inverted)
+  REAL(KIND=8) ref_liq_pi_i(klon,klev) ! cloud droplet radius pre-industrial from newmicro (inverted)
+  REAL(KIND=8) ref_ice_pi_i(klon,klev) ! ice crystal radius pre-industrial from newmicro (inverted)
 !--end OB
-      REAL(KIND=8) paprs_i(klon,klev+1)
-      REAL(KIND=8) pplay_i(klon,klev)
-      REAL(KIND=8) cldfra_i(klon,klev)
-      REAL(KIND=8) POZON_i(kdlon,kflev, size(wo, 3)) ! mass fraction of ozone 
+  REAL(KIND=8) paprs_i(klon,klev+1)
+  REAL(KIND=8) pplay_i(klon,klev)
+  REAL(KIND=8) cldfra_i(klon,klev)
+  REAL(KIND=8) POZON_i(kdlon,kflev, size(wo, 3)) ! mass fraction of ozone 
   ! "POZON(:, :, 1)" is for the average day-night field, 
   ! "POZON(:, :, 2)" is for daylight time.
 !!!!! Modif MPL 6.01.09 avec RRTM, on passe de 5 a 6      
-      REAL(KIND=8) PAER_i(kdlon,kflev,6)
-      REAL(KIND=8) PDP_i(klon,klev)
-      REAL(KIND=8) t_i(klon,klev),q_i(klon,klev),qsat_i(klon,klev)
-      REAL(KIND=8) flwc_i(klon,klev),fiwc_i(klon,klev)
+  REAL(KIND=8) PAER_i(kdlon,kflev,6)
+  REAL(KIND=8) PDP_i(klon,klev)
+  REAL(KIND=8) t_i(klon,klev),q_i(klon,klev),qsat_i(klon,klev)
+  REAL(KIND=8) flwc_i(klon,klev),fiwc_i(klon,klev)
 !MPL output RECMWFL:
-      REAL(KIND=8) ZEMTD (klon,klev+1),ZEMTD_i (klon,klev+1)       
-      REAL(KIND=8) ZEMTU (klon,klev+1),ZEMTU_i (klon,klev+1)      
-      REAL(KIND=8) ZTRSO (klon,klev+1),ZTRSO_i (klon,klev+1)    
-      REAL(KIND=8) ZTH   (klon,klev+1),ZTH_i   (klon,klev+1)   
-      REAL(KIND=8) ZCTRSO(klon,2)       
-      REAL(KIND=8) ZCEMTR(klon,2)     
-      REAL(KIND=8) ZTRSOD(klon)        
-      REAL(KIND=8) ZLWFC (klon,2)      
-      REAL(KIND=8) ZLWFT (klon,klev+1),ZLWFT_i (klon,klev+1)    
-      REAL(KIND=8) ZSWFC (klon,2)      
-      REAL(KIND=8) ZSWFT (klon,klev+1),ZSWFT_i (klon,klev+1)
-      REAL(KIND=8) ZFLUCDWN_i(klon,klev+1),ZFLUCUP_i(klon,klev+1)
-      REAL(KIND=8) PPIZA_TOT(klon,klev,NSW)
-      REAL(KIND=8) PCGA_TOT(klon,klev,NSW)
-      REAL(KIND=8) PTAU_TOT(klon,klev,NSW)
-      REAL(KIND=8) PPIZA_NAT(klon,klev,NSW)
-      REAL(KIND=8) PCGA_NAT(klon,klev,NSW)
-      REAL(KIND=8) PTAU_NAT(klon,klev,NSW)
+  REAL(KIND=8) ZEMTD (klon,klev+1),ZEMTD_i (klon,klev+1)       
+  REAL(KIND=8) ZEMTU (klon,klev+1),ZEMTU_i (klon,klev+1)      
+  REAL(KIND=8) ZTRSO (klon,klev+1),ZTRSO_i (klon,klev+1)    
+  REAL(KIND=8) ZTH   (klon,klev+1),ZTH_i   (klon,klev+1)   
+  REAL(KIND=8) ZCTRSO(klon,2)       
+  REAL(KIND=8) ZCEMTR(klon,2)     
+  REAL(KIND=8) ZTRSOD(klon)        
+  REAL(KIND=8) ZLWFC (klon,2)      
+  REAL(KIND=8) ZLWFT (klon,klev+1),ZLWFT_i (klon,klev+1)    
+  REAL(KIND=8) ZSWFC (klon,2)      
+  REAL(KIND=8) ZSWFT (klon,klev+1),ZSWFT_i (klon,klev+1)
+  REAL(KIND=8) ZFLUCDWN_i(klon,klev+1),ZFLUCUP_i(klon,klev+1)
+  REAL(KIND=8) PPIZA_TOT(klon,klev,NSW)
+  REAL(KIND=8) PCGA_TOT(klon,klev,NSW)
+  REAL(KIND=8) PTAU_TOT(klon,klev,NSW)
+  REAL(KIND=8) PPIZA_NAT(klon,klev,NSW)
+  REAL(KIND=8) PCGA_NAT(klon,klev,NSW)
+  REAL(KIND=8) PTAU_NAT(klon,klev,NSW)
 #ifdef CPP_RRTM
-      REAL(KIND=8) PTAU_LW_TOT(klon,klev,NLW)
-      REAL(KIND=8) PTAU_LW_NAT(klon,klev,NLW)
+  REAL(KIND=8) PTAU_LW_TOT(klon,klev,NLW)
+  REAL(KIND=8) PTAU_LW_NAT(klon,klev,NLW)
 #endif
-      REAL(KIND=8) PSFSWDIR(klon,NSW)
-      REAL(KIND=8) PSFSWDIF(klon,NSW)
-      REAL(KIND=8) PFSDNN(klon)
-      REAL(KIND=8) PFSDNV(klon)
+  REAL(KIND=8) PSFSWDIR(klon,NSW)
+  REAL(KIND=8) PSFSWDIF(klon,NSW)
+  REAL(KIND=8) PFSDNN(klon)
+  REAL(KIND=8) PFSDNV(klon)
 !MPL On ne redefinit pas les tableaux ZFLUX,ZFLUC,
 !MPL ZFSDWN,ZFCDWN,ZFSUP,ZFCUP car ils existent deja
 !MPL sous les noms de ZFLDN,ZFLDN0,ZFLUP,ZFLUP0,
 !MPL ZFSDN,ZFSDN0,ZFSUP,ZFSUP0
-      REAL(KIND=8) ZFLUX_i (klon,2,klev+1)
-      REAL(KIND=8) ZFLUC_i (klon,2,klev+1)
-      REAL(KIND=8) ZFSDWN_i (klon,klev+1)
-      REAL(KIND=8) ZFCDWN_i (klon,klev+1)
-      REAL(KIND=8) ZFCCDWN_i (klon,klev+1)
-      REAL(KIND=8) ZFSUP_i (klon,klev+1)
-      REAL(KIND=8) ZFCUP_i (klon,klev+1)
-      REAL(KIND=8) ZFCCUP_i (klon,klev+1)
-      REAL(KIND=8) ZFLCCDWN_i (klon,klev+1)
-      REAL(KIND=8) ZFLCCUP_i (klon,klev+1)
+  REAL(KIND=8) ZFLUX_i (klon,2,klev+1)
+  REAL(KIND=8) ZFLUC_i (klon,2,klev+1)
+  REAL(KIND=8) ZFSDWN_i (klon,klev+1)
+  REAL(KIND=8) ZFCDWN_i (klon,klev+1)
+  REAL(KIND=8) ZFCCDWN_i (klon,klev+1)
+  REAL(KIND=8) ZFSUP_i (klon,klev+1)
+  REAL(KIND=8) ZFCUP_i (klon,klev+1)
+  REAL(KIND=8) ZFCCUP_i (klon,klev+1)
+  REAL(KIND=8) ZFLCCDWN_i (klon,klev+1)
+  REAL(KIND=8) ZFLCCUP_i (klon,klev+1)
 ! 3 lignes suivantes a activer pour CCMVAL (MPL 20100412)
 !      REAL(KIND=8) RSUN(3,2)
 !      REAL(KIND=8) SUN(3)
 !      REAL(KIND=8) SUN_FRACT(2)
-  real, parameter:: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
+  REAL, PARAMETER:: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
   CHARACTER (LEN=80) :: abort_message
   CHARACTER (LEN=80) :: modname='radlwsw_m'
 
-  call assert(size(wo, 1) == klon, size(wo, 2) == klev, "radlwsw wo")
+  REAL zdir, zdif
+
+  CALL assert(size(wo, 1) == klon, size(wo, 2) == klev, "radlwsw wo")
   ! initialisation
   ist=1
@@ -414,13 +417,12 @@
   zsolsw0_aero(:,:) = 0. !ym missing init : warning : not initialized in SW_AEROAR4
 
-
-   ZTOPSWADAERO(:)  = 0. !ym missing init
-   ZSOLSWADAERO(:)  = 0. !ym missing init
-   ZTOPSWAD0AERO(:) = 0. !ym missing init
-   ZSOLSWAD0AERO(:) = 0. !ym missing init
-   ZTOPSWAIAERO(:)  = 0. !ym missing init 
-   ZSOLSWAIAERO(:)  = 0. !ym missing init  
-   ZTOPSWCF_AERO(:,:)= 0.!ym missing init  
-   ZSOLSWCF_AERO(:,:) =0. !ym missing init  
+  ZTOPSWADAERO(:)  = 0. !ym missing init
+  ZSOLSWADAERO(:)  = 0. !ym missing init
+  ZTOPSWAD0AERO(:) = 0. !ym missing init
+  ZSOLSWAD0AERO(:) = 0. !ym missing init
+  ZTOPSWAIAERO(:)  = 0. !ym missing init 
+  ZSOLSWAIAERO(:)  = 0. !ym missing init  
+  ZTOPSWCF_AERO(:,:)= 0.!ym missing init  
+  ZSOLSWCF_AERO(:,:) =0. !ym missing init  
 
   !
@@ -454,9 +456,9 @@
 #ifdef REPROBUS
     IF (iflag_rrtm==0) THEN
-      if(ok_SUNTIME) PSCT = solaireTIME/zdist/zdist
+      IF (ok_SUNTIME) PSCT = solaireTIME/zdist/zdist
       print*,'Constante solaire: ',PSCT*zdist*zdist
-    END IF
+    ENDIF
 #endif
-  END IF
+  ENDIF
 
   DO j = 1, nb_gr
@@ -541,6 +543,5 @@
        CALL RAD_INTERACTIF(POZON,iof)
 #endif
-    END IF
-
+    ENDIF
     !
     DO k = 1, kflev+1
@@ -568,9 +569,9 @@
       ENDDO
     ENDDO
-
 !
 !===== iflag_rrtm ================================================
 !      
     IF (iflag_rrtm == 0) THEN       !!!! remettre 0 juste pour tester l'ancien rayt via rrtm
+!
 !--- Mise a zero des tableaux output du rayonnement LW-AR4 ----------              
       DO k = 1, kflev+1
@@ -651,4 +652,9 @@
       zsolswaiaero(i)=0.
       ENDDO
+
+      !--fraction of diffuse radiation in surface SW downward radiation
+      !--not computed with old radiation scheme
+      zsolswfdiff(:) = -999.999
+
 !     print *,'Avant SW_LMDAR4: PSCT zrmu0 zfract',PSCT, zrmu0, zfract
        ! daylight ozone, if we have it, for short wave
@@ -676,5 +682,4 @@
        DO i=1,kdlon
        DO k=1,kflev+1
-!        print *,'iof i k klon klev=',iof,i,k,klon,klev
          lwdn0 ( iof+i,k)   = ZFLDN0 ( i,k)
          lwdn  ( iof+i,k)   = ZFLDN  ( i,k)
@@ -687,10 +692,5 @@
        ENDDO  
        ENDDO  
-!          print*,'SW_AR4 ZFSDN0 1 , klev:',ZFSDN0(1:klon,1),ZFSDN0(1:klon,klev)
-!          print*,'SW_AR4 swdn0  1 , klev:',swdn0(1:klon,1),swdn0(1:klon,klev)
-!          print*,'SW_AR4 ZFSUP0 1 , klev:',ZFSUP0(1:klon,1),ZFSUP0(1:klon,klev)
-!          print*,'SW_AR4 swup0  1 , klev:',swup0(1:klon,1),swup0(1:klon,klev)
-!          print*,'SW_AR4 ZFSDN  1 , klev:',ZFSDN(1:klon,1) ,ZFSDN(1:klon,klev)
-!          print*,'SW_AR4 ZFSUP  1 , klev:',ZFSUP(1:klon,1) ,ZFSUP(1:klon,klev)
+!
     ELSE  
 #ifdef CPP_RRTM
@@ -700,22 +700,22 @@
       DO k = 1, kflev+1
       DO i = 1, kdlon
-      ZEMTD_i(i,k)=0.
-      ZEMTU_i(i,k)=0.
-      ZTRSO_i(i,k)=0.
-      ZTH_i(i,k)=0.
-      ZLWFT_i(i,k)=0.
-      ZSWFT_i(i,k)=0.
-      ZFLUX_i(i,1,k)=0.
-      ZFLUX_i(i,2,k)=0.
-      ZFLUC_i(i,1,k)=0.
-      ZFLUC_i(i,2,k)=0.
-      ZFSDWN_i(i,k)=0.
-      ZFCDWN_i(i,k)=0.
-      ZFCCDWN_i(i,k)=0.
-      ZFSUP_i(i,k)=0.
-      ZFCUP_i(i,k)=0.
-      ZFCCUP_i(i,k)=0.
-      ZFLCCDWN_i(i,k)=0.
-      ZFLCCUP_i(i,k)=0.
+        ZEMTD_i(i,k)=0.
+        ZEMTU_i(i,k)=0.
+        ZTRSO_i(i,k)=0.
+        ZTH_i(i,k)=0.
+        ZLWFT_i(i,k)=0.
+        ZSWFT_i(i,k)=0.
+        ZFLUX_i(i,1,k)=0.
+        ZFLUX_i(i,2,k)=0.
+        ZFLUC_i(i,1,k)=0.
+        ZFLUC_i(i,2,k)=0.
+        ZFSDWN_i(i,k)=0.
+        ZFCDWN_i(i,k)=0.
+        ZFCCDWN_i(i,k)=0.
+        ZFSUP_i(i,k)=0.
+        ZFCUP_i(i,k)=0.
+        ZFCCUP_i(i,k)=0.
+        ZFLCCDWN_i(i,k)=0.
+        ZFLCCUP_i(i,k)=0.
       ENDDO
       ENDDO
@@ -771,6 +771,6 @@
       PFSDNV(i)=0.
       DO kk = 1, NSW
-      PSFSWDIR(i,kk)=0.
-      PSFSWDIF(i,kk)=0.
+        PSFSWDIR(i,kk)=0.
+        PSFSWDIF(i,kk)=0.
       ENDDO
       ENDDO
@@ -779,5 +779,5 @@
 ! On met les donnees dans l'ordre des niveaux arpege
          paprs_i(:,1)=paprs(:,klev+1)
-         do k=1,klev
+         DO k=1,klev
             paprs_i(1:klon,k+1) =paprs(1:klon,klev+1-k)
             pplay_i(1:klon,k)   =pplay(1:klon,klev+1-k)
@@ -794,14 +794,14 @@
             ref_liq_pi_i(1:klon,k) =ref_liq_pi(1:klon,klev+1-k)
             ref_ice_pi_i(1:klon,k) =ref_ice_pi(1:klon,klev+1-k)
-         enddo
-         do k=1,kflev
+         ENDDO
+         DO k=1,kflev
            POZON_i(1:klon,k,:)=POZON(1:klon,kflev+1-k,:)
 !!!            POZON_i(1:klon,k)=POZON(1:klon,k)	    !!! on laisse 1=sol et klev=top 
 !          print *,'Juste avant RECMWFL: k tsol temp',k,tsol,t(1,k)
 !!!!!!! Modif MPL 6.01.09 avec RRTM, on passe de 5 a 6      
-            do i=1,6
+            DO i=1,6
             PAER_i(1:klon,k,i)=PAER(1:klon,kflev+1-k,i)
-            enddo
-         enddo
+            ENDDO
+         ENDDO
 !       print *,'RADLWSW: avant RECMWFL, RI0,rmu0=',solaire,rmu0
 
@@ -832,5 +832,5 @@
 !    s   'RECMWF ')
 !
-      if(lldebug) then
+      IF (lldebug) THEN
         CALL writefield_phy('paprs_i',paprs_i,klev+1)
         CALL writefield_phy('pplay_i',pplay_i,klev)
@@ -846,5 +846,5 @@
         CALL writefield_phy('palbd_new',PALBD_NEW,NSW)
         CALL writefield_phy('palbp_new',PALBP_NEW,NSW)
-      endif
+      ENDIF
 
 ! Nouvel appel a RECMWF (celui du cy32t0)
@@ -876,5 +876,5 @@
             
 !        print *,'RADLWSW: apres RECMWF'
-      if(lldebug) then
+      IF (lldebug) THEN
         CALL writefield_phy('zemtd_i',ZEMTD_i,klev+1)
         CALL writefield_phy('zemtu_i',ZEMTU_i,klev+1)
@@ -901,5 +901,5 @@
         CALL writefield_phy('zfcdwn_i',ZFCDWN_i,klev+1)
         CALL writefield_phy('zfcup_i',ZFCUP_i,klev+1)
-      endif
+      ENDIF
 ! --------- output RECMWFL
 !  ZEMTD        (KPROMA,KLEV+1)  ; TOTAL DOWNWARD LONGWAVE EMISSIVITY
@@ -952,5 +952,5 @@
          ZFLDNC0(i,k+1)= ZFLCCDWN_i(i,k+1)
          ZFLUPC0(i,k+1)= ZFLCCUP_i(i,k+1)
-         IF(ok_volcan) THEN
+         IF (ok_volcan) THEN
             ZSWADAERO(i,k+1)=ZSWADAERO(i,k+1)*fract(i) !--NL
          ENDIF
@@ -992,4 +992,16 @@
 ! On renseigne les champs LMDz, pour avoir la meme chose qu'en sortie de
 ! LW_LMDAR4 et SW_LMDAR4
+
+      !--fraction of diffuse radiation in surface SW downward radiation
+      DO i = 1, kdlon
+       IF (fract(i).GT.0.0) THEN
+         zdir=SUM(PSFSWDIR(i,:))
+         zdif=SUM(PSFSWDIF(i,:))
+         zsolswfdiff(i) = zdif/(zdir+zdif)
+       ELSE  !--night
+         zsolswfdiff(i) = 1.0
+       ENDIF
+      ENDDO 
+!
       DO i = 1, kdlon
          zsolsw(i)    = ZSWFT(i,1)
@@ -1009,5 +1021,5 @@
          ztoplw0(i)   = ZLWFT0_i(i,klev+1)*(-1)
 !         
-           IF (fract(i) == 0.) THEN
+         IF (fract(i) == 0.) THEN
 !!!!! A REVOIR MPL (20090630) ca n a pas de sens quand fract=0
 ! pas plus que dans le sw_AR4
@@ -1030,11 +1042,11 @@
 ! ZLWFT(klon,k),ZSWFT
 
-      do k=1,kflev
-         do i=1,kdlon
+      DO k=1,kflev
+         DO i=1,kdlon
            zheat(i,k)=(ZSWFT(i,k+1)-ZSWFT(i,k))*RDAY*RG/RCPD/PDP(i,k)
            zheat0(i,k)=(ZSWFT0_i(i,k+1)-ZSWFT0_i(i,k))*RDAY*RG/RCPD/PDP(i,k)
            zcool(i,k)=(ZLWFT(i,k)-ZLWFT(i,k+1))*RDAY*RG/RCPD/PDP(i,k)
            zcool0(i,k)=(ZLWFT0_i(i,k)-ZLWFT0_i(i,k+1))*RDAY*RG/RCPD/PDP(i,k)
-           IF(ok_volcan) THEN
+           IF (ok_volcan) THEN
               zheat_volc(i,k)=(ZSWADAERO(i,k+1)-ZSWADAERO(i,k))*RG/RCPD/PDP(i,k) !NL
               zcool_volc(i,k)=(ZLWADAERO(i,k)-ZLWADAERO(i,k+1))*RG/RCPD/PDP(i,k) !NL
@@ -1043,6 +1055,6 @@
 !	   ZFLUCUP_i(i,k)=ZFLUC_i(i,1,k)
 !	   ZFLUCDWN_i(i,k)=ZFLUC_i(i,2,k)	   
-         enddo
-      enddo
+         ENDDO
+      ENDDO
 #else
     abort_message="You should compile with -rrtm if running with iflag_rrtm=1"
@@ -1056,4 +1068,5 @@
       toplw(iof+i) = ztoplw(i)
       solsw(iof+i) = zsolsw(i)
+      solswfdiff(iof+i) = zsolswfdiff(i)
       sollw(iof+i) = zsollw(i)
       sollwdown(iof+i) = zsollwdown(i)
