    SUBROUTINE CLTEND(ICLTEND)
!-----------------------------------------------------------------------
!$$$  SUBPROGRAM DOCUMENTATION BLOCK
!                .      .    .     
! SUBPROGRAM:    CLTEND      TEMPERATURE CHANGE BY CLOUD PROCESSES
!   PRGRMMR: Ferrier         ORG: W/NP22     DATE: 26 Sept 2001
!     
! ABSTRACT:
!     CLTEND gradually updates temperature tendencies from convection
!     grid-scale microphysics, and precipitation assimilation
!     
! USAGE: CALL CLTEND FROM MAIN PROGRAM EBU
!   INPUT ARGUMENT LIST:
!     ICLTEND - flag set to -1 prior to physics calls, 0 after physics
!               calls, and 1 for updating temperatures every time step
!  
!   OUTPUT ARGUMENT LIST:  NONE
!     
!   OUTPUT FILES:  NONE
!     
!   SUBPROGRAMS CALLED:  NONE
!  
!   UNIQUE: NONE
!  
!   LIBRARY: NONE
!  
!   COMMON BLOCKS: CTLBLK
!                  MASKS
!                  VRBLS
!                  C_Tadj
!   
! ATTRIBUTES:
!   LANGUAGE: FORTRAN 90
!   MACHINE : IBM SP
!
!-----------------------------------------------------------------------
    INCLUDE "parmeta.f90"
    INCLUDE "mpp.h"
!-----------------------------------------------------------------------
    LOGICAL
 &
    RUN,FIRST,RESTRT,SIGMA
!
    INCLUDE "COMM_CTLBLK.f90"
    INCLUDE "COMM_MASKS.f90"
    INCLUDE "COMM_VRBLS.f90"
    INCLUDE "COMM_C_Tadj.f90"
    REAL, SAVE :: T_old (IDIM1:IDIM2,JDIM1:JDIM2,LM)
!
!-----------------------------------------------------------------------
!
    IF (ICLTEND < 0) THEN
    !
    !---- Save old temperature array before CUCNVC, GSMDRIVE, & ADJPPT -----
    !
        DO L=1,LM
            DO J=MYJS,MYJE
                DO I=MYIS,MYIE
                    T_old(I,J,L)=T(I,J,L)
                ENDDO
            ENDDO
        ENDDO
    ELSE IF (ICLTEND == 0) THEN
    !
    !--- Calculate temperature tendencies from CUCNVC, GSMDRIVE, & ADJPPT 
    !
        DELTPH=1./FLOAT(NPHS)
        DO L=1,LM
            DO J=MYJS,MYJE
                DO I=MYIS,MYIE
                    T_adj(I,J,L)=HTM(I,J,L)*HBM2(I,J)*
 &
                    DELTPH*(T(I,J,L)-T_old(I,J,L))
                    T(I,J,L)=T_old(I,J,L)
                ENDDO
            ENDDO
        ENDDO
    ELSE
    !
    !--- Gradually update temperature from CUCNVC, GSMDRIVE, & ADJPPT 
    !    in small increments every dynamics time step
    !
        DO L=1,LM
            DO J=MYJS2,MYJE2
                DO I=MYIS,MYIE
                    T(I,J,L)=T(I,J,L)+T_adj(I,J,L)
                ENDDO
            ENDDO
        ENDDO
    ENDIF
!-----------------------------------------------------------------------
    RETURN
    END
