C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved.            RAD_ALL.19148 
C                                                                                  RAD_ALL.19149 
C Use, duplication or disclosure of this code is subject to the                    RAD_ALL.19150 
C restrictions as set forth in the contract.                                       RAD_ALL.19151 
C                                                                                  RAD_ALL.19152 
C                Meteorological Office                                             RAD_ALL.19153 
C                London Road                                                       RAD_ALL.19154 
C                BRACKNELL                                                         RAD_ALL.19155 
C                Berkshire UK                                                      RAD_ALL.19156 
C                RG12 2SZ                                                          RAD_ALL.19157 
C                                                                                  RAD_ALL.19158 
C If no contract has been raised with this copy of the code, the use,              RAD_ALL.19159 
C duplication or disclosure of it is strictly prohibited.  Permission              RAD_ALL.19160 
C to do so must first be obtained in writing from the Head of Numerical            RAD_ALL.19161 
C Modelling at the above address.                                                  RAD_ALL.19162 
C ******************************COPYRIGHT******************************            RAD_ALL.19163 
C                                                                                  RAD_ALL.19164 
!+ Subroutine to solve for mixed fluxes scattering without a matrix.               RAD_ALL.19165 
!                                                                                  RAD_ALL.19166 
! Method:                                                                          RAD_ALL.19167 
!       Gaussian elimination in an upward direction is employed to                 RAD_ALL.19168 
!       determine effective albedos for lower levels of the atmosphere.            RAD_ALL.19169 
!       This allows a downward pass of back-substitution to be carried             RAD_ALL.19170 
!       out to determine the upward and downward fluxes.                           RAD_ALL.19171 
!                                                                                  RAD_ALL.19172 
! Current Owner of Code: J. M. Edwards                                             RAD_ALL.19173 
!                                                                                  RAD_ALL.19174 
! History:                                                                         RAD_ALL.19175 
!       Version         Date                    Comment                            RAD_ALL.19176 
!       4.1             10-04-96                Original Code                      RAD_ALL.19177 
!                                               (J. M. Edwards)                    RAD_ALL.19178 
!                                                                                  RAD_ALL.19179 
! Description of Code:                                                             RAD_ALL.19180 
!   FORTRAN 77  with extensions listed in documentation.                           RAD_ALL.19181 
!                                                                                  RAD_ALL.19182 
!- ---------------------------------------------------------------------           RAD_ALL.19183 
      SUBROUTINE SOLVER_MIX_DIRECT(N_PROFILE, N_LAYER, N_CLOUD_TOP                 RAD_ALL.19184 
     &   , T, R, S_DOWN, S_UP                                                      RAD_ALL.19185 
     &   , T_CLOUD, R_CLOUD, S_DOWN_CLOUD, S_UP_CLOUD                              RAD_ALL.19186 
     &   , V11, V21, V12, V22                                                      RAD_ALL.19187 
     &   , U11, U12, U21, U22                                                      RAD_ALL.19188 
     &   , L_NET                                                                   RAD_ALL.19189 
     &   , FLUX_INC_DOWN                                                           RAD_ALL.19190 
     &   , SOURCE_GROUND_FREE, SOURCE_GROUND_CLOUD, ALBEDO_SURFACE_DIFF            RAD_ALL.19191 
     &   , FLUX_TOTAL                                                              RAD_ALL.19192 
     &   , NPD_PROFILE, NPD_LAYER                                                  RAD_ALL.19193 
     &   )                                                                         RAD_ALL.19194 
!                                                                                  RAD_ALL.19195 
!                                                                                  RAD_ALL.19196 
      IMPLICIT NONE                                                                RAD_ALL.19197 
!                                                                                  RAD_ALL.19198 
!                                                                                  RAD_ALL.19199 
!     SIZES OF DUMMY ARRAYS.                                                       RAD_ALL.19200 
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.19201 
     &     NPD_PROFILE                                                             RAD_ALL.19202 
!             MAXIMUM NUMBER OF PROFILES                                           RAD_ALL.19203 
     &   , NPD_LAYER                                                               RAD_ALL.19204 
