C***********************************************************************
C
C  THIS IS THE MAIN INPUT SUBROUTINE.
C
C***********************************************************************
      SUBROUTINE INSAEN(INOD)
      LOGICAL LP,BINT
      INTEGER END,LAST,NODE(60,12),IVECT(200)
      REAL R(4,9),V(4,9),C(4,9),L(4,9),A(4,9),COM(4,12)
      REAL PAR(60,6),OP(10),DRA(21)
      REAL DRAW(4,4)
      COMMON PAR,OP,W(60),D(60),M(20,60),NODE,DRA,ICOM,INO,IBUS
      COMMON /SPEN/NUM,IIIX,IIIY,BINT,LP,ITA
      COMMON /LIMITS/XMIN,XMAX,YMIN,YMAX
      COMMON /PLA/COM,END,S
      DATA F1,F2/5H(G12.,2H4)/
C                                      DATA FOR GRID DRAWING
      DATA DRAW(1,1),DRAW(2,1),DRAW(3,1),DRAW(4,1)/250.,250.,750.,250./
      DATA DRAW(1,2),DRAW(2,2),DRAW(3,2),DRAW(4,2)/250.,500.,750.,500./
      DATA DRAW(1,3),DRAW(2,3),DRAW(3,3),DRAW(4,3)/250.,750.,750.,750./
      DATA Z1,Z2/5HINCAM,4H1BIN/
      DATA F3/4H(I3)/
      DATA NV,NG,NE,NL,NC,NR,NI,NJ/5,3*7,3*6,9/
C                                   DATA STATEMENTS FOR THE COMPONENT
C                                   DRAWINGS.
      DATA R(1,1),R(2,1),R(3,1),R(4,1)/1.,0.,-1.,0./
      DATA R(1,2),R(2,2),R(3,2),R(4,2)/-1.,0.,-.75,.5/
      DATA R(1,3),R(2,3),R(3,3),R(4,3)/-.75,.5,-.25,-.5/
      DATA R(1,4),R(2,4),R(3,4),R(4,4)/-.25,-.5,.25,.5/
      DATA R(1,5),R(2,5),R(3,5),R(4,5)/.25,.5,.75,-.5/
      DATA R(1,6),R(2,6),R(3,6),R(4,6)/.75,-.5,1.,0./
      DATA R(1,7),R(2,7),R(3,7),R(4,7)/-1.,0.,1.,0./
      DATA V(1,1),V(2,1),V(3,1),V(4,1)/1.,0.,-1.,0./
      DATA V(1,2),V(2,2),V(3,2),V(4,2)/-1.,0.,0.,1./
      DATA V(1,3),V(2,3),V(3,3),V(4,3)/0.,1.,1.,0./
      DATA V(1,4),V(2,4),V(3,4),V(4,4)/1.,0.,0.,-1./
      DATA V(1,5),V(2,5),V(3,5),V(4,5)/0.,-1.,-1.,0./
      DATA V(1,6),V(2,6),V(3,6),V(4,6)/-.4,0.,-.8,0./
      DATA V(1,7),V(2,7),V(3,7),V(4,7)/-.6,.2,-.6,-.2/
      DATA C(1,1),C(2,1),C(3,1),C(4,1)/.25,0.,-.25,0./
      DATA C(1,2),C(2,2),C(3,2),C(4,2)/-.25,1.,-.25,-1./
      DATA C(1,3),C(2,3),C(3,3),C(4,3)/.4,-1.,.25,-.5/
      DATA C(1,4),C(2,4),C(3,4),C(4,4)/.25,-.5,.2,0./
      DATA C(1,5),C(2,5),C(3,5),C(4,5)/.2,0.,.25,.5/
      DATA C(1,6),C(2,6),C(3,6),C(4,6)/.25,.5,.4,1./
      DATA L(1,1),L(2,1),L(3,1),L(4,1)/.75,0.,-.75,0./
      DATA L(1,2),L(2,2),L(3,2),L(4,2)/-.75,0.,-.25,.75/
      DATA L(1,3),L(2,3),L(3,3),L(4,3)/-.25,.75,.25,0./
      DATA L(1,4),L(2,4),L(3,4),L(4,4)/.25,0.,0.,-.375/
      DATA L(1,5),L(2,5),L(3,5),L(4,5)/0.,-.375,-.25,0./
      DATA L(1,6),L(2,6),L(3,6),L(4,6)/-.25,0.,.25,.75/
      DATA L(1,7),L(2,7),L(3,7),L(4,7)/.25,.75,.75,0./
      DATA A(1,1),A(2,1),A(3,1),A(4,1)/1.,0.,-1.,0./
      DATA A(1,2),A(2,2),A(3,2),A(4,2)/-1.,-.75,-1.,.75/
      DATA A(1,3),A(2,3),A(3,3),A(4,3)/-1.,.75,.25,.75/
      DATA A(1,4),A(2,4),A(3,4),A(4,4)/.25,.75,1.,0./
      DATA A(1,5),A(2,5),A(3,5),A(4,5)/1.,0.,.25,-.75/
      DATA A(1,6),A(2,6),A(3,6),A(4,6)/.25,-.75,-1.,-.75/
      DATA A(1,7),A(2,7),A(3,7),A(4,7)/-.5,0.,.5,0./
      DATA A(1,8),A(2,8),A(3,8),A(4,8)/.5,0.,0.,.25/
      DATA A(1,9),A(2,9),A(3,9),A(4,9)/.5,0.,0.,-.25/
