Fortran SDS HDF Program: m_sds_hdf.f

      program m_sds_hdf
      integer ivals(64,64,44)
      real image(64,64,44) 
      integer shape(3),ret 
      integer DFSDsetdims
      integer DFSDputdata
c
      open(5,file='brown.ascii',status='old',err=888)
c
      shape(1)=64
      shape(2)=64
      shape(3)=44
c
c  read in integer values from input file
c
      ix=shape(1)
      iy=shape(2)
      iz=shape(3)
c      
      read(5,10)(((ivals(i,j,k),i=1,ix),j=1,iy),k=1,iz)
   10 format(20(1x,i3))
c
c   change mode
c
      do 200 k=1,iz
      do 200 j=1,iy
      do 200 i=1,ix
      image(i,j,k)=ivals(i,j,k)
  200 continue
c
c  write image to an HDF file
c
      ret=DFSDsetdims(3,shape) 
      ret=DFSDputdata('brown.hdf',3,shape,image)
c      
      if (ret .ne. 0)then
	 write(*,*)'Error Writing HDF File'
      endif
c  
  888 stop
      end