Index: LMDZ5/trunk/libf/phylmd/rrtm/rrtm_rtrn1a_140gp.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/rrtm/rrtm_rtrn1a_140gp.F90	(revision 2148)
+++ LMDZ5/trunk/libf/phylmd/rrtm/rrtm_rtrn1a_140gp.F90	(revision 2150)
@@ -105,4 +105,13 @@
 REAL(KIND=JPRB) :: ZHOOK_HANDLE
 
+
+
+REAL(KIND=JPRB)                  :: CLFNET(0:JPLAY) ! Argument NOT used
+REAL(KIND=JPRB)                  :: CLHTR(0:JPLAY) ! Argument NOT used
+REAL(KIND=JPRB)                  :: FNET(0:JPLAY) ! Argument NOT used
+REAL(KIND=JPRB)                  :: HTR(0:JPLAY) ! Argument NOT used
+
+
+
 !--------------------------------------------------------------------------
 ! Input
@@ -239,6 +248,8 @@
   Z_FACCMB2D(I_LEV) = 0.0_JPRB
 ENDDO  
+
 Z_RAT1 = 0.0_JPRB
 Z_RAT2 = 0.0_JPRB
+
 !_end_jjm 991209
 
@@ -280,6 +291,8 @@
       Z_FACCLR2(I_LEV+1) = 0.0_JPRB
 !-- DS_000515      
-!      FACCMB1(LEV+1) = _ZERO_
-!      FACCMB2(LEV+1) = _ZERO_
+!SB debug >>
+     Z_FACCMB1(I_LEV+1) =0.0_JPRB
+     Z_FACCMB2(I_LEV+1) =0.0_JPRB
+!SB debug <<
 !mji      ISTCLD(LEV+1) = _ZERO_
     ELSEIF (Z_CLDFRAC(I_LEV+1)  >=  Z_CLDFRAC(I_LEV)) THEN
@@ -294,5 +307,9 @@
           Z_FACCLR2(I_LEV+1) = (Z_CLDFRAC(I_LEV+1)-Z_CLDFRAC(I_LEV))/&
            & (1.0_JPRB-Z_CLDFRAC(I_LEV))  
-        ENDIF   
+        ENDIF  
+!SB debug >>
+      Z_FACCLR2(I_LEV) = 0.0_JPRB
+      Z_FACCLD2(I_LEV) = 0.0_JPRB
+!SB debug <<
       ELSE
         Z_FMAX = MAX(Z_CLDFRAC(I_LEV),Z_CLDFRAC(I_LEV-1))
@@ -315,5 +332,11 @@
         Z_RAT1 = 1.0_JPRB
         Z_RAT2 = 0.0_JPRB
+!SB debug >>
+!      ENDIF
+      ELSE
+        Z_RAT1 = 0.0_JPRB
+        Z_RAT2 = 0.0_JPRB
       ENDIF
+!SB debug <<
     ELSE
       Z_FACCLR1(I_LEV+1) = 0.0_JPRB
@@ -323,4 +346,8 @@
         Z_FACCLD1(I_LEV+1) = 0.0_JPRB
         Z_FACCLD2(I_LEV+1) = (Z_CLDFRAC(I_LEV)-Z_CLDFRAC(I_LEV+1))/Z_CLDFRAC(I_LEV)
+!SB debug >>
+        Z_FACCLR2(I_LEV) = 0.0_JPRB
+        Z_FACCLD2(I_LEV) = 0.0_JPRB
+!SB debug <<
       ELSE
         Z_FMIN = MIN(Z_CLDFRAC(I_LEV),Z_CLDFRAC(I_LEV-1))
@@ -337,15 +364,30 @@
         Z_RAT1 = 0.0_JPRB
         Z_RAT2 = 1.0_JPRB
+!SB debug >>
+!      ENDIF
+      ELSE 
+        Z_RAT1 = 0.0_JPRB
+        Z_RAT2 = 0.0_JPRB
       ENDIF
+!SB debug <<
     ENDIF
 !fcc
-    IF (I_LEV == 1) THEN
-      Z_FACCMB1(I_LEV+1) = 0.
-      Z_FACCMB2(I_LEV+1) = Z_FACCLD1(I_LEV+1) * Z_FACCLR2(I_LEV)
-    ELSE
-      Z_FACCMB1(I_LEV+1) = Z_FACCLR1(I_LEV+1) * Z_FACCLD2(I_LEV) *Z_CLDFRAC(I_LEV-1)
-      Z_FACCMB2(I_LEV+1) = Z_FACCLD1(I_LEV+1) * Z_FACCLR2(I_LEV) *&
-       & (1.0_JPRB - Z_CLDFRAC(I_LEV-1))   
-    ENDIF
+
+!SB debug >>
+!    IF (I_LEV == 1) THEN
+!      Z_FACCMB1(I_LEV+1) = 0.
+!      Z_FACCMB2(I_LEV+1) = Z_FACCLD1(I_LEV+1) * Z_FACCLR2(I_LEV)
+!    ELSE
+!      Z_FACCMB1(I_LEV+1) = Z_FACCLR1(I_LEV+1) * Z_FACCLD2(I_LEV) *Z_CLDFRAC(I_LEV-1)
+!      Z_FACCMB2(I_LEV+1) = Z_FACCLD1(I_LEV+1) * Z_FACCLR2(I_LEV) *&
+!       & (1.0_JPRB - Z_CLDFRAC(I_LEV-1))   
+!    ENDIF
+     if(istcld(i_lev).ne.1) then
+        z_faccmb1(i_lev+1) = max(0.,min(z_cldfrac(i_lev+1)-z_cldfrac(i_lev), &
+               z_cldfrac(i_lev-1)-z_cldfrac(i_lev)))
+        z_faccmb2(i_lev+1) = max(0.,min(z_cldfrac(i_lev)-z_cldfrac(i_lev+1), &
+               z_cldfrac(i_lev)-z_cldfrac(i_lev-1)))
+     endif
+!SB debug <<
 !end fcc
   ELSE
