C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved.            RAD_ALL.23512 
C                                                                                  RAD_ALL.23513 
C Use, duplication or disclosure of this code is subject to the                    RAD_ALL.23514 
C restrictions as set forth in the contract.                                       RAD_ALL.23515 
C                                                                                  RAD_ALL.23516 
C                Meteorological Office                                             RAD_ALL.23517 
C                London Road                                                       RAD_ALL.23518 
C                BRACKNELL                                                         RAD_ALL.23519 
C                Berkshire UK                                                      RAD_ALL.23520 
C                RG12 2SZ                                                          RAD_ALL.23521 
C                                                                                  RAD_ALL.23522 
C If no contract has been raised with this copy of the code, the use,              RAD_ALL.23523 
C duplication or disclosure of it is strictly prohibited.  Permission              RAD_ALL.23524 
C to do so must first be obtained in writing from the Head of Numerical            RAD_ALL.23525 
C Modelling at the above address.                                                  RAD_ALL.23526 
C ******************************COPYRIGHT******************************            RAD_ALL.23527 
C                                                                                  RAD_ALL.23528 
!+ Subroutine to calculate total upward and downward fluxes.                       RAD_ALL.23529 
!                                                                                  RAD_ALL.23530 
! Method:                                                                          RAD_ALL.23531 
!       The equations for the clear and cloudy upward and downward                 RAD_ALL.23532 
!       fluxes can be re-arranged, as discussed in a separate document,            RAD_ALL.23533 
!       to give equations for the total fluxes. The equations for                  RAD_ALL.23534 
!       these fluxes are set.                                                      RAD_ALL.23535 
!                                                                                  RAD_ALL.23536 
! Current Owner of Code: J. M. Edwards                                             RAD_ALL.23537 
!                                                                                  RAD_ALL.23538 
! History:                                                                         RAD_ALL.23539 
!       Version         Date                    Comment                            RAD_ALL.23540 
!       4.0             27-07-95                Original Code                      RAD_ALL.23541 
!                                               (J. M. Edwards)                    RAD_ALL.23542 
!                                                                                  RAD_ALL.23543 
! Description of Code:                                                             RAD_ALL.23544 
!   FORTRAN 77  with extensions listed in documentation.                           RAD_ALL.23545 
!                                                                                  RAD_ALL.23546 
!- ---------------------------------------------------------------------           RAD_ALL.23547 
      SUBROUTINE MIX_SUM_MATRIX(N_PROFILE, N_LAYER, N_CLOUD_TOP                    RAD_ALL.23548 
     &   , T_FREE, R_FREE, T_CLOUD, R_CLOUD                                        RAD_ALL.23549 
     &   , S_UP_FREE, S_DOWN_FREE, S_UP_CLOUD, S_DOWN_CLOUD                        RAD_ALL.23550 
     &   , ALBEDO_SURFACE_DIFF, ALBEDO_SURFACE_DIR, SOURCE_GROUND                  RAD_ALL.23551 
     &   , FLUX_DIRECT_GROUND                                                      RAD_ALL.23552 
     &   , FLUX_INC_DOWN                                                           RAD_ALL.23553 
     &   , N_FREE_PROFILE, I_FREE_PROFILE                                          RAD_ALL.23554 
     &   , N_CLOUD_PROFILE, I_CLOUD_PROFILE                                        RAD_ALL.23555 
     &   , GM_FM, GM_FP, BT_FM, BT_FP                                              RAD_ALL.23556 
     &   , P, V                                                                    RAD_ALL.23557 
     &   , NPD_PROFILE, NPD_LAYER                                                  RAD_ALL.23558 
     &   )                                                                         RAD_ALL.23559 
!                                                                                  RAD_ALL.23560 
!                                                                                  RAD_ALL.23561 
      IMPLICIT NONE                                                                RAD_ALL.23562 
!                                                                                  RAD_ALL.23563 
!                                                                                  RAD_ALL.23564 
!     SIZES OF DUMMY ARRAYS.                                                       RAD_ALL.23565 
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.23566 
     &     NPD_PROFILE                                                             RAD_ALL.23567 
!             NUMBER OF PROFILES                                                   RAD_ALL.23568 
     &   , NPD_LAYER                                                               RAD_ALL.23569 
!             MAXIMUM NUMBER OF LAYERS                                             RAD_ALL.23570 
!                                                                                  RAD_ALL.23571 
!     INCLUDE COMDECKS                                                             RAD_ALL.23572 
!     ------------------------------------------------------------------           PRMCH3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       PRMCH3A.3     
!                                                                                  PRMCH3A.4     
!     MODULE FOR SETTING MACHINE PRECISION.                                        PRMCH3A.5     
!                                                                                  PRMCH3A.6     
      REAL                                                                         PRMCH3A.7     
     &     TOL_MACHINE                                                             PRMCH3A.8     
!             MACHINE TOLERANCE                                                    PRMCH3A.9     
     &   , SQRT_TOL_MACHINE                                                        PRMCH3A.10    
!             SQRT OF MACHINE TOLERANCE                                            PRMCH3A.11    
!                                                                                  PRMCH3A.12    
!                                                                                  PRMCH3A.13    
!     THE PRECISION SHOULD BE ABOUT 2/2^(SIZE OF SIGNIFICAND)                      PRMCH3A.14    
!                                                                                  PRMCH3A.15    
!     THE IEEE-FORMAT USES 53 BITS FOR THE SIGNIFICAND                             PRMCH3A.16    
!     IN DOUBLE PRECISION                                                          PRMCH3A.17    
!                                                                                  PRMCH3A.18    
!     THE CRAY FORMAT USES 47 BITS IN SINGLE PRECISION.                            PRMCH3A.19    
!                                                                                  PRMCH3A.20    
      PARAMETER(                                                                   PRMCH3A.21    
     &     TOL_MACHINE=1.42E-14                                                    PRMCH3A.22    
     &   , SQRT_TOL_MACHINE=1.19E-7                                                PRMCH3A.23    
     &   )                                                                         PRMCH3A.24    
!                                                                                  PRMCH3A.25    
!     ------------------------------------------------------------------           PRMCH3A.26    
!     ------------------------------------------------------------------           PRECSN3A.2     
!     COMDECK FOR TWO-STREAM RADIATION CODE.                                       PRECSN3A.3     
!                                                                                  PRECSN3A.4     
!     MODULE FOR SETTING MACHINE-DEPENDENT TOLERANCES.                             PRECSN3A.5     
!     (THE COMDECK PRMCH3A MUST ALWAYS BE INCLUDED BEFORE THIS COMDECK.)           PRECSN3A.6     
!                                                                                  PRECSN3A.7     
      REAL                                                                         PRECSN3A.8     
     &     TOL_DIV                                                                 PRECSN3A.9     
