Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap3_198111 - decus/20-0079/3spice.for
There are no other files named 3spice.for in the archive.
      SUBROUTINE ANLYZE
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/MISCEL/NOGO,IGOOF,NOPRNT,IACCT,JOBNAM(16),RTIMES(15)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         8
      COMMON/OUTDAT/ROUT(101,10),FREQ(101),IONUM,IONAM(10),IOPND(10),
     1   IONND(10),IOFLG(10),NUMOR(3),IOVAR(10,2),IACVAR(5)
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
      COMMON/DC/ICVFLG,ITCELM,TCSTAR,TCSTOP,TCINCR,KSSOP,KINEL,KOVAR
      COMMON/TRAN/JTRFLG,TSTEP,TSTOP,TSTART,NOTINT,STEPS(5),ENDPTS(5),
     1   KFROUT,FORFRE,KFPTS
      COMMON/AC/JACFLG,FSTART,FSTOP,IDFREQ,FINCR,INOISE,NOSPRT,
     1   NOSOUT,NOSIN
      COMMON/TEMPER/TEMPS(6),NUMTEM,ITEMNO
      COMMON/SENVAR/NSENS,KSNOUT(10)
      COMMON/DESIGN/JDSFLG,NSPEC,NDES,ERROR,NOELEM(30),NELTPE(30),
     1   NOUNUM(10),DESVAL(10),WEIGHT(10)
