SUBROUTINE SUHOWLSM(KDGSA,KDGEN,KFRSTLOFF,PLATIN,KAFPB,PTMERGL,PTSIN,&
 & PLSMIN,PTSOUT,PLSMOUT,KLSIM,KBINL,KLEN,KLA,KL0,PDLAT,PDLO,PDLO1,PDLO2,&
 & PDLO3,PWXX)  

!**** *SUHOWLSM* - Compute the weights of nearest points.
!****
!****            Possibility to use the land/sea/ice mask

!     Purpose.
!     -------
!       Determines the weights for 12 points interpolations or
!       bilinear interpolations for FULL-POS fields.
!       Same as SUHOW2 but possibility of using the land/sea/ice mask.
!       Numbering of the points (I is the interpolation point):
!                     13       5       6      14

!                      7       1       2       8
!                                 (I)
!                      9       3       4      10

!                     15      11      12      16
!       Points number 1 to 12 are used if 12 points interpolations.
!       Points number 1 to 4 are used if bilinear interpolations.
!       - computation of weights.
!       Storage of coordinates and weights.

!       For distributed memory SUHOWLSM is executed locally on each processor
!       (iproca,iprocb).
!       Abbreviation DM-global means 'variable global for all processors'.
!       Abbreviation DM-local means 'variable local for each processor
!        iproca and iprocb'.

!**   Interface.
!**   ---------
!**   CALL SUHOWLSM(...)
!**
!        Explicit arguments :
!        --------------------

!     INPUT:
!      KDGSA     : Lower DM-locally numbered latitude 'jgl' involved.
!                  (DM-local).
!      KDGEN     : Upper DM-locally numbered latitude 'jgl' involved.
!                  (DM-local).
!      KFRSTLOFF : Difference 'DM-global numbering of latitudes' -
!                  'DM-local numbering of latitudes'
!                  KFRSTLOFF=0 if not distributed memory.
!                  (DM-local).
!      PLATIN    : Gaussian/Lobatto latitudes.
!                  (DM-global, but only elements KDGSA+KFRSTLOFF to
!                  KDGEN+KFRSTLOFF are provided here).
!      KAFPB     : horizontal dimension of a field in the buffer.
!                  (DM-local).
!      PTMERGL   : Melting temperature of floating ice.
!                  (DM-global).
!      PTSIN     : Interpolation buffer containing surface temperature.
!                  (DM-local).
!      PLSMIN    : Interpolation buffer containing land/sea mask.
!                  (DM-local).
!      PTSOUT    : Interpolated surface temperature.
!                  (DM-local).
!      PLSMOUT   : Interpolated surface land/sea mask.
!                  (DM-local).
!      KLSIM     : Options of land/sea/ice mask:
!                  = 0 ==> no use of l/s/i mask
!                  = 1 ==> use of l/s mask
!                  = 2 ==> use of l/s/i mask
!                  (DM-global). 
!      KBINL     : Options for choice of interpolations:
!                  = 12 ==> 12 points interpolation
!                  =  4 ==> bilinear interpolation
!                  (DM-global).
!      KLEN      : Length of output vector, to which data are interpolated.
!                  (DM-local). 
!      KLA       : Latitude index of the point numbered 1
!                  (DM-local).
!      KL0       : index of the four western point (numbered 13, 7, 9, 15)
!                  of the 16 points interpolation grid.
!                  (DM-local).
!      PDLAT     : Meridian linear weight.
!                  (DM-local).
!      PDLO      : Zonal linear weight for the latitude of point 5.
!                  (DM-local).
!      PDLO1     : Zonal linear weight for the latitude of point 1.
!                  (DM-local).
!      PDLO2     : Zonal linear weight for the latitude of point 3.
!                  (DM-local).
!      PDLO3     : Zonal linear weight for the latitude of point 11.
!                  (DM-local).

!     OUTPUT:
!      PWXX      : Weights array.
!                  (DM-local).
!        Implicit arguments :
!        --------------------
!        none

!     Method.
!     -------
!        See documentation about FULL-POS.

!     Externals.
!     ----------

!        No external.
!        Called by SUFPWFPBUF.

!     Reference.
!     ----------

!     Author.
!     -------
!     Author : K. YESSAD after routine SUHOW.
!     Date   : MARCH 1997