!             TOLERANCE FOR DIVISION                                               PRECSN3A.10    
     &   , TOL_TEST                                                                PRECSN3A.11    
!             TOLERANCE FOR TESTING EQUALITY                                       PRECSN3A.12    
!                                                                                  PRECSN3A.13    
      PARAMETER(                                                                   PRECSN3A.14    
     &     TOL_DIV=3.2E+01*TOL_MACHINE                                             PRECSN3A.15    
     &   , TOL_TEST=1.6E+01*TOL_MACHINE                                            PRECSN3A.16    
     &   )                                                                         PRECSN3A.17    
!                                                                                  PRECSN3A.18    
!     ------------------------------------------------------------------           PRECSN3A.19    
!                                                                                  RAD_ALL.23575 
!     DUMMY VARIABLES                                                              RAD_ALL.23576 
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.23577 
     &     N_PROFILE                                                               RAD_ALL.23578 
!             NUMBER OF PROFILES                                                   RAD_ALL.23579 
     &   , N_LAYER                                                                 RAD_ALL.23580 
!             NUMBER OF LAYERS                                                     RAD_ALL.23581 
     &   , N_CLOUD_TOP                                                             RAD_ALL.23582 
!             TOP LCOUDY LAYER                                                     RAD_ALL.23583 
     &   , N_FREE_PROFILE(NPD_LAYER)                                               RAD_ALL.23584 
!             NUMBER OF FREE PROFILES                                              RAD_ALL.23585 
     &   , I_FREE_PROFILE(NPD_PROFILE, NPD_LAYER)                                  RAD_ALL.23586 
!             INDICES OF FREE PROFILES                                             RAD_ALL.23587 
     &   , N_CLOUD_PROFILE(NPD_LAYER)                                              RAD_ALL.23588 
!             NUMBER OF CLOUDY PROFILES                                            RAD_ALL.23589 
     &   , I_CLOUD_PROFILE(NPD_PROFILE, NPD_LAYER)                                 RAD_ALL.23590 
!             INDICES OF CLOUDY PROFILES                                           RAD_ALL.23591 
!                                                                                  RAD_ALL.23592 
      REAL      !, INTENT(IN)                                                      RAD_ALL.23593 
     &     T_CLOUD(NPD_PROFILE, NPD_LAYER)                                         RAD_ALL.23594 
!             CLOUDY TRANSMITTANCE                                                 RAD_ALL.23595 
     &   , R_CLOUD(NPD_PROFILE, NPD_LAYER)                                         RAD_ALL.23596 
!             CLOUDY REFLECTANCE                                                   RAD_ALL.23597 
     &   , T_FREE(NPD_PROFILE, NPD_LAYER)                                          RAD_ALL.23598 
!             CLOUD-FREE TRANSMITTANCE                                             RAD_ALL.23599 
     &   , R_FREE(NPD_PROFILE, NPD_LAYER)                                          RAD_ALL.23600 
!             CLOUD-FREE REFLEXTANCE                                               RAD_ALL.23601 
     &   , S_UP_CLOUD(NPD_PROFILE, NPD_LAYER)                                      RAD_ALL.23602 
!             CLOUDY UPWARD SOURCE FUNCTION                                        RAD_ALL.23603 
     &   , S_UP_FREE(NPD_PROFILE, NPD_LAYER)                                       RAD_ALL.23604 
!             CLOUD-FREE UPWARD SOURCE FUNCTION                                    RAD_ALL.23605 
     &   , S_DOWN_CLOUD(NPD_PROFILE, NPD_LAYER)                                    RAD_ALL.23606 
!             CLOUDY DOWNWARD SOURCE FUNCTION                                      RAD_ALL.23607 
     &   , S_DOWN_FREE(NPD_PROFILE, NPD_LAYER)                                     RAD_ALL.23608 
!             CLOUD-FREE DOWNWARD SOURCE FUNCTION                                  RAD_ALL.23609 
      REAL      !, INTENT(IN)                                                      RAD_ALL.23610 
     &     ALBEDO_SURFACE_DIR(NPD_PROFILE)                                         RAD_ALL.23611 
!             DIRECT SURFACE RELFECTANCE                                           RAD_ALL.23612 
     &   , ALBEDO_SURFACE_DIFF(NPD_PROFILE)                                        RAD_ALL.23613 
!             DIFFUSE SURFACE REFLECTANCE                                          RAD_ALL.23614 
     &   , SOURCE_GROUND(NPD_PROFILE)                                              RAD_ALL.23615 
!             GROUND SOURCE FUNCTION                                               RAD_ALL.23616 
     &   , BT_FM(NPD_PROFILE, 0: NPD_LAYER)                                        RAD_ALL.23617 
!             ENERGY TRANSFER FUNCTION                                             RAD_ALL.23618 
     &   , BT_FP(NPD_PROFILE, 0: NPD_LAYER)                                        RAD_ALL.23619 
!             ENERGY TRANSFER FUNCTION                                             RAD_ALL.23620 
     &   , GM_FM(NPD_PROFILE, 0: NPD_LAYER)                                        RAD_ALL.23621 
!             ENERGY TRANSFER FUNCTION                                             RAD_ALL.23622 
     &   , GM_FP(NPD_PROFILE, 0: NPD_LAYER)                                        RAD_ALL.23623 
!             ENERGY TRANSFER FUNCTION                                             RAD_ALL.23624 
     &   , FLUX_DIRECT_GROUND(NPD_PROFILE)                                         RAD_ALL.23625 
!             DIRECT FLUX AT GROUND                                                RAD_ALL.23626 
     &   , FLUX_INC_DOWN(NPD_PROFILE)                                              RAD_ALL.23627 
!             DOWNWARD INCIDENT FLUX                                               RAD_ALL.23628 
      REAL      !, INTENT(OUT)                                                     RAD_ALL.23629 
     &     P(NPD_PROFILE, 5, 2*NPD_LAYER+2)                                        RAD_ALL.23630 
!             BANDED MATRIX OF EQUATIONS                                           RAD_ALL.23631 
     &   , V(NPD_PROFILE, 2*NPD_LAYER+2)                                           RAD_ALL.23632 
