      SUBROUTINE TRANFA(TIME,AMPLTD,NSHIFT,HELJD,XNU,FF,GG,ST,KD,FREMAX)
C     
C     ROUTINE TO CALCULATE THE FOURIER TRANSFORM OF THE DATA IN TIME AND
C     AMPLTD AND RETURN THE RESULTS IN XNU AND FF     
C     
      DIMENSION XNU(*),FF(*),GG(*),ST(*),TIME(*),AMPLTD(*)  
      DOUBLE PRECISION HELJD(*),TT(1000)
      DATA MODE/0/
      READ *,F1,F2,DF,NPOLY,NORM    
      FN=(F2-F1)/DF+1.  
      KD=FN 
      IF(FN-KD.NE.0.0)KD=KD+1 
      DO 20 J=1,KD
        XNU(J)=F1+(J-1)*DF    
        IF(XNU(J).GT.F2)XNU(J)=F2   
   20 CONTINUE    
      PRINT 30,NSHIFT,HELJD(1),(TIME(K),AMPLTD(K),K=1,NSHIFT)     
   30 FORMAT(12X,33HAMPLITUDE DATA FOR THE TRANSFORM:/
     *       14X,16HNUMBER OF POINTS ,I5/ 
     *       14X,25HTIMES RELATIVE TO HJD OF ,F18.7// 
     *       14X,11HTIME (SECS),12X,9HAMPLITUDE/14X,32(1H=)/
     *       (14X,0PF11.1,12X,1PE9.3))    
      PRINT 40    
   40 FORMAT(14X,32(1H=)//)   
      PRINT 45,KD,XNU(1),XNU(KD),DF,1./XNU(1),1./XNU(KD),MODE     
   45 FORMAT(12X,'POWER SPECTRUM CALCULATED FOR ',I6,' FREQUENCIES ',   
     *       'FROM ',1PE13.6,' TO ',1PE13.6,' IN STEPS OF ',
     *       1PE13.6/42X,'CORRESPONDING PERIODS : ',0PF13.6,4X,   
     *       F13.6,5X,'PROGRAM IN MODE ',I2)    
      PRINT 50,NPOLY,NORM     
   50 FORMAT(12X,'PREP CALLED FIRST WITH NPOLY: ',I4,' AND NORM ',I4)   
      SAMTIM=TIME(2)-TIME(1)  
C
C     DOUBLE PRECISION TIME ARRAY MUST BE PASSED TO TRANFQ SO COPY
C     THE ARRAY TIME TO ARRAY TT
C
      DO 60 J=1,NSHIFT
        TT(J)=TIME(J)
   60 CONTINUE
      CALL PREP(AMPLTD,1,NSHIFT,SAMTIM,NPOLY,NORM)    
      CALL TRANFQ(AMPLTD,TT,NSHIFT,KD,XNU,GG,FF,ST,MODE,FREMAX) 
      RETURN
      END   
