       INCLUDE 'FGRAPH.FI'

C****************************************************************************

      Subroutine GET_VIDEO_MODE (numtextrows)



      INCLUDE 'FGRAPH.FD'

      INTEGER*2 numtextrows



      numtextrows = SETVIDEOMODE ($MAXRESMODE)

      if (numtextrows .eq.0) then

	  PRINT*, 'ERROR:  Unsupported graphics board.'

          print*,' '

          print*,'You need a Hercules, CGA, EGA or VGA adapter.'

          print*,' '

          print*,'If you have a Hercules card, be sure that the '

          print*,'Hercules driver has been installed.  After you'

          print*,'stop this program, type:  MSHERC'

          print*,' '

          print*,'This will install the MicroSoft Hercules driver.'

          print*,' '

	  PRINT*, 'Press ENTER to continue with no screen graphics.'

          print*,' '

	  PAUSE	'Press CTRL-Break to quit.'

      endif



      RETURN

      END

C****************************************************************************

      Subroutine VT_CONFIG (xmin,xmax,ymin,ymax, rayflag, numypixel,

     &			    ax, bx, ay, by, numtextrow, numtextcol,

     &			    pixlpercol, pixlperrow)



      INCLUDE 'FGRAPH.FD'



      RECORD / videoconfig / vc



      REAL      pixlpercol,

     &		pixlperrow



      LOGICAL rayflag

C==>



      call GETVIDEOCONFIG (vc)

      numxpixel = vc.numxpixels

      numypixel = vc.numypixels

      numtextcol = vc.numtextcols

      numtextrow = vc.numtextrows



      if (rayflag) then



	   numrowtop = 9

	   numrowbot = 4

	   numcolleft = 9

	   numcolrt = 21

      else

	   numrowtop = 4

	   numrowbot = 4

	   numcolleft = 9

	   numcolrt = 9

      endif

C Calculate the number of pixels per row and column.  This is used for

C determining text locations.



      pixlpercol = FLOAT(numxpixel)/numtextcol

      pixlperrow = FLOAT(numypixel)/numtextrow



C Calculate the transformation factors for pixel-space.



      fhx = (FLOAT(numtextcol-numcolrt)-0.5)/numtextcol

      flx = (FLOAT(numcolleft)-0.5)/numtextcol

      fhy = (FLOAT(numtextrow-numrowtop)-0.2)/numtextrow

      fly = (FLOAT(numrowbot)+0.2)/numtextrow



      ax = (fhx-flx)*numxpixel/(xmax-xmin)

      bx = (flx*numxpixel)-(xmin*ax)

      ay = (fhy-fly)*numypixel/(ymax-ymin)

      by = (fly*numypixel)-(ymin*ay)



      return

      end

C************************************************************************

      Subroutine PLOT_PTS_VT (xmin,xmax,ymin,ymax, x, y,

     &                        xreal, yreal, numpts,

     &			      marker, rayflag, conflag,

     &			      numxticks, numyticks, num_pt_plots,

     &                        slomofact, eigflag)



C This routine is the main entry point to the screen graphics portion of

C the program.	In the event that MICROSOFT graphics are not used, this

C routine could still be used as the main interface to the graphics routines

C and the subroutines that are called herein would then be altered to call

C graphics routines other than MICROSOFT's.

C

C INPUT:

C        rayflag = True (rayplots), False (profiles)

C        conflag = True (contour plots), if true, then rayflag is also true

C	 numxticks, numyticks -

C        mins and maxes -

C        X,Y - integer*2 arrays of values to be plotted for rayplots, contours.

C        XREAL,YREAL - real arrays of profile points.  These are dummied when

C        this routine is called for rayplots or contour plots.  The reason

C        for the two array types is that HARPO and CONPLT output x,y coord-

C        inates as integers whereas PROFILE outputs real numbers to be

C        scaled and then plotted.  It is not possible to use one of the

C        intrinsic functions (e.g. NINT) on PROFILE points since you would

C        end up rounding the numbers to almost all the same number.  On the

C        other hand, if you create real arrays for the HARPO/CONPLT points,

C        you use twice as much memory as the INTEGER*2 arrays and this has