C                                   INITIALISATION SECTION.
      XMIN=0.
      WRITE(4,4444)ICOM,IBUS
 4444 FORMAT(2I6)
      XMAX=1023.
      YMIN=0.
      YMAX=1023.
      JTAG=0
      CALL MENCRT(Z1,Z2,-1)
      S=20.
C                                   IF THE NUMBER OF COMPONENTS IS ZERO
C                                   THEN THIS IS THE START.  GO DIRECTLY
C                                   TO THE INDEX.
      IF(ICOM.EQ.0)GO TO 3
C                                   OTHERWISE THE NODE MATRIX MUST BE
C                                   RESTORED AND THE NUMBER OF COMPON-
C                                   ENTS INCREASED TO INCLUDE THE BUSSES
      ICOM=ICOM+IBUS
      DO 10 I=1,ICOM
      DO 10 J=2,3
   10 NODE(I,J)=NODE(I,J+9)
C                                   LIGHT UP DISPLAY
      ASSIGN 1 TO N
      GO TO 1000
    3 OP(1)=0.0
      OP(2)=10.0
      OP(3)=0.1
      OP(4)=1.0
      DO 4 I=1,4
    4 PAR(60,I)=OP(I)
C                                   THE NEXT SECTION IS FOR THE DISPLAY
C                                   AND SELECTION OF THE INDEX ITEMS.
    1 CALL DISPM1(1,0)
C                                   IF NO. OF COMPONENTS GT ZERO
C                                   DELETE "READ" FROM THE INDEX.
      IF(ICOM.GT.0)CALL CRT(5,1005)
C                                   WAIT FOR SELECTION.
      IT=ITAGS(1001,1008,1008,2)-1000
C                                   ACTION IS DIFFERENT DEPENDING ON
C                                   THE VALUE OF ICOM
      IF(ICOM.EQ.0)GO TO 2
C                                   DRAW,DELETE,VALUE,OUTPUT,
C                                   READ,ANALYZE,EXIT,VIEW.
      GO TO(100,200,300,400,1,600,700,800),IT
    2 GO TO(100,100,100,100,500,700,700,700),IT
C                                   THIS IS THE SECTION TO ENTER A
C                                   NEW COMPONENT.
  100 CALL DISPM1(2,1499,1497,0)
C                                   WAIT FOR TAG TO BE ENTERED.
      IT=ITAGS(1011,1031,1497,2)
C                                   RETURN TO INDEX IF REQUIRED.
      IF(IT.EQ.1497)GO TO 1
C                                   IF AMMETER WANTED, GO TO 110
      IF(IT.EQ.1020)GO TO 110
C                                   SET UP DO-LOOP TO ENTER 3 NODES.
      IF=1
C                                   GIVE ENTER NODE DISPLAY.
      CALL DISPM1(0,1001,1498,1474,IT)
