SUBROUTINE IRCVGPF(PRCV,PFLD,KRCV)

!     Purpose.
!     --------
!     Receive this processors part of a distributed input grid point
!     field

!     Explicit arguments :
!     --------------------
!       PRCV   : grid point field to receive
!       PFLD   : if nproc is 1 then PFLD is the distributed field
!       KRCV   : processor we want to receive from

!     Author.
!     -------
!        MPP Group *ECMWF*

!     Modifications.
!     --------------
!        Original : 96-03-19
!        Modified : 00-09-01 by D.Dent : MPE to MPL conversion
!                   01-01-19 Y.Tremolet: cleaning
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!     ------------------------------------------------------------------

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

USE YOMMP    , ONLY : NPRCIDS
USE YOMTAG   , ONLY : MTAGDISTGP
USE YOMCT0   , ONLY : NPROC
USE YOMGEM   , ONLY : NGPTOT   ,NGPTOTMX
USE MPL_MODULE

IMPLICIT NONE

REAL(KIND=JPRB)   ,INTENT(OUT)   :: PRCV(NGPTOT) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PFLD(NGPTOTMX) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KRCV 
INTEGER(KIND=JPIM) :: ILEN, ITAG, J
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "abor1.intfb.h"

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

IF (LHOOK) CALL DR_HOOK('IRCVGPF',0,ZHOOK_HANDLE)
CALL GSTATS(527,0)
IF( NGPTOT > 0 )THEN
  ITAG=MTAGDISTGP
  IF( NPROC > 1 )THEN
    CALL MPL_RECV(PRCV(1:NGPTOT),KSOURCE=NPRCIDS(KRCV),KTAG=ITAG, &
     & KOUNT=ILEN,CDSTRING='IRCVGPF:')  
  ELSE
    ILEN=NGPTOT
    DO J=1,ILEN
      PRCV(J)=PFLD(J)
    ENDDO
  ENDIF
  IF( ILEN /= NGPTOT )THEN
    CALL ABOR1(' IRCVGPF: INVALID RECEIVE MESSAGE LENGTH')
  ENDIF
ENDIF
CALL GSTATS(527,1)

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