one_512_ris_hdf.f
program one_512_ris_hdf
character*1 image(512,512)
character*1 colors(768)
integer ivals(512,512,62)
integer DFR8setpalette,DFR8putimage,ret
c
open(5,file='fan_512.ascii',status='old',err=888)
c
ret=DFR8setpalette(colors)
c
c read in integer values from input file
c
ix=512
iy=512
iz=20
c
read(5,10)(((ivals(i,j,k),i=1,ix),j=1,iy),k=1,iz)
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_512_ris.hdf', image, 512, 512, 0)
c
if (istat .ne. 0)then
write(*,*)'Error Writing HDF File'
endif
c
888 stop
end