c spice version 2g.6  sccsid=readin.ma 3/22/83
      subroutine readin
      implicit double precision (a-h,o-z)
c
c
c     this routine drives the input processing of spice.  element cards
c and device models are handled by this routine.
c
c spice version 2g.6  sccsid=tabinf 3/15/83
      common /tabinf/ ielmnt,isbckt,nsbckt,iunsat,nunsat,itemps,numtem,
     1   isens,nsens,ifour,nfour,ifield,icode,idelim,icolum,insize,
     2   junode,lsbkpt,numbkp,iorder,jmnode,iur,iuc,ilc,ilr,numoff,isr,
     3   nmoffc,iseq,iseq1,neqn,nodevs,ndiag,iswap,iequa,macins,lvnim1,
     4   lx0,lvn,lynl,lyu,lyl,lx1,lx2,lx3,lx4,lx5,lx6,lx7,ld0,ld1,ltd,
     5   imynl,imvn,lcvn,nsnod,nsmat,nsval,icnod,icmat,icval,
     6   loutpt,lpol,lzer,irswpf,irswpr,icswpf,icswpr,irpt,jcpt,
     7   irowno,jcolno,nttbr,nttar,lvntmp
c spice version 2g.6  sccsid=miscel 3/15/83
      common /miscel/ atime,aprog(3),adate,atitle(10),defl,defw,defad,
     1  defas,rstats(50),iwidth,lwidth,nopage
c spice version 2g.6  sccsid=line 3/15/83
      common /line/ achar,afield(15),oldlin(15),kntrc,kntlim
c spice version 2g.6  sccsid=cirdat 3/15/83
      common /cirdat/ locate(50),jelcnt(50),nunods,ncnods,numnod,nstop,
     1   nut,nlt,nxtrm,ndist,ntlin,ibr,numvs,numalt,numcyc
c spice version 2g.6  sccsid=status 3/15/83
      common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet,
     1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon,
     2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile
c spice version 2g.6  sccsid=flags 3/15/83
      common /flags/ iprnta,iprntl,iprntm,iprntn,iprnto,limtim,limpts,
     1   lvlcod,lvltim,itl1,itl2,itl3,itl4,itl5,itl6,igoof,nogo,keof
c spice version 2g.6  sccsid=knstnt 3/15/83
      common /knstnt/ twopi,xlog2,xlog10,root2,rad,boltz,charge,ctok,
     1   gmin,reltol,abstol,vntol,trtol,chgtol,eps0,epssil,epsox,
     2   pivtol,pivrel
c spice version 2g.6  sccsid=dc 3/15/83
      common /dc/ tcstar(2),tcstop(2),tcincr(2),icvflg,itcelm(2),kssop,
     1   kinel,kidin,kovar,kidout
c spice version 2g.6  sccsid=ac 3/15/83
      common /ac/ fstart,fstop,fincr,skw2,refprl,spw2,jacflg,idfreq,
     1   inoise,nosprt,nosout,nosin,idist,idprt
c spice version 2g.6  sccsid=tran 3/15/83
      common /tran/ tstep,tstop,tstart,delmax,tdmax,forfre,jtrflg
c spice version 2g.6  sccsid=outinf 3/15/83
      common /outinf/ xincr,string(15),xstart,yvar(8),itab(8),itype(8),
     1   ilogy(8),npoint,numout,kntr,numdgt
c spice version 2g.6  sccsid=cje 3/15/83
      common /cje/ maxtim,itime,icost
c spice version 2g.6  sccsid=debug 3/15/83
      common/debug/ idebug(20)
c spice version 2g.6  sccsid=blank 3/15/83
      common /blank/ value(50000)
      integer nodplc(64)
      complex cvalue(32)
      equivalence (value(1),nodplc(1),cvalue(1))
c
c  control card identifiers
c
      dimension aide(20),nnods(20),ntnods(20),l2nod(24)
      dimension numic(4)
      dimension aidm(7),ipolar(7),modid(7),ipar(5),ampar(115)
      dimension titinp(4)
      dimension aidc(22)
      data titinp / 8hinput li, 8hsting   , 8h        , 8h         /
      data naidc / 22 /
      data aidc / 8hac      , 8hdc      , 8hdistorti, 8hend     ,
     1            8hends    , 8hfourier , 8hmodel   , 8hnoise   ,
     2            8hop      , 8hoptions , 8hplot    , 8hprint   ,
     3            8hsubckt  , 8hsensitiv, 8htransien, 8htf      ,
     4            8htemperat, 8hwidth   , 8hnodeset , 8hic      ,
     5            8h:debug: , 8halter   /
c
c  element card identifiers, keywords, and information
c
      data aide / 1hr,1hc,1hl,1hk,1hg,1he,1hf,1hh,1hv,1hi,1hd,1hq,1hj,
     1   1hm,1hs,1hy,1ht,0.0d0,1hx,0.0d0 /
      data alsac,alspu,alsex,alssi /2hac,2hpu,2hex,2hsi/
      data alsoff,alsdc,alspw / 3hoff,2hdc,3hpw  /
      data alsz0,alszo,alsnl,alsf,alstd / 2hz0,2hzo,2hnl,1hf,2htd /
      data alsl,alsw,alsas,alsad,alspd,alsps,alsrds,alsrss,alsxqc
     1   /1hl,1hw,2has,2had,2hpd,2hps,3hnrd,3hnrs,3hxqc/
      data alszx /2hzx/
      data alssf / 4hsf   /
      data apoly, aic, area / 4hpoly, 2hic, 4harea /
      data alstc / 2htc /
      data numic / 1, 2, 2, 3 /
      data ablnk, aper / 1h , 1h. /
      data nnods / 2,2,2,0,2,2,2,2,2,2,2,3,3,4,4,4,4,0,0,0 /
      data ntnods / 2,2,2,0,2,2,2,2,2,2,3,6,5,6,4,4,4,0,0,0 /
      data l2nod / 8,12,14, 6,13,14,13,14,11, 6,
     1            16,36,25,33, 6, 6,33, 0, 3, 3,
     2             3, 3, 3, 3 /
c
c  model card keywords
c
      data aidm /1hd,3hnpn,3hpnp,3hnjf,3hpjf,4hnmos,4hpmos/
      data ipolar /0,1,-1,1,-1,1,-1/
      data modid /1,2,2,3,3,4,4/
      data ipar / 0, 14, 60, 72, 114/
      data ampar /
     1   6his    ,6hrs    ,6hn     ,6htt    ,6hcjo   ,6hvj    ,6hm     ,
     2   6heg    ,6hxti   ,6hkf    ,6haf    ,6hfc    ,6hbv    ,6hibv   ,
     1   6his    ,6hbf    ,6hnf    ,6hvaf   ,6hikf   ,6hise   ,6hne    ,
     2   6hbr    ,6hnr    ,6hvar   ,6hikr   ,6hisc   ,6hnc    ,6h0     ,
     3   6h0     ,6hrb    ,6hirb   ,6hrbm   ,6hre    ,6hrc    ,6hcje   ,
     4   6hvje   ,6hmje   ,6htf    ,6hxtf   ,6hvtf   ,6hitf   ,6hptf   ,
     5   6hcjc   ,6hvjc   ,6hmjc   ,6hxcjc  ,6htr    ,6h0     ,6h0     ,
     6   6h0     ,6h0     ,6hcjs   ,6hvjs   ,6hmjs   ,6hxtb   ,6heg    ,
     7   6hxti   ,6hkf    ,6haf    ,6hfc    ,
     1   6hvto   ,6hbeta  ,6hlambda,6hrd    ,6hrs    ,6hcgs   ,6hcgd   ,
     2   6hpb    ,6his    ,6hkf    ,6haf    ,6hfc    ,
     1   6hlevel ,6hvto   ,6hkp    ,6hgamma ,6hphi   ,6hlambda,6hrd    ,
     2   6hrs    ,6hcbd   ,6hcbs   ,6his    ,6hpb    ,6hcgso  ,6hcgdo  ,
     3   6hcgbo  ,6hrsh   ,6hcj    ,6hmj    ,6hcjsw  ,6hmjsw  ,6hjs    ,
     4   6htox   ,6hnsub  ,6hnss   ,6hnfs   ,6htpg   ,6hxj    ,6hld    ,
     5   6huo    ,6hucrit ,6huexp  ,6hutra  ,6hvmax  ,6hneff  ,6hxqc   ,
     6   6hkf    ,6haf    ,6hfc    ,6hdelta ,6htheta ,6heta   ,6hkappa ,
     7   0.0d0   /
