
	subroutine dump_2d_slice(name, time, u, nx,ny,nz, yslice, &
	xmin,zmin, h)

	implicit none
	integer nx,ny,nz
	character*(*) name
	integer yslice
	real*8 time

	real*8 u(nx,ny,nz), xmin, zmin, h
	
	integer jerr,java_ser2d


		integer i,j,l
		real*8,allocatable,dimension(:) :: fxz,x2d,z2d

		allocate(x2d(nx*nz),z2d(nx*nz),fxz(nx*nz))

		l = 0

		do j = 1 , nz
		   do i = 1 , nx

		      l = l + 1
		      x2d(l) = xmin + h*(i-1)
		      z2d(l) = zmin + h*(j-1)
		      fxz(l)  = u(i,yslice,j)
		      
		   end do
		end do


		jerr = java_ser2d(name,time,x2d,z2d,fxz,nx*nz)
		if (jerr .ne. 0) then
		   pause
		   jerr = java_ser2d(name,time,x2d,z2d,fxz,nx*nz)  
		end if

		end

	subroutine dump_1dx (name, time, array,  nx, ny, nz, y, z, xmin, h)

	character*(*) name

	real*8 time, array(nx,ny,nz)

	integer nx,ny,nz, y, z

	real*8 xmin, h

!       Local

	integer i, j, jerr, java_ser
	real*8 fx(nx), x(nx)

	do i=1, nx
	   x(i) = xmin + h*(i-1)
	   fx(i) = array(i, y, z)
	end do

	jerr = java_ser(name, time, x, fx, nx)	
	if (jerr .ne. 0) then
	   pause
	   jerr = java_ser(name,time, x,fx,nx)  
	end if
	   
	end


	subroutine dump_1dy (name, time, array,  nx, ny, nz, x, z, ymin, h)

	character*(*) name

	real*8 time, array(nx,ny,nz)

	integer nx,ny,nz, x, z

	real*8 ymin, h

!       Local

	integer i, j, jerr, java_ser
	real*8 fy(ny), y(ny)

	do i=1, ny
	   y(i) = ymin + h*(i-1)
	   fy(i) = array(x, i, z)
	end do

	jerr = java_ser(name, time, y, fy, ny)
	if (jerr .ne. 0) then
	   pause
	   jerr = java_ser(name,time, x,fx,nx)  
	end if
	   
	end

	subroutine dump_1dz (name, time, array,  nx, ny, nz, x, y, zmin, h)

	character*(*) name

	real*8 time, array(nx,ny,nz)

	integer nx,ny,nz, x, y

	real*8 zmin, h

!       Local

	integer i, j, jerr, java_ser
	real*8 fz(nz), z(nz)

	do i=1, nz
	   z(i) = zmin + h*(i-1)
	   fz(i) = array(x, y, i)
	end do

	jerr = java_ser(name, time, z, fz, nz)
	if (jerr .ne. 0) then
	   pause
	   jerr = java_ser(name,time, x,fx,nx)  
	end if

        return
	end

        subroutine fput(n, array)
          implicit none
          
          integer n
          
          real*8 array(n)
          
!     Locals
          
          integer i
          
          real*8 r
          
          do i=1, n
             write (2) array(i)
          end do
          
          return
        end

        subroutine startdump (nx,ny,nz, bbox, h, width, ampl, cfl, &
          smooth)
          implicit none

          integer nx, ny, nz, smooth
          
          real*8 bbox(6), h, width, ampl, cfl

          ! Locals

          integer i

          real*8 x(nx)

          open(unit=2,access="sequential",&
               form="unformatted",file="wave3d.out")

          do i=1, nx
             x(i) = bbox(1) + h*(i-1) 
          end do

          write (2) nx, smooth, bbox(1), h, width, ampl, cfl
          
          call fput (nx, x)

end


	subroutine filedump(nx, ny, nz, time,  array)
          implicit none

	integer nx, ny, nz

	real*8 time
        real*8,dimension(nx,ny,nz) :: array

!     Locals

        integer x,y,z,i

        real*8, allocatable, dimension(:) :: dump

	y = (ny+1)/2
        z = (nz+1)/2

	allocate(dump(nx))

	do i=1, nx

           dump(i) = array(i, (ny+1)/2, (nz+1)/2)


	end do

        write (2) time
        call fput (nx, dump)

	end
