SUBROUTINE MXMAOP(PA,KA,KAD,PB,KB,KBD,PC,KC,KCA,KAR,KAC,KBC)

!**** *MXMAOP - Optimize call to SGEMMX

!     Purpose.
!     --------
!        Make sure SGEMMX is called in a way to insure maximum optimization.

!**   Interface.
!     ----------
!        CALL MXMAOP(PA,KA,KAD,PB,KB,KBD,PC,KC,KCA,KAR,KAC,KBC)

!        Explicit arguments : See SGEMMX documentaion.
!        --------------------

!        Implicit arguments :
!        --------------------

!     Method.
!     -------

!     Externals.   SGEMMX in Cray library.
!     ----------

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

!     Author.
!     -------
!        Mats Hamrud and Philippe Courtier  *ECMWF*

!     Modifications.
!     --------------
!        Original : 88-01-28
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

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

IMPLICIT NONE

REAL(KIND=JPRB)   ,INTENT(IN)    :: PA(1) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KAD 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PB(1) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KB 
INTEGER(KIND=JPIM),INTENT(IN)    :: KBD 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PC(2) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KC 
INTEGER(KIND=JPIM),INTENT(IN)    :: KCA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KAR 
INTEGER(KIND=JPIM),INTENT(IN)    :: KAC 
INTEGER(KIND=JPIM),INTENT(IN)    :: KBC 
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

!*       1.       PERFORM LEGENDRE TRANFORM.
!                 --------------------------
IF (LHOOK) CALL DR_HOOK('MXMAOP',0,ZHOOK_HANDLE)
IF (KAR >= KBC) THEN
  CALL SGEMMX(KAR,KBC,KAC,1.0_JPRB,PA,KA,KAD,PB,KB,KBD,0.0_JPRB,PC,KC,KCA)
ELSE
  CALL SGEMMX(KBC,KAR,KAC,1.0_JPRB,PB,KBD,KB,PA,KAD,KA,0.0_JPRB,PC,KCA,KC)
ENDIF

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

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