c
c  initialize variables
c
      call second(t1)
      call zero4(idebug,20)
      call getlin
      if (keof.ne.0) go to 6000
      call copy8(afield,atitle,10)
      call getm4(ielmnt,0)
      call getm8(itemps,1)
      value(itemps+1)=27.0d0
      itemno=1
      nopage=0
      call title(-1,72,1,titinp)
      iwidth=80
      do 5 i=1,8
      achar=ablnk
      call move(achar,1,atitle(10),i,1)
      if(achar.eq.ablnk) go to 8
    5 continue
      write(iofile,6)
    6 format('0warning:  input line-width set to 72 columns because',/
     11x,'possible sequencing appears in cols 73-80')
      iwidth=72
    8 do 10 i=1,15
      afield(i)=ablnk
   10 continue
      call copy8(afield,oldlin,15)
      call getm4(isbckt,0)
      nsbckt=0
      call getm8(iunsat,0)
      nunsat=0
      numalt=0
      numcyc=0
      lwidth=132
      iprnta=0
      iprntl=0
      iprntm=1
      iprntn=0
      iprnto=0
      gmin=1.0d-12
      pivtol=1.0d-13
      pivrel=1.0d-3
      reltol=0.001d0
      abstol=1.0d-12
      vntol=1.0d-6
      trtol=7.0d0
      chgtol=1.0d-14
      defl=1.0d-4
      defw=1.0d-4
      defad=0.0d0
      defas=0.0d0
      numdgt=4
      numtem=1
      itl1=100
      itl2=50
      itl3=4
      itl4=10
      itl5=5000
      itl6=0
      limtim=2
      limpts=201
      lvlcod=1
      lvltim=2
      method=1
      xmu=0.5d0
      maxord=2
      nosolv=0
      icvflg=0
      itcelm(2)=0
      idist=0
      idprt=0
      inoise=0
      jacflg=0
      jtrflg=0
      call getm4(ifour,0)
      nfour=0
      call getm4(nsnod,0)
      call getm8(nsval,0)
      call getm4(icnod,0)
      call getm8(icval,0)
      kinel=0
      kovar=0
      kssop=0
      nosprt=0
      nsens=0
      call getm4(isens,0)
      numnod=0
      ncnods=0
      nunods=0
      call zero4(locate,50)
      call zero4(jelcnt,50)
      insize=50
      call getm8(ifield,insize)
      call getm4(icode,insize)
      call getm8(idelim,insize)
      call getm4(icolum,insize)
      go to 50
c
c  error entry
c
   40 nogo=1
c
c  read and decode next card in input deck
c
   50 igoof=0
      call card
      if (keof.ne.0) go to 5000
      if (igoof.ne.0) go to 40
      if (nodplc(icode+1).eq.0) go to 95
      anam=value(ifield+1)
      call move(anam,2,ablnk,1,7)
      if (anam.ne.aper) go to 70
      call move(anam,1,value(ifield+1),2,7)
      call keysrc(aidc,naidc,anam,id)
      if (id.le.0) go to 90
      if (id.eq.4) go to 5000
      if (id.eq.5) go to 800
      if (id.eq.7) go to 500
      if (id.eq.13) go to 700
      if (id.eq.22) numalt=numalt+1
      if (nsbckt.ge.1) go to 85
      if (id.ne.22) call runcon(id)
      if (igoof.ne.0) go to 40
      go to 50
   70 id=0
   80 id=id+1
      if (id.gt.20) go to 90
      if (anam.eq.aide(id)) go to 100
      go to 80
   85 write (iofile,86)
   86 format('0warning:  above line not allowed within subcircuit -- ',
     1   'ignored'/)
      go to 50
   90 write (iofile,91) value(ifield+1)
   91 format('0*error*:  unknown data card:  ',a8/)
      go to 40
   95 write (iofile,96)
   96 format('0*error*:  unrecognizable data card'/)
      go to 40
c
c  element and device cards
c
  100 call find(value(ifield+1),id,loc,1)
      locv=nodplc(loc+1)
      if (id.eq.4) go to 140
      if (id.eq.19) go to 900
      istop=nnods(id)+1
      if (nodplc(loc+l2nod(id)).ne.0) go to 113
      do 110 i=2,istop
      if (nodplc(icode+i).ne.0) go to 410
      if (value(ifield+i).lt.0.0d0) go to 400
  110 nodplc(loc+i)=value(ifield+i)
      go to 115
  113 do 114 i=2,istop
      nodplc(loc+i)=0
  114 continue
  115 go to (120,130,130,140,150,150,180,180,200,200,300,300,300,300,
     1   390,390,350,390,390,390), id
c
c  resistor
c
  120 if (nodplc(icode+4).ne.0) go to 420
      if (value(ifield+4).eq.0.0d0) go to 480
      value(locv+2)=value(ifield+4)
      ifld=4
  122 ifld=ifld+1
      if (nodplc(icode+ifld)) 50,122,124
  124 anam=value(ifield+ifld)
      if (anam.ne.alstc) go to 460
      ifld=ifld+1
      if (nodplc(icode+ifld)) 50,126,124
  126 value(locv+3)=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld)) 50,128,124
  128 value(locv+4)=value(ifield+ifld)
      go to 50
c
c  capacitor or inductor
c
  130 iknt=0
      ltab=7
      if (id.eq.3) ltab=10
      if (nodplc(icode+4)) 420,131,132
  131 if (value(ifield+4).le.0.0d0) go to 420
      value(locv+1)=value(ifield+4)
      nodplc(loc+4)=1
      ifld=5
      if (nodplc(icode+ifld)) 50,420,139
  132 call getm8(nodplc(loc+ltab),0)
      anam=value(ifield+4)
      if (anam.ne.apoly) go to 450
      ifld=4
  134 ifld=ifld+1
      if (nodplc(icode+ifld)) 50,136,138
  136 call extmem(nodplc(loc+ltab),1)
      iknt=iknt+1
      ispot=nodplc(loc+ltab)+iknt
      value(ispot)=value(ifield+ifld)
      go to 134
  138 if (iknt.eq.0) go to 420
  139 anam=value(ifield+ifld)
      if (anam.ne.aic) go to 460
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 50
      value(locv+2)=value(ifield+ifld)
      go to 50
c
c  mutual inductance
c
  140 if (nodplc(icode+2).ne.1) go to 430
      anam=value(ifield+2)
      call move(anam,2,ablnk,1,7)
      if (anam.ne.aide(3)) go to 430
      call extnam(value(ifield+2),nodplc(loc+2))
      if (nodplc(icode+3).ne.1) go to 430
      anam=value(ifield+3)
      call move(anam,2,ablnk,1,7)
      if (anam.ne.aide(3)) go to 430
      call extnam(value(ifield+3),nodplc(loc+3))
      if (nodplc(icode+4).ne.0) go to 420
      xk=value(ifield+4)
      if (xk.le.0.0d0) go to 420
      if (xk.le.1.0d0) go to 145
      xk=1.0d0
      write (iofile,141)
  141 format('0warning:  coefficient of coupling reset to 1.0d0'/)
  145 value(locv+1)=xk
      go to 50
c
c  voltage controlled (nonlinear) sources
c
  150 ndim=1
      ifld=3
      if (nodplc(icode+4)) 410,156,152
  152 anam=value(ifield+4)
      if (anam.ne.apoly) go to 450
      if (nodplc(icode+5).ne.0) go to 420
      ndim=value(ifield+5)
      if (ndim.le.0) go to 420
      ifld=5
  156 nodplc(loc+4)=ndim
      ltab=id+1
      nssnod=2*ndim
      nmat=4*ndim
      if (id.eq.6) nmat=4+2*ndim
      call getm4(nodplc(loc+ltab),nssnod)
      call getm4(nodplc(loc+ltab+1),nmat)
      call getm8(nodplc(loc+ltab+2),0)
      call getm8(nodplc(loc+ltab+3),ndim)
      call getm4(nodplc(loc+ltab+4),ndim)
      call getm8(nodplc(loc+ltab+5),ndim)
      ispot=nodplc(loc+ltab+5)
      call zero8(value(ispot+1),ndim)
      lnod=nodplc(loc+ltab)
      do 158 i=1,nssnod
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 410
      if (value(ifield+ifld).lt.0.0d0) go to 400
      nodplc(lnod+i)=value(ifield+ifld)
  158 continue
  160 iknt=0
  162 ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 164
      call extmem(nodplc(loc+ltab+2),1)
      iknt=iknt+1
      ispot=nodplc(loc+ltab+2)+iknt
      value(ispot)=value(ifield+ifld)
      go to 162
  164 if (iknt.eq.0) go to 420
      if (nodplc(icode+ifld).ne.1) go to 170
      anam=value(ifield+ifld)
      if (anam.ne.aic) go to 460
      do 168 i=1,ndim
      ifld=ifld+1
      if (nodplc(icode+ifld)) 170,166,420
  166 ispot=nodplc(loc+ltab+5)+i
      value(ispot)=value(ifield+ifld)
  168 continue
  170 if (ndim.ne.1) go to 50
      if (iknt.ne.1) go to 50
      call extmem(nodplc(loc+ltab+2),1)
      ispot=nodplc(loc+ltab+2)
      value(ispot+2)=value(ispot+1)
      value(ispot+1)=0.0d0
      go to 50
