SUBROUTINE PROSCA (KDUM,YD_PX,YD_PY,PSC)

!***  *PROSCA* - Scalar product for the minimization

!**   Purpose.
!     --------
!            Calculate the scalar product for the minimization

!**   Interface.
!     *CALL* *PROSCA (KDUM,Px,Py,PSC)* (from M1QN3A)

!        Explicit arguments :
!        --------------------
!        KDUM   : (input)  The dimension of the problem (not used in CTONB)
!        PX     : (input)  A vector
!        PY     : (input)  Another vector
!        PSC    : (output) <PX,PY>

!        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.
!     ----------
!        CTONB

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

!     Author.
!     -------
!        Mike Fisher *ECMWF*

!     Modifications.
!     --------------
!        Original : 2001-02-27
!        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 CONTROL_VECTORS

IMPLICIT NONE

INTEGER(KIND=JPIM)               :: KDUM ! Argument NOT used
TYPE(CONTROL_VECTOR),INTENT(IN)    :: YD_PX 
TYPE(CONTROL_VECTOR),INTENT(IN)    :: YD_PY 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSC 
TYPE(control_vector) :: YL_PU, YL_PV
INTEGER(KIND=JPIM) :: IDUM = -999
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "ctonb.intfb.h"

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

IF (LHOOK) CALL DR_HOOK('PROSCA',0,ZHOOK_HANDLE)
CALL ALLOCATE_CTLVEC(YL_PU)
CALL ALLOCATE_CTLVEC(YL_PV)

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

CALL CTONB (IDUM,YD_PX,YL_PU)
CALL CTONB (IDUM,YD_PY,YL_PV)

PSC = DOT_PRODUCT (YL_PU,YL_PV)

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

CALL DEALLOCATE_CTLVEC(YL_PU)
CALL DEALLOCATE_CTLVEC(YL_PV)

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