C                                   SET END = NEW COMP NO..
      END=ICOM+1
C                                   IF ENTERING BUS, ONLY ALLOW 2 NODES.
      IF(IT.EQ.1018)IF=2
C                                   ENTER NODES.
      DO 120 I=1,3,IF
C                                   DISPLAY NO. OF NODE BEING ENTERED
      CALL CRT(2,1496,160,1010,6,1,F3,I)
C                                   WAIT FOR NODE
      CALL STAR(IX,IY,KT)
C                                   DELETE NODE NO.
      CALL CRT(3,1496)
C                                   PUT VALUES IN NODE MATRIX.
      NODE(END,2*I+2)=IX
      NODE(END,2*I+3)=IY
C                                   TEST FOR "RETURN"
      IF(KT.EQ.1474)GO TO 100
C                                   TEST FOR COMPONENT POSITION
      IF(I.EQ.2)GO TO 120
C                                   TEST FOR A NEW NODE
      IF(KT.EQ.-1.OR.KT.GT.500)GO TO 121
C                                   WE HAVE OLD NODE.. GET NODE NUMBER
      CALL TAGTYP(KT,ITYP,NO)
      J=NODE(NO,2)
      IF(KT.GT.250)J=NODE(NO,3)
C                                   FILL IN NODE MATRIX
      NODE(END,3)=J
      IF(I.EQ.1)NODE(END,2)=J
      GO TO 120
C                                   WE HAVE A NEW NODE
  121 INOD=INOD+1
      J=INOD
      NODE(END,3)=INOD
      IF(I.EQ.1)NODE(END,2)=INOD
C                                   END OF NODE-ENTRY DO-LOOP.
  120 CONTINUE
C                                   THE NODES ARE NOW ENTERED,
C                                   SO INCREASE ICOM,JTAG
      ICOM=END
  122 JTAG=JTAG+1
C                                   COMPLETE FILL-IN OF NODE MATRIX.
      NODE(ICOM,10)=JTAG
      NODE(ICOM,1)=IT-1009
C                                   SET-UP THE DISPLAYED PAR VALUE.
      PAR(ICOM,1)=0.
C                                   FOR VOLTMETER OR AMMETER, ADJUST
C                                   THE SCALE VALUE.
      IF(IT.EQ.1020.OR.IT.EQ.1030)S=S/2.
C                                   SET UP RETURN ADDRESS.
      ASSIGN 130 TO N
C                                   DISPLAY COMPONENT
      GO TO 900
C                                   RESET SCALE.
  130 IF(IT.EQ.1020.OR.IT.EQ.1030)S=2.*S
C                                   IF METER OR BUS, HAVE FINISHED.
      IF(IT.EQ.1020.OR.IT.EQ.1030.OR.IT.EQ.1018)GO TO 100
C                                   IF NOT HAVE TO DISPLAY VALUE.
      IT=JTAG+500
      IX=NODE(ICOM,6)
      IY=NODE(ICOM,7)+5
      CALL CRT(2,IT,IX,IY,7,1,F1,0.)
      GO TO 100
C                                   IF AN AMMETER WAS CALLED FOR THEN
C                                   THE ENTRY PROCEDURE IS DIFFERENT.
  110 CALL DISPM1(0,1495,1474,IT,0)
C                                   WAIT FOR TAG
      I=ITAGS(1,500,1474,3)
C                                   RETURN?
      IF(I.EQ.1474)GO TO 100
C                                   FIND NUMBER OF COMPONENT.
      CALL TAGTYP(I,ITYP,NO)
C                                   DELETE THIS COMPONENT FROM SCREEN.
C                                   DO NOT DELETE ITS VALUE.
  112 IF(I.LT.250)GO TO 113
      I=I-250
      GO TO 112
  113 CALL CRT(3,I)
      J=I+250
      CALL CRT(3,J)
C                                   FIND RELEVENT NODES
      X1=NODE(NO,4)
      Y1=NODE(NO,5)
      X3=NODE(NO,6)
      Y3=NODE(NO,7)
      X2=NODE(NO,8)
      Y2=NODE(NO,9)
