SUBROUTINE COPTRA(CDCONF)

!**** *COPTRA*  - copies the trajectory of the model

!     Purpose.
!     --------
!     Copy the trajectory

!**   Interface.
!     ----------
!        *CALL* *COPTRA(CDCONF)

!        Explicit arguments :     CDCONF - configuration of call
!        --------------------

!        Implicit arguments :      The state varaibles of the model
!        --------------------

!     Method.
!     -------
!        See documentation

!     Externals.
!     ----------

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

!     Author.
!     -------
!        Mats Hamrud and Philippe Courtier  *ECMWF*

!     Modifications.
!     --------------
!        Original : 88-03-02
!        Modified : 93-04-13 L. Labbe (computes trajectory orography)
!        Modified 95-06-06 by L.Isaksen : Reordering of spectral arrays
!        Modified 96-02-02 by L.Isaksen : Message Passing option added
!        Modified 97-10-28 by E.Andersson : Loops faster than F90-RESHAPE
!        Modified 98-08-10 by K. YESSAD: removal of LRPOLE option.
!         - LRPOLE removed from YOMCT0.
!         - LLPOLE removed, all parts under LRPOLE and LLPOLE removed.
!        Modified 99-07-25 by M.Hamrud  remove Matsuno
!        Modified 00-08-04 by Y.Tremolet remove SPECTRAJ and cleanup
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

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

USE YOMCT3   , ONLY : NSTEP
USE YOMSP    , ONLY : SPA3     ,SPA2
USE YOMSPJB  , ONLY : SP7A3, SP7A2
USE YOMSPT7  , ONLY : SPA3T7   ,SPA2T7
USE YOMVAR   , ONLY : LTRREF
USE YOMLUN   , ONLY : NULOUT

IMPLICIT NONE

CHARACTER(LEN=1)  ,INTENT(IN)    :: CDCONF 
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"

!     ------------------------------------------------------------------

IF (LHOOK) CALL DR_HOOK('COPTRA',0,ZHOOK_HANDLE)
IF(LTRREF)THEN

!*       3.    WRITE Reference IN CORE.
!              ------------------------

  IF(CDCONF == 'T')THEN
    SPA3T7(:,:,:,NSTEP) = SPA3(:,:,:)
    SPA2T7(:,:,NSTEP) = SPA2(:,:)

    write(nulout,*)'COPTRA: conf=T, ltrref=T'

!*       4.    Read Reference IN CORE.
!              -----------------------

  ELSEIF(CDCONF == 'B')THEN
    SP7A3(:,:,:) = SPA3T7(:,:,:,NSTEP)
    SP7A2(:,:) = SPA2T7(:,:,NSTEP)

    write(nulout,*)'COPTRA: conf=B, ltrref=T'
  ENDIF

!     ------------------------------------------------------------------

ELSE

  IF(CDCONF == 'B')THEN
    CALL abor1('COPTRA called with conf=B and LTRREF=F')
  ENDIF

ENDIF

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

