*IF DEF,C92_1A                                                             HORLIN1A.2      
C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved.    GTS2F400.15388  
C                                                                          GTS2F400.15389  
C Use, duplication or disclosure of this code is subject to the            GTS2F400.15390  
C restrictions as set forth in the contract.                               GTS2F400.15391  
C                                                                          GTS2F400.15392  
C                Meteorological Office                                     GTS2F400.15393  
C                London Road                                               GTS2F400.15394  
C                BRACKNELL                                                 GTS2F400.15395  
C                Berkshire UK                                              GTS2F400.15396  
C                RG12 2SZ                                                  GTS2F400.15397  
C                                                                          GTS2F400.15398  
C If no contract has been raised with this copy of the code, the use,      GTS2F400.15399  
C duplication or disclosure of it is strictly prohibited.  Permission      GTS2F400.15400  
C to do so must first be obtained in writing from the Head of Numerical    GTS2F400.15401  
C Modelling at the above address.                                          GTS2F400.15402  
C ******************************COPYRIGHT******************************    GTS2F400.15403  
C                                                                          GTS2F400.15404  

      SUBROUTINE HorizontalInterpLinear                                     2HORLIN1A.3      
     &              (LowerBound,                                           HORLIN1A.4      
     &               Len1In,  Len2In,                                      HORLIN1A.5      
     &               Len1Out, Len2Out,                                     HORLIN1A.6      
     &               DataExt,                                              HORLIN1A.7      
     &               WtLambda,                                             HORLIN1A.8      
     &               WtPhi,                                                HORLIN1A.9      
     &               IOut,                                                 HORLIN1A.10     
     &               JOut,                                                 HORLIN1A.11     
     &               DataOut)                                              HORLIN1A.12     
!                                                                          HORLIN1A.13     
! Description: Performs linear interpolation of a 2-d field to a 2-d       HORLIN1A.14     
!              set of points defined by IOut, JOut and WtLambda,           HORLIN1A.15     
!              WtPhi.                                                      HORLIN1A.16     
!                                                                          HORLIN1A.17     
! Method: This is a modified version of the routine tri_linear written     HORLIN1A.18     
!         by Mark Mawson and described in:                                 HORLIN1A.19     
!                                                                          HORLIN1A.20     
!                The proposed semi-Lagrangian advection scheme for the     HORLIN1A.21     
!                   semi-Implicit Unified Model integration scheme.        HORLIN1A.22     
!                         F.R. Division working paper No 162.              HORLIN1A.23     
!                                    Mark H. Mawson                        HORLIN1A.24     
!                                                                          HORLIN1A.25     
!                                                                          HORLIN1A.26     
! Owner: Stuart Bell                                                       HORLIN1A.27     
!                                                                          HORLIN1A.28     
! History:                                                                 HORLIN1A.29     
! Version   Date     Comment                                               HORLIN1A.30     
! -------   ----     -------                                               HORLIN1A.31     
!   4.0   6/6/95   Equiv. to VAR code as at time of build:Stuart Bell      HORLIN1A.32     
!                                                                          HORLIN1A.33     
! Code Description:                                                        HORLIN1A.34     
!   Language:           Fortran 77 plus                                    HORLIN1A.35     
!   Software Standards: "UM and Met O standards".                          HORLIN1A.36     
!                                                                          HORLIN1A.37     
!                                                                          HORLIN1A.38     
! Declarations:                                                            HORLIN1A.39     
                                                                           HORLIN1A.40     
        IMPLICIT NONE                                                      HORLIN1A.41     
                                                                           HORLIN1A.42     