!             MAXIMUM NUMBER OF LAYERS                                             RAD_ALL.19205 
!                                                                                  RAD_ALL.19206 
!                                                                                  RAD_ALL.19207 
!     DUMMY ARGUMENTS.                                                             RAD_ALL.19208 
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.19209 
     &     N_PROFILE                                                               RAD_ALL.19210 
!             NUMBER OF PROFILES                                                   RAD_ALL.19211 
     &   , N_LAYER                                                                 RAD_ALL.19212 
!             NUMBER OF LAYERS                                                     RAD_ALL.19213 
     &   , N_CLOUD_TOP                                                             RAD_ALL.19214 
!             TOPMOST CLOUDY LAYER                                                 RAD_ALL.19215 
      LOGICAL   !, INTENT(IN)                                                      RAD_ALL.19216 
     &     L_NET                                                                   RAD_ALL.19217 
!             FLAG FOR CALCULATION OF NET FLUXES                                   RAD_ALL.19218 
      REAL      !, INTENT(IN)                                                      RAD_ALL.19219 
     &     T(NPD_PROFILE, NPD_LAYER)                                               RAD_ALL.19220 
!             CLEAR-SKY TRANSMISSION                                               RAD_ALL.19221 
     &   , R(NPD_PROFILE, NPD_LAYER)                                               RAD_ALL.19222 
!             CLEAR-SKY REFLECTION                                                 RAD_ALL.19223 
     &   , S_DOWN(NPD_PROFILE, NPD_LAYER)                                          RAD_ALL.19224 
!             CLEAR-SKY DOWNWARD SOURCE FUNCTION                                   RAD_ALL.19225 
     &   , S_UP(NPD_PROFILE, NPD_LAYER)                                            RAD_ALL.19226 
!             CLEAR-SKY UPWARD SOURCE FUNCTION                                     RAD_ALL.19227 
     &   , T_CLOUD(NPD_PROFILE, NPD_LAYER)                                         RAD_ALL.19228 
!             CLOUDY TRANSMISSION                                                  RAD_ALL.19229 
     &   , R_CLOUD(NPD_PROFILE, NPD_LAYER)                                         RAD_ALL.19230 
!             CLOUDY REFLECTION                                                    RAD_ALL.19231 
     &   , S_DOWN_CLOUD(NPD_PROFILE, NPD_LAYER)                                    RAD_ALL.19232 
!             DOWNWARD CLOUDY SOURCE FUNCTION                                      RAD_ALL.19233 
     &   , S_UP_CLOUD(NPD_PROFILE, NPD_LAYER)                                      RAD_ALL.19234 
!             UPWARD CLOUDY SOURCE FUNCTION                                        RAD_ALL.19235 
      REAL      !, INTENT(IN)                                                      RAD_ALL.19236 
     &     V11(NPD_PROFILE, 0: NPD_LAYER)                                          RAD_ALL.19237 
!             ENERGY TRANSFER COEFFICIENT                                          RAD_ALL.19238 
     &   , V21(NPD_PROFILE, 0: NPD_LAYER)                                          RAD_ALL.19239 
!             ENERGY TRANSFER COEFFICIENT                                          RAD_ALL.19240 
     &   , V12(NPD_PROFILE, 0: NPD_LAYER)                                          RAD_ALL.19241 
!             ENERGY TRANSFER COEFFICIENT                                          RAD_ALL.19242 
     &   , V22(NPD_PROFILE, 0: NPD_LAYER)                                          RAD_ALL.19243 
!             ENERGY TRANSFER COEFFICIENT                                          RAD_ALL.19244 
     &   , U11(NPD_PROFILE, 0: NPD_LAYER)                                          RAD_ALL.19245 
!             ENERGY TRANSFER COEFFICIENT                                          RAD_ALL.19246 
     &   , U12(NPD_PROFILE, 0: NPD_LAYER)                                          RAD_ALL.19247 
!             ENERGY TRANSFER COEFFICIENT                                          RAD_ALL.19248 
     &   , U21(NPD_PROFILE, 0: NPD_LAYER)                                          RAD_ALL.19249 
