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