!             RIGHT-HAND SIDES OF EQUATIONS                                        RAD_ALL.23633 
!                                                                                  RAD_ALL.23634 
!     LOCAL VARIABLES.                                                             RAD_ALL.23635 
      INTEGER                                                                      RAD_ALL.23636 
     &     L                                                                       RAD_ALL.23637 
!             LOOP VARIABLE                                                        RAD_ALL.23638 
     &   , I                                                                       RAD_ALL.23639 
!             LOOP VARIABLE                                                        RAD_ALL.23640 
     &   , LL                                                                      RAD_ALL.23641 
!             LOOP VARIABLE                                                        RAD_ALL.23642 
      REAL                                                                         RAD_ALL.23643 
     &     DET(NPD_PROFILE, 0: NPD_LAYER)                                          RAD_ALL.23644 
!             DETERMINANTS FOR DIFF. EQNS.                                         RAD_ALL.23645 
     &   , DEL_M_MM(NPD_PROFILE, 0: NPD_LAYER)                                     RAD_ALL.23646 
!             COEFFICIENTS FOR DIFFERENCE EQNS.                                    RAD_ALL.23647 
     &   , DEL_M_0M(NPD_PROFILE, 0: NPD_LAYER)                                     RAD_ALL.23648 
!             COEFFICIENTS FOR DIFFERENCE EQNS.                                    RAD_ALL.23649 
     &   , DEL_M_PP(NPD_PROFILE, 0: NPD_LAYER)                                     RAD_ALL.23650 
!             COEFFICIENTS FOR DIFFERENCE EQNS.                                    RAD_ALL.23651 
     &   , DEL_M_2P(NPD_PROFILE, 0: NPD_LAYER)                                     RAD_ALL.23652 
!             COEFFICIENTS FOR DIFFERENCE EQNS.                                    RAD_ALL.23653 
     &   , DEL_P_MM(NPD_PROFILE, 0: NPD_LAYER)                                     RAD_ALL.23654 
!             COEFFICIENTS FOR DIFFERENCE EQNS.                                    RAD_ALL.23655 
     &   , DEL_P_0M(NPD_PROFILE, 0: NPD_LAYER)                                     RAD_ALL.23656 
!             COEFFICIENTS FOR DIFFERENCE EQNS.                                    RAD_ALL.23657 
     &   , DEL_P_PP(NPD_PROFILE, 0: NPD_LAYER)                                     RAD_ALL.23658 
!             COEFFICIENTS FOR DIFFERENCE EQNS.                                    RAD_ALL.23659 
     &   , DEL_P_2P(NPD_PROFILE, 0: NPD_LAYER)                                     RAD_ALL.23660 
!             COEFFICIENTS FOR DIFFERENCE EQNS.                                    RAD_ALL.23661 
     &   , KSI_M(NPD_PROFILE, 0: NPD_LAYER)                                        RAD_ALL.23662 
!             DIFFERENCE SOURCE TERMS                                              RAD_ALL.23663 
     &   , KSI_P(NPD_PROFILE, 0: NPD_LAYER)                                        RAD_ALL.23664 
!             DIFFERENCE SOURCE TERMS                                              RAD_ALL.23665 
      REAL                                                                         RAD_ALL.23666 
     &     ETA_M_MM(NPD_PROFILE)                                                   RAD_ALL.23667 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23668 
     &   , ETA_M_0M(NPD_PROFILE)                                                   RAD_ALL.23669 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23670 
     &   , ETA_M_PP(NPD_PROFILE)                                                   RAD_ALL.23671 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23672 
     &   , ETA_P_0M(NPD_PROFILE)                                                   RAD_ALL.23673 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23674 
     &   , ETA_P_PP(NPD_PROFILE)                                                   RAD_ALL.23675 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23676 
     &   , ETA_P_2P(NPD_PROFILE)                                                   RAD_ALL.23677 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23678 
     &   , DELTA_M_M(NPD_PROFILE)                                                  RAD_ALL.23679 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23680 
     &   , DELTA_M_P(NPD_PROFILE)                                                  RAD_ALL.23681 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23682 
     &   , DELTA_P_M(NPD_PROFILE)                                                  RAD_ALL.23683 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23684 
     &   , DELTA_P_P(NPD_PROFILE)                                                  RAD_ALL.23685 
!             COEFFICIENT IN DIFFERENCE EQN.                                       RAD_ALL.23686 
     &   , SIGMA_M(NPD_PROFILE)                                                    RAD_ALL.23687 
!             SOURCE TERM IN DIFFERENCE EQN.                                       RAD_ALL.23688 
     &   , SIGMA_P(NPD_PROFILE)                                                    RAD_ALL.23689 
!             SOURCE TERM IN DIFFERENCE EQN.                                       RAD_ALL.23690 
      REAL                                                                         RAD_ALL.23691 
     &     H_M_MM                                                                  RAD_ALL.23692 
!             COEFFICIENT IN SUMMED EQUATIONS                                      RAD_ALL.23693 
     &   , H_M_PP                                                                  RAD_ALL.23694 
!             COEFFICIENT IN SUMMED EQUATIONS                                      RAD_ALL.23695 
     &   , H_P_MM                                                                  RAD_ALL.23696 
!             COEFFICIENT IN SUMMED EQUATIONS                                      RAD_ALL.23697 
     &   , H_P_PP                                                                  RAD_ALL.23698 
!             COEFFICIENT IN SUMMED EQUATIONS                                      RAD_ALL.23699 
     &   , D_M_MM                                                                  RAD_ALL.23700 
!             COEFFICIENT IN SUMMED EQUATIONS                                      RAD_ALL.23701 
     &   , D_M_PP                                                                  RAD_ALL.23702 
!             COEFFICIENT IN SUMMED EQUATIONS                                      RAD_ALL.23703 
     &   , D_P_MM                                                                  RAD_ALL.23704 
!             COEFFICIENT IN SUMMED EQUATIONS                                      RAD_ALL.23705 
     &   , D_P_PP                                                                  RAD_ALL.23706 
!             COEFFICIENT IN SUMMED EQUATIONS                                      RAD_ALL.23707 
     &   , S_M                                                                     RAD_ALL.23708 
!             SOURCE TERM IN SUMMED EQNS.                                          RAD_ALL.23709 
     &   , S_P                                                                     RAD_ALL.23710 