c
c  current controlled (nonlinear) sources
c
  180 ndim=1
      ifld=3
      if (nodplc(icode+4).ne.1) go to 470
      anam=value(ifield+4)
      if (anam.ne.apoly) go to 182
      ifld=5
      if (nodplc(icode+5).ne.0) go to 420
      ndim=value(ifield+5)
      if (ndim.le.0) go to 420
  182 nodplc(loc+4)=ndim
      ltab=id-1
      nmat=2*ndim
      if (id.eq.8) nmat=4+ndim
      call getm4(nodplc(loc+ltab),ndim)
      call getm4(nodplc(loc+ltab+1),nmat)
      call getm8(nodplc(loc+ltab+2),0)
      call getm8(nodplc(loc+ltab+3),ndim)
      call getm4(nodplc(loc+ltab+4),ndim)
      call getm8(nodplc(loc+ltab+5),ndim)
      ispot=nodplc(loc+ltab+5)
      call zero8(value(ispot+1),ndim)
      do 184 i=1,ndim
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.1) go to 470
      anam=value(ifield+ifld)
      call move(anam,2,ablnk,1,7)
      if (anam.ne.aide(9)) go to 470
      call extnam(value(ifield+ifld),loct)
      ispot=nodplc(loc+ltab)+i
      nodplc(ispot)=loct
  184 continue
      go to 160
c
c  independent sources
c
  200 ifld=3
      call getm8(nodplc(loc+5),0)
  210 ifld=ifld+1
  215 if (nodplc(icode+ifld)) 50,220,230
  220 if (ifld.gt.4) go to 210
  225 value(locv+1)=value(ifield+ifld)
      go to 210
  230 anam=value(ifield+ifld)
      if (anam.ne.alsdc) go to 235
      ifld=ifld+1
      if (nodplc(icode+ifld)) 50,225,230
  235 if (anam.ne.alsac) go to 260
      value(locv+2)=1.0d0
      ifld=ifld+1
      if (nodplc(icode+ifld)) 50,240,230
  240 value(locv+2)=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld)) 50,250,230
  250 value(locv+3)=value(ifield+ifld)
      go to 210
  260 id=0
      call move(anam,3,ablnk,1,6)
      if (anam.eq.alspu) id=1
      if (anam.eq.alssi) id=2
      if (anam.eq.alsex) id=3
      if (anam.eq.alspw) id=4
      if (anam.eq.alssf) id=5
      if (id.eq.0) go to 450
      nodplc(loc+4)=id
      iknt=0
  270 ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 280
      call extmem(nodplc(loc+5),1)
      iknt=iknt+1
      ispot=nodplc(loc+5)+iknt
      value(ispot)=value(ifield+ifld)
      go to 270
  280 aval=0.0d0
      if (id.ne.4) go to 285
c...  for pwl source function, force even number of input values
      ibit=0
      if(iknt.ne.(iknt/2)*2) ibit=1
      aval=value(ispot)
      if (ibit.eq.0) go to 290
      call extmem(nodplc(loc+5),1)
      aval=value(ispot-1)
      iknt=iknt+1
      ispot=nodplc(loc+5)+iknt
      value(ispot)=aval
      go to 290
  285 if (iknt.ge.7) go to 215
  290 call extmem(nodplc(loc+5),2)
      ispot=nodplc(loc+5)+iknt
      value(ispot+1)=0.0d0
      value(ispot+2)=aval
      iknt=iknt+2
      go to 285
c
c  device cards
c
  300 value(locv+1)=1.0d0
      if (id.ne.14) go to 305
      value(locv+1)=0.0d0
      value(locv+11)=0.0d0
      value(locv+12)=0.0d0
      value(locv+13)=1.0d0
      value(locv+14)=1.0d0
      value(locv+15)=0.0d0
  305 locm=loc+ntnods(id)+2
      ifld=nnods(id)+2
c
c  temporarily (until modchk) put bjt's substrate node into nodplc(loc+5)
c
      if(id.ne.12) go to 308
      if(nodplc(icode+5).ne.0) go to 308
      ifld=6
      if (nodplc(loc+l2nod(id)).ne.0) go to 306
      nodplc(loc+5)=value(ifield+5)
      go to 308
  306 nodplc(loc+5)=0
  308 continue
c
c    reserve device internal nodes,read device geometry parameters
c    and initial conditions
c
      if (nodplc(icode+ifld).ne.1) go to 440
      call extnam(value(ifield+ifld),nodplc(locm))
  310 ifld=ifld+1
      if (nodplc(icode+ifld)) 50,325,315
  315 anam=value(ifield+ifld)
      if (anam.ne.alsoff) go to 320
      nodplc(locm+1)=1
      go to 310
  320 if (anam.ne.area) go to 330
      ifld=ifld+1
      if (nodplc(icode+ifld)) 50,325,315
  325 if (value(ifield+ifld).le.0.0d0) go to 420
      if (id.eq.14) go to 343
      value(locv+1)=value(ifield+ifld)
      go to 310
  330 if (anam.ne.aic) go to 341
      iknt=0
      icloc=0
      if (id.eq.14) icloc=3
      maxknt=numic(id-10)
  335 ifld=ifld+1
      if (nodplc(icode+ifld)) 50,340,315
  340 iknt=iknt+1
      if (iknt.gt.maxknt) go to 335
      value(locv+icloc+iknt+1)=value(ifield+ifld)
      go to 335
  341 if (id.ne.14) go to 460
      ispot=0
      if (anam.eq.alsl) ispot=1
      if (anam.eq.alsw) ispot=2
      if (anam.eq.alsad) ispot=3
      if (anam.eq.alszx) ispot=3
      if (anam.eq.alsas) ispot=4
      if (anam.eq.alspd) ispot=11
      if (anam.eq.alsps) ispot=12
      if (anam.eq.alsrds) ispot=13
      if (anam.eq.alsrss) ispot=14
      if (anam.eq.alsxqc) ispot=15
      if (ispot.eq.0) go to 460
      ifld=ifld+1
      if (nodplc(icode+ifld)) 50,342,315
  342 if (value(ifield+ifld).le.0.0d0) go to 420
      value(locv+ispot)=value(ifield+ifld)
      go to 310
  343 iknt=0
  344 iknt=iknt+1
      if(value(ifield+ifld).le.0.0d0) go to 420
      if(iknt.gt.15) go to 490
      if(iknt.eq.5) iknt=11
      value(locv+iknt)=value(ifield+ifld)
      ifld=ifld+1
      if(nodplc(icode+ifld)) 345,344,345
  345 if(nodplc(icode+ifld)) 50,50,315
c
c  transmission lines
c
  350 ifld=5
      xnl=0.25d0
      tfreq=0.0d0
  355 ifld=ifld+1
      if (nodplc(icode+ifld)) 378,355,360
  360 anam=value(ifield+ifld)
      if (anam.eq.aic) go to 364
      if (anam.eq.alsnl) go to 370
      if (anam.eq.alsf) go to 374
      id=0
      if (anam.eq.alsz0) id=1
      if (anam.eq.alszo) id=1
      if (anam.eq.alstd) id=2
      if (id.eq.0) go to 460
      ifld=ifld+1
      if (nodplc(icode+ifld)) 378,362,360
  362 if (value(ifield+ifld).le.0.0d0) go to 420
      value(locv+id)=value(ifield+ifld)
      go to 355
  364 iknt=0
  366 ifld=ifld+1
      if (nodplc(icode+ifld)) 378,368,360
  368 iknt=iknt+1
      if (iknt.gt.4) go to 366
      value(locv+iknt+4)=value(ifield+ifld)
      go to 366
  370 ifld=ifld+1
      if (nodplc(icode+ifld)) 378,372,360
  372 if (value(ifield+ifld).le.0.0d0) go to 420
      xnl=value(ifield+ifld)
      go to 355
  374 ifld=ifld+1
      if (nodplc(icode+ifld)) 378,376,360
  376 if (value(ifield+ifld).le.0.0d0) go to 420
      tfreq=value(ifield+ifld)
      go to 355
  378 if (value(locv+1).ne.0.0d0) go to 380
      write (iofile,379)
  379 format('0*error*:  z0 must be specified'/)
      go to 40
  380 if (value(locv+2).ne.0.0d0) go to 50
      if (tfreq.ne.0.0d0) go to 382
      write (iofile,381)
  381 format('0*error*:  either td or f must be specified'/)
      go to 40
  382 value(locv+2)=xnl/tfreq
      go to 50