!             ENERGY TRANSFER COEFFICIENT                                          RAD_ALL.19250 
     &   , U22(NPD_PROFILE, 0: NPD_LAYER)                                          RAD_ALL.19251 
!             ENERGY TRANSFER COEFFICIENT                                          RAD_ALL.19252 
      REAL      !, INTENT(IN)                                                      RAD_ALL.19253 
     &     FLUX_INC_DOWN(NPD_PROFILE)                                              RAD_ALL.19254 
!             INCIDENT FLUX                                                        RAD_ALL.19255 
     &   , SOURCE_GROUND_FREE(NPD_PROFILE)                                         RAD_ALL.19256 
!             SOURCE FROM GROUND (CLEAR SKY)                                       RAD_ALL.19257 
     &   , SOURCE_GROUND_CLOUD(NPD_PROFILE)                                        RAD_ALL.19258 
!             SOURCE FROM GROUND (CLOUDY REGION)                                   RAD_ALL.19259 
     &   , ALBEDO_SURFACE_DIFF(NPD_PROFILE)                                        RAD_ALL.19260 
!             DIFFUSE ALBEDO                                                       RAD_ALL.19261 
      REAL      !, INTENT(OUT)                                                     RAD_ALL.19262 
     &     FLUX_TOTAL(NPD_PROFILE, 2*NPD_LAYER+2)                                  RAD_ALL.19263 
!             TOTAL FLUX                                                           RAD_ALL.19264 
!                                                                                  RAD_ALL.19265 
!     LOCAL VARIABLES.                                                             RAD_ALL.19266 
      INTEGER                                                                      RAD_ALL.19267 
     &     I                                                                       RAD_ALL.19268 
!             LOOP VARIABLE                                                        RAD_ALL.19269 
     &   , L                                                                       RAD_ALL.19270 
!             LOOP VARIABLE                                                        RAD_ALL.19271 
!                                                                                  RAD_ALL.19272 
!     EFFECTIVE COUPLING ALBEDOS AND SOURCE FUNCTIONS:                             RAD_ALL.19273 
      REAL                                                                         RAD_ALL.19274 
     &     ALPHA11(NPD_PROFILE, NPD_LAYER+1)                                       RAD_ALL.19275 
     &   , ALPHA22(NPD_PROFILE, NPD_LAYER+1)                                       RAD_ALL.19276 
     &   , ALPHA21(NPD_PROFILE, NPD_LAYER+1)                                       RAD_ALL.19277 
     &   , ALPHA12(NPD_PROFILE, NPD_LAYER+1)                                       RAD_ALL.19278 
     &   , G1(NPD_PROFILE, NPD_LAYER+1)                                            RAD_ALL.19279 
     &   , G2(NPD_PROFILE, NPD_LAYER+1)                                            RAD_ALL.19280 
!     TERMS FOR DOWNWARD PROPAGATION:                                              RAD_ALL.19281 
      REAL                                                                         RAD_ALL.19282 
     &     GAMMA11(NPD_PROFILE, NPD_LAYER)                                         RAD_ALL.19283 
     &   , GAMMA12(NPD_PROFILE, NPD_LAYER)                                         RAD_ALL.19284 
     &   , GAMMA21(NPD_PROFILE, NPD_LAYER)                                         RAD_ALL.19285 
     &   , GAMMA22(NPD_PROFILE, NPD_LAYER)                                         RAD_ALL.19286 
     &   , BETA11_INV(NPD_PROFILE, NPD_LAYER)                                      RAD_ALL.19287 
     &   , BETA21(NPD_PROFILE, NPD_LAYER)                                          RAD_ALL.19288 
     &   , BETA22_INV(NPD_PROFILE, NPD_LAYER)                                      RAD_ALL.19289 
     &   , H1(NPD_PROFILE, NPD_LAYER)                                              RAD_ALL.19290 
     &   , H2(NPD_PROFILE, NPD_LAYER)                                              RAD_ALL.19291 