C                                   REPOSITION OLD COMPONENT.
      NODE(NO,4)=X3
      NODE(NO,5)=Y3
      SQ=SQRT((X3-X2)**2+(Y3-Y2)**2)
      NODE(NO,6)=X3+S*(X2-X3)/SQ
      NODE(NO,7)=Y3+S*(Y2-Y3)/SQ
C                                   RENAME NODES OF OLD COMPONENT, AND
C                                   NAME NODES OF AMMETER.
      INOD=INOD+1
      ICOM=ICOM+1
      NODE(ICOM,2)=NODE(NO,2)
      NODE(ICOM,3)=INOD
      NODE(NO,2)=INOD
C                                   POSITION AMMETER
      NODE(ICOM,8)=X3
      NODE(ICOM,9)=Y3
      NODE(ICOM,4)=X1
      NODE(ICOM,5)=Y1
      SQ=SQRT((X3-X1)**2+(Y3-Y1)**2)
      NODE(ICOM,6)=X3-S*(X3-X1)/SQ
      NODE(ICOM,7)=Y3-S*(Y3-Y1)/SQ
C                                   REDISPLAY OLD COMPONENT.
      J=JTAG
      JTAG=I
      END=NO
      ASSIGN 111 TO N
      GO TO 900
C                                   DISPLAY AMMETER
  111 JTAG=J
      END=ICOM
      GO TO 122
C              THIS SECTION LIGHTS UP A DISPLAY
 1000 DO 1001 I=1,ICOM
      IT=NODE(I,10)
      J=NODE(I,1)
      IF(IT.GT.JTAG)JTAG=IT
      CALL CRT(4,IT)
      IF(J.EQ.9)GO TO 1001
      IT=IT+250
      CALL CRT(4,IT)
      IF(J.EQ.11.OR.J.EQ.21)GO TO 1001
      IT=IT+250
      CALL CRT(4,IT)
 1001 CONTINUE
C              AND RETURNS CONTROL TO THE INDEX
C              OR ELSEWHERE, AS REQUIRED.
      GO TO N,(1,340)
C
C              EXIT SECTION: PROVIDES A DOUBLE
C              CHECK AGAINST ACCIDENTAL EXIT.
  700 CALL DISPM1(0,1007,1497,0)
      IT=ITAGS(1007,1007,1497,2)
      IF(IT.NE.1007)GO TO 1
      STOP
C
C              THIS SECTION IS TO DISPLAY A NEW
C              COMPONENT.
C              FIRST FIND TYPE OF COMPONENT.
  900 ITYP=NODE(END,1)
      IF(ITYP.GT.20)ITYP=8
      IF(ITYP.GT.10)ITYP=1
C              NOW CALCULATE COMPONENT POSITION
C              USING SUBROUTINE PLACE
      GO TO (901,902,903,904,905,906,907,908,909),ITYP
  901 CALL PLACE(V,NE)
      GO TO 920
  902 CALL PLACE(C,NC)
      GO TO 920
  903 CALL PLACE(V,NV)
      GO TO 920
  904 CALL PLACE(R,NR)
      GO TO 920
  905 CALL PLACE(R,NG)
      GO TO 920
  906 CALL PLACE(A,NI)
      GO TO 920
  907 CALL PLACE(L,NL)
      GO TO 920
  908 CALL PLACE(A,NJ)
      GO TO 920
  909 CALL PLACE(A,1)
C              FINALLY, DISPLAY COMPONENT.
C              FIRST THE "FROM" PART
  920 CALL VECTOR(1,COM,1,1,IVECT,1,LAST,7,1,.TRUE.)
      CALL CRT(6,JTAG,IVECT,1,LAST)
C              IF COMPONENT WAS A BUS THEN
C              DISPLAY IS NOW COMPLETE.
      IF(END.EQ.1)GO TO 921
C              OTHERWISE DISPLAY "TO" PART.
      CALL VECTOR(1,COM,2,END,IVECT,1,LAST,7,1,.TRUE.)
      I=JTAG+250
      CALL CRT(6,I,IVECT,1,LAST)
  921 GO TO N,(111,130,223,532)
