copyright (C) 2001  MSC-RPN COMM  %%%MC2%%%
***s/r didbcs
*

      subroutine didbcs ( dimgx, dimgy ) 1
      implicit none
*
      integer dimgx, dimgy
#include "lcldim.cdk"
#include "bcsdim.cdk"
#include "bcsgrds.cdk"
#include "rec.cdk"
#include "partopo.cdk"
*
      integer i,j,nit,njt,ofi,ofj,cnt,err
      real*8 xpxext(0:dimgx+1), ypxext(0:dimgy+1)
*
*-----------------------------------------------------------------------
*
      do i=1,dimgx
         xpxext(i) = xpx(i)
      end do
      xpxext(0) = xpxext(1) - (xpxext(2)-xpxext(1))
      xpxext(dimgx+1) = xpxext(dimgx) + (xpxext(dimgx)-xpxext(dimgx-1))
*
      do i=1,dimgy
         ypxext(i) = ypx(i)
      end do
      ypxext(0) = ypxext(1) - (ypxext(2)-ypxext(1))
      ypxext(dimgy+1) = ypxext(dimgy) + (ypxext(dimgy)-ypxext(dimgy-1))
*
      ofi = gc_ld(1,myproc) + hx - 1
      ofj = gc_ld(3,myproc) + hy - 1
*
* Defining target grid IDs for horizontal interpolation of BCs
*
* South and North grid
*
      nit = max(dimxs,dimxn)
      njt = 0
      if (south_L) njt = njt + dimys
      if (north_L) njt = njt + dimyn
*
      if (nit*njt.gt.0) then
*
         call hpalloc (paxpn , nit*2, err, 1)
         call hpalloc (paypn , njt*2, err, 1)
         call hpalloc (paxpun, nit*2, err, 1)
         call hpalloc (paypvn, njt*2, err, 1)
*
         cnt = 0
         do i = minxs,maxxs
            cnt = cnt + 1
            xpn (cnt) = xpx(ofi+i)
            xpun(cnt) = 0.5d0 * (xpxext(ofi+i) + xpxext(ofi+i-1))
         end do
*
         cnt = 0
         if (south_L) then
            do j = minys,maxys
               cnt = cnt + 1
               ypn (cnt) = ypx(ofj+j)
               ypvn(cnt) = 0.5d0 * (ypxext(ofj+j) + ypxext(ofj+j-1))
            end do 
         endif
*
         if (north_L) then
            do j=minyn,maxyn
               cnt = cnt + 1
               ypn (cnt) = ypx(ofj+j)
               ypvn(cnt) = 0.5d0 * (ypxext(ofj+j) + ypxext(ofj+j-1))
            end do 
         endif
*
      endif
*
* West and East grid
*
      nit = 0
      njt = max(dimyw,dimye)
      if (west_L) nit = nit + dimxw
      if (east_L) nit = nit + dimxe
*
      if (nit*njt.gt.0) then
*
         call hpalloc (paxpw , nit*2, err, 1)
         call hpalloc (paypw , njt*2, err, 1)
         call hpalloc (paxpuw, nit*2, err, 1)
         call hpalloc (paypvw, njt*2, err, 1)
*
         cnt = 0
         if (west_L) then
            do i=minxw,maxxw
               cnt = cnt + 1
               xpw (cnt) = xpx(ofi+i)
               xpuw(cnt) = 0.5d0 * (xpxext(ofi+i) + xpxext(ofi+i-1))
            end do
         endif
         if (east_L) then
            do i=minxe,maxxe
               cnt = cnt + 1
               xpw (cnt) = xpx(ofi+i)
               xpuw(cnt) = 0.5d0 * (xpxext(ofi+i) + xpxext(ofi+i-1))
            end do
         endif
*
         cnt = 0
         do j = minyw,maxyw
            cnt = cnt + 1
            ypw (cnt) = ypx(ofj+j)
            ypvw(cnt) = 0.5d0 * (ypxext(ofj+j) + ypxext(ofj+j-1))
         end do 
*
      endif
*
*-----------------------------------------------------------------------
      return
      end