C        led to compilation problems e.g. the dreaded 64K limit on PCs.



      INTEGER marker,

     &	      numpts,

     &	      maxpts,

     &	      numtextrow,

     &	      numtextcol



      PARAMETER (maxpts = 4000)



      REAL

     &          xreal(0:1000), yreal(0:1000),    !  Profile Plots

     &          pixlpercol,

     &          pixlperrow,

     &          slomofact



      INTEGER*2

     &          x(0:maxpts),

     &          y(0:maxpts),

     &          intx(0:maxpts),

     &		inty(0:maxpts),

     &          xmin_p, xmax_p, ymin_p, ymax_p



      LOGICAL  rayflag,

     &         conflag,

     &         eigflag



C.....Don't bother setting up the screen coordinates if the input minimum

C     and maximum values have not changed between frames.  The first time

C     this is called, the xminold etc should all be equal to zero, thus

C     VT_CONFIG would be called.



      if (xmin.ne.xminold .or. xmax.ne.xmaxold .or.

     &	  ymin.ne.yminold .or. ymax.ne.ymaxold) then



	  call VT_CONFIG (xmin,xmax,ymin,ymax, rayflag, numypixel, ax,

     &	       bx, ay, by, numtextrow, numtextcol,

     &	       pixlpercol, pixlperrow)



C Define the clipping region : bounded by upper left, lower right x,y values.

C The "_p" denotes pixel.

c The clipping region also defines the border of the frame rectangle.



	   xmin_p = NINT(ax*xmin + bx)

	   xmax_p = NINT(ax*xmax + bx)

	   ymin_p = NINT(numypixel-(ay*ymin+by) )

	   ymax_p = NINT(numypixel-(ay*ymax+by) )



C.....For HARPO ray plots and contour plots , DO NOT make a frame

C     or draw ticks, i.e. only for profiles and eigen plots should we make a

C     frame etc.

C     HARPO and CONPLT use moveto,linetos to draw lines whereas PROFILE and

C     EIGEN just give the min,max values and the LL corner and we figure out

C     how to draw the frame and tick marks.



           if (.not. rayflag) then

                call MAKE_FRAME (xmin_p,xmax_p,ymin_p,ymax_p)

                call DRAW_TICKS_VT (pixlpercol, pixlperrow,

     &				xmin_p, xmax_p, ymin_p, ymax_p,

     &				xmin, xmax, ymin, ymax,

     &				numxticks, numyticks)

                call DEFINE_CLIP_REGN (xmin_p,xmax_p,ymin_p,ymax_p)

           endif

      endif



      xminold = xmin

      xmaxold = xmax

      yminold = ymin

      ymaxold = ymax



      if (.not. rayflag) then



	   do i = 0, numpts-1

       		intx(i) = INT2(ax*xreal(i) + bx)

		inty(i) = INT2(numypixel-(ay*yreal(i)+by))

	   enddo

      else

	   do i = 0, numpts

		intx(i) = INT2(ax*x(i) + bx)

		inty(i) = INT2(numypixel-(ay*y(i)+by))

	   enddo

      endif



C Plot on the screen.  MARKER determines whether the points are to be connected

C or whether they will be a series of pixel points.  RAYFLAG determines whether

C there will be a PAUSE between lines made on the screen.  Need pause between

C profiles, but since rayplots are made up of many lines, do not  pause between

C them.  For rayplots, pausing is handled when an ICODE = -2 is encountered.



      call PLOT_PIXELS (intx(0), inty(0), numpts, marker, rayflag,

     &                  conflag, num_pt_plots, slomofact, eigflag)



      RETURN

      END

C*************************************************************************

      Subroutine PLOT_PIXELS (intx, inty, numpts, marker, rayflag,

     &                        conflag, num_pt_plots, slomofact, eigflag)



C This routine simply calls the appropriate MicroSoft Graphics routines

C which will plot the graphs for rayplots, contours, profiles or eigen

C plots.

C

C MARKER is a variable that indicates whether or not each point will be

C plotted with a symbol rather than just connecting the points with lines.

C It is used only for profile and eigen plots.

C

C NUM_PT_PLOTS determines which symbol will be used for the points for

C profile point plots.