@@ -386,4 +428,8 @@
            & (1.0_JPRB-Z_CLDFRAC(I_LEV))  
         ENDIF
+!SB debug >>
+       z_facclr2d(i_lev)=0.0_JPRB        
+       z_faccld2d(i_lev)=0.0_JPRB
+!SB debug <<
       ELSE
         Z_FMAX = MAX(Z_CLDFRAC(I_LEV),Z_CLDFRAC(I_LEV+1))
@@ -406,5 +452,11 @@
         Z_RAT1 = 1.0_JPRB
         Z_RAT2 = 0.0_JPRB
-      ENDIF
+!SB debug >>
+!      ENDIF
+      else 
+        Z_RAT1 = 0.0_JPRB
+        Z_RAT2 = 0.0_JPRB
+      endif       
+!SB debug <<
     ELSE
       Z_FACCLR1D(I_LEV-1) = 0.0_JPRB
@@ -414,4 +466,8 @@
         Z_FACCLD1D(I_LEV-1) = 0.0_JPRB
         Z_FACCLD2D(I_LEV-1) = (Z_CLDFRAC(I_LEV)-Z_CLDFRAC(I_LEV-1))/Z_CLDFRAC(I_LEV)
+!SB debug >>
+        z_facclr2d(i_lev)=0.0_JPRB
+        z_faccld2d(i_lev)=0.0_JPRB
+!SB debug <<
       ELSE
         Z_FMIN = MIN(Z_CLDFRAC(I_LEV),Z_CLDFRAC(I_LEV+1))
@@ -428,9 +484,23 @@
         Z_RAT1 = 0.0_JPRB
         Z_RAT2 = 1.0_JPRB
+!SB debug >>
+!      ENDIF
+      ELSE
+        Z_RAT1 = 0.0_JPRB
+        Z_RAT2 = 0.0_JPRB
       ENDIF
+!SB debug <<
     ENDIF
-    Z_FACCMB1D(I_LEV-1) = Z_FACCLR1D(I_LEV-1) * Z_FACCLD2D(I_LEV) *Z_CLDFRAC(I_LEV+1)
-    Z_FACCMB2D(I_LEV-1) = Z_FACCLD1D(I_LEV-1) * Z_FACCLR2D(I_LEV) *&
-     & (1.0_JPRB - Z_CLDFRAC(I_LEV+1))  
+!SB debug >>
+!    Z_FACCMB1D(I_LEV-1) = Z_FACCLR1D(I_LEV-1) * Z_FACCLD2D(I_LEV) *Z_CLDFRAC(I_LEV+1)
+!    Z_FACCMB2D(I_LEV-1) = Z_FACCLD1D(I_LEV-1) * Z_FACCLR2D(I_LEV) *&
+!     & (1.0_JPRB - Z_CLDFRAC(I_LEV+1))  
+    if (istcldd(i_lev).ne.1) then
+       z_faccmb1d(i_lev-1) = max(0.,min(z_cldfrac(i_lev+1)-z_cldfrac(i_lev), &
+                            z_cldfrac(i_lev-1)-z_cldfrac(i_lev)))
+       z_faccmb2d(i_lev-1) = max(0.,min(z_cldfrac(i_lev)-z_cldfrac(i_lev+1), &
+                    z_cldfrac(i_lev)-z_cldfrac(i_lev-1)))
+    endif
+!SB debug <<
   ELSE
     ISTCLDD(I_LEV-1) = 1
@@ -805,14 +875,14 @@
 !      TOTDFLUX(0) = TOTDFLUX(0) * FLUXFAC
 
-!      CLFNET(0) = TOTUFLUC(0) - TOTDFLUC(0)
-!      FNET(0)   = TOTUFLUX(0) - TOTDFLUX(0)
+!      CLFNET(0) = (P_TOTUFLUC(0) - P_TOTDFLUC(0))
+!      FNET(0)   = (P_TOTUFLUX(0) - P_TOTDFLUX(0))
 !      DO LEV = 1, KLEV
 !        TOTUFLUC(LEV) = TOTUFLUC(LEV) * FLUXFAC
 !        TOTDFLUC(LEV) = TOTDFLUC(LEV) * FLUXFAC
-!        CLFNET(LEV) = TOTUFLUC(LEV) - TOTDFLUC(LEV)
+!         CLFNET(LEV) =(P_TOTUFLUC(LEV) - P_TOTDFLUC(LEV))
 
 !        TOTUFLUX(LEV) = TOTUFLUX(LEV) * FLUXFAC
 !        TOTDFLUX(LEV) = TOTDFLUX(LEV) * FLUXFAC
-!        FNET(LEV) = TOTUFLUX(LEV) - TOTDFLUX(LEV)
+!        FNET(LEV) = (P_TOTUFLUX(LEV) - P_TOTDFLUX(LEV))
 !        L = LEV - 1
 
@@ -824,4 +894,6 @@
 !      HTR(KLEV)   = 0.0
 
+
+
 IF (LHOOK) CALL DR_HOOK('RRTM_RTRN1A_140GP',1,ZHOOK_HANDLE)
 END SUBROUTINE RRTM_RTRN1A_140GP
