C     THIS IS FILE TCDRIV.FOR
C     PURPOSE--THESE ARE THE FORTRAN ROUTINES WHICH SERVE AS
C              A DRIVER & BRIDGE BETWEEN THE DATAPLOT FORTRAN
C              AND THE TURBO-C C DRIVER, AND ULTIMATELY
C              THE TURBO C C ROUTINES.
C
C     TIME DRAIN--THE C CODE WILL NOT WORK & WILL GET ERROR MESSAGE:
C                 "REAL MODE LIBRARY TERMINATED IMPROPERLY--
C                 PLEASE REBOOT"
C                 UNLESS    COMSPACE   IN AUTOEXEC.BAT
C                 IS AT LEAST 400000 .
C                 THIS HAS BEEN A PROBLEM 3 TIMES!
C
C     NOTE--IT IS BEST THAT THE TURBO-C LOAD SWITCH (1/0) LOGIC
C           AND THE TURBO-C GRAPHICS STATUS (OPEN/CLOSE) LOGIC
C           IS DONE HEREIN RATHER THAN BE SCATTERED ABOUT
C           IN THE REST OF THE DATAPLOT CODE.
CCCCC NOTE--THE COMMON STRUCTURE IS--
CCCCC COMMON /FC/NTEXTF,NTEXTC,NPLOTF,TEXTFC,TEXTCF,PLOTFC(11)
CCCCC BYTES:       4      4      4      84     84     84*11
C
C NOTE--THESE ARE THE TURBO-C FILES--
C TEXT OUTPUT       7 C:\TURBOC\FRONTEND\DPTEOU.TEX TCSHME+ TCGECO-+
C GRAPHICS OUTPUT   8 C:\TURBOC\FRONTEND\DPGROU.TEX
C TCDRIV DEBUG      9 C:\TURBOC\FRONTEND\TCDEBU.TEX TCLOTC+ TCGETC-
C COM. HIST. INPUT 10 C:\TURBOC\FRONTEND\DPCOIN.TEX TCINCF+- TCWRCO+-+-
C
C     NOTE--THERE ARE 4 TURBO-C SWITCHES--
C           1. TCLOAD
C              HAS CMAIN.EXE BEEN LOADED (& INIT. EXEC.)? YES/NO
C           2. TCMENU
C              IS THE TURBO C MENU ON THE SCREEN?         YES/NO
C           3. TCPLFI        FILE 8
C              WHAT IS STATUS OF THE TURBO C PLOT FILE?   OPEN/CLOS
C           4. TCTEFI        FILE 7
C              WHAT IS STATUS OF THE TURBO C TEXT FILE?   OPEN/CLOS
C
C
C     NOTE--WHEN THE COMMAND    MENU   IS ENTERED ON THE FORTRAN SIDE,
C           THIS IS DETECTED IN     MAIN.FOR
C           AND THEN   TCLOTC IS CALLED FIRST
C           AND        TCSHME IS CALLED SECOND
C           (BOTH FROM    MAIN.FOR)
C     NOTE--THEY ARE INITIALLY ALLOCATED IN DPCODV.INC
C           THEY ARE INITIALLY DEFINED   IN INITOD.FOR
C     WRITTEN BY--JAMES J. FILLIBEN
C     ORIGINAL VERSION--MAY  18, 1991
C     UPDATED         --MAY  26, 1991
C     UPDATED         --JUNE 25, 1991
C
C ----------TCINCO-----------------------------
C
      SUBROUTINE TCINCO(ISUBRO)
C
C     PURPOSE--INITIALIZE TURBO-C COMMON
C              (THIS IS DONE ONLY ONCE PER DATAPLOT RUN)
C     DATAPLOT CALLING ROUTINE--MAIN ONLY
C     NOTE--WHEN THE USER ENTERS THE    MENU   COMMAND
C           FROM THE FORTRAN SIDE (BEFORE ANY MENU IS ON THE SCREEN)
C           TCINCO IS THE FIRST ROUTINE CALLED
C           TCLOTC IS THE SECOND ROUTINE CALLED
C           AND TCSHME IS THE THIRD ROUTINE CALLED
C           (ALL FROM MAIN)
CCCCC THE FOLLOWING COMMENT LINES WERE ADDED MAY 1992 (JJF)
C     DEFINE THE 4 GENERAL TURBO-C SWITCHES.
C     NOTE--THERE ARE 4 TURBO-C SWITCHES--
C           1. TCLOAD
C              HAS CMAIN.EXE BEEN LOADED (& INIT. EXEC.)? YES/NO
C           2. TCMENU
C              IS THE TURBO C MENU ON/OFF THE SCREEN?     ON/OFF
C           3. TCPLFI
C              WHAT IS STATUS OF THE TURBO C PLOT FILE?   OPEN/CLOS
C           4. TCTEFI
C              WHAT IS STATUS OF THE TURBO C TEXT FILE?   OPEN/CLOS
C     NOTE--THEY ARE INITIALLY ALLOCATED IN DPCODV.INC
C           THEY ARE INITIALLY DEFINED   IN TCINCO.FOR IN TCDRIV.FOR
C           THEY ARE USED                IN TCDRIV.FOR
C
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      CHARACTER*4 ISUBRO
C
      CHARACTER*4 IFEEDB
      CHARACTER*4 IPRINT
      COMMON /MACH/IRD,IPR,CPUMIN,CPUMAX,NUMBPC,NUMCPW,NUMBPW
      COMMON /PRINT/IFEEDB,IPRINT
