      subroutine expand(grid,ncol,nrow,grid2,ncol2,nrow2)
c
c  Subroutine EXPAND adds "tapered" rows and columns to a 
c  grid.  Input grid(i,j), i=1,2,...ncol, j=1,2,...nrow, is 
c  modified as follows:
c
c  (1) Each row is exanded in length from ncol to ncol2.  
c      New elements of row j linearly change in value from 
c      grid(ncol,j) to grid(1,j).
c  (2) Each column is expanded in length from nrow to nrow2.
c      New elements of column 1 linearly change in value 
c      from grid(i,nrow) to grid(i,1).
c  (3) All elements at i < or = to ncol and j < or = nrow 
c      are left unchanged.
c
c  Input parameters:
c    grid -        singly dimensioned real array representing 
c                  a two-dimensional grid.
c    ncol,nrow -   dimensions of input grid.
c    ncol2,nrow2 - dimensions of output grid (grid2).  
c                  ncol2 must be > ncol; nrow2 must be > nrow.
c
c  Output parameters:
c    grid2 -       singly dimensioned real array representing 
c                  a two-dimension grid, as described above.
c
      dimension grid(ncol*nrow),grid2(ncol2*nrow2)
      index(i,j,ncol)=(j-1)*ncol+i
      do 10 j=1,nrow
         do 10 i=1,ncol
            ij=index(i,j,ncol)
            ij2=index(i,j,ncol2)
   10       grid2(ij2)=grid(ij)
      if(ncol2.gt.ncol)then
         do 20 j=1,nrow
            i1=index(1,j,ncol2)
            i2=index(ncol,j,ncol2)
            i3=index(ncol2,j,ncol2)
            step=(grid2(i1)-grid2(i2))/(ncol2-ncol+1)
            do 20 i=ncol+1,ncol2
               ij=index(i,j,ncol2)
   20          grid2(ij)=grid2(i2)+step*(i-ncol)
         else
            pause 'EXPAND:  ncol2.le.ncol'
            end if
      if(nrow2.gt.nrow)then
         do 30 i=1,ncol2
            j1=index(i,1,ncol2)
            j2=index(i,nrow,ncol2)
            j3=index(i,nrow2,ncol2)
            step=(grid2(j1)-grid2(j2))/(nrow2-nrow+1)
            do 30 j=nrow+1,nrow2
               ij=index(i,j,ncol2)
   30          grid2(ij)=grid2(j2)+step*(j-nrow)
         else
            pause 'EXPAND:  nrow2.le.nrow'
            end if
      return
      end