C
C
      DATA LPRN /1H(/
C
C  IF CIRCUIT CONTAINS NO INDUCTORS, SETUP MATRIX ONCE
C
      MODE=0
      KSETUP=0
      IF (JELCNT(3).GT.0) GO TO 5
      MODE=1
      KSETUP=1
      CALL SETUP
      IF (NOGO.EQ.1) RETURN
C
C  DC DESIGN
C
    5 IF (JDSFLG.EQ.0) GO TO 20
      MODE=1
      IF (KSETUP.EQ.1) GO TO 10
      CALL SETUP
      IF (NOGO.EQ.1) RETURN
   10 CALL DSIGN
      RETURN
C
C  CYCLE THROUGH TEMPERATURES
C
   20 ITEMNO=1
      IF (NUMTEM.EQ.1) GO TO 40
   30 ITEMNO=ITEMNO+1
      IF (ITEMNO.GT.NUMTEM) RETURN
      CALL TMPUPD
C
C  DC TRANSFER CURVES
C
   40 IF (ICVFLG.EQ.0) GO TO 200
      MODE=1
      IF (KSETUP.EQ.1) GO TO 50
      CALL SETUP
      IF (NOGO.EQ.1) RETURN
   50 CALL SECOND(T1)
      LOC1=MNAME(ITCELM)
      TEMVAL=SOURCE(LOC1)
      SOURCE(LOC1)=TCSTAR
      KOUNT=0
      IPROB=0
      ICALC=0
   60 IGOOF=0
      IPASS1=1
      DO 70 I=2,NUMNOD
   70 VNIM1(I)=0.0
   80 CALL ITER8
      KOUNT=KOUNT+ITERNO
      IF (IGOOF.EQ.1) GO TO 150
C
C  STORE OUTPUTS
C
      ICALC=ICALC+1
      FREQ(ICALC)=SOURCE(LOC1)
      IKNT=0
   90 IKNT=IKNT+1
      IF (IKNT.GT.NUMOR(1)) GO TO 110
      JKNT=IOVAR(IKNT,1)
      IPNOD=IOPND(JKNT)
      IF (IOFLG(JKNT).EQ.2) GO TO 100
      INNOD=IONND(JKNT)
      ROUT(ICALC,IKNT)=VNIM1(IPNOD)-VNIM1(INNOD)
      GO TO 90
  100 CALL CALCUR(IPNOD,CREAL)
      ROUT(ICALC,IKNT)=CREAL
      GO TO 90
C
C  LINEAR INTERPOLATION FOR MISSING TRANSFER CURVE VALUE
C
  110 IF (IPROB.LT.2) GO TO 130
      IKNT=0
  120 IKNT=IKNT+1
      IF (IKNT.GT.NUMOR(1)) GO TO 130
      ROUT(ICALC-1,IKNT)=(ROUT(ICALC-2,IKNT)+ROUT(ICALC,IKNT))/2.0
      GO TO 120
C
C  INCREMENT SOURCE VALUE
C
  130 IPROB=0
      SOURCE(LOC1)=SOURCE(LOC1)+TCINCR
      IF (ICALC.LT.ICVFLG) GO TO 80
      SOURCE(LOC1)=TEMVAL
      GO TO 190
C
C  NONCONVERGENCE RECOVERY
C
  150 IF (ICALC.EQ.0) GO TO 170
      IF (IPROB.GT.0) GO TO 160
      IPROB=1
      WRITE (6,151) SOURCE(LOC1)
  151 FORMAT (//5X,'--- WARNING ---  TRANSFER CURVES RESTARTED AT '
     1   'SOURCE VALUE ',1PE9.2)
      GO TO 60
  160 IF (IPROB.GT.1) GO TO 165
      IPROB=2
      ICALC=ICALC+1
      FREQ(ICALC)=SOURCE(LOC1)
      SOURCE(LOC1)=SOURCE(LOC1)+TCINCR
      WRITE (6,151) SOURCE(LOC1)
      GO TO 60
  165 ICALC=ICALC-1
  170 NOGO=1
      WRITE (6,171) SOURCE(LOC1)
  171 FORMAT (1H1,4X,'----------  NO CONVERGENCE ON DC TRANSFER '
     1   'AT SOURCE VALUE ',1PE9.2//)
      WRITE (6,176) ITERNO,IPASS1,IFINAL
  176 FORMAT (5X,'ITERNO =  ',I3,5X,'IPASS1 =  ',I3,5X,'IFINAL =  ',I3//
     1   5X,'LAST NODE VOLTAGES'//1X,5(' NODE    VOLTAGE    ')//)
      WRITE (6,181) (LPRN,JUNODE(I),VNIM1(I),I=2,NUNODS)
  181 FORMAT (5(1X,A1,I3,1H),1X,F10.4,3X)/)
  190 CALL SECOND(T2)
      RTIMES(3)=RTIMES(3)+T2-T1
      RTIMES(4)=RTIMES(4)+KOUNT
      CALL OVTPVT
      IF (NOGO.EQ.1) RETURN
C
C  SMALL SIGNAL OPERATING POINT
C
  200 CALL SECOND(T1)
      ITEMP=NSENS+KSSOP
      IF (ITEMP.GT.0) GO TO 220
      IF (JACFLG.EQ.0) GO TO 210
      ITEMP=JELCNT(7)+JELCNT(8)+JELCNT(9)+JELCNT(10)
      IF (ITEMP.GT.0) GO TO 220
      GO TO 240
  210 ITEMP=JTRFLG+JDSFLG+ICVFLG
      IF (ITEMP.GT.0) GO TO 300
  220 IF (MODE.EQ.1) GO TO 230
      MODE=1
      IF (KSETUP.EQ.1) GO TO 230
      CALL SETUP
      IF (NOGO.EQ.1) RETURN
C*230 WRITE (6,231) (JOBNAM(I),I=1,8),TEMPS(ITEMNO)
C*231 FORMAT (1H7/////1X,125(1H*)///1X,8A10,26X,'-----  SPICE  -----'
C*   1   ///21X,'SMALL SIGNAL BIAS SOLUTION',30X,'TEMPERATURE  ',
C*   2   F10.3,'  DEG C'///1X,125(1H*)///)
  230 WRITE (6,231) (JOBNAM(I),I=1,16),TEMPS(ITEMNO)
  231 FORMAT (1H1/////1X,125(1H*)///1X,16A5,26X,'-----  SPICE  -----'
     1   ///21X,'SMALL SIGNAL BIAS SOLUTION',30X,'TEMPERATURE  ',
     2   F10.3,'  DEG C'///1X,125(1H*)///)
      CALL DCOP(1)
      IF (KINEL.EQ.0) GO TO 235
      CALL DCTRFN
  235 IF (NSENS.EQ.0) GO TO 238
      CALL SENCAL
  238 CALL SECOND(T2)
      RTIMES(5)=RTIMES(5)+T2-T1
      IF (NOGO.EQ.1) RETURN
C
C  AC SMALL SIGNAL ANALYSIS
C
      IF (JACFLG.EQ.0) GO TO 300
  240 MODE=2
      IF (KSETUP.EQ.1) GO TO 250
      CALL SETUP
      IF (NOGO.EQ.1) RETURN
  250 CALL ACAN
      CALL OVTPVT
      IF (NOGO.EQ.1) RETURN
C
C  TRANSIENT DC INITIAL CONDITIONS
C
  300 IF (JTRFLG.EQ.0) GO TO 30
      IF (MODE.EQ.1) GO TO 310
      MODE=1
      IF (KSETUP.EQ.1) GO TO 310
      CALL SETUP
      IF (NOGO.EQ.1) RETURN
  310 CALL SECOND(T1)
      DO 330 ID=4,6,2
      ISTART=LOCATE(ID)
      ISTOP=LOCATE(ID+1)-1
      IF (ISTART.GT.ISTOP) GO TO 330
      DO 320 I=ISTART,ISTOP
      MNAM=MNAME(I)
      SOURCE(MNAM+2)=SOURCE(MNAM)
      IF (SOURCE(MNAM+3).EQ.0.0) GO TO 320
      SOURCE(MNAM)=SOURCE(MNAM+5)
  320 CONTINUE
  330 CONTINUE
C*    WRITE (6,341) (JOBNAM(I),I=1,8),TEMPS(ITEMNO)
C*341 FORMAT (1H7/////1X,125(1H*)///1X,8A10,26X,'-----  SPICE  -----'
      WRITE (6,341) (JOBNAM(I),I=1,16),TEMPS(ITEMNO)
  341 FORMAT (1H1/////1X,125(1H*)///1X,16A5,26X,'-----  SPICE  -----'
     1   ///21X,'INITIAL TRANSIENT SOLUTION',30X,'TEMPERATURE  ',
     2   F10.3,'  DEG C'///1X,125(1H*)///)
      CALL DCOP(2)
      IF (NOGO.EQ.1) GO TO 440
C
C  STORE DC INDUCTOR CURRENTS
C
      ISTART=LOCATE(3)
      ISTOP=LOCATE(4)-1
      IF (ISTART.GT.ISTOP) GO TO 360
      ISPOT=ICURNT(3)
      DO 350 I=ISTART,ISTOP
      CALL CALCUR(I,CREAL)
      TRACUR(ISPOT)=0.0
      TRACUR(ISPOT+1)=CREAL
      ISPOT=ISPOT+2
  350 CONTINUE
C
C  STORE DC CAPACITOR VOLTAGES
C
  360 ISTART=LOCATE(2)
      ISTOP=LOCATE(3)-1
      IF (ISTART.GT.ISTOP) GO TO 380
      ISPOT=ICURNT(2)
      DO 370 I=ISTART,ISTOP
      LOC=LOCAL(I)
      IPNOD=NODPLC(LOC)
      INNOD=NODPLC(LOC+1)
      VCAP=VNIM1(IPNOD)-VNIM1(INNOD)
      TRACUR(ISPOT)=VCAP
      TRACUR(ISPOT+1)=0.0
      ISPOT=ISPOT+2
  370 CONTINUE
C
C  STORE INITIAL OUTPUTS
C
  380 FREQ(1)=0.0
      IKNT=0
  390 IKNT=IKNT+1
      IF (IKNT.GT.NUMOR(2)) GO TO 410
      JKNT=IOVAR(IKNT,2)
      IPNOD=IOPND(JKNT)
      IF (IOFLG(JKNT).EQ.2) GO TO 400
      INNOD=IONND(JKNT)
      ROUT(1,IKNT)=VNIM1(IPNOD)-VNIM1(INNOD)
      GO TO 390
  400 CALL CALCUR(IPNOD,CREAL)
      ROUT(1,IKNT)=CREAL
      GO TO 390
C
C  RESET SOURCE VALUES
C
  410 DO 430 ID=4,6,2
      ISTART=LOCATE(ID)
      ISTOP=LOCATE(ID+1)-1
      IF (ISTART.GT.ISTOP) GO TO 430
      DO 420 I=ISTART,ISTOP
      MNAM=MNAME(I)
      IF (SOURCE(MNAM+3).EQ.0.0) GO TO 420
      SOURCE(MNAM)=SOURCE(MNAM+2)
  420 CONTINUE
  430 CONTINUE
  440 CALL SECOND(T2)
      RTIMES(5)=RTIMES(5)+T2-T1
      IF (NOGO.EQ.1) RETURN
C
C  TRANSIENT ANALYSIS
C
      MODE=3
      IF (KSETUP.EQ.1) GO TO 450
      CALL SETUP
      IF (NOGO.EQ.1) RETURN
  450 CALL TRANAN
      CALL OVTPVT
      IF (NOGO.EQ.1) RETURN
      GO TO 30
      END
      SUBROUTINE TMPUPD
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/MODELS/NUMMOD,MODNAM(25),KIND(25)
      COMMON/KNSTNT/TWOPI,XLOG2,XLOG10,RAD,BOLTZ,CHARGE,VT
      COMMON/TEMPER/TEMPS(6),NUMTEM,ITEMNO
C
C
      TEMPD=TEMPS(ITEMNO)+273.0
      VT=BOLTZ*TEMPD/CHARGE
      IF (NUMMOD.EQ.0) RETURN
      RATIO=TEMPD/(TEMPS(ITEMNO-1)+273.0)
      RATIO2=RATIO*RATIO
      RATIO3=RATIO2*RATIO
      XNUM=-(1.0-RATIO)/VT
      DO 100 I=1,NUMMOD
      INUM=KIND(I)
      IF (INUM.EQ.0) GO TO 100
      GO TO (10,20,30,40,50,60),INUM
C
C  EBERS-MOLL TRANSISTOR MODELS
C
   10 FACTOR=RATIO3*EXP(SYMVAL(I,16)*XNUM)
      SYMVAL(I,12)=SYMVAL(I,12)*FACTOR
      GO TO 100
C
C  GUMMEL-POON TRANSISTOR MODELS
C
   20 FACTOR=RATIO3*EXP(SYMVAL(I,25)*XNUM)
      SYMVAL(I,2)=SYMVAL(I,2)*FACTOR
      SYMVAL(I,3)=SYMVAL(I,3)*FACTOR
      SYMVAL(I,12)=SYMVAL(I,12)*FACTOR
      SYMVAL(I,17)=SYMVAL(I,17)*RATIO
      SYMVAL(I,15)=SYMVAL(I,15)*EXP(VT*ALOG(FACTOR)/SYMVAL(I,17))
      SYMVAL(I,20)=SYMVAL(I,20)*RATIO
      SYMVAL(I,18)=SYMVAL(I,18)*EXP(VT*ALOG(FACTOR)/SYMVAL(I,20))
      GO TO 100
C
C  JUNCTION DIODE MODELS
C
   30 FACTOR=RATIO3*EXP(SYMVAL(I,7)*XNUM)
      SYMVAL(I,5)=SYMVAL(I,5)*RATIO
      SYMVAL(I,4)=SYMVAL(I,4)*EXP(VT*ALOG(FACTOR)/SYMVAL(I,5))
      GO TO 100
C
C  SHOTTKY BARRIER DIODE MODELS
C
   40 FACTOR=RATIO2*EXP(SYMVAL(I,7)*XNUM)
      SYMVAL(I,5)=SYMVAL(I,5)*RATIO
      SYMVAL(I,4)=SYMVAL(I,4)*EXP(VT*ALOG(FACTOR)/SYMVAL(I,5))
      GO TO 100
C
C  JFET MODEL
C
   50 FACTOR=RATIO3*EXP(1.11*XNUM)
      SYMVAL(I,10)=SYMVAL(I,10)*FACTOR
      GO TO 100
C
C  MOSFET MODEL
C
   60 FACTOR=RATIO3*EXP(1.11*XNUM)
      SYMVAL(I,15)=SYMVAL(I,15)*FACTOR
  100 CONTINUE
      RETURN
      END
      SUBROUTINE DSIGN
      RETURN
      END
      SUBROUTINE DCOP(IFLAG)
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/MODELS/NUMMOD,MODNAM(25),KIND(25)
      COMMON/MISCEL/NOGO,IGOOF,NOPRNT,IACCT,JOBNAM(16),RTIMES(15)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         9
      COMMON/KNSTNT/TWOPI,XLOG2,XLOG10,RAD,BOLTZ,CHARGE,VT
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
      COMMON/TEMPER/TEMPS(6),NUMTEM,ITEMNO
C
C
      DATA LPRN/1H(/
C
C  IFLAG=1 FOR AC SMALL SIGNAL OPERATING POINT
C  IFLAG=2 FOR INITIAL TRANSIENT OPERATING POINT
C
      IGOOF=0
      IPASS1=1
      DO 10 I=2,NUMNOD
   10 VNIM1(I)=0.0
      CALL ITER8
      RTIMES(6)=RTIMES(6)+ITERNO
      IF (IGOOF.EQ.0) GO TO 100
      NOGO=1
      WRITE (6,21)
   21 FORMAT (1H1,4X,'----------  NO CONVERGENCE ON DC '
     1   'OPERATING POINT'//)
      WRITE (6,31) ITERNO,IPASS1,IFINAL
   31 FORMAT (5X,'ITERNO =  ',I3,5X,'IPASS1 =  ',I3,5X,'IFINAL =  ',I3//
     1   5X,'LAST NODE VOLTAGES'//1X,5(' NODE    VOLTAGE    ')//)
      WRITE (6,41) (LPRN,JUNODE(I),VNIM1(I),I=2,NUNODS)
   41 FORMAT (5(1X,A1,I3,1H),1X,F10.4,3X)/)
      RETURN
C
C  PRINT DC OPERATING POINT
C
  100 WRITE (6,101)
  101 FORMAT (1X,5(' NODE    VOLTAGE    ')//)
      WRITE (6,41) (LPRN,JUNODE(I),VNIM1(I),I=2,NUNODS)
C
C  VOLTAGE SOURCE CURRENTS
C
      POWER=0.0
      ISTART=LOCATE(6)
      ISTOP=LOCATE(7)-1
      IF (ISTART.GT.ISTOP) GO TO 160
      WRITE (6,131)
  131 FORMAT (////5X,'VOLTAGE SOURCE CURRENTS'//8X,'NAME',10X,
     1   'CURRENT'/)
      DO 150 I=ISTART,ISTOP
      MNAM=MNAME(I)
      CALL CALCUR(I,CREAL)
      POWER=POWER-SOURCE(MNAM)*CREAL
      WRITE (6,141) NAME(I),CREAL
C*  141 FORMAT (/8X,A7,5X,1PE10.3,'  AMPS')
  141 FORMAT (/8X,R4,9X,1PE10.3,'  AMPS')
  150 CONTINUE
  160 ISTART=LOCATE(4)
      ISTOP=LOCATE(5)-1
      IF (ISTART.GT.ISTOP) GO TO 180
      DO 170 I=ISTART,ISTOP
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      MNAM=MNAME(I)
      POWER=POWER-SOURCE(MNAM)*(VNIM1(NODE1)-VNIM1(NODE2))
  170 CONTINUE
  180 WRITE (6,181) POWER
  181 FORMAT (//5X,'TOTAL POWER DISSIPATION  ',1PE9.2,'  WATTS')
C
C  SMALL SIGNAL DEVICE PARAMETERS
C
      ISTART=JELCNT(7)+JELCNT(8)+JELCNT(9)+JELCNT(10)
      IF (ISTART.EQ.0) RETURN
      WRITE (6,201)
  201 FORMAT (1H1)
      IPASS1=1
      MODE=2
      DELTA=1.0
      CALL BJT
      CALL DIODE
      CALL JFET
      CALL MOSFET
      MODE=1
      IPASS1=0
C
C  TRANSISTORS
C
  210 ISTART=LOCATE(7)
      ISTOP=LOCATE(8)-1
      IF (ISTART.GT.ISTOP) GO TO 300
      IF (IFLAG.EQ.2) GO TO 220
      WRITE (6,211)
  211 FORMAT (/////5X,'TRANSISTOR OPERATING POINTS'///1X,'NAME',
     1   4X,'MODEL',7X,'IB',8X,'IC',6X,'VBE',5X,'VBC',5X,'VCE',7X,
     2   'GM',7X,'RPI',6X,'RO',7X,'CPI',6X,'CMU',5X,'BETADC',2X,
     3   'BETAAC',3X,'FT'/)
      GO TO 230
  220 WRITE (6,221)
  221 FORMAT (/////5X,'TRANSISTOR OPERATING POINTS'///1X,'NAME',
     1   4X,'MODEL',7X,'IB',8X,'IC',6X,'VBE',5X,'VBC',5X,'VCE',5X,
     2   'BETADC'/)
  230 ISPOT=ICURNT(7)
      DO 280 I=ISTART,ISTOP
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      TYPE=SYMVAL(MNAM,1)
      VBE=VNIM1(NODE2)-VNIM1(NODE3)
      VBC=VNIM1(NODE2)-VNIM1(NODE1)
      VCE=VBE-VBC
      CC=TYPE*TRACUR(ISPOT+2)
      CB=TYPE*TRACUR(ISPOT+3)
      ARG=TRACUR(ISPOT+3)
      IF (ABS(ARG).LT.1.0E-20) ARG=1.0E-20
      BETADC=TRACUR(ISPOT+2)/ARG
      IF (IFLAG.EQ.1) GO TO 250
      WRITE (6,241) NAME(I),MODNAM(MNAM),CB,CC,VBE,VBC,VCE,BETADC
C*  241 FORMAT (/1X,A7,1X,A7,1X,1PE9.2,1X,E9.2,1X,0PF7.3,1X,F7.3,1X,
  241 FORMAT (/1X,R3,5X,R3,5X,1PE9.2,1X,E9.2,1X,0PF7.3,1X,F7.3,1X,
     1   F7.3,1X,F7.1)
      GO TO 270
  250 RPI=1.0/TRACUR(ISPOT+4)
      CPI=TRACUR(ISPOT+5)
      CMU=TRACUR(ISPOT+7)
      GM=TRACUR(ISPOT+8)
      ARG=TRACUR(ISPOT+9)
      IF (ARG.LT.1.0E-20) ARG=1.0E-20
      RO=1.0/ARG
      BETAAC=GM*RPI
      ARG=CPI+CMU
      IF (ARG.LT.1.0E-20) ARG=1.0E-20
      FT=GM/(TWOPI*ARG)
      WRITE (6,261) NAME(I),MODNAM(MNAM),CB,CC,VBE,VBC,VCE,GM,RPI,
     1   RO,CPI,CMU,BETADC,BETAAC,FT
  261 FORMAT (/1X,R3,5X,R3,5X,1PE9.2,1X,E9.2,1X,0PF7.3,1X,F7.3,1X,
     1   F7.3,1X,1PE9.2,1X,E8.2,1X,E8.2,1X,E8.2,1X,E8.2,1X,0PF7.1,1X,
     2   F7.1,1X,1PE8.2)
  270 ISPOT=ISPOT+15
  280 CONTINUE
C
C  DIODES
C
  300 ISTART=LOCATE(8)
      ISTOP=LOCATE(9)-1
      IF (ISTART.GT.ISTOP) GO TO 400
      IF (IFLAG.EQ.2) GO TO 310
      WRITE (6,301)
  301 FORMAT (/////5X,'DIODE OPERATING POINTS'///1X,'NAME',4X,
     1   'MODEL',10X,'ID',11X,'VJ',12X,'R',12X,'C'/)
      GO TO 320
  310 WRITE (6,311)
  311 FORMAT (/////5X,'DIODE OPERATING POINTS'///1X,'NAME',4X,
     1   'MODEL',10X,'ID',11X,'VJ'/)
  320 ISPOT=ICURNT(8)
      DO 370 I=ISTART,ISTOP
      LOC=LOCAL(I)
      MNAM=MNAME(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      VBE=VNIM1(NODE1)-VNIM1(NODE2)
      CC=TRACUR(ISPOT+1)
      IF (IFLAG.EQ.1) GO TO 340
      WRITE (6,331) NAME(I),MODNAM(MNAM),CC,VBE
C*  331 FORMAT (/1X,A7,1X,A7,2(3X,1PE10.3))
331	FORMAT (/1X,R3,1X,R3,2(3X,1PE10.3))
      GO TO 360
  340 RPI=1.0/TRACUR(ISPOT+2)
      WRITE (6,351) NAME(I),MODNAM(MNAM),CC,VBE,RPI,TRACUR(ISPOT+3)
C*  351 FORMAT (/1X,A7,1X,A7,4(3X,1PE10.3))
351	FORMAT (/1X,R3,1X,R3,4(3X,1PE10.3))
  360 ISPOT=ISPOT+5
  370 CONTINUE
C
C  JFETS
C
  400 ISTART=LOCATE(9)
      ISTOP=LOCATE(10)-1
      IF (ISTART.GT.ISTOP) GO TO 500
      IF (IFLAG.EQ.2) GO TO 410
      WRITE (6,401)
  401 FORMAT (/////5X,'JFET OPERATING POINTS'///1X,'NAME',4X,'MODEL',
     1   10X,'ID',11X,'VGS',10X,'VDS',10X,'GM',11X,'GDS',10X,'CGS',
     2   10X,'CGD'/)
      GO TO 420
  410 WRITE (6,411)
  411 FORMAT (/////5X,'JFET OPERATING POINTS'///1X,'NAME',4X,'MODEL',
     1   10X,'ID',11X,'VGS',10X,'VDS'/)
  420 ISPOT=ICURNT(9)
      DO 460 I=ISTART,ISTOP
      LOC=LOCAL(I)
      MNAM=MNAME(I)
      TYPE=SYMVAL(MNAM,1)
      CSAT=SYMVAL(MNAM,10)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      CDRAIN=TYPE*TRACUR(ISPOT+2)
      VGS=VNIM1(NODE2)-VNIM1(NODE3)
      VDS=VNIM1(NODE1)-VNIM1(NODE3)
      IF (IFLAG.EQ.1) GO TO 440
      WRITE (6,431) NAME(I),MODNAM(MNAM),CDRAIN,VGS,VDS
C*  431 FORMAT (/1X,A7,1X,A7,3(3X,1PE10.3))
431	FORMAT (/1X,R3,1X,R3,3(3X,1PE10.3))
      GO TO 450
  440 WRITE (6,441) NAME(I),MODNAM(MNAM),CDRAIN,VGS,VDS,
     1   TRACUR(ISPOT+3),TRACUR(ISPOT+4),TRACUR(ISPOT+6),
     2   TRACUR(ISPOT+8)
C*  441 FORMAT (/1X,A7,1X,A7,7(3X,1PE10.3))
441	FORMAT (/1X,R3,1X,R3,7(3X,1PE10.3))
  450 ISPOT=ISPOT+10
  460 CONTINUE
C
C  MOSFETS
C
  500 ISTART=LOCATE(10)
      ISTOP=LOCATE(11)-1
      IF (ISTART.GT.ISTOP) RETURN
      IF (IFLAG.EQ.2) GO TO 510
      WRITE (6,501)
  501 FORMAT (/////5X,'MOSFET OPERATING POINTS'///1X,'NAME',4X,
     1   'MODEL',10X,'ID',11X,'VGS',10X,'VDS',10X,'VBS',10X,'GM',11X,
     2   'GDS',9X,'GMBS',10X,'CBD',10X,'CBS'/)
      GO TO 520
  510 WRITE (6,511)
  511 FORMAT (/////5X,'MOSFET OPERATING POINTS'///1X,'NAME',4X,
     1   'MODEL',10X,'ID',11X,'VGS',10X,'VDS',10X,'VBS'/)
  520 ISPOT=ICURNT(10)
      DO 560 I=ISTART,ISTOP
      LOC=LOCAL(I)
      MNAM=MNAME(I)
      TYPE=SYMVAL(MNAM,1)
      CSAT=SYMVAL(MNAM,15)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      NODE4=NODPLC(LOC+3)
      VGS=VNIM1(NODE2)-VNIM1(NODE3)
      VDS=VNIM1(NODE1)-VNIM1(NODE3)
      VBS=VNIM1(NODE4)-VNIM1(NODE3)
      CDRAIN=TYPE*TRACUR(ISPOT+2)
      IF (IFLAG.EQ.1) GO TO 540
      WRITE (6,531) NAME(I),MODNAM(MNAM),CDRAIN,VGS,VDS,VBS
C*  531 FORMAT (/1X,A7,1X,A7,4(3X,1PE10.3))
531	FORMAT (/1X,R3,1X,R3,4(3X,1PE10.3))
      GO TO 550
  540 WRITE (6,541) NAME(I),MODNAM(MNAM),CDRAIN,VGS,VDS,VBS,
     1   TRACUR(ISPOT+3),TRACUR(ISPOT+4),TRACUR(ISPOT+5),
     2   TRACUR(ISPOT+7),TRACUR(ISPOT+9)
C*  541 FORMAT (/1X,A7,1X,A7,9(3X,1PE10.3))
541	FORMAT (/1X,R3,1X,R3,9(3X,1PE10.3))
  550 ISPOT=ISPOT+15
  560 CONTINUE
      RETURN
      END
      SUBROUTINE DCTRFN
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/POINTS/IUS,ILS,MIRROR,NSTOP,NUMVS,LASTUT,LASTLT
      COMMON/OUTDAT/ROUT(101,10),FREQ(101),IONUM,IONAM(10),IOPND(10),
     1   IONND(10),IOFLG(10),NUMOR(3),IOVAR(10,2),IACVAR(5)
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
      COMMON/DC/ICVFLG,ITCELM,TCSTAR,TCSTOP,TCINCR,KSSOP,KINEL,KOVAR
C
C
      DIMENSION U(1)
      EQUIVALENCE (U(1),YNL(402))
C
C
      LOC=LOCAL(KINEL)
      NOPOSI=NODPLC(LOC)
      NONEGI=NODPLC(LOC+1)
      NOPOSO=IOPND(KOVAR)
      NONEGO=IONND(KOVAR)
      IPASS1=-1
C
C  SETUP CURRENT VECTOR FOR INPUT IMPEDENCE AND TRANSFER FUNCTION
C
      DO 10 I=1,NUMNOD
   10 VN(I)=0.0
      IF (KINEL.GE.LOCATE(6)) GO TO 20
      VN(NOPOSI)=-1.0
      VN(NONEGI)=1.0
   20 KELNO=KINEL
C
C  LOAD IN VOLTAGE SOURCES TO CURRENT VECTOR
C
   30 IF (NUMVS.EQ.0) GO TO 60
      DO 50 I=1,NUMVS
      IELNUM=MATLOC(I)
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      SIGN=NODPLC(LOC+2)
      IF (IELNUM.NE.KELNO) SIGN=0.0
      VN(NODE2)=VN(NODE2)+VN(NODE1)-YNL(NODE1)*SIGN
      IF (SIGN.EQ.0.0) GO TO 50
      IPNOD=NODPLC(LOC+3)
      JSTART=IUR(IPNOD)
      JSTOP=IUR(IPNOD+1)-1
      IF (JSTART.GT.JSTOP) GO TO 50
      DO 40 J=JSTART,JSTOP
      JO=IUC(J)
      NODE3=IORDER(JO)
      VN(NODE3)=VN(NODE3)-U(J)*SIGN
   40 CONTINUE
   50 CONTINUE
C
C  PERFORM NEW FORWARD AND BACK SUBSTITUTION
C
   60 CALL ITER8
      VN(1)=0.0
      IF (NUMVS.EQ.0) GO TO 100
      DO 90 I=1,NUMVS
      IELNUM=MATLOC(NUMVS-I+1)
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      SIGN=NODPLC(LOC+2)
      IF (IELNUM.NE.KELNO) SIGN=0.0
      IF (IELNUM.LT.LOCATE(6)) GO TO 80
      ISPOT=ICURNT(6)+2*(IELNUM-LOCATE(6))
      TRACUR(ISPOT)=VN(NODE1)
   80 VN(NODE1)=VN(NODE2)+SIGN
   90 CONTINUE
  100 IF (KELNO.NE.KINEL) GO TO 200
C
C  EVALUATE TRANSFER FUNCTION
C
      IF (IOFLG(KOVAR).EQ.2) GO TO 110
      TRFN=VN(NOPOSO)-VN(NONEGO)
      GO TO 120
  110 CALL CALCUR(NOPOSO,TRFN)
C
C  EVALUATE INPUT IMPEDENCE
C
  120 IF (KINEL.GE.LOCATE(6)) GO TO 130
      ZIN=VN(NONEGI)-VN(NOPOSI)
      GO TO 150
  130 CALL CALCUR(KINEL,CREAL)
      IF (CREAL.GT.1.0E-20) GO TO 140
      IF (CREAL.LT.-1.0E-20) GO TO 140
      CREAL=-1.0E-20
  140 ZIN=-1.0/CREAL
C
C  SETUP CURRENT VECTOR FOR OUTPUT IMPEDENCE
C
  150 KELNO=0
      DO 160 I=1,NUMNOD
  160 VN(I)=0.0
      IF (IOFLG(KOVAR).EQ.2) GO TO 170
      VN(NOPOSO)=-1.0
      VN(NONEGO)=1.0
      GO TO 30
  170 KELNO=NOPOSO
      IF (KELNO.NE.KINEL) GO TO 30
      ZOUT=ZIN
      GO TO 250
C
C  EVALUATE OUTPUT IMPEDENCE
C
  200 IF (IOFLG(KOVAR).EQ.2) GO TO 210
      ZOUT=VN(NONEGO)-VN(NOPOSO)
      GO TO 250
  210 CALL CALCUR(NOPOSO,CREAL)
      IF (CREAL.GT.1.0E-20) GO TO 220
      IF (CREAL.LT.-1.0E-20) GO TO 220
      CREAL=-1.0E-20
  220 ZOUT=-1.0/CREAL
  250 WRITE (6,251) IONAM(KOVAR),NAME(KINEL),NAME(KINEL),IONAM(KOVAR),
     1   TRFN,ZIN,ZOUT
  251 FORMAT (/////5X,'SMALL SIGNAL CHARACTERISTICS'///6X,R3,3H/  ,
     1   R3,4X,'INPUT IMPEDENCE',7X,'OUTPUT IMPEDENCE'/31X,'AT  ',R3,
     2   11X,'AT  ',R3//8X,1PE10.3,12X,E10.3,12X,E10.3)
      RETURN
      END
      SUBROUTINE SENCAL
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/MODELS/NUMMOD,MODNAM(25),KIND(25)
      COMMON/KNSTNT/TWOPI,XLOG2,XLOG10,RAD,BOLTZ,CHARGE,VT
      COMMON/OUTDAT/ROUT(101,10),FREQ(101),IONUM,IONAM(10),IOPND(10),
     1   IONND(10),IOFLG(10),NUMOR(3),IOVAR(10,2),IACVAR(5)
      COMMON/TEMPER/TEMPS(6),NUMTEM,ITEMNO
      COMMON/SENVAR/NSENS,KSNOUT(10)
C
C
C*    DATA LSRB,LSRC,LSRE,LSIS,LSBF,LSBR,LSVA,LSRS,LSN /6H   RB ,
C*   1   6H   RC ,6H   RE ,6H   IS ,6H   BF ,6H   BR ,6H   VA ,
C*   2   6H   RS ,6H   N  /
      DATA LSRB,LSRC,LSRE,LSIS,LSBF,LSBR,LSVA,LSRS,LSN/5H  RB ,
     1   5H  RC ,5H  RE ,5H  IS ,5H  BF ,5H  BR ,5H  VA ,
     2   5H  RS ,5H  N  /
C
C
      DO 1000 N=1,NSENS
C
C  SMALL SIGNAL OPERATING POINT HAS BEEN OBTAINED.  SMALL SIGNAL
C  Y MATRIX IS STORED IN YNL ARRAY.  OBTAIN ADJOINT SOLUTION BY
C  CONSTRUCTING ADJOINT EXCITATION VECTOR AND DOING A FORWARD AND
C  BACK SUBSTITUTION ON THE TRANSPOSE OF Y MATRIX
C
      DO 10 I=1,NUMNOD
   10 VN(I)=0.0
      ISTART=LOCATE(6)
      ISTOP=LOCATE(7)-1
      IF (ISTART.GT.ISTOP) GO TO 30
      DO 20 I=ISTART,ISTOP
   20 VALUE(I)=0.0
   30 IKNT=KSNOUT(N)
      IPNOD=IOPND(IKNT)
      IF (IOFLG(IKNT).EQ.2) GO TO 40
      INNOD=IONND(IKNT)
      VN(IPNOD)=-1.0
      VN(INNOD)=1.0
      GO TO 50
   40 VALUE(IPNOD)=-1.0
   50 CALL ASOL
C
C  REAL SOLUTION IS STORED IN VNIM1 ARRAY, AND ADJOINT SOLUTION IS
C  STORED IN VN ARRAY.  COMPUTE SENSITIVITIES
C
      WRITE (6,51) IONAM(IKNT)
   51 FORMAT (1H1,'SENSITIVITIES OF OUTPUT ',R3///8X,'ELEMENT',9X,
     1   'ELEMENT',7X,'ELEMENT',7X,'NORMALIZED'/10X,'NAME',11X,'VALUE',
     2   6X,'SENSITIVITY',4X,'SENSITIVITY'/35X,'(VOLTS/UNIT)',2X,
     3   '(VOLTS/PERCENT)')
C
C  RESISTORS
C
      ISTOP=LOCATE(2)-1
      IF (ISTOP.LT.1) GO TO 100
      WRITE (6,61)
   61 FORMAT (//)
      DO 80 I=1,ISTOP
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      VAL=1.0/VALUE(I)
      SENS=-(VNIM1(NODE1)-VNIM1(NODE2))*(VN(NODE1)-VN(NODE2))/(VAL*VAL)
      SENSN=VAL*SENS/100.0
      WRITE (6,71) NAME(I),VAL,SENS,SENSN
   71 FORMAT (10X,R3,5X,1PE10.3,5X,E10.3,5X,E10.3)
   80 CONTINUE
C
C  CURRENT SOURCES
C
  100 ISTART=LOCATE(4)
      ISTOP=LOCATE(5)-1
      IF (ISTART.GT.ISTOP) GO TO 150
      WRITE (6,61)
      DO 120 I=ISTART,ISTOP
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      MNAM=MNAME(I)
      VAL=SOURCE(MNAM)
      SENS=VN(NODE1)-VN(NODE2)
      SENSN=VAL*SENS/100.0
      WRITE (6,71) NAME(I),VAL,SENS,SENSN
  120 CONTINUE
C
C  VOLTAGE DEPENDENT CURRENT SOURCES
C
  150 ISTART=LOCATE(5)
      ISTOP=LOCATE(6)-1
      IF (ISTART.GT.ISTOP) GO TO 200
      WRITE (6,61)
      DO 170 I=ISTART,ISTOP
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      NODE4=NODPLC(LOC+3)
      VAL=VALUE(I)
      SENS=(VNIM1(NODE3)-VNIM1(NODE4))*(VN(NODE1)-VN(NODE2))
      SENSN=VAL*SENS/100.0
      WRITE (6,71) NAME(I),VAL,SENS,SENSN
  170 CONTINUE
C
C  VOLTAGE SOURCES
C
  200 ISTART=LOCATE(6)
      ISTOP=LOCATE(7)-1
      IF (ISTART.GT.ISTOP) GO TO 300
      WRITE (6,61)
      DO 230 I=ISTART,ISTOP
      MNAM=MNAME(I)
      VAL=SOURCE(MNAM)
      CALL ACALC(I,CREAL)
      SENS=-CREAL
      SENSN=VAL*SENS/100.0
      WRITE (6,71) NAME(I),VAL,SENS,SENSN
  230 CONTINUE
C
C  TRANSISTORS
C
  300 ISTART=LOCATE(7)
      ISTOP=LOCATE(8)-1
      IF (ISTART.GT.ISTOP) GO TO 400
      WRITE (6,61)
      DO 380 I=ISTART,ISTOP
      MNAM=MNAME(I)
      WRITE (6,301) NAME(I)
  301 FORMAT (1X,R3)
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      NODE4=NODPLC(LOC+3)
      NODE5=NODPLC(LOC+4)
      NODE6=NODPLC(LOC+5)
C
C  BASE RESISTANCE (RB)
C
      IF (SYMVAL(MNAM,4).NE.0.0) GO TO 320
      WRITE (6,311) LSRB
  311 FORMAT (10X,R3,5X,4H 0.0,11X,4H 0.0,11X,4H 0.0)
      GO TO 330
  320 VAL=1.0/(SYMVAL(MNAM,4)*VALUE(I))
      SENS=-(VNIM1(NODE2)-VNIM1(NODE5))*(VN(NODE2)-VN(NODE5))/(VAL*VAL)
      SENSN=VAL*SENS/100.0
      WRITE (6,71) LSRB,VAL,SENS,SENSN
C
C  COLLECTOR RESISTANCE (RC)
C
  330 IF (SYMVAL(MNAM,5).NE.0.0) GO TO 340
      WRITE (6,311) LSRC
      GO TO 350
  340 VAL=1.0/(SYMVAL(MNAM,5)*VALUE(I))
      SENS=-(VNIM1(NODE1)-VNIM1(NODE4))*(VN(NODE1)-VN(NODE4))/(VAL*VAL)
      SENSN=VAL*SENS/100.0
      WRITE (6,71) LSRC,VAL,SENS,SENSN
C
C  EMITTER RESISTANCE (RE)
C
  350 IF (SYMVAL(MNAM,6).NE.0.0) GO TO 360
      WRITE (6,311) LSRE
      GO TO 370
  360 VAL=1.0/(SYMVAL(MNAM,6)*VALUE(I))
      SENS=-(VNIM1(NODE3)-VNIM1(NODE6))*(VN(NODE3)-VN(NODE6))/(VAL*VAL)
      SENSN=VAL*SENS/100.0
      WRITE (6,71) LSRE,VAL,SENS,SENSN
C
C  INTRINSIC PARAMETERS
C
  370 IF (KIND(MNAM).NE.1) GO TO 380
      TYPE=SYMVAL(MNAM,1)
      BF=SYMVAL(MNAM,2)
      BR=SYMVAL(MNAM,3)
      CSAT=SYMVAL(MNAM,12)*VALUE(I)
      OVA=SYMVAL(MNAM,15)
      VBE=TYPE*(VNIM1(NODE5)-VNIM1(NODE6))
      VBC=TYPE*(VNIM1(NODE5)-VNIM1(NODE4))
      EVBE=EXP(VBE/VT)
      EVBC=EXP(VBC/VT)
      VABE=TYPE*(VN(NODE5)-VN(NODE6))
      VABC=TYPE*(VN(NODE5)-VN(NODE4))
      VACE=VABE-VABC
C
C  SATURATION CURRENT (IS)
C
      SENS=VACE*((EVBE-EVBC)*(1.0-VBC*OVA)-(EVBC-1.0)/BR)
     1   +VABE*((EVBE-1.0)/BF+(EVBC-1.0)/BR)
      SENSN=CSAT*SENS/100.0
      WRITE (6,71) LSIS,CSAT,SENS,SENSN
C
C  CURRENT GAINS (BF,BR)
C
      SENS=-VABE*CSAT*(EVBE-1.0)/(BF*BF)
      SENSN=BF*SENS/100.0
      WRITE (6,71) LSBF,BF,SENS,SENSN
      SENS=-VABC*CSAT*(EVBC-1.0)/(BR*BR)
      SENSN=BR*SENS/100.0
      WRITE (6,71) LSBR,BR,SENS,SENSN
C
C  EARLY VOLTAGE (VA)
C
C
      IF (OVA.NE.0.0) GO TO 375
      WRITE (6,311) LSVA
      GO TO 380
  375 SENS=VACE*VBC*CSAT*(EVBE-EVBC)*OVA*OVA
      IF (ABS(SENS).LT.1.0E-35) SENS=0.0
      VA=1.0/OVA
      SENSN=VA*SENS/100.0
      WRITE (6,71) LSVA,VA,SENS,SENSN
  380 CONTINUE
C
C  DIODES
C
  400 ISTART=LOCATE(8)
      ISTOP=LOCATE(9)-1
      IF (ISTART.GT.ISTOP) GO TO 1000
      WRITE (6,61)
      DO 500 I=ISTART,ISTOP
      WRITE (6,301) NAME(I)
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      MNAM=MNAME(I)
C
C  SERIES RESISTANCE (RS)
C
      IF (SYMVAL(MNAM,1).NE.0.0) GO TO 410
      WRITE (6,311) LSRS
      GO TO 420
  410 VAL=1.0/(SYMVAL(MNAM,1)*VALUE(I))
      SENS=-(VNIM1(NODE1)-VNIM1(NODE3))*(VN(NODE1)-VN(NODE3))/(VAL*VAL)
      SENSN=VAL*SENS/100.0
      WRITE (6,71) LSRS,VAL,SENS,SENSN
C
C  INTRINSIC PARAMETERS
C
  420 CSAT=SYMVAL(MNAM,4)*VALUE(I)
      VTE=SYMVAL(MNAM,5)
      XNE=VTE/VT
      VBE=VNIM1(NODE3)-VNIM1(NODE2)
      EVBE=EXP(VBE/VTE)
      VABE=VN(NODE3)-VN(NODE2)
C
C  SATURATION CURRENT (IS)
C
      SENS=VABE*(EVBE-1.0)
      SENSN=CSAT*SENS/100.0
      WRITE (6,71) LSIS,CSAT,SENS,SENSN
C
C  IDEALITY FACTOR (N)
C
      SENS=-VABE*(CSAT/XNE)*(VBE/VTE)*EVBE
      IF (ABS(SENS).LT.1.0E-35) SENS=0.0
      SENSN=XNE*SENS/100.0
      WRITE (6,71) LSN,XNE,SENS,SENSN
  500 CONTINUE
 1000 CONTINUE
      RETURN
      END
      SUBROUTINE ACALC (IELNUM,CREAL)
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
C
C
      DIMENSION U(1)
      EQUIVALENCE (U(1),YNL(402))
C
C
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      SIGN=NODPLC(LOC+2)
      IPNOD=NODPLC(LOC+3)
      ISPOT=ICURNT(6)+2*(IELNUM-LOCATE(6))
      CREAL=TRACUR(ISPOT)-YNL(NODE1)*VN(NODE1)
      ISTART=IUR(IPNOD)
      ISTOP=IUR(IPNOD+1)-1
      IF (ISTART.GT.ISTOP) GO TO 20
      DO 10 I=ISTART,ISTOP
      IO=IUC(I)
      NODE3=IORDER(IO)
      CREAL=CREAL-U(I)*VN(NODE3)
   10 CONTINUE
   20 CREAL=SIGN*CREAL
      RETURN
      END
      SUBROUTINE TRANAN
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/MISCEL/NOGO,IGOOF,NOPRNT,IACCT,JOBNAM(16),RTIMES(15)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         7
      COMMON/OUTDAT/ROUT(101,10),FREQ(101),IONUM,IONAM(10),IOPND(10),
     1   IONND(10),IOFLG(10),NUMOR(3),IOVAR(10,2),IACVAR(5)
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
      COMMON/TRAN/JTRFLG,TSTEP,TSTOP,TSTART,NOTINT,STEPS(5),ENDPTS(5),
     1   KFROUT,FORFRE,KFPTS
C
C
      DATA LPRN /1H(/
      DIMENSION OUT1(10),OUT2(10)
C
C  INITIALIZE
C
      CALL SECOND(T1)
      KOUNT=0
      IGOOF=0
      IPASS1=1
      INTER=1
      DELTA=STEPS(1)
      TIMEE=0.0                                                                 6
      NUMOUT=NUMOR(2)
      DO 10 I=1,NUMOUT
   10 OUT2(I)=ROUT(1,I)
      IF (TSTART.GT.0.0) GO TO 20
      TNEXT=TSTEP
      ICALC=1
      GO TO 100
   20 TNEXT=TSTART
      ICALC=0
C
C  INCREMENT TIME, UPDATE SOURCES, AND SOLVE NEXT TIMEPOINT
C
  100 TIMEE=TIMEE+DELTA                                                         39
      CALL SORUPD
      CALL ITER8
      KOUNT=KOUNT+ITERNO
      IF (IGOOF.EQ.1) GO TO 1000
C
C  CHANGE DELTA IF NEXT INTERVAL IS ENTERED
C
      DELOLD=DELTA
  210 DEL1=ENDPTS(INTER)-TIMEE                                                  8
      IF (DEL1.GE.0.0) GO TO 220
      IF (INTER.GE.NOTINT) GO TO 300
      INTER=INTER+1
      DELTA=STEPS(INTER)
      GO TO 210
  220 IF (DEL1.GT.DELTA) GO TO 300
      IF (INTER.GE.NOTINT) GO TO 300
      DEL2=STEPS(INTER+1)
      IF (DELTA.LT.DEL2) DEL2=DELTA
      IF (DEL1.LT.DEL2) DEL1=DEL2
      DELTA=DEL1
C
C  STORE OUTPUT VARIABLES
C
  300 IF ((TIMEE+DELTA).LT.TNEXT) GO TO 370                                     3
      DO 320 I=1,NUMOUT
      IKNT=IOVAR(I,2)
      IPNOD=IOPND(IKNT)
      IF (IOFLG(IKNT).EQ.2) GO TO 310
      INNOD=IONND(IKNT)
      OUT1(I)=VNIM1(IPNOD)-VNIM1(INNOD)
      GO TO 320
  310 CALL CALCUR(IPNOD,OUT1(I))
  320 CONTINUE
C
C  LINEAR INTERPOLATION FOR OUTPUT VARIABLES
C
  330 IF (TIMEE.LT.TNEXT) GO TO 350                                             6
      ICALC=ICALC+1
      FREQ(ICALC)=TNEXT
      FRACT=(TIMEE-TNEXT)/DELOLD                                                9
      DO 340 I=1,NUMOUT
  340 ROUT(ICALC,I)=OUT1(I)+FRACT*(OUT2(I)-OUT1(I))
      TNEXT=TNEXT+TSTEP
      IF (ICALC-JTRFLG) 330,1100,1100
  350 DO 360 I=1,NUMOUT
  360 OUT2(I)=OUT1(I)
  370 MODE=4
      GO TO 100
C
C  NONCONVERGENCE TRAP
C
 1000 WRITE (6,1001) TIMEE                                                      1
 1001 FORMAT (1H1,4X,'----------  NO CONVERGENCE IN TRANSIENT '
     1   'ANALYSIS AT TIMEPOINT  ',1PE9.2//)
      WRITE (6,1011) ITERNO,IPASS1,IFINAL
 1011 FORMAT (5X,'ITERNO =  ',I3,5X,'IPASS1 =  ',I3,5X,'IFINAL =  ',I3//
     1   5X,'LAST NODE VOLTAGES'//1X,5(' NODE    VOLTAGE    ')//)
      WRITE (6,1021) (LPRN,JUNODE(I),VNIM1(I),I=2,NUNODS)
 1021 FORMAT (5(1X,A1,I3,1H),1X,F10.4,3X)/)
 1100 CALL SECOND(T2)
      RTIMES(8)=RTIMES(8)+T2-T1
      RTIMES(9)=RTIMES(9)+KOUNT
      RETURN
      END
      SUBROUTINE SORUPD
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         5
C
C
      DO 350 ID=4,6,2
      ISTART=LOCATE(ID)
      ISTOP=LOCATE(ID+1)-1
      IF (ISTART.GT.ISTOP) GO TO 350
      DO 300 I=ISTART,ISTOP
      MNAM=MNAME(I)
      ITYPE=SOURCE(MNAM+3)
      IF (ITYPE.EQ.0) GO TO 300
      GO TO (110,150,200),ITYPE
C
C  PULSE SOURCE
C
  110 V1=SOURCE(MNAM+5)
      V2=SOURCE(MNAM+6)
      T1=SOURCE(MNAM+7)
      T2=SOURCE(MNAM+8)
      T3=SOURCE(MNAM+9)
      T4=SOURCE(MNAM+10)
      PERIOD=SOURCE(MNAM+11)
      TIME1=TIMEE                                                               7
  115 IF (TIME1.LT.T1+PERIOD) GO TO 120
      TIME1=TIME1-PERIOD
      GO TO 115
  120 IF (TIME1.LT.T4) GO TO 125
      SOURCE(MNAM+2)=V1
      GO TO 300
  125 IF (TIME1.LT.T3) GO TO 130
      SOURCE(MNAM+2)=V2+(TIME1-T3)*(V1-V2)/(T4-T3)
      GO TO 300
  130 IF (TIME1.LT.T2) GO TO 135
      SOURCE(MNAM+2)=V2
      GO TO 300
  135 IF (TIME1.LT.T1) GO TO 140
      SOURCE(MNAM+2)=V1+(TIME1-T1)*(V2-V1)/(T2-T1)
      GO TO 300
  140 SOURCE(MNAM+2)=V1
      GO TO 300
C
C  EXPONENTIAL SOURCE
C
  150 V1=SOURCE(MNAM+5)
      V2=SOURCE(MNAM+6)
      T1=SOURCE(MNAM+7)
      TAU1=SOURCE(MNAM+8)
      T2=SOURCE(MNAM+9)
      TAU2=SOURCE(MNAM+10)
      TIME1=TIMEE                                                               4
      IF (TIME1.GT.T1) GO TO 155
      SOURCE(MNAM+2)=V1
      GO TO 300
  155 IF (TIME1.GT.T2) GO TO 160
      SOURCE(MNAM+2)=V1+(V2-V1)*(1.0-EXP((T1-TIME1)/TAU1))
      GO TO 300
  160 SOURCE(MNAM+2)=V1+(V2-V1)*(1.0-EXP((T1-TIME1)/TAU1))
     1   +(V1-V2)*(1.0-EXP((T2-TIME1)/TAU2))
      GO TO 300
C
C  SINUSOIDAL SOURCE
C
  200 V1=SOURCE(MNAM+5)
      V2=SOURCE(MNAM+6)
      T1=SOURCE(MNAM+7)
      THETA=SOURCE(MNAM+8)
      OMEG=SOURCE(MNAM+9)
      TIME1=TIMEE-T1                                                            2
      IF (TIME1.GT.0.0) GO TO 220
      SOURCE(MNAM+2)=V1
      GO TO 300
  220 SOURCE(MNAM+2)=V1+V2*(EXP(-TIME1*THETA))*SIN(OMEG*TIME1)
  300 CONTINUE
  350 CONTINUE
      RETURN
      END
      SUBROUTINE CALCUR(IELNUM,CREAL)
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
C
C
      DIMENSION UL(1)
      EQUIVALENCE (UL(1),YNL(1202))
C
C
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      IPNOD=NODPLC(LOC+3)
      IF (IELNUM.LT.LOCATE(6)) GO TO 10
      ISPOT=ICURNT(6)+2*(IELNUM-LOCATE(6))
      SIGN=NODPLC(LOC+2)
      GO TO 20
   10 ISPOT=ICURNT(3)+2*(IELNUM-LOCATE(3))
      SIGN=1.0
   20 CREAL=TRACUR(ISPOT)-YNL(NODE1)*VN(NODE1)
      ISTART=IUR(IPNOD)
      ISTOP=IUR(IPNOD+1)-1
      IF (ISTART.GT.ISTOP) GO TO 40
      DO 30 I=ISTART,ISTOP
      J=IUC(I)
      JO=IORDER(J)
      CREAL=CREAL-UL(I)*VN(JO)
   30 CONTINUE
   40 CREAL=SIGN*CREAL
      RETURN
      END
      SUBROUTINE LOAD
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/MISCEL/NOGO,IGOOF,NOPRNT,IACCT,JOBNAM(16),RTIMES(15)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         8
      COMMON/POINTS/IUS,ILS,MIRROR,NSTOP,NUMVS,LASTUT,LASTLT
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
C
C
      DIMENSION U(1),UL(1)
      EQUIVALENCE (U(1),YNL(402)),(UL(1),YNL(1202))
      DIMENSION VCAP(1),VIND(1),CCAP(1),CIND(1)
      EQUIVALENCE (VCAP(1),VIND(1),TRACUR(1))
      EQUIVALENCE (CCAP(1),CIND(1),TRACUR(2))
C
C
      IFIND=NUMVS
C
C  RESISTORS
C
      ISTOP=LOCATE(2)-1
      IF (ISTOP.LT.1) GO TO 20
      DO 10 I=1,ISTOP
      LOC=LOCAL(I)
      VAL=VALUE(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=MATLOC(IFIND+1)
      LOC4=MATLOC(IFIND+2)
      IFIND=IFIND+2
      YNL(LOC1)=YNL(LOC1)+VAL
      YNL(LOC2)=YNL(LOC2)+VAL
      YNL(LOC3)=YNL(LOC3)-VAL
      YNL(LOC4)=YNL(LOC4)-VAL
   10 CONTINUE
C
C  CAPACITORS
C
   20 IF (MODE.GT.1) GO TO 25
      IFIND=IFIND+2*JELCNT(2)
      GO TO 100
   25 ISTART=LOCATE(2)
      ISTOP=LOCATE(3)-1
      IF (ISTART.GT.ISTOP) GO TO 60
      ISPOT=ICURNT(2)
      DO 50 I=ISTART,ISTOP
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=MATLOC(IFIND+1)
      LOC4=MATLOC(IFIND+2)
      IFIND=IFIND+2
      IF (MODE.EQ.3) GO TO 40
      GEQ=VALUE(I)*2.0/DELOLD
      CEQ=VCAP(ISPOT)*GEQ+CCAP(ISPOT)
      VCAP(ISPOT)=VNIM1(LOC1)-VNIM1(LOC2)
      CCAP(ISPOT)=VCAP(ISPOT)*GEQ-CEQ
   40 GEQ=VALUE(I)*2.0/DELTA
      CEQ=VCAP(ISPOT)*GEQ+CCAP(ISPOT)
      ISPOT=ISPOT+2
      VN(LOC1)=VN(LOC1)+CEQ
      VN(LOC2)=VN(LOC2)-CEQ
      YNL(LOC1)=YNL(LOC1)+GEQ
      YNL(LOC2)=YNL(LOC2)+GEQ
      YNL(LOC3)=YNL(LOC3)-GEQ
      YNL(LOC4)=YNL(LOC4)-GEQ
   50 CONTINUE
C
C  INDUCTORS
C
   60 ISTART=LOCATE(3)
      ISTOP=LOCATE(4)-1
      IF (ISTART.GT.ISTOP) GO TO 100
      ISPOT=ICURNT(3)
      DO 90 I=ISTART,ISTOP
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=MATLOC(IFIND+1)
      LOC4=MATLOC(IFIND+2)
      IFIND=IFIND+2
      IF (MODE.EQ.3) GO TO 80
      GEQ=VALUE(I)*DELOLD/2.0
      CEQ=-VIND(ISPOT)*GEQ-CIND(ISPOT)
      VIND(ISPOT)=VNIM1(LOC1)-VNIM1(LOC2)
      CIND(ISPOT)=VIND(ISPOT)*GEQ-CEQ
   80 GEQ=VALUE(I)*DELTA/2.0
      CEQ=-VIND(ISPOT)*GEQ-CIND(ISPOT)
      ISPOT=ISPOT+2
      VN(LOC1)=VN(LOC1)+CEQ
      VN(LOC2)=VN(LOC2)-CEQ
      YNL(LOC1)=YNL(LOC1)+GEQ
      YNL(LOC2)=YNL(LOC2)+GEQ
      YNL(LOC3)=YNL(LOC3)-GEQ
      YNL(LOC4)=YNL(LOC4)-GEQ
   90 CONTINUE
C
C  VOLTAGE DEPENDENT CURRENT SOURCES
C
  100 ISTART=LOCATE(5)
      ISTOP=LOCATE(6)-1
      IF (ISTART.GT.ISTOP) GO TO 500
      DO 120 I=ISTART,ISTOP
      LOC1=MATLOC(IFIND+1)
      LOC2=MATLOC(IFIND+2)
      LOC3=MATLOC(IFIND+3)
      LOC4=MATLOC(IFIND+4)
      IFIND=IFIND+4
      VAL=VALUE(I)
      YNL(LOC1)=YNL(LOC1)+VAL
      YNL(LOC2)=YNL(LOC2)-VAL
      YNL(LOC3)=YNL(LOC3)-VAL
      YNL(LOC4)=YNL(LOC4)+VAL
  120 CONTINUE
C
C  CALL DEVICE MODEL ROUTINES
C
  500 CALL BJT
      CALL DIODE
      CALL JFET
      CALL MOSFET
C
C  CURRENT SOURCES
C
      IF (MODE.GT.3) MODE=3
      ISTART=LOCATE(4)
      ISTOP=LOCATE(5)-1
      IF (ISTART.GT.ISTOP) GO TO 600
      DO 520 I=ISTART,ISTOP
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      VAL=SOURCE(MNAM+MODE-1)
      VN(NODE1)=VN(NODE1)-VAL
      VN(NODE2)=VN(NODE2)+VAL
  520 CONTINUE
C
C  VOLTAGE SOURCES (AND INDUCTORS IN DC ANALYSIS)
C
  600 IF (NUMVS.EQ.0) RETURN
      DO 900 I=1,NUMVS
      IELNUM=MATLOC(I)
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      SIGN=NODPLC(LOC+2)
      IPNOD=NODPLC(LOC+3)
      INNOD=NODPLC(LOC+4)
C
C  ALTER Y MATRIX
C
      JSTART=IUR(IPNOD)
      JSTOP=IUR(IPNOD+1)-1
      IF (NODE2.EQ.1) GO TO 800
      YNL(NODE2)=YNL(NODE2)+YNL(NODE1)
      IF (JSTART.GT.JSTOP) GO TO 800
      DO 700 J=JSTART,JSTOP
C
C  FOR EACH (N+,I) TERM, FIND THE CORRESPONDING (N-,I) TERM
C
      JO=IUC(J)
      IF (INNOD-JO) 650,610,620
C
C  DIAGONAL (N-,N-) TERM
C
  610 YNL(NODE2)=YNL(NODE2)+U(J)+UL(J)
      GO TO 700
C
C  UPPER TRIANGLE (INNOD,JO) TERM  INNOD.LT.JO OR INNOD A SOURCE NODE
C
  620 KFLAG=1
      IF (INNOD.LE.NSTOP) GO TO 660
  630 K=IUR(INNOD+1)
      KSTOP=IUR(INNOD)
  640 K=K-1
      IF (K.LT.KSTOP) GO TO 1000
      IF (IUC(K).NE.JO) GO TO 640
      IF (KFLAG) 690,1000,680
C
C  LOWER TRIANGLE (JO,INNOD) TERM  JO.LT.INNOD OR JO A SOURCE NODE
C
  650 KFLAG=-1
      IF (JO.LE.NSTOP) GO TO 630
  660 K=IUR(JO+1)
      KSTOP=IUR(JO)
  670 K=K-1
      IF (K.LT.KSTOP) GO TO 1000
      IF (IUC(K).NE.INNOD) GO TO 670
      IF (KFLAG) 690,1000,680
C
C  ADD LOWER N+ TERM TO LOWER N- TERM AND UPPER N+ TERM TO
C  UPPER N- TERM
C
  680 U(K)=U(K)+U(J)
      UL(K)=UL(K)+UL(J)
      GO TO 700
C
C  ADD LOWER N+ TERM TO UPPER N- TERM AND UPPER N+ TERM TO
C  LOWER N- TERM
C
  690 U(K)=U(K)+UL(J)
      UL(K)=UL(K)+U(J)
  700 CONTINUE
C
C  ALTER CURRENT VECTOR
C
  800 IF (IELNUM.LT.LOCATE(6)) GO TO 810
      MNAM=MNAME(IELNUM)
      VAL=SIGN*SOURCE(MNAM+MODE-1)
      GO TO 820
  810 VAL=0.0
  820 VN(NODE2)=VN(NODE2)+VN(NODE1)-YNL(NODE1)*VAL
      IF (VAL) 830,900,830
  830 IF (JSTART.GT.JSTOP) GO TO 900
      DO 850 J=JSTART,JSTOP
      JO=IUC(J)
      NODE3=IORDER(JO)
      VN(NODE3)=VN(NODE3)-U(J)*VAL
  850 CONTINUE
  900 CONTINUE
      RETURN
 1000 IGOOF=1
      WRITE (6,1001)
 1001 FORMAT (//5X,'----------  PROGRAM ERROR ... LOAD'//)
      RETURN
      END
      SUBROUTINE JUNCT(VNEW,VOLD,CSAT,VTE)
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
C
C
      VLIM1=10.0*VTE
      VLIM2=2.0*VTE
      DELV=VNEW-VOLD
      IF (ABS(DELV).LT.VLIM2) GO TO 30
      IF (DELV.LT.0.0) GO TO 10
      IF (VNEW.LT.VLIM1) GO TO 30
      VNEW=VOLD+VLIM2
      IF (VNEW.LT.VLIM1) VNEW=VLIM1
      GO TO 20
   10 IF (VOLD.LT.VLIM1) GO TO 30
      VNEW=VOLD-VLIM2
   20 IFINAL=0
   30 RETURN
      END
      SUBROUTINE BJT
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/MODELS/NUMMOD,MODNAM(25),KIND(25)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         8
      COMMON/KNSTNT/TWOPI,XLOG2,XLOG10,RAD,BOLTZ,CHARGE,VT
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
C
C
      DIMENSION VBEO(1),VBCO(1),CJBE(1),CJBC(1),VCCS(1),CCCS(1)
      EQUIVALENCE (VBEO(1),TRACUR(1)),(VBCO(1),TRACUR(2)),
     1   (CJBE(1),TRACUR(3)),(CJBC(1),TRACUR(4)),(VCCS(1),TRACUR(5)),
     2   (CCCS(1),TRACUR(6))
C
C
      ISTART=LOCATE(7)
      ISTOP=LOCATE(8)-1
      IF (ISTART.GT.ISTOP) RETURN
      ISPOT=ICURNT(7)
      DO 1000 I=ISTART,ISTOP
C
C  LOOKUP MATRIX POINTERS
C
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=NODPLC(LOC+2)
      LOC4=NODPLC(LOC+3)
      LOC5=NODPLC(LOC+4)
      LOC6=NODPLC(LOC+5)
      IF (MODE.EQ.2) GO TO 50
      LOC7=MATLOC(IFIND+1)
      LOC8=MATLOC(IFIND+2)
      LOC9=MATLOC(IFIND+3)
      LOC10=MATLOC(IFIND+4)
      LOC11=MATLOC(IFIND+5)
      LOC12=MATLOC(IFIND+6)
      LOC13=MATLOC(IFIND+7)
      LOC14=MATLOC(IFIND+8)
      LOC15=MATLOC(IFIND+9)
      LOC16=MATLOC(IFIND+10)
      LOC17=MATLOC(IFIND+11)
      LOC18=MATLOC(IFIND+12)
      IFIND=IFIND+12
C
C  DC ANALYSIS
C
   50 TYPE=SYMVAL(MNAM,1)
      GBPR=SYMVAL(MNAM,4)*VALUE(I)
      GCPR=SYMVAL(MNAM,5)*VALUE(I)
      GEPR=SYMVAL(MNAM,6)*VALUE(I)
      CSAT=SYMVAL(MNAM,12)*VALUE(I)
C
C  INITIALIZE JUNCTIONS ON FIRST DC PASS
C
      IF (IPASS1.EQ.0) GO TO 60
      IF (MODE.GT.1) GO TO 60
      VBE=VT*ALOG(VT/(1.414*CSAT))
      VBC=-1.0
      GO TO 70
   60 VBE=TYPE*(VNIM1(LOC5)-VNIM1(LOC6))
      VBC=TYPE*(VNIM1(LOC5)-VNIM1(LOC4))
      IF (IPASS1.EQ.1) GO TO 70
      CALL JUNCT(VBE,VBEO(ISPOT),CSAT,VT)
      CALL JUNCT(VBC,VBCO(ISPOT),CSAT,VT)
   70 VBEO(ISPOT)=VBE
      VBCO(ISPOT)=VBC
C
C  EBERS-MOLL TRANSISTOR MODEL
C
   80 IF (KIND(MNAM).EQ.2) GO TO 200
      BF=SYMVAL(MNAM,2)
      BR=SYMVAL(MNAM,3)
      OVA=SYMVAL(MNAM,15)
C
C  COMPUTE EQUIVALENT DC CONDUCTANCES
C
      IF (VBE.GT.0.0) GO TO 82
      EVBE=1.0
      CBE=CSAT*VBE/VT
      GO TO 84
   82 EVBE=EXP(VBE/VT)
      CBE=CSAT*(EVBE-1.0)
   84 IF (VBC.GT.0.0) GO TO 86
      EVBC=1.0
      CBC=CSAT*VBC/VT
      GO TO 88
   86 EVBC=EXP(VBC/VT)
      CBC=CSAT*(EVBC-1.0)
   88 FVA=1.0-OVA*VBC
      GSAT=CSAT/VT
      GPI=(GSAT/BF)*EVBE+GMIN
      GMU=(GSAT/BR)*EVBC+GMIN
      GO=(CBE-CBC)*OVA+GSAT*EVBC*FVA
      GM=GSAT*EVBE*FVA-GO
      GMPGO=GM+GO
      CC=(CBE-CBC)*FVA-CBC/BR-GMIN*VBC
      CB=CBE/BF+CBC/BR+GMIN*(VBE+VBC)
      CEQBC=TYPE*(CC-VBE*(GMPGO)+VBC*(GMU+GO))
      CEQBE=TYPE*(-CC-CB+VBE*GMPGO+VBE*GPI-VBC*GO)
      IF (MODE.EQ.1) GO TO 400
C
C  CHARGE STORAGE ELEMENTS
C
  110 CCS=SYMVAL(MNAM,7)*VALUE(I)
      TF=SYMVAL(MNAM,8)
      TR=SYMVAL(MNAM,9)
      CZBE=SYMVAL(MNAM,10)*VALUE(I)
      CZBC=SYMVAL(MNAM,11)*VALUE(I)
      PE=SYMVAL(MNAM,13)
      PC=SYMVAL(MNAM,14)
      IF (VBE.GE.0.0) GO TO 112
      SARG=SQRT(1.0-VBE/PE)
      CTBE=2.0*(TF*CBE+2.0*PE*CZBE*(1.0-SARG))/DELTA
      CAPBE=TF*CSAT/VT+CZBE/SARG
      GO TO 114
  112 CTBE=2.0*(TF*CBE+VBE*CZBE*(1.0+VBE/(4.0*PE)))/DELTA
      CAPBE=TF*CSAT*EVBE/VT+CZBE*(1.0+VBE/(2.0*PE))
  114 IF (VBC.GE.0.0) GO TO 116
      SARG=SQRT(1.0-VBC/PC)
      CTBC=2.0*(TR*CBC+2.0*PC*CZBC*(1.0-SARG))/DELTA
      CAPBC=TR*CSAT/VT+CZBC/SARG
      GO TO 320
  116 CTBC=2.0*(TR*CBC+VBC*CZBC*(1.0+VBC/(4.0*PC)))/DELTA
      CAPBC=TR*CSAT*EVBC/VT+CZBC*(1.0+VBC/(2.0*PC))
      GO TO 320
C
C  GUMMEL-POON TRANSISTOR MODEL
C
  200 C1=SYMVAL(MNAM,2)
      C3=SYMVAL(MNAM,3)
      OVA=SYMVAL(MNAM,13)
      OVB=SYMVAL(MNAM,14)
      C2=SYMVAL(MNAM,15)
      OIK=SYMVAL(MNAM,16)/VALUE(I)
      VTE=SYMVAL(MNAM,17)
      C4=SYMVAL(MNAM,18)
      OIKR=SYMVAL(MNAM,19)/VALUE(I)
      VTC=SYMVAL(MNAM,20)
      IF (VBE.GT.0.0) GO TO 202
      EVE=1.0
      EVEN=1.0
      CBE=CSAT*VBE/VT
      CBEN=CSAT*VBE/VTE
      GO TO 204
  202 EVE=EXP(VBE/VT)
      EVEN=EXP(VBE/VTE)
      CBE=CSAT*(EVE-1.0)
      CBEN=CSAT*(EVEN-1.0)
  204 IF (VBC.GT.0.0) GO TO 206
      EVC=1.0
      EVCN=1.0
      CBC=CSAT*VBC/VT
      CBCN=CSAT*VBC/VTC
      GO TO 208
  206 EVC=EXP(VBC/VT)
      EVCN=EXP(VBC/VTC)
      CBC=CSAT*(EVC-1.0)
      CBCN=CSAT*(EVCN-1.0)
C
C  DETERMINE BASE CHARGE TERMS
C
  208 Q1=1.0+OVA*VBC+OVB*VBE
      Q2=OIK*CBE+OIKR*CBC
      SQARG=SQRT(Q1*Q1+4.*Q2)
      QB=(Q1+SQARG)/2.
      DQBDVE=(OVB+(1.0/SQARG)*(Q1*OVB+2.0*OIK*CSAT*EVE/VT))/2.0
      DQBDVC=(OVA+(1.0/SQARG)*(Q1*OVA+2.0*OIKR*CSAT*EVC/VT))/2.0
      IF (QB.GT.1.0E-5) GO TO 210
      QB=1.E-5
      DQBDVE=0.
      DQBDVC=0.
C
C  DETERMINE DC INCREMENTAL CONDUCTANCES
C
  210 CC=(CBE-CBC)/QB-C3*CBC-C4*CBCN-GMIN*VBC
      CB=C1*CBE+C2*CBEN+C3*CBC+C4*CBCN+GMIN*(VBE+VBC)
      GPI=CSAT*((C1/VT)*EVE+(C2/VTE)*EVEN)+GMIN
      GMU=CSAT*((C3/VT)*EVC+(C4/VTC)*EVCN)+GMIN
      GO=(CSAT*EVC/VT+(CBE-CBC)*DQBDVC/QB)/QB
      GM=(CSAT*EVE/VT-(CBE-CBC)*DQBDVE/QB)/QB-GO
      GMPGO=GM+GO
      CEQBC=TYPE*(CC-VBE*(GMPGO)+VBC*(GMU+GO))
      CEQBE=TYPE*(-CC-CB+VBE*GMPGO+VBE*GPI-VBC*GO)
      IF (MODE.EQ.1) GO TO 400
C
C  CHARGE STORAGE ELEMENTS
C
  310 CCS=SYMVAL(MNAM,7)*VALUE(I)
      TF=SYMVAL(MNAM,8)
      TR=SYMVAL(MNAM,9)
      CZBE=SYMVAL(MNAM,10)*VALUE(I)
      CZBC=SYMVAL(MNAM,11)*VALUE(I)
      PE=SYMVAL(MNAM,21)
      XME=SYMVAL(MNAM,22)
      PC=SYMVAL(MNAM,23)
      XMC=SYMVAL(MNAM,24)
      IF (VBE.GE.0.0) GO TO 312
      ARG=1.0-VBE/PE
      SARG=EXP(XME*ALOG(ARG))
      CTBE=2.0*(TF*CBE+PE*CZBE*(1.0-ARG/SARG)/(1.0-XME))/DELTA
      CAPBE=TF*CSAT/VT+CZBE/SARG
      GO TO 314
  312 CTBE=2.0*(TF*CBE+VBE*CZBE*(1.0+XME*VBE/(2.0*PE)))/DELTA
      CAPBE=TF*CSAT*EVE/VT+CZBE*(1.0+XME*VBE/PE)
  314 IF (VBC.GE.0.0) GO TO 316
      ARG=1.0-VBC/PC
      SARG=EXP(XMC*ALOG(ARG))
      CTBC=2.0*(TR*CBC+PC*CZBC*(1.0-ARG/SARG)/(1.0-XMC))/DELTA
      CAPBC=TR*CSAT/VT+CZBC/SARG
      GO TO 320
  316 CTBC=2.0*(TR*CBC+VBC*CZBC*(1.0+XMC*VBC/(2.0*PC)))/DELTA
      CAPBC=TR*CSAT*EVC/VT+CZBC*(1.0+XMC*VBC/PC)
C
C  SMALL SIGNAL PARAMETERS
C
  320 IF (MODE.GT.2) GO TO 350
      TRACUR(ISPOT+2)=CC
      TRACUR(ISPOT+3)=CB
      TRACUR(ISPOT+4)=GPI
      TRACUR(ISPOT+5)=CAPBE
      TRACUR(ISPOT+6)=GMU
      TRACUR(ISPOT+7)=CAPBC
      TRACUR(ISPOT+8)=GM
      TRACUR(ISPOT+9)=GO
      GO TO 900
C
C  TRANSIENT ANALYSIS
C
  350 IF (IPASS1.EQ.0) GO TO 360
      CJBE(ISPOT)=CTBE
      CJBC(ISPOT)=CTBC
      VCCS(ISPOT)=VNIM1(LOC4)
      CCCS(ISPOT)=0.0
C
C  UPDATE ON FIRST ITERATION OF EACH TIMEPOINT
C
  360 IF (MODE.EQ.3) GO TO 370
      CJBE(ISPOT)=CTBE*(1.0+DELTA/DELOLD)-CJBE(ISPOT)
      CJBC(ISPOT)=CTBC*(1.0+DELTA/DELOLD)-CJBC(ISPOT)
      CCCS(ISPOT)=(2.0*CCS/DELOLD)*(VNIM1(LOC4)-VCCS(ISPOT))-CCCS(ISPOT)
      VCCS(ISPOT)=VNIM1(LOC4)
C
C  COMPUTE CAPACITOR EQUIVALENT CONDUCTANCES AND CURRENT SOURCES
C
  370 GTEMP=2.0*CAPBE/DELTA
      GPI=GPI+GTEMP
      CEQBE=CEQBE+TYPE*(GTEMP*VBE-CTBE+CJBE(ISPOT))
      GTEMP=2.0*CAPBC/DELTA
      GMU=GMU+GTEMP
      CEQBC=CEQBC+TYPE*(GTEMP*VBC-CTBC+CJBC(ISPOT))
      GCCS=2.0*CCS/DELTA
      CEQCS=GCCS*VCCS(ISPOT)+CCCS(ISPOT)
      GO TO 500
C
C  ZERO TRANSIENT CONDUCTANCES DURING DC ANALYSIS
C
  400 GCCS=0.0
      CEQCS=0.0
C
C  LOAD CURRENT EXCITATION VECTOR
C
  500 VN(LOC4)=VN(LOC4)+CEQCS-CEQBC
      VN(LOC5)=VN(LOC5)+CEQBC+CEQBE
      VN(LOC6)=VN(LOC6)-CEQBE
C
C  LOAD Y MATRIX, REAL TERMS
C
      YNL(LOC1)=YNL(LOC1)+GCPR
      YNL(LOC2)=YNL(LOC2)+GBPR
      YNL(LOC3)=YNL(LOC3)+GEPR
      YNL(LOC4)=YNL(LOC4)+GMU+GO+GCPR+GCCS
      YNL(LOC5)=YNL(LOC5)+GBPR+GPI+GMU
      YNL(LOC6)=YNL(LOC6)+GPI+GEPR+GMPGO
      YNL(LOC7)=YNL(LOC7)-GCPR
      YNL(LOC8)=YNL(LOC8)-GBPR
      YNL(LOC9)=YNL(LOC9)-GEPR
      YNL(LOC10)=YNL(LOC10)-GCPR
      YNL(LOC11)=YNL(LOC11)-GMU+GM
      YNL(LOC12)=YNL(LOC12)-GMPGO
      YNL(LOC13)=YNL(LOC13)-GBPR
      YNL(LOC14)=YNL(LOC14)-GMU
      YNL(LOC15)=YNL(LOC15)-GPI
      YNL(LOC16)=YNL(LOC16)-GEPR
      YNL(LOC17)=YNL(LOC17)-GO
      YNL(LOC18)=YNL(LOC18)-GPI-GM
  900 ISPOT=ISPOT+15
 1000 CONTINUE
      RETURN
      END
      SUBROUTINE DIODE
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         7
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
C
C
      DIMENSION VDO(1),CJN(1)
      EQUIVALENCE (VDO(1),TRACUR(1)),(CJN(1),TRACUR(2))
C
C
      ISTART=LOCATE(8)
      ISTOP=LOCATE(9)-1
      IF (ISTART.GT.ISTOP) RETURN
      ISPOT=ICURNT(8)
      DO 1000 I=ISTART,ISTOP
C
C  LOOKUP MATRIX POINTERS
C
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=NODPLC(LOC+2)
      IF (MODE.EQ.2) GO TO 50
      LOC4=MATLOC(IFIND+1)
      LOC5=MATLOC(IFIND+2)
      LOC6=MATLOC(IFIND+3)
      LOC7=MATLOC(IFIND+4)
      IFIND=IFIND+4
C
C
C  DC ANALYSIS
C
   50 GSPR=SYMVAL(MNAM,1)*VALUE(I)
      CSAT=SYMVAL(MNAM,4)*VALUE(I)
      VTE=SYMVAL(MNAM,5)
C
C  INITIALIZE ON FIRST DC PASS
C
      IF (IPASS1.EQ.0) GO TO 60
      IF (MODE.GT.1) GO TO 60
      VD=VTE*ALOG(VTE/(1.414*CSAT))
      GO TO 70
C
C  COMPUTE NEW JUNCTION VOLTAGE
C
   60 VD=VNIM1(LOC3)-VNIM1(LOC2)
      IF (IPASS1.EQ.1) GO TO 70
      CALL JUNCT(VD,VDO(ISPOT),CSAT,VTE)
   70 VDO(ISPOT)=VD
C
C  COMPUTE EQUIVALENT DC CONDUCTANCES
C
   80 IF (VD.GT.0.0) GO TO 82
      EVD=1.0
      GEQ=CSAT/VTE+GMIN
      CD=GEQ*VD
      CDEQ=0.0
      GO TO 84
   82 EVD=EXP(VD/VTE)
      CD=CSAT*(EVD-1.0)+GMIN*VD
      GEQ=CSAT*EVD/VTE+GMIN
      CDEQ=GEQ*VD-CD
   84 IF (MODE.EQ.1) GO TO 500
C
C  CHARGE STORAGE ELEMENTS
C
  310 TAU=SYMVAL(MNAM,2)
      CZERO=SYMVAL(MNAM,3)*VALUE(I)
      PHIB=SYMVAL(MNAM,6)
      IF (VD.GE.0.0) GO TO 312
      SARG=SQRT(1.0-VD/PHIB)
      CTEMP=2.0*(TAU*CSAT*VD/VTE+2.0*PHIB*CZERO*(1.0-SARG))/DELTA
      CAPD=TAU*CSAT/VTE+CZERO/SARG
      GO TO 320
  312 CTEMP=2.0*(TAU*CSAT*(EVD-1.0)+VD*CZERO*(1.0+VD/(4.0*PHIB)))/DELTA
      CAPD=TAU*CSAT*EVD/VTE+CZERO*(1.0+VD/(2.0*PHIB))
C
C  SMALL SIGNAL PARAMETERS
C
  320 IF (MODE.GT.2) GO TO 350
      TRACUR(ISPOT+1)=CD
      TRACUR(ISPOT+2)=GEQ
      TRACUR(ISPOT+3)=CAPD
      GO TO 900
C
C  TRANSIENT ANALYSIS
C
  350 IF (IPASS1.EQ.0) GO TO 360
      CJN(ISPOT)=CTEMP
C
C  UPDATE AT FIRST ITERATION OF NEW TIMEPOINT
C
  360 IF (MODE.EQ.3) GO TO 370
      CJN(ISPOT)=CTEMP*(1.0+DELTA/DELOLD)-CJN(ISPOT)
C
C  COMPUTE CAPACITOR CONDUCTANCE AND EQUIVALENT CURRENT SOURCE
C
  370 GTEMP=2.0*CAPD/DELTA
      GEQ=GEQ+GTEMP
      CDEQ=CDEQ+GTEMP*VD+CJN(ISPOT)-CTEMP
C
C  LOAD CURRENT VECTOR
C
  500 VN(LOC2)=VN(LOC2)-CDEQ
      VN(LOC3)=VN(LOC3)+CDEQ
C
C  LOAD MATRIX
C
      YNL(LOC1)=YNL(LOC1)+GSPR
      YNL(LOC2)=YNL(LOC2)+GEQ
      YNL(LOC3)=YNL(LOC3)+GEQ+GSPR
      YNL(LOC4)=YNL(LOC4)-GSPR
      YNL(LOC5)=YNL(LOC5)-GEQ
      YNL(LOC6)=YNL(LOC6)-GSPR
      YNL(LOC7)=YNL(LOC7)-GEQ
  900 ISPOT=ISPOT+5
 1000 CONTINUE
      RETURN
      END
      SUBROUTINE FETLIM(VNEW,VOLD,VTO)
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
C
C
      VLIM2=0.1+ABS(VTO)
      DELV=VNEW-VOLD
      IF (ABS(DELV).LT.VLIM2) GO TO 30
      IF (DELV.LT.0.0) GO TO 10
      IF (VNEW.LT.VTO) GO TO 30
      VNEW=VOLD+VLIM2
      IF (VNEW.LT.VTO) VNEW=VTO
      GO TO 20
   10 IF (VOLD.LT.VTO) GO TO 30
      VNEW=VOLD-VLIM2
   20 IFINAL=0
   30 RETURN
      END
      SUBROUTINE JFET
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         7
      COMMON/KNSTNT/TWOPI,XLOG2,XLOG10,RAD,BOLTZ,CHARGE,VT
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
C
C
      DIMENSION VGSO(1),VGDO(1),CDRO(1),CJGS(1),CJGD(1)
      EQUIVALENCE (VGSO(1),TRACUR(1)),(VGDO(1),TRACUR(2)),
     1   (CDRO(1),TRACUR(3)),(CJGS(1),TRACUR(4)),(CJGD(1),TRACUR(5))
C
C
      ISTART=LOCATE(9)
      ISTOP=LOCATE(10)-1
      IF (ISTART.GT.ISTOP) RETURN
      ISPOT=ICURNT(9)
      DO 1000 I=ISTART,ISTOP
C
C  LOOKUP MATRIX POINTERS
C
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=NODPLC(LOC+2)
      LOC4=NODPLC(LOC+3)
      LOC5=NODPLC(LOC+4)
      IF (MODE.EQ.2) GO TO 50
      LOC6=MATLOC(IFIND+1)
      LOC7=MATLOC(IFIND+2)
      LOC8=MATLOC(IFIND+3)
      LOC9=MATLOC(IFIND+4)
      LOC10=MATLOC(IFIND+5)
      LOC11=MATLOC(IFIND+6)
      LOC12=MATLOC(IFIND+7)
      LOC13=MATLOC(IFIND+8)
      LOC14=MATLOC(IFIND+9)
      LOC15=MATLOC(IFIND+10)
      IFIND=IFIND+10
C
C  DC ANALYSIS
C
   50 TYPE=SYMVAL(MNAM,1)
      VTO=SYMVAL(MNAM,2)
      BETA=SYMVAL(MNAM,3)*VALUE(I)
      XLAMB=SYMVAL(MNAM,4)
      GDPR=SYMVAL(MNAM,5)*VALUE(I)
      GSPR=SYMVAL(MNAM,6)*VALUE(I)
      CSAT=SYMVAL(MNAM,10)
C
C  INITIALIZE ON FIRST DC PASS
C
      IF (IPASS1.EQ.0) GO TO 60
      IF (MODE.GT.1) GO TO 60
      CDRO(ISPOT)=0.0
      VGS=-1.0
      VGD=-1.0
      GO TO 70
C
C  COMPUTE INTERNAL BRANCH VOLTAGES AND GATE JUNCTION MODELS
C
   60 VGS=TYPE*(VNIM1(LOC2)-VNIM1(LOC5))
      VGD=TYPE*(VNIM1(LOC2)-VNIM1(LOC4))
      IF (IPASS1.EQ.1) GO TO 70
      CALL JUNCT(VGS,VGSO(ISPOT),CSAT,VT)
      CALL JUNCT(VGD,VGDO(ISPOT),CSAT,VT)
      CALL FETLIM(VGS,VGSO(ISPOT),VTO)
      CALL FETLIM(VGD,VGDO(ISPOT),VTO)
   70 VGSO(ISPOT)=VGS
      VGDO(ISPOT)=VGD
      VDS=VGS-VGD
C
C  COMPUTE GATE JUNCTION CONDUCTANCES
C
   80 IF (VGS.GT.0.0) GO TO 82
      GGS=CSAT/VT+GMIN
      CGSJ=GGS*VGS
      CEQGS=0.0
      GO TO 84
   82 ARG=EXP(VGS/VT)
      CGSJ=CSAT*(ARG-1.0)+GMIN*VGS
      GGS=CSAT*ARG/VT+GMIN
      CEQGS=TYPE*(VGS*GGS-CGSJ)
   84 IF (VGD.GT.0.0) GO TO 86
      GGD=CSAT/VT+GMIN
      CGDJ=GGD*VGD
      CEQGD=0.0
      GO TO 100
   86 ARG=EXP(VGD/VT)
      CGDJ=CSAT*(ARG-1.0)+GMIN*VGD
      GGD=CSAT*ARG/VT+GMIN
      CEQGD=TYPE*(VGD*GGD-CGDJ)
C
C  COMPUTE DRAIN CURRENT AND DERIVITIVES FOR NORMAL MODE
C
  100 IF (VDS.LT.0.0) GO TO 200
      VGST=VGS-VTO
C
C  NORMAL MODE, CUTOFF REGION
C
      IF (VGST.GT.0.0) GO TO 110
      CDRAIN=0.0
      GM=0.0
      GDS=0.0
      GO TO 300
C
C  NORMAL MODE, SATURATION REGION
C
  110 IF (VGST.GT.VDS) GO TO 120
      BETAP=BETA*(1.0+XLAMB*VDS)
      CDRAIN=BETAP*VGST*VGST
      GM=2.0*BETAP*VGST
      GDS=XLAMB*BETA*VGST*VGST
      GO TO 300
C
C  NORMAL MODE, LINEAR REGION
C
  120 BETAP=BETA*(1.0+XLAMB*VDS)
      CDRAIN=BETAP*VDS*(2.0*VGST-VDS)
      GM=2.0*BETAP*VDS
      GDS=2.0*BETAP*(VGST-VDS)+XLAMB*BETA*VDS*(2.0*VGST-VDS)
      GO TO 300
C
C  COMPUTE DRAIN CURRENT AND DERIVITIVES FOR INVERSE MODE
C
  200 VGDT=VGD-VTO
C
C  INVERSE MODE, CUTOFF REGION
C
      IF (VGDT.GT.0.0) GO TO 210
      CDRAIN=0.0
      GM=0.0
      GDS=0.0
      GO TO 300
C
C  INVERSE MODE, SATURATION REGION
C
  210 IF (VGDT.GT.-VDS) GO TO 220
      BETAP=BETA*(1.0-XLAMB*VDS)
      CDRAIN=-BETAP*VGDT*VGDT
      GM=-2.0*BETAP*VGDT
      GDS=XLAMB*BETA*VGDT*VGDT-GM
      GO TO 300
C
C  INVERSE MODE, LINEAR REGION
C
  220 BETAP=BETA*(1.0-XLAMB*VDS)
      CDRAIN=BETAP*VDS*(2.0*VGDT+VDS)
      GM=2.0*BETAP*VDS
      GDS=2.0*BETAP*VGDT-XLAMB*BETA*VDS*(2.0*VGDT+VDS)
C
C  COMPUTE EQUIVALENT DRAIN CURRENT SOURCE, CHECK CHANGE IN DRAIN
C  CURRENT FROM LAST ITERATION, AND STORE DC RESULTS
C
  300 CDREQ=TYPE*(VGS*GM+VDS*GDS-CDRAIN)
      CDRAIN=CDRAIN-CGDJ
      TOL=PERTOL*ABS(CDRAIN)
      IF (TOL.LT.1.0E-9) TOL=1.0E-9
      DIFF=ABS(CDRAIN-CDRO(ISPOT))
      IF (DIFF.GT.TOL) IFINAL=0
      CDRO(ISPOT)=CDRAIN
C
C  CHARGE STORAGE ELEMENTS
C
      IF (MODE.EQ.1) GO TO 500
      CZGS=SYMVAL(MNAM,7)*VALUE(I)
      CZGD=SYMVAL(MNAM,8)*VALUE(I)
      PHIB=SYMVAL(MNAM,9)
      IF (VGS.GE.0.0) GO TO 312
      SARG=SQRT(1.0-VGS/PHIB)
      CTGS=4.0*PHIB*CZGS*(1.0-SARG)/DELTA
      CAPGS=CZGS/SARG
      GO TO 314
  312 CTGS=2.0*VGS*CZGS*(1.0+VGS/(4.0*PHIB))/DELTA
      CAPGS=CZGS*(1.0+VGS/(2.0*PHIB))
  314 IF (VGD.GE.0.0) GO TO 316
      SARG=SQRT(1.0-VGD/PHIB)
      CTGD=4.0*PHIB*CZGD*(1.0-SARG)/DELTA
      CAPGD=CZGD/SARG
      GO TO 320
  316 CTGD=2.0*VGD*CZGD*(1.0+VGD/(4.0*PHIB))/DELTA
      CAPGD=CZGD*(1.0+VGD/(2.0*PHIB))
C
C  SMALL SIGNAL PARAMETERS
C
  320 IF (MODE.GT.2) GO TO 350
      TRACUR(ISPOT+3)=GM
      TRACUR(ISPOT+4)=GDS
      TRACUR(ISPOT+5)=GGS
      TRACUR(ISPOT+6)=CAPGS
      TRACUR(ISPOT+7)=GGD
      TRACUR(ISPOT+8)=CAPGD
      GO TO 900
C
C  TRANSIENT ANALYSIS
C
  350 IF (IPASS1.EQ.0) GO TO 360
      CJGS(ISPOT)=CTGS
      CJGD(ISPOT)=CTGD
C
C  UPDATE AT FIRST ITERATION OF EACH TIMEPOINT
C
  360 IF (MODE.EQ.3) GO TO 370
      CJGS(ISPOT)=CTGS*(1.0+DELTA/DELOLD)-CJGS(ISPOT)
      CJGD(ISPOT)=CTGD*(1.0+DELTA/DELOLD)-CJGD(ISPOT)
C
C  COMPUTE CAPACITOR CONDUCTANCES AND EQUIVALENT CURRENT SOURCES
C
  370 GTEMP=2.0*CAPGS/DELTA
      GGS=GGS+GTEMP
      CEQGS=CEQGS+TYPE*(GTEMP*VGS-CTGS+CJGS(ISPOT))
      GTEMP=2.0*CAPGD/DELTA
      GGD=GGD+GTEMP
      CEQGD=CEQGD+TYPE*(GTEMP*VGD-CTGD+CJGD(ISPOT))
C
C  LOAD CURRENT VECTOR
C
  500 VN(LOC2)=VN(LOC2)+CEQGS+CEQGD
      VN(LOC4)=VN(LOC4)+CDREQ-CEQGD
      VN(LOC5)=VN(LOC5)-CDREQ-CEQGS
C
C  LOAD Y MATRIX
C
      YNL(LOC1)=YNL(LOC1)+GDPR
      YNL(LOC2)=YNL(LOC2)+GGD+GGS
      YNL(LOC3)=YNL(LOC3)+GSPR
      YNL(LOC4)=YNL(LOC4)+GDPR+GDS+GGD
      YNL(LOC5)=YNL(LOC5)+GSPR+GDS+GM+GGS
      YNL(LOC6)=YNL(LOC6)-GDPR
      YNL(LOC7)=YNL(LOC7)-GGD
      YNL(LOC8)=YNL(LOC8)-GGS
      YNL(LOC9)=YNL(LOC9)-GSPR
      YNL(LOC10)=YNL(LOC10)-GDPR
      YNL(LOC11)=YNL(LOC11)+GM-GGD
      YNL(LOC12)=YNL(LOC12)-GDS-GM
      YNL(LOC13)=YNL(LOC13)-GGS-GM
      YNL(LOC14)=YNL(LOC14)-GSPR
      YNL(LOC15)=YNL(LOC15)-GDS
  900 ISPOT=ISPOT+10
 1000 CONTINUE
      RETURN
      END
      SUBROUTINE MOSFET
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         7
      COMMON/KNSTNT/TWOPI,XLOG2,XLOG10,RAD,BOLTZ,CHARGE,VT
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
C
C
      DIMENSION VBDO(1),VBSO(1),CDRO(1),CJBD(1),CJBS(1),VCGS(1),
     1   CCGS(1),VCGD(1),CCGD(1),VCGB(1),CCGB(1),VGSO(1),VGDO(1)
      EQUIVALENCE (VBDO(1),TRACUR(1)),(VBSO(1),TRACUR(2)),
     1   (CDRO(1),TRACUR(3)),(CJBD(1),TRACUR(4)),(CJBS(1),TRACUR(5)),
     2   (VCGS(1),TRACUR(6)),(CCGS(1),TRACUR(7)),(VCGD(1),TRACUR(8)),
     3   (CCGD(1),TRACUR(9)),(VCGB(1),TRACUR(10)),(CCGB(1),TRACUR(11)),
     4   (VGSO(1),TRACUR(12)),(VGDO(1),TRACUR(13))
C
C
      ISTART=LOCATE(10)
      ISTOP=LOCATE(11)-1
      IF (ISTART.GT.ISTOP) RETURN
      ISPOT=ICURNT(10)
      DO 1000 I=ISTART,ISTOP
C
C  LOOKUP MATRIX POINTERS
C
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=NODPLC(LOC+2)
      LOC4=NODPLC(LOC+3)
      LOC5=NODPLC(LOC+4)
      LOC6=NODPLC(LOC+5)
      IF (MODE.EQ.2) GO TO 50
      LOC7=MATLOC(IFIND+1)
      LOC8=MATLOC(IFIND+2)
      LOC9=MATLOC(IFIND+3)
      LOC10=MATLOC(IFIND+4)
      LOC11=MATLOC(IFIND+5)
      LOC12=MATLOC(IFIND+6)
      LOC13=MATLOC(IFIND+7)
      LOC14=MATLOC(IFIND+8)
      LOC15=MATLOC(IFIND+9)
      LOC16=MATLOC(IFIND+10)
      LOC17=MATLOC(IFIND+11)
      LOC18=MATLOC(IFIND+12)
      LOC19=MATLOC(IFIND+13)
      LOC20=MATLOC(IFIND+14)
      LOC21=MATLOC(IFIND+15)
      LOC22=MATLOC(IFIND+16)
      IFIND=IFIND+16
C
C  DC ANALYSIS
C
   50 TYPE=SYMVAL(MNAM,1)
      VTO=SYMVAL(MNAM,2)
      PHI=SYMVAL(MNAM,3)
      BETA=SYMVAL(MNAM,4)*VALUE(I)
      GAMMA=SYMVAL(MNAM,5)
      XLAMB=SYMVAL(MNAM,6)
      GDPR=SYMVAL(MNAM,7)*VALUE(I)
      GSPR=SYMVAL(MNAM,8)*VALUE(I)
      CSAT=SYMVAL(MNAM,15)
C
C  INITIALIZE ON FIRST DC PASS
C
      IF (IPASS1.EQ.0) GO TO 60
      IF (MODE.GT.1) GO TO 60
      CDRO(ISPOT)=0.0
      VBS=-1.0
      VBD=-1.0
      VGS=0.0
      VGD=0.0
      GO TO 70
C
C  DETERMINE INTERNAL BRANCH VOLTAGES AND SUBSTRATE JUNCTION MODELS
C
   60 VBD=TYPE*(VNIM1(LOC4)-VNIM1(LOC5))
      VBS=TYPE*(VNIM1(LOC4)-VNIM1(LOC6))
      VGS=TYPE*(VNIM1(LOC2)-VNIM1(LOC6))
      VGD=TYPE*(VNIM1(LOC2)-VNIM1(LOC5))
      IF (IPASS1.EQ.1) GO TO 70
      CALL JUNCT(VBD,VBDO(ISPOT),CSAT,VT)
      CALL JUNCT(VBS,VBSO(ISPOT),CSAT,VT)
      CALL FETLIM(VGS,VGSO(ISPOT),VTO)
      CALL FETLIM(VGD,VGDO(ISPOT),VTO)
   70 VBDO(ISPOT)=VBD
      VBSO(ISPOT)=VBS
      VGSO(ISPOT)=VGS
      VGDO(ISPOT)=VGD
      VDS=VGS-VGD
      VGB=VGS-VBS
C
C  COMPUTE SUBSTRATE JUNCTION EQUIVALENT CONDUCTANCES
C
   80 IF (VBD.GT.0.0) GO TO 82
      GBD=CSAT/VT+GMIN
      CBDJ=GBD*VBD
      CEQBD=0.0
      GO TO 84
   82 ARG=EXP(VBD/VT)
      CBDJ=CSAT*(ARG-1.0)+GMIN*VBD
      GBD=CSAT*ARG/VT+GMIN
      CEQBD=TYPE*(VBD*GBD-CBDJ)
   84 IF (VBS.GT.0.0) GO TO 86
      GBS=CSAT/VT+GMIN
      CBSJ=GBS*VBS
      CEQBS=0.0
      GO TO 100
   86 ARG=EXP(VBS/VT)
      CBSJ=CSAT*(ARG-1.0)+GMIN*VBS
      GBS=CSAT*ARG/VT+GMIN
      CEQBS=TYPE*(VBS*GBS-CBSJ)
C
C  COMPUTE DRAIN CURRENT AND DERIVITIVES FOR NORMAL MODE
C
  100 IF (VDS.LT.0.0) GO TO 200
      IF (VBS.GT.0.0) GO TO 102
      SARG=SQRT(PHI-VBS)
      VGST=VGS-VTO-GAMMA*SARG
      ARG=GAMMA/(2.0*SARG)
      GO TO 105
  102 SARG=SQRT(PHI)
      VGST=VGS-VTO-GAMMA*(SARG-VBS/(2.0*SARG))
      ARG=GAMMA/(2.0*SARG)
C
C  NORMAL MODE, CUTOFF REGION
C
  105 IF (VGST.GT.0.0) GO TO 110
      CDRAIN=0.0
      GM=0.0
      GDS=0.0
      GMBS=0.0
      GO TO 300
C
C  NORMAL MODE, SATURATION REGION
C
  110 IF (VGST.GT.VDS) GO TO 120
      BETAP=BETA*(1.0+XLAMB*VDS)
      CDRAIN=BETAP*VGST*VGST
      GM=2.0*BETAP*VGST
      GDS=XLAMB*BETA*VGST*VGST
      GMBS=GM*ARG
      GO TO 300
C
C  NORMAL MODE, LINEAR REGION
C
  120 BETAP=BETA*(1.0+XLAMB*VDS)
      CDRAIN=BETAP*VDS*(2.0*VGST-VDS)
      GM=2.0*BETAP*VDS
      GDS=2.0*BETAP*(VGST-VDS)+XLAMB*BETA*VDS*(2.0*VGST-VDS)
      GMBS=GM*ARG
      GO TO 300
C
C  COMPUTE DRAIN CURRENT AND DERIVITIVES FOR INVERSE MODE
C
  200 IF (VBD.GT.0.0) GO TO 202
      SARG=SQRT(PHI-VBD)
      VGDT=VGD-VTO-GAMMA*SARG
      ARG=GAMMA/(2.0*SARG)
      GO TO 205
  202 SARG=SQRT(PHI)
      VGDT=VGD-VTO-GAMMA*(SARG-VBD/(2.0*SARG))
      ARG=GAMMA/(2.0*SARG)
C
C  INVERSE MODE, CUTOFF REGION
C
  205 IF (VGDT.GT.0.0) GO TO 210
      CDRAIN=0.0
      GM=0.0
      GDS=0.0
      GMBS=0.0
      GO TO 300
C
C  INVERSE MODE, SATURATION REGION
C
  210 IF (VGDT.GT.-VDS) GO TO 220
      BETAP=BETA*(1.0-XLAMB*VDS)
      CDRAIN=-BETAP*VGDT*VGDT
      GM=-2.0*BETAP*VGDT
      GDS=XLAMB*BETA*VGDT*VGDT-GM*(1.0+ARG)
      GMBS=GM*ARG
      GO TO 300
C
C  INVERSE MODE, LINEAR REGION
C
  220 BETAP=BETA*(1.0-XLAMB*VDS)
      CDRAIN=BETAP*VDS*(2.0*VGDT+VDS)
      GM=2.0*BETAP*VDS
      GDS=2.0*BETAP*(VGDT-VDS*ARG)-XLAMB*BETA*VDS*(2.0*VGDT+VDS)
      GMBS=GM*ARG
C
C  COMPUTE EQUIVALENT DRAIN CURRENT SOURCE, CHECK CHANGE IN DRAIN
C  CURRENT FROM LAST ITERATION, STORE DC RESULTS, AND ZERO TRANSIENT
C  CONDUCTANCES
C
  300 CDREQ=TYPE*(VGS*GM+VDS*GDS+VBS*GMBS-CDRAIN)
      CDRAIN=CDRAIN-CBDJ
      TOL=PERTOL*ABS(CDRAIN)
      IF (TOL.LT.1.0E-9) TOL=1.0E-9
      DIFF=ABS(CDRAIN-CDRO(ISPOT))
      IF (DIFF.GT.TOL) IFINAL=0
      CDRO(ISPOT)=CDRAIN
      IF (MODE.GT.1) GO TO 310
      GCGS=0.0
      CEQGS=0.0
      GCGD=0.0
      CEQGD=0.0
      GCGB=0.0
      CEQGB=0.0
      GO TO 500
C
C  CHARGE STORAGE ELEMENTS
C
  310 CGS=SYMVAL(MNAM,9)*VALUE(I)
      CGD=SYMVAL(MNAM,10)*VALUE(I)
      CGB=SYMVAL(MNAM,11)*VALUE(I)
      CZBD=SYMVAL(MNAM,12)*VALUE(I)
      CZBS=SYMVAL(MNAM,13)*VALUE(I)
      PHIB=SYMVAL(MNAM,14)
      IF (VBD.GE.0.0) GO TO 312
      SARG=SQRT(1.0-VBD/PHIB)
      CTBD=4.0*PHIB*CZBD*(1.0-SARG)/DELTA
      CAPBD=CZBD/SARG
      GO TO 314
  312 CTBD=2.0*VBD*CZBD*(1.0+VBD/(4.0*PHIB))/DELTA
      CAPBD=CZBD*(1.0+VBD/(2.0*PHIB))
  314 IF (VBS.GE.0.0) GO TO 316
      SARG=SQRT(1.0-VBS/PHIB)
      CTBS=4.0*PHIB*CZBS*(1.0-SARG)/DELTA
      CAPBS=CZBS/SARG
      GO TO 320
  316 CTBS=2.0*VBS*CZBS*(1.0+VBS/(4.0*PHIB))/DELTA
      CAPBS=CZBS*(1.0+VBS/(2.0*PHIB))
C
C  SMALL SIGNAL PARAMETERS
C
  320 IF (MODE.GT.2) GO TO 350
      TRACUR(ISPOT+3)=GM
      TRACUR(ISPOT+4)=GDS
      TRACUR(ISPOT+5)=GMBS
      TRACUR(ISPOT+6)=GBD
      TRACUR(ISPOT+7)=CAPBD
      TRACUR(ISPOT+8)=GBS
      TRACUR(ISPOT+9)=CAPBS
      GO TO 900
C
C  TRANSIENT ANALYSIS
C
  350 IF (IPASS1.EQ.0) GO TO 360
      VCGS(ISPOT)=VGS
      CCGS(ISPOT)=0.0
      VCGD(ISPOT)=VGD
      CCGD(ISPOT)=0.0
      VCGB(ISPOT)=VGB
      CCGB(ISPOT)=0.0
      CJBD(ISPOT)=CTBD
      CJBS(ISPOT)=CTBS
C
C  UPDATE AT FIRST ITERATION OF EACH TIMEPOINT
C
  360 IF (MODE.EQ.3) GO TO 370
      CCGS(ISPOT)=(2.0*CGS/DELOLD)*(VGS-VCGS(ISPOT))-CCGS(ISPOT)
      VCGS(ISPOT)=VGS
      CCGD(ISPOT)=(2.0*CGD/DELOLD)*(VGD-VCGD(ISPOT))-CCGD(ISPOT)
      VCGD(ISPOT)=VGD
      CCGB(ISPOT)=(2.0*CGB/DELOLD)*(VGB-VCGB(ISPOT))-CCGB(ISPOT)
      VCGB(ISPOT)=VGB
      CJBD(ISPOT)=CTBD*(1.0+DELTA/DELOLD)-CJBD(ISPOT)
      CJBS(ISPOT)=CTBS*(1.0+DELTA/DELOLD)-CJBS(ISPOT)
C
C  COMPUTE CAPACITOR CONDUCTANCES AND EQUIVALENT CURRENT SOURCES
C
  370 GCGS=2.0*CGS/DELTA
      CEQGS=TYPE*(VCGS(ISPOT)*GCGS+CCGS(ISPOT))
      GCGD=2.0*CGD/DELTA
      CEQGD=TYPE*(VCGD(ISPOT)*GCGD+CCGD(ISPOT))
      GCGB=2.0*CGB/DELTA
      CEQGB=TYPE*(VCGB(ISPOT)*GCGB+CCGB(ISPOT))
      GTEMP=2.0*CAPBD/DELTA
      GBD=GBD+GTEMP
      CEQBD=CEQBD+TYPE*(GTEMP*VBD-CTBD+CJBD(ISPOT))
      GTEMP=2.0*CAPBS/DELTA
      GBS=GBS+GTEMP
      CEQBS=CEQBS+TYPE*(GTEMP*VBS-CTBS+CJBS(ISPOT))
C
C  LOAD CURRENT VECTOR
C
  500 VN(LOC2)=VN(LOC2)+CEQGS+CEQGD+CEQGB
      VN(LOC4)=VN(LOC4)+CEQBS+CEQBD-CEQGB
      VN(LOC5)=VN(LOC5)+CDREQ-CEQGD-CEQBD
      VN(LOC6)=VN(LOC6)-CDREQ-CEQGS-CEQBS
C
C  LOAD Y MATRIX
C
      YNL(LOC1)=YNL(LOC1)+GDPR
      YNL(LOC2)=YNL(LOC2)+GCGD+GCGS+GCGB
      YNL(LOC3)=YNL(LOC3)+GSPR
      YNL(LOC4)=YNL(LOC4)+GBD+GBS+GCGB
      YNL(LOC5)=YNL(LOC5)+GDPR+GDS+GCGD+GBD
      YNL(LOC6)=YNL(LOC6)+GSPR+GDS+GCGS+GBS+GM+GMBS
      YNL(LOC7)=YNL(LOC7)-GDPR
      YNL(LOC8)=YNL(LOC8)-GCGB
      YNL(LOC9)=YNL(LOC9)-GCGD
      YNL(LOC10)=YNL(LOC10)-GCGS
      YNL(LOC11)=YNL(LOC11)-GSPR
      YNL(LOC12)=YNL(LOC12)-GCGB
      YNL(LOC13)=YNL(LOC13)-GBD
      YNL(LOC14)=YNL(LOC14)-GBS
      YNL(LOC15)=YNL(LOC15)-GDPR
      YNL(LOC16)=YNL(LOC16)-GCGD+GM
      YNL(LOC17)=YNL(LOC17)-GBD+GMBS
      YNL(LOC18)=YNL(LOC18)-GDS-GM-GMBS
      YNL(LOC19)=YNL(LOC19)-GCGS-GM
      YNL(LOC20)=YNL(LOC20)-GSPR
      YNL(LOC21)=YNL(LOC21)-GBS-GMBS
      YNL(LOC22)=YNL(LOC22)-GDS
  900 ISPOT=ISPOT+15
 1000 CONTINUE
      RETURN
      END
      SUBROUTINE ACAN
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/MISCEL/NOGO,IGOOF,NOPRNT,IACCT,JOBNAM(16),RTIMES(15)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         8
      COMMON/KNSTNT/TWOPI,XLOG2,XLOG10,RAD,BOLTZ,CHARGE,VT
      COMMON/POINTS/IUS,ILS,MIRROR,NSTOP,NUMVS,LASTUT,LASTLT
      COMMON/OUTDAT/ROUT(101,10),FREQ(101),IONUM,IONAM(10),IOPND(10),
     1   IONND(10),IOFLG(10),NUMOR(3),IOVAR(10,2),IACVAR(5)
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
      COMMON/AC/JACFLG,FSTART,FSTOP,IDFREQ,FINCR,INOISE,NOSPRT,
     1   NOSOUT,NOSIN
C
C
      DIMENSION PUTOUT(2,101,5)
      EQUIVALENCE (PUTOUT(1,1,1),ROUT(1,1))
      DIMENSION YPARTS(2,1),VNPART(2,1)
      COMPLEX CVAL,CYNL(1),CVN(1),CU(1),CUL(1)
      EQUIVALENCE (CYNL(1),YPARTS(1,1),YNL(1))
      EQUIVALENCE (CVN(1),VNPART(1,1),VN(1))
      EQUIVALENCE (CU(1),CYNL(402)),(CUL(1),CYNL(1202))
C
C
      CALL SECOND(T1)
      LE=NSTOP-1
      ICALC=0
      FREQ1=FSTART
C
C  LOAD MATRIX
C
    1 OMEGA=TWOPI*FREQ1
      DO 2 I=1,NUMNOD
      VNPART(1,I)=0.0
      VNPART(2,I)=0.0
      YPARTS(1,I)=0.0
    2 YPARTS(2,I)=0.0
      DO 3 I=IUS,LASTUT
      YPARTS(1,I)=0.0
    3 YPARTS(2,I)=0.0
      DO 4 I=ILS,LASTLT
      YPARTS(1,I)=0.0
    4 YPARTS(2,I)=0.0
      CALL ACLOAD
      IF (IGOOF.EQ.1) GO TO 1000
      IF (LE) 100,75,10
C
C  DECOMPOSITION
C
   10 DO 50 L=1,LE
      KK=IORDER(L)
      RY=ABS(YPARTS(1,KK))
      XY=ABS(YPARTS(2,KK))
      IF ((RY+XY).GT.GMIN) GO TO 30
      YPARTS(1,KK)=GMIN
      YPARTS(2,KK)=0.0
      WRITE (6,21)
   21 FORMAT (5X,'--- WARNING ---  UNDERFLOW ENCOUNTERED')
   30 IS=IUR(L)
      IE=IUR(L+1)-1
      IF (IS.GT.IE) GO TO 50
      DO 40 IL=IS,IE
      CUL(IL)=CUL(IL)/CYNL(KK)
      IO=IUC(IL)
      IDIAG=IORDER(IO)
      CYNL(IDIAG)=CYNL(IDIAG)-CUL(IL)*CU(IL)
      DO 35 IU=IS,IE
      JO=IUC(IU)
      IF (IO-JO) 31,35,33
C
C  FIND (IO,JO) MATRIX TERM (UPPER TRIANGLE)
C
   31 J=IUR(IO+1)
      JE=IUR(IO)
   32 J=J-1
      IF (J.LT.JE) GO TO 1000
      IF (IUC(J).NE.JO) GO TO 32
      CU(J)=CU(J)-CUL(IL)*CU(IU)
      GO TO 35
C
C  FIND (IO,JO) MATRIX TERM (LOWER TRIANGLE)
C
   33 J=IUR(JO+1)
      JE=IUR(JO)
   34 J=J-1
      IF (J.LT.JE) GO TO 1000
      IF (IUC(J).NE.IO) GO TO 34
      CUL(J)=CUL(J)-CUL(IL)*CU(IU)
   35 CONTINUE
   40 CONTINUE
   50 CONTINUE
C
C  FORWARD SUBSTITUTION
C
      DO 70 J=1,LE
      JCS=IUR(J)
      JCE=IUR(J+1)-1
      IF (JCE.LT.JCS) GO TO 70
      JB=IORDER(J)
      DO 60 I=JCS,JCE
      II=IUC(I)
      IB=IORDER(II)
      CVN(IB)=CVN(IB)-CVN(JB)*CUL(I)
   60 CONTINUE
   70 CONTINUE
C
C  BACK SUBSTITUTION
C
   75 IO=IORDER(NSTOP)
      RY=ABS(YPARTS(1,IO))
      XY=ABS(YPARTS(2,IO))
      IF ((RY+XY).GT.GMIN) GO TO 78
      YPARTS(1,IO)=GMIN
      YPARTS(2,IO)=0.0
      WRITE (6,21)
   78 CVN(IO)=CVN(IO)/CYNL(IO)
      IF (LE.EQ.0) GO TO 100
      DO 90 I=1,LE
      IO=IORDER(NSTOP-I)
      JS=IUR(NSTOP-I)
      JE=IUR(NSTOP-I+1)-1
      IF (JE.LT.JS) GO TO 85
      DO 80 J=JS,JE
      JJ=IUC(J)
      JO=IORDER(JJ)
      CVN(IO)=CVN(IO)-CU(J)*CVN(JO)
   80 CONTINUE
   85 CVN(IO)=CVN(IO)/CYNL(IO)
   90 CONTINUE
C
C  SET SOURCE NODES TO THEIR VOLTAGE VALUE
C
  100 VNPART(1,1)=0.0
      VNPART(2,1)=0.0
      IF (NUMVS.EQ.0) GO TO 135
      DO 110 I=1,NUMVS
      IELNUM=MATLOC(NUMVS-I+1)
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      SIGN=NODPLC(LOC+2)
      MNAM=MNAME(IELNUM)
      ISPOT=ICURNT(6)+2*(IELNUM-LOCATE(6))
      TRACUR(ISPOT)=VNPART(1,NODE1)
      TRACUR(ISPOT+1)=VNPART(2,NODE1)
      CVAL=SIGN*CMPLX(SOURCE(MNAM+1),SOURCE(MNAM+4))
      CVN(NODE1)=CVN(NODE2)+CVAL
  110 CONTINUE
C
C  STORE OUTPUT
C
  135 ICALC=ICALC+1
      FREQ(ICALC)=FREQ1
      IKNT=0
  140 IKNT=IKNT+1
      IF (IKNT.GT.NUMOR(3)) GO TO 160
      JKNT=IACVAR(IKNT)
      IF (IOFLG(JKNT).EQ.3) GO TO 140
      IPNOD=IOPND(JKNT)
      IF (IOFLG(JKNT).EQ.2) GO TO 150
      INNOD=IONND(JKNT)
      PUTOUT(1,ICALC,IKNT)=VNPART(1,IPNOD)-VNPART(1,INNOD)
      PUTOUT(2,ICALC,IKNT)=VNPART(2,IPNOD)-VNPART(2,INNOD)
      GO TO 140
  150 CALL ACCAL(IPNOD,CREAL,CIMAG)
      PUTOUT(1,ICALC,IKNT)=CREAL
      PUTOUT(2,ICALC,IKNT)=CIMAG
      GO TO 140
  160 IF (NOSOUT.NE.0) CALL NOISE
C
C  INCREMENT FREQUENCY
C
      IF (IDFREQ.GT.1) GO TO 180
      FREQ1=FREQ1+FINCR
      GO TO 190
  180 FREQ1=FREQ1*FINCR
  190 IF (ICALC-JACFLG) 1,1100,1100
C
C  FINISHED
C
 1000 NOGO=1
      WRITE (6,1001)
 1001 FORMAT (//5X,'----------  PROGRAM ERROR IN MATRIX INVERSION'//)
 1100 CALL SECOND(T2)
      RTIMES(7)=RTIMES(7)+T2-T1
      RETURN
      END
      SUBROUTINE ACLOAD
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/MISCEL/NOGO,IGOOF,NOPRNT,IACCT,JOBNAM(16),RTIMES(15)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         8
      COMMON/POINTS/IUS,ILS,MIRROR,NSTOP,NUMVS,LASTUT,LASTLT
      COMMON/ITER/GMIN,PERTOL,VNTOL,IPASS1,IFINAL,ITERNO,IFIND
C
C
      COMPLEX CVAL,CYNL(1),CVN(1),CU(1),CUL(1)
      DIMENSION YPARTS(2,1),VNPART(2,1)
      EQUIVALENCE (CYNL(1),YPARTS(1,1),YNL(1))
      EQUIVALENCE (CVN(1),VNPART(1,1),VN(1))
      EQUIVALENCE (CU(1),CYNL(402)),(CUL(1),CYNL(1202))
C
C
      IFIND=NUMVS
C
C  RESISTORS
C
      ISTOP=LOCATE(2)-1
      IF (ISTOP.LT.1) GO TO 20
      DO 10 I=1,ISTOP
      LOC=LOCAL(I)
      VAL=VALUE(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=MATLOC(IFIND+1)
      LOC4=MATLOC(IFIND+2)
      IFIND=IFIND+2
      YPARTS(1,LOC1)=YPARTS(1,LOC1)+VAL
      YPARTS(1,LOC2)=YPARTS(1,LOC2)+VAL
      YPARTS(1,LOC3)=YPARTS(1,LOC3)-VAL
      YPARTS(1,LOC4)=YPARTS(1,LOC4)-VAL
   10 CONTINUE
C
C  CAPACITORS
C
   20 ISTART=LOCATE(2)
      ISTOP=LOCATE(3)-1
      DO 30 I=ISTART,ISTOP
      IF (ISTART.GT.ISTOP) GO TO 40
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=MATLOC(IFIND+1)
      LOC4=MATLOC(IFIND+2)
      IFIND=IFIND+2
      VAL=VALUE(I)*OMEGA
      YPARTS(2,LOC1)=YPARTS(2,LOC1)+VAL
      YPARTS(2,LOC2)=YPARTS(2,LOC2)+VAL
      YPARTS(2,LOC3)=YPARTS(2,LOC3)-VAL
      YPARTS(2,LOC4)=YPARTS(2,LOC4)-VAL
   30 CONTINUE
C
C  INDUCTORS
C
   40 ISTART=LOCATE(3)
      ISTOP=LOCATE(4)-1
      IF (ISTART.GT.ISTOP) GO TO 60
      DO 50 I=ISTART,ISTOP
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=MATLOC(IFIND+1)
      LOC4=MATLOC(IFIND+2)
      IFIND=IFIND+2
      VAL=-VALUE(I)/OMEGA
      YPARTS(2,LOC1)=YPARTS(2,LOC1)+VAL
      YPARTS(2,LOC2)=YPARTS(2,LOC2)+VAL
      YPARTS(2,LOC3)=YPARTS(2,LOC3)-VAL
      YPARTS(2,LOC4)=YPARTS(2,LOC4)-VAL
   50 CONTINUE
C
C  VOLTAGE DEPENDENT CURRENT SOURCES
C
   60 ISTART=LOCATE(5)
      ISTOP=LOCATE(6)-1
      IF (ISTART.GT.ISTOP) GO TO 80
      DO 70 I=ISTART,ISTOP
      LOC1=MATLOC(IFIND+1)
      LOC2=MATLOC(IFIND+2)
      LOC3=MATLOC(IFIND+3)
      LOC4=MATLOC(IFIND+4)
      IFIND=IFIND+4
      VAL=VALUE(I)
      MNAM=MNAME(I)
      ARG=OMEGA*SOURCE(MNAM)
      XVAL=-VAL*SIN(ARG)
      VAL=VAL*COS(ARG)
      CVAL=CMPLX(VAL,XVAL)
      CYNL(LOC1)=CYNL(LOC1)+CVAL
      CYNL(LOC2)=CYNL(LOC2)-CVAL
      CYNL(LOC3)=CYNL(LOC3)-CVAL
      CYNL(LOC4)=CYNL(LOC4)+CVAL
   70 CONTINUE
C
C  BJTS
C
   80 ISTART=LOCATE(7)
      ISTOP=LOCATE(8)-1
      IF (ISTART.GT.ISTOP) GO TO 100
      ISPOT=ICURNT(7)
      DO 90 I=ISTART,ISTOP
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=NODPLC(LOC+2)
      LOC4=NODPLC(LOC+3)
      LOC5=NODPLC(LOC+4)
      LOC6=NODPLC(LOC+5)
      LOC7=MATLOC(IFIND+1)
      LOC8=MATLOC(IFIND+2)
      LOC9=MATLOC(IFIND+3)
      LOC10=MATLOC(IFIND+4)
      LOC11=MATLOC(IFIND+5)
      LOC12=MATLOC(IFIND+6)
      LOC13=MATLOC(IFIND+7)
      LOC14=MATLOC(IFIND+8)
      LOC15=MATLOC(IFIND+9)
      LOC16=MATLOC(IFIND+10)
      LOC17=MATLOC(IFIND+11)
      LOC18=MATLOC(IFIND+12)
      IFIND=IFIND+12
      GBPR=SYMVAL(MNAM,4)*VALUE(I)
      GCPR=SYMVAL(MNAM,5)*VALUE(I)
      GEPR=SYMVAL(MNAM,6)*VALUE(I)
      XCCS=SYMVAL(MNAM,7)*VALUE(I)*OMEGA
      GPI=TRACUR(ISPOT+4)
      XCPI=TRACUR(ISPOT+5)*OMEGA
      GMU=TRACUR(ISPOT+6)
      XCMU=TRACUR(ISPOT+7)*OMEGA
      GM=TRACUR(ISPOT+8)
      GO=TRACUR(ISPOT+9)
      GMPGO=GM+GO
      ISPOT=ISPOT+15
      YPARTS(1,LOC1)=YPARTS(1,LOC1)+GCPR
      YPARTS(1,LOC2)=YPARTS(1,LOC2)+GBPR
      YPARTS(1,LOC3)=YPARTS(1,LOC3)+GEPR
      YPARTS(1,LOC4)=YPARTS(1,LOC4)+GMU+GO+GCPR
      YPARTS(1,LOC5)=YPARTS(1,LOC5)+GBPR+GPI+GMU
      YPARTS(1,LOC6)=YPARTS(1,LOC6)+GPI+GEPR+GMPGO
      YPARTS(1,LOC7)=YPARTS(1,LOC7)-GCPR
      YPARTS(1,LOC8)=YPARTS(1,LOC8)-GBPR
      YPARTS(1,LOC9)=YPARTS(1,LOC9)-GEPR
      YPARTS(1,LOC10)=YPARTS(1,LOC10)-GCPR
      YPARTS(1,LOC11)=YPARTS(1,LOC11)-GMU+GM
      YPARTS(1,LOC12)=YPARTS(1,LOC12)-GMPGO
      YPARTS(1,LOC13)=YPARTS(1,LOC13)-GBPR
      YPARTS(1,LOC14)=YPARTS(1,LOC14)-GMU
      YPARTS(1,LOC15)=YPARTS(1,LOC15)-GPI
      YPARTS(1,LOC16)=YPARTS(1,LOC16)-GEPR
      YPARTS(1,LOC17)=YPARTS(1,LOC17)-GO
      YPARTS(1,LOC18)=YPARTS(1,LOC18)-GPI-GM
      YPARTS(2,LOC4)=YPARTS(2,LOC4)+XCMU+XCCS
      YPARTS(2,LOC5)=YPARTS(2,LOC5)+XCPI+XCMU
      YPARTS(2,LOC6)=YPARTS(2,LOC6)+XCPI
      YPARTS(2,LOC11)=YPARTS(2,LOC11)-XCMU
      YPARTS(2,LOC14)=YPARTS(2,LOC14)-XCMU
      YPARTS(2,LOC15)=YPARTS(2,LOC15)-XCPI
      YPARTS(2,LOC18)=YPARTS(2,LOC18)-XCPI
   90 CONTINUE
C
C  DIODES
C
  100 ISTART=LOCATE(8)
      ISTOP=LOCATE(9)-1
      IF (ISTART.GT.ISTOP) GO TO 120
      ISPOT=ICURNT(8)
      DO 110 I=ISTART,ISTOP
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=NODPLC(LOC+2)
      LOC4=MATLOC(IFIND+1)
      LOC5=MATLOC(IFIND+2)
      LOC6=MATLOC(IFIND+3)
      LOC7=MATLOC(IFIND+4)
      IFIND=IFIND+4
      GSPR=SYMVAL(MNAM,1)*VALUE(I)
      GEQ=TRACUR(ISPOT+2)
      XCEQ=TRACUR(ISPOT+3)*OMEGA
      ISPOT=ISPOT+5
      YPARTS(1,LOC1)=YPARTS(1,LOC1)+GSPR
      YPARTS(1,LOC2)=YPARTS(1,LOC2)+GEQ
      YPARTS(1,LOC3)=YPARTS(1,LOC3)+GEQ+GSPR
      YPARTS(1,LOC4)=YPARTS(1,LOC4)-GSPR
      YPARTS(1,LOC5)=YPARTS(1,LOC5)-GEQ
      YPARTS(1,LOC6)=YPARTS(1,LOC6)-GSPR
      YPARTS(1,LOC7)=YPARTS(1,LOC7)-GEQ
      YPARTS(2,LOC2)=YPARTS(2,LOC2)+XCEQ
      YPARTS(2,LOC3)=YPARTS(2,LOC3)+XCEQ
      YPARTS(2,LOC5)=YPARTS(2,LOC5)-XCEQ
      YPARTS(2,LOC7)=YPARTS(2,LOC7)-XCEQ
  110 CONTINUE
C
C  JFETS
C
  120 ISTART=LOCATE(9)
      ISTOP=LOCATE(10)-1
      IF (ISTART.GT.ISTOP) GO TO 140
      ISPOT=ICURNT(9)
      DO 130 I=ISTART,ISTOP
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=NODPLC(LOC+2)
      LOC4=NODPLC(LOC+3)
      LOC5=NODPLC(LOC+4)
      LOC6=MATLOC(IFIND+1)
      LOC7=MATLOC(IFIND+2)
      LOC8=MATLOC(IFIND+3)
      LOC9=MATLOC(IFIND+4)
      LOC10=MATLOC(IFIND+5)
      LOC11=MATLOC(IFIND+6)
      LOC12=MATLOC(IFIND+7)
      LOC13=MATLOC(IFIND+8)
      LOC14=MATLOC(IFIND+9)
      LOC15=MATLOC(IFIND+10)
      IFIND=IFIND+10
      GDPR=SYMVAL(MNAM,5)*VALUE(I)
      GSPR=SYMVAL(MNAM,6)*VALUE(I)
      GM=TRACUR(ISPOT+3)
      GDS=TRACUR(ISPOT+4)
      GGS=TRACUR(ISPOT+5)
      XGS=TRACUR(ISPOT+6)*OMEGA
      GGD=TRACUR(ISPOT+7)
      XGD=TRACUR(ISPOT+8)*OMEGA
      ISPOT=ISPOT+10
      YPARTS(1,LOC1)=YPARTS(1,LOC1)+GDPR
      YPARTS(1,LOC2)=YPARTS(1,LOC2)+GGD+GGS
      YPARTS(1,LOC3)=YPARTS(1,LOC3)+GSPR
      YPARTS(1,LOC4)=YPARTS(1,LOC4)+GDPR+GDS+GGD
      YPARTS(1,LOC5)=YPARTS(1,LOC5)+GSPR+GDS+GM+GGS
      YPARTS(1,LOC6)=YPARTS(1,LOC6)-GDPR
      YPARTS(1,LOC7)=YPARTS(1,LOC7)-GGD
      YPARTS(1,LOC8)=YPARTS(1,LOC8)-GGS
      YPARTS(1,LOC9)=YPARTS(1,LOC9)-GSPR
      YPARTS(1,LOC10)=YPARTS(1,LOC10)-GDPR
      YPARTS(1,LOC11)=YPARTS(1,LOC11)+GM-GGD
      YPARTS(1,LOC12)=YPARTS(1,LOC12)-GDS-GM
      YPARTS(1,LOC13)=YPARTS(1,LOC13)-GGS-GM
      YPARTS(1,LOC14)=YPARTS(1,LOC14)-GSPR
      YPARTS(1,LOC15)=YPARTS(1,LOC15)-GDS
      YPARTS(2,LOC2)=YPARTS(2,LOC2)+XGS+XGD
      YPARTS(2,LOC4)=YPARTS(2,LOC4)+XGD
      YPARTS(2,LOC5)=YPARTS(2,LOC5)+XGS
      YPARTS(2,LOC7)=YPARTS(2,LOC7)-XGD
      YPARTS(2,LOC8)=YPARTS(2,LOC8)-XGS
      YPARTS(2,LOC11)=YPARTS(2,LOC11)-XGD
      YPARTS(2,LOC13)=YPARTS(2,LOC13)-XGS
  130 CONTINUE
C
C  MOSFETS
C
  140 ISTART=LOCATE(10)
      ISTOP=LOCATE(11)-1
      IF (ISTART.GT.ISTOP) GO TO 160
      ISPOT=ICURNT(10)
      DO 150 I=ISTART,ISTOP
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      LOC1=NODPLC(LOC)
      LOC2=NODPLC(LOC+1)
      LOC3=NODPLC(LOC+2)
      LOC4=NODPLC(LOC+3)
      LOC5=NODPLC(LOC+4)
      LOC6=NODPLC(LOC+5)
      LOC7=MATLOC(IFIND+1)
      LOC8=MATLOC(IFIND+2)
      LOC9=MATLOC(IFIND+3)
      LOC10=MATLOC(IFIND+4)
      LOC11=MATLOC(IFIND+5)
      LOC12=MATLOC(IFIND+6)
      LOC13=MATLOC(IFIND+7)
      LOC14=MATLOC(IFIND+8)
      LOC15=MATLOC(IFIND+9)
      LOC16=MATLOC(IFIND+10)
      LOC17=MATLOC(IFIND+11)
      LOC18=MATLOC(IFIND+12)
      LOC19=MATLOC(IFIND+13)
      LOC20=MATLOC(IFIND+14)
      LOC21=MATLOC(IFIND+15)
      LOC22=MATLOC(IFIND+16)
      IFIND=IFIND+16
      GDPR=SYMVAL(MNAM,7)*VALUE(I)
      GSPR=SYMVAL(MNAM,8)*VALUE(I)
      XCGS=SYMVAL(MNAM,9)*VALUE(I)*OMEGA
      XCGD=SYMVAL(MNAM,10)*VALUE(I)*OMEGA
      XCGB=SYMVAL(MNAM,11)*VALUE(I)*OMEGA
      GM=TRACUR(ISPOT+3)
      GDS=TRACUR(ISPOT+4)
      GMBS=TRACUR(ISPOT+5)
      GBD=TRACUR(ISPOT+6)
      XBD=TRACUR(ISPOT+7)*OMEGA
      GBS=TRACUR(ISPOT+8)
      XBS=TRACUR(ISPOT+9)*OMEGA
      ISPOT=ISPOT+15
      YPARTS(1,LOC1)=YPARTS(1,LOC1)+GDPR
      YPARTS(1,LOC3)=YPARTS(1,LOC3)+GSPR
      YPARTS(1,LOC4)=YPARTS(1,LOC4)+GBD+GBS
      YPARTS(1,LOC5)=YPARTS(1,LOC5)+GDPR+GDS+GBD
      YPARTS(1,LOC6)=YPARTS(1,LOC6)+GSPR+GDS+GBS+GM+GMBS
      YPARTS(1,LOC7)=YPARTS(1,LOC7)-GDPR
      YPARTS(1,LOC11)=YPARTS(1,LOC11)-GSPR
      YPARTS(1,LOC13)=YPARTS(1,LOC13)-GBD
      YPARTS(1,LOC14)=YPARTS(1,LOC14)-GBS
      YPARTS(1,LOC15)=YPARTS(1,LOC15)-GDPR
      YPARTS(1,LOC16)=YPARTS(1,LOC16)+GM
      YPARTS(1,LOC17)=YPARTS(1,LOC17)-GBD+GMBS
      YPARTS(1,LOC18)=YPARTS(1,LOC18)-GDS-GM-GMBS
      YPARTS(1,LOC19)=YPARTS(1,LOC19)-GM
      YPARTS(1,LOC20)=YPARTS(1,LOC20)-GSPR
      YPARTS(1,LOC21)=YPARTS(1,LOC21)-GBS-GMBS
      YPARTS(1,LOC22)=YPARTS(1,LOC22)-GDS
      YPARTS(2,LOC2)=YPARTS(2,LOC2)+XCGD+XCGS+XCGB
      YPARTS(2,LOC4)=YPARTS(2,LOC4)+XBD+XBS+XCGB
      YPARTS(2,LOC5)=YPARTS(2,LOC5)+XCGD+XBD
      YPARTS(2,LOC6)=YPARTS(2,LOC6)+XCGS+XBS
      YPARTS(2,LOC8)=YPARTS(2,LOC8)-XCGB
      YPARTS(2,LOC9)=YPARTS(2,LOC9)-XCGD
      YPARTS(2,LOC10)=YPARTS(2,LOC10)-XCGS
      YPARTS(2,LOC12)=YPARTS(2,LOC12)-XCGB
      YPARTS(2,LOC13)=YPARTS(2,LOC13)-XBD
      YPARTS(2,LOC14)=YPARTS(2,LOC14)-XBS
      YPARTS(2,LOC16)=YPARTS(2,LOC16)-XCGD
      YPARTS(2,LOC17)=YPARTS(2,LOC17)-XBD
      YPARTS(2,LOC19)=YPARTS(2,LOC19)-XCGS
      YPARTS(2,LOC21)=YPARTS(2,LOC21)-XBS
  150 CONTINUE
C
C  CURRENT SOURCES
C
  160 ISTART=LOCATE(4)
      ISTOP=LOCATE(5)-1
      IF (ISTART.GT.ISTOP) GO TO 200
      DO 170 I=ISTART,ISTOP
      MNAM=MNAME(I)
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      CVAL=CMPLX(SOURCE(MNAM+1),SOURCE(MNAM+4))
      CVN(NODE1)=CVN(NODE1)-CVAL
      CVN(NODE2)=CVN(NODE2)+CVAL
  170 CONTINUE
C
C  VOLTAGE SOURCES
C
  200 IF (NUMVS.EQ.0) RETURN
      DO 500 I=1,NUMVS
      IELNUM=MATLOC(I)
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      SIGN=NODPLC(LOC+2)
      IPNOD=NODPLC(LOC+3)
      INNOD=NODPLC(LOC+4)
C
C  ALTER Y MATRIX
C
      JSTART=IUR(IPNOD)
      JSTOP=IUR(IPNOD+1)-1
      IF (NODE2.EQ.1) GO TO 400
      CYNL(NODE2)=CYNL(NODE2)+CYNL(NODE1)
      IF (JSTART.GT.JSTOP) GO TO 400
      DO 300 J=JSTART,JSTOP
C
C  FOR EACH (N+,I) TERM, FIND THE CORRESPONDING (N-,I) TERM
C
      JO=IUC(J)
      IF (INNOD-JO) 250,210,220
C
C  DIAGONAL (N-,N-) TERM
C
  210 CYNL(NODE2)=CYNL(NODE2)+CU(J)+CUL(J)
      GO TO 300
C
C  UPPER TRIANGLE (INNOD,JO) TERM  INNOD.LT.JO OR INNOD A SOURCE NODE
C
  220 KFLAG=1
      IF (INNOD.LE.NSTOP) GO TO 260
  230 K=IUR(INNOD+1)
      KSTOP=IUR(INNOD)
  240 K=K-1
      IF (K.LT.KSTOP) GO TO 1000
      IF (IUC(K).NE.JO) GO TO 240
      IF (KFLAG) 290,1000,280
C
C  LOWER TRIANGLE (JO,INNOD) TERM  JO.LT.INNOD OR JO A SOURCE NODE
C
  250 KFLAG=-1
      IF (JO.LE.NSTOP) GO TO 230
  260 K=IUR(JO+1)
      KSTOP=IUR(JO)
  270 K=K-1
      IF (K.LT.KSTOP) GO TO 1000
      IF (IUC(K).NE.INNOD) GO TO 270
      IF (KFLAG) 290,1000,280
C
C  ADD LOWER N+ TERM TO LOWER N- TERM AND UPPER N+ TERM TO
C  UPPER N- TERM
C
  280 CU(K)=CU(K)+CU(J)
      CUL(K)=CUL(K)+CUL(J)
      GO TO 300
C
C  ADD LOWER N+ TERM TO UPPER N- TERM AND UPPER N+ TERM TO
C  LOWER N- TERM
C
  290 CU(K)=CU(K)+CUL(J)
      CUL(K)=CUL(K)+CU(J)
  300 CONTINUE
C
C  ALTER CURRENT VECTOR
C
  400 MNAM=MNAME(IELNUM)
      CVAL=SIGN*CMPLX(SOURCE(MNAM+1),SOURCE(MNAM+4))
      CVN(NODE2)=CVN(NODE2)+CVN(NODE1)-CYNL(NODE1)*CVAL
      IF (SOURCE(MNAM+1)) 410,500,410
  410 IF (JSTART.GT.JSTOP) GO TO 500
      DO 420 J=JSTART,JSTOP
      JO=IUC(J)
      NODE3=IORDER(JO)
      CVN(NODE3)=CVN(NODE3)-CU(J)*CVAL
  420 CONTINUE
  500 CONTINUE
      RETURN
 1000 IGOOF=1
      WRITE (6,1001)
 1001 FORMAT (//5X,'----------  PROGRAM ERROR ... ACLOAD'//)
      RETURN
      END
      SUBROUTINE NOISE
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
      COMMON/PARAM/VALUE(200),SOURCE(150),SYMVAL(25,25)
      COMMON/MISCEL/NOGO,IGOOF,NOPRNT,IACCT,JOBNAM(16),RTIMES(15)
      COMMON/STATUS/MODE,OMEGA,TIMEE,DELTA,DELOLD,ICALC                         8
      COMMON/KNSTNT/TWOPI,XLOG2,XLOG10,RAD,BOLTZ,CHARGE,VT
      COMMON/POINTS/IUS,ILS,MIRROR,NSTOP,NUMVS,LASTUT,LASTLT
      COMMON/OUTDAT/ROUT(101,10),FREQ(101),IONUM,IONAM(10),IOPND(10),
     1   IONND(10),IOFLG(10),NUMOR(3),IOVAR(10,2),IACVAR(5)
      COMMON/AC/JACFLG,FSTART,FSTOP,IDFREQ,FINCR,INOISE,NOSPRT,
     1   NOSOUT,NOSIN
      COMMON/TEMPER/TEMPS(6),NUMTEM,ITEMNO
      COMMON/TBLOK/FNDATA(25,5)
C
C
      DIMENSION PUTOUT(2,101,5)
      EQUIVALENCE (PUTOUT(1,1,1),ROUT(1,1))
      DIMENSION VNPART(2,1)
      EQUIVALENCE (VNPART(1,1),VN(1))
C
C
      KILL=0
      IF (ICALC.GT.1) GO TO 10
      FOURKT=4.0*CHARGE*VT
      TWOQ=2.0*CHARGE
      IPNOD=IOPND(NOSOUT)
      INNOD=IONND(NOSOUT)
      KNTR=1
   10 IF (NOSPRT.EQ.0) GO TO 30
      IF (KNTR.GT.ICALC) GO TO 30
      KILL=1
      KNTR=KNTR+NOSPRT
      WRITE (6,11) (JOBNAM(I),I=1,8),TEMPS(ITEMNO),FREQ(ICALC)
   11 FORMAT (1H7/////1X,125(1H*)///1X,8A10,26X,'-----  SPICE  -----'
     1   ///21X,'NOISE ANALYSIS',41X,'TEMPERATURE  ',F10.3,'  DEG C'///
     2   1X,125(1H*)///5X,'FREQUENCY  ',1PE10.3,'  HZ')
      WRITE (6,21)
   21 FORMAT (1HX)
C
C  OBTAIN THE ADJOINT CIRCUIT SOLUTION
C
   30 IF (KILL.EQ.1) GO TO 40
      IF (INOISE.EQ.0) RETURN
   40 VNRMS=0.0
      VREAL=VNPART(1,IPNOD)-VNPART(1,INNOD)
      VIMAG=VNPART(2,IPNOD)-VNPART(2,INNOD)
      VOUT=SQRT(VREAL*VREAL+VIMAG*VIMAG)
      IF (VOUT.LT.1.0E-20) VOUT=1.0E-20
      DO 50 I=1,NUMNOD
      VNPART(1,I)=0.0
   50 VNPART(2,I)=0.0
      VNPART(1,IPNOD)=-1.0
      VNPART(1,INNOD)=1.0
      IF (NUMVS.EQ.0) GO TO 70
      DO 60 I=1,NUMVS
      IELNUM=MATLOC(I)
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      VNPART(1,NODE2)=VNPART(1,NODE2)+VNPART(1,NODE1)
      VNPART(2,NODE2)=VNPART(2,NODE2)+VNPART(2,NODE1)
   60 CONTINUE
   70 CALL ACASOL
      VNPART(1,1)=0.0
      VNPART(2,1)=0.0
      IF (NUMVS.EQ.0) GO TO 100
      DO 80 I=1,NUMVS
      IELNUM=MATLOC(NUMVS-I+1)
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      VNPART(1,NODE1)=VNPART(1,NODE2)
      VNPART(2,NODE1)=VNPART(2,NODE2)
   80 CONTINUE
C
C  RESISTORS
C
  100 ISTOP=LOCATE(2)-1
      IF (ISTOP.LT.1) GO TO 200
      IF (KILL.EQ.0) GO TO 110
      WRITE (6,101)
  101 FORMAT (////5X,'RESISTOR SQUARED NOISE VOLTAGES (SQ V/HZ)'//
     1   5X,'NAME',9X,'TOTAL'//)
  110 DO 130 I=1,ISTOP
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      VREAL=VNPART(1,NODE1)-VNPART(1,NODE2)
      VIMAG=VNPART(2,NODE1)-VNPART(2,NODE2)
      VNO1=(VREAL*VREAL+VIMAG*VIMAG)*FOURKT*VALUE(I)
      VNRMS=VNRMS+VNO1
      IF (KILL.EQ.0) GO TO 130
      WRITE (6,121) NAME(I),VNO1
  121 FORMAT (5X,R7,7(3X,1PE9.3))
  130 CONTINUE
C
C  BIPOLAR JUNCTION TRANSISTORS
C
  200 ISTART=LOCATE(7)
      ISTOP=LOCATE(8)-1
      IF (ISTART.GT.ISTOP) GO TO 300
      IF (KILL.EQ.0) GO TO 210
      WRITE (6,201)
  201 FORMAT (////5X,'TRANSISTOR SQUARED NOISE VOLTAGES (SQ V/HZ)'//
     1   5X,'NAME',10X,'RB',10X,'RC',10X,'RE',10X,'IB',10X,'IC',10X,
     2   'FN',9X,'TOTAL'//)
  210 ISPOT=ICURNT(7)
      DO 220 I=ISTART,ISTOP
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      NODE4=NODPLC(LOC+3)
      NODE5=NODPLC(LOC+4)
      NODE6=NODPLC(LOC+5)
      MNAM=MNAME(I)
C
C  BASE RESISTANCE
C
      VREAL=VNPART(1,NODE2)-VNPART(1,NODE5)
      VIMAG=VNPART(2,NODE2)-VNPART(2,NODE5)
      VNO1=(VREAL*VREAL+VIMAG*VIMAG)*FOURKT*SYMVAL(MNAM,4)*VALUE(I)
C
C  COLLECTOR RESISTANCE
C
      VREAL=VNPART(1,NODE1)-VNPART(1,NODE4)
      VIMAG=VNPART(2,NODE1)-VNPART(2,NODE4)
      VNO2=(VREAL*VREAL+VIMAG*VIMAG)*FOURKT*SYMVAL(MNAM,5)*VALUE(I)
C
C  EMITTER RESISTANCE
C
      VREAL=VNPART(1,NODE3)-VNPART(1,NODE6)
      VIMAG=VNPART(2,NODE3)-VNPART(2,NODE6)
      VNO3=(VREAL*VREAL+VIMAG*VIMAG)*FOURKT*SYMVAL(MNAM,6)*VALUE(I)
C
C  BASE CURRENT SHOT NOISE AND FLICKER NOISE
C
      VREAL=VNPART(1,NODE5)-VNPART(1,NODE6)
      VIMAG=VNPART(2,NODE5)-VNPART(2,NODE6)
      VTEMP=VREAL*VREAL+VIMAG*VIMAG
      ARG=ABS(TRACUR(ISPOT+3))
      IF (ARG.LT.1.0E-20) ARG=1.0E-20
      VNO4=VTEMP*TWOQ*ARG
      VNO6=VTEMP*FNDATA(MNAM,1)*EXP(FNDATA(MNAM,2)*ALOG(ARG))
     1   *TWOPI/OMEGA
C
C  COLLECTOR CURRENT SHOT NOISE
C
      VREAL=VNPART(1,NODE4)-VNPART(1,NODE6)
      VIMAG=VNPART(2,NODE4)-VNPART(2,NODE6)
      VNO5=(VREAL*VREAL+VIMAG*VIMAG)*TWOQ*ABS(TRACUR(ISPOT+2))
      ISPOT=ISPOT+15
      VNTOT=VNO1+VNO2+VNO3+VNO4+VNO5+VNO6
      VNRMS=VNRMS+VNTOT
      IF (KILL.EQ.0) GO TO 220
      WRITE (6,121) NAME(I),VNO1,VNO2,VNO3,VNO4,VNO5,VNO6,VNTOT
  220 CONTINUE
C
C  JUNCTION DIODES
C
  300 ISTART=LOCATE(8)
      ISTOP=LOCATE(9)-1
      IF (ISTART.GT.ISTOP) GO TO 400
      IF (KILL.EQ.0) GO TO 310
      WRITE (6,301)
  301 FORMAT (////5X,'DIODE SQUARED NOISE VOLTAGES (SQ V/HZ)'//
     1   5X,'NAME',10X,'RS',10X,'ID',10X,'FN',9X,'TOTAL'//)
  310 DO 320 I=ISTART,ISTOP
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      MNAM=MNAME(I)
C
C  OHMIC RESISTANCE
C
      VREAL=VNPART(1,NODE1)-VNPART(1,NODE3)
      VIMAG=VNPART(2,NODE1)-VNPART(2,NODE3)
      VNO1=(VREAL*VREAL+VIMAG*VIMAG)*FOURKT*SYMVAL(MNAM,1)*VALUE(I)
C
C  JUNCTION SHOT NOISE AND FLICKER NOISE
C
      VREAL=VNPART(1,NODE3)-VNPART(1,NODE2)
      VIMAG=VNPART(2,NODE3)-VNPART(2,NODE2)
      VTEMP=VREAL*VREAL+VIMAG*VIMAG
      ARG=ABS(TRACUR(ISPOT+1))
      IF (ARG.LT.1.0E-20) ARG=1.0E-20
      VNO2=VTEMP*TWOQ*ARG
      VNO3=VTEMP*FNDATA(MNAM,1)*EXP(FNDATA(MNAM,2)*ALOG(ARG))
     1   *TWOPI/OMEGA
      ISPOT=ISPOT+5
      VNTOT=VNO1+VNO2+VNO3
      VNRMS=VNRMS+VNTOT
      IF (KILL.EQ.0) GO TO 320
      WRITE (6,121) NAME(I),VNO1,VNO2,VNO3,VNTOT
  320 CONTINUE
C
C  JFETS
C
  400 ISTART=LOCATE(9)
      ISTOP=LOCATE(10)-1
      IF (ISTART.GT.ISTOP) GO TO 500
      IF (KILL.EQ.0) GO TO 410
      WRITE (6,401)
  401 FORMAT (////5X,'JFET SQUARED NOISE VOLTAGES (SQ V/HZ)'//
     1   5X,'NAME',10X,'RD',10X,'RS',10X,'ID',10X,'FN',9X,'TOTAL'//)
  410 ISPOT=ICURNT(9)
      DO 420 I=ISTART,ISTOP
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      NODE4=NODPLC(LOC+3)
      NODE5=NODPLC(LOC+4)
      MNAM=MNAME(I)
C
C  DRAIN RESISTANCE
C
      VREAL=VNPART(1,NODE1)-VNPART(1,NODE4)
      VIMAG=VNPART(2,NODE1)-VNPART(2,NODE4)
      VNO1=(VREAL*VREAL+VIMAG*VIMAG)*FOURKT*SYMVAL(MNAM,5)*VALUE(I)
C
C  SOURCE RESISTANCE
C
      VREAL=VNPART(1,NODE3)-VNPART(1,NODE5)
      VIMAG=VNPART(2,NODE3)-VNPART(2,NODE5)
      VNO2=(VREAL*VREAL+VIMAG*VIMAG)*FOURKT*SYMVAL(MNAM,6)*VALUE(I)
C
C  DRAIN CURRENT SHOT NOISE AND FLICKER NOISE
C
      VREAL=VNPART(1,NODE4)-VNPART(1,NODE5)
      VIMAG=VNPART(2,NODE4)-VNPART(2,NODE5)
      VTEMP=VREAL*VREAL+VIMAG*VIMAG
      VNO3=VTEMP*FOURKT*2.0*ABS(TRACUR(ISPOT+3))/3.0
      ARG=ABS(TRACUR(ISPOT+2))
      IF (ARG.LT.1.0E-20) ARG=1.0E-20
      VNO4=VTEMP*FNDATA(MNAM,1)*EXP(FNDATA(MNAM,2)*ALOG(ARG))
     1   *TWOPI/OMEGA
      ISPOT=ISPOT+10
      VNTOT=VNO1+VNO2+VNO3+VNO4
      VNRMS=VNRMS+VNTOT
      IF (KILL.EQ.0) GO TO 420
      WRITE (6,121) NAME(I),VNO1,VNO2,VNO3,VNO4,VNTOT
  420 CONTINUE
C
C  MOSFETS
C
  500 ISTART=LOCATE(10)
      ISTOP=LOCATE(11)-1
      IF (ISTART.GT.ISTOP) GO TO 600
      IF (KILL.EQ.0) GO TO 510
      WRITE (6,501)
  501 FORMAT (////5X,'MOSFET SQUARED VOISE VOLTAGES (SQ V/HZ)'//
     1   5X,'NAME',10X,'RD',10X,'RS',10X,'ID',10X,'FN',9X,'TOTAL'//)
  510 ISPOT=ICURNT(10)
      DO 520 I=ISTART,ISTOP
      LOC=LOCAL(I)
      NODE1=NODPLC(LOC)
      NODE2=NODPLC(LOC+1)
      NODE3=NODPLC(LOC+2)
      NODE5=NODPLC(LOC+4)
      NODE6=NODPLC(LOC+5)
      MNAM=MNAME(I)
C
C  DRAIN RESISTANCE
C
      VREAL=VNPART(1,NODE1)-VNPART(1,NODE5)
      VIMAG=VNPART(2,NODE1)-VNPART(2,NODE5)
      VNO1=(VREAL*VREAL+VIMAG*VIMAG)*FOURKT*SYMVAL(MNAM,7)*VALUE(I)
C
C  SOURCE RESISTANCE
C
      VREAL=VNPART(1,NODE3)-VNPART(1,NODE6)
      VIMAG=VNPART(2,NODE3)-VNPART(2,NODE6)
      VNO2=(VREAL*VREAL+VIMAG*VIMAG)*FOURKT*SYMVAL(MNAM,8)*VALUE(I)
C
C  DRAIN CURRENT SHOT NOISE AND FLICKER NOISE
C
      VREAL=VNPART(1,NODE5)-VNPART(1,NODE6)
      VIMAG=VNPART(2,NODE5)-VNPART(2,NODE6)
      VTEMP=VREAL*VREAL+VIMAG*VIMAG
      VNO3=VTEMP*FOURKT*2.0*ABS(TRACUR(ISPOT+3))/3.0
      ARG=ABS(TRACUR(ISPOT+2))
      IF (ARG.LT.1.0E-20) ARG=1.0E-20
      VNO4=VTEMP*FNDATA(MNAM,1)*EXP(FNDATA(MNAM,2)*ALOG(ARG))
     1   *TWOPI/OMEGA
      ISPOT=ISPOT+15
      VNTOT=VNO1+VNO2+VNO3+VNO4
      VNRMS=VNRMS+VNTOT
      IF (KILL.EQ.0) GO TO 520
      WRITE (6,121) NAME(I),VNO1,VNO2,VNO3,VNO4,VNTOT
  520 CONTINUE
C
C  COMPUTE EQUIVALENT INPUT NOISE VOLTAGE
C
  600 VNOUT=SQRT(VNRMS)
      VNIN=VNOUT/VOUT
      IF (KILL.EQ.0) GO TO 620
      WRITE (6,601) VNRMS,VNOUT,IONAM(NOSOUT),NAME(NOSIN),VOUT,
     1   NAME(NOSIN),VNIN
  601 FORMAT (////////5X,'TOTAL OUTPUT NOISE VOLTAGE',4X,1PE10.3,
     1   '  SQ V/HZ',6X,'=',4X,E10.3,'  V/RT HZ'//5X,'TRANSFER '
     2   'FUNCTION VALUE  ( ',R7,'/ ',R7,')',16X,E10.3//5X,
     3   'EQUIVALENT INPUT NOISE   (AT  ',R7,')',22X,E10.3,
     4   '   /RT HZ')
      WRITE (6,611)
  611 FORMAT (1HY)
  620 IF (INOISE.EQ.0) RETURN
      PUTOUT(1,ICALC,INOISE)=VNOUT
      PUTOUT(2,ICALC,INOISE)=VNIN
      RETURN
      END
      SUBROUTINE ACASOL
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/POINTS/IUS,ILS,MIRROR,NSTOP,NUMVS,LASTUT,LASTLT
C
C
      COMPLEX CYNL(1),CVN(1),CU(1),CUL(1)
      EQUIVALENCE (CYNL(1),YNL(1)),(CVN(1),VN(1))
      EQUIVALENCE (CU(1),CYNL(402)),(CUL(1),CYNL(1202))
C
C
      LE=NSTOP-1
      IF (LE) 60,5,10
    5 IB=IORDER(1)
      CVN(IB)=CVN(IB)/CYNL(IB)
      RETURN
C
C  FORWARD SUBSTITUTION
C
   10 DO 30 I=1,LE
      L=IORDER(I)
      CVN(L)=CVN(L)/CYNL(L)
      IUST=IUR(I)
      IUE=IUR(I+1)-1
      IF (IUST.GT.IUE) GO TO 30
      DO 20 IU=IUST,IUE
      II=IUC(IU)
      IC=IORDER(II)
      CVN(IC)=CVN(IC)-CVN(L)*CU(IU)
   20 CONTINUE
   30 CONTINUE
C
C  BACK SUBSTITUTION
C
      IB=IORDER(NSTOP)
      CVN(IB)=CVN(IB)/CYNL(IB)
      DO 50 I=1,LE
      IB=IORDER(NSTOP-I)
      IUST=IUR(NSTOP-I)
      IUE=IUR(NSTOP-I+1)-1
      IF (IUST.GT.IUE) GO TO 50
      DO 40 IU=IUST,IUE
      JJ=IUC(IU)
      JB=IORDER(JJ)
      CVN(IB)=CVN(IB)-CUL(IU)*CVN(JB)
   40 CONTINUE
   50 CONTINUE
   60 RETURN
      END
      SUBROUTINE ACCAL(IELNUM,CREAL,CIMAG)
      COMMON NODPLC(800),YNL(2001),TSTORE(2001),TRACUR(1700),VN(401),
     1   VNIM1(401),IORDER(401),IUR(402),IUC(800),MATLOC(1800)
      COMMON/INDATA/NUMEL,NUNODS,NUMNOD,NOSTOP,JELCNT(20),LOCATE(21),
     1   ICURNT(21),JUNODE(401),NAME(200),LOCAL(200),MNAME(200)
C
C
      COMPLEX CUR,CYNL(1),CVN(1),CUL(1)
      EQUIVALENCE (CYNL(1),YNL(1)),(CVN(1),VN(1))
      EQUIVALENCE (CUL(1),CYNL(1202))
C
C
      CREAL=0.0
      CIMAG=0.0
      LOC=LOCAL(IELNUM)
      NODE1=NODPLC(LOC)
      SIGN=NODPLC(LOC+2)
      IPNOD=NODPLC(LOC+3)
      ISPOT=ICURNT(6)+2*(IELNUM-LOCATE(6))
      ISTART=IUR(IPNOD)
      ISTOP=IUR(IPNOD+1)-1
      CUR=CMPLX(TRACUR(ISPOT),TRACUR(ISPOT+1))-CYNL(NODE1)*CVN(NODE1)
      IF (ISTART.GT.ISTOP) GO TO 40
      DO 30 I=ISTART,ISTOP
      J=IUC(I)
      JO=IORDER(J)
      CUR=CUR-CUL(I)*CVN(JO)
   30 CONTINUE
   40 CREAL=SIGN*REAL(CUR)
      CIMAG=SIGN*AIMAG(CUR)
      RETURN
      END