!                                                                                  RAD_ALL.19292 
!     AUXILAIRY NUMERICAL VARIABLES REQUIRED ONLY IN THE CURRENT LAYER:            RAD_ALL.19293 
      REAL                                                                         RAD_ALL.19294 
     &     THETA11                                                                 RAD_ALL.19295 
     &   , THETA12                                                                 RAD_ALL.19296 
     &   , THETA21                                                                 RAD_ALL.19297 
     &   , THETA22                                                                 RAD_ALL.19298 
     &   , LAMBDA                                                                  RAD_ALL.19299 
     &   , LAMBDA_BAR                                                              RAD_ALL.19300 
!                                                                                  RAD_ALL.19301 
!     TEMPORARY FLUXES                                                             RAD_ALL.19302 
      REAL                                                                         RAD_ALL.19303 
     &     FLUX_DOWN_1(NPD_PROFILE, 0: NPD_LAYER)                                  RAD_ALL.19304 
!             DOWNWARD FLUXES OUTSIDE CLOUDS JUST BELOW I'TH LEVEL                 RAD_ALL.19305 
     &   , FLUX_DOWN_2(NPD_PROFILE, 0: NPD_LAYER)                                  RAD_ALL.19306 
!             DOWNWARD FLUXES INSIDE CLOUDS JUST BELOW I'TH LEVEL                  RAD_ALL.19307 
     &   , FLUX_UP_1(NPD_PROFILE, 0: NPD_LAYER)                                    RAD_ALL.19308 
!             UPWARD FLUXES OUTSIDE CLOUDS JUST ABOVE I'TH LEVEL                   RAD_ALL.19309 
     &   , FLUX_UP_2(NPD_PROFILE, 0: NPD_LAYER)                                    RAD_ALL.19310 
!             UPWARD FLUXES INSIDE CLOUDS JUST ABOVE I'TH LEVEL                    RAD_ALL.19311 
!                                                                                  RAD_ALL.19312 
!                                                                                  RAD_ALL.19313 
!                                                                                  RAD_ALL.19314 
!     INITIALIZE AT THE BOTTOM OF THE COLUMN FOR UPWARD ELIMINATION.               RAD_ALL.19315 
      DO L=1, N_PROFILE                                                            RAD_ALL.19316 
         ALPHA11(L, N_LAYER+1)=ALBEDO_SURFACE_DIFF(L)                              RAD_ALL.19317 
         ALPHA22(L, N_LAYER+1)=ALBEDO_SURFACE_DIFF(L)                              RAD_ALL.19318 
         ALPHA21(L, N_LAYER+1)=0.0E+00                                             RAD_ALL.19319 
         ALPHA12(L, N_LAYER+1)=0.0E+00                                             RAD_ALL.19320 
         G1(L, N_LAYER+1)=SOURCE_GROUND_FREE(L)                                    RAD_ALL.19321 
         G2(L, N_LAYER+1)=SOURCE_GROUND_CLOUD(L)                                   RAD_ALL.19322 
      ENDDO                                                                        RAD_ALL.19323 
!                                                                                  RAD_ALL.19324 
!     UPWARD ELIMINATION THROUGH THE CLOUDY LAYERS.                                RAD_ALL.19325 
      DO I=N_LAYER, N_CLOUD_TOP, -1                                                RAD_ALL.19326 
         DO L=1, N_PROFILE                                                         RAD_ALL.19327 
