C*********************************************************************
C
C Written by Victor De Pinto
C Revised Jan. 25, 1982
C
      SUBROUTINE PLOT ( DAT )
C
C     This routine generates absolute moves. Full scale is unity in both
C     x and y axes. It is up to the hardware-dependent draw routine
C     to execute the moves. Point 0,0 is lower left.
C
      LOGICAL QFLG, DRWFLG, LOGFLG
      DIMENSION DAT(2,1024)
      DATA XSCALE / .0009775 /
1     WRITE (1,100)
100   FORMAT (' --PLOTTER MENU--  Select function:'/
     X ' 1  PLOT REAL PART OF FILE '/
     X ' 2  PLOT MAGNITUDE OF FILE (LINEAR) '/
     X ' 3  PLOT MAGNITUDE OF FILE (LOGARITHMIC) '/
     X ' 4  PLOT PHASE OF FILE '/
     X ' 5  DRAW BORDER'/
     X ' 6  DRAW GRID LINES'/
     X ' 7  SET PLOTTER TIMING'/
     X ' 8  BACK TO MAIN MENU >> ')
      READ (1,111) J
111   FORMAT (I2)
      GO TO (500,215,200,450,300,400,350,116),J
116   RETURN
C
C PLOT THE REAL PARTS OF A FILE.
C
500   WRITE (1,501)
501   FORMAT (' This routine adds an offset to the real parts'/
     X        ' of a file, then multiplies by a scale factor.'/
     X        ' Full scale is 1.0'/
     X        ' ENTER OFFSET <CR> SCALE:'/)
      READ (1,506) FSET, SCALE
506   FORMAT (F10.0)
      CALL READ (DAT)
C First move does not draw.
      DRWFLG = .FALSE.
C Do the plot.
      QFLG = .FALSE.
      DO 520 N=0,1023
      IF ( QFLG ) GO TO 520
      Y = SCALE * ( DAT(1,N+1) + FSET )
      X = N * XSCALE
      CALL DRAW ( X, Y, DRWFLG )
      DRWFLG = .TRUE.
      CALL QCHEK ( QFLG )
520   CONTINUE
      CALL HOME
      GO TO 1
C
C Logarithmic magnitude plot.
C
200   LOGFLG = .TRUE.
      WRITE (1,205)
205   FORMAT (' 0 dB is full scale.'/
     X        ' Enter bottom scale decibels. >> ')
      READ (1,506) BOTDB
      BOTDB = ABS( BOTDB )
      GO TO 216
C
C Linear magnitude plot.
C
215   LOGFLG = .FALSE.
216   WRITE (1,220)
220   FORMAT (' Enter the full scale magnitude. (This will be
     X determined'/
     X ' automatically if a negative number is entered.) >> '/)
      READ (1,506) FSMAG
      CALL READ (DAT)
      IF ( FSMAG ) 250,250,265
C     Determine full scale magnitude.
250   FSMAG = 0.0
      DO 260 N=1,1024
      T = DAT(1,N)**2 + DAT(2,N)**2
      IF (T .GT. FSMAG) FSMAG = T
260   CONTINUE
      FSMAG = SQRT( FSMAG )
265   YSCALE = 1.0 / FSMAG
      DRWFLG = .FALSE.
C Do the plot.
      QFLG = .FALSE.
      DO 280 N = 0,1023
      IF ( QFLG ) GO TO 280
      Y = YSCALE *  SQRT( DAT(1,N+1)**2 + DAT(2,N+1)**2 )
      IF ( .NOT. LOGFLG ) GO TO 275
C Convert to decibels only if log plot.
      IF ( Y ) 267, 267, 270
267   DB = -600.0
      GO TO 271
270   DB = 20.0 * ALOG10 (Y)
271   Y = ( DB + BOTDB ) / BOTDB
C
275   X = N * XSCALE
      CALL DRAW ( X, Y, DRWFLG )
      DRWFLG = .TRUE.
      CALL QCHEK ( QFLG )
280   CONTINUE
      CALL HOME
      GO TO 1
C
C Plot the phase of a file
C
450   CALL READ ( DAT )
      DRWFLG = .FALSE.
      QFLG = .FALSE.
      DO 480 N = 0,1023
      IF ( QFLG ) GO TO 480
      IF (N .EQ. 1) CALL PENDN
      TMP1 = DAT(1,N+1)
      TMP2 = DAT(2,N+1)
      IF (TMP1 .NE. 0.0 .OR. TMP2 .NE. 0.0) GO TO 460
      ANGLE = 0.0
      GO TO 470
460   ANGLE = ATAN2 ( TMP2, TMP1 )
470   X = N * XSCALE
      Y = 0.5 + ANGLE / 6.283
      CALL DRAW ( X, Y, DRWFLG )
      DRWFLG = .TRUE.
      CALL QCHEK ( QFLG )
480   CONTINUE
      CALL HOME
      GO TO 1
C
C DRAW BORDER
C
300   CALL BORDER
      GO TO 1
C
C SET PLOTTER SPEED
C
350   CALL SPEED
      GO TO 1
C
C DRAW GRIDLINES
C
400   CALL GRID
      GO TO 1
                    E N D