!             SOURCE TERM IN SUMMED EQNS.                                          RAD_ALL.23711 
      REAL                                                                         RAD_ALL.23712 
     &     U_M_M2M                                                                 RAD_ALL.23713 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23714 
     &   , U_M_MM                                                                  RAD_ALL.23715 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23716 
     &   , U_M_0M                                                                  RAD_ALL.23717 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23718 
     &   , U_M_0P                                                                  RAD_ALL.23719 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23720 
     &   , U_M_PP                                                                  RAD_ALL.23721 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23722 
     &   , U_M_2P                                                                  RAD_ALL.23723 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23724 
     &   , U_P_M2M                                                                 RAD_ALL.23725 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23726 
     &   , U_P_MM                                                                  RAD_ALL.23727 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23728 
     &   , U_P_0M                                                                  RAD_ALL.23729 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23730 
     &   , U_P_0P                                                                  RAD_ALL.23731 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23732 
     &   , U_P_PP                                                                  RAD_ALL.23733 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23734 
     &   , U_P_2P                                                                  RAD_ALL.23735 
!             COEFFICIENT IN HEPTADIAGONAL EQN.                                    RAD_ALL.23736 
     &   , Q_M                                                                     RAD_ALL.23737 
!             SOURCE TERM IN HEPTADIAGONAL EQN.                                    RAD_ALL.23738 
     &   , Q_P                                                                     RAD_ALL.23739 
!             SOURCE TERM IN HEPTADIAGONAL EQN.                                    RAD_ALL.23740 
      REAL                                                                         RAD_ALL.23741 
     &     DIFF_T(NPD_PROFILE, NPD_LAYER)                                          RAD_ALL.23742 
!             DIFFERENCES IN TRANSMISSION                                          RAD_ALL.23743 
     &   , DIFF_R(NPD_PROFILE, NPD_LAYER)                                          RAD_ALL.23744 
!             DIFFERENCES IN REFLECTION                                            RAD_ALL.23745 
     &   , FACTOR(NPD_PROFILE, NPD_LAYER)                                          RAD_ALL.23746 
!             FACTOR IN ELIMINATING EQUATIONS                                      RAD_ALL.23747 
!                                                                                  RAD_ALL.23748 
!                                                                                  RAD_ALL.23749 
!     PRECALCULATE ARRAYS FOR ELIMINATION AND PERTURB SPECIAL CASES                RAD_ALL.23750 
!     AWAY FROM SINGULARITIES.                                                     RAD_ALL.23751 
      DO I=N_CLOUD_TOP, N_LAYER                                                    RAD_ALL.23752 
         DO LL=1, N_CLOUD_PROFILE(I)                                               RAD_ALL.23753 
            L=I_CLOUD_PROFILE(LL, I)                                               RAD_ALL.23754 
            DIFF_T(L, I)=T_FREE(L, I)-T_CLOUD(L, I)                                RAD_ALL.23755 
            IF (DIFF_T(L, I).LT.TOL_DIV*T_FREE(L, I)) THEN                         RAD_ALL.23756 
               T_CLOUD(L, I)=(1.0E+00-TOL_DIV)*T_CLOUD(L, I)                       RAD_ALL.23757 
               DIFF_T(L, I)=T_FREE(L, I)-T_CLOUD(L, I)                             RAD_ALL.23758 
            ENDIF                                                                  RAD_ALL.23759 
            DIFF_R(L, I)=R_FREE(L, I)-R_CLOUD(L, I)                                RAD_ALL.23760 
            FACTOR(L, I)=DIFF_R(L, I)/DIFF_T(L, I)                                 RAD_ALL.23761 
            IF (ABS(1.0E+00-ABS(FACTOR(L, I))).LT.TOL_DIV) THEN                    RAD_ALL.23762 
               R_CLOUD(L, I)=R_CLOUD(L, I)-2.0E+00*TOL_DIV*DIFF_T(L, I)            RAD_ALL.23763 
               FACTOR(L, I)=FACTOR(L, I)-2.0E+00*TOL_DIV                           RAD_ALL.23764 
            ENDIF                                                                  RAD_ALL.23765 
         ENDDO                                                                     RAD_ALL.23766 
      ENDDO                                                                        RAD_ALL.23767 
!                                                                                  RAD_ALL.23768 
!     SET UP THE EQUATIONS FOR THE DIFFERENCES IN THE CLEAR AND CLOUDY             RAD_ALL.23769 
!     FLUXES AND SOLVE THEM. THESE SHOULD BE THOUGHT OF AS EQUATIONS               RAD_ALL.23770 
!     AT THE I'TH LEVEL.                                                           RAD_ALL.23771 
                                                                                   RAD_ALL.23772 
!     COEFFICIENTS AT THE TOP OF THE CLOUDY REGION                                 RAD_ALL.23773 
!     (DOWNWARD TERMS ONLY):                                                       RAD_ALL.23774 
      DO L=1, N_PROFILE                                                            RAD_ALL.23775 
         DET(L, N_CLOUD_TOP-1)=1.0E+00                                             RAD_ALL.23776 
         DEL_M_MM(L, N_CLOUD_TOP-1)=0.0E+00                                        RAD_ALL.23777 
         DEL_M_0M(L, N_CLOUD_TOP-1)=1.0E+00                                        RAD_ALL.23778 
         DEL_M_PP(L, N_CLOUD_TOP-1)=0.0E+00                                        RAD_ALL.23779 
         DEL_M_2P(L, N_CLOUD_TOP-1)=0.0E+00                                        RAD_ALL.23780 
         KSI_M(L, N_CLOUD_TOP-1)=0.0E+00                                           RAD_ALL.23781 
      ENDDO                                                                        RAD_ALL.23782 
!                                                                                  RAD_ALL.23783 
!     INTERMEDIATE LEVELS:                                                         RAD_ALL.23784 
      DO I=N_CLOUD_TOP, N_LAYER-1                                                  RAD_ALL.23785 
!                                                                                  RAD_ALL.23786 
!        DOWNWARD FLUX:                                                            RAD_ALL.23787 
         DO LL=1, N_FREE_PROFILE(I)                                                RAD_ALL.23788 
            L=I_FREE_PROFILE(LL, I)                                                RAD_ALL.23789 