!     Modifications
!     -------------
!        K.YESSAD : (AUGUST 1997):
!          - cleaning for cy18: corrections or removal of false comments.
!        Modified 98-08-10 by K. YESSAD: removal of LRPOLE option.
!         -> dummy arguments LDPOLMODEL,LDPOLFPOS become always .false. and
!            disappear, dummy argument KDGLG becomes useless and disappears.
!        J.Boutahar 2000-03-01 New treatment of the Lakes in Fullpos
!        R. El Khatib 01-06-14 LFPLAKE => NFPLAKE
!        M.Hamrud      01-Oct-2003 CY28 Cleaning
!----------------------------------------------------------------------------

USE PARKIND1  ,ONLY : JPIM     ,JPRB
USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK

IMPLICIT NONE

!     DUMMY:
INTEGER(KIND=JPIM),INTENT(IN)    :: KDGSA 
INTEGER(KIND=JPIM),INTENT(IN)    :: KDGEN 
INTEGER(KIND=JPIM),INTENT(IN)    :: KFRSTLOFF 
INTEGER(KIND=JPIM),INTENT(IN)    :: KAFPB 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLEN 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLATIN(KDGSA+KFRSTLOFF:KDGEN+KFRSTLOFF) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTMERGL 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTSIN(KAFPB) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLSMIN(KAFPB) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PTSOUT(KLEN) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PLSMOUT(KLEN) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLSIM 
INTEGER(KIND=JPIM),INTENT(IN)    :: KBINL 
INTEGER(KIND=JPIM),INTENT(IN)    :: KLA(KLEN) 
INTEGER(KIND=JPIM),INTENT(IN)    :: KL0(KLEN,0:3) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDLAT(KLEN) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDLO(KLEN) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDLO1(KLEN) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDLO2(KLEN) 
REAL(KIND=JPRB)   ,INTENT(IN)    :: PDLO3(KLEN) 
REAL(KIND=JPRB)   ,INTENT(OUT)   :: PWXX(KLEN,KBINL) 
INTEGER(KIND=JPIM) :: ILA1G, ILA2G, ILA3G, ILAG, IMKIN1, IMKIN10,&
 & IMKIN11, IMKIN12, IMKIN2, IMKIN3, IMKIN4, &
 & IMKIN5, IMKIN6, IMKIN7, IMKIN8, IMKIN9, IMKOUT, &
 & JLEN  

REAL(KIND=JPRB) :: ZCXN, ZCXNN, ZCXS, ZCXSS, ZCY, ZDLAT, ZDLO,&
 & ZDLO1, ZDLO2, ZDLO3, ZDY, ZDY10, ZDY21, ZDY32, &
 & ZEPSIL, ZWLSI1, ZWLSI10, ZWLSI11, ZWLSI12, &
 & ZWLSI13, ZWLSI14, ZWLSI15, ZWLSI16, ZWLSI17, &
 & ZWLSI2, ZWLSI3, ZWLSI4, ZWLSI5, ZWLSI6, ZWLSI7, &
 & ZWLSI8, ZWLSI9, ZWXN, ZWXN0, ZWXN1, ZWXN2, &
 & ZWXN3, ZWXNN, ZWXS, ZWXS0, ZWXS1, ZWXS2, &
 & ZWXS3, ZWXSS, ZWY, ZWY0, ZWY1, ZWY2, ZWY3  
REAL(KIND=JPRB) :: ZHOOK_HANDLE

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

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

ZEPSIL=1.E-5_JPRB


!*       1. WEIGHTS FOR BILINEAR INTERPOLATION.
!           -----------------------------------

IF (KBINL == 4) THEN

  DO JLEN = 1,KLEN

!          * Preliminary initialisation of ZWLSI1 to ZWLSI4, ZWLSI14, ZWLSI15,
!            ZWLSI17.

    ZWLSI1=1._JPRB
    ZWLSI2=1._JPRB
    ZWLSI3=1._JPRB
    ZWLSI4=1._JPRB

    ZWLSI14=0._JPRB
    ZWLSI15=0._JPRB
    ZWLSI17=0._JPRB


