SUBROUTINE EMPTB3(KLEVG,KWRDS,POUT,PBUF,KSTA,KEXPAND,KEXPB)

!**** *EMPTB3  *  - Copy from buffer

!     Purpose.
!     --------
!           Copy from user supplied buffer into array.
!           Update buffer pointer.

!**   Interface.
!     ----------
!        *CALL* *EMPTB3(...)*

!        Explicit arguments : 
!                             KLEVG   - number of fields
!                             KWRDS   - number of words to unpack (copy)
!                             POUT    - array to recieve unpacked data
!                             PBUF    - buffer containing (packed) data
!                             KSTA    - start adress in buffer,
!                                       updated by routine
!                             KEXPAND - packing factor (1 to 4)
!                             KEXPB   - number of bits for exponent in
!                                       packed data

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

!     Method.
!     -------
!        3D version of EMPTB

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

!     Author.
!     -------
!        Deborah Salmond  *ECMWF*

!     Modifications.
!     --------------
!        Original : 08-01-30
!     ------------------------------------------------------------------

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

IMPLICIT NONE

INTEGER(KIND=JPIM),INTENT(IN)    :: KLEVG 
INTEGER(KIND=JPIM),INTENT(IN)    :: KWRDS 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: POUT(NPROMA,KLEVG) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PBUF(:) 
INTEGER(KIND=JPIM),INTENT(INOUT) :: KSTA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KEXPAND 
INTEGER(KIND=JPIM),INTENT(IN)    :: KEXPB 
! === END OF INTERFACE BLOCK ===

INTEGER(KIND=JPIM) :: J, JLEV
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

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

DO JLEV=1,KLEVG
  DO J=1,KWRDS
    POUT(J,JLEV)=PBUF(KSTA+J-1)
  ENDDO
  KSTA=KSTA+KWRDS
ENDDO

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

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