!           DO NOT CANCEL TRANSMITTANCES SO THAT DET IS ALWAYS O(T^2)              RAD_ALL.23790 
!           FOR CONFORMITY IN TEST.                                                RAD_ALL.23791 
            ETA_M_MM(L)=0                                                          RAD_ALL.23792 
            ETA_M_0M(L)=T_FREE(L, I)                                               RAD_ALL.23793 
            ETA_M_PP(L)=0                                                          RAD_ALL.23794 
            SIGMA_M(L)=0                                                           RAD_ALL.23795 
            DELTA_M_M(L)=T_FREE(L, I)                                              RAD_ALL.23796 
            DELTA_M_P(L)=0                                                         RAD_ALL.23797 
         ENDDO                                                                     RAD_ALL.23798 
         DO LL=1, N_CLOUD_PROFILE(I)                                               RAD_ALL.23799 
            L=I_CLOUD_PROFILE(LL, I)                                               RAD_ALL.23800 
            ETA_M_MM(L)=2.0E+00*T_CLOUD(L, I)*T_FREE(L, I)                         RAD_ALL.23801 
            ETA_M_0M(L)=-(T_FREE(L, I)+T_CLOUD(L, I))                              RAD_ALL.23802 
            ETA_M_PP(L)=R_FREE(L, I)*T_CLOUD(L, I)*BT_FP(L, I)                     RAD_ALL.23803 
     &         +R_CLOUD(L, I)*T_FREE(L, I)*(2.0E+00-BT_FP(L, I))                   RAD_ALL.23804 
            SIGMA_M(L)=2.0E+00*(T_CLOUD(L, I)*S_DOWN_FREE(L, I)                    RAD_ALL.23805 
     &         +T_FREE(L, I)*S_DOWN_CLOUD(L, I))                                   RAD_ALL.23806 
            DELTA_M_M(L)=-DIFF_T(L, I)                                             RAD_ALL.23807 
            DELTA_M_P(L)=-BT_FM(L, I)*(R_FREE(L, I)*T_CLOUD(L, I)                  RAD_ALL.23808 
     &         -R_CLOUD(L, I)*T_FREE(L, I))                                        RAD_ALL.23809 
         ENDDO                                                                     RAD_ALL.23810 
!                                                                                  RAD_ALL.23811 
!        UPWARD FLUX:                                                              RAD_ALL.23812 
         DO LL=1, N_FREE_PROFILE(I+1)                                              RAD_ALL.23813 
            L=I_FREE_PROFILE(LL, I+1)                                              RAD_ALL.23814 
            ETA_P_0M(L)=0                                                          RAD_ALL.23815 
            ETA_P_PP(L)=T_FREE(L, I+1)                                             RAD_ALL.23816 
            ETA_P_2P(L)=0                                                          RAD_ALL.23817 
            SIGMA_P(L)=0                                                           RAD_ALL.23818 
            DELTA_P_M(L)=0                                                         RAD_ALL.23819 
            DELTA_P_P(L)=T_FREE(L, I+1)                                            RAD_ALL.23820 
         ENDDO                                                                     RAD_ALL.23821 
         DO LL=1, N_CLOUD_PROFILE(I+1)                                             RAD_ALL.23822 
            L=I_CLOUD_PROFILE(LL, I+1)                                             RAD_ALL.23823 
            ETA_P_0M(L)=T_CLOUD(L, I+1)*R_FREE(L, I+1)*GM_FP(L, I)                 RAD_ALL.23824 
     &         +T_FREE(L, I+1)*R_CLOUD(L, I+1)*(2.0E+00-GM_FP(L, I))               RAD_ALL.23825 
            ETA_P_PP(L)=-(T_FREE(L, I+1)+T_CLOUD(L, I+1))                          RAD_ALL.23826 
            ETA_P_2P(L)=2.0E+00*T_FREE(L, I+1)*T_CLOUD(L, I+1)                     RAD_ALL.23827 
            SIGMA_P(L)=2.0E+00*(T_CLOUD(L, I+1)*S_UP_FREE(L, I+1)                  RAD_ALL.23828 
     &         +T_FREE(L, I+1)*S_UP_CLOUD(L, I+1))                                 RAD_ALL.23829 
            DELTA_P_M(L)=-GM_FM(L, I)                                              RAD_ALL.23830 
     &         *(T_CLOUD(L, I+1)*R_FREE(L, I+1)                                    RAD_ALL.23831 
     &         -T_FREE(L, I+1)*R_CLOUD(L, I+1))                                    RAD_ALL.23832 
            DELTA_P_P(L)=-DIFF_T(L, I+1)                                           RAD_ALL.23833 
         ENDDO                                                                     RAD_ALL.23834 
!                                                                                  RAD_ALL.23835 
!        SOLVE THE EQUATIONS:                                                      RAD_ALL.23836 
!        THESE COEFFICIENTS SHOULD ALL BE DIVIDED BY DET; WE CAN                   RAD_ALL.23837 
!        SAVE OPERATIONS BY DIVIDING THE D-VARIABLES BELOW BY DET                  RAD_ALL.23838 
!        INSTEAD OF DIVIDING THESE.                                                RAD_ALL.23839 
         DO L=1, N_PROFILE                                                         RAD_ALL.23840 
            DET(L, I)=DELTA_P_P(L)*DELTA_M_M(L)                                    RAD_ALL.23841 
     &         -DELTA_P_M(L)*DELTA_M_P(L)                                          RAD_ALL.23842 
            DEL_M_MM(L, I)=DELTA_P_P(L)*ETA_M_MM(L)                                RAD_ALL.23843 
            DEL_M_0M(L, I)=(DELTA_P_P(L)*ETA_M_0M(L)                               RAD_ALL.23844 
     &         -DELTA_M_P(L)*ETA_P_0M(L))                                          RAD_ALL.23845 
            DEL_M_PP(L, I)=(DELTA_P_P(L)*ETA_M_PP(L)                               RAD_ALL.23846 
     &         -DELTA_M_P(L)*ETA_P_PP(L))                                          RAD_ALL.23847 
            DEL_M_2P(L, I)=-DELTA_M_P(L)*ETA_P_2P(L)                               RAD_ALL.23848 
            KSI_M(L, I)=(DELTA_P_P(L)*SIGMA_M(L)                                   RAD_ALL.23849 
     &         -DELTA_M_P(L)*SIGMA_P(L))                                           RAD_ALL.23850 
            DEL_P_MM(L, I)=-DELTA_P_M(L)*ETA_M_MM(L)                               RAD_ALL.23851 
            DEL_P_0M(L, I)=(ETA_P_0M(L)*DELTA_M_M(L)                               RAD_ALL.23852 
     &         -ETA_M_0M(L)*DELTA_P_M(L))                                          RAD_ALL.23853 
            DEL_P_PP(L, I)=(ETA_P_PP(L)*DELTA_M_M(L)                               RAD_ALL.23854 
     &         -ETA_M_PP(L)*DELTA_P_M(L))                                          RAD_ALL.23855 
            DEL_P_2P(L, I)=DELTA_M_M(L)*ETA_P_2P(L)                                RAD_ALL.23856 
            KSI_P(L, I)=(DELTA_M_M(L)*SIGMA_P(L)                                   RAD_ALL.23857 
     &         -DELTA_P_M(L)*SIGMA_M(L))                                           RAD_ALL.23858 
