      SUBROUTINE PLOT (Y,NSCX,NPLT,LENGTH,NSCALE)                       PLOT0100
      REAL QDGST(6),D(6,1200)                                           PLOT0110
      INTEGER*2 A(1200),B(1200),C(1200)                                 PLOT0120
      LOGICAL*1 ITITLE,IDAY                                             PLOT0130
      COMMON /GENL/XLAMDA,WL2,DMIN,XMUR,XMAX,XMU,E(19),SC(5),ITIME,NIN,NPLOT0140
     1OUT,NPUNCH,NSCRT1,NFILE,IA,NABS,NSG,IXYZ,ITRANS,NTRANS(3,3),ISCALEPLOT0150
     2,NPLOT,JJ,NAS,NWL,ISH,ISK,ISL,IOUT,LENT,LENX,ITITLE(320),IDAY(8)          
      COMMON /XPLOT/W,TTHETA,SCMAX                                      PLOT0170
      DIMENSION Y(8001)                                                 PLOT0180
      INTEGER*2 MOVFLG/0/                                               PLOT0190
      IF (MOVFLG.GT.0) GO TO 100                                        PLOT0200
      CALL NOPRQ                                                        PLOT0210
      CALL INITQ (A,B,C,D,1200)                                         PLOT0220
      IPICT=0                                                           PLOT0230
  100 ORDX=0.0                                                          PLOT0240
      SFAC=SCMAX/100.0                                                  PLOT0250
      XLEN=LENGTH                                                       PLOT0260
      XLEN1=LENGTH                                                      PLOT0270
      NSEG=LENGTH                                                       PLOT0280
      XCORD=0.50*2.0**(4-NSCALE)                                        PLOT0290
      XDIF=XCORD                                                        PLOT0300
      IF (XCORD.GE.1.0) GO TO 110                                       PLOT0310
C  IF XCORD < 1.0 LABEL EVERY OTHER TIC MARK                            PLOT0320
      XCORD=1.0                                                         PLOT0330
      NSEG=LENGTH/2                                                     PLOT0340
      XLEN1=(LENGTH/2)*2                                                PLOT0350
  110 CALL XFSTQ (-2.0,0.0,0.14,0.14,1.570797,0.0,QDGST)                PLOT0360
      CALL LABLQ (ITITLE,LENT,QDGST,IPICT)                              PLOT0370
      CALL DISPQ (IPICT,200.0)                                          PLOT0380
      CALL REMVQ (IPICT)                                                PLOT0390
      IF (NSCX-1) 150,120,140                                           PLOT0400
C  SUPRESS NUMBERING AND LABELING OF BOTH AXES                          PLOT0410
  120 YHITE=-0.10                                                       PLOT0420
      XHITE=-0.10                                                       PLOT0430
      NDEC=-2                                                           PLOT0440
      IF (XLEN.LE.45.00) GO TO 160                                      PLOT0450
      XTLN=XLEN                                                         PLOT0460
      XTLN1=45.00                                                       PLOT0470
  130 CALL ADPTQ (XTLN1,0.0,0,IPICT)                                    PLOT0480
      XTLN1=XTLN1+45.00                                                 PLOT0490
      XTLN=XTLN-45.00                                                   PLOT0500
      IF (XTLN.GT.45.00) GO TO 130                                      PLOT0510
      GO TO 160                                                         PLOT0520
C  DRAW AND NUMBER ONLY Y-AXIS                                          PLOT0530
  140 YHITE=-0.10                                                       PLOT0540
      NDEC=-1                                                           PLOT0550
      GO TO 180                                                         PLOT0560
C  DRAW, LABEL & NUMBER Y AXIS -- DRAW & NUMBER X AXIS                  PLOT0570
  150 YHITE=-0.10                                                       PLOT0580
      XHITE=-0.10                                                       PLOT0590
      NDEC=-1                                                           PLOT0600
C  DRAW X-AXIS                                                          PLOT0610
C  NUMBER AXIS FIRST                                                    PLOT0620
      CALL XFSTQ (0.0,0.0,1.0,1.0,0.0,0.0,QDGST)                        PLOT0630
      CALL AXISQ (-XLEN1,NSEG,5.0,XCORD,-XHITE,NDEC,QDGST,IPICT)        PLOT0640
      CALL DISPQ (IPICT,200.0)                                          PLOT0650
      CALL REMVQ (IPICT)                                                PLOT0660
