SUBROUTINE FPINVTRCUF

! ------------------------------------------------------------------------
USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
USE YOMCT0   , ONLY : LELAM
USE YOMDIM   , ONLY : NSPEC2
USE YOMGEM   , ONLY : NGPTOT
USE YOMMCUF  , ONLY : RMCUFFP  ,NCUFNR  , &
 &                    RMCUFGP1  ,RMCUFGP2  ,RMCUFGP3  ,RMCUFGP4  ,RMCUFGP5

!**** FPINVTRCUF **** Inverse transform RMCUFGPi i=1,5 to Grid-point space 

!       Purpose:
!      ---------
!               Transform RMCUFGPi from specral space to grid-point space
!       Interface
!      ----------
!               CALL FPINVTRCUF
!       Author
!      -------
!               Rachida El Ouaraini & Ryad El Khatib 05-07-27
 

IMPLICIT NONE

REAL(KIND=JPRB) :: ZHOOK_HANDLE


#include "esperee.intfb.h"
#include "speree.intfb.h"

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

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

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

!   INITIALISATION

!   FROM SPECTARL TO GRIDr- POINT SPACE
!   RMCUFFP  : Spectral array (input)
!   RMCUFGP1 : Grid point array (output)
!   RMCUFGP2 : Grid point array (output)
!   RMCUFGP3 : Grid point array (output)
!   RMCUFGP4 : Grid point array (output)
!   RMCUFGP5 : Grid point array (output)

IF (NCUFNR >=1) THEN
  IF (LELAM)  THEN
    CALL ESPEREE(1,1,RMCUFFP(1:NSPEC2,0,1),RMCUFGP1)
  ELSE
    CALL SPEREE(1,1,RMCUFFP(1:NSPEC2,0,1),RMCUFGP1)
  ENDIF
ENDIF
IF (NCUFNR >=2) THEN
  IF (LELAM)  THEN
    CALL ESPEREE(1,1,RMCUFFP(1:NSPEC2,0,2),RMCUFGP2)
  ELSE
    CALL SPEREE(1,1,RMCUFFP(1:NSPEC2,0,2),RMCUFGP2)
  ENDIF
ENDIF
IF (NCUFNR >=3) THEN
  IF (LELAM)  THEN
    CALL ESPEREE(1,1,RMCUFFP(1:NSPEC2,0,3),RMCUFGP3)
  ELSE
    CALL SPEREE(1,1,RMCUFFP(1:NSPEC2,0,3),RMCUFGP3)
  ENDIF
ENDIF
IF (NCUFNR >=4) THEN
  IF (LELAM)  THEN
    CALL ESPEREE(1,1,RMCUFFP(1:NSPEC2,0,4),RMCUFGP4)
  ELSE
    CALL SPEREE(1,1,RMCUFFP(1:NSPEC2,0,4),RMCUFGP4)
  ENDIF
ENDIF
IF (NCUFNR >=5) THEN
  IF (LELAM)  THEN
    CALL ESPEREE(1,1,RMCUFFP(1:NSPEC2,0,5),RMCUFGP5)
  ELSE
    CALL SPEREE(1,1,RMCUFFP(1:NSPEC2,0,5),RMCUFGP5)
  ENDIF
ENDIF

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