C
CCCCC DELETE THE FOLLOWING LINE AFTER DEBUGGED
CNOPC OPEN(UNIT=9,FILE='C:\TURBOC\FRONTEND\TCDEBU.TEX')
CNOPC OPEN(UNIT=9,FILE='TCDEBU.TEX')
C
      IF(ISUBRO.EQ.'INCO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
  999    FORMAT(1H )
         WRITE(9,51)
   51    FORMAT(1H ,'***** AT THE BEGINNING OF TCINCO IN TCDRIV--')
         WRITE(9,52)ISUBRO
   52    FORMAT(1H ,'ISUBRO = ',A4)
      ENDIF
C
      TCLOAD='NO'
      TCMENU='OFF'
CCCCC THE FOLLOWING 2 LINES WERE CORRECTED JULY 1992 (JJF)
CCCCC TCPLFI='OFF'
CCCCC TCTEFI='OFF'
      TCPLFI='CLOS'
      TCTEFI='CLOS'
      ITCST='OFF'
      TEXTFC=' '
      NTEXTF=0
CCCCC THE FOLLOWING 4 LINES WERE ADDED MAY 1992 (JJF)
      NPLOTF=0
      DO2100I=1,11
      PLOTFC(I)=' '
 2100 CONTINUE
C
      IF(ISUBRO.EQ.'LOTC'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
         WRITE(9,9011)
 9011    FORMAT(1H ,'***** AT THE END       OF TCLOTC IN TCDRIV--')
         WRITE(9,9012)ISUBRO
 9012    FORMAT(1H ,'ISUBRO= ',A4)
         WRITE(IPR,9013)TCLOAD,TCMENU,TCPLFI,TCTEFI
 9013    FORMAT(1H ,'TCLOAD,TCMENU,TCPLFI,TCTEFI = ',
     1               A4,2X,A4,2X,A4,2X,A4)
      ENDIF
C
      RETURN
      END
C
C ----------TCLOTC-----------------------------
C
      SUBROUTINE TCLOTC(ISUBRO)
C
C     PURPOSE--INITIALIZE (LOAD IN) THE TURBO-C C DRIVER (CMAIN.C)
C              (THIS IS DONE ONLY ONCE PER DATAPLOT RUN)
C     NOTE--THE CALL TO REAL_MODE_LIBRARY@ MUST BE DONE
C           AT MOST ONCE DURING ANY DATAPLOT RUN.
C     DATAPLOT CALLING ROUTINE--MAIN ONLY
C     NOTE--WHEN THE USER ENTERS THE    MENU   COMMAND
C           FROM THE FORTRAN SIDE (BEFORE ANY MENU IS ON THE SCREEN)
C           TCLOTC IS THE FIRST ROUTINE CALLED
C           AND TCSHME IS THE SECOND ROUTINE CALLED
C           (BOTH FROM MAIN)
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      CHARACTER*4 ISUBRO
C
      CHARACTER*4 IFEEDB
      CHARACTER*4 IPRINT
      COMMON /MACH/IRD,IPR,CPUMIN,CPUMAX,NUMBPC,NUMCPW,NUMBPW
      COMMON /PRINT/IFEEDB,IPRINT
C
      IF(ISUBRO.EQ.'LOTC'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
  999    FORMAT(1H )
         WRITE(9,51)
   51    FORMAT(1H ,'***** AT THE BEGINNING OF TCLOTC IN TCDRIV--')
         WRITE(9,52)ISUBRO,TCLOAD
   52    FORMAT(1H ,'ISUBRO,TCLOAD = ',A4,2X,A4)
      ENDIF
C
      IF(TCLOAD.EQ.'NO')THEN
CNOPC    CALL REAL_MODE_SHORT_CUT@
CCCCC CALL PAUSE('1')
C
CNOPC    CALL LOAD_REAL_MODE_LIBRARY@('C:\TURBOC\FRONTEND\CMAIN.EXE')
CCCCC    CALL LOAD_REAL_MODE_LIBRARY@('C:\TURBOC\FRONTEND\CMAINF.EXE')
C
CCCCC ****************** DANGER ABOVE *********************
CCCCC ***** NOTE--DATAPLOT AND FED HAVE DIFFERENCE C-SIDE MAIN ROUTINES
CCCCC             DATAPLOT USES CMAIN.EXE
CCCCC             FED      USED CMAINF.EXE
CCCCC        IF NOT HAV PROPER CMAIN..  LOADED
CCCCC THEN WILL GET MESSAGE:
CCCCC REAL MODE LIBRARY HAS TERMINATED IMPROPERLY,
CCCCC SYSTEM MUST BE REBOOTED
CCCCC CALL PAUSE('2')
CCCCC CHANGE ABOVE AND ALSO WELL BELOW
         TCLOAD='YES'
      ENDIF
C
      IF(ISUBRO.EQ.'LOTC'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
         WRITE(9,9011)
 9011    FORMAT(1H ,'***** AT THE END       OF TCLOTC IN TCDRIV--')
         WRITE(9,9012)ISUBRO,TCLOAD
 9012    FORMAT(1H ,'ISUBRO,TCLOAD = ',A4,2X,A4)
         WRITE(9,999)
         WRITE(9,9011)
         WRITE(9,9012)ISUBRO,TCLOAD
      ENDIF
C
      RETURN
      END
C
C ----------TCSHME-----------------------------
C
      SUBROUTINE TCSHME(ISUBRO)
C
C     PURPOSE--SHOW THE DATAPLOT GUI MENU UNDER TURBO-C
C     DATAPLOT CALLING ROUTINE--MAIN
C     NOTE--WHEN THE USER ENTERS THE    MENU   COMMAND
C           FROM THE FORTRAN SIDE (BEFORE ANY MENU IS ON THE SCREEN)
C           TCLOTC IS THE FIRST ROUTINE CALLED
C           AND TCSHME IS THE SECOND ROUTINE CALLED
C           (BOTH FROM MAIN)
C
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      CHARACTER*4 ISUBRO
CCCCC INTEGER*4 NBYTES
      INTEGER NBYTES
C
      CHARACTER*4 IFEEDB
      CHARACTER*4 IPRINT
      COMMON /MACH/IRD,IPR,CPUMIN,CPUMAX,NUMBPC,NUMCPW,NUMBPW
      COMMON /PRINT/IFEEDB,IPRINT
C
      IF(ISUBRO.EQ.'SHME'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
  999    FORMAT(1H )
         WRITE(9,51)
   51    FORMAT(1H ,'***** AT THE BEGINNING OF TCSHME IN TCDRIV--')
         WRITE(9,52)ISUBRO,TCLOAD
   52    FORMAT(1H ,'ISUBRO,TCLOAD = ',A4,2X,A4)
      ENDIF
C
      IF(TCMENU.EQ.'OFF')THEN
         TEXTFC(1:4)='SHME'
         TEXTFC(5:8)='SHME'
CCCCC    NBYTES=8+4
CCCCC    NBYTES=12+4
         NBYTES=12+4+4
CNOPC    CALL COPY_TO_REAL_MODE@(NTEXTF,NBYTES)
CNOPC    CALL REAL_MODE@
         TCMENU='ON'
CNOPC    OPEN(UNIT=7,FILE='C:\TURBOC\FRONTEND\DPTEOU.TEX')
         OPEN(UNIT=7,FILE='DPTEOU.TEX')
         IPR=7
         TCTEFI='OPEN'
      ENDIF
C
      IF(ISUBRO.EQ.'SHME'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
         WRITE(9,9011)
 9011    FORMAT(1H ,'***** AT THE END       OF TCSHME IN TCDRIV--')
         WRITE(9,9012)ISUBRO,TCLOAD,TEXTCF(1:4)
 9012    FORMAT(1H ,'ISUBRO,TCLOAD,TEXTCF(1:4) = ',A4,2X,A4,2X,A4)
      ENDIF
C
      RETURN
      END
C
C ----------TCGECO-----------------------------
C
      SUBROUTINE TCGECO(IB,NIB,IBUGS2,ISUBRO)
C
C     PURPOSE--GET A DATAPLOT COMMAND FROM THE GUI MENU
C     DATAPLOT CALLING ROUTINE--DPGETC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
CCCCC INTEGER*4 NBYTES
      INTEGER NBYTES
C
      CHARACTER*4 ISTEPN
      CHARACTER*4 ISUBN1
      CHARACTER*4 ISUBN2
C
      CHARACTER*4 IBUGS2
      CHARACTER*4 ISUBRO
CCCCC CHARACTER*4 IFOUND
CCCCC CHARACTER*4 IERROR
C
      CHARACTER*4 IFEEDB
      CHARACTER*4 IPRINT
      COMMON /MACH/IRD,IPR,CPUMIN,CPUMAX,NUMBPC,NUMCPW,NUMBPW
      COMMON /PRINT/IFEEDB,IPRINT
C
      CHARACTER*80 IB
C
      ISUBN1='TCGE'
      ISUBN2='CO  '
C
      ISTEPN='--0-'
CCCCC ISUBRO='GECO'
      IF(IBUGS2.EQ.'ON'.OR.ISUBRO.EQ.'GECO'.OR.ISUBRO.EQ.'DRIV')
     1WRITE(9,105)ISTEPN,ISUBN1,ISUBN2
  105 FORMAT(1H ,'TRACE AT STEP ',A4,' OF ',A4,A4)
      NIB=0
      IF(TCMENU.EQ.'ON')THEN
         ENDFILE 7
         CLOSE(7)
         IPR=6
         TCTEFI='CLOS'
         TEXTCF=' '
         TEXTFC(1:4)='GECO'
         TEXTFC(5:8)='GECO'
      ISTEPN='1'
      IF(IBUGS2.EQ.'ON'.OR.ISUBRO.EQ.'GECO'.OR.ISUBRO.EQ.'DRIV')
     1WRITE(9,105)ISTEPN,ISUBN1,ISUBN2
CCCCC    NBYTES=8+4
CCCCC    NBYTES=12+4
         NBYTES=12+4+4
C
CNOPC    CALL COPY_TO_REAL_MODE@(NTEXTF,NBYTES)
CNOPC    CALL REAL_MODE@
C
CCCCC    NBYTES=8+80
         NBYTES=12+84+84
CNOPC    CALL COPY_FROM_REAL_MODE@(NTEXTF,NBYTES)
      ISTEPN='4'
      IF(IBUGS2.EQ.'ON'.OR.ISUBRO.EQ.'GECO'.OR.ISUBRO.EQ.'DRIV')
     1WRITE(9,105)ISTEPN,ISUBN1,ISUBN2
      WRITE(9,885)NTEXTF,NTEXTC
  885 FORMAT(1H ,'FROM TCDRIV/TCGECO.FOR--NTEXTF,NTEXTC = ',2I8)
      WRITE(9,886)TEXTFC(1:10)
  886 FORMAT(1H ,'FROM TCDRIV/TCGECO.FOR--TEXTFC(1:10) = ',A10)
      WRITE(9,887)TEXTCF(1:10)
  887 FORMAT(1H ,'FROM TCDRIV/TCGECO.FOR--TEXTCF(1:10) = ',A10)
C
         NIB=NTEXTC
         IB=TEXTCF
C
         IF(TEXTCF(1:4).EQ.'EXME'.OR.TEXTCF(1:4).EQ.'ERRO')THEN
            TCMENU='OFF'
            TCTEFI='CLOS'
         ELSE IF(TEXTCF(1:4).EQ.'EXIT')THEN
            TCMENU='OFF'
            TCTEFI='CLOS'
CCCCC       ENDFILE 9  6/12/92
CCCCC       CLOSE(9) 6/12/92
            ENDFILE 9
            CLOSE(9)
CCCCC THE FOLLOWING LINE WAS ADDED AUGUST 1992
            RETURN
         ELSE
CNOPC       OPEN(UNIT=7,FILE='C:\TURBOC\FRONTEND\DPTEOU.TEX')
            OPEN(UNIT=7,FILE='DPTEOU.TEX')
            IPR=7
            TCTEFI='OPEN'
         ENDIF
C
      ENDIF
C
      WRITE(9,888)TEXTCF(1:10)
  888 FORMAT(1H ,'FROM TCDRIV/TCGECO.FOR--TEXTCF(1:10) = ',A10)
      WRITE(9,889)IB
  889 FORMAT(1H ,'FROM TCDRIV/TCGECO.FOR--IB = ',A80)
      WRITE(9,890)NIB
  890 FORMAT(1H ,'FROM TCDRIV/TCGECO.FOR--NIB = ',I4)
      DO895I=1,80
      JIB=ICHAR(IB(I:I))
      IF(JIB.LE.31)IB(I:I)=' '
CCCCC WRITE(9,896)I,IB(I:I),JIB
CC896 FORMAT(1H ,'I,IB(I:I),JIB = ',I8,2X,A1,I8)
  895 CONTINUE
      WRITE(9,990)
  990 FORMAT(1H )
C
      ISTEPN='-99-'
      IF(IBUGS2.EQ.'ON'.OR.ISUBRO.EQ.'GECO'.OR.ISUBRO.EQ.'DRIV')
     1WRITE(9,105)ISTEPN,ISUBN1,ISUBN2
      RETURN
      END
C
C ----------TCINDE-----------------------------
C
      SUBROUTINE TCINDE
C
C     PURPOSE--INITIALIZE (LOAD IN) THE TURBO-C C DRIVER (CMAIN.C)
C              (THIS IS DONE ONLY ONCE PER DATAPLOT RUN)
C     NOTE--THE CALL TO REAL_MODE_LIBRARY@ MUST BE DONE
C           AT MOST ONCE DURING ANY DATAPLOT RUN.
C     DATAPLOT CALLING ROUTINE--GRINDE
C     NOTE--WHEN THE MENU IS ON THE SCREEN
C           AND THE USER ENTERS A PLOT COMMAND (SUCH AS HISTOGRAM Y),
C           TCINDE IS THE FIRST ROUTINE CALLED
C           AND TCOPDE IS THE SECOND ROUTINE CALLED
C           IN GETTING THE PLOT ONTO THE MENU'S PLOT WINDOW.
C           (TCINDE FROM GRINDE    AND    TCOPDE FROM GROPDE).
C           NOTE THAT THE FIRST CALL (TCINDE) IS IN FACT UNNECESSARY
C           SINCE THE FORTRAN-TO-C LINK HAS ALREADY BEEN ESTABLISHED
C           BACK IN THE SUBROUTINE TCLOTC--WHICH WAS CALLED
C           WHEN THE USER CAUSED THE MENU TO APPEAR
C           BY ENTERING THE FORTRAN-SIDE COMMAND    MENU.
C     NOTE--TCINDE.FOR    HAS NO CORRESPONDANCE IN    TUDRIV.C
C
      CHARACTER*4 ISUBRO
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
CCCCC THE FOLLOWING LINE SHOULD BE COMMENTED OUT WHEN DEBUGGED
      ISUBRO='DRIV'
      IF(ISUBRO.EQ.'INDE'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
  999    FORMAT(1H )
         WRITE(9,51)
   51    FORMAT(1H ,'***** AT THE BEGINNING OF TCINDE IN TCDRIV--')
         WRITE(9,53)TCPLFI,TCTEFI,TCLOAD
   53    FORMAT(1H ,'TCPLFI,TCTEFI,TCLOAD= ',A4,2X,A4,2X,A4)
         WRITE(9,54)TCMENU,IPLATF
   54    FORMAT(1H ,'TCMENU,IPLATF = ',A4,2X,A10)
         WRITE(9,55)TEXTFC(1:20)
   55    FORMAT(1H ,'TEXTFC(1:20) = ',A20)
         WRITE(9,56)TEXTCF(1:20)
   56    FORMAT(1H ,'TEXTCF(1:20) = ',A20)
      ENDIF
C
      IF(TCLOAD.EQ.'NO')THEN
CNOPC    CALL REAL_MODE_SHORT_CUT@
CCCCC    CALL LOAD_REAL_MODE_LIBRARY@('C:\TURBOC\FRONTEND\CMAINF.EXE')
CNOPC    CALL LOAD_REAL_MODE_LIBRARY@('C:\TURBOC\FRONTEND\CMAIN.EXE')
         TCLOAD='YES'
      ENDIF
C
      IPLATF='WITHINMENU'
      IF(TCMENU.EQ.'OFF')IPLATF='STANDALONE'
C
      IF(ISUBRO.EQ.'INDE'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
         WRITE(9,9011)
 9011    FORMAT(1H ,'***** AT THE END       OF TCINDE IN TCDRIV--')
         WRITE(9,9013)TCPLFI,TCTEFI,TCLOAD
 9013    FORMAT(1H ,'TCPLFI,TCTEFI,TCLOAD= ',A4,2X,A4,2X,A4)
         WRITE(9,9014)TCMENU,IPLATF
 9014    FORMAT(1H ,'TCMENU,IPLATF = ',A4,2X,A10)
         WRITE(9,9015)TEXTFC(1:20)
 9015    FORMAT(1H ,'TEXTFC(1:20) = ',A20)
         WRITE(9,9016)TEXTCF(1:20)
 9016    FORMAT(1H ,'TEXTCF(1:20) = ',A20)
      ENDIF
C
      RETURN
      END
C
C ----------TCOPDE-----------------------------
C
      SUBROUTINE TCOPDE
C
C     PURPOSE--OPEN TURBO-C GRAPHICS
C              (THE INITIALIZATION IS ALREADY ASSUMED TO BE DONE)
C     NOTE--THE CALL TO REAL_MODE_LIBRARY@ MUST BE DONE
C           AT MOST ONCE DURING ANY DATAPLOT RUN.
C     DATAPLOT CALLING ROUTINE--GROPDE
C     NOTE--WHEN THE MENU IS ON THE SCREEN
C           AND THE USER ENTERS A PLOT COMMAND (SUCH AS HISTOGRAM Y),
C           TCINDE IS THE FIRST ROUTINE CALLED
C           AND TCOPDE IS THE SECOND ROUTINE CALLED
C           IN GETTING THE PLOT ONTO THE MENU'S PLOT WINDOW.
C           (TCINDE FROM GRINDE    AND    TCOPDE FROM GROPDE).
C           NOTE THAT THE FIRST CALL (TCINDE) IS IN FACT UNNECESSARY
C           SINCE THE FORTRAN-TO-C LINK HAS ALREADY BEEN ESTABLISHED
C           BACK IN THE SUBROUTINE TCLOTC--WHICH WAS CALLED
C           WHEN THE USER CAUSED THE MENU TO APPEAR
C           BY ENTERING THE FORTRAN-SIDE COMMAND    MENU.
C
      CHARACTER*4 ISUBRO
CCCCC INTEGER*4 NBYTES
      INTEGER NBYTES
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
CCCCC THE FOLLOWING LINE SHOULD BE COMMENTED OUT WHEN DEBUGGED
      ISUBRO='DRIV'
      IF(ISUBRO.EQ.'OPDE'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
  999    FORMAT(1H )
         WRITE(9,51)
   51    FORMAT(1H ,'***** AT THE BEGINNING OF TCOPDE IN TCDRIV--')
         WRITE(9,53)TCPLFI,TCTEFI,TCLOAD
   53    FORMAT(1H ,'TCPLFI,TCTEFI,TCLOAD= ',A4,2X,A4,2X,A4)
         WRITE(9,54)TCMENU,IPLATF
   54    FORMAT(1H ,'TCMENU,IPLATF = ',A4,2X,A10)
         WRITE(9,55)TEXTFC(1:20)
   55    FORMAT(1H ,'TEXTFC(1:20) = ',A20)
         WRITE(9,56)TEXTCF(1:20)
   56    FORMAT(1H ,'TEXTCF(1:20) = ',A20)
      ENDIF
C
CCCCC WRITE(6,777)TCPLFI
CC777 FORMAT(1H ,'TCPLFI = ',A4)
C
      IF(TCPLFI.EQ.'CLOS')THEN
CCCCC    OPEN(UNIT=8,FILE='C:\TURBOC\FRONTEND\DPGROU.TEX')
         TEXTFC(1:4)='PLOT'
         TEXTFC(5:8)='OPDE'
CCCCC    NBYTES=8+4
CCCCC    NBYTES=12+4
         NBYTES=12+4+4
CNOPC    CALL COPY_TO_REAL_MODE@(NTEXTF,NBYTES)
CNOPC    CALL REAL_MODE@
         NPLOTF=0
         TCPLFI='OPEN'
      ENDIF
C
CCCCC WRITE(6,778)TCPLFI
CC778 FORMAT(1H ,'TCPLFI = ',A4)
C
      COMMFC='INDE'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),112)COMMFC,IPLATF,INULC
  112 FORMAT(A4,1X,A10,A1)
CCCCC IF(ISUBRO.EQ.'OPDE'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCOPDE.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
      IF(NPLOTF.GE.10) CALL TCSEND
C
      COMMFC='OPDE'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),111)COMMFC,INULC
  111 FORMAT(A4,A1)
      IF(NPLOTF.GE.10) CALL TCSEND
C
      IF(ISUBRO.EQ.'OPDE'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
         WRITE(9,9011)
 9011    FORMAT(1H ,'***** AT THE END       OF TCOPDE IN TCDRIV--')
         WRITE(9,9013)TCPLFI,TCTEFI,TCLOAD
 9013    FORMAT(1H ,'TCPLFI,TCTEFI,TCLOAD= ',A4,2X,A4,2X,A4)
         WRITE(9,9014)TCMENU,IPLATF
 9014    FORMAT(1H ,'TCMENU,IPLATF = ',A4,2X,A10)
         WRITE(9,9015)TEXTFC(1:20)
 9015    FORMAT(1H ,'TEXTFC(1:20) = ',A20)
         WRITE(9,9016)TEXTCF(1:20)
 9016    FORMAT(1H ,'TEXTCF(1:20) = ',A20)
      ENDIF
C
      RETURN
      END
C
C ----------TCCLDE-----------------------------
C
      SUBROUTINE TCCLDE
C
C     PURPOSE--CLOSE TURBO C GRAPHICS
C     DATAPLOT CALLING ROUTINE--GRCLDE
C
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='CLDE'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),111)COMMFC,INULC
  111 FORMAT(A4,A1)
CCCCC IF(NPLOTF.GE.10) CALL TCSEND
CNOPC CALL TCSEND
C
CCCCC ENDFILE 8
CCCCC CLOSE(8)
      TCPLFI='CLOS'
C
CCCCC CLOSE(9)
C
CCCCC TEXTFC=' '
CCCCC TEXTFC(1:4)='CLDE'
CCCCC NBYTES=8+4
CCCCC CALL COPY_TO_REAL_MODE@(NTEXTF,NBYTES)
CCCCC CALL REAL_MODE@
C
      RETURN
      END
C
C ----------TCCHEX-----------------------------
C
      SUBROUTINE TCCHEX
C
C     PURPOSE--CHECK FOR EXPOSE AND CONFIGURATION EVENTS.
C              (NOT NEEDED FOR TURBO C)
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      RETURN
      END
C
C ----------TCREMO-----------------------------
C
      SUBROUTINE TCREMO
C
C     PURPOSE--READ POSITION FROM THE GRAPHICS WINDOW.
C              THE MOUSE POSITION AT THE NEXT MOUSE CLICK
C              WILL BE DETERMINED.
C              THIS ROUTINE WILL WAIT UNTIL A MOUSE BUTTON
C              IS PRESSED.
C              THIS IS USED BY THE DATAPLOT CROSS-HAIR COMMAND.
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      RETURN
      END
C
C ----------TCERSC-----------------------------
C
      SUBROUTINE TCERSC
C
C     PURPOSE--ERASE THE SCREEN (= REGION (X1,Y1)-(X2,Y2).)
C              DEFINE A VIEWPORT THAT WILL BE USED
C              AS THE GRAPHICS AREA.
C              (AND ERASE THE AREA ONLY).
C     DATAPLOT CALLING ROUTINE--GRERSC
C
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='ERSC'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),111)COMMFC,INULC
  111 FORMAT(A4,A1)
CCCCC IF(ISUBRO.EQ.'ERSC'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCERSC.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCRIBE-----------------------------
C
      SUBROUTINE TCRIBE
C
C     PURPOSE--RING THE BELL
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='RIBE'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),111)COMMFC,INULC
  111 FORMAT(A4,A1)
CCCCC IF(ISUBRO.EQ.'RIBE'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCRIBE.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCCOSC-----------------------------
C
      SUBROUTINE TCCOSC
C
C     PURPOSE--COPY THE SCREEN
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='COSC'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),111)COMMFC,INULC
  111 FORMAT(A4,A1)
CCCCC IF(ISUBRO.EQ.'COSC'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCCOSC.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCRESC----------------------------
C
      SUBROUTINE TCRESC(PX1,PY1)
C
C     PURPOSE--READ THE SCREEN (VIA CROSS-HAIR OR MOUSE)
CCCCC ***** NOT YET WORKING *****
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='RESC'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),122)COMMFC,PX1,PY1,INULC
  122 FORMAT(A4,1X,F10.5,1X,F10.5,A1)
