SUBROUTINE TRANSDIR_FP(PGP)

!**** *TRANSDIR_FP * - Direct transforms for Full-Pos

!     Purpose.  Perform direct transform (gridpoint to spectral)
!     --------

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

!     Explicit arguments : 
!     --------------------
!        PGP    - gridpoint fields

!        Called by TRANSDIRH

!     Externals.
!     ----------
!     DIR_TRANS - inverse transform (TRANS library)

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

!     Author.
!     -------
!        Mats Hamrud *ECMWF*

!     Modifications.
!     --------------
!        Original : 00-10-25
!    R. El Khatib : 01-03-28 More appropriate ordering
!    R. El Khatib : 02-21-20 Fullpos B-level distribution + remove IO scheme
!    R. El Khatib : 03-04-17 Fullpos improvments
!        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 : NSPEC2   ,NPROMA
USE YOMFPDIM , ONLY : NFPSCA   ,NFPVEC   ,NFPSCAG  ,NFPVECG

IMPLICIT NONE

REAL(KIND=JPRB)                  :: PGP(:,:,:) ! UNDETERMINED INTENT
REAL(KIND=JPRB) :: ZSPSCA(NFPSCA,NSPEC2), ZSPVOR(NFPVEC,NSPEC2), ZSPDIV(NFPVEC,NSPEC2)

INTEGER(KIND=JPIM) :: IVSETSC(NFPSCAG), IVSETVD(NFPVECG)
REAL(KIND=JPRB) :: ZHOOK_HANDLE

INTERFACE
#include "dir_trans.h"
END INTERFACE

#include "fptsa_dir.intfb.h"
#include "sufpvset_dir.intfb.h"

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

!    1. Setups

IF (LHOOK) CALL DR_HOOK('TRANSDIR_FP',0,ZHOOK_HANDLE)
CALL SUFPVSET_DIR(IVSETSC,IVSETVD)

!    2. Spectral transforms

IF (NFPSCAG > 0 .AND. NFPVECG > 0) THEN
  CALL DIR_TRANS(PSPVOR=ZSPVOR(:,:),PSPDIV=ZSPDIV(:,:),PSPSCALAR=ZSPSCA(:,:),&
   & KPROMA=NPROMA,KVSETUV=IVSETVD(:),KVSETSC=IVSETSC(:),PGP=PGP(:,:,:))  
ELSEIF (NFPSCAG > 0 ) THEN
  CALL DIR_TRANS(PSPSCALAR=ZSPSCA(:,:),KPROMA=NPROMA,KVSETSC=IVSETSC(:),&
   & PGP=PGP(:,:,:))  
ELSEIF (NFPVECG > 0) THEN
  CALL DIR_TRANS(PSPVOR=ZSPVOR(:,:),PSPDIV=ZSPDIV(:,:),KPROMA=NPROMA,&
   & KVSETUV=IVSETVD(:),PGP=PGP(:,:,:))  
ENDIF

!    3. Transfer to the post-processing spectral arrays

CALL GSTATS(1992,0)
CALL FPTSA_DIR(PSCA=ZSPSCA(:,:),PVOR=ZSPVOR(:,:),PDIV=ZSPDIV(:,:))
CALL GSTATS(1992,1)

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

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