       SUBROUTINE XPENTA(JDIM,KDIM,A,B,C,D,E,X,Y,F,JL,JU,KL,KU)
       IMPLICIT DOUBLE PRECISION (A-H,O-Z)
       DOUBLE PRECISION LD,LD1,LD2,LDI
       DIMENSION A(JDIM,KDIM),B(JDIM,KDIM),C(JDIM,KDIM),D(JDIM,KDIM),
     *           E(JDIM,KDIM),X(JDIM,KDIM),Y(JDIM,KDIM),F(JDIM,KDIM)
C
C      ! START FORWARD GENERATION PROCESS AND SWEEP
C
        J = JL
        DO 1 K = KL,KU
        LD = C(J,K)
        LDI = 1./LD
        F(J,K) = F(J,K)*LDI
        X(J,K) = D(J,K)*LDI
        Y(J,K) = E(J,K)*LDI
1       CONTINUE
C
        J = JL+1
        DO 2 K = KL,KU
        LD1 = B(J,K)
        LD = C(J,K) - LD1*X(J-1,K)
        LDI = 1./LD
        F(J,K) = (F(J,K) - LD1*F(J-1,K))*LDI
        X(J,K) = (D(J,K) - LD1*Y(J-1,K))*LDI
        Y(J,K) = E(J,K)*LDI
2       CONTINUE
C
            DO 3 J = JL+2,JU-2
                DO 11 K = KL,KU
                LD2 = A(J,K)
                LD1 = B(J,K) - LD2*X(J-2,K)
                LD = C(J,K) - (LD2*Y(J-2,K) + LD1*X(J-1,K))
                LDI = 1./LD
                F(J,K) = (F(J,K) - LD2*F(J-2,K) - LD1*F(J-1,K))*LDI
                X(J,K) = (D(J,K) - LD1*Y(J-1,K))*LDI        
                Y(J,K) = E(J,K)*LDI
11              CONTINUE
3            CONTINUE
C
        J = JU-1
        DO 12 K = KL,KU
        LD2 = A(J,K)
        LD1 = B(J,K) - LD2*X(J-2,K)
        LD = C(J,K) - (LD2*Y(J-2,K) + LD1*X(J-1,K))
        LDI = 1./LD
        F(J,K) = (F(J,K) - LD2*F(J-2,K) - LD1*F(J-1,K))*LDI
        X(J,K) = (D(J,K) - LD1*Y(J-1,K))*LDI
12      CONTINUE
C
                J = JU
                DO 13 K = KL,KU
                LD2 = A(J,K)
                LD1 = B(J,K) - LD2*X(J-2,K)
                LD = C(J,K) - (LD2*Y(J-2,K) + LD1*X(J-1,K))
                LDI = 1./LD
                F(J,K) = (F(J,K) - LD2*F(J-2,K) - LD1*F(J-1,K))*LDI
13              CONTINUE
C
C        !  BACK SWEEP SOLUTION
C
        DO 14 K = KL,KU
        F(JU,K) = F(JU,K)
        F(JU-1,K) = F(JU-1,K) - X(JU-1,K)*F(JU,K)
14      CONTINUE
C
        DO 4 J = 2,JU-JL
           JX = JU-J
           DO 15 K = KL,KU
           F(JX,K) = F(JX,K) - X(JX,K)*F(JX+1,K) - Y(JX,K)*F(JX+2,K)
15         CONTINUE
4       CONTINUE
C
        RETURN
        END