C                                   THIS SECTION IS TO DELETE A
C                                   COMPONENT.
 200  CALL DISPM1(0,1002,1495,1494,1497)
C                                   WAIT FOR TAG
      IT=ITAGS(1,750,1497,3)
C                                   IF INDEX, RETURN.
      IF(IT.EQ.1497)GO TO 1
C                                   OTHERWISE, FIND COMPONENT NUMBER
C                                   AND TYPE.
      CALL TAGTYP(IT,ITYP,NO)
C                                   DELETE "FROM" PART.
  201 IF(IT.LT.250)GO TO 202
      IT=IT-250
      GO TO 201
  202 CALL CRT(3,IT)
C                                   IF BUS, HAVE FINISHED.
      IF(ITYP.EQ.9)GO TO 211
C                                   DELETE SECOND PART.
      IT=IT+250
      CALL CRT(3,IT)
C                                   IF METER, HAVE FINISHED.
      IF(ITYP.EQ.11.OR.ITYP.EQ.21)GO TO 210
C                                   DELETE VALUE.
      IT=IT+250
      CALL CRT(3,IT)
C                                   IF NOT AMMETER, SKIP.
  210 IF(ITYP.NE.11)GO TO 211
C                                   IF AMMETER, FIRST REDISPLAY OTHER
C                                   COMPONENT.
C                                   FIND OTHER COMPONENT.
      J=NODE(NO,3)
      DO 221 I=1,ICOM
      IF(J.EQ.NODE(I,2))GO TO 222
  221 CONTINUE
C                                   IF OTHER COMPONENT IS ALREADY
C                                   DELETED, SKIP.
      GO TO 211
C                                   NOW REPOSITION IT AND RENAME THE
C                                   "FROM" NODES.
  222 NODE(I,2)=NODE(NO,2)
      NODE(I,4)=NODE(NO,4)
      NODE(I,5)=NODE(NO,5)
      NODE(I,6)=NODE(NO,8)
      NODE(I,7)=NODE(NO,9)
C                                   REDISPLAY
      END=I
      J=JTAG
      JTAG=NODE(I,10)
      CALL CRT(3,JTAG)
      I=JTAG+250
      CALL CRT(3,I)
      ASSIGN 223 TO N
      GO TO 900
  223 JTAG=J
C                                   REARRANGE NODE AND PAR
  211 DO 230 J=1,10
  230 NODE(NO,J)=NODE(ICOM,J)
      DO 231 J=1,6
      PAR(NO,J)=PAR(ICOM,J)
  231 PAR(ICOM,J)=0.
      NODE(ICOM,1)=0
      ICOM=ICOM-1
      IF(ICOM.EQ.0)GO TO 1
      GO TO 200
C
C                                   SCALING SECTION.
  800 GO TO 1
C                                   NOT YET ACTIVATED.
C                                   THIS SECTION IS TO ENTER PARAMETERS
  300 CALL DISPM1(0,1003,1495,1497,0)
C                                   WAIT FOR COMPONENT
  301 IT=ITAGS(1,750,1497,3)
C                                   IF INDEX, RETURN
      IF(IT.EQ.1497)GO TO 1
C                                   FIND TYPE AND NUMBER
      CALL TAGTYP(IT,ITYP,NO)
C                                   IF METER, DON'T ACCEPT
      IF(ITYP.NE.11.AND.ITYP.NE.21)GO TO 302
      CALL CRT(4,1473)
      GO TO 301
C                                   IF NOT DEPENDENT DRIVER, SKIP
  302 IF(ITYP.NE.3.AND.ITYP.NE.6)GO TO 310
C                                   DEPENDENT DRIVER
  303 CALL DISPM1(0,1003,1495,1493,1474)
C                                   WAIT FOR COMPONENT.
      IT=ITAGS(1,750,1474,3)
C                                   IF "RETURN", RETURN
      IF(IT.EQ.1474)GO TO 300
C                                   FIND TYPE AND NUMBER.
      CALL TAGTYP(IT,ITY,N)
C                                   IF METER, TRY AGAIN
      IF(ITY.EQ.11.OR.ITY.EQ.21)GO TO 303
C                                   OTHERWISE RECORD NUMBER
      PAR(NO,3)=N