!                                                                                  RAD_ALL.23859 
         ENDDO                                                                     RAD_ALL.23860 
!        DEAL WITH ILL-CONDITIONED CASES.                                          RAD_ALL.23861 
         DO L=1, N_PROFILE                                                         RAD_ALL.23862 
            IF (DET(L, I).LT.(TOL_DIV*T_FREE(L, I)*T_FREE(L, I+1))) THEN           RAD_ALL.23863 
!              FREAK COMBINATION OF OPTICAL PROPERTIES AND GEOMETRY:               RAD_ALL.23864 
!              HERE PERTURB THE UPPER CLOUDY TRANSMISSION.                         RAD_ALL.23865 
               IF ( ((T_CLOUD(L, I)-T_FREE(L, I))                                  RAD_ALL.23866 
     &            * (T_CLOUD(L, I+1)-T_FREE(L, I+1)))                              RAD_ALL.23867 
     &            .GT.(TOL_DIV*T_FREE(L, I)*T_FREE(L, I+1))) THEN                  RAD_ALL.23868 
                  T_CLOUD(L, I)=(1.0E+00-1.0E+02*TOL_DIV)*T_CLOUD(L, I)            RAD_ALL.23869 
                  ETA_M_MM(L)=2.0E+00*T_CLOUD(L, I)*T_FREE(L, I)                   RAD_ALL.23870 
                  ETA_M_0M(L)=-(T_FREE(L, I)+T_CLOUD(L, I))                        RAD_ALL.23871 
                  ETA_M_PP(L)=R_FREE(L, I)*T_CLOUD(L, I)*BT_FP(L, I)               RAD_ALL.23872 
     &               +R_CLOUD(L, I)*T_FREE(L, I)*(2.0E+00-BT_FP(L, I))             RAD_ALL.23873 
                  SIGMA_M(L)=2.0E+00*(T_CLOUD(L, I)*S_DOWN_FREE(L, I)              RAD_ALL.23874 
     &               +T_FREE(L, I)*S_DOWN_CLOUD(L, I))                             RAD_ALL.23875 
                  DELTA_M_M(L)=T_CLOUD(L, I)-T_FREE(L, I)                          RAD_ALL.23876 
                  DELTA_M_P(L)=-BT_FM(L, I)*(R_FREE(L, I)*T_CLOUD(L, I)            RAD_ALL.23877 
     &               -R_CLOUD(L, I)*T_FREE(L, I))                                  RAD_ALL.23878 
               ENDIF                                                               RAD_ALL.23879 
!                                                                                  RAD_ALL.23880 
!              RESOLVE THE EQUATIONS:                                              RAD_ALL.23881 
               DET(L, I)=DELTA_P_P(L)*DELTA_M_M(L)                                 RAD_ALL.23882 
     &            -DELTA_P_M(L)*DELTA_M_P(L)                                       RAD_ALL.23883 
               DEL_M_MM(L, I)=DELTA_P_P(L)*ETA_M_MM(L)                             RAD_ALL.23884 
               DEL_M_0M(L, I)=(DELTA_P_P(L)*ETA_M_0M(L)                            RAD_ALL.23885 
     &            -DELTA_M_P(L)*ETA_P_0M(L))                                       RAD_ALL.23886 
               DEL_M_PP(L, I)=(DELTA_P_P(L)*ETA_M_PP(L)                            RAD_ALL.23887 
     &            -DELTA_M_P(L)*ETA_P_PP(L))                                       RAD_ALL.23888 
               DEL_M_2P(L, I)=-DELTA_M_P(L)*ETA_P_2P(L)                            RAD_ALL.23889 
               KSI_M(L, I)=(DELTA_P_P(L)*SIGMA_M(L)                                RAD_ALL.23890 
     &            -DELTA_M_P(L)*SIGMA_P(L))                                        RAD_ALL.23891 
               DEL_P_MM(L, I)=-DELTA_P_M(L)*ETA_M_MM(L)                            RAD_ALL.23892 
               DEL_P_0M(L, I)=(ETA_P_0M(L)*DELTA_M_M(L)                            RAD_ALL.23893 
     &            -ETA_M_0M(L)*DELTA_P_M(L))                                       RAD_ALL.23894 
               DEL_P_PP(L, I)=(ETA_P_PP(L)*DELTA_M_M(L)                            RAD_ALL.23895 
     &            -ETA_M_PP(L)*DELTA_P_M(L))                                       RAD_ALL.23896 
               DEL_P_2P(L, I)=DELTA_M_M(L)*ETA_P_2P(L)                             RAD_ALL.23897 
               KSI_P(L, I)=(DELTA_M_M(L)*SIGMA_P(L)                                RAD_ALL.23898 
     &            -DELTA_P_M(L)*SIGMA_M(L))                                        RAD_ALL.23899 
            ENDIF                                                                  RAD_ALL.23900 
         ENDDO                                                                     RAD_ALL.23901 
      ENDDO                                                                        RAD_ALL.23902 
!                                                                                  RAD_ALL.23903 
!     THE BOTTOM LEVEL (UPWARD TERMS ONLY):                                        RAD_ALL.23904 
      DO L=1, N_PROFILE                                                            RAD_ALL.23905 
         DET(L, N_LAYER)=1.0E+00                                                   RAD_ALL.23906 
         DEL_P_MM(L, N_LAYER)=0.0E+00                                              RAD_ALL.23907 
         DEL_P_0M(L, N_LAYER)=0.0E+00                                              RAD_ALL.23908 
         DEL_P_PP(L, N_LAYER)=1.0E+00                                              RAD_ALL.23909 
         DEL_P_2P(L, N_LAYER)=0.0E+00                                              RAD_ALL.23910 
         KSI_P(L, N_LAYER)=0.0E+00                                                 RAD_ALL.23911 
      ENDDO                                                                        RAD_ALL.23912 
!                                                                                  RAD_ALL.23913 
!     ASSEMBLE THE SUMMED EQUATIONS WORKING OVER LAYERS.                           RAD_ALL.23914 
!                                                                                  RAD_ALL.23915 
!     REGION ABOVE CLOUDS:                                                         RAD_ALL.23916 
      DO I=1, N_CLOUD_TOP-1                                                        RAD_ALL.23917 
         DO L=1, N_PROFILE                                                         RAD_ALL.23918 
