!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    SUBROUTINE VDIFV(LMVK,KTM,DTQ2,UZ0,VZ0,AKMS,U,V,AKM,Z)
!     ******************************************************************
!     *                                                                *
!     *  VERTICAL DIFFUSION                                            *
!     *                                                                *
!     ******************************************************************
!-----------------------------------------------------------------------
    INCLUDE "parmeta.f90"
    INCLUDE "mpp.h"
#include "sp.h"
!-----------------------------------------------------------------------
    PARAMETER &
    (LP1=LM+1,LM1=LM-1)
!-----------------------------------------------------------------------
    DIMENSION &
    U     (LM),V     (LM)
    DIMENSION &
    AKM   (LM1) &
    ,Z     (LP1)
    DIMENSION &
    CM    (LM1),CR    (LM1),RSU   (LM1),RSV   (LM1) &
    ,DTOZ  (LM1)
!-----------------------------------------------------------------------
!***********************************************************************
    DTDIF=DTQ2/FLOAT(KTM)
    LMVM=LMVK-1
    LMVP=LMVK+1
!-----------------------------------------------------------------------
    DO 300 KT=1,KTM
    !-----------------------------------------------------------------------
        DO 100 L=1,LMVM
            DTOZ(L)=DTDIF/(Z(L)-Z(L+1))
            CR(L)=-DTOZ(L)*AKM(L)
        100 END DO
    
        CM(1)=DTOZ(1)*AKM(1)+1.
        RSU(1)=U(1)
        RSV(1)=V(1)
    !-----------------------------------------------------------------------
        DO 110 L=2,LMVM
            DTOZL=DTOZ(L)
            CF=-DTOZL*AKM(L-1)/CM(L-1)
            CM(L)=-CR(L-1)*CF+(AKM(L-1)+AKM(L))*DTOZL+1.
            RSU(L)=-RSU(L-1)*CF+U(L)
            RSV(L)=-RSV(L-1)*CF+V(L)
        110 END DO
    !-----------------------------------------------------------------------
        DTOZS=DTDIF/(Z(LMVK)-Z(LMVP))
        AKMH=AKM(LMVM)
    
        CF=-DTOZS*AKMH/CM(LMVM)
        RCMVB=1./((AKMH+AKMS)*DTOZS-CR(LMVM)*CF+1.)
        DTOZAK=DTOZS*AKMS
    !-----------------------------------------------------------------------
        U(LMVK)=(DTOZAK*UZ0-RSU(LMVM)*CF+U(LMVK))*RCMVB
        V(LMVK)=(DTOZAK*VZ0-RSV(LMVM)*CF+V(LMVK))*RCMVB
    !-----------------------------------------------------------------------
        DO 120 IVI=1,LMVM
            L=LMVK-IVI
            RCML=1./CM(L)
            U(L)=(-CR(L)*U(L+1)+RSU(L))*RCML
            V(L)=(-CR(L)*V(L+1)+RSV(L))*RCML
        120 END DO
    !-----------------------------------------------------------------------
    300 END DO
!-----------------------------------------------------------------------
    RETURN
    END SUBROUTINE VDIFV