!          * Modification of ZWLSI1 to ZWLSI4, ZWLSI14, ZWLSI15,
!            ZWLSI17 according to value of the land/sea/ice mask.

    IF ( KLSIM  /=  0 ) THEN

      IMKOUT=NINT(PLSMOUT(JLEN))
      IF(IMKOUT == 0)THEN
        IMKOUT=1
        IF(PTSOUT(JLEN) <= PTMERGL.AND.KLSIM == 2) IMKOUT=2
      ELSE
        IMKOUT=3
      ENDIF

      IMKIN1=NINT(PLSMIN(KL0(JLEN,1)+1))
      IF(IMKIN1 == 0)THEN
        IMKIN1=1
        IF(PTSIN(KL0(JLEN,1)+1) <= PTMERGL.AND.KLSIM == 2)IMKIN1=2
      ELSE
        IMKIN1=3
      ENDIF

      IMKIN2=NINT(PLSMIN(KL0(JLEN,1)+2))
      IF(IMKIN2 == 0)THEN
        IMKIN2=1
        IF(PTSIN(KL0(JLEN,1)+2) <= PTMERGL.AND.KLSIM == 2)IMKIN2=2
      ELSE
        IMKIN2=3
      ENDIF

      IMKIN3=NINT(PLSMIN(KL0(JLEN,2)+1))
      IF(IMKIN3 == 0)THEN
        IMKIN3=1
        IF(PTSIN(KL0(JLEN,2)+1) <= PTMERGL.AND.KLSIM == 2)IMKIN3=2
      ELSE
        IMKIN3=3
      ENDIF

      IMKIN4=NINT(PLSMIN(KL0(JLEN,2)+2))
      IF(IMKIN4 == 0)THEN
        IMKIN4=1
        IF(PTSIN(KL0(JLEN,2)+2) <= PTMERGL.AND.KLSIM == 2)IMKIN4=2
      ELSE
        IMKIN4=3
      ENDIF

      IF(IMKIN1 /= IMKOUT) ZWLSI1=0.0_JPRB
      IF(IMKIN2 /= IMKOUT) ZWLSI2=0.0_JPRB
      IF(IMKIN3 /= IMKOUT) ZWLSI3=0.0_JPRB
      IF(IMKIN4 /= IMKOUT) ZWLSI4=0.0_JPRB

    ENDIF

    ZWLSI14=MIN(ZWLSI1+ZWLSI2,1.0_JPRB)
    ZWLSI15=MIN(ZWLSI3+ZWLSI4,1.0_JPRB)
    ZWLSI17=MIN(ZWLSI14+ZWLSI15,1.0_JPRB)

!          * Definite values for ZWLSI1 to ZWLSI4, ZWLSI14 and ZWLSI15.

    ZWLSI1=1.0_JPRB-INT(ZWLSI14+ZEPSIL)*(1.0_JPRB-ZWLSI1)
    ZWLSI2=1.0_JPRB-INT(ZWLSI14+ZEPSIL)*(1.0_JPRB-ZWLSI2)
    ZWLSI3=1.0_JPRB-INT(ZWLSI15+ZEPSIL)*(1.0_JPRB-ZWLSI3)
    ZWLSI4=1.0_JPRB-INT(ZWLSI15+ZEPSIL)*(1.0_JPRB-ZWLSI4)

    ZWLSI14=1.0_JPRB-INT(ZWLSI17+ZEPSIL)*(1.0_JPRB-ZWLSI14)
    ZWLSI15=1.0_JPRB-INT(ZWLSI17+ZEPSIL)*(1.0_JPRB-ZWLSI15)

!*         * Weights for bilinear interpolation.

    ZWY=ZWLSI15*(1.0_JPRB+ZWLSI14*(PDLAT(JLEN)-1.0_JPRB))
    ZCY=1.0_JPRB-ZWY

    ZWXN=ZWLSI2*(1.0_JPRB+ZWLSI1*(PDLO1(JLEN)-1.0_JPRB))
    ZCXN=1.0_JPRB-ZWXN

    ZWXS=ZWLSI4*(1.0_JPRB+ZWLSI3*(PDLO2(JLEN)-1.0_JPRB))
    ZCXS=1.0_JPRB-ZWXS

    PWXX(JLEN,1)  = ZCXN*ZCY
    PWXX(JLEN,2)  = ZWXN*ZCY
    PWXX(JLEN,3)  = ZCXS*ZWY
    PWXX(JLEN,4)  = ZWXS*ZWY

  ENDDO

