SUBROUTINE CHAVAR (YDVAZX)

!**** *CHAVAR*    - Change of Variable

!     PURPOSE.
!     --------

!        Change variable :
!              NCNTVAR = 1 : identity
!              NCNTVAR = 2 : X ==> V((X-Xg)/SIGMAg)

!**   INTERFACE.
!     ----------

!        *CALL* *CHAVAR*

!        INPUT: SPA3,SPA2 of YOMSP (CORRUPTED)

!        OUTPUT: YDVAZX

!     METHOD.
!     -------

!     EXTERNALS.
!     ----------
!           CVAR2

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

!     AUTHOR.
!     -------
!        J.N.THEPAUT and P.COURTIER   *ECMWF*

!     MODIFICATIONS.
!     --------------
!        Bill Heckley 22/09/92 Additional choice of control variable
!        M.Hamrud     15/12/95 Remove NCNTVAR=3
!        Y.Tremolet   05/08/02 Use control_vectors.
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        M.Hamrud      01-Dec-2003 CY28R1 Cleaning
!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMCT0 , ONLY: NCNTVAR
USE CONTROL_VECTORS

IMPLICIT NONE
TYPE(CONTROL_VECTOR),INTENT(INOUT) :: YDVAZX 
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
#include "cainin.intfb.h"
#include "cvar2.intfb.h"

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

IF (LHOOK) CALL DR_HOOK('CHAVAR',0,ZHOOK_HANDLE)


IF (NCNTVAR == 1) THEN
  CALL CAININ(YDVAZX)
ELSEIF (NCNTVAR == 2) THEN
  CALL CVAR2(YDVAZX)
ELSE
  CALL ABOR1(' BAD LUCK, ERROR NCNTVAR IN CHAVAR')
ENDIF

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

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