      SUBROUTINE GFLUX (DATA,MIDBEAM,FLUX)
******************************************
*     calculate flux by fitting a gaussian
* inputs :
*     DATA        real*4      data array
*     MIDBEAM     integer*2   index of mid beam = center of Gaussian
* output :
*     FLUX        real*4      flux calculated from Gaussian fit
*
*     number of samples per half power beamwidth
      PARAMETER (NSPBW = 12)
*
      REAL DATA(1)
*
      IRANGE = NSPBW / 2
      SFLUX = 0.0
      SBMSQ = 0.0
      DO I = MIDBEAM-IRANGE, MIDBEAM+IRANGE
*         offset from center of beam in sampling units
          OFFSET  = FLOAT (I - MIDBEAM) / FLOAT (IRANGE)
*         normalised beam height at offset - use eqn for Gaussian
          BEAM = EXP (-0.693 * OFFSET**2)
          SFLUX = SFLUX + BEAM * DATA(I)
          SBMSQ = SBMSQ + BEAM**2
      END DO
*     flux in data input units
      FLUX = SFLUX / SBMSQ
      RETURN
      END
************************