ENDIF

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

!*       2. WEIGHTS FOR 12 POINTS INTERPOLATION. 
!           ------------------------------------

IF (KBINL == 12) THEN

  DO JLEN = 1,KLEN

!          * Preliminary initialisation of ZWLSI1 to ZWLSI17.

    ZWLSI1=1._JPRB
    ZWLSI2=1._JPRB
    ZWLSI3=1._JPRB
    ZWLSI4=1._JPRB
    ZWLSI5=1._JPRB
    ZWLSI6=1._JPRB
    ZWLSI7=1._JPRB
    ZWLSI8=1._JPRB
    ZWLSI9=1._JPRB
    ZWLSI10=1._JPRB
    ZWLSI11=1._JPRB
    ZWLSI12=1._JPRB

    ZWLSI13=0._JPRB
    ZWLSI14=0._JPRB
    ZWLSI15=0._JPRB
    ZWLSI16=0._JPRB
    ZWLSI17=0._JPRB


!          * Modification of ZWLSI1 to ZWLSI17
!            according to value of the land/sea/ice mask.

    IF ( KLSIM  /=  0 ) THEN

      IMKOUT=NINT(PLSMOUT(JLEN))
      IF(IMKOUT == 0)THEN
        IMKOUT=1
        IF(PTSOUT(JLEN) <= PTMERGL.AND.KLSIM == 2) IMKOUT=2
      ELSE
        IMKOUT=3
      ENDIF

      IMKIN1=NINT(PLSMIN(KL0(JLEN,1)+1))
      IF(IMKIN1 == 0)THEN
        IMKIN1=1
        IF(PTSIN(KL0(JLEN,1)+1) <= PTMERGL.AND.KLSIM == 2)IMKIN1=2
      ELSE
        IMKIN1=3
      ENDIF

      IMKIN2=NINT(PLSMIN(KL0(JLEN,1)+2))
      IF(IMKIN2 == 0)THEN
        IMKIN2=1
        IF(PTSIN(KL0(JLEN,1)+2) <= PTMERGL.AND.KLSIM == 2)IMKIN2=2
      ELSE
        IMKIN2=3
      ENDIF

      IMKIN3=NINT(PLSMIN(KL0(JLEN,2)+1))
      IF(IMKIN3 == 0)THEN
        IMKIN3=1
        IF(PTSIN(KL0(JLEN,2)+1) <= PTMERGL.AND.KLSIM == 2)IMKIN3=2
      ELSE
        IMKIN3=3
      ENDIF

      IMKIN4=NINT(PLSMIN(KL0(JLEN,2)+2))
      IF(IMKIN4 == 0)THEN
        IMKIN4=1
        IF(PTSIN(KL0(JLEN,2)+2) <= PTMERGL.AND.KLSIM == 2)IMKIN4=2
      ELSE
        IMKIN4=3
      ENDIF

      IMKIN5=NINT(PLSMIN(KL0(JLEN,0)+1))
      IF(IMKIN5 == 0)THEN
        IMKIN5=1
        IF(PTSIN(KL0(JLEN,0)+1) <= PTMERGL.AND.KLSIM == 2)IMKIN5=2
      ELSE
        IMKIN5=3
      ENDIF

      IMKIN6=NINT(PLSMIN(KL0(JLEN,0)+2))
      IF(IMKIN6 == 0)THEN
        IMKIN6=1
        IF(PTSIN(KL0(JLEN,0)+2) <= PTMERGL.AND.KLSIM == 2)IMKIN6=2
      ELSE
        IMKIN6=3
      ENDIF

      IMKIN7=NINT(PLSMIN(KL0(JLEN,1)))
      IF(IMKIN7 == 0)THEN
        IMKIN7=1
        IF(PTSIN(KL0(JLEN,1)) <= PTMERGL.AND.KLSIM == 2)IMKIN7=2
      ELSE
        IMKIN7=3
      ENDIF

      IMKIN8=NINT(PLSMIN(KL0(JLEN,1)+3))
      IF(IMKIN8 == 0)THEN
        IMKIN8=1
        IF(PTSIN(KL0(JLEN,1)+3) <= PTMERGL.AND.KLSIM == 2)IMKIN8=2
      ELSE
        IMKIN8=3
      ENDIF

      IMKIN9=NINT(PLSMIN(KL0(JLEN,2)))
      IF(IMKIN9 == 0)THEN
        IMKIN9=1
        IF(PTSIN(KL0(JLEN,2)) <= PTMERGL.AND.KLSIM == 2)IMKIN9=2
      ELSE
        IMKIN9=3
      ENDIF

      IMKIN10=NINT(PLSMIN(KL0(JLEN,2)+3))
      IF(IMKIN10 == 0)THEN
        IMKIN10=1
        IF(PTSIN(KL0(JLEN,2)+3) <= PTMERGL.AND.KLSIM == 2)IMKIN10=2
      ELSE
        IMKIN10=3
      ENDIF

      IMKIN11=NINT(PLSMIN(KL0(JLEN,3)+1))
      IF(IMKIN11 == 0)THEN
        IMKIN11=1
        IF(PTSIN(KL0(JLEN,3)+1) <= PTMERGL.AND.KLSIM == 2)IMKIN11=2
      ELSE
        IMKIN11=3
      ENDIF

      IMKIN12=NINT(PLSMIN(KL0(JLEN,3)+2))
      IF(IMKIN12 == 0)THEN
        IMKIN12=1
        IF(PTSIN(KL0(JLEN,3)+2) <= PTMERGL.AND.KLSIM == 2)IMKIN12=2
      ELSE
        IMKIN12=3
      ENDIF

      IF(IMKIN1 /= IMKOUT) ZWLSI1=0.0_JPRB
      IF(IMKIN2 /= IMKOUT) ZWLSI2=0.0_JPRB
      IF(IMKIN3 /= IMKOUT) ZWLSI3=0.0_JPRB
      IF(IMKIN4 /= IMKOUT) ZWLSI4=0.0_JPRB
      IF(IMKIN5 /= IMKOUT) ZWLSI5=0.0_JPRB
      IF(IMKIN6 /= IMKOUT) ZWLSI6=0.0_JPRB
      IF(IMKIN7 /= IMKOUT) ZWLSI7=0.0_JPRB
      IF(IMKIN8 /= IMKOUT) ZWLSI8=0.0_JPRB
      IF(IMKIN9 /= IMKOUT) ZWLSI9=0.0_JPRB
      IF(IMKIN10 /= IMKOUT) ZWLSI10=0.0_JPRB
      IF(IMKIN11 /= IMKOUT) ZWLSI11=0.0_JPRB
      IF(IMKIN12 /= IMKOUT) ZWLSI12=0.0_JPRB

    ENDIF

    ZWLSI13=MIN(ZWLSI5+ZWLSI6,1.0_JPRB)
    ZWLSI14=MIN(ZWLSI7+ZWLSI1+ZWLSI2+ZWLSI8,1.0_JPRB)
    ZWLSI15=MIN(ZWLSI9+ZWLSI3+ZWLSI4+ZWLSI10,1.0_JPRB)
    ZWLSI16=MIN(ZWLSI11+ZWLSI12,1.0_JPRB)
    ZWLSI17=MIN(ZWLSI13+ZWLSI14+ZWLSI15+ZWLSI16,1.0_JPRB)