!           UPWARD EQUATION:                                                       RAD_ALL.23919 
            P(L, 5, 2*I)=0.0E+00                                                   RAD_ALL.23920 
            P(L, 4, 2*I)=1.0E+00                                                   RAD_ALL.23921 
            P(L, 3, 2*I)=-R_FREE(L, I)                                             RAD_ALL.23922 
            P(L, 2, 2*I)=-T_FREE(L, I)                                             RAD_ALL.23923 
            P(L, 1, 2*I)=0.0E+00                                                   RAD_ALL.23924 
            V(L, 2*I)=S_UP_FREE(L, I)                                              RAD_ALL.23925 
!           DOWNWARD EQUATION:                                                     RAD_ALL.23926 
            P(L, 5, 2*I+1)=0.0E+00                                                 RAD_ALL.23927 
            P(L, 4, 2*I+1)=-T_FREE(L, I)                                           RAD_ALL.23928 
            P(L, 3, 2*I+1)=-R_FREE(L, I)                                           RAD_ALL.23929 
            P(L, 2, 2*I+1)=1.0E+00                                                 RAD_ALL.23930 
            P(L, 1, 2*I+1)=0.0E+00                                                 RAD_ALL.23931 
            V(L, 2*I+1)=S_DOWN_FREE(L, I)                                          RAD_ALL.23932 
         ENDDO                                                                     RAD_ALL.23933 
      ENDDO                                                                        RAD_ALL.23934 
!                                                                                  RAD_ALL.23935 
!     REGION WHERE CLOUDS ARE POSSIBLE:                                            RAD_ALL.23936 
      DO I=N_CLOUD_TOP, N_LAYER                                                    RAD_ALL.23937 
         DO LL=1, N_CLOUD_PROFILE(I)                                               RAD_ALL.23938 
            L=I_CLOUD_PROFILE(LL, I)                                               RAD_ALL.23939 
!           SUMMED DOWNWARD EQUATIONS:                                             RAD_ALL.23940 
            D_M_MM=GM_FM(L, I-1)*DIFF_T(L, I)/DET(L, I-1)                          RAD_ALL.23941 
            H_M_MM=T_FREE(L, I)*GM_FP(L, I-1)                                      RAD_ALL.23942 
     &          +T_CLOUD(L, I)*(2.0E+00-GM_FP(L, I-1))                             RAD_ALL.23943 
            H_M_PP=R_FREE(L, I)*BT_FP(L, I)+R_CLOUD(L, I)                          RAD_ALL.23944 
     &          *(2.0E+00-BT_FP(L, I))                                             RAD_ALL.23945 
            D_M_PP=BT_FM(L, I)*DIFF_R(L, I)/DET(L, I)                              RAD_ALL.23946 
            S_M=2.0E+00*(S_DOWN_FREE(L, I)+S_DOWN_CLOUD(L, I))                     RAD_ALL.23947 
!                                                                                  RAD_ALL.23948 
!           SUMMED UPWARD EQUATIONS:                                               RAD_ALL.23949 
            D_P_MM=GM_FM(L, I-1)*DIFF_R(L, I)/DET(L, I-1)                          RAD_ALL.23950 
            H_P_MM=R_FREE(L, I)*GM_FP(L, I-1)                                      RAD_ALL.23951 
     &         +R_CLOUD(L, I)*(2.0E+00-GM_FP(L, I-1))                              RAD_ALL.23952 
            H_P_PP=T_FREE(L, I)*BT_FP(L, I)+T_CLOUD(L, I)                          RAD_ALL.23953 
     &         *(2.0E+00-BT_FP(L, I))                                              RAD_ALL.23954 
            D_P_PP=BT_FM(L, I)*DIFF_T(L, I)/DET(L, I)                              RAD_ALL.23955 
            S_P=2.0E+00*(S_UP_FREE(L, I)+S_UP_CLOUD(L, I))                         RAD_ALL.23956 
!                                                                                  RAD_ALL.23957 
!           ESTABLISH THE COEFFICIENTS OF                                          RAD_ALL.23958 
!           THE PRIMITIVE HEPTADIAGONAL EQUATIONS:                                 RAD_ALL.23959 
!           EQUATION FOR FLUX_UP(I-1):                                             RAD_ALL.23960 
            U_P_M2M=D_P_MM*DEL_M_MM(L, I-1)                                        RAD_ALL.23961 
            U_P_MM=D_P_MM*DEL_M_0M(L, I-1)+H_P_MM+D_P_PP*DEL_P_MM(L, I)            RAD_ALL.23962 
            U_P_0M=D_P_PP*DEL_P_0M(L, I)                                           RAD_ALL.23963 
            U_P_0P=D_P_MM*DEL_M_PP(L, I-1)-2.0E+00                                 RAD_ALL.23964 
            U_P_PP=D_P_MM*DEL_M_2P(L, I-1)+H_P_PP+D_P_PP*DEL_P_PP(L, I)            RAD_ALL.23965 
            U_P_2P=D_P_PP*DEL_P_2P(L, I)                                           RAD_ALL.23966 
            Q_P=-S_P-D_P_MM*KSI_M(L, I-1)-D_P_PP*KSI_P(L, I)                       RAD_ALL.23967 
!           EQUATION FOR FLUX_DOWN(I-1):                                           RAD_ALL.23968 
            U_M_M2M=D_M_MM*DEL_M_MM(L, I-1)                                        RAD_ALL.23969 
            U_M_MM=D_M_MM*DEL_M_0M(L, I-1)+H_M_MM+D_M_PP*DEL_P_MM(L, I)            RAD_ALL.23970 
            U_M_0M=-2.0E+00+D_M_PP*DEL_P_0M(L, I)                                  RAD_ALL.23971 
            U_M_0P=D_M_MM*DEL_M_PP(L, I-1)                                         RAD_ALL.23972 
            U_M_PP=D_M_MM*DEL_M_2P(L, I-1)+H_M_PP+D_M_PP*DEL_P_PP(L, I)            RAD_ALL.23973 
            U_M_2P=D_M_PP*DEL_P_2P(L, I)                                           RAD_ALL.23974 
            Q_M=-S_M-D_M_MM*KSI_M(L, I-1)-D_M_PP*KSI_P(L, I)                       RAD_ALL.23975 
