C READS FROM STANDARD OUT3 AND PLOTS CONTOURS DIRECTLY
      PARAMETER(NMAX=29999,NCOLOR=15,NPLOT=10000)
      IMPLICIT REAL*8 (A-H,O-Z)
      LOGICAL FOUND
      CHARACTER HED*80,ANSW,JUNK*80
      DIMENSION XOUT(NPLOT),YOUT(NPLOT),IOUT(NPLOT)
      DIMENSION X(44,40),Y(44,40),Z(44,40)
      DIMENSION XX(NMAX),YY(NMAX),ZZ(NMAX),NNODE(NMAX),NBOUND(400)
      DIMENSION PSURF(NMAX),FRACT(NMAX),FLOWA(NMAX),HTICE(NMAX)
      DIMENSION ADOT(NMAX),WWW(NMAX),WRATE(NMAX),THK(NMAX)
      DIMENSION DEPB(NMAX),SLDGB(NMAX),AFUDGE(NMAX),TBED(NMAX)
      DIMENSION WTHICK(NMAX),BMELT(NMAX),WWWBASE(NMAX)
      DIMENSION XLINE(400),YLINE(400)
      DIMENSION KX(NMAX,4),IK(5)
      DIMENSION ICMAP(NCOLOR)
      DIMENSION INARAY(3)
      DATA ICMAP /1,2,3,4,5,6,7,8,9,10,11,12,13,14,15/
      IDISP=1
      II=1
      DO I=1,NPLOT
        READ(12,*,END=21) XIN,YIN,IIN
        IF(XIN.EQ.-99999.) THEN
          READ(12,22) JUNK
22    FORMAT(A80)
        ELSE
          XOUT(II)=XIN
          YOUT(II)=YIN
          IOUT(II)=IIN
          NOUT=II
          II=II+1
        ENDIF
      ENDDO
21    CONTINUE
C *** FOLLOWING IS LEVEL SPACING
      ISEG=1
3     CONTINUE
      WRITE(*,*) 'INPUT -N FOR DISPLAY STEP'
      WRITE(*,*) 'INPUT  0 FOR HTICE,'
      WRITE(*,*) '       1 FOR BDROCK,'
      WRITE(*,*) '       2 FOR ADOT,'
      WRITE(*,*) '       3 FOR FRACT'
      WRITE(*,*) '       4 FOR FLOW CONSTANT,'
      WRITE(*,*) '       5 FOR DIFFERENCE,'
      WRITE(*,*) '       6 FOR THICKNESS,'
      WRITE(*,*) '       7 FOR MARGIN,'
      WRITE(*,*) '       8 FOR PSURF,'
      WRITE(*,*) '       9 FOR ZONE,'
      WRITE(*,*) '      10 FOR SLIDING CONSTANT,'
      WRITE(*,*) '      11-FOR AFUDGE'
      WRITE(*,*) '      12-FOR TBED'
      WRITE(*,*) '      13-FOR BASAL MELT RATE'
      WRITE(*,*) '      14-FOR WATER THICKNESS '
      WRITE(*,*) '      15-FOR BEDROCK DEPRESSION '
      WRITE(*,*) '      16-FOR RATE OF BEDROCK DEPRESSION '
      WRITE(*,*) '      17-FOR BEDROCK DEPRESSION DIFFERENCE '
      WRITE(*,*) '      99-QUIT'
      READ(*,*,END=9999) IPLOT
      IF(IPLOT.EQ.99) GOTO 9999
  350 FORMAT (I6)
      IF(IPLOT.LT.0) THEN
        IDISP=ABS(IPLOT)
        GOTO 3
      ENDIF
      PRINT *,' THIS IS IPLOT',IPLOT
      write(*,*) ' which node to output?'
      read(*,*) idnode
      ISTART=1
1001  FORMAT(16I6)
C READ INPUT HEADER
      READ(30,1000,END=999) HED,NUMNP,NUMEL,NUMCOL,NUMLEV,NUMGBC,NDT,
     &              INTER,DT
1000  FORMAT (A80,/,7I6,F8.0)
C READ INPUT GRID, THINGS THAT NEVER CHANGE
      READ(31) HED
      READ(31) (KODE,I=1,NUMNP)
      READ(31) (XX(I),I=1,NUMNP)
      READ(31) (YY(I),I=1,NUMNP)
      READ(31) (PSURF(I),I=1,NUMNP)
      READ(31) (AJUNK,I=1,NUMNP)
      READ(31) (KX(I,1),KX(I,2),KX(I,3),KX(I,4),I=1,NUMEL)
      READ(31) (IB1,IB2,BJUNK,I=1,NUMGBC)