!          * Definite values for ZWLSI1 to ZWLSI16.

    ZWLSI1=1.0_JPRB-INT(ZWLSI14+ZEPSIL)*(1.0_JPRB-ZWLSI1)
    ZWLSI2=1.0_JPRB-INT(ZWLSI14+ZEPSIL)*(1.0_JPRB-ZWLSI2)
    ZWLSI3=1.0_JPRB-INT(ZWLSI15+ZEPSIL)*(1.0_JPRB-ZWLSI3)
    ZWLSI4=1.0_JPRB-INT(ZWLSI15+ZEPSIL)*(1.0_JPRB-ZWLSI4)
    ZWLSI5=1.0_JPRB-INT(ZWLSI13+ZEPSIL)*(1.0_JPRB-ZWLSI5)
    ZWLSI6=1.0_JPRB-INT(ZWLSI13+ZEPSIL)*(1.0_JPRB-ZWLSI6)
    ZWLSI7=1.0_JPRB-INT(ZWLSI14+ZEPSIL)*(1.0_JPRB-ZWLSI7)
    ZWLSI8=1.0_JPRB-INT(ZWLSI14+ZEPSIL)*(1.0_JPRB-ZWLSI8)
    ZWLSI9=1.0_JPRB-INT(ZWLSI15+ZEPSIL)*(1.0_JPRB-ZWLSI9)
    ZWLSI10=1.0_JPRB-INT(ZWLSI15+ZEPSIL)*(1.0_JPRB-ZWLSI10)
    ZWLSI11=1.0_JPRB-INT(ZWLSI16+ZEPSIL)*(1.0_JPRB-ZWLSI11)
    ZWLSI12=1.0_JPRB-INT(ZWLSI16+ZEPSIL)*(1.0_JPRB-ZWLSI12)

    ZWLSI13=1.0_JPRB-INT(ZWLSI17+ZEPSIL)*(1.0_JPRB-ZWLSI13)
    ZWLSI14=1.0_JPRB-INT(ZWLSI17+ZEPSIL)*(1.0_JPRB-ZWLSI14)
    ZWLSI15=1.0_JPRB-INT(ZWLSI17+ZEPSIL)*(1.0_JPRB-ZWLSI15)
    ZWLSI16=1.0_JPRB-INT(ZWLSI17+ZEPSIL)*(1.0_JPRB-ZWLSI16)