C  DRAW AXIS WITH TIC MARKS                                             PLOT0670
  160 CALL XFSTQ (XLEN,0.0,1.0,1.0,3.141593,0.0,QDGST)                  PLOT0680
      CALL AXISQ (XLEN,LENGTH,0.0,0.0,XHITE,-2,QDGST,IPICT)             PLOT0690
      CALL DISPQ (IPICT,200.0)                                          PLOT0700
      CALL REMVQ (IPICT)                                                PLOT0710
C                                                                       PLOT0720
C                                                                       PLOT0730
      WRITE (6,170)                                                     PLOT0740
  170 FORMAT ('0WRITE NUMBER 5')                                        PLOT0750
C                                                                       PLOT0760
C                                                                       PLOT0770
C  IF NDEC = -2 DO NOT LABEL Y-AXIS                                     PLOT0780
      IF (NDEC.EQ.-2) GO TO 180                                         PLOT0790
C  LABEL Y-AXIS                                                         PLOT0800
      CALL XFSTQ (-0.375,5.0,0.14,0.14,1.570797,0.0,QDGST)              PLOT0810
      CALL LABLQ ('INTENSITY',-9,QDGST,IPICT)                           PLOT0820
C  DRAW Y-AXIS                                                          PLOT0830
  180 CALL XFSTQ (0.0,0.0,1.0,1.0,1.570797,0.0,QDGST)                   PLOT0840
      CALL AXISQ (10.0,10,0.0,10.0,YHITE,NDEC,QDGST,IPICT)              PLOT0850
C  WRITE "SCALE FACTOR"                                                 PLOT0860
      CALL XFSTQ (1.0,9.5,0.21,0.21,0.0,0.0,QDGST)                      PLOT0870
      CALL LABLQ ('SCALE FACTOR =',14,QDGST,IPICT)                      PLOT0880
      SCLE=1.375*2.0**(4-NSCALE)+6.0                                    PLOT0890
C  WRITE THE SCALE FACTOR USED                                          PLOT0900
      CALL XFSTQ (3.94,9.5,0.21,0.21,0.0,0.0,QDGST)                     PLOT0910
      CALL NMBRQ (SFAC,2,1,QDGST,IPICT)                                 PLOT0920
C  DISPLAY AXES                                                         PLOT0930
      CALL DISPQ (IPICT,200.0)                                          PLOT0940
      CALL REMVQ (IPICT)                                                PLOT0950
C     AXES DRAWN, SET UP FOR PLOTTING CURVE                             PLOT0960
      IF (Y(1).LT.100.0) GO TO 190                                      PLOT0970
      YABS=10.0                                                         PLOT0980
      GO TO 200                                                         PLOT0990
  190 YABS=Y(1)/10.0                                                    PLOT1000
C  MOVE PEN TO FIRST POINT                                              PLOT1010
  200 CALL ADPTQ (ORDX/XDIF,YABS,0,IPICT)                               PLOT1020
      NOPTS=1                                                           PLOT1030
C  PLOT POINTS ON GRAPH                                                 PLOT1040
      IF (NPLT.LE.8001) GO TO 220                                       PLOT1050
      PRINT 210, NPLT                                                   PLOT1060
  210 FORMAT ('0NPLT=',I8//////)                                        PLOT1070
      NPLT=8001                                                         PLOT1080
  220 DO 250  NP=2,NPLT                                                 PLOT1090
      ORDX=ORDX+0.02                                                    PLOT1100
      IF (Y(NP).LT.100.0) GO TO 230                                     PLOT1110
      YABS=10.0                                                         PLOT1120
      GO TO 240                                                         PLOT1130
  230 YABS=Y(NP)/10.0                                                   PLOT1140
  240 CALL ADPTQ (ORDX/XDIF,YABS,1,IPICT)                               PLOT1150
      NOPTS=NOPTS+1                                                     PLOT1160
      IF (NOPTS.LE.2600) GO TO 250                                      PLOT1170
      CALL DISPQ (IPICT,200.0)                                          PLOT1180
      CALL REMVQ (IPICT)                                                PLOT1190
      NOPTS=0                                                           PLOT1200
  250 CONTINUE                                                          PLOT1210
      CALL DISPQ (IPICT,200.0)                                          PLOT1220
      CALL REMVQ (IPICT)                                                PLOT1230
      CALL PAWZQ                                                        PLOT1240
      CALL MOOVQ ((XLEN+4.0)*200.0,0.0)                                 PLOT1250
      MOVFLG=1                                                          PLOT1260
      RETURN                                                            PLOT1270
      END                                                                       