C READ INPUT DIFFER, THINGS THAT DIFFER FROM ONE GRID TO THE NEXT
      READ(32) HED
      READ(32) (AJUNK,I=1,NUMNP)
      READ(32) (FRACT(I),I=1,NUMNP)
      READ(32) (FLOWA(I),I=1,NUMNP)
      READ(32) (SLDGB(I),I=1,NUMNP)
      DO NUM=1,NUMNP
        XX(NUM)=XX(NUM)*.001
        YY(NUM)=YY(NUM)*.001
      ENDDO
      IREAD=0
1     CONTINUE
      IREAD=IREAD+1
C READ INPUT TIME, THINGS THAT CHANGE WITH TIME
      IF(IPLOT.EQ.0 .OR. IPLOT.EQ.1 .OR.IPLOT.EQ.2 .OR.
     &   IPLOT.EQ.5 .OR. IPLOT.EQ.6 .OR.IPLOT.EQ.7 .OR.
     &   IPLOT.EQ.9 .OR. IPLOT.EQ.3 .OR. IPLOT.EQ.4 .OR. 
     &   IPLOT.EQ.11) THEN
         READ(33,END=999) HED
         READ(33) (HTICE(I),I=1,NUMNP)
         READ(33) (ADOT(I),I=1,NUMNP)
         READ(33) (DEPB(I),I=1,NUMNP)
         READ(33) (CONST,I=1,NUMEL)
         READ(33) (ACON,I=1,NUMEL)
         READ(34) (FRACT(I),I=1,NUMNP)
         READ(34) (FLOWA(I),I=1,NUMNP)
         READ(34) (SLDGB(I),I=1,NUMNP)
         READ(34) (AFUDGE(I),I=1,NUMNP)
      ELSEIF(IPLOT.EQ.12 .OR. IPLOT.EQ.13 .OR. IPLOT.EQ.14) THEN
         READ(36,END=999) HED
         READ(36) (TBED(I),I=1,NUMNP)
         READ(36) (BMELT(I),I=1,NUMNP)
         READ(36) (WTHICK(I),I=1,NUMNP)
      ELSEIF(IPLOT.EQ.15 .OR. IPLOT.EQ.16 .OR. IPLOT.EQ.17) THEN
         READ(37,END=999) HED
         READ(37) (WWW(I),I=1,NUMNP)
         READ(37) (THK(I),I=1,NUMNP)
         READ(37) (WRATE(I),I=1,NUMNP)
        IF(IREAD.EQ.2) THEN
          DO I=1,NUMNP
            WWWBASE(I)=WWW(I)
          ENDDO
        ENDIF
      ENDIF
      if(idisp.ne.1) PRINT *,IREAD,IDISP,MOD(IREAD,IDISP)+1
      IF(MOD(IREAD,IDISP)+1.NE.1) GOTO 1
        NUM=IDNODE
C CHANGE PLOTTED VARIABBLE HERE
        IF(IPLOT.EQ.0) zznum=HTICE(NUM)
        IF(IPLOT.EQ.1) zznum=DEPB(NUM)
        IF(IPLOT.EQ.2) zznum=ADOT(NUM)
        IF(IPLOT.EQ.3) zznum=FRACT(NUM)
        IF(IPLOT.EQ.4) zznum=FLOWA(NUM)
        IF(IPLOT.EQ.5) zznum=HTICE(NUM)-PSURF(NUM)
        IF(IPLOT.EQ.6 .OR. IPLOT.EQ.7) THEN
          zznum=HTICE(NUM)-DEPB(NUM)
          IF(DEPB(NUM).LT.0.) THEN
c            FLOT=-DEPB(NUM)*1.03/.917
            FLOT=DEPB(NUM)*(1.-1.03/.917)
            IF(HTICE(NUM).LT.FLOT) zznum=0.
          ENDIF
          IF(zznum.LT.10.) zznum=0.
        ENDIF
        IF(IPLOT.EQ.8) zznum=PSURF(NUM)
        IF(IPLOT.EQ.9) zznum=ADOT(NUM)
        IF(IPLOT.EQ.10) zznum=SLDGB(NUM)
        IF(IPLOT.EQ.11) zznum=AFUDGE(NUM)
        IF(IPLOT.EQ.12) zznum=TBED(NUM)
        IF(IPLOT.EQ.13) zznum=BMELT(NUM)*1000.
        IF(IPLOT.EQ.14) zznum=WTHICK(NUM)
        IF(IPLOT.EQ.15) zznum=WWW(NUM)
        IF(IPLOT.EQ.16) zznum=WRATE(NUM)
        IF(IPLOT.EQ.17) zznum=WWW(NUM)-WWWBASE(NUM)
        write(junk,*) hed
        read(junk,2000) ttime
        write(*,*) 'time=',ttime,zznum
2000  format(8x,f20.0)
        itime=nint(ttime)
        WRITE(9,*) REAL(ttime/1000),zznum
      GOTO 1
999   CONTINUE
9999  CONTINUE
      WRITE(9,*) -99999.,0.
      WRITE(9,*) IPLOT
      END
