/* cmeyer.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 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 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 twopi, xlog2, xlog10, root2, rad, boltz, charge, ctok, gmin, 
	    reltol, abstol, vntol, trtol, chgtol, eps0, epssil, epsox, pivtol,
	     pivrel;
} knstnt_;

#define knstnt_1 knstnt_

/*<       subroutine cmeyer (vgs0,vgd0,vgb0,von0,vdsat0,vgs1,vgd1,vgb1, >*/
/*<      1   covlgs,covlgd,covlgb,cgs0,cgd0,cgb0,cgs1,cgd1,cgb1) >*/
/* Subroutine */ int cmeyer_(vgs0, vgd0, vgb0, von0, vdsat0, vgs1, vgd1, vgb1,
	 covlgs, covlgd, covlgb, cgs0, cgd0, cgb0, cgs1, cgd1, cgb1)
doublereal *vgs0, *vgd0, *vgb0, *von0, *vdsat0, *vgs1, *vgd1, *vgb1, *covlgs, 
	*covlgd, *covlgb, *cgs0, *cgd0, *cgb0, *cgs1, *cgd1, *cgb1;
{
    static doublereal vgbt, vons, vddif;
    static integer indax;
    static doublereal vddif1, vddif2, vdbsat, cgb, cgd, vdb, cgs, vgb, vgd, 
	    vbs, vds, vgs;

/*<       implicit double precision (a-h,o-z) >*/

/*     this routine computes the mosfet overlap capacitances as functions 
*/
/* of the device terminal voltages. */

/* 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=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=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 >*/
/*<       indax=1 >*/
    indax = 1;
/*<       vgs=vgs1 >*/
    vgs = *vgs1;
/*<       vgd=vgd1 >*/
    vgd = *vgd1;
/*<       vgb=vgb1 >*/
    vgb = *vgb1;
/*<       vons=von >*/
    vons = mosarg_1.von;
/*<       vbs=vgs-vgb >*/
    vbs = vgs - vgb;
/*<       vdbsat=vdsat-vbs >*/
    vdbsat = mosarg_1.vdsat - vbs;
/*<       vdb=vgb-vgd >*/
    vdb = vgb - vgd;
/*<    10 vds=vgs-vgd >*/
L10:
    vds = vgs - vgd;
/*<       vgbt=vgs-vons >*/
    vgbt = vgs - vons;
/*<       if (vgbt.gt.-phi) go to 100 >*/
    if (vgbt > -mosarg_1.phi) {
	goto L100;
    }
/*<       cgb=cox+covlgb >*/
    cgb = mosarg_1.cox + *covlgb;
/*<       cgd=covlgd >*/
    cgd = *covlgd;
/*<       cgs=covlgs >*/
    cgs = *covlgs;
/*<       go to 430 >*/
    goto L430;


/*<   100 if (vgbt.gt.-phi/2.0d0) go to 200 >*/
L100:
    if (vgbt > -mosarg_1.phi / 2.) {
	goto L200;
    }
/*<       cgb=-vgbt*cox/phi+covlgb >*/
    cgb = -vgbt * mosarg_1.cox / mosarg_1.phi + *covlgb;
/*<       cgd=covlgd >*/
    cgd = *covlgd;
/*<       cgs=covlgs >*/
    cgs = *covlgs;
/*<       go to 430 >*/
    goto L430;


/*<   200 if (vgbt.gt.0.0d0) go to 300 >*/
L200:
    if (vgbt > 0.) {
	goto L300;
    }
/*<       cgb=-vgbt*cox/phi+covlgb >*/
    cgb = -vgbt * mosarg_1.cox / mosarg_1.phi + *covlgb;
/*<       cgd=covlgd >*/
    cgd = *covlgd;
/*<       cgs=cox/(7.5d-1*phi)*vgbt+cox/1.5d0+covlgs >*/
    cgs = mosarg_1.cox / (mosarg_1.phi * .75) * vgbt + mosarg_1.cox / 1.5 + *
	    covlgs;
/*<       go to 430 >*/
    goto L430;


/*<   300 if (vdbsat.gt.vdb) go to 400 >*/
L300:
    if (vdbsat > vdb) {
	goto L400;
    }
/*<       cgb=covlgb >*/
    cgb = *covlgb;
/*<       cgd=covlgd >*/
    cgd = *covlgd;
/*<       cgs=cox/1.5d0+covlgs >*/
    cgs = mosarg_1.cox / 1.5 + *covlgs;
/*<       go to 430 >*/
    goto L430;


/*<   400 vddif=2.0d0*vdbsat-vdb >*/
L400:
    vddif = vdbsat * 2. - vdb;
/*<       vddif1=vdbsat-vdb-1.0d-12 >*/
    vddif1 = vdbsat - vdb - 1e-12;
/*<       vddif2=vddif*vddif >*/
    vddif2 = vddif * vddif;
/*<       cgd=cox*(1.0d0-vdbsat*vdbsat/vddif2)/1.5d0+covlgd >*/
    cgd = mosarg_1.cox * (1. - vdbsat * vdbsat / vddif2) / 1.5 + *covlgd;
/*<       cgs=cox*(1.0d0-vddif1*vddif1/vddif2)/1.5d0+covlgs >*/
    cgs = mosarg_1.cox * (1. - vddif1 * vddif1 / vddif2) / 1.5 + *covlgs;
/*<       cgb=covlgb >*/
    cgb = *covlgb;


/*<   430 go to (440,560), indax >*/
L430:
    switch (indax) {
	case 1:  goto L440;
	case 2:  goto L560;
    }
/*<   440 indax=2 >*/
L440:
    indax = 2;
/*<       cgs1=cgs >*/
    *cgs1 = cgs;
/*<       cgd1=cgd >*/
    *cgd1 = cgd;
/*<       cgb1=cgb >*/
    *cgb1 = cgb;
/*<       vgs=vgs0 >*/
    vgs = *vgs0;
/*<       vgd=vgd0 >*/
    vgd = *vgd0;
/*<       vgb=vgb0 >*/
    vgb = *vgb0;
/*<       vons=von0 >*/
    vons = *von0;
/*<       vbs=vgs-vgb >*/
    vbs = vgs - vgb;
/*<       vdbsat=vdsat0-vbs >*/
    vdbsat = *vdsat0 - vbs;
/*<       vdb=vgb-vgd >*/
    vdb = vgb - vgd;
/*<       go to 10 >*/
    goto L10;


/*<   560 cgs0=cgs >*/
L560:
    *cgs0 = cgs;
/*<       cgd0=cgd >*/
    *cgd0 = cgd;
/*<       cgb0=cgb >*/
    *cgb0 = cgb;

/*  finished */

/*<  1000 return >*/
/* L1000: */
    return 0;
/*<       end >*/
} /* cmeyer_ */