CCCCC IF(ISUBRO.EQ.'RESC'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCRESC.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCUPSC-----------------------------
C
      SUBROUTINE TCUPSC
C
C     PURPOSE--COPY THE PIXMAP TO THE SCREEN.
C              UPDATE THE GRAPHICS WINDOW WITH
C              A PREVIOUSLY SAVED WINDOW.
C              (NOT USED FOR PC DRIVER)
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      RETURN
      END
C
C ----------TCFLBU-----------------------------
C
      SUBROUTINE TCFLBU
C
C     PURPOSE--FLUSH THE SCREEN BUFFER.
C              (NEEDED ON PC?)
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      RETURN
      END
C
C ----------TCSEMO-----------------------------
C
      SUBROUTINE TCSEMO(IMODE)
C
C     PURPOSE--SET THE MODE
C
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      CHARACTER*4 IMODE
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='SEMO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),112)COMMFC,IMODE,INULC
  112 FORMAT(A4,1X,A4,A1)
CCCCC IF(ISUBRO.EQ.'SEMO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSEMO.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCSECO-----------------------------
C
      SUBROUTINE TCSECO(ICASE,ICOL)
C
C     PURPOSE--SET THE COLOR
C
CCCCC INTEGER*4 NBYTES
      INTEGER NBYTES
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      CHARACTER*4 ICASE
      CHARACTER*4 ICOL
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      IF(TCPLFI.EQ.'CLOS')THEN
CCCCC    OPEN(UNIT=8,FILE='C:\TURBOC\FRONTEND\DPGROU.TEX')
         TEXTFC(1:4)='PLOT'
         TEXTFC(5:8)='SECO'
CCCCC    NBYTES=8+4
CCCCC    NBYTES=12+4
         NBYTES=12+4+4
CNOPC    CALL COPY_TO_REAL_MODE@(NTEXTF,NBYTES)
CNOPC    CALL REAL_MODE@
         NPLOTF=0
         TCPLFI='OPEN'
C
         COMMFC='INDE'
         NPLOTF=NPLOTF+1
         PLOTFC(NPLOTF)=' '
         WRITE(PLOTFC(NPLOTF),112)COMMFC,IPLATF,INULC
  112    FORMAT(A4,1X,A10,A1)
CCCCC IF(ISUBRO.EQ.'SECO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSECO.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC    IF(NPLOTF.GE.10) CALL TCSEND
C
         COMMFC='OPDE'
         NPLOTF=NPLOTF+1
         PLOTFC(NPLOTF)=' '
         WRITE(PLOTFC(NPLOTF),111)COMMFC,INULC
  111    FORMAT(A4,A1)
CCCCC IF(ISUBRO.EQ.'SECO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC    IF(NPLOTF.GE.10) CALL TCSEND
C
      ENDIF
C
      COMMFC='SECO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),113)COMMFC,ICASE,ICOL,INULC
  113 FORMAT(A4,1X,A4,1X,A4,A1)
CCCCC IF(ISUBRO.EQ.'SECO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCSEPA-----------------------------
C
      SUBROUTINE TCSEPA(ICASE,IPATT)
C
C     PURPOSE--SET THE PATTERN
C
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      CHARACTER*4 ICASE
      CHARACTER*4 IPATT
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='SEPA'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),113)COMMFC,ICASE,IPATT,INULC
  113 FORMAT(A4,1X,A4,1X,A4,A1)
CCCCC IF(ISUBRO.EQ.'SEPA'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSEPA.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCSETH----------------------------
C
      SUBROUTINE TCSETH(PTHICK)
C
C     PURPOSE--SET LINE THICKNESS.
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='SETH'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),122)COMMFC,PTHICK,INULC
  122 FORMAT(A4,1X,F10.5,A1)
CCCCC IF(ISUBRO.EQ.'SETH'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSETH.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCSEFO----------------------------
C
      SUBROUTINE TCSEFO(FONT)
C
C     PURPOSE--SET TEXT FONT.
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      CHARACTER*4 FONT
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='SEFO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),112)COMMFC,FONT,INULC
  112 FORMAT(A4,1X,A4,A1)
CCCCC IF(ISUBRO.EQ.'SEFO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSEFO.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCSECA----------------------------
C
      SUBROUTINE TCSECA(ICASE)
C
C     PURPOSE--SET TEXT CASE.
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      CHARACTER*4 ICASE
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='SECA'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),112)COMMFC,ICASE,INULC
  112 FORMAT(A4,1X,A4,A1)
CCCCC IF(ISUBRO.EQ.'SECA'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSECA.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCSEFI----------------------------
C
      SUBROUTINE TCSEFI(IFILL)
C
C     PURPOSE--SET REGION FILL.???
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      CHARACTER*4 IFILL
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='SEFI'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),112)COMMFC,IFILL,INULC
  112 FORMAT(A4,1X,A4,A1)
CCCCC IF(ISUBRO.EQ.'SEFI'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSEFI.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCSESI----------------------------
C
      SUBROUTINE TCSESI(PHEIGH,PWIDTH,PVEGAP,PHOGAP)
C
C     PURPOSE--SET TEXT SIZE.
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='SESI'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PHEIGH,PWIDTH,INULC
  123 FORMAT(A4,1X,F10.5,1X,F10.5,A1)
CCCCC IF(ISUBRO.EQ.'SESI'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSESI.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCSEDI----------------------------
C
      SUBROUTINE TCSEDI(IDIR)
C
C     PURPOSE--SET TEXT DIRECTION.
      CHARACTER*4 IDIR
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='SEDI'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),112)COMMFC,IDIR,INULC
  112 FORMAT(A4,1X,A4,A1)
CCCCC IF(ISUBRO.EQ.'SEDI'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSEDI.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCSEJU----------------------------
C
      SUBROUTINE TCSEJU(JUST)
C
C     PURPOSE--SET TEXT JUSTIFICATION.
      CHARACTER*4 JUST
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='SEJU'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),112)COMMFC,JUST,INULC
  112 FORMAT(A4,1X,A4,A1)