!*         * Weights for 12 points interpolation.

    ILA1G=KLA(JLEN)+KFRSTLOFF
    ILAG =ILA1G-1
    ILA2G=ILA1G+1
    ILA3G=ILA1G+2

    ZDLAT = PDLAT(JLEN)
    ZDY   = ZDLAT*(PLATIN(ILA2G)-PLATIN(ILA1G))
    ZDY10 = PLATIN(ILA1G)-PLATIN(ILAG)
    ZDY21 = PLATIN(ILA2G)-PLATIN(ILA1G)
    ZDY32 = PLATIN(ILA3G)-PLATIN(ILA2G)

!*           -- L - polynom in x- direction; northern parallel

    ZDLO1 = PDLO1(JLEN)
    ZWXN3 = ZWLSI8*((1.0_JPRB+ZWLSI7*ZDLO1)*(1.0_JPRB+ZWLSI1*(ZDLO1-1.0_JPRB))&
     & *(1.0_JPRB+ZWLSI2*(ZDLO1-2.0_JPRB))) &
     & /((1.0_JPRB+2.0_JPRB*ZWLSI7)*(1.0_JPRB+ZWLSI1))  
    ZWXN2 = ZWLSI2*((1.0_JPRB+ZWLSI7*ZDLO1)*(1.0_JPRB+ZWLSI1*(ZDLO1-1.0_JPRB))&
     & *(1.0_JPRB+ZWLSI8*(ZDLO1-3._JPRB))) &
     & /((1.0_JPRB+ZWLSI7)*(1.0_JPRB-2.0_JPRB*ZWLSI8))  
    ZWXN1 = ZWLSI1*((1.0_JPRB+ZWLSI7*ZDLO1)*(1.0_JPRB+ZWLSI2*(ZDLO1-2.0_JPRB))&
     & *(1.0_JPRB+ZWLSI8*(ZDLO1-3._JPRB))) &
     & /((1.0_JPRB-2.0_JPRB*ZWLSI2)*(1.0_JPRB-3._JPRB*ZWLSI8))  
    ZWXN0 = 1.0_JPRB-ZWXN1-ZWXN2-ZWXN3

!*           -- L - polynom in x- direction; southern parallel

    ZDLO2 = PDLO2(JLEN)
    ZWXS3 = ZWLSI10*((1.0_JPRB+ZWLSI9*ZDLO2) &
     & *(1.0_JPRB+ZWLSI3*(ZDLO2-1.0_JPRB))&
     & *(1.0_JPRB+ZWLSI4*(ZDLO2-2.0_JPRB))) &
     & /((1.0_JPRB+2.0_JPRB*ZWLSI9)*(1.0_JPRB+ZWLSI3))  
    ZWXS2 = ZWLSI4*((1.0_JPRB+ZWLSI9*ZDLO2)*(1.0_JPRB+ZWLSI3*(ZDLO2-1.0_JPRB))&
     & *(1.0_JPRB+ZWLSI10*(ZDLO2-3._JPRB))) &
     & /((1.0_JPRB+ZWLSI9)*(1.0_JPRB-2.0_JPRB*ZWLSI10))  
    ZWXS1 = ZWLSI3*((1.0_JPRB+ZWLSI9*ZDLO2)*(1.0_JPRB+ZWLSI4*(ZDLO2-2.0_JPRB))&
     & *(1.0_JPRB+ZWLSI10*(ZDLO2-3._JPRB))) &
     & /((1.0_JPRB-2.0_JPRB*ZWLSI4)*(1.0_JPRB-3._JPRB*ZWLSI10))  
    ZWXS0 = 1.0_JPRB-ZWXS1-ZWXS2-ZWXS3

