SUBROUTINE CTONB(KDUM,YD_PU,YD_PV)

!***  *CTONB* - change to orthonormal basis

!**   Purpose.
!     --------
!            go from the initial basis to the orthonormal basis
!            (with respect to the inner product).

!**   Interface.
!     *CALL* *CTONB(KDUM,PU,PV)* (from M1QN3A)

!        Explicit arguments :
!        --------------------
!        KDUM   : dimension of the problem (not used)
!        PU     : in initial basis
!        PV     : in final basis

!        Implicit arguments :
!        --------------------
!        SCALP  : from YOMCVA

!     Method.
!     -------
!        See documentation : The modules M1QN2,N1QN2,M1QN3,N1QN3
!                            version 1.1.b (February 1989)
!                            J.C Gilbert and C. Lemarechal

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

!     Reference.
!     ----------
!        ECMWF research department documentation of the IFS

!     Author.
!     -------
!        Jean-Noel Thepaut *ECMWF*

!     Modifications.
!     --------------
!        Original : 91-09-19
!        E.Andersson : 96-08-01 - Use pre-calculated SQRT of SCALP
!        M.Hamrud    : 98-01-10 - Minimisation parallelized
!        M.Fisher    : 02-07-15 - Don't call PRECOND if LAVCGL.OR.LCONGRAD
!        Y.Tremolet  : 02-08-05 - Use control_vectors.
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

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

USE YOMCVA   , ONLY : YSCALPSQRT
USE YOMVAR   , ONLY : LMPCGL, LAVCGL, LCONGRAD
USE CONTROL_VECTORS

IMPLICIT NONE

INTEGER(KIND=JPIM)               :: KDUM ! Argument NOT used
TYPE(CONTROL_VECTOR),INTENT(IN)    :: YD_PU 
TYPE(CONTROL_VECTOR),INTENT(INOUT) :: YD_PV 
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "precond.intfb.h"

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

!*    1.  CHANGE BASIS
!         ------------

IF (LHOOK) CALL DR_HOOK('CTONB',0,ZHOOK_HANDLE)
YD_PV%data = YSCALPSQRT%data * YD_PU%data

IF (LMPCGL .AND. .NOT.(LAVCGL .OR. LCONGRAD)) CALL PRECOND(YD_PV,2)

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

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