C                                   IF COMPONENT IS A DRIVER, ALLOW
C                                   ENTRY OF TYPE
  310 IF(ITYP.LT.8)GO TO 320
      CALL DISPM1(3,1474,0)
C                                   PICK UP TAG
      ITYP=ITAGS(1041,1044,1474,2)-1033
C                                   CHECK FOR RETURN
      IF(IT.EQ.460)GO TO 300
      I=ITYP+4
C                                   IF CURRENT DRIVER, ADD 10 TO I
      IF(ITYP.GT.20)I=I+10
C                                   STORE TYPE
      NODE(NO,1)=I
C                                   MAIN ENTER VALUES SECTION
  320 I=ITYP-1
      J=1
      GO TO (321,327,322,322,327,321,323,324,325,326),I
C                                   VALUE + I.C. ENTRY
  321 CALL DISPM1(0,1003,1487,1488,1489)
      CALL FILPAR(NO,2)
      GO TO 340
C                                   VALUE ENTRY
  322 CALL DISPM1(0,1003,1487,1489,0)
      CALL FILPAR(NO,1)
      GO TO 340
C                                   STEP ENTRY
  323 CALL DISPM1(0,1041,1486,1489,0)
      CALL FILPAR(NO,5)
      GO TO 340
C                                   RAMP ENTRY
  324 CALL DISPM1(0,1042,1485,1489,0)
      CALL FILPAR(NO,3)
      GO TO 340
C                                   SINUSOID ENTRY
  325 CALL DISPM1(0,1043,1484,1489,0)
      CALL FILPAR(NO,6)
      GO TO 340
C                                   DEPENDENT DRIVERS ENTRY
  327 CALL DISPM1(0,1003,1487,1489,1490)
      I=PAR(NO,2)*4.+1206.
      CALL CRT(4,I)
      CALL FILPAR(NO,1)
      CALL CRT(5,I)
      GO TO 340
C                                   ENTRY FOR DRAW OPTION
  326 CALL DISPM1(0,1044,1483,1482,1489)
      CALL FILPAR(NO,5)
C                                   PARAMETERS FOR DRAW ARE NOW
C                                   ENTERED.
C                                   CLEAR THE SCREEN
  330 CALL CLEAR(.TRUE.)
      CALL DISPM1(0,1479,1489,0,0)
      VAL=PAR(NO,1)
      CALL CRT(2,1400,150,250,7,1,F1,VAL)
      VAL=PAR(NO,2)
      CALL CRT(2,1401,150,750,7,1,F1,VAL)
      VAL=PAR(NO,3)
      CALL CRT(2,1402,230,230,7,1,F1,VAL)
      VAL=PAR(NO,4)
      CALL CRT(2,1403,730,230,7,1,F1,VAL)
      CALL VECTOR(1,DRAW,1,3,IVECT,1,LAST,7,1,.FALSE.)
      CALL CRT(6,1404,IVECT,1,LAST)
      VAL=225.
      DRAW(2,4)=250.
      DRAW(4,4)=750.
      DO 331 I=1,21
      J=1404+I
      VAL=VAL+25.
      DRAW(1,4)=VAL
      DRAW(3,4)=VAL
      CALL VECTOR(1,DRAW,4,4,IVECT,1,LAST,6,1,.TRUE.)
  331 CALL CRT(6,J,IVECT,1,LAST)
C                                   GRID HAS NOW BEEN DRAWN
C                                   NEXT SECTION IS FOR ENTRY OF GRAPH
C                                   FIRST DRAW DUMMY GRAPH
      VAL=225.
      DRAW(4,4)=255.
      DO 332 I=1,21
      DRA(I)=0.
      J=1300+I
      VAL=VAL+25.
      DRAW(1,4)=VAL
      DRAW(3,4)=VAL
      CALL VECTOR(1,DRAW,4,4,IVECT,1,LAST,7,1,.FALSE.)
  332 CALL CRT(6,J,IVECT,1,LAST)
