m_512_sds_hdf.f
program m_512_sds_hdf
integer ivals(512,512,62)
real image(512,512,62)
integer shape(3),ret
integer DFSDsetdims
integer DFSDputdata
c
open(5,file='fan_512.ascii',status='old',err=888)
c
shape(1)=512
shape(2)=512
shape(3)=62
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('fan_128_sds.hdf',3,shape,image)
c
if (ret .ne. 0)then
write(*,*)'Error Writing HDF File'
endif
c
888 stop
end