C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved.            RAD_ALL.25024 
C                                                                                  RAD_ALL.25025 
C Use, duplication or disclosure of this code is subject to the                    RAD_ALL.25026 
C restrictions as set forth in the contract.                                       RAD_ALL.25027 
C                                                                                  RAD_ALL.25028 
C                Meteorological Office                                             RAD_ALL.25029 
C                London Road                                                       RAD_ALL.25030 
C                BRACKNELL                                                         RAD_ALL.25031 
C                Berkshire UK                                                      RAD_ALL.25032 
C                RG12 2SZ                                                          RAD_ALL.25033 
C                                                                                  RAD_ALL.25034 
C If no contract has been raised with this copy of the code, the use,              RAD_ALL.25035 
C duplication or disclosure of it is strictly prohibited.  Permission              RAD_ALL.25036 
C to do so must first be obtained in writing from the Head of Numerical            RAD_ALL.25037 
C Modelling at the above address.                                                  RAD_ALL.25038 
C ******************************COPYRIGHT******************************            RAD_ALL.25039 
C                                                                                  RAD_ALL.25040 
!+ Subroutine to solve tridaigonal equations.                                      RAD_ALL.25041 
!                                                                                  RAD_ALL.25042 
! Method:                                                                          RAD_ALL.25043 
!       A set of tridiagonal equations is solved by Gaussian                       RAD_ALL.25044 
!       elimination. The eliminative step proceeds downward through                RAD_ALL.25045 
!       the atmosphere.                                                            RAD_ALL.25046 
!                                                                                  RAD_ALL.25047 
! Current Owner of Code: J. M. Edwards                                             RAD_ALL.25048 
!                                                                                  RAD_ALL.25049 
! History:                                                                         RAD_ALL.25050 
!       Version         Date                    Comment                            RAD_ALL.25051 
!       4.0             27-07-95                Original Code                      RAD_ALL.25052 
!                                               (J. M. Edwards)                    RAD_ALL.25053 
!                                                                                  RAD_ALL.25054 
! Description of Code:                                                             RAD_ALL.25055 
!   FORTRAN 77  with extensions listed in documentation.                           RAD_ALL.25056 
!                                                                                  RAD_ALL.25057 
!- ---------------------------------------------------------------------           RAD_ALL.25058 
      SUBROUTINE TRIDIAG_SOLVER_DOWN(M, N                                          RAD_ALL.25059 
     &   , A3, B                                                                   RAD_ALL.25060 
     &   , X                                                                       RAD_ALL.25061 
     &   , PM, PN                                                                  RAD_ALL.25062 
     &   , RHO, SIGMA                                                              RAD_ALL.25063 
     &   )                                                                         RAD_ALL.25064 
!                                                                                  RAD_ALL.25065 
!                                                                                  RAD_ALL.25066 
      IMPLICIT NONE                                                                RAD_ALL.25067 
!                                                                                  RAD_ALL.25068 
!                                                                                  RAD_ALL.25069 
!     DUMMY VARIABLES.                                                             RAD_ALL.25070 
      INTEGER   !, INTENT(IN)                                                      RAD_ALL.25071 
     &     M                                                                       RAD_ALL.25072 
!             NUMBER OF SETS OF EQUATIONS                                          RAD_ALL.25073 
     &   , N                                                                       RAD_ALL.25074 
!             NUMBER OF EQUATIONS IN EACH SET                                      RAD_ALL.25075 
     &   , PM                                                                      RAD_ALL.25076 
!             ARRAY SIZE FOR NUMBER OF SETS                                        RAD_ALL.25077 
     &   , PN                                                                      RAD_ALL.25078 
!             ARRAY SIZE FOR NUMBER OF EQUATIONS                                   RAD_ALL.25079 
      REAL      !, INTENT(IN)                                                      RAD_ALL.25080 
     &     A3(PM, 3, PN)                                                           RAD_ALL.25081 
!             TRIDIAGONAL MATRICES                                                 RAD_ALL.25082 
     &   , B(PM, PN)                                                               RAD_ALL.25083 
!             RIGHT-HAND SIDES                                                     RAD_ALL.25084 
      REAL      !, INTENT(OUT)                                                     RAD_ALL.25085 
     &     X(PM, PN)                                                               RAD_ALL.25086 
!             SOLUTION VECTORS                                                     RAD_ALL.25087 
!                                                                                  RAD_ALL.25088 
!     LOCAL VARIABLES.                                                             RAD_ALL.25089 
      INTEGER                                                                      RAD_ALL.25090 
     &     I                                                                       RAD_ALL.25091 
!             LOOP VARIABLE                                                        RAD_ALL.25092 
     &   , L                                                                       RAD_ALL.25093 
!             LOOP VARIABLE                                                        RAD_ALL.25094 
      REAL                                                                         RAD_ALL.25095 
     &     RHO(PM, PN)                                                             RAD_ALL.25096 
!             COEFFICIENT IN RECURRENCE                                            RAD_ALL.25097 
     &   , SIGMA(PM, PN)                                                           RAD_ALL.25098 
!             TERM IN RECURRENCE                                                   RAD_ALL.25099 
     &   , TEMP                                                                    RAD_ALL.25100 
!             TEMPORARY VARIABLE                                                   RAD_ALL.25101 
!                                                                                  RAD_ALL.25102 
!                                                                                  RAD_ALL.25103 
!                                                                                  RAD_ALL.25104 
!     PROCEED BACKWARD THROUGH THE EQUATIONS PERFORMING GUASSIAN                   RAD_ALL.25105 
!     ELIMINATION TO FORM A RECURRENCE.                                            RAD_ALL.25106 
      DO L=1, M                                                                    RAD_ALL.25107 
         RHO(L, 1)=-A3(L, 3, 1)/A3(L, 2, 1)                                        RAD_ALL.25108 
         SIGMA(L, 1)=B(L, 1)/A3(L, 2, 1)                                           RAD_ALL.25109 
      ENDDO                                                                        RAD_ALL.25110 
      DO I=2, N-1                                                                  RAD_ALL.25111 
         DO L=1, M                                                                 RAD_ALL.25112 
            TEMP=A3(L, 2, I)+A3(L, 1, I)*RHO(L, I-1)                               RAD_ALL.25113 
            RHO(L, I)=-A3(L, 3, I)/TEMP                                            RAD_ALL.25114 
            SIGMA(L, I)=(B(L, I)-A3(L, 1, I)*SIGMA(L, I-1))/TEMP                   RAD_ALL.25115 
         ENDDO                                                                     RAD_ALL.25116 
      ENDDO                                                                        RAD_ALL.25117 
!                                                                                  RAD_ALL.25118 
!     FORWARD SUBSTITUTING LOOP.                                                   RAD_ALL.25119 
      DO L=1, M                                                                    RAD_ALL.25120 
         X(L, N)=(B(L, N)-A3(L, 1, N)*SIGMA(L, N-1))                               RAD_ALL.25121 
     &      /(A3(L, 2, N)+A3(L, 1, N)*RHO(L, N-1))                                 RAD_ALL.25122 
      ENDDO                                                                        RAD_ALL.25123 
      DO I=N-1, 1, -1                                                              RAD_ALL.25124 
         DO L=1, M                                                                 RAD_ALL.25125 
            X(L, I)=RHO(L, I)*X(L, I+1)+SIGMA(L, I)                                RAD_ALL.25126 
         ENDDO                                                                     RAD_ALL.25127 
      ENDDO                                                                        RAD_ALL.25128 
!                                                                                  RAD_ALL.25129 
!                                                                                  RAD_ALL.25130 
      RETURN                                                                       RAD_ALL.25131 
      END  
