copyright (C) 2001  MSC-RPN COMM  %%%MC2%%%
*

      subroutine uvbdy (ubcs,ubcn,ubcw,ubce,vbcs,vbcn,lminxs,lmaxxs, 1
     $                    lminys,lmaxys,lminxw,lmaxxw,lminyw,lmaxyw)
      implicit none
*
      integer lminxs,lmaxxs,lminys,lmaxys,
     $        lminxw,lmaxxw,lminyw,lmaxyw
      real ubcs(lminxs:lmaxxs,lminys:lmaxys,*),
     $     ubcn(lminxs:lmaxxs,lminys:lmaxys,*),
     $     ubcw(lminxw:lmaxxw,lminyw:lmaxyw,*),
     $     ubce(lminxw:lmaxxw,lminyw:lmaxyw,*),
     $     vbcs(lminxs:lmaxxs,lminys:lmaxys,*),
     $     vbcn(lminxs:lmaxxs,lminys:lmaxys,*)
*
#include "bcsdim.cdk"
#include "dynmem.cdk"
*
      integer i, j, k
*
*----------------------------------------------------------------------
*
*** Imposing boundary conditions for the elliptic problem:
*** we impose normal winds:        u at west  and east  boundaries
***                          and   v at south and north boundaries
*
      if (south.gt.0) then
         do k=1,gnk-1
         do i=1,ldni-east
            vvp(i,1,k) =  vbcs(i,1,k)
         end do
         end do
      endif
*
      if (north.gt.0) then
         do k=1,gnk-1
         do i=1,ldni-east
            vvp(i,ldnj,k) = vbcn(i,ldnj-bcs_ofj,k)
         end do
         end do
      endif
*
      if (west.gt.0) then
         do k=1,gnk-1
            do j=minyw,maxyw
               uup(1,j,k) = ubcw(1,j,k)
            end do
            if (south.gt.0) then
               do j=1,maxys
                  uup(1,j,k) = ubcs(1,j,k)
               end do
            endif
            if (north.gt.0) then
               do j=minyn,ldnj-1
                  uup(1,j,k) = ubcn(1,j-bcs_ofj,k)
               end do
            endif
         end do
      endif
*
      if (east.gt.0) then
         do k=1,gnk-1
            do j=minye,maxye
               uup(ldni,j,k) = ubce(ldni-bcs_ofi,j,k)
            end do
            if (south.gt.0) then
               do j=1,maxys
                  uup(ldni,j,k) = ubcs(ldni,j,k)
               end do
            endif
            if (north.gt.0) then
               do j=minyn,ldnj-1
                  uup(ldni,j,k) = ubcn(ldni,j-bcs_ofj,k)
               end do
            endif
         end do
      endif
*
      call rpn_comm_xch_halo (uup,minx,maxx,miny,maxy,ldni,ldnj,
     $                    2*gnk,hx,hy,period_x,period_y,ldni,0)
*
*---------------------------------------------------------------
      return
      end