*....*...1.........2.........3.........4.........5.........6.........7.*.......8
*     pack     12/21/92
*
*     purpose
*     Pack a matrix of size ir by ic that is dimensioned as a(idr,idc) 
*     into columnwise storage.
*
*     usage
*     call pack(A,idr,idc,ir,ic)
*
*     arguments
*     A   - idr by idc matrix containing the elements of an ir by ic
*           matrix.  On return contains the elements stored in an ir
*           by ic matrix; that is, A contains vec(A) on return.
*           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 pack(A,idr,idc,ir,ic)
      implicit none
      save
      real*8 A
      integer*4 idr,idc,ir,ic
      integer*4 i,j
      dimension A(idr*idc)
      do j=1,ic
      do i=1,ir
        A(ir*(j-1)+i)=A(idr*(j-1)+i)
      end do
      end do
      return
      end


