SUBROUTINE GRNORMA (CDPREF,KLEV,CDSUFF,PREAL,KRD,KULOUT)

!**** *GRNORMA*  - grid point norm on reduced grid for Arpege fields

!     PURPOSE.
!     --------
!        to print out the mean value of a field.

!**   INTERFACE.
!     ----------
!       *CALL* *GRNORMA*

!        EXPLICIT ARGUMENTS
!        --------------------
!           CDPREF : prefix of the field name
!           KLEV   : vertical level
!           CDSUFF : suffix of the field name
!           PREAL  : field array
!           KRD    : dimension of preal
!           KULOUT : output unit number

!        IMPLICIT ARGUMENTS
!        --------------------
!        NONE.

!     METHOD.
!     -------
!        SEE DOCUMENTATION

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

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

!     AUTHOR.
!     -------
!        RYAD EL KHATIB *METEO-FRANCE*

!     MODIFICATIONS.
!     --------------
!        ORIGINAL : 95-06-08
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        A.Alias       10-Feb-2006 Output of ZMIN and ZMAX (P. Marquet)
!     ------------------------------------------------------------------

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KRD 
CHARACTER(LEN=*)  ,INTENT(IN)    :: CDPREF 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEV 
CHARACTER(LEN=*)  ,INTENT(IN)    :: CDSUFF 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PREAL(KRD) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KULOUT 
REAL(KIND=JPRB) :: ZMEAN, ZMIN, ZMAX
INTEGER(KIND=JPIM) :: JL
REAL(KIND=JPRB) :: ZHOOK_HANDLE

!*       1. PRINT OUT MEAN VALUE
!           --------------------

IF (LHOOK) CALL DR_HOOK('GRNORMA',0,ZHOOK_HANDLE)
ZMEAN=SUM(PREAL)/REAL(KRD,JPRB)

ZMIN=PREAL(1)
ZMAX=PREAL(1)
DO JL=1,KRD
  IF (PREAL(JL) < ZMIN) ZMIN=PREAL(JL)
  IF (PREAL(JL) > ZMAX) ZMAX=PREAL(JL)
ENDDO
IF (CDPREF(1:2) == 'S ') THEN
  WRITE(UNIT=KULOUT,FMT='(''GRNORMA '',A,I3.3,A,'' : '',3(1X,E21.15) )')&
   & CDPREF,KLEV,CDSUFF,ZMIN,ZMEAN,ZMAX  
ELSE
  WRITE(UNIT=KULOUT,FMT='(''GRNORMA '',A,A,'' : '',3(1X,E21.15) )')&
   & CDPREF,CDSUFF,ZMIN,ZMEAN,ZMAX  
ENDIF

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

