

      subroutine inithdf(etascale,thtascale,neta,nthta)
c**********************************************************************
c
c This subroutine should be called once before calling the
c subroutine "writehdf".  It sets the eta and theta scales
c and provides unit, name, and format information.
c etascale and thetascale are arrays containing eta and theta
c
c***********************************************************************
c
      IMPLICIT REAL(a-h,o-z)
      IMPLICIT INTEGER(i-n)

      include 'param.h'
      INTEGER*4 ret,shape(2),dssdims,dssdist,DFSDsetdimscale
      real*8 etascale(im),thtascale(jm)
      real*4 etahdf(im),thtahdf(jm)

      do 100 i=1,im
  100   etahdf(i)=etascale(i)
      do 200 j=1,jm
  200   thtahdf(j)=thtascale(j)
      shape(1) = im
      shape(2) = jm
      ret = dssdims(2,shape)
      ret = dssdist(1,'eta','M','f6.2')
      ret = dssdist(2,'theta','radians','f6.2')
      ret = DFSDsetdimscale(1,shape(1),etahdf)
      ret = DFSDsetdimscale(2,shape(2),thtahdf)
      RETURN
      END
 




 
      subroutine writehdf(varname,filname,array,time,neta,nthta)
c**********************************************************************
c
c varname is the name you wish to call the array, filname is the name
c you wish to give to the hdf file
c
c*********************************************************************
c
      IMPLICIT REAL(a-h,o-z)
      IMPLICIT INTEGER(i-n)

      include 'param.h'
      INTEGER*4 ret,shape(2),dssdast,dsadata
      real*8 array(im,jm)   
      real*4 arrayhdf(im,jm)
      CHARACTER*10 varname,filname
      CHARACTER*40 title

      do 100 j=1,jm
      do 100 i=1,im
  100   arrayhdf(i,j)=array(i,j)

      shape(1) = im
      shape(2) = jm
c write a
      WRITE(title,222)varname,time
222   FORMAT(A10,1X,F10.6)
      ret = dssdast(title,' ','e12.5','polar')
      ret = dsadata(filname,2,shape,arrayhdf)
      RETURN
      END



