************************************************************************
*     Randall R. Correll
*     Mijan F. Huq
*     Scott A. Klasky
*     Richard A. Matzner
*
*     COPYRIGHT 1995-1996

*  Prints 2D slices of 3D grid functions
************************************************************************
      subroutine plot2d(ntape,nx,ny,nz,x,y,z,grid)

      implicit none

      integer  ntape
      integer  nx,ny,nz
      real*8   x(nx),y(ny),z(nz)
      real*8   grid(nx,ny,nz)

      integer  i,j,k

      open(unit=ntape,status='unknown')

      k = (nz-1)/2 + 1

      do i = 1, nx
      do j = 1, ny

         write(ntape,'(2f12.6,e12.3)') x(i),y(j),grid(i,j,k)

      end do

         write(ntape,*)

      end do

      close(ntape)

      return
      end

c-----------------------------------------------------------------------
c	subroutine to dump data to a named file with suffix along a constant
c  x-slice of index indx where 1 <= indx <= nx
		subroutine dumpxnamed(nx, ny, nz, indx, suffix,it, x, y, z, uu)
			implicit none
			
			integer	nx, ny, nz, indx, it
	
			character*3	suffix
			real*8	x(nx), y(ny), z(nz)
			real*8	uu(nx,ny,nz)

c		Local variables

			integer	i, j, k
         character*64 fname

         if(it .lt. 10)then
            write(fname,1011)suffix,it
         endif
         if(it .lt. 100 .and. it .gt. 9)then
            write(fname,1012)suffix,it
         endif
         if(it .lt. 1000 .and. it .gt. 99)then
            write(fname,1013)suffix,it
         endif

         open(unit=13,file=fname)


			i = indx

			do j = 1, ny
				do k = 1, nz
					write(13,'(3F20.15)')y(j),z(k),uu(i,j,k)
				end do
				write(13,*)
			end do

			close(unit=13)
	
1011		format('slice',a3,'.',I1)	
1012		format('slice',a3,'.',I2)	
1013		format('slice',a3,'.',I3)	

			return
			end
c-----------------------------------------------------------------------
c	subroutine to dump data to a named file with suffix along a constant
c  y-slice of index indx where 1 <= indx <= ny
		subroutine dumpynamed(nx, ny, nz, indx, suffix,it, x, y, z, uu)
			implicit none
			
			integer	nx, ny, nz, indx, it
	
			character*3	suffix
			real*8	x(nx), y(ny), z(nz)
			real*8	uu(nx,ny,nz)

c		Local variables

			integer	i, j, k
         character*64 fname

         if(it .lt. 10)then
            write(fname,1011)suffix,it
         endif
         if(it .lt. 100 .and. it .gt. 9)then
            write(fname,1012)suffix,it
         endif
         if(it .lt. 1000 .and. it .gt. 99)then
            write(fname,1013)suffix,it
         endif

         open(unit=13,file=fname)


			j = indx

			do i = 1, nx
				do k = 1, nz
					write(13,'(3F20.15)')x(i),z(k),uu(i,j,k)
				end do
				write(13,*)
			end do

			close(unit=13)
	
1011		format('slice',a3,'.',I1)	
1012		format('slice',a3,'.',I2)	
1013		format('slice',a3,'.',I3)	

			return
			end
c-----------------------------------------------------------------------
c	subroutine to dump data to a named file with suffix along a constant
c  z-slice of index indx where 1 <= indx <= nz
		subroutine dumpznamed(nx, ny, nz, indx, suffix,it, x, y, z, uu)
			implicit none
			
			integer	nx, ny, nz, indx, it
	
			character*3	suffix
			real*8	x(nx), y(ny), z(nz)
			real*8	uu(nx,ny,nz)

c		Local variables

			integer	i, j, k
         character*64 fname

         if(it .lt. 10)then
            write(fname,1011)suffix,it
         endif
         if(it .lt. 100 .and. it .gt. 9)then
            write(fname,1012)suffix,it
         endif
         if(it .lt. 1000 .and. it .gt. 99)then
            write(fname,1013)suffix,it
         endif

         open(unit=13,file=fname)


			k = indx

			do i = 1, nx
				do j = 1, ny
					write(13,'(3F20.15)')x(i),y(j),uu(i,j,k)
				end do
				write(13,*)
			end do

			close(unit=13)
	
1011		format('slice',a3,'.',I1)	
1012		format('slice',a3,'.',I2)	
1013		format('slice',a3,'.',I3)	

			return
			end