c
c  elements not yet implemented
c
  390 write (iofile,391)
  391 format('0*error*:  element type not yet implemented'/)
      go to 40
c
c  element card errors
c
  400 write (iofile,401)
  401 format('0*error*:  negative node number found'/)
      go to 40
  410 write (iofile,411)
  411 format('0*error*:  node numbers are missing'/)
      go to 40
  420 write (iofile,421)
  421 format('0*error*:  value is missing or is nonpositive'/)
      go to 40
  430 write (iofile,431)
  431 format('0*error*:  mutual inductance references are missing'/)
      go to 40
  440 write (iofile,441)
  441 format('0*error*:  model name is missing'/)
      go to 40
  450 write (iofile,451) anam
  451 format('0*error*:  unknown source function:  ',a8)
      go to 40
  460 write (iofile,461) anam
  461 format('0*error*:  unknown parameter:  ',a8/)
      go to 40
  470 write (iofile,471)
  471 format('0*error*:  voltage source not found on above line'/)
      go to 40
  480 write (iofile,481)
  481 format('0*error*:  value is zero'/)
      go to 40
  490 write(iofile,491)
  491 format('0*error*:  extra numerical data on mosfet card'/)
      go to 40
c
c  model card
c
  500 if (nodplc(icode+2).ne.1) go to 650
      if (nodplc(icode+3).ne.1) go to 650
      id=0
  510 id=id+1
      if (id.gt.7) go to 660
      if (value(ifield+3).ne.aidm(id)) go to 510
      ipol=ipolar(id)
      jtype=modid(id)
      id=jtype+20
      call find(value(ifield+2),id,loc,1)
      nodplc(loc+2)=ipol
      locv=nodplc(loc+1)
  520 locm=ipar(jtype)
      nopar=ipar(jtype+1)-locm
      ifld=3
  530 ifld=ifld+1
      if (nodplc(icode+ifld)) 50,530,560
  560 anam=value(ifield+ifld)
      if(jtype.eq.2) anam=alias(anam)
      iknt=0
  570 iknt=iknt+1
      if (iknt.gt.nopar) go to 670
      if (anam.ne.ampar(locm+iknt)) go to 570
      ifld=ifld+1
      if (nodplc(icode+ifld)) 50,580,560
  580 value(locv+iknt)=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld)) 50,590,560
  590 iknt=iknt+1
      if (iknt.gt.nopar) go to 530
      if (ablnk.ne.ampar(locm+iknt)) go to 530
      go to 580
c
c  model card errors
c
  650 write (iofile,651)
  651 format('0*error*:  model type is missing'/)
      go to 40
  660 write (iofile,661) value(ifield+3)
  661 format('0*error*:  unknown model type:  ',a8/)
      go to 40
  670 write (iofile,671) anam
  671 format('0*error*:  unknown model parameter:  ',a8,/)
      nogo=1
      go to 530
c
c  subcircuit definition
c
  700 if (nodplc(icode+2).ne.1) go to 780
      call find(value(ifield+2),20,loc,1)
      call extmem(isbckt,1)
      nsbckt=nsbckt+1
      nodplc(isbckt+nsbckt)=loc
      ifld=2
      if (nodplc(icode+3).ne.0) go to 790
      call getm4(nodplc(loc+2),0)
      iknt=0
  710 ifld=ifld+1
      if (nodplc(icode+ifld)) 50,720,710
  720 call extmem(nodplc(loc+2),1)
      iknt=iknt+1
      ispot=nodplc(loc+2)+iknt
      if (value(ifield+ifld).le.0.0d0) go to 770
      nodplc(ispot)=value(ifield+ifld)
      node=nodplc(ispot)
      i=iknt-1
  730 if (i.eq.0) go to 710
      ispot=ispot-1
      if (nodplc(ispot).eq.node) go to 760
      i=i-1
      go to 730
  760 write (iofile,761) node
  761 format('0*error*:  subcircuit definition duplicates node ',i5,/)
      go to 40
  770 write (iofile,771)
  771 format('0*error*:  nonpositive node number found in subcircuit ',
     1   'definition'/)
      go to 40
  780 write (iofile,781)
  781 format('0*error*:  subcircuit name missing'/)
      go to 40
  790 write (iofile,791)
  791 format('0*error*:  subcircuit nodes missing'/)
      go to 40
c
c  .ends processing
c
  800 if (nsbckt.eq.0) go to 890
      iknt=1
      if (nodplc(icode+2).le.0) go to 820
      anam=value(ifield+2)
      iknt=nsbckt
  810 loc=nodplc(isbckt+iknt)
      locv=nodplc(loc+1)
      anams=value(locv)
      if (anam.eq.anams) go to 820
      iknt=iknt-1
      if (iknt.ne.0) go to 810
      go to 880
  820 irel=nsbckt-iknt+1
      call relmem(isbckt,irel)
      nsbckt=nsbckt-irel
      go to 50
  880 write (iofile,881) anam
  881 format('0*error*:  unknown subcircuit name:  ',a8/)
      go to 40
  890 write (iofile,891)
  891 format('0warning:  no subcircuit definition known -- line ignored'
     1/)
      go to 50
c
c  subcircuit call
c
  900 call getm4(nodplc(loc+2),0)
      ifld=1
      iknt=0
  910 ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 920
      call extmem(nodplc(loc+2),1)
      iknt=iknt+1
      ispot=nodplc(loc+2)+iknt
      if (value(ifield+ifld).lt.0.0d0) go to 400
      nodplc(ispot)=value(ifield+ifld)
      go to 910
  920 if (iknt.eq.0) go to 410
      if (nodplc(icode+ifld).ne.1) go to 990
      call extnam(value(ifield+ifld),nodplc(loc+3))
      go to 50
  990 write (iofile,991)
  991 format('0*error*:  subcircuit name missing'/)
      go to 40
c
c  end
c
 5000 if (nsbckt.eq.0) go to 5010
      nsbckt=0
      write (iofile,5001)
 5001 format('0*error*:  .ends  card missing'/)
      nogo=1
 5010 call clrmem(ifield)
      call clrmem(icode)
      call clrmem(idelim)
      call clrmem(icolum)
      call clrmem(isbckt)
      if (nfour.eq.0) call clrmem(ifour)
      if (nsens.eq.0) call clrmem(isens)
 6000 call second(t2)
      rstats(1)=t2-t1
      return
      end
      subroutine relmem(ipntr,ksize)
      implicit double precision (a-h,o-z)
      dimension ipntr(1)
c spice version 2g.6  sccsid=memmgr 3/15/83
      common /memmgr/ cpyknt,istack(1),lorg,icore,maxcor,maxuse,memavl,
     1   ldval,numblk,loctab,ltab,ifwa,nwoff,ntab,maxmem,memerr,nwd4,
     2   nwd8,nwd16
      logical memptr
c
c***  relmem - release part of block
c
c
c...  check for valid pointer
      if (memptr(ipntr(1))) go to 10
      memerr=5
      call errmem(5,memerr,ipntr(1))
   10 isize=ksize*istack(ltab+5)
c...  check for valid size
      if (isize.ge.0) go to 20
      memerr=2
      call errmem(5,memerr,ipntr(1))
   20 jsize=istack(ltab+3)
      if (isize.le.jsize) go to 30
      memerr=6
      call errmem(5,memerr,ipntr(1))
   30 istack(ltab+3)=istack(ltab+3)-isize
      memavl=memavl+(nxtevn(jsize)-nxtevn(istack(ltab+3)))
      call memadj
      return
      end
      subroutine reordr
      implicit double precision (a-h,o-z)
