module wei_dump
  !! array output for debugging

  use sep

  !---------------
  implicit none

  interface weidump
     module procedure weidumpI1
     module procedure weidumpI2
     module procedure weidumpI3
     module procedure weidumpI4
     module procedure weidumpI5

     module procedure weidumpR1
     module procedure weidumpR2
     module procedure weidumpR3
     module procedure weidumpR4
     module procedure weidumpR5

     module procedure weidumpC1
     module procedure weidumpC2
     module procedure weidumpC3
     module procedure weidumpC4
     module procedure weidumpC5
  end interface

  character(len=128), public :: dumpname

contains
  !----------------------------------------------------------------
  subroutine weidumpI1(array)
    integer, dimension(:), pointer            :: array
    integer :: esize
    integer :: n1

    call auxscr(trim(dumpname))

    esize = 1
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))

    call srite(trim(dumpname),array,n1*esize)
  end subroutine weidumpI1
  !----------------------------------------------------------------
  subroutine weidumpI2(array)
    integer, dimension(:,:), pointer          :: array
    integer :: esize
    integer :: n1,n2

    call auxscr(trim(dumpname))

    esize = 1
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))

    call srite(trim(dumpname),array,n1*n2*esize)
  end subroutine weidumpI2
  !----------------------------------------------------------------
  subroutine weidumpI3(array)
    integer, dimension(:,:,:), pointer        :: array
    integer :: esize
    integer :: n1,n2,n3

    call auxscr(trim(dumpname))

    esize = 1
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))
    n3 = size(array,3)
    call auxputch("n3",'i',n3,trim(dumpname))

    call srite(trim(dumpname),array,n1*n2*n3*esize)
  end subroutine weidumpI3
  !----------------------------------------------------------------
  subroutine weidumpI4(array)
    integer, dimension(:,:,:,:), pointer      :: array
    integer :: esize
    integer :: n1,n2,n3,n4

    call auxscr(trim(dumpname))

    esize = 1
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))
    n3 = size(array,3)
    call auxputch("n3",'i',n3,trim(dumpname))
    n4 = size(array,4)
    call auxputch("n4",'i',n4,trim(dumpname))

    call srite(trim(dumpname),n1*n2*n3*n4*esize)
  end subroutine weidumpI4
  !----------------------------------------------------------------
  subroutine weidumpI5(array)
    integer, dimension(:,:,:,:,:), pointer    :: array
    integer :: esize
    integer :: n1,n2,n3,n4,n5

    call auxscr(trim(dumpname))

    esize = 1
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))
    n3 = size(array,3)
    call auxputch("n3",'i',n3,trim(dumpname))
    n4 = size(array,4)
    call auxputch("n4",'i',n4,trim(dumpname))
    n5 = size(array,5)
    call auxputch("n5",'i',n5,trim(dumpname))

    call srite(trim(dumpname),array,n1*n2*n3*n4*n5*esize)
  end subroutine weidumpI5
  !----------------------------------------------------------------

  !----------------------------------------------------------------
  subroutine weidumpR1(array)
    real, dimension(:), pointer            :: array
    integer :: esize
    integer :: n1

    call auxscr(trim(dumpname))

    esize = 4
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpR1
  !----------------------------------------------------------------
  subroutine weidumpR2(array)
    real, dimension(:,:), pointer          :: array
    integer :: esize
    integer :: n1,n2

    call auxscr(trim(dumpname))

    esize = 4
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpR2
  !----------------------------------------------------------------
  subroutine weidumpR3(array)
    real, dimension(:,:,:), pointer        :: array
    integer :: esize
    integer :: n1,n2,n3

    call auxscr(trim(dumpname))

    esize = 4
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))
    n3 = size(array,3)
    call auxputch("n3",'i',n3,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpR3
  !----------------------------------------------------------------
  subroutine weidumpR4(array)
    real, dimension(:,:,:,:), pointer      :: array
    integer :: esize
    integer :: n1,n2,n3,n4

    call auxscr(trim(dumpname))

    esize = 4
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))
    n3 = size(array,3)
    call auxputch("n3",'i',n3,trim(dumpname))
    n4 = size(array,4)
    call auxputch("n4",'i',n4,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpR4
  !----------------------------------------------------------------
  subroutine weidumpR5(array)
    real, dimension(:,:,:,:,:), pointer    :: array
    integer :: esize
    integer :: n1,n2,n3,n4,n5

    call auxscr(trim(dumpname))

    esize = 4
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))
    n3 = size(array,3)
    call auxputch("n3",'i',n3,trim(dumpname))
    n4 = size(array,4)
    call auxputch("n4",'i',n4,trim(dumpname))
    n5 = size(array,5)
    call auxputch("n5",'i',n5,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpR5
  !----------------------------------------------------------------

  !----------------------------------------------------------------
  subroutine weidumpC1(array)
    complex, dimension(:), pointer         :: array
    integer :: esize
    integer :: n1

    call auxscr(trim(dumpname))

    esize = 8
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpC1
  !----------------------------------------------------------------
  subroutine weidumpC2(array)
    complex, dimension(:,:), pointer       :: array
    integer :: esize
    integer :: n1,n2

    call auxscr(trim(dumpname))

    esize = 8
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpC2
  !----------------------------------------------------------------
  subroutine weidumpC3(array)
    complex, dimension(:,:,:), pointer     :: array
    integer :: esize
    integer :: n1,n2,n3

    call auxscr(trim(dumpname))

    esize = 8
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))
    n3 = size(array,3)
    call auxputch("n3",'i',n3,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpC3
  !----------------------------------------------------------------
  subroutine weidumpC4(array)
    complex, dimension(:,:,:,:), pointer   :: array
    integer :: esize
    integer :: n1,n2,n3,n4

    call auxscr(trim(dumpname))

    esize = 8
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))
    n3 = size(array,3)
    call auxputch("n3",'i',n3,trim(dumpname))
    n4 = size(array,4)
    call auxputch("n4",'i',n4,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpC4
  !----------------------------------------------------------------
  subroutine weidumpC5(array)
    complex, dimension(:,:,:,:,:), pointer :: array
    integer :: esize
    integer :: n1,n2,n3,n4,n5

    call auxscr(trim(dumpname))

    esize = 8
    call auxputch("esize",'i',esize,trim(dumpname))
    n1 = size(array,1)
    call auxputch("n1",'i',n1,trim(dumpname))
    n2 = size(array,2)
    call auxputch("n2",'i',n2,trim(dumpname))
    n3 = size(array,3)
    call auxputch("n3",'i',n3,trim(dumpname))
    n4 = size(array,4)
    call auxputch("n4",'i',n4,trim(dumpname))
    n5 = size(array,5)
    call auxputch("n5",'i',n5,trim(dumpname))

    call sep_write(array,trim(dumpname))
  end subroutine weidumpC5
  !----------------------------------------------------------------
end module wei_dump