!                                                                                  RAD_ALL.19328 
            THETA11=ALPHA11(L, I+1)*V11(L, I)+ALPHA12(L, I+1)*V21(L, I)            RAD_ALL.19329 
            THETA12=ALPHA11(L, I+1)*V12(L, I)+ALPHA12(L, I+1)*V22(L, I)            RAD_ALL.19330 
            THETA21=ALPHA21(L, I+1)*V11(L, I)+ALPHA22(L, I+1)*V21(L, I)            RAD_ALL.19331 
            THETA22=ALPHA21(L, I+1)*V12(L, I)+ALPHA22(L, I+1)*V22(L, I)            RAD_ALL.19332 
                                                                                   RAD_ALL.19333 
            BETA21(L, I)=-THETA21*R(L, I)                                          RAD_ALL.19334 
            BETA22_INV(L, I)=1.0E+00/(1.0E+00-THETA22*R_CLOUD(L, I))               RAD_ALL.19335 
            GAMMA21(L, I)=THETA21*T(L, I)                                          RAD_ALL.19336 
            GAMMA22(L, I)=THETA22*T_CLOUD(L, I)                                    RAD_ALL.19337 
            H2(L, I)=G2(L, I+1)+THETA21*S_DOWN(L, I)                               RAD_ALL.19338 
     &         +THETA22*S_DOWN_CLOUD(L, I)                                         RAD_ALL.19339 
                                                                                   RAD_ALL.19340 
            LAMBDA=THETA12*R_CLOUD(L, I)*BETA22_INV(L, I)                          RAD_ALL.19341 
            BETA11_INV(L, I)=1.0E+00                                               RAD_ALL.19342 
     &         /(1.0E+00-THETA11*R(L, I)+LAMBDA*BETA21(L, I))                      RAD_ALL.19343 
            GAMMA11(L, I)=THETA11*T(L, I)+LAMBDA*GAMMA21(L, I)                     RAD_ALL.19344 
            GAMMA12(L, I)=THETA12*T_CLOUD(L, I)+LAMBDA*GAMMA22(L, I)               RAD_ALL.19345 
            H1(L, I)=G1(L, I+1)+THETA11*S_DOWN(L, I)                               RAD_ALL.19346 
     &         +THETA12*S_DOWN_CLOUD(L, I)+LAMBDA*H2(L, I)                         RAD_ALL.19347 
                                                                                   RAD_ALL.19348 
            LAMBDA=U22(L, I-1)*T_CLOUD(L, I)*BETA22_INV(L, I)                      RAD_ALL.19349 
            LAMBDA_BAR=(U21(L, I-1)*T(L, I)+LAMBDA*BETA21(L, I))                   RAD_ALL.19350 
     &         *BETA11_INV(L, I)                                                   RAD_ALL.19351 
            ALPHA21(L, I)=U21(L, I-1)*R(L, I)+LAMBDA*GAMMA21(L, I)                 RAD_ALL.19352 
     &         +LAMBDA_BAR*GAMMA11(L, I)                                           RAD_ALL.19353 
            ALPHA22(L, I)=U22(L, I-1)*R_CLOUD(L, I)                                RAD_ALL.19354 
     &         +LAMBDA*GAMMA22(L, I)+LAMBDA_BAR*GAMMA12(L, I)                      RAD_ALL.19355 
            G2(L, I)=U21(L, I-1)*S_UP(L, I)+U22(L, I-1)*S_UP_CLOUD(L, I)           RAD_ALL.19356 
     &         +LAMBDA*H2(L, I)+LAMBDA_BAR*H1(L, I)                                RAD_ALL.19357 
!                                                                                  RAD_ALL.19358 
            LAMBDA=U12(L, I-1)*T_CLOUD(L, I)*BETA22_INV(L, I)                      RAD_ALL.19359 
            LAMBDA_BAR=(U11(L, I-1)*T(L, I)+LAMBDA*BETA21(L, I))                   RAD_ALL.19360 
     &         *BETA11_INV(L, I)                                                   RAD_ALL.19361 
            ALPHA11(L, I)=U11(L, I-1)*R(L, I)+LAMBDA*GAMMA21(L, I)                 RAD_ALL.19362 
     &         +LAMBDA_BAR*GAMMA11(L, I)                                           RAD_ALL.19363 
            ALPHA12(L, I)=U12(L, I-1)*R_CLOUD(L, I)                                RAD_ALL.19364 
     &         +LAMBDA*GAMMA22(L, I)+LAMBDA_BAR*GAMMA12(L, I)                      RAD_ALL.19365 
            G1(L, I)=U11(L, I-1)*S_UP(L, I)+U12(L, I-1)*S_UP_CLOUD(L, I)           RAD_ALL.19366 
     &         +LAMBDA*H2(L, I)+LAMBDA_BAR*H1(L, I)                                RAD_ALL.19367 
