      SUBROUTINE DATGEN(Q,TQ,NQ,NORUN,SAMTIM,LIM,HELJD)     
C     
C     ROUTINE TO PUT SPECIAL DATA IN Q    
C     
      DIMENSION Q(1),SAMTIM(1),LIM(2,1)   
      DOUBLE PRECISION HELJD(1),TQ(1)
      TWOPI=2.0*3.141592654   
      READ *,P,A,PHI,DELT,NP,MODE   
      READ *,PMOD,AMPMOD,PHIMOD     
      PRINT 10,P,A,PHI,DELT,NP,PMOD,AMPMOD,PHIMOD     
   10 FORMAT(12X,'MODULATED DATA AT PERIOD ',T50,F10.1/     
     *       12X,'AMPLITUDE ',T50,F10.1/12X,'PHASE',T50,F10.5/    
     *       12X,'SAMPLING TIME',T50,F10.1/     
     *       12X,'NO OF POINTS',T50,I10/12X,'MODULATION PERIOD',  
     *       T50,F10.1/12X,'MODULATION AMPLITUDE',T50,F10.1/
     *       12X,'MODULATION PHASE',T50,F10.5)  
      IF(MODE.EQ.0)PRINT 20   
      IF(MODE.EQ.1)PRINT 30   
      IF(MODE.EQ.2)PRINT 40   
   20 FORMAT(12X,'DATA IS AMPLITUDE MODULATED') 
   30 FORMAT(12X,'DATA IS PHASE MODULATED')     
   40 FORMAT(12X,'DATA BOTH PHASE AND AMPLITUDE MODULATED') 
      NQ=NP 
      NORUN=1     
      LIM(1,1)=1  
      LIM(2,1)=NQ 
      SAMTIM(1)=DELT    
      HELJD(1)=0.0
      DO 50 J=1,NQ
        T=DELT/2.0+(J-1)*DELT 
        TQ(J)=T   
        ARG=AMOD(TWOPI*T/P+PHI,TWOPI)     
        ARGMOD=AMOD(TWOPI*T/PMOD+PHIMOD,TWOPI)  
        IF(MODE.EQ.0)Q(J)=Q(J)+(1.0+AMPMOD*COS(ARGMOD))*COS(ARG)  
        IF(MODE.EQ.1)THEN     
          ARG=AMOD(ARG+AMPMOD*COS(ARGMOD),TWOPI)
          Q(J)=Q(J)+COS(ARG)  
        END IF    
        IF(MODE.EQ.2)THEN     
          ARG=AMOD(ARG+AMPMOD*COS(ARGMOD),TWOPI)
          Q(J)=Q(J)+(1.0+AMPMOD*COS(ARGMOD))*COS(ARG) 
        END IF    
   50 CONTINUE    
      RETURN
      END   
