SUBROUTINE RDPHTRSF (KSTEP,KSTA,KEND,KJUMP,KFIELDS,PQS,PTS,PSNS )

!**** *RDPHTRSF* - Read out the trajectory for surface arrays 
!                  from work file

!     Purpose.  Read out the trajectory for surface arrays 
!     --------  from work file

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

!        Explicit arguments :  KSTEP - time step              (input)
!        --------------------  KSTA    - start adress         (input)
!                              KEND    - end adress           (input)
!                              KJUMP   - offset into gp array (input)
!                              KFIELDS - number of fields     (input)

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

!     Method.
!     -------

!     -------

!     Externals. EMPTB - interface to packing routines
!     ---------- 

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

!     Author.
!     -------
!      M. Janiskova

!     Modifications.
!     --------------
!        Original : 96-12-10
!        Modified :
!           97-05-05, adapted for message passing
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!        M.Hamrud      10-Jan-2004 CY28R1 Cleaning

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

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMDIM   , ONLY : NPROMA
USE YOMTPHY  , ONLY : NLENGTS5B,TRAJPHSF
USE YOMIOP   , ONLY : NPCKFTS5 ,NEXPBTS5

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

IMPLICIT NONE

! * DUMMY:
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTEP 
INTEGER(KIND=JPIM),INTENT(IN)    :: KSTA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KEND 
INTEGER(KIND=JPIM),INTENT(IN)    :: KJUMP 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFIELDS 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PQS(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PTS(NPROMA) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PSNS(NPROMA) 
INTEGER(KIND=JPIM) :: ILEN, ILENB, ISTAGPB, IWORDS
REAL(KIND=JPRB) :: ZHOOK_HANDLE

#include "emptb.intfb.h"

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

!*       1.    READ OUT GRIDPOINT ARRAY.
!              --------------------------

!*       1.1       CALCULATE LENGTHS

IF (LHOOK) CALL DR_HOOK('RDPHTRSF',0,ZHOOK_HANDLE)
ILEN   = NPROMA*KFIELDS
IWORDS = KEND-KSTA+1

!*       1.2       WRITE OUT BUFFER

ISTAGPB = 1+(KJUMP-1)*KFIELDS
ILENB   = NLENGTS5B

!        1.3       SURFACE 2D FIELDS

CALL EMPTB(IWORDS,PQS(KSTA),TRAJPHSF(:,KSTEP),&
 & ILENB,ISTAGPB,NPCKFTS5,NEXPBTS5)  
CALL EMPTB(IWORDS,PTS(KSTA),TRAJPHSF(:,KSTEP),&
 & ILENB,ISTAGPB,NPCKFTS5,NEXPBTS5)  
CALL EMPTB(IWORDS,PSNS(KSTA),TRAJPHSF(:,KSTEP),&
 & ILENB,ISTAGPB,NPCKFTS5,NEXPBTS5)  

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

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