c
c     this routine swaps rows in the coefficient matrix to eliminate
c singularity problems which can be recognized by examining the circuit
c topology.
c
c spice version 2g.6  sccsid=tabinf 3/15/83
      common /tabinf/ ielmnt,isbckt,nsbckt,iunsat,nunsat,itemps,numtem,
     1   isens,nsens,ifour,nfour,ifield,icode,idelim,icolum,insize,
     2   junode,lsbkpt,numbkp,iorder,jmnode,iur,iuc,ilc,ilr,numoff,isr,
     3   nmoffc,iseq,iseq1,neqn,nodevs,ndiag,iswap,iequa,macins,lvnim1,
     4   lx0,lvn,lynl,lyu,lyl,lx1,lx2,lx3,lx4,lx5,lx6,lx7,ld0,ld1,ltd,
     5   imynl,imvn,lcvn,nsnod,nsmat,nsval,icnod,icmat,icval,
     6   loutpt,lpol,lzer,irswpf,irswpr,icswpf,icswpr,irpt,jcpt,
     7   irowno,jcolno,nttbr,nttar,lvntmp
c spice version 2g.6  sccsid=cirdat 3/15/83
      common /cirdat/ locate(50),jelcnt(50),nunods,ncnods,numnod,nstop,
     1   nut,nlt,nxtrm,ndist,ntlin,ibr,numvs,numalt,numcyc
c spice version 2g.6  sccsid=flags 3/15/83
      common /flags/ iprnta,iprntl,iprntm,iprntn,iprnto,limtim,limpts,
     1   lvlcod,lvltim,itl1,itl2,itl3,itl4,itl5,itl6,igoof,nogo,keof
c spice version 2g.6  sccsid=blank 3/15/83
      common /blank/ value(50000)
c spice version 2g.6  sccsid=status 3/15/83
      common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet,
     1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon,
     2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile
      integer nodplc(64)
      complex cvalue(32)
      equivalence (value(1),nodplc(1),cvalue(1))
c
c  allocate and initialize storage
c
      call getm4(irswpf,nstop)
      call getm4(irswpr,nstop)
      call getm4(icswpf,nstop)
      call getm4(icswpr,nstop)
c
      do 10 i=1,nstop
      nodplc(irswpf+i)=i
   10 continue
      call copy4(nodplc(irswpf+1),nodplc(irswpr+1),nstop)
      call copy4(nodplc(irswpf+1),nodplc(icswpf+1),nstop)
      call copy4(nodplc(irswpf+1),nodplc(icswpr+1),nstop)
c
c  swap current equations into admittance part of equation matrix
c
      nextv=1
c
c  find suitable voltage source
c
  100 if (nextv.gt.numvs) go to 600
      ix=0
      do 130 i=nextv,numvs
      loc=nodplc(iseq+i)
      node=nodplc(loc+2)
      nflag=nodplc(iseq1+i)
      if (nflag.eq.1) node=nodplc(loc+6)
      if (nflag.eq.2) node=nodplc(loc+7)
      if (node.eq.1) go to 110
      if (nodplc(nodevs+node).ge.2) go to 110
      if (nodplc(ndiag+node).eq.0) go to 145
      ix=i
      locx=loc
      nodex=node
  110 node=nodplc(loc+3)
      if (nflag.eq.2) node=nodplc(loc+5)
      if (node.eq.1) go to 130
      if (nodplc(nodevs+node).ge.2) go to 130
  120 if (nodplc(ndiag+node).eq.0) go to 145
      ix=i
      locx=loc
      nodex=node
  130 continue
      if (ix.eq.0) go to 590
      i=ix
      loc=locx
      node=nodex
c
c  resequence voltage sources
c
  145 nodplc(iseq+i)=nodplc(iseq+nextv)
      nodplc(iseq+nextv)=loc
      ltemp=nodplc(iseq1+i)
      nodplc(iseq1+i)=nodplc(iseq1+nextv)
      nodplc(iseq1+nextv)=ltemp
      ibr=nodplc(neqn+i)
      nodplc(neqn+i)=nodplc(neqn+nextv)
      nodplc(neqn+nextv)=ibr
      node1=nodplc(loc+2)
      if (ltemp.eq.1) node1=nodplc(loc+6)
      if (ltemp.eq.2) node1=nodplc(loc+7)
      node2=nodplc(loc+3)
      if (ltemp.eq.1) node2=nodplc(loc+3)
      if (ltemp.eq.2) node2=nodplc(loc+5)
      nodplc(nodevs+node1)=nodplc(nodevs+node1)-1
      nodplc(nodevs+node2)=nodplc(nodevs+node2)-1
c
c  set row swap indicators
c
      l=nodplc(irswpf+ibr)
      j=nodplc(irswpr+node)
      nodplc(irswpf+j)=l
      nodplc(irswpr+l)=j
      nodplc(irswpf+ibr)=node
      nodplc(irswpr+node)=ibr
      call swapij(ibr,j,1,1)
      nextv=nextv+1
      go to 100
c
c
c  error - voltage-source/inductor/transmission-line loop detected ...
c
  590 nogo=1
      write (iofile,591)
c...  loop should have been detected in topchk
  591 format('0*abort*:  spice internal error in reordr'/)
c
c  finished
c
  600 return
      end
      subroutine reserv (node1,node2)
      implicit double precision (a-h,o-z)
c
c     this routine records the fact that the (node1, node2) element of
c the circuit equation coefficient matrix is nonzero.
c
c spice version 2g.6  sccsid=tabinf 3/15/83
      common /tabinf/ ielmnt,isbckt,nsbckt,iunsat,nunsat,itemps,numtem,
     1   isens,nsens,ifour,nfour,ifield,icode,idelim,icolum,insize,
     2   junode,lsbkpt,numbkp,iorder,jmnode,iur,iuc,ilc,ilr,numoff,isr,
     3   nmoffc,iseq,iseq1,neqn,nodevs,ndiag,iswap,iequa,macins,lvnim1,
     4   lx0,lvn,lynl,lyu,lyl,lx1,lx2,lx3,lx4,lx5,lx6,lx7,ld0,ld1,ltd,
     5   imynl,imvn,lcvn,nsnod,nsmat,nsval,icnod,icmat,icval,
     6   loutpt,lpol,lzer,irswpf,irswpr,icswpf,icswpr,irpt,jcpt,
     7   irowno,jcolno,nttbr,nttar,lvntmp
c spice version 2g.6  sccsid=flags 3/15/83
      common /flags/ iprnta,iprntl,iprntm,iprntn,iprnto,limtim,limpts,
     1   lvlcod,lvltim,itl1,itl2,itl3,itl4,itl5,itl6,igoof,nogo,keof
c spice version 2g.6  sccsid=blank 3/15/83
      common /blank/ value(50000)
      integer nodplc(64)
      complex cvalue(32)
      equivalence (value(1),nodplc(1),cvalue(1))
c
      logical memptr
c
      if (nogo.ne.0) go to 300
c...  test for ground
      if (node1.eq.1) go to 300
      if (node2.eq.1) go to 300
c
c     reserve (node1,node2) in row node1 at col posn node2
c
      loc=node1
   10 locj=loc
      loc=nodplc(jcpt+loc)
      if (loc.eq.0) go to 20
      if (nodplc(jcolno+loc)-node2) 10,300,20
   20 call sizmem(jcpt,isize)
      newloc=isize+1
      nodplc(numoff+node1)=nodplc(numoff+node1)+1
      nodplc(nmoffc+node2)=nodplc(nmoffc+node2)+1
      call extmem(jcpt,1)
      call extmem(jcolno,1)
      nodplc(jcpt+locj)=newloc
      nodplc(jcpt+newloc)=loc
      nodplc(jcolno+newloc)=node2
c
c     reserve (node1,node2) in col node2 at row posn node1
c
      loc=node2
   30 loci=loc
      loc=nodplc(irpt+loc)
      if (loc.eq.0) go to 40
      if (nodplc(irowno+loc)-node1) 30,300,40
   40 call extmem(irpt,1)
      call extmem(irowno,1)
      nodplc(irpt+loci)=newloc
      nodplc(irpt+newloc)=loc
      nodplc(irowno+newloc)=node1
c
c     mark diagonal
c
      if (node1.ne.node2) go to 300
      if (memptr(ndiag)) nodplc(ndiag+node1)=1
c
c     finished
c
  300 return
      end
      subroutine runcon(id)
      implicit double precision (a-h,o-z)
c
c     this routine processes run control cards.
c
c spice version 2g.6  sccsid=tabinf 3/15/83
      common /tabinf/ ielmnt,isbckt,nsbckt,iunsat,nunsat,itemps,numtem,
     1   isens,nsens,ifour,nfour,ifield,icode,idelim,icolum,insize,
     2   junode,lsbkpt,numbkp,iorder,jmnode,iur,iuc,ilc,ilr,numoff,isr,
     3   nmoffc,iseq,iseq1,neqn,nodevs,ndiag,iswap,iequa,macins,lvnim1,
     4   lx0,lvn,lynl,lyu,lyl,lx1,lx2,lx3,lx4,lx5,lx6,lx7,ld0,ld1,ltd,
     5   imynl,imvn,lcvn,nsnod,nsmat,nsval,icnod,icmat,icval,
     6   loutpt,lpol,lzer,irswpf,irswpr,icswpf,icswpr,irpt,jcpt,
     7   irowno,jcolno,nttbr,nttar,lvntmp