C                                   NOW CHANGE IT UNTIL SATISFIED
  335 LP=.FALSE.
  333 IF(.NOT.LP)GO TO 333
      IT=ITA
      IF(IT.GT.1404.AND.IT.LT.1427)GO TO 334
      CALL CRT(5,1479)
      IT=ITAGS(1405,1426,1489,5)
      IF(IT.EQ.1489)GO TO 336
      CALL CRT(4,1479)
      GO TO 335
  334 IX=IIIX
      IY=IIIY
      IT=IT-104
      CALL CRT(3,IT)
      DRAW(1,4)=IX
      DRAW(3,4)=IX
      DRAW(4,4)=IY
      I=(IX-225)/25
      DRA(I)=IY-250
      CALL VECTOR(1,DRAW,4,4,IVECT,1,LAST,7,1,.FALSE.)
      CALL CRT(6,IT,IVECT,1,LAST)
      GO TO 335
  336 K=1404
      J=1300
      DO 337 I=1,21
      J=J+1
      CALL CRT(3,J)
      K=K+1
  337 CALL CRT(3,K)
      DO 338 I=1400,1404
  338 CALL CRT(3,I)
C                                   LIGHT UP DISPLAY AGAIN
      ASSIGN 340 TO N
      GO TO 1000
C                                   DISPLAY NEW VALUE
  340 VAL=PAR(NO,1)
      IX=NODE(NO,6)
      IY=NODE(NO,7)+5
      IT=NODE(NO,10)+500
      CALL CRT(2,IT,IX,IY,7,1,F1,VAL)
C                                   AND RETURN
      GO TO 300
C                                   THIS SECTION IS FOR OUTPUT
  400 CALL DISPM1(5,1497,0)
C                                   WAIT FOR TAG
      IT=ITAGS(1050,1052,1497,2)-1049
C                                   CHECK FOR INDEX
      IF(IT.EQ.448)GO TO 1
C                                   SPLIT UP THE VARIOUS OPTIONS
      CALL DISPM1(0,0)
      GO TO (410,420,430),IT
C                                   PUNCH TAPE OPTION
  410 WRITE(7,412)INOD
      DO 411 I=1,ICOM
      WRITE(7,412)NODE(I,1)
      WRITE(7,412)(NODE(I,J),J=2,10)
  412 FORMAT(1H ,9I6)
      WRITE(7,413)(PAR(I,J),J=1,6)
  413 FORMAT(1H ,6E14.6)
  411 CONTINUE
C                                   END MARKER
      I=-1
      WRITE(7,412)I
      GO TO 400
C                                   PLOT OPTION
  420 CALL COPY
      GO TO 400
C                                   DEC-TAPE OPTION
  430 REWIND 1
      WRITE(1)ICOM,INOD
      WRITE(1)((NODE(I,J),J=1,10),I=1,ICOM)
      WRITE(1)((PAR(I,J),J=1,6),I=1,ICOM)
      ENDFILE 1
      GO TO 400
C                                   THIS SECTION IS FOR INPUT
  500 CALL DISPM1(6,1005,1497,0)
      IT=ITAGS(1055,1056,1497,2)-1054
C                                   CHECK FOR RETURN TO INDEX
      IF(IT.EQ.443)GO TO 1
C                                   OTHERWISE GO TO APPROPRIATE SECTION
      CALL DISPM1(0,0)
      GO TO (510,520),IT
C                                   THIS IS PAPER TAPE READ
  510 READ(5,512)INOD
      DO 511 I=1,100
      READ(5,512)J
C                                   WHEN FINISHED, DISPLAY CIRCUIT.
      IF(J.EQ.-1)GO TO 530
C                                   OTHERWISE CONTINUE READ
      ICOM=I
      NODE(I,1)=J
      READ(5,512)(NODE(I,J),J=2,10)
  512 FORMAT(9I6)
      READ(5,513)(PAR(I,J),J=1,6)
  513 FORMAT(6E14.6)
  511 CONTINUE
C                                   THIS IS DEC-TAPE READ
  520 REWIND 1
      READ(1)ICOM
      READ(1)((NODE(I,J),J=1,10),I=1,ICOM)
      READ(1)((PAR(I,J),J=1,6),I=1,ICOM)
