      !***********************************************************************!
      SUBROUTINE  nrmerr(  gnrm2,  gnrmoo,  u,  u_exact,  tps,  comm3d  )
      !***********************************************************************!
!
      USE MPI
!
      USE numerics
!
      IMPLICIT  NONE
!
      INCLUDE 'comthd.h'
!
      INTERFACE
!
      INCLUDE    'i_fctut.h'
!
      END INTERFACE
!Solution  u  a  l'instant tps
      REAL(rp),  DIMENSION(  sx-1:ex+1,  sy-1:ey+1,  sz-1:ez+1),  INTENT(IN)  ::  u
!
!Solution exacte
      REAL(rp),  DIMENSION(  sx-1:ex+1,  sy-1:ey+1,  sz-1:ez+1),  INTENT(IN)  ::  u_exact
!
!Norme L2,   solution et erreur
      REAL(rp),  DIMENSION(2),  INTENT(OUT)  ::  gnrm2
!
!Norme Loo,  solution
      REAL(rp),  DIMENSION(2),  INTENT(OUT)  ::  gnrmoo
!
!Instant courant
      REAL(rp),  INTENT(IN)   ::  tps
!
! communicateur
      INTEGER,   INTENT(IN)   ::  comm3d
!
!--Declaration des variales locales
!
!Composante temporelle
      REAL(rp)  ::  ut
!
      REAL(rp)  ::  rnrm2, rerr2
      REAL(rp)  ::  rnrmoo, rerroo
!
!Tableau intermediaire
      REAL(rp),  DIMENSION(2)  ::  lnrm2  = zero
      REAL(rp),  DIMENSION(2)  ::  lnrmoo = zero
!
!Compteurs
      INTEGER   ::  i,  j,  k
!
      !***********************************************************************!
!
!$OMP MASTER
      DO  i  =  1,  2
         lnrm2(i)  = zero
         lnrmoo(i) = zero
      END DO
!$OMP END MASTER
!
!$OMP BARRIER
!
      CALL fctut( tps, ut )
!
      rnrm2 = zero
      rerr2 = zero
      rnrmoo = zero
      rerroo = zero
!
!Calcul des quantites L2 et Loo
      DO  k  =  kmin,  kmax
         DO  j  =  sy,  ey
            DO  i  =  sx,  ex
               rnrm2  = rnrm2 + u(i,j,k)**2
               rerr2  = rerr2 + ( u(i,j,k) - ut * u_exact(i,j,k) ) **2
               rnrmoo = MAX( rnrmoo, ABS( u(i,j,k) ) )
               rerroo = MAX( rerroo, ABS( u(i,j,k) - ut * u_exact(i,j,k) ) )
            END  DO
         END  DO
      END  DO
!
!$OMP CRITICAL
      lnrm2(1)  = lnrm2(1) + rnrm2
      lnrm2(2)  = lnrm2(2) + rerr2
      lnrmoo(1) = MAX( lnrmoo(1), rnrmoo )
      lnrmoo(2) = MAX( lnrmoo(2), rerroo )
!$OMP END CRITICAL
!
!$OMP BARRIER
!
!$OMP MASTER
      CALL  MPI_ALLREDUCE(  lnrm2,   gnrm2,   2,  ITYPE_REAL,  &
                            MPI_SUM,  comm3d,  ierr  )
!
      CALL  MPI_ALLREDUCE(  lnrmoo,  gnrmoo,  2,  ITYPE_REAL,  &
                            MPI_MAX,  comm3d,  ierr  )
!
     gnrm2(1:2) = SQRT( gnrm2(1:2) / ( REAL(ntx, rp) * REAL(nty, rp) * REAL(ntz, rp ) ) )
!
!$OMP END MASTER
!
      RETURN
      END  SUBROUTINE  nrmerr