!                                                                                  RAD_ALL.23976 
!                                                                                  RAD_ALL.23977 
!           ASSIGN THE COEFFICIENTS OF THE PENTADIAGONAL MATRIX:                   RAD_ALL.23978 
!                                                                                  RAD_ALL.23979 
!           DOWNWARD EQUATION:                                                     RAD_ALL.23980 
            P(L, 5, 2*I)=U_M_M2M-FACTOR(L, I)*U_P_M2M                              RAD_ALL.23981 
            P(L, 4, 2*I)=U_M_0P-FACTOR(L, I)*U_P_0P                                RAD_ALL.23982 
            P(L, 3, 2*I)=U_M_MM-FACTOR(L, I)*U_P_MM                                RAD_ALL.23983 
            P(L, 2, 2*I)=U_M_PP-FACTOR(L, I)*U_P_PP                                RAD_ALL.23984 
            P(L, 1, 2*I)=U_M_0M-FACTOR(L, I)*U_P_0M                                RAD_ALL.23985 
            V(L, 2*I)=Q_M-FACTOR(L, I)*Q_P                                         RAD_ALL.23986 
!           UPWARD EQUATION:                                                       RAD_ALL.23987 
            P(L, 5, 2*I+1)=U_P_0P-FACTOR(L, I)*U_M_0P                              RAD_ALL.23988 
            P(L, 4, 2*I+1)=U_P_MM-FACTOR(L, I)*U_M_MM                              RAD_ALL.23989 
            P(L, 3, 2*I+1)=U_P_PP-FACTOR(L, I)*U_M_PP                              RAD_ALL.23990 
            P(L, 2, 2*I+1)=U_P_0M-FACTOR(L, I)*U_M_0M                              RAD_ALL.23991 
            P(L, 1, 2*I+1)=U_P_2P-FACTOR(L, I)*U_M_2P                              RAD_ALL.23992 
            V(L, 2*I+1)=Q_P-FACTOR(L, I)*Q_M                                       RAD_ALL.23993 
!                                                                                  RAD_ALL.23994 
         ENDDO                                                                     RAD_ALL.23995 
!                                                                                  RAD_ALL.23996 
!        CLOUDLESS PROFILES:                                                       RAD_ALL.23997 
         DO LL=1, N_FREE_PROFILE(I)                                                RAD_ALL.23998 
            L=I_FREE_PROFILE(LL, I)                                                RAD_ALL.23999 
!                                                                                  RAD_ALL.24000 
!           ASSIGN THE COEFFICIENTS OF THE PENTADIAGONAL MATRIX:                   RAD_ALL.24001 
!           UPWARD EQUATION:                                                       RAD_ALL.24002 
            P(L, 5, 2*I)=0.0E+00                                                   RAD_ALL.24003 
            P(L, 4, 2*I)=1.0E+00                                                   RAD_ALL.24004 
            P(L, 3, 2*I)=-R_FREE(L, I)                                             RAD_ALL.24005 
            P(L, 2, 2*I)=-T_FREE(L, I)                                             RAD_ALL.24006 
            P(L, 1, 2*I)=0.0E+00                                                   RAD_ALL.24007 
            V(L, 2*I)=S_UP_FREE(L, I)                                              RAD_ALL.24008 
!                                                                                  RAD_ALL.24009 
!           DOWNWARD EQUATION:                                                     RAD_ALL.24010 
            P(L, 5, 2*I+1)=0.0E+00                                                 RAD_ALL.24011 
            P(L, 4, 2*I+1)=-T_FREE(L, I)                                           RAD_ALL.24012 
            P(L, 3, 2*I+1)=-R_FREE(L, I)                                           RAD_ALL.24013 
            P(L, 2, 2*I+1)=1.0E+00                                                 RAD_ALL.24014 
            P(L, 1, 2*I+1)=0.0E+00                                                 RAD_ALL.24015 
            V(L, 2*I+1)=S_DOWN_FREE(L, I)                                          RAD_ALL.24016 
         ENDDO                                                                     RAD_ALL.24017 
!                                                                                  RAD_ALL.24018 
      ENDDO                                                                        RAD_ALL.24019 
!                                                                                  RAD_ALL.24020 
!     SET THE EQUATIONS AT THE BOUNDARIES.                                         RAD_ALL.24021 
      DO L=1, N_PROFILE                                                            RAD_ALL.24022 
!        TOP BOUNDARY CONDITION:                                                   RAD_ALL.24023 
         P(L, 5, 1)=0.0E+00                                                        RAD_ALL.24024 
         P(L, 4, 1)=0.0E+00                                                        RAD_ALL.24025 
         P(L, 3, 1)=0.0E+00                                                        RAD_ALL.24026 
         P(L, 2, 1)=1.0E+00                                                        RAD_ALL.24027 
         P(L, 1, 1)=0.0E+00                                                        RAD_ALL.24028 
         V(L, 1)=FLUX_INC_DOWN(L)                                                  RAD_ALL.24029 
!        BOTTOM BOUNDARY CONDITION:                                                RAD_ALL.24030 
!        A PERTURBATION IS REQUIRED IN CASES WHERE THE ALBEDO IS 0.                RAD_ALL.24031 
         P(L, 5, 2*N_LAYER+2)=0.0E+00                                              RAD_ALL.24032 
         P(L, 4, 2*N_LAYER+2)=-1.0E+00                                             RAD_ALL.24033 
         P(L, 3, 2*N_LAYER+2)=ALBEDO_SURFACE_DIFF(L)                               RAD_ALL.24034 
     &       +TOL_MACHINE/(ALBEDO_SURFACE_DIFF(L)+SQRT_TOL_MACHINE)                RAD_ALL.24035 
         P(L, 2, 2*N_LAYER+2)=0.0E+00                                              RAD_ALL.24036 
         P(L, 1, 2*N_LAYER+2)=0.0E+00                                              RAD_ALL.24037 
         V(L, 2*N_LAYER+2)                                                         RAD_ALL.24038 
     &      =-(ALBEDO_SURFACE_DIR(L)-ALBEDO_SURFACE_DIFF(L))                       RAD_ALL.24039 
     &      *FLUX_DIRECT_GROUND(L)                                                 RAD_ALL.24040 
     &      -SOURCE_GROUND(L)                                                      RAD_ALL.24041 
      ENDDO                                                                        RAD_ALL.24042 
!                                                                                  RAD_ALL.24043 
!                                                                                  RAD_ALL.24044 
      RETURN                                                                       RAD_ALL.24045 
      END    
