one_128_ris_hdf.f
program one_128_ris_hdf
character*1 image(128,128)
character*1 colors(768)
integer ivals(128,128,62)
integer DFR8setpalette,DFR8putimage,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=3
c
do 200 k=1,iz
200 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,iz))
100 continue
c
c write image to an HDF file
c
ret=DFR8putimage('one_128_ris.hdf', image, 128, 128, 0)
c
if (istat .ne. 0)then
write(*,*)'Error Writing HDF File'
endif
c
888 stop
end