SUBROUTINE SPNORMBM(PX,PSN,PSM,KLEV,PMET,KFLEV,KFLSUR,LDNWAVE)

!**** *SPNORMBM* - Compute norms in spectral space, arpifs/aladin interface

!     Purpose.
!     --------
!        Compute the norm in spectral space

!**   Interface.
!     ----------
!        *CALL* *SPNORMBM(PX,PSN,PSM,KLEV,PMET,KFLEV,KFLSUR,LDNWAVE)

!        Explicit arguments :
!        --------------------
!        PX      : Input array
!        PSN     : spectrum at constant n
!        PSM     : spectrum at constant m
!        KLEV    : number of levels of computation
!        PMET    : Metric
!        KFLEV   : first dimensioning of output arrays.
!        KFLSUR  : first dimensioning of input array.
!        LDNWAVE : .TRUE. to compute spectrum at constant n

!        Implicit arguments :  none.
!        --------------------

!     Method.
!     -------

!     Externals.
!     ----------
!      Calls SPNORMB.
!      Called by SPNORMBE and SPNORMBL.

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

!     Author.
!     -------
!        Philippe Courtier  *ECMWF*

!     Modifications.
!     --------------
!        Original : 92-12-20
!        Modified : 95-06-06 L.Isaksen   Reordering of spectral arrays
!      R. El Khatib 99-02-09 LDNWAVE ; overdimension NSPECG for PMET ; case LELAM
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!      R. El Khatib 99-02-09 :Reduce overhead of call by moving loops insidei
!                             inner the inner routines
!     ------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMDIM   , ONLY : NUMP
USE YOMCT0   , ONLY : LELAM

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KFLEV 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFLSUR 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PX(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSN(:,:) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSM(:,:) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PMET(:) 
LOGICAL           ,INTENT(IN)    :: LDNWAVE 

REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "espnormb.intfb.h"
#include "spnormb.intfb.h"

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

!*       1.    CALL SPNORMB.
!              -------------

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

CALL GSTATS(1048,0)

IF (.NOT.LELAM) THEN
  CALL SPNORMB(PX,KLEV,PSN,PSM,PMET,KFLEV,KFLSUR,LDNWAVE)
ELSE
  CALL ESPNORMB(PX,KLEV,PSN,PSM,PMET,KFLEV,KFLSUR,LDNWAVE)
ENDIF

CALL GSTATS(1048,1)

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

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