      program readwrite
      implicit none

c**** Program reads in unformatted 3D arrays output by 
c**** Kenny's grid code. Outputs 2D slices through the grids
c**** which can then be read and displayed by gnuplot, 
c**** Mathematica, etc

      integer nxg,nyg,nzg,i,j
      parameter(nxg=201,nyg=201,nzg=201)
      real*8 grid1(nxg,nyg,nzg)

      
c**** Read in density grid as unformatted array
      open(10,file='density.dat',status='unknown',
     +        form='unformatted')
           read(10) grid1
      close(10)

c**** Write out a 2D slice. Change the numerical index
c**** to choose the location of the slice in x, y, or z      
      open(10,file='slice.dat',status='unknown')      
        do i=1,nxg
          write(10,*) (grid1(i,j,101), j=1,nyg)
        end do
      close(10)
      
      return
      end
