/* moscap.f -- translated by f2c (version of 3 February 1990  3:36:42).
   You must link the resulting object file with the libraries:
	-lF77 -lI77 -lm -lc   (in that order)
*/

#include "f2c.h"

/* Common Block Declarations */

struct {
    doublereal vto, beta, gamma, phi, phib, cox, xnsub, xnfs, xd, xj, xld, 
	    xlamda, uo, uexp, vbp, utra, vmax, xneff, xl, xw, vbi, von, vdsat,
	     qspof, beta0, beta1, cdrain, xqco, xqc, fnarrw, fshort;
    integer lev;
} mosarg_;

#define mosarg_1 mosarg_

struct {
    doublereal omega, time, delta, delold[7], ag[7], vt, xni, egfet, xmu, 
	    sfactr;
    integer mode, modedc, icalc, initf, method, iord, maxord, noncon, iterno, 
	    itemno, nosolv, modac, ipiv, ivmflg, ipostp, iscrch, iofile;
} status_;

#define status_1 status_

struct {
    doublereal value[200000];
} blank_;

#define blank_1 blank_

/*<       subroutine moscap(vgd,vgs,vgb,covlgd,covlgs,covlgb, >*/
/*<      1   capbd,capbs,cggb,cgdb,cgsb,cbgb,cbdb,cbsb, >*/
/*<      2   gcggb,gcgdb,gcgsb,gcbgb,gcbdb,gcbsb, >*/
/*<      3   gcdgb,gcddb,gcdsb,gcsgb,gcsdb,gcssb, >*/
/*<      4   qgate,qchan,qbulk,qdrn,qsrc) >*/
/* Subroutine */ int moscap_(vgd, vgs, vgb, covlgd, covlgs, covlgb, capbd, 
	capbs, cggb, cgdb, cgsb, cbgb, cbdb, cbsb, gcggb, gcgdb, gcgsb, gcbgb,
	 gcbdb, gcbsb, gcdgb, gcddb, gcdsb, gcsgb, gcsdb, gcssb, qgate, qchan,
	 qbulk, qdrn, qsrc)