!                                                                                  RAD_ALL.19368 
         ENDDO                                                                     RAD_ALL.19369 
      ENDDO                                                                        RAD_ALL.19370 
!                                                                                  RAD_ALL.19371 
!     THE LAYER ABOVE THE CLOUD: ONLY ONE SET OF ALPHAS IS NOW NEEDED.             RAD_ALL.19372 
!                                                                                  RAD_ALL.19373 
      I=N_CLOUD_TOP-1                                                              RAD_ALL.19374 
      DO L=1, N_PROFILE                                                            RAD_ALL.19375 
!                                                                                  RAD_ALL.19376 
         IF (N_CLOUD_TOP.LT.N_LAYER) THEN                                          RAD_ALL.19377 
!           IF THERE IS NO CLOUD IN THE COLUMN THE V'S WILL NOT BE                 RAD_ALL.19378 
!           ASSIGNED SO AN IF TEST IS REQUIRED.                                    RAD_ALL.19379 
            THETA11=ALPHA11(L, I+1)*V11(L, I)+ALPHA12(L, I+1)*V21(L, I)            RAD_ALL.19380 
         ELSE                                                                      RAD_ALL.19381 
            THETA11=ALPHA11(L, I+1)                                                RAD_ALL.19382 
         ENDIF                                                                     RAD_ALL.19383 
!                                                                                  RAD_ALL.19384 
         BETA11_INV(L, I)=1.0E+00/(1.0E+00-THETA11*R(L, I))                        RAD_ALL.19385 
         GAMMA11(L, I)=THETA11*T(L, I)                                             RAD_ALL.19386 
         H1(L, I)=G1(L, I+1)+THETA11*S_DOWN(L, I)                                  RAD_ALL.19387 
!                                                                                  RAD_ALL.19388 
         LAMBDA=T(L, I)*BETA11_INV(L, I)                                           RAD_ALL.19389 
         ALPHA11(L, I)=R(L, I)+LAMBDA*GAMMA11(L, I)                                RAD_ALL.19390 
         G1(L, I)=S_UP(L, I)+LAMBDA*H1(L, I)                                       RAD_ALL.19391 
!                                                                                  RAD_ALL.19392 
      ENDDO                                                                        RAD_ALL.19393 
!                                                                                  RAD_ALL.19394 
      DO I=N_CLOUD_TOP-2, 1, -1                                                    RAD_ALL.19395 
         DO L=1, N_PROFILE                                                         RAD_ALL.19396 
!                                                                                  RAD_ALL.19397 
            BETA11_INV(L, I)=1.0E+00/(1.0E+00-ALPHA11(L, I+1)*R(L, I))             RAD_ALL.19398 
            GAMMA11(L, I)=ALPHA11(L, I+1)*T(L, I)                                  RAD_ALL.19399 
            H1(L, I)=G1(L, I+1)+ALPHA11(L, I+1)*S_DOWN(L, I)                       RAD_ALL.19400 
!                                                                                  RAD_ALL.19401 
            LAMBDA=T(L, I)*BETA11_INV(L, I)                                        RAD_ALL.19402 
            ALPHA11(L, I)=R(L, I)+LAMBDA*GAMMA11(L, I)                             RAD_ALL.19403 
            G1(L, I)=S_UP(L, I)+LAMBDA*H1(L, I)                                    RAD_ALL.19404 
!                                                                                  RAD_ALL.19405 
         ENDDO                                                                     RAD_ALL.19406 
      ENDDO                                                                        RAD_ALL.19407 
!                                                                                  RAD_ALL.19408 
!                                                                                  RAD_ALL.19409 
!     INITIALIZE FOR DOWNWARD BACK-SUBSTITUTION.                                   RAD_ALL.19410 
      DO L=1, N_PROFILE                                                            RAD_ALL.19411 
         FLUX_TOTAL(L, 2)=FLUX_INC_DOWN(L)                                         RAD_ALL.19412 
         FLUX_TOTAL(L, 1)=ALPHA11(L, 1)*FLUX_TOTAL(L, 2)+G1(L, 1)                  RAD_ALL.19413 
      ENDDO                                                                        RAD_ALL.19414 
