!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer, 
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms 
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer 
!version 3 or (at your option) any later version that should be found at: 
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html 
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software; 
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec), 
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
!     #################################################################################

SUBROUTINE HOR_INTERPOL(KLUOUT,PFIELDIN,PFIELDOUT) 1,1
!     #################################################################################
!
!!****  *HOR_INTERPOL * - Call the interpolation of a surface field
!!
!!    PURPOSE
!!    -------
!
!!**  METHOD
!!    ------
!!
!!    REFERENCE
!!    ---------
!!      
!!
!!    AUTHOR
!!    ------
!!     V. Masson 
!!
!!    MODIFICATIONS
!!    -------------
!!      Original    01/2004
!!------------------------------------------------------------------
!

!
!
USE MODD_PREP,       ONLY : CINGRID_TYPE, CINTERP_TYPE
!
!USE MODI_HOR_INTERPOL_GAUSS
!USE MODI_HOR_INTERPOL_AROME
!
IMPLICIT NONE
!
!*      0.1    declarations of arguments
!
INTEGER,            INTENT(IN)  :: KLUOUT    ! logical unit of output listing
REAL, POINTER, DIMENSION(:,:)   :: PFIELDIN  ! field to interpolate horizontally
REAL, DIMENSION(:,:), INTENT(OUT)  :: PFIELDOUT ! interpolated field
!
!*      0.2    declarations of local variables
!
INTEGER :: JL ! loop counter
!
!-------------------------------------------------------------------------------------
!
SELECT CASE (CINTERP_TYPE)
!
!*      1.     Interpolation with horibl (from gaussian, Legendre or regular grid)
!              -------------------------------------------------------------------
!
  CASE('HORIBL')
    SELECT CASE(CINGRID_TYPE)
!
!*      1.1    Interpolation from gaussian or Legendre
!
      CASE ('GAUSS ')
!        CALL HOR_INTERPOL_GAUSS(KLUOUT,PFIELDIN,PFIELDOUT)
!
!*      1.2    Interpolation from regular grid
!
      CASE ('AROME ')
!        CALL HOR_INTERPOL_AROME(KLUOUT,PFIELDIN,PFIELDOUT)

    END SELECT
!
!*      2.     Prescribed uniform field
!              ------------------------
!
  CASE('UNIF  ')
    DO JL=1,SIZE(PFIELDIN,2)
      PFIELDOUT(:,JL) = PFIELDIN(1,JL)
    END DO
!
!*      3.     MC2GEM (already interpolated
!              ----------------------------
!
  CASE('NONE  ')
      PFIELDOUT(:,:) = PFIELDIN(:,:)

END SELECT
!
!-------------------------------------------------------------------------------------
END SUBROUTINE HOR_INTERPOL