doublereal *vgd, *vgs, *vgb, *covlgd, *covlgs, *covlgb, *capbd, *capbs, *cggb,
	 *cgdb, *cgsb, *cbgb, *cbdb, *cbsb, *gcggb, *gcgdb, *gcgsb, *gcbgb, *
	gcbdb, *gcbsb, *gcdgb, *gcddb, *gcdsb, *gcsgb, *gcsdb, *gcssb, *qgate,
	 *qchan, *qbulk, *qdrn, *qsrc;
{
    /* Local variables */
    static doublereal gcgxd, gcdxd, gcdxs, gcsxd, gcgxs, gcsxs;
#define nodplc ((integer *)&blank_1)
#define cvalue ((complex *)&blank_1)
    static doublereal gcd, gcg, qgb, qgd, gcs, qgs;

/*<       implicit double precision (a-h,o-z) >*/
/* spice version 2g.6  sccsid=mosarg 3/15/83 */
/*<       common /mosarg/ vto,beta,gamma,phi,phib,cox,xnsub,xnfs,xd,xj,xld, >*/
/*<      1   xlamda,uo,uexp,vbp,utra,vmax,xneff,xl,xw,vbi,von,vdsat,qspof, >*/
/*<      2   beta0,beta1,cdrain,xqco,xqc,fnarrw,fshort,lev >*/
/* 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 >*/
/* spice version 2g.6  sccsid=blank 3/15/83 */
/*<       common /blank/ value(200000) >*/
/*<       integer nodplc(64) >*/
/*<       complex cvalue(32) >*/
/*<       equivalence (value(1),nodplc(1),cvalue(1)) >*/

/*     compute equivalent conductances */
/*     divide up the channel charge (1-xqc)/xqc to source and drain */

/*<       gcg=(cggb+cbgb)*ag(1) >*/
    gcg = (*cggb + *cbgb) * status_1.ag[0];
/*<       gcd=(cgdb+cbdb)*ag(1) >*/
    gcd = (*cgdb + *cbdb) * status_1.ag[0];
/*<       gcs=(cgsb+cbsb)*ag(1) >*/
    gcs = (*cgsb + *cbsb) * status_1.ag[0];
/*<       gcgxd=-xqc*gcg >*/
    gcgxd = -mosarg_1.xqc * gcg;
/*<       gcgxs=-(1.0d0-xqc)*gcg >*/
    gcgxs = -(1. - mosarg_1.xqc) * gcg;
/*<       gcdxd=-xqc*gcd >*/
    gcdxd = -mosarg_1.xqc * gcd;
/*<       gcdxs=-(1.0d0-xqc)*gcd >*/
    gcdxs = -(1. - mosarg_1.xqc) * gcd;
/*<       gcsxd=-xqc*gcs >*/
    gcsxd = -mosarg_1.xqc * gcs;
/*<       gcsxs=-(1.0d0-xqc)*gcs >*/
    gcsxs = -(1. - mosarg_1.xqc) * gcs;
/*<       gcdgb=gcgxd-covlgd*ag(1) >*/
    *gcdgb = gcgxd - *covlgd * status_1.ag[0];
/*<       gcddb=gcdxd+(capbd+covlgd)*ag(1) >*/
    *gcddb = gcdxd + (*capbd + *covlgd) * status_1.ag[0];
/*<       gcdsb=gcsxd >*/
    *gcdsb = gcsxd;
/*<       gcsgb=gcgxs-covlgs*ag(1) >*/
    *gcsgb = gcgxs - *covlgs * status_1.ag[0];
/*<       gcsdb=gcdxs >*/
    *gcsdb = gcdxs;
/*<       gcssb=gcsxs+(capbs+covlgs)*ag(1) >*/
    *gcssb = gcsxs + (*capbs + *covlgs) * status_1.ag[0];
/*<       gcggb=(cggb+covlgd+covlgs+covlgb)*ag(1) >*/
    *gcggb = (*cggb + *covlgd + *covlgs + *covlgb) * status_1.ag[0];
/*<       gcgdb=(cgdb-covlgd)*ag(1) >*/
    *gcgdb = (*cgdb - *covlgd) * status_1.ag[0];
/*<       gcgsb=(cgsb-covlgs)*ag(1) >*/
    *gcgsb = (*cgsb - *covlgs) * status_1.ag[0];
/*<       gcbgb=(cbgb-covlgb)*ag(1) >*/
    *gcbgb = (*cbgb - *covlgb) * status_1.ag[0];
/*<       gcbdb=(cbdb-capbd)*ag(1) >*/
    *gcbdb = (*cbdb - *capbd) * status_1.ag[0];
/*<       gcbsb=(cbsb-capbs)*ag(1) >*/
    *gcbsb = (*cbsb - *capbs) * status_1.ag[0];

/*     compute total terminal charges */

/*<       qgd=covlgd*vgd >*/
    qgd = *covlgd * *vgd;
/*<       qgs=covlgs*vgs >*/
    qgs = *covlgs * *vgs;
/*<       qgb=covlgb*vgb >*/
    qgb = *covlgb * *vgb;
/*<       qgate=qgate+qgd+qgs+qgb >*/
    *qgate = *qgate + qgd + qgs + qgb;
/*<       qbulk=qbulk-qgb >*/
    *qbulk -= qgb;
/*<       qdrn=xqc*qchan-qgd >*/
    *qdrn = mosarg_1.xqc * *qchan - qgd;
/*<       qsrc=(1.0d0-xqc)*qchan-qgs >*/
    *qsrc = (1. - mosarg_1.xqc) * *qchan - qgs;

/*     finished */

/*<       return >*/
    return 0;
/*<       end >*/
} /* moscap_ */

#undef cvalue
#undef nodplc