!                                                                                  RAD_ALL.19415 
!     SWEEP DOWNWARD THROUGH THE CLEAR-SKY REGION, FINDING THE DOWNWARD            RAD_ALL.19416 
!     FLUX AT THE TOP OF THE LAYER AND THE UPWARD FLUX AT THE BOTTOM.              RAD_ALL.19417 
      DO I=1, N_CLOUD_TOP-1                                                        RAD_ALL.19418 
         DO L=1, N_PROFILE                                                         RAD_ALL.19419 
            FLUX_TOTAL(L, 2*I+1)=(GAMMA11(L, I)*FLUX_TOTAL(L, 2*I)                 RAD_ALL.19420 
     &         +H1(L, I))*BETA11_INV(L, I)                                         RAD_ALL.19421 
            FLUX_TOTAL(L, 2*I+2)=T(L, I)*FLUX_TOTAL(L, 2*I)                        RAD_ALL.19422 
     &         +R(L, I)*FLUX_TOTAL(L, 2*I+1)+S_DOWN(L, I)                          RAD_ALL.19423 
         ENDDO                                                                     RAD_ALL.19424 
      ENDDO                                                                        RAD_ALL.19425 
!                                                                                  RAD_ALL.19426 
!     PASS INTO THE TOP CLOUDY LAYER. USE FLUX_DOWN_[1,2] TO HOLD,                 RAD_ALL.19427 
!     PROVISIONALLY, THE DOWNWARD FLUXES JUST BELOW THE TOP OF THE                 RAD_ALL.19428 
!     LAYER, THEN CALCULATE THE UPWARD FLUXES AT THE BOTTOM AND                    RAD_ALL.19429 
!     FINALLY THE DOWNWARD FLUXES AT THE BOTTOM OF THE LAYER.                      RAD_ALL.19430 
      I=N_CLOUD_TOP                                                                RAD_ALL.19431 
      DO L=1, N_PROFILE                                                            RAD_ALL.19432 
         FLUX_DOWN_1(L, I)=V11(L, I-1)*FLUX_TOTAL(L, 2*I)                          RAD_ALL.19433 
         FLUX_DOWN_2(L, I)=V21(L, I-1)*FLUX_TOTAL(L, 2*I)                          RAD_ALL.19434 
         FLUX_UP_1(L, I)=(GAMMA11(L, I)*FLUX_DOWN_1(L, I)                          RAD_ALL.19435 
     &      +GAMMA12(L, I)*FLUX_DOWN_2(L, I)+H1(L, I))*BETA11_INV(L, I)            RAD_ALL.19436 
         FLUX_UP_2(L, I)=(GAMMA21(L, I)*FLUX_DOWN_1(L, I)                          RAD_ALL.19437 
     &      +GAMMA22(L, I)*FLUX_DOWN_2(L, I)+H2(L, I)                              RAD_ALL.19438 
     &      -BETA21(L, I)*FLUX_UP_1(L, I))*BETA22_INV(L, I)                        RAD_ALL.19439 
         FLUX_DOWN_1(L, I)=T(L, I)*FLUX_DOWN_1(L, I)                               RAD_ALL.19440 
     &      +R(L, I)*FLUX_UP_1(L, I)+S_DOWN(L, I)                                  RAD_ALL.19441 
         FLUX_DOWN_2(L, I)=T_CLOUD(L, I)*FLUX_DOWN_2(L, I)                         RAD_ALL.19442 
     &      +R_CLOUD(L, I)*FLUX_UP_2(L, I)+S_DOWN_CLOUD(L, I)                      RAD_ALL.19443 
      ENDDO                                                                        RAD_ALL.19444 
