FORTRAN Example - sd_addd.f



      PROGRAM ADD_DATA

      implicit none

      integer  sd_id, sds_id 
      integer start(1), stride(1), edge(1), sds_idx
      integer*4 data(10) 
      integer i, istat
      integer sfstart, sfselect, sfn2index
      integer sfendacc, sfend, sfwdata
      integer DFACC_WRITE
      parameter (DFACC_WRITE = 2)


C     Create and open the file and initiate the SD interface.
      sd_id = sfstart('addsdvg.hdf', DFACC_WRITE)

C     Select SDS called "sd1"
      sds_idx = sfn2index (sd_id, 'sd1')

      sds_id = sfselect (sd_id, sds_idx)

      do 10 i=1,10
         data(i) = i+10-1
10    continue

      start(1) = 0 
      stride(1) = 1
      edge(1) = 10 

C     Write data out
      istat =  sfwdata (sds_id, start, stride, edge, data)

C     Terminate access to the array.
      istat = sfendacc(sds_id)
 
C     Terminate access to the SD interface and close the file.
      istat = sfend(sd_id)

      end