!* Subroutine arguments                                                    HORLIN1A.43     
! Scalar arguments with INTENT(in):                                        HORLIN1A.44     
        INTEGER     LowerBound    ! lower bounds of DataExt                HORLIN1A.45     
        INTEGER     Len1In    ! Dimension of DataIn in i direction.        HORLIN1A.46     
        INTEGER     Len2In    ! Dimension of DataIn in j direction.        HORLIN1A.47     
        INTEGER     Len1Out   ! Dimension of DataOut in i direction.       HORLIN1A.48     
        INTEGER     Len2Out   ! Dimension of DataOut in j direction.       HORLIN1A.49     
                                                                           HORLIN1A.50     
! Array  arguments with INTENT(in):                                        HORLIN1A.51     
        INTEGER     IOut (Len1Out,Len2Out)   ! Point such that             HORLIN1A.52     
        INTEGER     JOut (Len1Out,Len2Out)   ! the desired output point    HORLIN1A.53     
!                                            ! lies between it and it+1.   HORLIN1A.54     
        REAL   DataExt(LowerBound:Len1In+1-LowerBound,                     HORLIN1A.55     
     &          LowerBound:Len2In+1-LowerBound)  ! Data interpolated       HORLIN1A.56     
        REAL   WtLambda (Len1Out,Len2Out)   ! A number between 0 & 1.      HORLIN1A.57     
        REAL   WtPhi (Len1Out,Len2Out)      ! A number between 0 & 1.      HORLIN1A.58     
                                                                           HORLIN1A.59     
! Array  arguments with INTENT(out):                                       HORLIN1A.60     
        REAL    DataOut (Len1Out,Len2Out)    ! Data interpolated to        HORLIN1A.61     
!                                            ! desired locations.          HORLIN1A.62     
                                                                           HORLIN1A.63     
!* End of Subroutine arguments                                             HORLIN1A.64     
                                                                           HORLIN1A.65     
! Local scalars:                                                           HORLIN1A.66     
        INTEGER             i                 ! } Loop                     HORLIN1A.67     
        INTEGER             j                 ! } indices.                 HORLIN1A.68     
!- End of header -------------------------------------------------------   HORLIN1A.69     
                                                                           HORLIN1A.70     
!  1.0   Perform linear interpolation in i and j  simultaneously.          HORLIN1A.71     
! ----------------------------------------------------------------------   HORLIN1A.72     
        DO j = 1, Len2Out                                                  HORLIN1A.73     
         DO i = 1, Len1Out                                                 HORLIN1A.74     
                                                                           HORLIN1A.75     
        DataOut (i,j)= (1.0 - WtLambda(i,j))                               HORLIN1A.76     
     &               * (1.0 - WtPhi(i,j))                                  HORLIN1A.77     
     &               * DataExt (IOut(i,j), JOut(i,j))                      HORLIN1A.78     
     &              +                                                      HORLIN1A.79     
     &                 WtLambda(i,j)                                       HORLIN1A.80     
     &               * (1.0 - WtPhi(i,j))                                  HORLIN1A.81     
     &               * DataExt (IOut(i,j) + 1, JOut(i,j))                  HORLIN1A.82     
     &              +                                                      HORLIN1A.83     
     &                 (1.0 - WtLambda(i,j))                               HORLIN1A.84     
     &               * WtPhi(i,j)                                          HORLIN1A.85     
     &               * DataExt (IOut(i,j), JOut(i,j) + 1)                  HORLIN1A.86     
     &              +                                                      HORLIN1A.87     
     &                 WtLambda(i,j)                                       HORLIN1A.88     
     &               * WtPhi(i,j)                                          HORLIN1A.89     
     &               * DataExt (IOut(i,j) + 1, JOut(i,j) + 1)              HORLIN1A.90     
                                                                           HORLIN1A.91     
         END DO      ! Close i loop                                        HORLIN1A.92     
        END DO       ! Close j loop                                        HORLIN1A.93     
                                                                           HORLIN1A.94     
! End of routine.                                                          HORLIN1A.95     
      RETURN                                                               HORLIN1A.96     
      END                                                                  HORLIN1A.97     
*ENDIF                                                                     HORLIN1A.98