m_128_sds_hdf.f

      program m_128_sds_hdf
      integer ivals(128,128,62)
      real image(128,128,62) 
      integer shape(3),ret 
      integer DFSDsetdims
      integer DFSDputdata
c
      open(5,file='fan.128_ascii',status='old',err=888)
c
      shape(1)=128
      shape(2)=128
      shape(3)=62
c
c  read in integer values from input file
c
      ix=shape(1)
      iy=shape(2)
      iz=shape(3)
c      
      do 100 k=1,iz
  100 read(5,10)((ivals(i,j,k),i=1,ix),j=1,iy)
   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('fan_128_sds.hdf',3,shape,image)
c      
      if (ret .ne. 0)then
	 write(*,*)'Error Writing HDF File'
      endif
c  
  888 stop
      end