!*           -- L - polynom in y- direction

    ZWY3 = ZWLSI16*((1.0_JPRB+ZWLSI13*(ZDY+ZDY10-1.0_JPRB)) &
     & *(1.0_JPRB+ZWLSI14*(ZDY-1.0_JPRB)) &
     & *(1.0_JPRB+ZWLSI15*(ZDY-ZDY21-1.0_JPRB)))/((1.0_JPRB+ZWLSI13 &
     & *(ZDY10+ZDY21+ZDY32-1.0_JPRB))*(1.0_JPRB+ZWLSI14 &
     & *(ZDY21+ZDY32-1.0_JPRB))*(1.0_JPRB+ZWLSI15*(ZDY32-1.0_JPRB)))  

    ZWY2 = ZWLSI15*((1.0_JPRB+ZWLSI13*(ZDY+ZDY10-1.0_JPRB)) &
     & *(1.0_JPRB+ZWLSI14*(ZDY-1.0_JPRB)) &
     & *(1.0_JPRB+ZWLSI16*(ZDY-ZDY21-ZDY32-1.0_JPRB)))/((1.0_JPRB+ZWLSI13 &
     & *(ZDY10+ZDY21-1.0_JPRB))*(1.0_JPRB+ZWLSI14*(ZDY21-1.0_JPRB)) &
     & *(1.0_JPRB+ZWLSI16*(-ZDY32-1.0_JPRB)))  

    ZWY1 = ZWLSI14*((1.0_JPRB+ZWLSI13*(ZDY+ZDY10-1.0_JPRB)) &
     & *(1.0_JPRB+ZWLSI15*(ZDY-ZDY21-1.0_JPRB))*(1.0_JPRB+ZWLSI16 &
     & *(ZDY-ZDY21-ZDY32-1.0_JPRB)))/((1.0_JPRB+ZWLSI13 &
     & *(ZDY10-1.0_JPRB))*(1.0_JPRB+ZWLSI15*(-ZDY21-1.0_JPRB)) &
     & *(1.0_JPRB+ZWLSI16*(-ZDY21-ZDY32-1.0_JPRB)))  

    ZWY0 = 1.0_JPRB-ZWY1-ZWY2-ZWY3

!*           -- linear parts for extreme rows

    ZDLO = PDLO(JLEN)
    ZWXNN=ZWLSI6*(1.0_JPRB+ZWLSI5*(ZDLO-1.0_JPRB))
    ZCXNN=1.0_JPRB-ZWXNN

    ZDLO3=PDLO3(JLEN)
    ZWXSS=ZWLSI12*(1.0_JPRB+ZWLSI11*(ZDLO3-1.0_JPRB))
    ZCXSS=1.0_JPRB-ZWXSS

!*           -- Weights for 12 points interpolation.

    PWXX(JLEN,1)  = ZWXN1*ZWY1
    PWXX(JLEN,2)  = ZWXN2*ZWY1
    PWXX(JLEN,3)  = ZWXS1*ZWY2
    PWXX(JLEN,4)  = ZWXS2*ZWY2
    PWXX(JLEN,5)  = ZCXNN*ZWY0
    PWXX(JLEN,6)  = ZWXNN*ZWY0
    PWXX(JLEN,7)  = ZWXN0*ZWY1
    PWXX(JLEN,8)  = ZWXN3*ZWY1
    PWXX(JLEN,9)  = ZWXS0*ZWY2
    PWXX(JLEN,10) = ZWXS3*ZWY2
    PWXX(JLEN,11) = ZCXSS*ZWY3
    PWXX(JLEN,12) = ZWXSS*ZWY3

  ENDDO

ENDIF

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

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