c-----------------------------------------------------------------------
c hdf.f
c Routines to read and write hdf files using RNPL FORTRAN hdf calls
*     Randall R. Correll
*     Mijan F. Huq
*     Scott A. Klasky
*     Richard A. Matzner
*
*     COPYRIGHT 1995-1996
c-----------------------------------------------------------------------
		subroutine dumphdf3d(nx, ny, nz, data, crd1, crd2, crd3, time,
     .           cname1, cname2, cname3, name,temp)
			implicit none

			integer nx, ny, nz

			real*8	data(nx,ny,nz), crd1(nx), crd2(ny), crd3(nz),
     .            temp(nx+ny+nz), time

			character*32 name, cname1, cname2, cname3

c		Local variables

			integer	i, j, k, 
     . 				shape(3), gf3_rc, gft_write_full

			character*32 cnames(3)

c		Copying over coordinates to 1D array

			k = 0
			do i = 1, nx
				k = k + 1
				temp(k) = crd1(i)
			end do
			do i = 1, ny
				k = k + 1
				temp(k) = crd2(i)
			end do
			do i = 1, nz
				k = k + 1
				temp(k) = crd3(i)
			end do

			cnames(1) = cname1
			cnames(2) = cname2
			cnames(3) = cname3

			shape(1) = nx
			shape(2) = ny
			shape(3) = nz

         write(6,*)'*****hdf dump*****'
			write(6,*)'Dumping to file ',name

			gf3_rc = gft_write_full(name, time, shape, cnames, 
     .          3, temp, data)

			if( gf3_rc .ne. 1)then
				write(0,*)'**********ERROR in dumphdf3d**********'
			else
				write(0,*)'*****HDF dump completed*****'
         end if

			return
			end
c-----------------------------------------------------------------------
		subroutine readhdf3d(nx, ny, nz, data, crd1, crd2, crd3, time,
     .           cname1, cname2, cname3, level,name,temp)
			implicit none

			integer nx, ny, nz, level

			real*8	data(nx,ny,nz), crd1(nx), crd2(ny), crd3(nz),
     .            temp(nx+ny+nz), time

			character*32 name, cname1, cname2, cname3

c		Local variables

			integer	i, j, k,  rank,
     . 				shape(3), gf3_rc, gft_read_full

			character*32 cnames(3)

         write(6,*)'*****hdf dump*****'
			write(6,*)'Reading from file ',name

			rank = 3

			gf3_rc = gft_read_full(name, level,shape, cnames, 
     .          rank, time, temp, data)

			if( gf3_rc .ne. 1)then
				write(0,*)'**********ERROR in readhdf3d**********'
			else
				write(0,*)'*****HDF read completed*****'
         end if


c		Copying over coordinates to 1D array

			k = 0
			do i = 1, nx
				k = k + 1
				temp(k) = crd1(i)
			end do
			do i = 1, ny
				k = k + 1
				temp(k) = crd2(i)
			end do
			do i = 1, nz
				k = k + 1
				temp(k) = crd3(i)
			end do

			cnames(1) = cname1
			cnames(2) = cname2
			cnames(3) = cname3


			return
			end
c-----------------------------------------------------------------------