!                                                                                  RAD_ALL.19445 
!     THE MAIN LOOP OF BACK-SUBSTITUTION. THE PROVISIONAL USE OF THE               RAD_ALL.19446 
!     DOWNWARD FLUXES IS AS ABOVE.                                                 RAD_ALL.19447 
      DO I=N_CLOUD_TOP+1, N_LAYER                                                  RAD_ALL.19448 
         DO L=1, N_PROFILE                                                         RAD_ALL.19449 
            FLUX_DOWN_1(L, I)=V11(L, I-1)*FLUX_DOWN_1(L, I-1)                      RAD_ALL.19450 
     &         +V12(L, I-1)*FLUX_DOWN_2(L, I-1)                                    RAD_ALL.19451 
            FLUX_DOWN_2(L, I)=V21(L, I-1)*FLUX_DOWN_1(L, I-1)                      RAD_ALL.19452 
     &         +V22(L, I-1)*FLUX_DOWN_2(L, I-1)                                    RAD_ALL.19453 
            FLUX_UP_1(L, I)=(GAMMA11(L, I)*FLUX_DOWN_1(L, I)                       RAD_ALL.19454 
     &         +GAMMA12(L, I)*FLUX_DOWN_2(L, I)+H1(L, I))                          RAD_ALL.19455 
     &         *BETA11_INV(L, I)                                                   RAD_ALL.19456 
            FLUX_UP_2(L, I)=(GAMMA21(L, I)*FLUX_DOWN_1(L, I)                       RAD_ALL.19457 
     &         +GAMMA22(L, I)*FLUX_DOWN_2(L, I)                                    RAD_ALL.19458 
     &         -BETA21(L, I)*FLUX_UP_1(L, I)+H2(L, I))                             RAD_ALL.19459 
     &         *BETA22_INV(L, I)                                                   RAD_ALL.19460 
            FLUX_DOWN_1(L, I)=T(L, I)*FLUX_DOWN_1(L, I)                            RAD_ALL.19461 
     &         +R(L, I)*FLUX_UP_1(L, I)+S_DOWN(L, I)                               RAD_ALL.19462 
            FLUX_DOWN_2(L, I)=T_CLOUD(L, I)*FLUX_DOWN_2(L, I)                      RAD_ALL.19463 
     &         +R_CLOUD(L, I)*FLUX_UP_2(L, I)+S_DOWN_CLOUD(L, I)                   RAD_ALL.19464 
         ENDDO                                                                     RAD_ALL.19465 
      ENDDO                                                                        RAD_ALL.19466 
!                                                                                  RAD_ALL.19467 
!                                                                                  RAD_ALL.19468 
!     CALCULATE THE OVERALL FLUX.                                                  RAD_ALL.19469 
      DO I=N_CLOUD_TOP, N_LAYER                                                    RAD_ALL.19470 
         DO L=1, N_PROFILE                                                         RAD_ALL.19471 
            FLUX_TOTAL(L, 2*I+1)=FLUX_UP_1(L, I)+FLUX_UP_2(L, I)                   RAD_ALL.19472 
            FLUX_TOTAL(L, 2*I+2)=FLUX_DOWN_1(L, I)+FLUX_DOWN_2(L, I)               RAD_ALL.19473 
         ENDDO                                                                     RAD_ALL.19474 
      ENDDO                                                                        RAD_ALL.19475 
!                                                                                  RAD_ALL.19476 
!     REDUCE TO NET FLUXES IF REQUIRED.                                            RAD_ALL.19477 
      IF (L_NET) THEN                                                              RAD_ALL.19478 
         DO I=0, N_LAYER                                                           RAD_ALL.19479 
            DO L=1, N_PROFILE                                                      RAD_ALL.19480 
               FLUX_TOTAL(L, I+1)                                                  RAD_ALL.19481 
     &            =FLUX_TOTAL(L, 2*I+2)-FLUX_TOTAL(L, 2*I+1)                       RAD_ALL.19482 
            ENDDO                                                                  RAD_ALL.19483 
         ENDDO                                                                     RAD_ALL.19484 
      ENDIF                                                                        RAD_ALL.19485 
!                                                                                  RAD_ALL.19486 
!                                                                                  RAD_ALL.19487 
!                                                                                  RAD_ALL.19488 
      RETURN                                                                       RAD_ALL.19489 
      END 
