      SUBROUTINE AVTRAN(KD,XNU,FF,HELJD)
      CHARACTER FNAME*25,TITLE*78,INTITL*78   
      DOUBLE PRECISION HELJD(1),HJDIN
      DIMENSION XNU(1),FF(1),FFIN(10000)
      IFILE=0
      DO 1 J=1,10000
    1 FF(J)=0.0

    5 READ 10,FNAME
   10 FORMAT(A)
      IF(FNAME.EQ.'END')GO TO 150
      PRINT 20,FNAME
   20 FORMAT(/12X,'NEXT FOURIER TRANSFORM FROM FILE ',A)
      OPEN(11,FILE=FNAME,STATUS='OLD')
      IFILE=IFILE+1
      READ(11,40)INTITL
   40 FORMAT(A78) 
      PRINT 60,INTITL
   60 FORMAT(12X,'TITLE: ',A78) 
      READ(11,70)NQIN,HJDIN,KDIN,XNULIN,XNUHIN,DFIN
   70 FORMAT('NPTS : ',I5,4X,'HJD : ',F18.7,4X,'NFREQ : ',I5/   
     *   'FLOW : ',1PE15.7,4X,'FHIGH : ',1PE15.7,4X,'DF : ',1PE15.7)    
      PRINT 75,NQIN,HJDIN,KDIN,XNULIN,XNUHIN,DFIN
   75 FORMAT(12X,'NPTS : ',I5,4X,'HJD : ',F18.7,4X,'NFREQ : ',I5/12X,
     *   'FLOW : ',1PE15.7,4X,'FHIGH : ',1PE15.7,4X,'DF : ',1PE15.7)    
      IF(IFILE.EQ.1)THEN
        NQ=NQIN
        HELJD(1)=HJDIN
        KD=KDIN
        XNU1=XNULIN
        XNUKD=XNUHIN
        DF=DFIN
        TITLE=INTITL
      ELSE
        IF(KDIN.NE.KD.OR.XNU1.NE.XNULIN.OR.XNUKD.NE.XNUHIN.OR.
     *     DFIN.NE.DF)THEN
          PRINT 90
   90     FORMAT(12X,'THIS FILE INCOMPATIBLE WITH THE FIRST ONE'/
     *           12X,'DIFFERENT FREQUENCY RANGE OR GRID')
          STOP
        END IF
      END IF
      READ(11,100)(IDUM,XNU(J),FFIN(J),J=1,KDIN)
  100 FORMAT(I10,2E20.8)
      DO 120 J=1,KDIN
        FF(J)=FF(J)+FFIN(J)
  120 CONTINUE        
      CLOSE(11)
      GO TO 5
  150 READ *,FHI
      IF(FHI.GT.0.0)PRINT 175,FHI
  175 FORMAT(/12X,'AVERAGE FT TRUNCATED BELOW ',1PE15.7)
      DO 200 J=1,KD
        IF(FHI.GT.0.0.AND.XNU(J).GT.FHI)GO TO 250
        FF(J)=FF(J)/IFILE
  200 CONTINUE
  250 KD=J-1
      RETURN
      END
