C     .TITLE HYSAT
C
C  26 NOV 73 (PDH) CHANGE MAX CHANNEL FOR A-D & D-A (#1690 & #1710)
C  16 MAY 72 - MOD BY PAUL HENDERSON FOR UOW
C		CHANGE 'CALL SEEK( . .)' TO 'CALL OPEN ( . .)'
C
C       HYBRID STATIC ANALOG TEST
C       NOVEMBER, 1968
C       C.L. CROSS
C       CARNEGIE-MELLON UNIVERSITY
C       HYBRID COMPUTATION LABORATORY
C
        INTEGER ANSWER,COL,ERROR,OU,S,TOLER,TYPE,VALUE
        LOGICAL ERRORS,ERRSW,REPSW,SAVESW,SKIP,STATE,SWITCH,Z
        LOGICAL RSAC,RSCS,TGPI,TRSL
        REAL IFIELD(8),ILCODE(8),INAME(2),IREP(8),LMODE(3),INVARG(8)
        REAL IERROR(8,5),MODES(3,3),MESS1(5,3),MESS2(3,3)
        REAL MFIELD,NFIELD,ATOD
        DIMENSION ONAME(2),AMODE(3),TCON(3),UFIELD(8),TYPES(8)
        DIMENSION COMP(5),SLINE(5),GPI(5),WSTATE(3),OCCURI(3),FOCCUR(3)
        EXTERNAL HANDLE
        COMMON/A/CHAR(72)
        COMMON/B/VALUE
        COMMON/C/COL,TYPE
        COMMON/D/ANSWER
        COMMON/E/Z
        COMMON/F/INPUT
        EQUIVALENCE (IERROR(1,1),UFIELD(1))
        EQUIVALENCE (IERROR(1,2),ILCODE(1))
        EQUIVALENCE (IERROR(1,3),IFIELD(1))
        EQUIVALENCE (IERROR(1,4),IREP(1))
        EQUIVALENCE (IERROR(1,5),INVARG(1))
        EQUIVALENCE (MODES(1,1),AMODE(1))
        EQUIVALENCE (MODES(1,2),TCON(1))
        EQUIVALENCE (MODES(1,3),LMODE(1))
        EQUIVALENCE (MESS1(1,1),COMP(1))
        EQUIVALENCE (MESS1(1,2),SLINE(1))
        EQUIVALENCE (MESS1(1,3),GPI(1))
        EQUIVALENCE (MESS2(1,1),WSTATE(1))
        EQUIVALENCE (MESS2(1,2),OCCURI(1))
        EQUIVALENCE (MESS2(1,3),FOCCUR(1))
        DATA AMODE(1)/5H ANAL/
        DATA AMODE(2)/5HOG MO/
        DATA AMODE(3)/5HDE   /
        DATA ATOD/2HAD/
        DATA COMP(1)/5HCOMPA/
        DATA COMP(2)/5HRATOR/
        DATA COMP(3)/5H     /
        DATA COMP(4)/5H     /
        DATA COMP(5)/5H     /
        DATA FOCCUR(1)/5HFAILE/
        DATA FOCCUR(2)/5HD TO /
        DATA FOCCUR(3)/5HOCCUR/
        DATA GPI(1)/5HGENER/
        DATA GPI(2)/5HAL PU/
        DATA GPI(3)/5HRPOSE/
        DATA GPI(4)/5H INTE/
        DATA GPI(5)/5HRRUPT/
        DATA IFIELD(1)/5HILLEG/
        DATA IFIELD(2)/5HAL FI/
        DATA IFIELD(3)/5HELD  /
        DATA IFIELD(4)/5H     /
        DATA IFIELD(5)/5H     /
        DATA IFIELD(6)/5H     /
        DATA IFIELD(7)/5H     /
        DATA IFIELD(8)/5H     /
        DATA ILCODE(1)/5HILLEG/
        DATA ILCODE(2)/5HAL CO/
        DATA ILCODE(3)/5HMMAND/
        DATA ILCODE(4)/5H CODE/
        DATA ILCODE(5)/5H     /
        DATA ILCODE(6)/5H     /
        DATA ILCODE(7)/5H     /
        DATA ILCODE(8)/5H     /
        DATA INVARG(1)/5HINVAL/
        DATA INVARG(2)/5HID AR/
        DATA INVARG(3)/5HGUMEN/
        DATA INVARG(4)/5HT IN /
        DATA INVARG(6)/5HLD   /
        DATA INVARG(7)/5H     /
        DATA INVARG(8)/5H     /
        DATA IREP(1)/5HINCON/
        DATA IREP(2)/5HSISTE/
        DATA IREP(3)/5HNT RE/
        DATA IREP(4)/5HPETIT/
        DATA IREP(5)/5HION S/
        DATA IREP(6)/5HPECIF/
        DATA IREP(7)/5HICATI/
        DATA IREP(8)/5HON   /
        DATA LMODE(1)/5H LOGI/
        DATA LMODE(2)/5HC MOD/
        DATA LMODE(3)/5HE    /
        DATA MFIELD/5HM FIE/
        DATA NFIELD/5HN FIE/
        DATA OCCURI(1)/5HOCCUR/
        DATA OCCURI(2)/5HRED  /
        DATA OCCURI(3)/5H     /
        DATA SLINE(1)/5HSENSE/
        DATA SLINE(2)/5H LINE/
        DATA SLINE(3)/5H     /
        DATA SLINE(4)/5H     /
        DATA SLINE(5)/5H     /
        DATA TCON(1)/5H TIME/
        DATA TCON(2)/5H CONS/
        DATA TCON(3)/5HTANT /
        DATA TYPES(1)/2HA /
        DATA TYPES(2)/2HD /
        DATA TYPES(3)/2HF /
        DATA TYPES(4)/2HT /
        DATA TYPES(5)/2HP /
        DATA TYPES(6)/2HPP/
        DATA TYPES(7)/2HD /
        DATA TYPES(8)/2HQ /
        DATA UFIELD(1)/5HUNREC/
        DATA UFIELD(2)/5HOGNIZ/
        DATA UFIELD(3)/5HABLE /
      DATA UFIELD(4)/5HFIELD/
        DATA UFIELD(5)/5H     /
        DATA UFIELD(6)/5H     /
        DATA UFIELD(7)/5H     /
        DATA UFIELD(8)/5H     /
        DATA WSTATE(1)/5HIN WR/
        DATA WSTATE(2)/5HONG S/
        DATA WSTATE(3)/5HTATE /
C       CONSOLE INITIALIATION
        CALL INIT(ERROR)
        IF (ERROR.EQ.0) GO TO 10
        WRITE (4,99999)
        STOP 1
C       PROGRAM INITIALIZATION
10      TOLER=5
        ERRSW=.TRUE.
        SAVESW=.FALSE.
        WRITE(4,10010)
C       INPUT UNIT SPECIFICATION
20      IF (RSAC(0)) GO TO 21
        WRITE (4,10020)
        GO TO 22
21      WRITE(4,10021)
22      WRITE(4,10000)
        READ (4,11000) IU
        IF (IU.LT.1) GO TO 60
        IF (IU-3) 70,30,60
C       DECTAPE INPUT
30      IF (.NOT.RSAC(0)) WRITE(4,10030)
40      IF (RSAC(0)) GO TO 41
        WRITE(4,10040)
        GO TO 42
41      WRITE(4,10041)
42      WRITE(4,10000)
        READ(4,11010) IU,INAME
        IF (IU.GT.0.AND.IU.LT.4) GO TO 50
        WRITE(4,12000)
        GO TO 40
50      CALL OPEN(IU,INAME)
        GO TO 100
C       ILLEGAL IU
60      WRITE(4,12000)
        GO TO 20
C       TELETYPE OR CARD READER INPUT
70      IU=IU+3
C
C       OUTPUT UNIT SPECIFICATION
100     IF (RSAC(0)) GO TO 101
        WRITE(4,10050)
        GO TO 102
101     WRITE(4,10051)
102     WRITE(4,10000)
        READ(4,11000) OU
        IF (OU-1) 120,110,130
C       TELETYPE OUTPUT
110     OU=4
        GO TO 200
C       ILLEGAL OU
120     WRITE(4,12010)
        GO TO 100
C
130   IF (OU.EQ.3) GO TO 150
C  LINE PRINTER OR PRECISION DISPLAY OUTPUT
140     OU=OU+4
        GO TO 200
C       DECTAPE OUTPUT
150     IF (.NOT.RSAC(0)) WRITE(4,10060)
160     IF (RSAC(0)) GO TO 161
        WRITE(4,10040)
        GO TO 162
161     WRITE(4,10041)
162     WRITE(4,10000)
        READ(4,11010) OU,ONAME
        IF (OU.GT.0.AND.OU.LT.4) GO TO 170
        WRITE(4,12010)
        GO TO 160
170     CALL OPEN(OU,ONAME)
        GO TO 200
C
C       TEST INITIALIZATION
200     INPUT=IU
        S=1
        IF (.NOT.RSAC(0)) WRITE(4,10070)
210     IF (RSAC(0)) GO TO 211
        WRITE(4,10080)
        GO TO 212
211     WRITE(4,10081)
212     WRITE(4,10000)
        READ(4,11000) L
C
C       DATA STATEMENT INTERPRETER
C
C       READ NEXT EXECUTABLE RECORD
1000    IF (SKIP) GO TO 1001
        IF (ERRORS) GO TO 1010
        GO TO 1020
1001    IF (ERRORS) GO TO 1020
1010    S=1
1020    IF (RSAC(7).OR.RSAC(8).OR.RSAC(9)) GO TO 9990
        IF (RSAC(10)) GO TO 2140
        JINPUT=INPUT
        IF ( RSAC(11)) JINPUT=4
        DO 1030 L=1,S
        IF (JINPUT.EQ.4) WRITE(4,10000)
1030    READ(JINPUT,11020) CHAR
C       GET COMMAND CODE
1040    COL=1
        CALL DECODE
        IF (TYPE) 2500,1050,1060
1050    IF (VALUE.NE.0) GO TO 2520
C       BLANK STATEMENT - RESTORE IU
        INPUT=IU
        GO TO 1010
C
1060    IF (TYPE-3) 2520,1070,1150
1070    IF (VALUE+5) 1080,1090,1100
C       YES STATEMENT
1080    ERRSW=.TRUE.
        GO TO 1010
C       NO STATEMENT
1090    ERRSW=.FALSE.
        GO TO 1010
C
1100    IF (VALUE+3) 1110,1120,1130
C       ON STATEMENT
1110    SAVESW=.TRUE.
        GO TO 1010
C       OFF STATEMENT
1120    SAVESW=.FALSE.
        GO TO 1010
C       END,COMMENT,OTHER
1130    IF (VALUE+1) 2140,1140,1150
C       COMMENT
1140    WRITE(OU,11030) CHAR
        GO TO 1010
C       SAVE COMMAND CODE AND INITIALIZE ALL VALUES
1150    IVALUE=VALUE
        ITYPE=TYPE
        I=-1
        J=0
        M=0
        N=0
        S=1
        STATE=.TRUE.
        SWITCH=.FALSE.
        ERRORS=.FALSE.
        IF (ITYPE.NE.3) GO TO 1380
C       GET (N)
        CALL DECODE
        IF (TYPE) 2500,1200,1160
1160    IF (TYPE-2) 1170,1410,2540
1170    N=VALUE
        IF (IVALUE-25) 1210,1180,1190
C       ERROR TOLERANCE STATEMENT
1180    TOLER=N
        GO TO 1020
C       SKIP STATEMENT
1190    S=N+1
1195    INPUT=IU
        GO TO 1020
C
1200    IF (VALUE.NE.0) GO TO 1230
        IF (IVALUE-25) 1210,1180,1195
C      GET (SIGN)
1210    CALL DECODE
        IF (TYPE) 2500,1220,1260
1220    IF (VALUE.EQ.0) GO TO 1240
1230    IF (IVALUE.GE.25) GO TO 2540
        IF (VALUE.EQ.1) GO TO 1240
C       MINUS SIGN
        STATE=.FALSE.
C       PLUS SIGN
1240    IF (IVALUE.GE.15) GO TO 1290
C       GET (M)
        CALL DECODE
        IF (TYPE) 2500,1250,1270
1250    IF (VALUE) 2540,1290,2540
1260    IF (IVALUE.GE.15) GO TO 1310
1270    IF (TYPE-2) 1280,1410,2540
1280    M=VALUE
C       GET (I)
1290    CALL DECODE
        IF (TYPE) 2500,1300,1310
1300    IF (VALUE) 2540,1330,2540
1310    IF (TYPE-2) 1320,1410,2540
1320    I=VALUE
C       GET (J)
1330    CALL DECODE
        IF (TYPE) 2500,1340,1350
1340    IF (VALUE) 2540,1370,2540
1350    IF (TYPE-2) 1360,1410,2540
1360    J=VALUE
1370    IF (IVALUE.EQ.11.OR.IVALUE.GE.20) GO TO 1600
C       GET (ERROR SWITCH)
1380    CALL DECODE
        IF (TYPE) 2500,1390,1400
1390    IF (VALUE) 2540,1600,2540
1400    IF (TYPE-2) 2540,1420,2540
1410    IF (IVALUE.EQ.11.OR .IVALUE.GE.20) GO TO 2540
1420    IF (VALUE) 1430,1440,1450
C       E ERROR SWITCH
1430    SKIP=.TRUE.
        GO TO 1460
C       H ERROR SWITCH
1440    SWITCH=.TRUE.
        GO TO 1600
C       S ERROR SWITCH
1450    SKIP=.FALSE.
C       GET (S)
1460    CALL DECODE
        IF (TYPE) 2500,1470,1480
1470    IF (VALUE) 2540,1600,2540
1480    IF (TYPE-2) 1490,2540,2540
1490    S=VALUE+1
C       END OF DATA STATEMENT INTERPRETER
C
C       DATA STATEMENT EXECUTION
1600    IF (ITYPE.EQ.3) GO TO 1650
1605    IF (ITYPE-5) 1610,1630,1640
C       ANALOG MODE STATEMENT
1610    CALL SAMO(IVALUE,ERROR)
C       15 MILLISECOND PAUSE
        DO 1620 L=1,1100
1620    CONTINUE
        GO TO 1642
C       TIME CONSTANT STATEMENT
1630    CALL STCO(IVALUE,ERROR)
        GO TO 1642
C       LOGIC MODE STATEMENT
1640    CALL SLMO(IVALUE,ERROR)
C       ERRORX SECTION
1642    IF (ERROR.EQ.0) GO TO 1000
        ERRORS=.TRUE.
        IF (SWITCH.OR.RSAC(4).OR.RSAC(6)) GO TO 1644
        IF (ERRSW.AND..NOT.RSAC(5)) GO TO 1644
        IF (RSAC(1)) GO TO 1605
        GO TO 1000
1644    WRITE(OU,12040) (MODES(J,I),J=1,3)
        IF (SWITCH.OR.RSAC(1).OR.RSAC(6)) GO TO 1645
        GO TO 1000
1645    IF (OU.NE.4) WRITE(4,12040) (MODES(J,I),J=1,3)
        ANSWER=0
        CALL DECIDE
        IF (ANSWER) 1605,1000,1040
C       TRANSLATE COMPONENT INDEX TO ALPHANUMERIC CODE
1650    IF (IVALUE-10) 1652,1654,1656
1652    CTYPE=TYPES(IVALUE+1)
        GO TO 1656
1654    CTYPE=ATOD
C       ANALYZE ADDRESS (N) AND VALUE (M)
1656    IF (IVALUE-10) 1680,1690,1660
1660    IF (IVALUE-15) 1710,1730,1670
1670    IF (IVALUE-17) 1730,1740,1740
C       ANALOG COMPONENT
1680    NMAX=119
        GO TO 1700
C       A-TO-D
1690    NMAX=63
1700    IF (RSAC(2)) GO TO 1725
        IF (RSAC(3)) GO TO 1701
        IF (SAVESW) GO TO 1725
1701    IF (IVALUE.EQ.10) GO TO 1720
        IF (M.GT.11999) GO TO 2600
        IF (IVALUE.NE.4) GO TO 1725
        CALL RAMO(MODE)
        IF (MODE.NE.7) GO TO 1725
        IF (.NOT.STATE) GO TO 2600
        GO TO 1720
C       D-TO-A
1710    NMAX=5
1720    IF (M.GT.9999) GO TO 2600
1725    IF (N.GT.NMAX) GO TO 2610
        IF (IVALUE.EQ.11) M=FLOAT(M)*13.1072
        IF (.NOT.STATE) M=-M
        GO TO 1770
C       SL OR GP
1730    NMAX=7
        GO TO 1750
C       CS, FR, OR CL
1740    NMAX=15
1750    IF (N-NMAX-1) 1770,1760,2610
C       ALL COMPONENTS
1760    IF (I.GE.0) GO TO 2560
        N=0
        J=NMAX+1
        GO TO 1790
C       ANALYZE REPETITION SPECFICATIONS
1770    IF (I) 1780,1800,1810
C       (I) IS BLANK - NO REPETITIONS
1780    J=N+1
1790    I=1
        GO TO 1820
C       (I) IS ZERO - J REPETITIONS OF N
1800    L=N
        N=1
        I=1
        REPSW=.FALSE.
        GO TO 1830
C       (I) IS GREATER THAN ZERO - INCREMENT N BY I TO J
1810    IF (N.GT.J.OR.J.GT.NMAX) GO TO 2560
        J=J+1
1820    N=N+1
        REPSW=.TRUE.
C       MAIN EXECUTION LOOP
1830    DO 2130 K=N,J,I
        IF (REPSW) L=K-1
        IF (IVALUE-10) 1870,1900,1840
1840    IF (IVALUE-15) 1910,1920,1850
1850    IF (IVALUE-17) 1930,2060,1860
1860    IF (IVALUE-21) 2070,2110,2540
C       ANALOG COMPONENT SELECTION STATEMENT
1870    IF (RSAC(2)) GO TO 1880
        IF (RSAC(3)) GO TO 1871
        IF (SAVESW) GO TO 1880
1871    IF (IVALUE.EQ.4.AND.MODE.EQ.7) GO TO 1890
1880    CALL RAVA(IVALUE,L,VALUE,ERROR)
        TYPE=-1
        GO TO 1901
C       SET A POT
1890    CALL SPOT(L,M,TOLER,ERROR)
        IF (ERROR.EQ.0) GO TO 2130
        TYPE=0
        GO TO 1905
C       A-TO-D STATEMENT
1900    CALL CRAC(L,VALUE,ERROR)
        VALUE=FLOAT(VALUE)/13.1072
        TYPE=1
C       ERRORZ SECTION
1901    IF (ERROR.NE.0) GO TO 1905
        IF (RSAC(2)) GO TO 1904
        IF (RSAC(3)) GO TO 1902
        IF (SAVESW) GO TO 1904
1902    VALUE=VALUE-M
        IF (TOLER-IABS(VALUE).GE.0) GO TO 2130
        ERRORS=.TRUE.
        IF (SWITCH.OR.RSAC(4).OR.RSAC(6)) GO TO 1903
        IF (ERRSW.AND..NOT.RSAC(5)) GO TO 1903
        IF (RSAC(1)) GO TO 1908
        GO TO 2130
1903    WRITE(OU,12050) CTYPE,L,VALUE
        IF (SWITCH.OR.RSAC(1).OR.RSAC(6)) GO TO 19031
        GO TO 2130
19031   IF (OU.NE.4) WRITE(4,12050) CTYPE,L,VALUE
        GO TO 1907
C       STATUS READOUT MODE
1904    WRITE(OU,11060) CTYPE,L,VALUE
        GO TO 2130
C       ERRORY SECTION
1905    ERRORS=.TRUE.
        IF (SWITCH.OR.RSAC(4).OR.RSAC(6)) GO TO 1906
        IF (ERRSW.AND..NOT.RSAC(5)) GO TO 1906
        IF (RSAC(1)) GO TO 1908
        GO TO 2130
1906    WRITE(OU,12060) CTYPE,L,ERROR
        IF (SWITCH.OR.RSAC(1).OR.RSAC(6)) GO TO 19061
        GO TO 2130
19061   IF (OU.NE.4) WRITE(4,12060) CTYPE,L,ERROR
1907    ANSWER=0
        CALL DECIDE
        IF (ANSWER) 1908,2130,1040
1908    IF (TYPE) 1880,1890,1900
C       D-TO-A STATEMENT
1910    CALL LTDA(L,M,ERROR)
        GO TO 2130
C       SENSE LINE STATEMENT
1920    Z=TRSL(L)
        IF (STATE) GO TO 1921
        IF (Z) GO TO 1922
        GO TO 2130
1921    IF (Z) GO TO 2130
1922    TYPE=2
        GO TO 2064
C       GENERAL PURPOSE INTERRUPT STATEMENT
1930    Z=TGPI(L)
        IF (STATE) GO TO 1931
        IF (Z) GO TO 1932
        GO TO 1940
1931    IF (Z) GO TO 1940
1932    VALUE=1
        GO TO 2050
1940    Z=.FALSE.
        CALL IGPI(L,HANDLE,ERROR)
        CALL DGPI(L,ERROR)
        IF (Z) GO TO 2031
        IF (STATE) GO TO 2040
        GO TO 2130
2031    IF (STATE) GO TO 2130
        VALUE=2
        GO TO 2050
2040    VALUE=3
2050    TYPE=3
        GO TO 2065
C       COMPARATOR STATUS STATEMENT
2060    Z=RSCS(L)
        IF (STATE) GO TO 2061
        IF (Z) GO TO 2062
        GO TO 2130
2061    IF (Z) GO TO 2130
2062    TYPE=1
2064    VALUE=1
C       ERRORT SECTION
2065    ERRORS=.TRUE.
        IF (SWITCH.OR.RSAC(4).OR.RSAC(6)) GO TO 2066
        IF (ERRSW.AND..NOT.RSAC(5)) GO TO 2066
        IF (RSAC(1)) GO TO 2067
        GO TO 2068
2066  WRITE(OU,12070) (MESS1(COL,TYPE),COL=1,5),L,(MESS2(COL,VALUE),
     1 COL=1,3)
        IF (SWITCH.OR.RSAC(1).OR.RSAC(6)) GO TO 20661
        GO TO 2068
20661 IF (OU.NE.4) WRITE(4,12070) (MESS1(COL,TYPE),COL=1,5),L,
     1 (MESS2(COL,VALUE),COL=1,3)
        ANSWER=0
        CALL DECIDE
        IF (ANSWER) 2067,2068,1040
2067    IF (IVALUE-16) 1920,1930,2060
2068    IF (IVALUE.EQ.16.AND.VALUE.EQ.1) GO TO 1940
        GO TO 2130
C       FUNCTION RELAY STATEMENT
2070    IF (STATE) GO TO 2080
        CALL SSRM(L,ERROR)
        GO TO 2090
2080    CALL SSRP(L,ERROR)
C       2 MILLISECOND PAUSE
2090    DO 2100 M=1,150
2100    CONTINUE
        GO TO 2130
C       CONTROL LINE STATEMENT
2110    IF (STATE) GO TO 2120
        CALL RSCL(L,ERROR)
        GO TO 2130
2120    CALL SSCL(L,ERROR)
2130    CONTINUE
        GO TO 1000
C       END OF DATA STATEMENT EXECUTION
C
C       END STATEMENT
2140    WRITE(4,10090)
        IF (OU.NE.4) WRITE(OU,10090)
        IF (IU.LT.4) CALL CLOSE(IU)
        IF (OU.LT.4) CALL CLOSE(OU)
C       CONTINUATION DIRECTIVE
2150    IF (RSAC(0)) GO TO 2151
        WRITE(4,10100)
        GO TO 2152
2151    WRITE(4,10101)
2152    WRITE(4,10000)
        READ(4,11000) I
        IF (I-1) 2160,2170,2180
C       CONTINUE
2160    IF (IU.LT.4) CALL OPEN(IU,INAME)
        IF (OU-4) 150,210,210
C       TERMINATE
2170    STOP 2
C       RESTART, CHANGE IU AND OU, ILLEGAL CONTINUATION DIRECTIVE
2180    IF (I-3) 10,20,2190
2190    WRITE(4,12020)
        GO TO 2150
C
C       INPUT ERRORS CONTROL
2500    I=1
        GO TO 2700
2520    I=2
        GO TO 2700
2540    I=3
        GO TO 2700
2560    I=4
        GO TO 2700
2600    INVARG(5)=MFIELD
        GO TO 2620
2610    INVARG(5)=NFIELD
2620    I=5
C       ERRORA SECTION
2700    WRITE(4,11040) (IERROR(J,I),J=1,8)
        IF (INPUT.NE.4) WRITE(4,11030) (CHAR(J),J=1,40)
        IF (OU.EQ.4) GO TO 2710
        WRITE(OU,11040) (IERROR(J,I),J=1,8)
        WRITE(OU,11050) (CHAR(J),J=1,40)
2710    INPUT=4
        IF (RSAC(0)) GO TO 2711
        WRITE(4,10110)
        GO TO 1010
2711    WRITE(4,10111)
        GO TO 1010
C       ABORTS
9990    IF (IU.LT.4) CALL CLOSE(IU)
        IF (OU.LT.4) CALL CLOSE(OU)
        IF (RSAC(7)) GO TO 2170
        IF (RSAC(8)) GO TO 10
        IF (RSAC(9)) GO TO 20
        GO TO 2150
C       END OF INPUT ERROR CONTROL
C
C       OUTPUT FORMATS (HYSAT DIRECTIVES)
10000 FORMAT(1H ,1H$)
10010 FORMAT(1H1,5HHYSAT)
10020 FORMAT (57H0TYPE INPUT DIRECTIVE- 1-TTY,2-CARD READER,
     *3-DISK/DECTAPE)
10021 FORMAT(1H0,3HIU-)
10030 FORMAT(1H ,16HMOUNT INPUT TAPE)
10040 FORMAT(1H ,38HTYPE UNIT NUMBER,FILE NAME- NFILENMEXT)
10041 FORMAT (1H ,11HNFILENMEXT-)
10050 FORMAT (69H0TYPE OUTPUT DIRECTIVE- 1-TTY,2-LINE PRINTER,
     *3-DISK/DECTAPE,4-DISPLAY)
10051 FORMAT(1H0,3HOU-)
10060 FORMAT(1H ,17HMOUNT OUTPUT TAPE)
10070 FORMAT(1H0,27HENGAGE PATCH PANEL FOR TEST)
10080 FORMAT(1H ,18HTYPE CR WHEN READY)
10081 FORMAT (1H ,3HCR-)
10090 FORMAT(1H0,11HEND OF TEST)
10100 FORMAT(1H0,28HTYPE CONTINUATION DIRECTIVE-/1H ,47H0-CONTINUE,1-TER
     1MINATE,2-RESTART,3-CHANGE IU/OU)
10101 FORMAT(1H0,13HCONTINUATION-)
10110 FORMAT(1H ,21HCORRECT STATEMENT(S)-)
10111 FORMAT(1H ,8HCORRECT-)
C
C       INPUT FORMATS
11000 FORMAT(I1)
11010 FORMAT(I1,A5,A4)
11020 FORMAT(72A1)
11030 FORMAT(1H ,72A1)
11040 FORMAT(1H ,5HCO **,8A5)
11050 FORMAT(1H ,3HCO ,40A1)
11060 FORMAT(1H ,A2,I3,I6)
C
C       OUTPUT FORMATS (ERROR MESSAGES)
12000 FORMAT(1H ,12H**ILLEGAL IU)
12010 FORMAT(1H ,12H**ILLEGAL OU)
12020 FORMAT(1H ,32H**ILLEGAL CONTINUATION DIRECTIVE)
12040 FORMAT(1H ,2HCO,3A5,22HFAILED TO SET PROPERLY)
12050 FORMAT(1H ,13HCO COMPONENT ,A2,1X,I3,10H WRONG BY ,I6,11H MILLIVOL
     1TS)
12060 FORMAT(1H ,13HCO COMPONENT ,A2,1X,I3,16H GAVE ERROR NO. ,I1)
12070 FORMAT(1H ,3HCO ,5A5,1H ,I2,1H ,3A5)
C
99999 FORMAT (1H ,24HCONSOLE FAILED TO SELECT)
        END
C       PROCESS A HARDWARE ERROR FOR HYSAT
        SUBROUTINE DECIDE
        INTEGER ANSWER
        LOGICAL ERRSW,RSAC
        COMMON/A/CHAR(72)
        COMMON/D/ANSWER
        COMMON/F/INPUT
        DATA BLANK,CC,RR/1H ,1HC,1HR/
        IF (RSAC(1)) GO TO 5
        IF (RSAC(0)) GO TO 1
        WRITE(4,30)
        GO TO 2
1       WRITE(4,31)
2       IF (RSAC(1)) GO TO 5
        READ(4,40) CHAR
        IF (RSAC(1)) GO TO 5
        IF (CHAR(2).NE.BLANK ) GO TO 10
        IF (CHAR(1).EQ.CC) RETURN
        IF (CHAR(1).NE.RR) GO TO 10
C       RETRY
5       ANSWER=-1
        RETURN
C       NEW STATEMENT(S)
10      ANSWER=1
        INPUT=4
        RETURN
30    FORMAT(49H TYPE R (RETRY),C (CONTINUE),OR NEW STATEMENT(S)-/2H $)
31    FORMAT (10H RECOVERY-/2H $)
40    FORMAT(72A1)
        END
        SUBROUTINE DECODE
        INTEGER COL,TYPE,VALUE
        REAL II,KK,LL,MM,NN,MINUS,N
        DIMENSION N(10)
        COMMON/A/CHAR(72)
        COMMON/B/VALUE
        COMMON/C/COL,TYPE
      DATA N(1),N(2),N(3),N(4),N(5),N(6),N(7),N(8),N(9),N(10)/1H0,1H1,1H
     12,1H3,1H4,1H5,1H6,1H7,1H8,1H9/
      DATA BLANK,COMMA,MINUS,PLUS,SLASH/1H ,1H,,1H-,1H+,1H//
        DATA AA,BB,CC,DD,EE/1HA,1HB,1HC,1HD,1HE/
        DATA FF,GG,HH,II,KK/1HF,1HG,1HH,1HI,1HK/
        DATA LL,MM,NN,OO,PP/1HL,1HM,1HN,1HO,1HP/
        DATA QQ,RR,SS,TT,UU,YY/1HQ,1HR,1HS,1HT,1HU,1HY/
C       TYPE=-1: UNRECOGNIZABLE FIELD
C       TYPE=0:  SPECIAL FIELD
C                VALUE=-1 FOR -,0 FOR BLANK,+1 FOR +
C       TYPE=1:  NUMERIC FIELD
C                VALUE=INTEGER EQUIVALENT
C       TYPE=2: ERROR CONTROL OPTION
C               VALUE=-1 (E),0 (H),1 (S)
C       TYPE=3:  COMMAND CODE
C              VALUE=-6 (YES),-5(N0),-4 (ON),-3 (OFF),-2 (END),-1 (CO)
C                   =0 (A),1 (D),2 (F),3 (T),4 (P),5 (PB),6 (D/),7 (Q)
C                     =10 (AD),11 (DA)
C                     =15 (SL),16 (GP), 17 (CS)
C                     =20 (FR), 21 (CL),
C                     =25 (ER), 26 (SK)
C       TYPE=4:  ANALOG MODE
C               VALUE=1 (PC),2 (PP),3 (ST),4 (OP),5 (HD),6 (IC),7 (SP)
C       TYPE=5:  TIME CONSTANT
C                VALUE=0 (NS),1 (FS),2 (NM),3 (FM)
C       TYPE=6:  LOGIC MODE
C               VALUE=1 (RUN),2 (STOP),3 (CLEAR)
10      IF (COL.GT.36) GO TO 60
        IF (CHAR(COL).NE.BLANK) GO TO 20
        COL=COL+1
        GO TO 10
C       START OF FIELD
20      CH=CHAR(COL)
        IF (CH.EQ.COMMA) GO TO 60
        IF (CH.EQ.PLUS) GO TO 70
        IF (CH.EQ.MINUS) GO TO 80
        IF (CH.GT.N(10)) GO TO 100
        IF (CH.LT.N(1)) GO TO 110
C       NUMERIC FIELD
        TYPE=1
        VALUE=0
30      DO 40 I=1,10
        IF (CH.NE.N(I)) GO TO 40
        VALUE=10*VALUE+I-1
        GO TO 50
40      CONTINUE
        GO TO 600
50      COL=COL+1
        IF (COL.GT.36) RETURN
        CH=CHAR(COL)
        GO TO 30
C       BLANK FIELD
60      TYPE=0
        VALUE=0
      COL=COL+1
        RETURN
C       PLUS SIGN
70      VALUE=1
        GO TO 90
C       MINUS SIGN
80      VALUE=-1
C       SIGN FIELD
90      TYPE=0
        COL=COL+1
        CH=CHAR(COL)
        GO TO 600
C       ALPHABETIC FIELD
100     COL=COL+1
        CT=CHAR(COL)
        IF (CH.EQ.AA) GO TO 120
        IF (CH.EQ.CC) GO TO 140
        IF (CH.EQ.DD) GO TO 180
        IF (CH.EQ.EE) GO TO 210
        IF (CH.EQ.FF) GO TO 240
        IF (CH.EQ.GG) GO TO 280
        IF (CH.EQ.HH) GO TO 290
        IF (CH.EQ.II) GO TO 310
        IF (CH.EQ.NN) GO TO 320
        IF (CH.EQ.OO) GO TO 360
        IF (CH.EQ.PP) GO TO 390
        IF (CH.EQ.QQ) GO TO 430
        IF (CH.EQ.RR) GO TO 440
        IF (CH.EQ.SS) GO TO 450
        IF (CH.EQ.TT) GO TO 550
        IF (CH.EQ.YY) GO TO 560
C       FIRST ALPHABETIC IS ILLEGAL
110     TYPE=-1
        RETURN
120     IF (COL.LT.37.AND.CT.EQ.DD) GO TO 130
C       AMPLIFIER
        VALUE=0
        GO TO 570
C       A-TO-D
130     VALUE=10
        GO TO 490
140     IF (CT.EQ.LL) GO TO 150
        IF (CT.EQ.OO) GO TO 170
        IF (CT.NE.SS) GO TO 110
C       COMPARATOR STATUS
        VALUE=17
        GO TO 490
150     IF (COL.LT.37.AND.CHAR(COL+1).EQ.EE) GO TO 160
C       CONTROL LINE
        VALUE=21
        GO TO 490
160     COL=COL+4
        IF (CHAR(COL-2).NE.AA) GO TO 110
        IF (CHAR(COL-1).NE.RR) GO TO 110
C       CLEAR
        VALUE=3
        GO TO 540
C       COMMENT
170     VALUE=-1
        GO TO 490
180     IF (COL.EQ.37) GO TO 185
        IF (CT.EQ.AA) GO TO 190
        IF (CT.EQ.SLASH) GO TO 200
C       DERIVATIVE
185     VALUE=1
        GO TO 570
C       D-TO-A
190     VALUE=11
        GO TO 490
C       DERIVATIVE/10
200     VALUE=6
        GO TO 490
210     IF (COL.EQ.37) GO TO 215
        IF (CT.EQ.NN) GO TO 220
        IF (CT.EQ.RR) GO TO 230
C       E OPTION
215     VALUE=-1
        GO TO 460
220     COL=COL+2
        IF (CHAR(COL-1).NE.DD) GO TO 110
C       END
        VALUE=-2
        GO TO 570
C       ERROR TOLERANCE
230     VALUE=25
        GO TO 490
240     IF (COL.EQ.37) GO TO 245
        IF (CT.EQ.MM) GO TO 250
        IF (CT.EQ.RR) GO TO 260
        IF (CT.EQ.SS) GO TO 270
C       FUNCTION GENERATOR
245     VALUE=2
        GO TO 570
C       FAST-MILLISECONDS
250     VALUE=3
        GO TO 350
C       FUNCTION RELAY
260     VALUE=20
        GO TO 490
C       FAST-SECONDS
270     VALUE=1
        GO TO 350
280     IF (CT.NE.PP) GO TO 110
C       GENERAL PURPOSE INTERRUPT
        VALUE=16
        GO TO 490
290     IF (CT.EQ.DD) GO TO 300
C       H OPTION
        VALUE=0
        GO TO 460
C       HOLD
300     VALUE=5
        GO TO 520
310     IF (CT.NE.CC) GO TO 110
C       INITIAL CONDITION
        VALUE=6
        GO TO 520
320     IF (CT.EQ.MM) GO TO 340
        IF (CT.EQ.OO) GO TO 330
        IF (CT.NE.SS) GO TO 110
C       NORMAL-SECONDS
        VALUE=0
        GO TO 350
C       NO
330     VALUE=-5
        GO TO 490
C       NORMAL-MILLISECONDS
340     VALUE=2
C       TIME CONSTANT
350     TYPE=5
        GO TO 580
360     IF (CT.EQ.FF) GO TO 370
        IF (CT.EQ.NN) GO TO 380
        IF (CT.NE.PP) GO TO 110
C       OPERATE
        VALUE=4
        GO TO 520
370     COL=COL+2
        IF (CHAR(COL-1).NE.FF) GO TO 110
C       OFF
        VALUE=-3
        GO TO 570
C       ON
380     VALUE=-4
        GO TO 490
390     IF (COL.EQ.37) GO TO 395
        IF (CT.EQ.BB) GO TO 400
        IF (CT.EQ.CC) GO TO 410
        IF (CT.EQ.PP) GO TO 420
C       POTENTIOMETER
395     VALUE=4
        GO TO 570
C       PATCH-BOARD (ADDRESS)
400     VALUE=5
        GO TO 490
C       POT COEFFICIENT
410     VALUE=1
        GO TO 520
C       PATCH PANEL (MODE)
420     VALUE=2
        GO TO 520
C       QUOTENTIOMETER
430     VALUE=7
        GO TO 570
440     IF (CT.NE.UU) GO TO 110
        COL=COL+2
        IF (CHAR(COL-1).NE.NN) GO TO 110
C       RUN
        VALUE=1
        GO TO 540
450     IF (COL.EQ.37) GO TO 455
        IF (CT.EQ.KK) GO TO 470
        IF (CT.EQ.LL) GO TO 480
        IF (CT.EQ.PP) GO TO 500
        IF (CT.EQ.TT) GO TO 510
C       S OPTION
455     VALUE=1
C       ERROR CONTROL OPTION
460     TYPE=2
        GO TO 590
C       SKIP
470     VALUE=26
        GO TO 490
C       SENSE LINE
480     VALUE=15
C       COMMAND CODE
490     TYPE=3
        GO TO 580
C       SET POT
500     VALUE=7
        GO TO 520
510     IF (COL.LT.36.AND.CHAR(COL+1).EQ.OO) GO TO 530
C       STATIC TEST
        VALUE=3
C       ANALOG MODE
520     TYPE=4
        GO TO 580
530     COL=COL+3
        IF (CHAR(COL-1).NE.PP) GO TO 110
C       STOP
        VALUE=2
C       LOGIC MODE
540     TYPE=6
        GO TO 590
C       TRUNK
550     VALUE=3
        GO TO 570
560   COL=COL+2
        IF (CT.NE.EE) GO TO 110
        IF (CHAR(COL-1).NE.SS) GO TO 110
C       YES
        VALUE=-6
C       COMMAND CODE
570     TYPE=3
        GO TO 590
C       COL=LAST COLUMN PROCESSED
580     COL=COL+1
C       COL=LAST COLUMN PROCESSED+1
590     IF (COL.GT.37) GO TO 110
        CH=CHAR(COL)
        IF (CH.GE.AA) GO TO 110
C       CHECK FOR COMMA
600     IF (CH.EQ.COMMA) COL=COL+1
        RETURN
        END
C       HYSAT -GPI HANDLER
        SUBROUTINE HANDLE
        LOGICAL Z
        COMMON/E/Z
        Z=.TRUE.
        RETURN
        END
