SUBROUTINE CHAVARIN (YDVAZX)

!**** *CHAVARIN*    - Change of Variable

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

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

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

!        *CALL* *CHAVARIN*

!        INPUT: YDVAZX

!     METHOD.
!     -------

!     EXTERNALS.
!     ----------
!           CVAR2IN

!     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_vector.
!        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 YOMJG    , ONLY : LSUBBG
USE CONTROL_VECTORS

IMPLICIT NONE
TYPE(CONTROL_VECTOR),INTENT(INOUT) :: YDVAZX 

REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"
#include "cain.intfb.h"
#include "cvar2in.intfb.h"
#include "addbgs.intfb.h"

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

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

IF     (NCNTVAR == 1)THEN
  CALL CAIN(YDVAZX)
ELSEIF (NCNTVAR == 2)THEN
  CALL CVAR2IN(YDVAZX)

!     1.    Convert X into X+Xb : add background
!           -------------------------------------

  CALL GSTATS(1844,0)
  IF (LSUBBG) CALL ADDBGS
  CALL GSTATS(1844,1)

ELSE
  CALL ABOR1(' BAD LUCK, ERROR NCNTVAR IN CHAVARIN')
ENDIF

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

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