CCCCC IF(ISUBRO.EQ.'SEJU'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSEJU.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCMOTO----------------------------
C
      SUBROUTINE TCMOTO(PX1,PY1)
C
C     PURPOSE--MOVE TO A POINT (INVISIBLY)
C              DO NOT DRAW.   DO NOT ACTIVATE THE PIXEL.
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='MOTO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),122)COMMFC,PX1,PY1,INULC
  122 FORMAT(A4,1X,F10.5,1X,F10.5,A1)
CCCCC IF(ISUBRO.EQ.'MOTO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCMOTO.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCDRPO----------------------------
C
      SUBROUTINE TCDRPO(PX1,PY1)
C
C     PURPOSE--DRAW A POINT (ACTIVATE A PIXEL).
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='DRPO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),122)COMMFC,PX1,PY1,INULC
  122 FORMAT(A4,1X,F10.5,1X,F10.5,A1)
CCCCC IF(ISUBRO.EQ.'DRPO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCDRPO.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCDRLI----------------------------
C
      SUBROUTINE TCDRLI(PX1,PY1,PX2,PY2)
C
C     PURPOSE--DRAW A (P1-SEGMENT) LINE FROM (PX1,PY1) TO (PX2,PY2).
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='MOTO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX1,PY1,INULC
  123 FORMAT(A4,1X,F10.5,1X,F10.5,A1)
CCCCC IF(ISUBRO.EQ.'DRLI'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCDRLI.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
      IF(NPLOTF.GE.10) CALL TCSEND
C
      COMMFC='DRTO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX2,PY2,INULC
CCCCC IF(ISUBRO.EQ.'DRLI'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCDRBO----------------------------
C
      SUBROUTINE TCDRBO(PX1,PY1,PX2,PY2)
C
C     PURPOSE--DRAW A BOX (BUT DO NOTHING ABOUT FILL).
C              THE COLOR OF THE BOX BORDER IS DICTATED BY
C              THE LAST CALL TO TCFIFC (FORE!GROUND COLOR).
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='MOTO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX1,PY1,INULC
  123 FORMAT(A4,1X,F10.5,1X,F10.5,A1)
CCCCC IF(ISUBRO.EQ.'DRBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCDRBO.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      COMMFC='DRTO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX2,PY1,INULC
CCCCC IF(ISUBRO.EQ.'DRBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX2,PY2,INULC
CCCCC IF(ISUBRO.EQ.'DRBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX1,PY2,INULC
CCCCC IF(ISUBRO.EQ.'DRBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX1,PY1,INULC
CCCCC IF(ISUBRO.EQ.'DRBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCDRPL----------------------------
C
      SUBROUTINE TCDRPL(PXV,PYV,NV)
C
C     PURPOSE--DRAW A LINE OR POLYLINE.
C              NOTE THAT THE ATTRIBUTES OF THE LINE HAVE ALREADY
C              BEEN SET (BY THE TCSELP, TCSELT, AND TCSEFG ROUTINES).
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      DIMENSION PXV(*)
      DIMENSION PYV(*)
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='MOTO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PXV(1),PYV(1),INULC
  123 FORMAT(A4,1X,F10.5,1X,F10.5,A1)
CCCCC IF(ISUBRO.EQ.'DRPL'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCDRPL.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      IF(NV.LE.1)GOTO1090
      COMMFC='DRTO'
      DO1000I=2,NV
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PXV(I),PYV(I),INULC
CCCCC IF(ISUBRO.EQ.'DRPL'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
 1000 CONTINUE
 1090 CONTINUE
C
      RETURN
      END
C
C ----------TCFIBO----------------------------
C
      SUBROUTINE TCFIBO(PX1,PY1,PX2,PY2)
C
C     PURPOSE--FILL A BOX (BUT ONLY WITH SOLID FILL).
C              THE COLOR OF THE FILL IS DICTATED BY
C              THE LAST CALL TO ...
C              HATCH PATTERNS MUST BE DRAWN BY THE CALLING
C              PROGRAM (I.E., SEND THE INDIVIDUAL LINES TO THE
C              TCDRLI ROUTINE).  ???
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='MOTO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX1,PY1,INULC
  123 FORMAT(A4,1X,F10.5,1X,F10.5,A1)
CCCCC IF(ISUBRO.EQ.'FIBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCFIBO.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      COMMFC='DRTO'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX2,PY1,INULC
CCCCC IF(ISUBRO.EQ.'FIBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX2,PY2,INULC
      IF(NPLOTF.GE.10) CALL TCSEND
CCCCC IF(ISUBRO.EQ.'FIBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
C
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX1,PY2,INULC
CCCCC IF(ISUBRO.EQ.'FIBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),123)COMMFC,PX1,PY1,INULC
CCCCC IF(ISUBRO.EQ.'FIBO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCWRTE----------------------------
C
      SUBROUTINE TCWRTE(ISTRI4,NSTRI4)
C
C     PURPOSE--WRITE OUT A HORIZONTAL STRING AT CURRENT POISTION
      CHARACTER*4 ISTRI4
      DIMENSION ISTRI4(*)
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
      COMMFC='WRTE'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      WRITE(PLOTFC(NPLOTF),132)COMMFC,(ISTRI4(I),I=1,NSTRI4),INULC
  132 FORMAT(A4,1X,80A1,A1)
CCCCC IF(ISUBRO.EQ.'WRTE'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCWRTE.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
C
      RETURN
      END
C
C ----------TCFIRE----------------------------
C
      SUBROUTINE TCFIRE(PXV,PYV,NV)
C
C     PURPOSE--FILL A REGION.
C              RECTANGULAR REGIONS WILL BE FILLED DIFFERENTLY
C              THAN NON-RECTANGULAR REGIONS.  DATAPLOT ONLY
C              HANDLES CONVEX POLYGONS, SO SET THIS (FOR FASTER
C              PERFORMANCE).
C              THIS ROUTINE ONLY DOES SOLID FILL.
C              THE COLOR OF THE FILL IS DICTATED BY
C              THE LAST CALL TO TCFIFC (FORE!GROUND COLOR).
C              HATCH PATTERNS MUST BE DRAWN BY THE CALLING
C              HATCH PATTERNS MUST BE DRAWN BY THE CALLING
C              PROGRAM (I.E., SEND THE INDIVIDUAL LINES TO THE
C              TCDRLI ROUTINE).
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
      DIMENSION PXV(*)
      DIMENSION PYV(*)
CCCCC OCTOBER 1993.  ADD FOLLOWING LINE
      CHARACTER*4 COMMFC
C
      COMMFC='FIRE'
      NPLOTF=NPLOTF+1
      PLOTFC(NPLOTF)=' '
      DO2100I=1,NV
CCCCC NOT YET DONE
CCCCC IF(ISUBRO.EQ.'FIRE'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCFIRE.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
CNOPC IF(NPLOTF.GE.10) CALL TCSEND
 2100 CONTINUE
C
      RETURN
      END
C
C ----------TCSEND----------------------------
C
      SUBROUTINE TCSEND
C
C     PURPOSE--SEND NGRBYT BYTES
C              OF TC'S COMMON--
C                 84 BYTES OF TEXTFC,
C                 4 BYTES OF NTEXTF,
C                 4 BYTES FOR NPLOTF,
C                 (AT MOST) 11*84 BYTES OF PLOTFC
C              TO THE C-SIDE.
C
C     WRITTEN BY--JAMES J. FILLIBEN
C     ORIGINAL VERSION--MAY  18, 1991
C
CCCCC INTEGER*4 NBYTES
      INTEGER NBYTES
      INCLUDE 'DPCODV.INC'
      INCLUDE 'DPCONP.INC'
C
CCCCC IF(ISUBRO.EQ.'SEND'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,811)
  811    FORMAT(1H ,'FROM TCSEND.FOR--NPLOTF,PLOTFC(NPLOTF) =')
         WRITE(9,812)NPLOTF,PLOTFC(NPLOTF)
  812    FORMAT(1H ,I4,2X,A84)
CCCCC ENDIF
C
CCCCC NBYTES=(8+84)+(84*NPLOTF)
      NBYTES=(12+84+84)+(84*NPLOTF)
CNOPC CALL COPY_TO_REAL_MODE@(NTEXTF,NBYTES)
CNOPC CALL REAL_MODE@
      NPLOTF=0
C
      RETURN
      END
C
C ----------TCINCF-----------------------------
C
      SUBROUTINE TCINCF(ISUBRO)
C
C     PURPOSE--INITIALIZE (= MAKE EMPTY) THE FILE ...DPCOIN
C              THAT WILL RECEIVE COMMAND LINES.
C     DATAPLOT CALLING ROUTINE--MAIN
C
      CHARACTER*4 ISUBRO
C
      CHARACTER*4 IFEEDB
      CHARACTER*4 IPRINT
      COMMON /MACH/IRD,IPR,CPUMIN,CPUMAX,NUMBPC,NUMCPW,NUMBPW
      COMMON /PRINT/IFEEDB,IPRINT
C
      IF(ISUBRO.EQ.'INCF'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
  999    FORMAT(1H )
         WRITE(9,51)
   51    FORMAT(1H ,'***** AT THE BEGINNING OF TCINCF IN TCDRIV--')
         WRITE(9,52)ISUBRO
   52    FORMAT(1H ,'ISUBRO = ',A4)
      ENDIF
C
CNOPC OPEN(UNIT=10,FILE='C:\TURBOC\FRONTEND\DPCOIN.TEX')
      OPEN(UNIT=10,FILE='DPCOIN.TEX')
      ENDFILE 10
      CLOSE(10)
C
      IF(ISUBRO.EQ.'INCF'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
         WRITE(9,9021)
 9021    FORMAT(1H ,'***** AT THE END       OF TCINCF IN TCDRIV--')
         WRITE(9,9022)ISUBRO
 9022    FORMAT(1H ,'ISUBRO = ',A4)
      ENDIF
C
      RETURN
      END
C
C ----------TCWRCO-----------------------------
C
      SUBROUTINE TCWRCO(STRING,ISUBRO)
C
C     PURPOSE--WRITE THE LAST ENTERED COMMAND LINE
C              (CONSISTING OF 80 CHARACTERS IN STRING())
C              TO THE END OF FILE ...TCCOMF.TEX
C     DATAPLOT CALLING ROUTINE--DPGETC
C
      CHARACTER*80 STRING
      CHARACTER*4 ISUBRO
      CHARACTER*1 ICJUNK
C
      CHARACTER*4 IFEEDB
      CHARACTER*4 IPRINT
      COMMON /MACH/IRD,IPR,CPUMIN,CPUMAX,NUMBPC,NUMCPW,NUMBPW
      COMMON /PRINT/IFEEDB,IPRINT
C
      IF(ISUBRO.EQ.'WRCO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
  999    FORMAT(1H )
         WRITE(9,51)
   51    FORMAT(1H ,'***** AT THE BEGINNING OF TCWRCO IN TCDRIV--')
         WRITE(9,52)ISUBRO
   52    FORMAT(1H ,'ISUBRO = ',A4)
         WRITE(9,54)STRING(1:80)
   54    FORMAT(1H ,'STRING(1:80) = ',A80)
      ENDIF
C
CNOPC OPEN(UNIT=10,FILE='C:\TURBOC\FRONTEND\DPCOIN.TEX')
      OPEN(UNIT=10,FILE='DPCOIN.TEX')
C
      DO1100I=1,1000000
      READ(10,1105,END=1180)ICJUNK
 1105 FORMAT(A1)
 1100 CONTINUE
C
 1180 CONTINUE
      BACKSPACE 10
C
      WRITE(10,1181)STRING(1:80)
 1181 FORMAT(A80)
C
      ENDFILE 10
      CLOSE(10)
C
      IF(ISUBRO.EQ.'WRCO'.OR.ISUBRO.EQ.'DRIV')THEN
         WRITE(9,999)
         WRITE(9,9021)
 9021    FORMAT(1H ,'***** AT THE END       OF TCWRCO IN TCDRIV--')
         WRITE(9,9022)ISUBRO
 9022    FORMAT(1H ,'ISUBRO = ',A4)
         WRITE(9,9024)STRING(1:80)
 9024    FORMAT(1H ,'STRING(1:80) = ',A80)
      ENDIF
C
      RETURN
      END