C Eigen point plots always use a small filled circle.



      INCLUDE 'FGRAPH.FD'



      INTEGER*2 intx(0:numpts),

     &		inty(0:numpts),

     &		idum,

     &          icolor,

     &          numcolors,

     &          oldcolor,

     &          numxpixel,

     &          numypixel,

     &          icall,kkk,

     &          itmp,

     &          numtxtrow,

     &          ihr,imin,isec,ihundth,inittime





      REAL slomofact



      INTEGER marker,

     &        num_pt_plots



      LOGICAL rayflag,

     &        conflag,

     &        eigflag



      RECORD / xycoord / xy

      RECORD / rccoord / dum

      RECORD / videoconfig / vc



      data icolor / 0 /

      data icall / 1 /

C

C Note that rayplots and profile plots store the first values in different

C places.  This is due to the fact that the  NUMPTS in the rayplot output

C file indicate  the number of points that FOLLOW the initial "moveto"

C command.  Whereas, for profiles, there are exactly NUMPTS from the "CURVE"

C command with the first point being implied as a "moveto".

C

C     NOTE:  When this routine is called for the first time for a contour plot,

C            find out how many colors are available.



      if (icall .eq. 1) then

           call GETVIDEOCONFIG (vc)

           numcolors = vc.numcolors

           numxpixel = vc.numxpixels

           numypixel = vc.numypixels

           numtxtrow = vc.numtextrows

      endif





C For contour plots, the first pair of x,y points is a moveto, the second

C pair is a lineto, the third a moveto, etc.



      if (.not. rayflag) then

	   numplotpts = numpts - 1

      else

	   numplotpts = numpts

      endif



C.....For contours, we set the color to a different color for each

C     contour level.   NOTE:  Color #7 (= White) is skipped because

C     it is too much like color #8 (= Dark Gray).

C     For monochrome monitors, SETCOLOR functions are ignored.

C     NOTE:  When ICOLOR reaches the maximum available colors (NUMCOLORS)

c            reset ICOLOR to 1 which is Blue.



      if (conflag) then

           icolor = icolor + 1

           if (icolor .ge. numcolors) icolor = 1

           if (icolor.eq.7) icolor = 8

           oldcolor = SETCOLOR (icolor)



           do i = 1, numplotpts-1, 2

                call MOVETO (intx(i),inty(i), xy)

                idum = LINETO (intx(i+1), inty(i+1))

	   enddo