c spice version 2g.6  sccsid=cje 3/15/83
      common /cje/ maxtim,itime,icost
c spice version 2g.6  sccsid=miscel 3/15/83
      common /miscel/ atime,aprog(3),adate,atitle(10),defl,defw,defad,
     1  defas,rstats(50),iwidth,lwidth,nopage
c spice version 2g.6  sccsid=cirdat 3/15/83
      common /cirdat/ locate(50),jelcnt(50),nunods,ncnods,numnod,nstop,
     1   nut,nlt,nxtrm,ndist,ntlin,ibr,numvs,numalt,numcyc
c spice version 2g.6  sccsid=status 3/15/83
      common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet,
     1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon,
     2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile
c spice version 2g.6  sccsid=flags 3/15/83
      common /flags/ iprnta,iprntl,iprntm,iprntn,iprnto,limtim,limpts,
     1   lvlcod,lvltim,itl1,itl2,itl3,itl4,itl5,itl6,igoof,nogo,keof
c spice version 2g.6  sccsid=knstnt 3/15/83
      common /knstnt/ twopi,xlog2,xlog10,root2,rad,boltz,charge,ctok,
     1   gmin,reltol,abstol,vntol,trtol,chgtol,eps0,epssil,epsox,
     2   pivtol,pivrel
c spice version 2g.6  sccsid=dc 3/15/83
      common /dc/ tcstar(2),tcstop(2),tcincr(2),icvflg,itcelm(2),kssop,
     1   kinel,kidin,kovar,kidout
c spice version 2g.6  sccsid=ac 3/15/83
      common /ac/ fstart,fstop,fincr,skw2,refprl,spw2,jacflg,idfreq,
     1   inoise,nosprt,nosout,nosin,idist,idprt
c spice version 2g.6  sccsid=tran 3/15/83
      common /tran/ tstep,tstop,tstart,delmax,tdmax,forfre,jtrflg
c spice version 2g.6  sccsid=outinf 3/15/83
      common /outinf/ xincr,string(15),xstart,yvar(8),itab(8),itype(8),
     1   ilogy(8),npoint,numout,kntr,numdgt
c spice version 2g.6  sccsid=debug 3/15/83
      common/debug/ idebug(20)
c spice version 2g.6  sccsid=blank 3/15/83
      common /blank/ value(50000)
      integer nodplc(64)
      complex cvalue(32)
      equivalence (value(1),nodplc(1),cvalue(1))
      dimension iprnt(5),limits(4),itrlim(6),contol(6),dflts(4)
      equivalence (iprnt(1),iprnta),(limits(1),limtim),(itrlim(1),itl1),
     1   (contol(1),gmin),(dflts(1),defl)
c
c
      integer xxor
c
c  print/plot keywords
c
      dimension aopt(5)
      dimension aopts(34),lsetop(5)
      dimension aide(20)
      data aopt / 2hdc, 2htr, 2hac, 2hno, 2hdi /
c
c  options card keywords
c
      data aopts / 6hacct  , 6hlist  , 6hnomod , 6hnode  , 6hopts  ,
     1             6hitl1  , 6hitl2  , 6hitl3  , 6hitl4  , 6hitl5  ,
     2             6hitl6  , 6hlimtim, 6hlimpts, 6hlvlcod, 6hlvltim,
     3             6hgmin  , 6hreltol, 6habstol, 6hvntol , 6htrtol ,
     4             6hchgtol, 6htnom  , 6hnumdgt, 6hmaxord, 6hmethod,
     5             6hnopage, 6hmu    , 6hcptime, 6hdefl  , 6hdefw  ,
     6             6hdefad , 6hdefas , 6hpivtol, 6hpivrel /
      data lsetop / 1 ,1, 0, 1, 1 /
c
c
      data aide / 1hr,1hc,1hl,1hk,1hg,1he,1hf,1hh,1hv,1hi,1hd,1hq,1hj,
     1   1hm,1hs,1hy,1ht,4htemp,1hx,0.0d0 /
      data alsde,alsoc,alsli / 3hdec, 3hoct, 3hlin /
      data atrap, agear, auic / 4htrap, 4hgear, 3huic /
      data ablnk, ain, aout / 1h , 2hin, 3hout /
      data amiss / 8h*missing /
      data ams / 2hms /
      data minpts / 1 /
c
c
      go to (1200,1100,1650,6000,6000,1700,6000,1600,1550,2000,3600,
     1   3500,6000,1750,1300,1500,1800,4000,4100,4200,5900), id
c
c  dc transfer curves
c
 1100 ifld=2
      icvflg=0
      inum=1
 1105 anam=value(ifield+ifld)
      if(inum.gt.2) go to 6000
      id=0
      call move(anam,2,ablnk,1,7)
      if (anam.eq.aide(1)) id=1
      if (anam.eq.aide(9)) id=9
      if (anam.eq.aide(10)) id=10
      if (anam.eq.aide(17)) go to 1108
      if (id.eq.0) go to 1130
      call find(value(ifield+ifld),id,itcelm(inum),0)
      go to 1115
 1108 anam=value(ifield+ifld)
      call move(anam,5,ablnk,1,4)
      if (anam.ne.aide(18)) go to 1130
      id=18
      call find(anam,id,itcelm(inum),1)
      locs=nodplc(itcelm(inum)+1)
      nodplc(itcelm(inum)+2)=0
      value(locs)=anam
      value(locs+1)=value(itemps+1)
      call extmem(itemps,2)
      value(itemps+2)=value(itemps+1)
 1115 ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1130
      tcstar(inum)=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1130
      tcstop(inum)=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1130
      tcincr(inum)=value(ifield+ifld)
      if (tcincr(inum).eq.0.0d0) go to 1130
      temp=(tcstop(inum)-tcstar(inum))/tcincr(inum)
      if (temp.gt.0.0d0) go to 1110
      tcincr(inum)=-tcincr(inum)
      temp=-temp
 1110 itemp=idint(temp+0.5d0)+1
      itemp=max0(itemp,minpts)
      if(inum.eq.1) icvflg=itemp
      if(inum.eq.2) icvflg=itemp*icvflg
      ifld=ifld+1
      inum=2
      if(nodplc(icode+ifld)) 6000,1130,1105
 1130 write (iofile,1131)
      icvflg=0
 1131 format('0warning:  missing parameter(s) ... analysis omitted'/)
      go to 6000
c
c  frequency specification
c
 1200 ifld=2
      if (nodplc(icode+2)) 1250,1250,1210
 1210 id=0
      if (value(ifield+ifld).eq.alsde) id=1
      if (value(ifield+ifld).eq.alsoc) id=2
      if (value(ifield+ifld).eq.alsli) id=3
      if (id.eq.0) go to 1240
      idfreq=id
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1250
      if (value(ifield+ifld).le.0.0d0) go to 1250
      fincr=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1250
      if (value(ifield+ifld).le.0.0d0) go to 1250
      fstart=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1250
      if (value(ifield+ifld).le.0.0d0) go to 1250
      fstop=value(ifield+ifld)
      if (fstart.gt.fstop) go to 1260
      jacflg=fincr
      if (idfreq-2) 1215,1220,1235
 1215 fincr=dexp(xlog10/fincr)
      go to 1230
 1220 fincr=dexp(xlog2/fincr)
 1230 temp=dlog(fstop/fstart)/dlog(fincr)
      jacflg=idint(temp+0.999d0)+1
 1235 jacflg=max0(jacflg,minpts)
      if (idfreq.ne.3) go to 6000
      fincr=(fstop-fstart)/dble(max0(jacflg-1,1))
      go to 6000
 1240 write (iofile,1241) value(ifield+ifld)
 1241 format('0warning:  unknown frequency function:  ',a8,' ... analys'
     1   ,'is omitted'/)
      go to 6000
 1250 write (iofile,1251)
 1251 format('0warning:  frequency parameters incorrect ... analysis om'
     1   ,'itted'/)
      go to 6000
 1260 write (iofile,1261)
 1261 format('0warning:  start freq > stop freq ... analysis omitted'/)
      go to 6000
