      SUBROUTINE PLOT(NA,VECT)
      LOGICAL NF,LP
      REAL XXX(60,6),XXO(10),XXY(60),XXZ(60)
      INTEGER FIRST,I1(20,60),I2(60,12),I3(60)
      DIMENSION VECT(4),W(2,50),V(4,50),DRA(21)
      COMMON XXX,XXO,XXY,XXZ,I1,I2,DRA,I5,I6,I4,I3,IT
      COMMON /LIMITS/XMIN,XMAX,YMIN,YMAX
      COMMON /OIL/IVECT(200)
      DATA NF/.FALSE./
      DATA INUM/0/
      DATA F1,F2/5H(G12.,5H4)   /
      DATA P1,P2/5HINCAM,4H4BIN/
      DATA FOR/4H(I4)/
      N=IABS(NA)
      IF(N.NE.NA)GO TO 34
      IF(NF)GO TO 1
      NF=.TRUE.
      CALL SETPEN(ITAG,LP,IXX,IYY)
      XMIN=0.
      XMAX=1023.
      YMIN=VECT(1)
      YMAX=VECT(1)
      DO 2 I=1,N
      VE=VECT(I)
      IF(VE.LT.YMIN)YMIN=VE
    2 IF(VE.GT.YMAX)YMAX=VE
      R=1.
      IF(YMAX-YMIN.GT.1.)R=YMAX-YMIN
      YMAX=YMAX+5.*R
      YMIN=YMIN-5.*R
   21 LP=.FALSE.
      CALL MENCRT(P1,P2,1)
      J=1
      IF(IT.EQ.2000)GO TO 24
      DO 23 I=2000,IT
   23 CALL CRT(3,I)
24    IT=2007
       V(1,1)=18.
       V(2,1)=YMIN
       V(3,1)=18.
       V(4,1)=YMAX
       V(1,2)=XMIN
       VE=(YMAX+YMIN)/2.
       V(2,2)=YMIN+(YMAX-YMIN)/50.
       V(3,2)=XMAX
       V(4,2)=V(2,2)
       CALL VECTOR (1,V,1,2,IVECT,1,LAST,5,1,.FALSE.)
       CALL CRT(6,2000,IVECT,1,LAST)
       DO25I=1,N
25     V(I,1)=VECT(I)
       CALL CRT(2,2004,0,20,6,1,F1,YMIN)
       CALL CRT(2,2005,0,1007,6,1,F1,YMAX)
       CALL CRT(2,2006,0,512,6,1,F1,VE)
       CALL CRT(2,2001,20,0,6,1,FOR,INUM)
       INUM=INUM+24
       CALL CRT(2,2002,450,0,6,1,FOR,INUM)
       INUM=INUM+24
       CALL CRT(2,2003,850,0,6,1,FOR,INUM)
       RETURN
1      IF(J.LE.48)GOTO36
34     CALL MENCRT(P1,P2,0)
       CALL MENCRT(P1,P2,2)
       IX=380
       DO 30 I=1,N
       JTA=900+I
       IY=980-I*20
30     CALL CRT(2,JTA,IX,IY,6,1,FOR,I)
       IX=420
       DO 31 I=1,N
       JTA=JTA+1
       IY=980-I*20
       DIS=VECT(I)
  31   CALL CRT(2,JTA,IX,IY,6,1,F1,DIS)
       LP=.FALSE.
32     IF(.NOT.LP)GO TO 32
       CALL MENCRT(P1,P2,0)
       CALL CRT(4,1001)
       DO 33 I=901,JTA
33     CALL CRT(3,I)
       IF(N.NE.NA)GOTO40
       IF(ITAG.EQ.1004)GOTO40
       IF(J.LE.48)GO TO 20
       GOTO 21
36     IF(.NOT.LP)GO TO 20
       IF(ITAG.EQ.1001)GO TO 34
       LP=.FALSE.
20     JO=J
       J=J+1
5      YX=YMAX-(YMAX-YMIN)*15./1023.
       YN=YMIN+(YMAX-YMIN)*15./1023.
       DO 3 I=1,N
       VE=VECT(I)
       IF(VE.LT.YN.OR.VE.GT.YX)GOTO4
3      V(I,J)=VE
       IX=J*18
       KX=IX-15
       DO6I=1,N
       W(1,1)=JO*18
       W(1,2)=IX
       W(2,1)=V(I,JO)
       W(2,2)=VECT(I)
       IY=(W(2,2)-YMIN)*1023./(YMAX-YMIN)
       IF(IY.LT.0)IY=0
       IF(IY.GT.1000)IY=1000
       IZ=I+3000
C      CALL CRT(2,IZ,KX,IY,6,1,FOR,I)
       CALL VECTOR(3,W,1,2,IVECT,1,LAST,7,1,.FALSE.)
       IT=IT+1
       CALL CRT(6,IT,IVECT,1,LAST)
6      CONTINUE
       RETURN
4      DO7I=1,N
       VE=VECT(I)
       IF(VE.LT.YMIN)YMIN=VE
7      IF(VE.GT. YMAX)YMAX=VE
       YMAX=YMAX+10.*(YMAX-YX)
       YMIN=YMIN+10.*(YMIN-YN)
       PAUSE 1
       CALL CLEAR(.TRUE.)
       PAUSE 2
       CALL CRT (4,2000)
       PAUSE 3
       CALL CRT(2,2004,0,20,6,1,F1,YMIN)
       CALL CRT(2,2005,0,1007,6,1,F1,YMAX)
       VE=(YMAX+YMIN)/2.
       CALL CRT(2,2006,0,512,6,1,F1,VE)
       PAUSE 4
       CALL CRT(4,2001)
       CALL CRT(4,2002)
       CALL CRT(4,2003)
       CALL CRT(4,1001)
       DO10I=1,N
       IT=IT+1
       DO8JN=1,JO
       W(1,JN)=JN*18
8      W(2,JN)=V(I,JN)
       PAUSE 6
       CALL VECTOR(3,W,1,JO,IVECT,1,LAST,7,1,.FALSE.)
       PAUSE 7
       CALL CRT(6,IT,IVECT,1,LAST)
10     CONTINUE
       PAUSE 5
       GOTO5
40     NA=-N
       DO230I=2000,IT
230    CALL CRT(3,I)
       IT=2000
       RETURN
       END
