*....*...1.........2.........3.........4.........5.........6.........7.*.......8
*     unpack   12/21/92
*
*     purpose
*     Expand a matrix of size ir by ic stored columnwise into a matrix
*     that is dimensioned as a(idr,idc).
*
*     usage
*     call unpack(A,idr,idc,ir,ic)
*
*     arguments
*     A   - an idr by idc matrix containing the elements of an ir by ic
*           matrix stored columnwise.  On return contains the elements 
*           stored in an idr by idc matrix.
*           real*8
*     idr - number of rows in the dimension statement for A.
*           integer*4
*     idc - number of columns in the dimension statement for A.
*           integer*4
*     ir  - number of rows of A; ir must be less than or equal idr.
*           integer*4
*     ic  - number of columns of A; ic must be less than or equal idc.
*           integer*4
*
*     typical usage
*     call pack(A,idr,idc,n,n)
*     call dsweep(A,n,eps,ier)
*     call unpack(A,idr,idc,n,n)
*
      subroutine unpack(A,idr,idc,ir,ic)
      implicit none
      save
      real*8 A
      integer*4 idr,idc,ir,ic
      integer*4 i,j,ii,jj
      dimension A(idr*idc)
      do j=1,ic
      jj=ic-(j-1)
      do i=1,ir
        ii=ir-(i-1)
        A(idr*(jj-1)+ii)=A(ir*(jj-1)+ii)
      end do
      end do
      return
      end