c
c  time specification
c
 1300 ifld=2
      if (nodplc(icode+ifld).ne.0) go to 1430
      if (value(ifield+ifld).le.0.0d0) go to 1430
      tstep=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1430
      if (value(ifield+ifld).le.0.0d0) go to 1430
      tstop=value(ifield+ifld)
      tstart=0.0d0
      delmax=tstop/50.0d0
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1310
      if (value(ifield+ifld).lt.0.0d0) go to 1430
      tstart=value(ifield+ifld)
      delmax=(tstop-tstart)/50.0d0
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1310
      if (value(ifield+ifld).le.0.0d0) go to 1430
      delmax=value(ifield+ifld)
      ifld=ifld+1
 1310 if (nodplc(icode+ifld).ne.1) go to 1320
      if (value(ifield+ifld).ne.auic) go to 1320
      nosolv=1
 1320 if (tstart.gt.tstop) go to 1440
      if (tstep.gt.tstop) go to 1430
      jtrflg=idint((tstop-tstart)/tstep+0.5d0)+1
      jtrflg=max0(jtrflg,minpts)
      go to 6000
 1430 write (iofile,1431)
 1431 format('0warning:  time parameters incorrect ... analysis omitted'
     1   /)
      go to 6000
 1440 write (iofile,1441)
 1441 format('0warning:  start time > stop time ... analysis omitted'/)
      go to 6000
c
c  transfer function
c
 1500 kssop=1
      ifld=2
      if (nodplc(icode+ifld).ne.1) go to 1530
      call outdef(ifld,1,kovar,ktype)
      if (igoof.ne.0) go to 1530
      if (ktype.ne.1) go to 1540
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.1) go to 1530
      anam=value(ifield+ifld)
      call move(anam,2,ablnk,1,7)
      id=0
      if (anam.eq.aide(9)) id=9
      if (anam.eq.aide(10)) id=10
      if (id.eq.0) go to 1530
      call find(value(ifield+ifld),id,kinel,0)
      kidin=id
      go to 6000
 1530 kovar=0
      kinel=0
      write (iofile,1131)
      igoof=0
      go to 6000
 1540 kovar=0
      kinel=0
      write (iofile,1541)
 1541 format('0warning:  illegal output variable ... analysis omitted'/)
      igoof=0
      go to 6000
c
c  operating point
c
 1550 kssop=1
      go to 6000
