SUBROUTINE MVTENDAD(PVOR,PDIV,PT,PSP)

!**** *MVTENDAD* - COPYING SPECTRAL TENDENCIES WHEN NTMAX > NSMAX .

!     PURPOSE.   TO COPY SPECTRAL TENDENCIES IN CASE OF STRETCHING
!     --------    (USED IN NONLINEAR NORMAL MODE INITIALIZATION)

!**   INTERFACE.
!     ----------
!        *CALL* *MVTENDAD(PVOR,PDIV,PT,PSP)*

!        EXPLICIT ARGUMENTS :  PVOR : ARRAY RECEIVING SPTVOR
!        --------------------  PDIV : ..... ......... SPTDIV
!                              PT   : ..... ......... SPTT
!                              PSP  : ..... ......... SPTSP

!        IMPLICIT ARGUMENTS :  YOMSPT (SPTVOR,SPTDIV,SPTT,SPTSP)
!        --------------------  (spectral tendencies)

!     REFERENCE.
!     ----------
!        ECMWF Research Department documentation of the IFS

!     AUTHOR.
!     -------
!        D. Giard  * METEO-FRANCE *

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 93-04-05
!        D. GIARD : 93-05-13  tendencies up to NSMAX+1 for vor,div
!      L. ISAKSEN : 95-06-06  Reordering of spectral arrays
!      L. ISAKSEN : 96-02-20  NFLEV --> NFLEVL, cleaning
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!***********************************************************************


USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE YOMDIM   , ONLY : NFLEVL   ,NFTHER   ,NTPEC2
USE YOMSPTT  , ONLY : SPTVOR   ,SPTDIV   ,SPTT     ,SPTSP
USE YOMLAP   , ONLY : NATM0
USE YOMMP    , ONLY : MYSETW   ,NPROCM

IMPLICIT NONE

REAL(KIND=JPRB)   ,INTENT(INOUT) :: PVOR(NFLEVL,NTPEC2) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PDIV(NFLEVL,NTPEC2) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PT(NFLEVL,NTPEC2) 
REAL(KIND=JPRB)   ,INTENT(INOUT) :: PSP(NTPEC2) 
INTEGER(KIND=JPIM) :: J, JK
REAL(KIND=JPRB) :: ZHOOK_HANDLE

!*  3. Reset vorticity and divergence for n<=NSMAX+1 , m<=NSMAX
!      (Nothing to do)

!*  2. From m=0 to NTMAX and n=m to NTMAX

IF (LHOOK) CALL DR_HOOK('MVTENDAD',0,ZHOOK_HANDLE)
DO J=1,NTPEC2
  SPTSP(J)= SPTSP(J) + PSP(J)
  PSP(J)= 0.0_JPRB
ENDDO
DO JK=1,NFLEVL
  DO J=1,NTPEC2
    SPTVOR(JK,J)= SPTVOR(JK,J) + PVOR(JK,J)
    PVOR(JK,J)= 0.0_JPRB
    SPTDIV(JK,J)= SPTDIV(JK,J) + PDIV(JK,J)
    PDIV(JK,J)= 0.0_JPRB
    IF (NFTHER >= 1) THEN
      SPTT(JK,J)= SPTT(JK,J) + PT(JK,J)
      PT(JK,J)= 0.0_JPRB
    ENDIF
  ENDDO
ENDDO

!*  1. vor=div=0 for m=n=0

IF (MYSETW == NPROCM(0)) THEN
  DO JK=1,NFLEVL
    SPTVOR(JK,NATM0(0))=0.0_JPRB
    SPTDIV(JK,NATM0(0))=0.0_JPRB
  ENDDO
ENDIF

IF (LHOOK) CALL DR_HOOK('MVTENDAD',1,ZHOOK_HANDLE)
END SUBROUTINE MVTENDAD
