SUBROUTINE SUALLAVT(KULOUT)

!**** *SUALLAVT*  - allocate tables for avarc trajectory - reference                 
!     Purpose.
!     --------
!           Allocate tables for avarc trajectory minus reference to store them
!           for the minimization

!**   Interface.
!     ----------
!        *CALL* *SUALLAVT

!        Explicit arguments :
!        --------------------
!        KULOUT:  logical unit used for output

!        Implicit arguments :  Common YOMJR
!        --------------------

!     Method.
!     -------

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

!     Reference.
!     ----------

!     Author.
!     -------
!        R. Brozkova   *CNRM/GMAP*

!     Modifications.
!     --------------
!        Original : 01-11-29
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------
USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

USE YOMDIM  , ONLY:   NFLSUR,NSPEC2
USE YOMJR   , ONLY:  ATRAVOR, ATRADIV, ATRAT, ATRAQ, ATRASP
USE YOMHCP  , ONLY:  NHECP

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KULOUT 
INTEGER(KIND=JPIM) :: ILEN, IEVENT
LOGICAL :: LLALLOC
REAL(KIND=JPRB) :: ZHOOK_HANDLE

IF (LHOOK) CALL DR_HOOK('SUALLAVT',0,ZHOOK_HANDLE)
WRITE(KULOUT,9000)'SUALLAVT - Initialization of the AVARC at level cva1'&
 & ,'Memory allocation for the trajectory-ref'  
9000 FORMAT(//,8X,A,/,17X,A)

!     1. Memory allocation

IEVENT = NHECP(0)

LLALLOC = ALLOCATED(ATRAVOR )
IF(.NOT.LLALLOC) THEN
  ILEN = NFLSUR*NSPEC2*IEVENT
  WRITE(KULOUT,*)'  SUALLAVT-  allocating ATRAVOR. Length = ',ILEN
  ALLOCATE(ATRAVOR(NFLSUR,NSPEC2,IEVENT))
ENDIF
ATRAVOR = 0.0_JPRB

LLALLOC = ALLOCATED(ATRADIV )
IF(.NOT.LLALLOC) THEN
  ILEN = NFLSUR*NSPEC2*IEVENT
  WRITE(KULOUT,*)'  SUALLAVT-  allocating ATRADIV. Length = ',ILEN
  ALLOCATE(ATRADIV(NFLSUR,NSPEC2,IEVENT))
ENDIF
ATRADIV = 0.0_JPRB

LLALLOC = ALLOCATED(ATRAT )
IF(.NOT.LLALLOC) THEN
  ILEN = NFLSUR*NSPEC2*IEVENT
  WRITE(KULOUT,*)'  SUALLAVT-  allocating ATRAT. Length = ',ILEN
  ALLOCATE(ATRAT(NFLSUR,NSPEC2,IEVENT))
ENDIF
ATRAT = 0.0_JPRB

LLALLOC = ALLOCATED(ATRAQ )
IF(.NOT.LLALLOC) THEN
  ILEN = NFLSUR*NSPEC2*IEVENT
  WRITE(KULOUT,*)'  SUALLAVT-  allocating ATRAQ. Length = ',ILEN
  ALLOCATE(ATRAQ(NFLSUR,NSPEC2,IEVENT))
ENDIF
ATRAQ = 0.0_JPRB

LLALLOC = ALLOCATED(ATRASP )
IF(.NOT.LLALLOC) THEN
  ILEN = NSPEC2*IEVENT
  WRITE(KULOUT,*)'  SUALLAVT-  allocating ATRASP. Length = ',ILEN
  ALLOCATE(ATRASP(NSPEC2,IEVENT))
ENDIF
ATRASP = 0.0_JPRB

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