c
c  noise analysis
c
 1600 ifld=2
      if (nodplc(icode+ifld).ne.1) go to 1610
      call outdef(ifld,2,nosout,ntype)
      if (igoof.ne.0) go to 1610
      if (ntype.ne.1) go to 1610
      if (nodplc(nosout+5).ne.0) go to 1610
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.1) go to 1620
      anam=value(ifield+ifld)
      call move(anam,2,ablnk,1,7)
      id=0
      if (anam.eq.aide(9)) id=9
      if (anam.eq.aide(10)) id=10
      if (id.eq.0) go to 1620
      call find(value(ifield+ifld),id,nosin,0)
      nosprt=0
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 1605
      nosprt=dmax1(0.0d0,value(ifield+ifld))
 1605 inoise=1
      go to 6000
 1610 write (iofile,1611)
 1611 format('0warning:  voltage output unrecognizable ... analysis omit
     1ted'/)
      igoof=0
      go to 6000
 1620 write (iofile,1621)
 1621 format('0warning:  invalid input source ... analysis omitted'/)
      igoof=0
      go to 6000
c
c  distortion analysis
c
 1650 ifld=2
      if (nodplc(icode+ifld).ne.1) go to 1660
      anam=value(ifield+ifld)
      call move(anam,2,ablnk,1,7)
      if (anam.ne.aide(1)) go to 1660
      call find(value(ifield+ifld),1,idist,0)
      idprt=0
      skw2=0.9d0
      refprl=1.0d-3
      spw2=1.0d0
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 6000
      idprt=value(ifield+ifld)
      idprt=max0(idprt,0)
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 6000
      if (value(ifield+ifld).le.0.001d0) go to 1670
      if (value(ifield+ifld).gt.0.999d0) go to 1670
      skw2=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 6000
      if (value(ifield+ifld).lt.1.0d-10) go to 1670
      refprl=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 6000
      if (value(ifield+ifld).lt.0.001d0) go to 1670
      spw2=value(ifield+ifld)
      go to 6000
 1660 write (iofile,1661)
 1661 format('0warning:  distortion load resistor missing ... analysis '
     1   ,'omitted'/)
      go to 6000
 1670 idist=0
      write (iofile,1671)
 1671 format('0warning:  distortion parameters incorrect ... analysis o'
     1   ,'mitted'/)
      go to 6000
c
c  fourier analysis
c
 1700 ifld=2
      if (nodplc(icode+ifld).ne.0) go to 1720
      if (value(ifield+ifld).le.0.0d0) go to 1720
      forfre=value(ifield+ifld)
 1705 ifld=ifld+1
      if (nodplc(icode+ifld).ne.1) go to 1710
      call outdef(ifld,2,loct,ltype)
      if (igoof.ne.0) go to 1720
      if (ltype.ne.1) go to 1720
      call extmem(ifour,1)
      nfour=nfour+1
      nodplc(ifour+nfour)=loct
      go to 1705
 1710 if (nfour.ge.1) go to 6000
 1720 write (iofile,1721)
 1721 format('0warning:  fourier parameters incorrect ... analysis omit'
     1   ,'ted'/)
      igoof=0
      nfour=0
      call clrmem(ifour)
      call getm4(ifour,0)
      go to 6000
c
c  sensitivity analysis
c
 1750 kssop=1
      ifld=1
 1760 ifld=ifld+1
      if (nodplc(icode+ifld).ne.1) go to 6000
      call outdef(ifld,1,loct,ltype)
      if (igoof.ne.0) go to 1780
      if (ltype.ne.1) go to 1780
      call extmem(isens,1)
      nsens=nsens+1
      nodplc(isens+nsens)=loct
      go to 1760
 1780 write (iofile,1781)
 1781 format('0warning:  output variable unrecognizable ... analysis om'
     1   ,'mitted'/)
      igoof=0
      nsens=0
      call clrmem(isens)
      call getm4(isens,0)
      go to 6000
c
c  temperature variation
c
 1800 ifld=1
 1810 ifld=ifld+1
      if (nodplc(icode+ifld).ne.0) go to 6000
      if (value(ifield+ifld).le.-223.0d0) go to 1810
      call extmem(itemps,1)
      numtem=numtem+1
      value(itemps+numtem)=value(ifield+ifld)
      go to 1810
c
c  options card
c
 2000 ifld=1
 2010 ifld=ifld+1
 2020 if (nodplc(icode+ifld)) 6000,2010,2030
 2030 anam=value(ifield+ifld)
      do 2040 i=1,5
      if (anam.ne.aopts(i)) go to 2040
      iprnt(i)=lsetop(i)
      ifld=ifld+1
      if(nodplc(icode+ifld).ne.0) go to 2020
      iprnt(i)=value(ifield+ifld)
      go to 2010
 2040 continue
      if (anam.eq.aopts(25)) go to 2110
      if (anam.eq.aopts(26)) go to 2120
      if (anam.eq.aopts(27)) go to 2130
      if (anam.eq.aopts(28)) go to 2150
      if (anam.eq.aopts(33)) go to 2200
      if (anam.eq.aopts(34)) go to 2250
      if (nodplc(icode+ifld+1).ne.0) go to 2510
      ifld=ifld+1
      aval=value(ifield+ifld)
      do 2050 i=6,11
      if (anam.ne.aopts(i)) go to 2050
      if(aval.le.0.0d0.and.i.ne.10) go to 2510
      itrlim(i-5)=aval
      go to 2010
 2050 continue
      if (aval.le.0.0d0) go to 2510
      do 2060 i=12,15
      if (anam.ne.aopts(i)) go to 2060
      limits(i-11)=aval
      go to 2010
 2060 continue
      do 2070 i=16,21
      if (anam.ne.aopts(i)) go to 2070
      contol(i-15)=aval
      go to 2010
 2070 continue
      do 2075 i=29,32
      if(anam.ne.aopts(i)) go to 2075
      dflts(i-28)=aval
      go to 2010
 2075 continue
      if (anam.ne.aopts(22)) go to 2080
      if (aval.lt.-223.0d0) go to 2510
      value(itemps+1)=aval
      go to 2010
 2080 if (anam.ne.aopts(23)) go to 2100
      ndigit=aval
      if (ndigit.le.7) go to 2090
      ndigit=7
      write (iofile,2081) ndigit
 2081 format('0warning:  numdgt may not exceed',i2,
     1 ';  maximum value assumed'/)
 2090 numdgt=ndigit
      go to 2010
 2100 if (anam.ne.aopts(24)) go to 2500
      n=aval
      if ((n.le.1).or.(n.ge.7)) go to 2510
      maxord=n
      go to 2010
 2110 if (nodplc(icode+ifld+1).ne.1) go to 2510
      ifld=ifld+1
      anam=value(ifield+ifld)
      call move(anam,5,ablnk,1,4)
      jtype=0
      if (anam.eq.atrap) jtype=1
      if (anam.eq.agear) jtype=2
      if (jtype.eq.0) go to 2510
      method=jtype
      go to 2010
 2120 nopage=1
      go to 2010
 2130 ifld=ifld+1
      if(nodplc(icode+ifld)) 6000,2140,2030
 2140 aval=value(ifield+ifld)
      if(aval.lt.0.0d0.or.aval.gt.0.500001d0) go to 2510
      xmu=aval
      go to 2010
 2150 ifld=ifld+1
      if(nodplc(icode+ifld)) 6000,2160,2030
 2160 aval=value(ifield+ifld)
      maxtim=aval
      go to 2010
 2200 ifld=ifld+1
      if (nodplc(icode+ifld)) 6000,2210,2030
 2210 aval=value(ifield+ifld)
      if (aval.gt.1.0d0) go to 2510
      pivtol=aval
      go to 2010
 2250 ifld=ifld+1
      if (nodplc(icode+ifld)) 6000,2260,2030
 2260 aval=value(ifield+ifld)
      if (aval.gt.1.0d0) go to 2510
      pivrel=aval
      go to 2010
 2500 write (iofile,2501) anam
 2501 format('0warning:  unknown option:  ',a8,' ... ignored'/)
      go to 2010
 2510 write (iofile,2511) anam
 2511 format('0warning:  illegal value specified for option:  ',a8,' ...
     1 ignored'/)
      go to 2010
c
c  print card
c
 3500 iprpl=0
      go to 3610
c
c  plot (and print) card
c
 3600 iprpl=1
 3610 ifld=2
 3613 anam=amiss
      if (nodplc(icode+ifld).ne.1) go to 3950
      anam=value(ifield+ifld)
      ms=0
      if (xxor(anam,ams).ne.0) go to 3615
      ms=1
      ifld=3
      if (nodplc(icode+ifld).ne.1) go to 3970
      anam=value(ifield+ifld)
 3615 call move(anam,3,ablnk,1,6)
      do 3620 i=1,5
      if (anam.ne.aopt(i)) go to 3620
      ktype=i
      go to 3630
 3620 continue
      go to 3950
 3630 id=30+5*iprpl+ktype
      call find(dble(jelcnt(id)),id,loc,1)
      nodplc(loc+2)=ktype
      if (ms.eq.0) go to 3635
      locv=nodplc(loc+1)
      value(locv)=0.0d0
 3635 numout=0
 3640 ifld=ifld+1
      if (nodplc(icode+ifld)) 3900,3640,3650
 3650 call outdef(ifld,ktype,loct,ltype)
      if (igoof.ne.0) go to 3970
      if (iprpl.eq.0) go to 3660
      plimlo=0.0d0
      plimhi=0.0d0
      if (nodplc(icode+ifld+1).ne.0) go to 3660
      if (nodplc(icode+ifld+2).ne.0) go to 3660
      plimlo=value(ifield+ifld+1)
      plimhi=value(ifield+ifld+2)
      ifld=ifld+2
 3660 numout=numout+1
      lspot=loc+2*numout+2
      nodplc(lspot)=loct
      nodplc(lspot+1)=ltype
      if (iprpl.eq.0) go to 3670
      locv=nodplc(loc+1)
      lspot=locv+2*numout-1
      value(lspot)=plimlo
      value(lspot+1)=plimhi
 3670 if (numout.eq.8) go to 3900
      go to 3640
 3900 nodplc(loc+3)=numout
      if (iprpl.eq.0) go to 6000
c...  propogate plot limits downward
      if (numout.le.1) go to 6000
      locv=nodplc(loc+1)
      lspot=locv+2*numout-1
      plimlo=value(lspot)
      plimhi=value(lspot+1)
      i=numout-1
 3905 lspot=lspot-2
      if (value(lspot).ne.0.0d0) go to 3910
      if (value(lspot+1).ne.0.0d0) go to 3910
      value(lspot)=plimlo
      value(lspot+1)=plimhi
      go to 3920
 3910 plimlo=value(lspot)
      plimhi=value(lspot+1)
 3920 i=i-1
      if (i.ge.1) go to 3905
      go to 6000
c
c     errors
c
 3950 write (iofile,3951) anam
 3951 format('0warning:  unknown analysis mode:  ',a8,
     1  ' ... line ignored'/)
      go to 6000
 3970 write (iofile,3971)
 3971 format('0warning:  unrecognizable output variable on above line'/)
      igoof=0
      go to 3640
c
c  width card
c
 4000 ifld=1
 4010 ifld=ifld+1
      if (nodplc(icode+ifld).ne.1) go to 6000
 4020 anam=value(ifield+ifld)
      if (anam.ne.ain) go to 4040
      ifld=ifld+1
      if (nodplc(icode+ifld)) 6000,4030,4020
 4030 iwidth=value(ifield+ifld)
      iwidth=min0(max0(iwidth,10),120)
      go to 4010
 4040 if (anam.ne.aout) go to 6000
      ifld=ifld+1
      if (nodplc(icode+ifld)) 6000,4050,4020
 4050 lwidth=dmin1(dmax1(value(ifield+ifld),72.0d0),132.0d0)
      go to 4010
c
c  nodeset statement
c
 4100 ifld=1
 4110 ifld=ifld+1
      if(nodplc(icode+ifld)) 6000,4120,4110
 4120 nodnum=value(ifield+ifld)
      if(nodnum.le.0) go to 4190
      ifld=ifld+1
      if(nodplc(icode+ifld)) 4180,4130,4170
 4130 call sizmem(nsnod,nic)
      call extmem(nsnod,1)
      call extmem(nsval,1)
      nodplc(nsnod+nic+1)=nodnum
      value(nsval+nic+1)=value(ifield+ifld)
      go to 4110
c
c  errors on .nodeset statement
c
 4170 write(iofile,4171) value(ifield+ifld)
 4171 format('0warning: out-of-place non-numeric field ',a8,
     1 ' skipped'/)
      go to 4110
 4180 write(iofile,4181) nodnum
 4181 format('0warning: initial value missing for node ',i5,/)
      go to 6000
 4190 write(iofile,4191)
 4191 format('0warning: attempt to specify initial condition for ',
     1 'ground ingnored',/)
      ifld=ifld+1
      if(nodplc(icode+ifld)) 6000,4110,4170
c
c  initial conditions statement
c
 4200 ifld=1
 4210 ifld=ifld+1
      if(nodplc(icode+ifld)) 6000,4220,4210
 4220 nodnum=value(ifield+ifld)
      if(nodnum.le.0) go to 4290
      ifld=ifld+1
      if(nodplc(icode+ifld)) 4280,4230,4270
 4230 call sizmem(icnod,nic)
      call extmem(icnod,1)
      call extmem(icval,1)
      nodplc(icnod+nic+1)=nodnum
      value(icval+nic+1)=value(ifield+ifld)
      go to 4210
c
c  errors on .ic statement
c
 4270 write(iofile,4271) value(ifield+ifld)
 4271 format('0warning: out-of-place non-numeric field ',a8,
     1 ' skipped'/)
      go to 4210
 4280 write(iofile,4281) nodnum
 4281 format('0warning: initial value missing for node ',i5,/)
      go to 6000
 4290 write(iofile,4291)
 4291 format('0warning: attempt to specify initial condition for ',
     1 'ground ignored',/)
      ifld=ifld+1
      if(nodplc(icode+ifld)) 6000,4210,4270
c
c     :debug: statement
c     sample debug line: .:debug: 5=3 17=5
c
 5900 ifld=1
 5910 ifld=ifld+1
      if (nodplc(icode+ifld)) 6000,5920,5910
 5920 index=value(ifield+ifld)
      ifld=ifld+1
      if (nodplc(icode+ifld)) 6000,5930,5910
 5930 ival=value(ifield+ifld)
      if (index.lt.1) go to 5910
      if (index.gt.20) go to 5910
      write(iofile,5931) index,ival
 5931 format(' *debug*:  runcon - idebug(',i2,') set to ',i10)
      idebug(index)=ival
      go to 5910
c
c  finished
c
 6000 return
      end
