



      CHARACTER*80 FUNCTION EPSNEW()




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'EPSINC.INC'
      INTEGER       EPSPLTNUM
      LOGICAL       GVFFOP
      CHARACTER*80  FILENAME
      SAVE EPSPLTNUM
      DATA EPSPLTNUM /0/







      IF (WIFPAR(473).GE.1) GOTO 998

      IF (GVFFOP(EPSUNIT)) THEN
         CALL EPSCLOSE
      END IF
      CALL GVSCTB (FILENAME,80)
      CALL GVSSTX (FILENAME,'epsXXXX.eps')
      EPSPLTNUM=EPSPLTNUM+1
      IF (EPSPLTNUM.GE.10000) THEN
         CALL GVSTTE ('?NEWE555')
         CALL GVSSTX (EPSNEW,'noname.eps')
         RETURN
      END IF
      WRITE(FILENAME(4:7),1000) EPSPLTNUM
      CALL EPSOPEN (FILENAME)
      EPSNEW=FILENAME



 998  CONTINUE


 1000 FORMAT(I4.4)

      RETURN
      END
      SUBROUTINE EPSOPEN(FILENAME)



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'
      CHARACTER*(*) FILENAME
      LOGICAL       GVFFOP

      IF (GVFFOP(EPSUNIT)) THEN
         CALL GVSTTB ('?NEWB199')
         CALL EPSCLOSE
      END IF
      OLDX=OUTOFRANGE
      OLDY=OUTOFRANGE
      LINEWIDTH=2
      CALL GVSOPF (FILENAME,EPSUNIT,'UNKNOWN')
      CALL EPSPUT ('%!PS-Adobe-2.0 EPSF-2.0')
      CALL EPSPUT ('%%Creator: WHAT IF')
      CALL EPSPUT ('%%BoundingBox: 18 18 578 578')
      CALL EPSPUT ('/d {def} def')
      CALL EPSDEF ('/M','{moveto}')
      CALL EPSDEF ('/L','{lineto}')
      CALL EPSDEF ('/m','{rmoveto}')
      CALL EPSDEF ('/l','{rlineto}')
      CALL EPSDEF ('/v','{0 exch l}')
      CALL EPSDEF ('/h','{0 l}')
      CALL EPSDEF ('/x','{dup l}')
      CALL EPSDEF ('/y','{dup neg l}')
      CALL EPSDEF ('/V','{0 exch m}')
      CALL EPSDEF ('/H','{0 m}')
      CALL EPSDEF ('/X','{dup m}')
      CALL EPSDEF ('/Y','{dup neg m}')
      CALL EPSDEF ('/s','{stroke}')
      CALL EPSDEF ('/f','{fill}')
      CALL EPSDEF ('/lw','{setlinewidth}')
      CALL EPSDEF ('/lws','{lw s}')
      CALL EPSDEF ('/c','{1.0 0.6 sethsbcolor}')
      CALL EPSPUT ('18 18 translate')
      CALL EPSPUT ('0.1 0.1 scale')
      CALL EPSPUT ('1 setlinecap')
      CALL EPSPUT ('1 setlinejoin')
      CALL EPSPUT ('3 setmiterlimit')
      CALL EPSMOVE (-10.,-10.)
      CALL EPSDRAW (-10.,+10.)
      CALL EPSDRAW (+10.,+10.)
      CALL EPSDRAW (+10.,-10.)
      CALL EPSDRAW (-10.,-10.)
      CALL EPSPUT ('closepath')
      CALL EPSPUT ('clip')
      CALL EPSSTROKE
      RETURN
      END
      SUBROUTINE EPSCLOSE



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'

      IF (EPSVECCNT.GT.0) THEN
         CALL GVSTTB ('?NEWB200')
         CALL EPSSTROKE
      END IF
      CALL EPSPUT ('showpage')
      CALL EPSPUT ('% End of PLOT by WHAT IF')
      CALL EPSFLUSH
      CALL GVSCLF (EPSUNIT)

      RETURN
      END
      SUBROUTINE EPSSETLINEWIDTH(P)



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'
      REAL          P

      LINEWIDTH=NINT(10.0*P)

      RETURN
      END
      SUBROUTINE EPSCOLOR(P)



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'
      INTEGER       P

      IF (P.NE.PATHCOLOR) THEN
         CALL EPSSTROKE
         PATHCOLOR=P
         CALL EPSPUTF (FLOAT(MOD(P+240,360))/360.0)
         CALL EPSPUT ('c')
      END IF

      RETURN
      END
      SUBROUTINE EPSDRAW (X,Y)



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'
      INTEGER       IX, IY, JX, JY, NDIG
      REAL          X, Y

      IF (X.EQ.OLDX.AND.Y.EQ.OLDY) RETURN
      IX=NINT(5600*(X+10.0)/20.0)
      IY=NINT(5600*(Y+10.0)/20.0)
      JX=NINT(5600*(X-OLDX)/20.0)
      JY=NINT(5600*(Y-OLDY)/20.0)



      IF (NDIG(JX)+NDIG(JY).LT.NDIG(IX)+NDIG(IY)) THEN
         IF (JX.NE.0.OR.JY.NE.0) THEN
            IF (JX.EQ.0) THEN
               CALL EPSPUTI (JY)
               CALL EPSPUT ('v')
            ELSE IF (JY.EQ.0) THEN
               CALL EPSPUTI (JX)
               CALL EPSPUT ('h')
            ELSE IF (JX.EQ.JY) THEN
               CALL EPSPUTI (JX)
               CALL EPSPUT ('x')
            ELSE IF (JX.EQ.-JY) THEN
               CALL EPSPUTI (JX)
               CALL EPSPUT ('y')
            ELSE
               CALL EPSPUTI (JX)
               CALL EPSPUTI (JY)
               CALL EPSPUT ('l')
            END IF
         END IF
      ELSE
         CALL EPSPUTI (IX)
         CALL EPSPUTI (IY)
         CALL EPSPUT ('L')
      END IF





      OLDX=IX*20./5600-10.0
      OLDY=IY*20./5600-10.0
      EPSVECCNT=EPSVECCNT+1
      IF (EPSVECCNT.GT.512) THEN
         CALL EPSSTROKE
         CALL EPSPUTI (IX)
         CALL EPSPUTI (IY)
         CALL EPSPUT ('M')
      END IF
      RETURN
      END
      SUBROUTINE EPSPUTI (II)



















      IMPLICIT      NONE
      INTEGER       I,II
      CHARACTER*7   C

      I=II
      IF (ABS(I).GT.999999) I=(I/ABS(I))*999999
      WRITE (C,1000,ERR=999) I
      CALL EPSPUT (C)
      RETURN

 999  CALL GVSTTB ('?NEWB201')
      CALL GVSTTI ('?NEWZ88',I)

 1000 FORMAT(I7)

      RETURN
      END
      SUBROUTINE EPSPUTF (FF)



















      IMPLICIT      NONE
      REAL          F,FF
      CHARACTER*7   C

      F=FF
      IF (ABS(F).GT.99.999) F=(F/ABS(F))*99.999
      WRITE (C,1000,ERR=999) F
      CALL EPSPUT (C)
      RETURN

 999  CALL GVSTTB ('?NEWB201A')
      CALL GVSTTR ('?NEWZ88A',F)

 1000 FORMAT(F7.3)

      RETURN
      END
      SUBROUTINE EPSMOVE (X,Y)



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'
      INTEGER       IX, IY, JX, JY, NDIG
      REAL          X, Y

      IF (X.EQ.OLDX.AND.Y.EQ.OLDY) RETURN
      IX=NINT(5600*(X+10.0)/20.0)
      IY=NINT(5600*(Y+10.0)/20.0)
      JX=NINT(5600*(X-OLDX)/20.0)
      JY=NINT(5600*(Y-OLDY)/20.0)



      IF (NDIG(JX)+NDIG(JY).LT.NDIG(IX)+NDIG(IY)) THEN
         IF (JX.NE.0.OR.JY.NE.0) THEN
            IF (JX.EQ.0) THEN
               CALL EPSPUTI (JY)
               CALL EPSPUT ('V')
            ELSE IF (JY.EQ.0) THEN
               CALL EPSPUTI (JX)
               CALL EPSPUT ('H')
            ELSE IF (JX.EQ.JY) THEN
               CALL EPSPUTI (JX)
               CALL EPSPUT ('X')
            ELSE IF (JX.EQ.-JY) THEN
               CALL EPSPUTI (JX)
               CALL EPSPUT ('Y')
            ELSE
               CALL EPSPUTI (JX)
               CALL EPSPUTI (JY)
               CALL EPSPUT ('m')
            END IF
         END IF
      ELSE
         CALL EPSPUTI (IX)
         CALL EPSPUTI (IY)
         CALL EPSPUT ('M')
      END IF
      EPSVECCNT=EPSVECCNT+1





      OLDX=IX*20./5600-10.0
      OLDY=IY*20./5600-10.0
      IF (EPSVECCNT.GT.512) THEN
         CALL EPSSTROKE
         CALL EPSPUTI (IX)
         CALL EPSPUTI (IY)
         CALL EPSPUT ('M')
      END IF
      RETURN
      END
      SUBROUTINE EPSPUT (S)



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'
      CHARACTER*(*) S
      INTEGER       L, I, GVFLEN
      LOGICAL       BLANK

      L=GVFLEN(S)
      IF (S(1:1).EQ.'%'.OR.(EPSBUFCNT.GT.0.AND.EPSBUF(1).EQ.'%'))
     +     CALL EPSFLUSH
      IF (L.GT.MAXEPSBUF) THEN
         CALL GVSTTB ('?NEWB202')
         RETURN
      END IF
      IF (L+EPSBUFCNT.GT.MAXEPSBUF) CALL EPSFLUSH
      BLANK=.TRUE.
      DO 10 I=1,L
         IF (S(I:I).EQ.' ') THEN
            IF (.NOT.BLANK) THEN
               EPSBUFCNT=EPSBUFCNT+1
               EPSBUF(EPSBUFCNT)=S(I:I)
               BLANK=.TRUE.
            END IF
         ELSE
            BLANK=.FALSE.
            EPSBUFCNT=EPSBUFCNT+1
            EPSBUF(EPSBUFCNT)=S(I:I)
         END IF
 10   CONTINUE
      IF (EPSBUFCNT.EQ.MAXEPSBUF) THEN
         CALL EPSFLUSH
      ELSE IF (EPSBUFCNT.EQ.0) THEN
         CONTINUE
      ELSE IF (EPSBUF(EPSBUFCNT).NE.' ') THEN
         EPSBUFCNT=EPSBUFCNT+1
         EPSBUF(EPSBUFCNT)=' '
      END IF

      RETURN
      END
      SUBROUTINE EPSFLUSH



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'
      INTEGER       I
      LOGICAL       GVFFOP

      IF (.NOT.GVFFOP(EPSUNIT)) THEN
         CALL GVSTTB ('?NEWB203')
         EPSBUFCNT=0
         RETURN
      END IF
      IF (EPSBUFCNT.GT.0) THEN
         IF (EPSBUF(EPSBUFCNT).EQ.' ') EPSBUFCNT=EPSBUFCNT-1
      END IF
      IF (EPSBUFCNT.GT.0) THEN
         WRITE (EPSUNIT,1000,ERR=999) (EPSBUF(I),I=1,EPSBUFCNT)
         EPSBUFCNT=0
      END IF
      RETURN
 999  CALL GVSTTE ('?NEWE556')

 1000 FORMAT (132A1)

      RETURN
      END
      SUBROUTINE EPSSTROKE



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'

      IF (EPSVECCNT.EQ.0) THEN
         RETURN
      END IF
      CALL EPSPUTI (LINEWIDTH)
      CALL EPSPUT ('lws')
      EPSVECCNT=0
      OLDX=OUTOFRANGE
      OLDY=OUTOFRANGE

      RETURN
      END
      SUBROUTINE EPSFILL



















      IMPLICIT      NONE
      INCLUDE       'EPSINC.INC'

      IF (EPSVECCNT.EQ.0) THEN
         CALL GVSTTB ('?NEWB204')
         RETURN
      END IF
      CALL EPSPUT ('f')
      EPSVECCNT=0

      RETURN
      END
      SUBROUTINE EPSDEF (S1,S2)



















      IMPLICIT      NONE
      CHARACTER*(*) S1,S2

      CALL EPSPUT (S1)
      CALL EPSPUT (S2)
      CALL EPSPUT ('d')

      RETURN
      END
      INTEGER FUNCTION NDIG(I)



















      IMPLICIT      NONE
      INTEGER       I, N

      N=0
      IF (I.LT.0) N=1
      IF (ABS(I).LT.10) THEN
         N=N+1
      ELSE IF (ABS(I).LT.100) THEN
         N=N+2
      ELSE IF (ABS(I).LT.1000) THEN
         N=N+3
      ELSE IF (ABS(I).LT.10000) THEN
         N=N+4
      ELSE IF (ABS(I).LT.100000) THEN
         N=N+5
      ELSE
         N=N+6
      END IF
      NDIG=N

      RETURN
      END
      SUBROUTINE EPS008 (FROW,TROW,COL,NUM,PENTYP,STEREO)





















      IMPLICIT      NONE
      INTEGER       NUM, IVEC, COL(NUM)
      REAL          GVFDTR, FROW(3,NUM), TROW(3,NUM), RMAT(3,3), 
     +              PENTYP, LV(3)
      LOGICAL       STEREO



      CALL EPSSETLINEWIDTH (PENTYP)
      IF (STEREO) THEN
         CALL GVSMYM (RMAT,GVFDTR(6.0))
      ELSE
         CALL GVSMTU (RMAT,3)
      END IF
      CALL EPSMOVE (FROW(1,1),FROW(2,1))
      CALL EPSDRAW (TROW(1,1),TROW(2,1))



      DO 100 IVEC=1,NUM
         CALL EPSCOLOR (COL(IVEC))



         CALL GVSMV3 (LV,RMAT,FROW(1,IVEC))
         CALL EPSMOVE (LV(1),LV(2))
         CALL GVSMV3 (LV,RMAT,TROW(1,IVEC))
         CALL EPSDRAW (LV(1),LV(2))
 100  CONTINUE



      CALL EPSSTROKE

      RETURN
      END
