      SUBROUTINE PLAMP(AT,AF,AA,IPART,AJDH,IND)
C     
C     ROUTINE TO PLOT THE PERIOD AND AMPLITUDE OF THE MAXIMA OF THE     
C     FOURIER TRANSFORMS CALCULATED BY ANALYS (TAKEN FROM SQUID THE     
C     PERIODOGRAM PROGRAM     
C
      COMMON /PLOTFL/PLNAME
      CHARACTER PLNAME*12
      DIMENSION AT(1),AF(2,256),AA(1),LINE(60),NUMB(26),IND(1),DUM(4)   
      CHARACTER*1 NUMB,LINE   
      DOUBLE PRECISION AJDH   
      DATA NUMB/'A','B','C','D','E','F','G','H','+','J','K','L',  
     *          'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'/
      DO 1 J=1,IPART    
        IF(J.EQ.1)PAV=0.0     
        PAV=PAV+AF(2,J) 
    1 CONTINUE    
      PAV=PAV/IPART     
      DO 5 J=1,60 
    5 LINE(J)=' ' 
      PRINT 10,AJDH     
   10 FORMAT(12X,39HHELIOCENTRIC JULIAN DATE OF AXIS START=,F18.7)
C     
   15 READ *,XL,YL,STEPT,AMAX    
C     
      IF(XL.LE..01) XL=8.0    
      IF(YL.LT..01) YL=6.0    
      PMAX=0.0    
      PMIN=1.E30  
      DO 20 I=1,IPART   
        IF(AA(I).GT.AMAX)AMAX=AA(I) 
        IF(AF(2,I).GT.PMAX)PMAX=AF(2,I)   
        IF(AF(2,I).LT.PMIN)PMIN=AF(2,I)   
   20 CONTINUE    
      DUM(1)=PMIN 
      DUM(2)=PMAX 
c     CALL SCALE(DUM,YL,2,1)  
      PMIN=DUM(3) 
      PMAX=DUM(3)+YL*DUM(4)   
      DPDY=DUM(4) 
      DUM(1)=0.0  
      DUM(2)=AMAX 
c     CALL SCALE(DUM,YL,2,1)  
      AMAX=DUM(3)+YL*DUM(4)   
      DADY=DUM(4) 
      STEPP=60.0/(PMAX-PMIN)  
      IF(STEPT.EQ.0.0)STEPT=48.0/86400.0  
      DQ=1.0/STEPT
      TIME=AT(IPART)    
      DTDX=AT(IPART)/XL 
      PRINT 25,PMIN,PMAX,DPDY,YL,AMAX,DADY
   25 FORMAT(12X,'PLOT SCALED TO PERIODS ',F7.2,' TO ',F7.2,
     *       ' : SCALE FACTOR ',F9.2,'   Y AXIS LENGTH ',F7.2/    
     *       12X,'AMPLITUDE MAXIMUM IS ',F9.3,' WITH SCALE',
     *       ' FACTOR ',F9.2) 
c     CALL SETCC
c     CALL PLFILE(PLNAME)
c     call plots(ierr,idummy,28)
c     if(ierr.ne.0)stop 'Error on opening call to Spooltek'
c     CALL FACTOR(2.54)
      QQQ=(XL+2.5) 
      PPP=(YL+2.5) 
c     CALL FRAME(QQQ,PPP)    
c     CALL PLOT(1.5,1.5,-3)   
c     CALL AXIS(0.0,0.0,'PERIOD (S)',10,YL,90.0,PMIN,DPDY) 
c     CALL AXIS(0.0,0.0,'TIME',-4,XL,0.0,0.0,DTDX)    
c     CALL SYMBOL(0.0,-1.0,0.14,'(         +)',0.0,12) 
      X=0.14    
      AJD=AJDH    
c     CALL NUMBER(X,-1.0,0.14,AJD,0.0,4)  
c     CALL PLOT(XL,0.0,3)     
c     CALL PLOT(XL,YL,2)
c     CALL PLOT(0.0,YL,2)     
c     CALL SYMBOL(0.0,YL+0.3,0.14,'PLOT OF PERIOD VS. TIME',0.0,23)    
c     CALL SYMBOL(3.2,YL+0.3,0.14,' FOR THE      S PERIOD',0.0,22)     
c     CALL NUMBER(4.46,YL+0.3,0.14,PAV,0.0,-1)  
   35 PRINT 40,PAV
   40 FORMAT(1H0,11X,92('-')/12X,'I',22X,'PLOT OF PERIOD VS. TIME'
     *       ,' FOR THE ',F6.0,' S PERIOD',21X,'I'/12X,92('-')/   
     *       12X,'I',7X,'SECS',70X,'PERIOD',3X,'I'/12X,92('-'))   
      I=1   
      Q=-DQ 
      DO 50 L=1,1000    
      Q=Q+DQ
      X=(AT(I)-0.0)/DTDX
      Y=(AF(2,I)-PMIN)/DPDY   
      J=(AF(2,I)-PMIN)*STEPP  
      J=MIN0(MAX0(1,J),60)    
      K=AT(I)*STEPT+1   
      IF(L.GE.K)LINE(J)='*'   
      IF(LINE(J).EQ.'*')PRINT 45,Q,LINE,AF(2,I) 
   45 FORMAT(12X,'I',F11.1,1X,'I',60A1,1X,'I',F13.5,2X,'I') 
      IF(LINE(J).EQ.' ')PRINT 30,Q,LINE   
   30 FORMAT(12X,'I',F11.1,1X,'I',60A1,1X,'I',13X,2X,'I')   
      INDEX=IND(I)
c     IF(LINE(J).EQ.'*')CALL SYMBOL(X,Y,.08,NUMB(INDEX),0.0,1)    
      IF(LINE(J).EQ.'*')I=I+1 
      LINE(J)=' ' 
      IF(I.GT.IPART)GO TO 55  
   50 CONTINUE    
   55 PRINT 60    
   60 FORMAT(12X,92('-')////) 
c     CALL PLOT(0.0,0.0,999)    

c     call setcc
c     call plfile(plname)
c     call plots(ierr,idummy,28)
c     if(ierr.ne.0)stop 'Error on opening call to Spooltek'
c     CALL FACTOR(2.54) 
c     CALL FRAME(QQQ,PPP)    
c     CALL PLOT(1.5,1.5,-3)   
   90 STEPA=60.0/AMAX   
      DADY=AMAX/YL
c     CALL AXIS(0.0,0.0,'AMPLITUDE',9,YL,90.0,0.0,DADY)     
c     CALL AXIS(0.0,0.0,'TIME',-4,XL,0.0,0.0,DTDX)    
      X=0.0 
c     CALL SYMBOL(X,-1.0,0.14,'(         +)',0.0,12) 
      X=X+0.14    
c     CALL NUMBER(X,-1.0,0.14,AJD,0.0,4)  
c     CALL PLOT(XL,0.0,3)     
c     CALL PLOT(XL,YL,2)
c     CALL PLOT(0.0,YL,2)     
c     CALL SYMBOL(0.0,YL+0.3,0.14,'PLOT OF AMPLITUDE VS. TIME',0.0,26) 
c     CALL SYMBOL(3.64,YL+0.3,0.14,' FOR THE      S PERIOD',0.0,22)    
c     CALL NUMBER(4.9,YL+0.3,0.14,PAV,0.0,-1)   
  130 PRINT 140,PAV     
  140 FORMAT(1H0,11X,92('-')/12X,'I',20X,'PLOT OF AMPLITUDE VS. TIME'  
     *       ,' FOR THE ',F6.0,' S PERIOD',20X,'I'/12X,92('-')/   
     *       12X,'I',7X,'SECS',73X,'D',5X,'I'/12X,92('-'))  
      I=1   
      Q=-DQ 
      DO 150 L=1,1000   
      Q=Q+DQ
      X=(AT(I)-0.0)/DTDX
      Y=AA(I)/DADY
      J=(AA(I))*STEPA   
      J=MIN0(MAX0(1,J),60)    
      K=AT(I)*STEPT+1   
      INDEX=IND(I)
      IF(L.GE.K)LINE(J)=NUMB(INDEX) 
      IF(LINE(J).NE.' ')PRINT 145,Q,LINE,AA(I)  
  145 FORMAT(12X,'I',F11.1,1X,'I',60A1,1X,'I',1PE13.5,2X,'I')     
      IF(LINE(J).EQ.' ')PRINT 30,Q,LINE   
c     IF(LINE(J).NE.' ')CALL SYMBOL(X,Y,.08,NUMB(INDEX),0.0,1)    
      IF(LINE(J).NE.' ')I=I+1 
      LINE(J)=' ' 
      IF(I.GT.IPART)GO TO 155 
  150 CONTINUE    
  155 PRINT 60    
c     CALL PLOT(0.0,0.0,999)     
      RETURN
      END   