C                                   DISPLAY CIRCUIT
  530 ASSIGN 532 TO N
      IEN=1
  531 NODE(IEN,10)=IEN
      JTAG=IEN
      END=IEN
      I1=NODE(IEN,1)
      IF(I1.EQ.11.OR.I1.EQ.21)S=S/2.
      GO TO 900
  532 VAL=PAR(IEN,1)
      IF(I1.EQ.11.OR.I1.EQ.21)S=S*2.
      IF(I1.EQ.11.OR.I1.EQ.21.OR.I1.EQ.9)GO TO 533
      J=JTAG+500
      IX=NODE(IEN,6)
      IY=NODE(IEN,7)+5
      CALL CRT(2,J,IX,IY,7,1,F1,VAL)
  533 IEN=IEN+1
      IF(IEN.GT.ICOM)GO TO 1
      GO TO 531
C                                   THIS IS "GO TO ANALYSIS" SECTION
C                                   STORE NODE NUMBERS.
  600 DO 601 I=1,ICOM
      DO 601 J=2,3
  601 NODE(I,J+9)=NODE(I,J)
C                                   ORDER COMPONENTS
      K=0
      DO 610 J=1,8
      DO 610 I=1,ICOM
      N=NODE(I,1)
      IF(N.GT.20)N=8
      IF(N.GT.10)N=1
      IF(N.NE.J)GO TO 610
      K=K+1
      IF(K.EQ.I)GO TO 610
      DO 611 JJ=1,12
      N=NODE(K,JJ)
      NODE(K,JJ)=NODE(I,JJ)
  611 NODE(I,JJ)=N
      DO 612 JJ=1,6
      VAL=PAR(I,JJ)
      PAR(I,JJ)=PAR(K,JJ)
  612 PAR(K,JJ)=VAL
  610 CONTINUE
C                                   COMPONENTS ARE NOW ORDERED
      IBUS=0
      DO 620 I=1,ICOM
      IF(NODE(I,1).EQ.9)GO TO 621
  620 CONTINUE
      I=ICOM+1
C                                   THERE ARE IBUS BUSSES.
  621 IBUS=ICOM-I+1
      ICO=ICOM
      ICOM=ICOM-IBUS
C                                   COMBINE NODES
      IF(IBUS.EQ.0)GO TO 640
      DO 630 J=1,ICO
      JJ=NODE(J,2)
      JK=NODE(J,3)
      DO 630 K=1,ICO
      DO 630 LA=2,3
      IF(NODE(K,LA).EQ.JJ)NODE(K,LA)=JK
  630 CONTINUE
C                                   COMPRESS NODES
  640 INO=1000
      DO 641 I=1,ICOM
      DO 641 J=2,3
      I1=NODE(I,J)
      IF(I1.GT.1000)GO TO 641
      INO=INO+1
      DO 642 II=I,ICOM
      DO 642 JJ=2,3
  642 IF(NODE(II,JJ).EQ.I1)NODE(II,JJ)=INO
  641 CONTINUE
      INO=INO-1000
      DO 643 I=1,ICOM
      DO 643 J=2,3
  643 NODE(I,J)=NODE(I,J)-1000
C                                   ENTER OUTPUT OPTIONS
      CALL DISPM1(7,1489,0)
      I=OP(6)*4.+1207.
C                                   1207 NO,1211 YES.
      CALL CRT(4,I)
      CALL FILPAR(60,5)
      CALL CRT(5,I)
      DO 650 J=1,6
  650 OP(J)=PAR(60,J)
C                                   FINAL CHECK, INDEX OR CONTINUE
      CALL DISPM1(0,1489,1497,0)
      WRITE(4,444)ICOM,INOD
      WRITE(4,444)((NODE(I,J),J=1,3),I=1,ICOM)
      WRITE(4,445)(PAR(I,1),I=1,ICOM)
  444 FORMAT(1H ,3I6)
  445 FORMAT(2H *,F8.2)
      IT=ITAGS(1489,1489,1497,2)
      IF(IT.NE.1489)GO TO 1
C                                   CLEAR SCREEN AND MENU
      CALL DISPM1(-2,0)
      CALL CLEAR(.TRUE.)
C     RETURN
      RETURN
      END
