many_128_ris_hdf.f

      program many_128_ris_hdf
      character*1 image(128,128)
      character*1 colors(768) 
      integer ivals(128,128,62)
      integer DFR8setpalette,DFR8putimage,DFR8addimage,ret
c
      open(5,file='fan.128_ascii',status='old',err=888)
c
      ret=DFR8setpalette(colors)
c
c  read in integer values from input file
c
      ix=128
      iy=128
      iz=62
c      
      do 400 k=1,iz
  400 read(5,10)((ivals(i,j,k),i=1,ix),j=1,iy)
   10 format(20(1x,i3))
c
c  convert first slice to character (8-bit) data
c
      do 100 j=1,iy
      do 100 i=1,ix
      image(i,j)=char(ivals(i,j,1))
  100 continue
c
c  write image to an HDF file
c
      ret=DFR8putimage('many_128_ris.hdf', image, 128, 128, 0)
c
c  convert values in array ivals to character (8-bit) data
c
      do 300 k=2,iz 
      do 200 j=1,iy
      do 200 i=1,ix
      image(i,j)=char(ivals(i,j,k))
  200 continue
c
c  write image to an HDF file
c
      ret=DFR8addimage('many_128_ris.hdf', image, 128, 128, 0)
  300 continue
c      
      if (istat .ne. 0)then
	 write(*,*)'Error Writing HDF File'
      endif
c  
  888 stop
      end