      SUBROUTINE DTRANF(Q,TQ,NQ,KD,XNU,MXFRQ,GG,FF,ST,MODE,FREMAX,FNAME,
     *                  TITLE,HELJD)
C
C     ROUTINE TO READ IN THE FREQUENCY RANGE FOR A DFT CALCULATION
C     WITH A DOUBLE PRECISION FREQUENCY ARRAY DXNU AND SET UP THE
C     ARRAY DXNU
C
      DIMENSION Q(NQ),XNU(1)
      DIMENSION FF(1),GG(1),ST(1)   
      DOUBLE PRECISION TQ(NQ),DXNU(1),HELJD(1),F1,F2,DF
      CHARACTER FNAME*25,TITLE*80 
c     POINTER (PDXNU,DXNU)
c     PDXNU=MALLOC(SIZEOF(DXNU(1))*MXFRQ)
      READ *,F1,F2,DF,MODE 
      FN=(F2-F1)/DF+1.  
      KD=FN 
      IF(FN-KD.NE.0.0)KD=KD+1 
      DO 1020 J=1,KD    
        DXNU(J)=F1+(J-1)*DF    
        IF(DXNU(J).GT.F2)DXNU(J)=F2   
C       COPY THE DOUBLE PRECISION FREQUENCIES TO THE SINGLE PRECISION
C       XNU ARRAY
        XNU(J)=DXNU(J)
 1020 CONTINUE    
      PRINT 1030,KD,DXNU(1),DXNU(KD),DF,1./DMAX1(DXNU(1),1.0D-10)
     *          ,1./DXNU(KD),MODE   
 1030 FORMAT(12X,'POWER SPECTRUM CALCULATED FOR ',I6,' FREQUENCIES ',   
     *       'FROM ',1PE13.6,' TO ',1PE13.6,' IN STEPS OF ',
     *       1PE13.6/42X,'CORRESPONDING PERIODS : ',0PG13.6,4X,   
     *       G13.6,5X,'PROGRAM IN MODE ',I2/
     *       12X,'*** DOUBLE PRECISION FREQUENCIES ***')    
      IF(MODE.GE.2)THEN 
        READ(*,'(A)')FNAME    
        CLOSE(11) 
        OPEN(11,FILE=FNAME,STATUS='NEW')   
        IF(MODE.EQ.2)PRINT 1012,FNAME
 1012   FORMAT(12X,'*** SINE AND COSINE SUMS BEING DUMPED'/ 
     *         12X,'*** TO FILE ',A25/)   
        IF(MODE.EQ.4)PRINT 1014,FNAME
 1014   FORMAT(12X,'*** AMPLITUDE SPECTRUM   BEING DUMPED'/ 
     *         12X,'*** TO FILE ',A25/)   
        WRITE(11,'(A78)')TITLE
        WRITE(11,1015)NQ,HELJD(1),KD,DXNU(1),DXNU(KD),DF
 1015   FORMAT('NPTS : ',I5,4X,'HJD : ',F18.7,4X,'NFREQ : ',I5/   
     *   'FLOW : ',1PE15.7,4X,'FHIGH : ',1PE15.7,4X,'DF : ',1PE15.7)    
      END IF
C
C     NOW CALL TRANFD TO DO THE CALCULATION
C
      CALL TRANFD(Q,TQ,NQ,KD,DXNU,GG,FF,ST,MODE,FREMAX)
      RETURN
      END   