C..........We use 2 fewer colors than the total available (don't use

C          Black or White#7). We use colors #1 through #6 and #8 through

C          #15.



                itmp = icolor



C...............Handle the skipping of White #7.

                if (icolor .ge. 7) itmp = itmp - 1



C...............Draw the box on the color scale for the current color.

C               No color scale for monochrome.



                if (numcolors .gt. 2) then

                     do kkk = 1,12

                          do jjj = 1,6

                               idum = SETPIXEL (numxpixel-60-kkk,

     &                                     0.75*numypixel-itmp*8-jjj)

                          enddo

                     enddo



                     if (icolor.eq.1) then

                          call SETTEXTPOSITION (0.8*numtxtrow,67,dum)

                          call OUTTEXT ('Min. Level')

                     endif

                endif



C..........Increment ICALL so GETVIDEOCONFIG will only be called once per

C          plotting session.



           icall = icall + 1

           RETURN

      endif



C.....Profile plots of tabular data i.e., point plots



      if (marker .lt. 0 .and. .not. eigflag) then

	   do i = 0, numplotpts

                if (num_pt_plots .eq. 1)      ! small circle

     &   	     idum = ELLIPSE ($GBORDER, intx(i)-2, inty(i)+2,

     &		                     intx(i)+2, inty(i)-2)

                if (num_pt_plots .eq. 2)      ! small box

     &   	     idum = RECTANGLE ($GBORDER, intx(i)-2, inty(i)+2,

     &		                     intx(i)+2, inty(i)-2)

                if (num_pt_plots .eq. 3)      ! large circle

     &   	     idum = ELLIPSE ($GBORDER, intx(i)-4, inty(i)+4,

     &		                     intx(i)+4, inty(i)-4)

                if (num_pt_plots .eq. 4)      ! large box

     &   	     idum = RECTANGLE ($GBORDER, intx(i)-4, inty(i)+4,

     &		                     intx(i)+4, inty(i)-4)



	   enddo



C.....Eigen plots with discrete points



      else if (marker .lt. 0 .and. eigflag) then



           do i = 0, numplotpts

                idum = ELLIPSE ($GFILLINTERIOR, intx(i)-1, inty(i)+1,

     &		                intx(i)+1, inty(i)-1)

           enddo



C.....Now do rayplots, profiles (with connected points) and eigen plots

C     (with connected points).



      else



           call MOVETO (intx(0), inty(0), xy)



C..........Handle the fact that for contour plots, the RAYFLAG is true.  This is

C          because the axes are plotted as rayplots.  We want the color of the

C          axes to be white so force it to be.



           icolor = GETCOLOR ()

           if (icolor.ne.15) idum = SETCOLOR (15)



C..........Slow motion stuff.  Pause every 20 plot points for 3*slomofact

C          hundredths of a second.



	   do i = 1, numplotpts

                if (slomofact .ne. 1.0) then

                     if (MOD(i,20).eq.0) then



                          call GETTIM (ihr,imin,isec,inittime)

                          ihundth = inittime

                          do while (

     &                         ABS(inittime-ihundth).lt.slomofact*3.)

                               call GETTIM (ihr,imin,isec,ihundth)

                          enddo

                     endif

                endif

		idum = LINETO (intx(i), inty(i))

	   enddo

      endif



C.....Don't want to pause between plots for rayplots or eigen plots.



      if (.not.rayflag .and. .not. eigflag) then

	   call SETTEXTPOSITION (1,58,dum)

	   call OUTTEXT ('Press ENTER to continue')

           call WAIT

      endif



      RETURN

      END

C******************************************************************************

      Subroutine SETVIDEO_DFT



      INCLUDE 'FGRAPH.FD'



      integer*2 idum



      idum = SETVIDEOMODE($DEFAULTMODE)



      RETURN

      END

C************************************************************************

      Subroutine CLR_SCREEN



      INCLUDE 'FGRAPH.FD'



      call CLEARSCREEN ($GCLEARSCREEN)



      RETURN

      END

C*****************************************************************************

      Subroutine MAKE_FRAME (xmin_p,xmax_p,ymin_p,ymax_p)



      INCLUDE 'FGRAPH.FD'



      INTEGER*2

     &	       idum,

     &	       xmin_p, xmax_p, ymin_p, ymax_p



      idum = RECTANGLE ($GBORDER, xmin_p,ymax_p,xmax_p,ymin_p)



      RETURN

      END

C***************************************************************************

      Subroutine DRAW_TICKS_VT (pixlpercol, pixlperrow,

     &				 xmin_p, xmax_p, ymin_p, ymax_p,

     &				 xmin, xmax, ymin, ymax,

     &				 numxticks, numyticks)



C Only for Profile and Eigen Plots...

C

C INPUT: Everything

C OUTPUT: Labels for the tick marks and the tick marks themselves.



C NUMXTICKS, NUMYTICKS both include marks at the endpoint.  Therefore,

C if there are only two intervals, there would be 3 tick marks but only

C one tick mark (in the middle) would be visible.  The ones at the endpoints

C are obscured by the frame.



      INCLUDE 'FGRAPH.FD'



      RECORD / rccoord / txtposn

      RECORD / xycoord / dum



      INTEGER*2

     &	       xmin_p, xmax_p, ymin_p, ymax_p,

     &         idum,

     &         xintvl, yintvl,

     &         outrow, outcol



       REAL xmin, xmax, ymin, ymax,

     &      pixlpercol,

     &      pixlperrow,

     &      rowposn



C.....Set up some local variables to handle the sign change when

C     the entire plot is below the surface of the ocean.



       REAL yminloc, ymaxloc



       CHARACTER*8 xmin_txt, xmax_txt, ymin_txt, ymax_txt

       CHARACTER*6 fmtchar

C

C Note:  The F8.2 works fine for negatives to -9999.99 not -99999.99 as

C        it seems from the "lt. 1e+5" check, but will probably never

C        encounter numbers that large.



      if ((ABS(xmin) .ge. 0.01 .and. ABS(xmin) .lt.1e+5)

     &       .or. xmin.eq.0.0 ) then

            fmtchar = '(F8.2)'

      else

            fmtchar = '(E8.2)'

      endif



      WRITE (xmin_txt,fmtchar) xmin



      if ((ABS(xmax) .ge. 0.01 .and. ABS(xmax) .lt.1e+5)

     &       .or. xmax.eq.0.0 ) then

            fmtchar = '(F8.2)'

      else

            fmtchar = '(E8.2)'

      endif

      WRITE (xmax_txt,fmtchar) xmax



      if ((ABS(ymin) .ge. 0.01 .and. ABS(ymin) .lt.1e+5)

     &       .or. ymin.eq.0.0) then

            fmtchar = '(F8.2)'

       else

            fmtchar = '(E8.2)'

       endif



C.....If the entire profile is below the surface, then change the

C     tick values to positive, since it will be positive depth.



       if (ymax .le. 0) then

            ymaxloc = -ymax

            yminloc = -ymin

       else

            yminloc = ymin

            ymaxloc = ymax

       endif



       WRITE (ymin_txt,fmtchar) yminloc



       if ((ABS(ymax) .ge. 0.01 .and. ABS(ymax) .lt.1e+5)

     &       .or. ymax.eq.0.0) then

            fmtchar = '(F8.2)'

       else

            fmtchar = '(E8.2)'

       endif



       WRITE (ymax_txt,fmtchar) ymaxloc



C......Label the X axis



C NOTE:  The FLOAT and NINT lines could have been combined but were not for

C        readability.



       rowposn = FLOAT(ymin_p)/pixlperrow + 2

       outrow = NINT(rowposn)

       colposn = FLOAT(xmin_p)/pixlpercol - 4

       outcol = NINT (colposn)

       call SETTEXTPOSITION (outrow,outcol,txtposn)



       call OUTTEXT (xmin_txt)



       colposn = FLOAT(xmax_p)/pixlpercol - 4

       outcol = NINT (colposn)

       call SETTEXTPOSITION (outrow,outcol,txtposn)



       call OUTTEXT (xmax_txt)



C......Divide by NUMXTICKS - 1 so that we get the interval size.



       xintvl = (xmax_p - xmin_p)/(numxticks-1)



C......We subtract 2 from NUMTICKS so that there is no tick mark for

C      either of the endpoints.



       do i = 1, numxticks-2

	   call MOVETO (xmin_p+i*xintvl,ymin_p,dum)

	   idum = LINETO (xmin_p+i*xintvl,ymin_p-7)

       enddo



C......Label the Y axis



       rowposn = FLOAT(ymax_p)/pixlperrow

       outrow = NINT(rowposn)

       colposn = FLOAT(xmin_p)/pixlpercol - 7

       outcol = NINT (colposn)



       call SETTEXTPOSITION (outrow,outcol,txtposn)



       call OUTTEXT (ymax_txt)



       rowposn = FLOAT(ymin_p)/pixlperrow +1

       outrow = NINT(rowposn)

       call SETTEXTPOSITION (outrow,

     &                       outcol,txtposn)



       call OUTTEXT (ymin_txt)



C.....Remember that pixel values (in vertical direction) are greater

C     as you go down the screen.



       yintvl = (ymin_p - ymax_p)/(numyticks-1) + 1



       do i = 1, numyticks-2

	   call MOVETO (xmin_p,ymin_p-i*yintvl,dum)

	   idum = LINETO (xmin_p+7,ymin_p-i*yintvl)

       enddo



       RETURN

       END



C*****************************************************************************

      Subroutine DEFINE_CLIP_REGN (xmin_p,xmax_p,ymin_p,ymax_p)



      INCLUDE 'FGRAPH.FD'



      INTEGER*2

     &	       xmin_p, xmax_p, ymin_p, ymax_p



      call SETCLIPRGN (xmin_p,ymax_p,xmax_p,ymin_p)



      RETURN

      END

C****************************************************************************

      Subroutine LABEL_AXES_VT (newtitle, newhoriz_label,

     &                          newvert_label, numtextrows)



C.....This subroutine handles the title, x and y axis labels

C     for Profile and Eigen plots.



      INCLUDE 'FGRAPH.FD'



      RECORD / rccoord / dum



      INTEGER*2 numtextrows



      CHARACTER*(*) newtitle,

     &		   newhoriz_label,

     &		   newvert_label





      lennew = LEN_TRIMMED (newtitle)



      call SETTEXTPOSITION (2,40-lennew/2,dum)

      call OUTTEXT (newtitle(1:lennew))



      lennew = LEN_TRIMMED (newhoriz_label)



      call SETTEXTPOSITION (numtextrows-2,40-lennew/2,dum)

      call OUTTEXT (newhoriz_label(1:lennew))



      lennew = LEN_TRIMMED (newvert_label)



      call SETTEXTPOSITION (numtextrows/2,1,dum)

      call OUTTEXT (newvert_label(1:lennew))



      RETURN

      END

C*****************************************************************************

      Subroutine SUBHEAD_VT (subtext, lentxt, marker)



C     As usual, MARKER indicates whether the plot is a point plot.

C     If it is, the subtext will be placed on row 4 rather than 3

C     so as not to obscure the subtext from a previous non-point plot

C     which will be on row 3.



      INCLUDE 'FGRAPH.FD'



      RECORD / rccoord / dum



      CHARACTER *(*)

     &             subtext



      INTEGER lentxt,

     &        marker



      if (marker .ge. 0) then

           call SETTEXTPOSITION (3,1,dum)

           call SETTEXTPOSITION (3,40-lentxt/2,dum)

           call OUTTEXT (subtext(1:lentxt) )

      else   ! point plot

           call SETTEXTPOSITION (4,1,dum)

           call SETTEXTPOSITION (4,40-lentxt/2,dum)

           call OUTTEXT (subtext(1:lentxt) )

      endif



      RETURN

      END

C*****************************************************************************

      Subroutine PAUSEIT



C This routine was created so that 1. MicroSoft Graphics would not be called

C from the main routine



      INCLUDE 'FGRAPH.FD'



      INTEGER*2

     &          oldcolor,

     &          dummy



      RECORD / rccoord / dum





      oldcolor = GETTEXTCOLOR ()



C.....Change the text color to cyan (=3) if it is not already cyan.

C     If the current text color is cyan, set the color to green (=2).

C     I would have made the text blink, but many color graphics modes,

C     e.g. ERESCOLOR, VRES16COLOR only support 16 colors and some only

C     have 4 colors, e.g. MRES4COLOR.



      if (oldcolor .ne. 3) dummy = SETTEXTCOLOR (3)

      if (oldcolor .eq. 3) dummy = SETTEXTCOLOR (2)

      call SETTEXTPOSITION (1,58,dum)

      call OUTTEXT ('Press ENTER to Continue')



      call WAIT



C.....Reset the text color.

      dummy = SETTEXTCOLOR (oldcolor)



      RETURN

      END

C*****************************************************************************

      Subroutine WAIT



C This routine was created in order to allow pausing between frames on the

C screen for both interactive and re-directed input modes.

C By putting the character "y" or "Y" in the input-redirection file, the

C routine will wait 20 seconds before continuing.  Any other character would

C cause the program to continue.  Likewise, in interactive mode, pressing

C the ENTER key would cause execution to continue. The program would wait

C until some key was pressed otherwise. (if the user happened to press "y",

C the 30 second timer would be invoked.)

C

C

      INCLUDE 'FGRAPH.FD'



      RECORD / rccoord / dum





      CHARACTER*1 key,

     &		  char10,

     &		  chr_table(0:9)



      CHARACTER*23 blanks

      CHARACTER*21 outchar

      INTEGER*2 ihr,imin,isec,idum,startime,deltime,

     &		deltime_old, timeleft



      LOGICAL displayed     !  indicates that clock has been displayed once



      DATA displayed / .false. /



      DATA chr_table /'0','1','2','3','4','5','6','7','8','9'/



      blanks = '                       '

      READ (*,111) key

111   FORMAT (A)



      deltime = 0

      deltime_old = 0

      if (key .eq. 'y' .or. key .eq. 'Y') then

	    call GETTIM (ihr,imin,isec,idum)

	    startime = isec



            do while (deltime .lt. 20)

		 call GETTIM (ihr,imin,isec,idum)

		 if (isec .ge. startime) deltime = isec-startime

		 if (isec .lt. startime) then



		    deltime = 60 - ABS(isec - startime)

		 endif



C................The following is for the clock shown in upper right of screen.



		 if (deltime .gt. deltime_old .and.

     &               deltime .lt. 20) then



                    timeleft = 20 - deltime

		    if (timeleft.lt.10) then

			 char10 = '0'

			 char1 = chr_table(timeleft)

		    endif

                    if (timeleft.ge.10 .and. timeleft .lt.20) then

			 char10 = '1'

			 char1 = chr_table(timeleft-10)

                    endif



		    outchar = 'Pausing-Time left: '//char10//char1

                    if (displayed) then

                         call SETTEXTPOSITION (1,77,dum)

                         call OUTTEXT (outchar(20:21))

                    else

		         call SETTEXTPOSITION (1,58,dum)

                         call outtext (blanks)

		         call SETTEXTPOSITION (1,58,dum)

		         call OUTTEXT (outchar)

                    endif

                    displayed = .true.

		endif

		deltime_old = deltime

	   enddo

      endif



      displayed = .false.

      RETURN

      END

C*****************************************************************************



      Subroutine RAYTXT_OUT_VT (xmin,xmax,ymin,ymax,ior,nchar,raytxt,

     &		                xtxt, ytxt)



      INCLUDE 'FGRAPH.FD'



      RECORD / videoconfig / vc

      RECORD / rccoord / dum



      INTEGER*2 irow,icol



      REAL xmin,xmax,ymin,ymax, xtxt, ytxt

      CHARACTER*(*) raytxt



      EXTERNAL len_trimmed



       data icall / 1/

C==>



      if (icall.eq.1) then

           call GETVIDEOCONFIG (vc)

           numxpixel = vc.numxpixels

           numypixel = vc.numypixels

           ncol = vc.numtextcols

           nrow = vc.numtextrows



           icall = 2

      endif

      nrtop = 9

      nrbot = 4

      ncolrt = 21

      ncollt = 9





C.....Handle vertically oriented text first.



      if ((ior.eq.1) .and. (nchar.gt.10)) then

	   nchar = 30

	   irow = 15

	   icol = 1

           call SETTEXTPOSITION (irow,icol,dum)

           lentxt = LEN_TRIMMED (raytxt)

           call OUTTEXT (raytxt(1:lentxt))



           RETURN

      endif



      if (nchar.le.10) then

	   irow = INT(FLOAT(nrtop+1)+(ymax-10.*ytxt)/(ymax-ymin)

     &		  *FLOAT((nrow-nrbot)-(nrtop+1)))

	   if (ytxt.eq.11.) irow = nrow

	   if (ytxt.eq.43.) irow = nrow-1

	   if (ytxt.eq.45.) irow = nrow-2

	   if (ytxt.eq.80.) irow = nrow-3

	   icol = INT(FLOAT(ncollt+1)+(10.*xtxt-xmin)/(xmax-xmin)

     &		  *FLOAT((80-ncolrt)-ncollt))



      else



c  1023 harpo points / 25 rows = 40.92 harpo points per row

c  40.92 / 34 = 1023 / 850

c  34 is the distance between text rows in harpo.

c  so this algorithm assumes a 25 row monitor.



	   irow = INT(FLOAT(1023-ytxt)/850.*FLOAT(nrow)+0.5)

           irow = irow + 1



	   if (ytxt.eq.11.) irow = nrow

	   if (ytxt.eq.43.) irow = nrow-1

	   if (ytxt.eq.45.) irow = nrow-2

	   if (ytxt.eq.80.) irow = nrow-3

	   icol = INT(FLOAT(ncol)-FLOAT(1300-xtxt)/1300.*

     &		  FLOAT(ncol)+0.5)

	   if (icol.lt.1) icol = 1



      endif

      if (icol.lt.1 .or. icol.gt.ncol) return



      call SETTEXTPOSITION (irow,icol,dum)

      lentxt = LEN_TRIMMED (raytxt)





C.....For labels with REAL values, trim off a trailing zero if one exists.

C     E.g. convert "1.50" to "1.5".

C     However, do not trim the trailing zero for numbers like "3.0".



      if (INDEX(raytxt,'.') .ne. 0) then

           if (raytxt(lentxt:lentxt) .eq. '0' .and.

     &         raytxt(lentxt-1:lentxt-1) .ne. '.') lentxt = lentxt-1



C.....Handle the special case for the models with the model number e.g.

C     "NPBOTM   .0".  This is how they are written by the CONPLT or HARPO

C     programs.  Insert a "0" so we have "NPBOTM  0.0" instead.



           if (raytxt(lentxt:lentxt) .eq. '0' .and.

     &         raytxt(lentxt-1:lentxt-1) .eq. '.' .and.

     &         raytxt(lentxt-2:lentxt-2) .eq. ' ') then



               raytxt(lentxt-2:lentxt-2) = '0'

           endif

      endif



      call OUTTEXT (raytxt(1:lentxt))



      RETURN

      END

