1 /**** BSIM4.7.0 Released by Darsen Lu 04/08/2011 ****/
2 
3 /**********
4  * Copyright 2006 Regents of the University of California. All rights reserved.
5  * File: b4set.c of BSIM4.7.0.
6  * Author: 2000 Weidong Liu
7  * Authors: 2001- Xuemei Xi, Mohan Dunga, Ali Niknejad, Chenming Hu.
8  * Authors: 2006- Mohan Dunga, Ali Niknejad, Chenming Hu
9  * Authors: 2007- Mohan Dunga, Wenwei Yang, Ali Niknejad, Chenming Hu
10  * Authors: 2008- Wenwei Yang, Ali Niknejad, Chenming Hu
11  * Project Director: Prof. Chenming Hu.
12  * Modified by Xuemei Xi, 04/06/2001.
13  * Modified by Xuemei Xi, 10/05/2001.
14  * Modified by Xuemei Xi, 11/15/2002.
15  * Modified by Xuemei Xi, 05/09/2003.
16  * Modified by Xuemei Xi, 03/04/2004.
17  * Modified by Xuemei Xi, Mohan Dunga, 07/29/2005.
18  * Modified by Mohan Dunga, 12/13/2006
19  * Modified by Mohan Dunga, Wenwei Yang, 05/18/2007.
20  * Modified by Wenwei Yang, 07/31/2008.
21  * Modified by Tanvir Morshed, Darsen Lu 03/27/2011
22 **********/
23 
24 #include "ngspice/ngspice.h"
25 #include "ngspice/jobdefs.h"
26 #include "ngspice/ftedefs.h"
27 #include "ngspice/smpdefs.h"
28 #include "ngspice/cktdefs.h"
29 #include "bsim4v7def.h"
30 #include "ngspice/const.h"
31 #include "ngspice/sperror.h"
32 #include "ngspice/suffix.h"
33 
34 #ifdef USE_OMP
35 #include "ngspice/cpextern.h"
36 #endif
37 
38 #define MAX_EXP 5.834617425e14
39 #define MIN_EXP 1.713908431e-15
40 #define EXP_THRESHOLD 34.0
41 #define EPS0 8.85418e-12
42 #define EPSSI 1.03594e-10
43 #define PI 3.141592654
44 #define Charge_q 1.60219e-19
45 
46 int
BSIM4v7setup(SMPmatrix * matrix,GENmodel * inModel,CKTcircuit * ckt,int * states)47 BSIM4v7setup(
48 SMPmatrix *matrix,
49 GENmodel *inModel,
50 CKTcircuit *ckt,
51 int *states)
52 {
53 BSIM4v7model *model = (BSIM4v7model*)inModel;
54 BSIM4v7instance *here;
55 int error;
56 CKTnode *tmp;
57 int    noiseAnalGiven = 0, createNode;  /* Criteria for new node creation */
58 double Rtot, DMCGeff, DMCIeff, DMDGeff;
59 JOB   *job;
60 
61 #ifdef USE_OMP
62 int idx, InstCount;
63 BSIM4v7instance **InstArray;
64 #endif
65 
66     /* Search for a noise analysis request */
67     for (job = ((TSKtask *)ft_curckt->ci_curTask)->jobs;job;job = job->JOBnextJob) {
68         if(strcmp(job->JOBname,"Noise Analysis")==0) {
69             noiseAnalGiven = 1;
70             break;
71         }
72     }
73 
74     /*  loop through all the BSIM4v7 device models */
75     for( ; model != NULL; model = BSIM4v7nextModel(model))
76     {   /* process defaults of model parameters */
77         if (!model->BSIM4v7typeGiven)
78             model->BSIM4v7type = NMOS;
79 
80         if (!model->BSIM4v7mobModGiven)
81             model->BSIM4v7mobMod = 0;
82         else if ((model->BSIM4v7mobMod != 0) && (model->BSIM4v7mobMod != 1)
83                  && (model->BSIM4v7mobMod != 2)&& (model->BSIM4v7mobMod != 3))
84         {   model->BSIM4v7mobMod = 0;
85             printf("Warning: mobMod has been set to its default value: 0.\n");
86         }
87 
88         if (!model->BSIM4v7binUnitGiven)
89             model->BSIM4v7binUnit = 1;
90         if (!model->BSIM4v7paramChkGiven)
91             model->BSIM4v7paramChk = 1;
92 
93         if (!model->BSIM4v7dioModGiven)
94             model->BSIM4v7dioMod = 1;
95         else if ((model->BSIM4v7dioMod != 0) && (model->BSIM4v7dioMod != 1)
96             && (model->BSIM4v7dioMod != 2))
97         {   model->BSIM4v7dioMod = 1;
98             printf("Warning: dioMod has been set to its default value: 1.\n");
99         }
100 
101         if (!model->BSIM4v7cvchargeModGiven)
102             model->BSIM4v7cvchargeMod = 0;
103         if (!model->BSIM4v7capModGiven)
104             model->BSIM4v7capMod = 2;
105         else if ((model->BSIM4v7capMod != 0) && (model->BSIM4v7capMod != 1)
106             && (model->BSIM4v7capMod != 2))
107         {   model->BSIM4v7capMod = 2;
108             printf("Warning: capMod has been set to its default value: 2.\n");
109         }
110 
111         if (!model->BSIM4v7rdsModGiven)
112             model->BSIM4v7rdsMod = 0;
113         else if ((model->BSIM4v7rdsMod != 0) && (model->BSIM4v7rdsMod != 1))
114         {   model->BSIM4v7rdsMod = 0;
115             printf("Warning: rdsMod has been set to its default value: 0.\n");
116         }
117         if (!model->BSIM4v7rbodyModGiven)
118             model->BSIM4v7rbodyMod = 0;
119         else if ((model->BSIM4v7rbodyMod != 0) && (model->BSIM4v7rbodyMod != 1) && (model->BSIM4v7rbodyMod != 2))
120         {   model->BSIM4v7rbodyMod = 0;
121             printf("Warning: rbodyMod has been set to its default value: 0.\n");
122         }
123 
124         if (!model->BSIM4v7rgateModGiven)
125             model->BSIM4v7rgateMod = 0;
126         else if ((model->BSIM4v7rgateMod != 0) && (model->BSIM4v7rgateMod != 1)
127             && (model->BSIM4v7rgateMod != 2) && (model->BSIM4v7rgateMod != 3))
128         {   model->BSIM4v7rgateMod = 0;
129             printf("Warning: rgateMod has been set to its default value: 0.\n");
130         }
131 
132         if (!model->BSIM4v7perModGiven)
133             model->BSIM4v7perMod = 1;
134         else if ((model->BSIM4v7perMod != 0) && (model->BSIM4v7perMod != 1))
135         {   model->BSIM4v7perMod = 1;
136             printf("Warning: perMod has been set to its default value: 1.\n");
137         }
138 
139         if (!model->BSIM4v7geoModGiven)
140             model->BSIM4v7geoMod = 0;
141 
142         if (!model->BSIM4v7rgeoModGiven)
143             model->BSIM4v7rgeoMod = 0;
144         else if ((model->BSIM4v7rgeoMod != 0) && (model->BSIM4v7rgeoMod != 1))
145         {   model->BSIM4v7rgeoMod = 1;
146             printf("Warning: rgeoMod has been set to its default value: 1.\n");
147         }
148         if (!model->BSIM4v7fnoiModGiven)
149             model->BSIM4v7fnoiMod = 1;
150         else if ((model->BSIM4v7fnoiMod != 0) && (model->BSIM4v7fnoiMod != 1))
151         {   model->BSIM4v7fnoiMod = 1;
152             printf("Warning: fnoiMod has been set to its default value: 1.\n");
153         }
154         if (!model->BSIM4v7tnoiModGiven)
155             model->BSIM4v7tnoiMod = 0; /* WDLiu: tnoiMod=1 needs to set internal S/D nodes */
156         else if ((model->BSIM4v7tnoiMod != 0) && (model->BSIM4v7tnoiMod != 1) && (model->BSIM4v7tnoiMod != 2))  /* v4.7 */
157         {   model->BSIM4v7tnoiMod = 0;
158             printf("Warning: tnoiMod has been set to its default value: 0.\n");
159         }
160 
161         if (!model->BSIM4v7trnqsModGiven)
162             model->BSIM4v7trnqsMod = 0;
163         else if ((model->BSIM4v7trnqsMod != 0) && (model->BSIM4v7trnqsMod != 1))
164         {   model->BSIM4v7trnqsMod = 0;
165             printf("Warning: trnqsMod has been set to its default value: 0.\n");
166         }
167         if (!model->BSIM4v7acnqsModGiven)
168             model->BSIM4v7acnqsMod = 0;
169         else if ((model->BSIM4v7acnqsMod != 0) && (model->BSIM4v7acnqsMod != 1))
170         {   model->BSIM4v7acnqsMod = 0;
171             printf("Warning: acnqsMod has been set to its default value: 0.\n");
172         }
173 
174         if (!model->BSIM4v7mtrlModGiven)
175             model->BSIM4v7mtrlMod = 0;
176         else if((model->BSIM4v7mtrlMod != 0) && (model->BSIM4v7mtrlMod != 1))
177         {
178             model->BSIM4v7mtrlMod = 0;
179             printf("Warning: mtrlMod has been set to its default value: 0.\n");
180         }
181         if (!model->BSIM4v7mtrlCompatModGiven)
182             model->BSIM4v7mtrlCompatMod = 0;
183         else if((model->BSIM4v7mtrlCompatMod != 0) && (model->BSIM4v7mtrlCompatMod != 1))
184         {
185             model->BSIM4v7mtrlCompatMod = 0;
186             printf("Warning: mtrlCompatMod has been set to its default value: 0.\n");
187         }
188 
189         if (!model->BSIM4v7igcModGiven)
190             model->BSIM4v7igcMod = 0;
191         else if ((model->BSIM4v7igcMod != 0) && (model->BSIM4v7igcMod != 1)
192                   && (model->BSIM4v7igcMod != 2))
193         {   model->BSIM4v7igcMod = 0;
194             printf("Warning: igcMod has been set to its default value: 0.\n");
195         }
196         if (!model->BSIM4v7igbModGiven)
197             model->BSIM4v7igbMod = 0;
198         else if ((model->BSIM4v7igbMod != 0) && (model->BSIM4v7igbMod != 1))
199         {   model->BSIM4v7igbMod = 0;
200             printf("Warning: igbMod has been set to its default value: 0.\n");
201         }
202         if (!model->BSIM4v7tempModGiven)
203             model->BSIM4v7tempMod = 0;
204         else if ((model->BSIM4v7tempMod != 0) && (model->BSIM4v7tempMod != 1)
205                   && (model->BSIM4v7tempMod != 2) && (model->BSIM4v7tempMod != 3))
206         {   model->BSIM4v7tempMod = 0;
207             printf("Warning: tempMod has been set to its default value: 0.\n");
208         }
209 
210         if (!model->BSIM4v7versionGiven)
211             model->BSIM4v7version = copy("4.7.0");
212         if (!model->BSIM4v7toxrefGiven)
213             model->BSIM4v7toxref = 30.0e-10;
214         if (!model->BSIM4v7eotGiven)
215             model->BSIM4v7eot = 15.0e-10;
216         if (!model->BSIM4v7vddeotGiven)
217             model->BSIM4v7vddeot = (model->BSIM4v7type == NMOS) ? 1.5 : -1.5;
218         if (!model->BSIM4v7tempeotGiven)
219             model->BSIM4v7tempeot = 300.15;
220         if (!model->BSIM4v7leffeotGiven)
221             model->BSIM4v7leffeot = 1;
222         if (!model->BSIM4v7weffeotGiven)
223             model->BSIM4v7weffeot = 10;
224         if (!model->BSIM4v7adosGiven)
225             model->BSIM4v7ados = 1.0;
226         if (!model->BSIM4v7bdosGiven)
227             model->BSIM4v7bdos = 1.0;
228         if (!model->BSIM4v7toxeGiven)
229             model->BSIM4v7toxe = 30.0e-10;
230         if (!model->BSIM4v7toxpGiven)
231             model->BSIM4v7toxp = model->BSIM4v7toxe;
232         if (!model->BSIM4v7toxmGiven)
233             model->BSIM4v7toxm = model->BSIM4v7toxe;
234         if (!model->BSIM4v7dtoxGiven)
235             model->BSIM4v7dtox = 0.0;
236         if (!model->BSIM4v7epsroxGiven)
237             model->BSIM4v7epsrox = 3.9;
238 
239         if (!model->BSIM4v7cdscGiven)
240             model->BSIM4v7cdsc = 2.4e-4;   /* unit Q/V/m^2  */
241         if (!model->BSIM4v7cdscbGiven)
242             model->BSIM4v7cdscb = 0.0;   /* unit Q/V/m^2  */
243         if (!model->BSIM4v7cdscdGiven)
244             model->BSIM4v7cdscd = 0.0;   /* unit Q/V/m^2  */
245         if (!model->BSIM4v7citGiven)
246             model->BSIM4v7cit = 0.0;   /* unit Q/V/m^2  */
247         if (!model->BSIM4v7nfactorGiven)
248             model->BSIM4v7nfactor = 1.0;
249         if (!model->BSIM4v7xjGiven)
250             model->BSIM4v7xj = .15e-6;
251         if (!model->BSIM4v7vsatGiven)
252             model->BSIM4v7vsat = 8.0e4;    /* unit m/s */
253         if (!model->BSIM4v7atGiven)
254             model->BSIM4v7at = 3.3e4;    /* unit m/s */
255         if (!model->BSIM4v7a0Given)
256             model->BSIM4v7a0 = 1.0;
257         if (!model->BSIM4v7agsGiven)
258             model->BSIM4v7ags = 0.0;
259         if (!model->BSIM4v7a1Given)
260             model->BSIM4v7a1 = 0.0;
261         if (!model->BSIM4v7a2Given)
262             model->BSIM4v7a2 = 1.0;
263         if (!model->BSIM4v7ketaGiven)
264             model->BSIM4v7keta = -0.047;    /* unit  / V */
265         if (!model->BSIM4v7nsubGiven)
266             model->BSIM4v7nsub = 6.0e16;   /* unit 1/cm3 */
267         if (!model->BSIM4v7phigGiven)
268             model->BSIM4v7phig = 4.05;
269         if (!model->BSIM4v7epsrgateGiven)
270             model->BSIM4v7epsrgate = 11.7;
271         if (!model->BSIM4v7easubGiven)
272             model->BSIM4v7easub = 4.05;
273         if (!model->BSIM4v7epsrsubGiven)
274             model->BSIM4v7epsrsub = 11.7;
275         if (!model->BSIM4v7ni0subGiven)
276             model->BSIM4v7ni0sub = 1.45e10;   /* unit 1/cm3 */
277         if (!model->BSIM4v7bg0subGiven)
278             model->BSIM4v7bg0sub =  1.16;     /* unit eV */
279         if (!model->BSIM4v7tbgasubGiven)
280             model->BSIM4v7tbgasub = 7.02e-4;
281         if (!model->BSIM4v7tbgbsubGiven)
282             model->BSIM4v7tbgbsub = 1108.0;
283         if (!model->BSIM4v7ndepGiven)
284             model->BSIM4v7ndep = 1.7e17;   /* unit 1/cm3 */
285         if (!model->BSIM4v7nsdGiven)
286             model->BSIM4v7nsd = 1.0e20;   /* unit 1/cm3 */
287         if (!model->BSIM4v7phinGiven)
288             model->BSIM4v7phin = 0.0; /* unit V */
289         if (!model->BSIM4v7ngateGiven)
290             model->BSIM4v7ngate = 0;   /* unit 1/cm3 */
291         if (!model->BSIM4v7vbmGiven)
292             model->BSIM4v7vbm = -3.0;
293         if (!model->BSIM4v7xtGiven)
294             model->BSIM4v7xt = 1.55e-7;
295         if (!model->BSIM4v7kt1Given)
296             model->BSIM4v7kt1 = -0.11;      /* unit V */
297         if (!model->BSIM4v7kt1lGiven)
298             model->BSIM4v7kt1l = 0.0;      /* unit V*m */
299         if (!model->BSIM4v7kt2Given)
300             model->BSIM4v7kt2 = 0.022;      /* No unit */
301         if (!model->BSIM4v7k3Given)
302             model->BSIM4v7k3 = 80.0;
303         if (!model->BSIM4v7k3bGiven)
304             model->BSIM4v7k3b = 0.0;
305         if (!model->BSIM4v7w0Given)
306             model->BSIM4v7w0 = 2.5e-6;
307         if (!model->BSIM4v7lpe0Given)
308             model->BSIM4v7lpe0 = 1.74e-7;
309         if (!model->BSIM4v7lpebGiven)
310             model->BSIM4v7lpeb = 0.0;
311         if (!model->BSIM4v7dvtp0Given)
312             model->BSIM4v7dvtp0 = 0.0;
313         if (!model->BSIM4v7dvtp1Given)
314             model->BSIM4v7dvtp1 = 0.0;
315         if (!model->BSIM4v7dvtp2Given)        /* New DIBL/Rout */
316             model->BSIM4v7dvtp2 = 0.0;
317         if (!model->BSIM4v7dvtp3Given)
318             model->BSIM4v7dvtp3 = 0.0;
319         if (!model->BSIM4v7dvtp4Given)
320             model->BSIM4v7dvtp4 = 0.0;
321         if (!model->BSIM4v7dvtp5Given)
322             model->BSIM4v7dvtp5 = 0.0;
323         if (!model->BSIM4v7dvt0Given)
324             model->BSIM4v7dvt0 = 2.2;
325         if (!model->BSIM4v7dvt1Given)
326             model->BSIM4v7dvt1 = 0.53;
327         if (!model->BSIM4v7dvt2Given)
328             model->BSIM4v7dvt2 = -0.032;   /* unit 1 / V */
329 
330         if (!model->BSIM4v7dvt0wGiven)
331             model->BSIM4v7dvt0w = 0.0;
332         if (!model->BSIM4v7dvt1wGiven)
333             model->BSIM4v7dvt1w = 5.3e6;
334         if (!model->BSIM4v7dvt2wGiven)
335             model->BSIM4v7dvt2w = -0.032;
336 
337         if (!model->BSIM4v7droutGiven)
338             model->BSIM4v7drout = 0.56;
339         if (!model->BSIM4v7dsubGiven)
340             model->BSIM4v7dsub = model->BSIM4v7drout;
341         if (!model->BSIM4v7vth0Given)
342             model->BSIM4v7vth0 = (model->BSIM4v7type == NMOS) ? 0.7 : -0.7;
343         if (!model->BSIM4v7vfbGiven)
344             model->BSIM4v7vfb = -1.0;
345         if (!model->BSIM4v7euGiven)
346             model->BSIM4v7eu = (model->BSIM4v7type == NMOS) ? 1.67 : 1.0;
347         if (!model->BSIM4v7ucsGiven)
348             model->BSIM4v7ucs = (model->BSIM4v7type == NMOS) ? 1.67 : 1.0;
349         if (!model->BSIM4v7uaGiven)
350             model->BSIM4v7ua = ((model->BSIM4v7mobMod == 2)) ? 1.0e-15 : 1.0e-9; /* unit m/V */
351         if (!model->BSIM4v7ua1Given)
352             model->BSIM4v7ua1 = 1.0e-9;      /* unit m/V */
353         if (!model->BSIM4v7ubGiven)
354             model->BSIM4v7ub = 1.0e-19;     /* unit (m/V)**2 */
355         if (!model->BSIM4v7ub1Given)
356             model->BSIM4v7ub1 = -1.0e-18;     /* unit (m/V)**2 */
357         if (!model->BSIM4v7ucGiven)
358             model->BSIM4v7uc = (model->BSIM4v7mobMod == 1) ? -0.0465 : -0.0465e-9;
359         if (!model->BSIM4v7uc1Given)
360             model->BSIM4v7uc1 = (model->BSIM4v7mobMod == 1) ? -0.056 : -0.056e-9;
361         if (!model->BSIM4v7udGiven)
362             model->BSIM4v7ud = 0.0;     /* unit m**(-2) */
363         if (!model->BSIM4v7ud1Given)
364             model->BSIM4v7ud1 = 0.0;
365         if (!model->BSIM4v7upGiven)
366             model->BSIM4v7up = 0.0;
367         if (!model->BSIM4v7lpGiven)
368             model->BSIM4v7lp = 1.0e-8;
369         if (!model->BSIM4v7u0Given)
370             model->BSIM4v7u0 = (model->BSIM4v7type == NMOS) ? 0.067 : 0.025;
371         if (!model->BSIM4v7uteGiven)
372             model->BSIM4v7ute = -1.5;
373         if (!model->BSIM4v7ucsteGiven)
374             model->BSIM4v7ucste = -4.775e-3;
375         if (!model->BSIM4v7voffGiven)
376             model->BSIM4v7voff = -0.08;
377         if (!model->BSIM4v7vofflGiven)
378             model->BSIM4v7voffl = 0.0;
379         if (!model->BSIM4v7voffcvlGiven)
380             model->BSIM4v7voffcvl = 0.0;
381         if (!model->BSIM4v7minvGiven)
382             model->BSIM4v7minv = 0.0;
383         if (!model->BSIM4v7minvcvGiven)
384             model->BSIM4v7minvcv = 0.0;
385         if (!model->BSIM4v7fproutGiven)
386             model->BSIM4v7fprout = 0.0;
387         if (!model->BSIM4v7pditsGiven)
388             model->BSIM4v7pdits = 0.0;
389         if (!model->BSIM4v7pditsdGiven)
390             model->BSIM4v7pditsd = 0.0;
391         if (!model->BSIM4v7pditslGiven)
392             model->BSIM4v7pditsl = 0.0;
393         if (!model->BSIM4v7deltaGiven)
394            model->BSIM4v7delta = 0.01;
395         if (!model->BSIM4v7rdswminGiven)
396             model->BSIM4v7rdswmin = 0.0;
397         if (!model->BSIM4v7rdwminGiven)
398             model->BSIM4v7rdwmin = 0.0;
399         if (!model->BSIM4v7rswminGiven)
400             model->BSIM4v7rswmin = 0.0;
401         if (!model->BSIM4v7rdswGiven)
402             model->BSIM4v7rdsw = 200.0; /* in ohm*um */
403         if (!model->BSIM4v7rdwGiven)
404             model->BSIM4v7rdw = 100.0;
405         if (!model->BSIM4v7rswGiven)
406             model->BSIM4v7rsw = 100.0;
407         if (!model->BSIM4v7prwgGiven)
408             model->BSIM4v7prwg = 1.0; /* in 1/V */
409         if (!model->BSIM4v7prwbGiven)
410             model->BSIM4v7prwb = 0.0;
411         if (!model->BSIM4v7prtGiven)
412             model->BSIM4v7prt = 0.0;
413         if (!model->BSIM4v7eta0Given)
414             model->BSIM4v7eta0 = 0.08;      /* no unit  */
415         if (!model->BSIM4v7etabGiven)
416             model->BSIM4v7etab = -0.07;      /* unit  1/V */
417         if (!model->BSIM4v7pclmGiven)
418             model->BSIM4v7pclm = 1.3;      /* no unit  */
419         if (!model->BSIM4v7pdibl1Given)
420             model->BSIM4v7pdibl1 = 0.39;    /* no unit  */
421         if (!model->BSIM4v7pdibl2Given)
422             model->BSIM4v7pdibl2 = 0.0086;    /* no unit  */
423         if (!model->BSIM4v7pdiblbGiven)
424             model->BSIM4v7pdiblb = 0.0;    /* 1/V  */
425         if (!model->BSIM4v7pscbe1Given)
426             model->BSIM4v7pscbe1 = 4.24e8;
427         if (!model->BSIM4v7pscbe2Given)
428             model->BSIM4v7pscbe2 = 1.0e-5;
429         if (!model->BSIM4v7pvagGiven)
430             model->BSIM4v7pvag = 0.0;
431         if (!model->BSIM4v7wrGiven)
432             model->BSIM4v7wr = 1.0;
433         if (!model->BSIM4v7dwgGiven)
434             model->BSIM4v7dwg = 0.0;
435         if (!model->BSIM4v7dwbGiven)
436             model->BSIM4v7dwb = 0.0;
437         if (!model->BSIM4v7b0Given)
438             model->BSIM4v7b0 = 0.0;
439         if (!model->BSIM4v7b1Given)
440             model->BSIM4v7b1 = 0.0;
441         if (!model->BSIM4v7alpha0Given)
442             model->BSIM4v7alpha0 = 0.0;
443         if (!model->BSIM4v7alpha1Given)
444             model->BSIM4v7alpha1 = 0.0;
445         if (!model->BSIM4v7beta0Given)
446             model->BSIM4v7beta0 = 0.0;
447         if (!model->BSIM4v7gidlModGiven)
448             model->BSIM4v7gidlMod = 0;         /* v4.7 New GIDL/GISL */
449         if (!model->BSIM4v7agidlGiven)
450             model->BSIM4v7agidl = 0.0;
451         if (!model->BSIM4v7bgidlGiven)
452             model->BSIM4v7bgidl = 2.3e9; /* V/m */
453         if (!model->BSIM4v7cgidlGiven)
454             model->BSIM4v7cgidl = 0.5; /* V^3 */
455         if (!model->BSIM4v7egidlGiven)
456             model->BSIM4v7egidl = 0.8; /* V */
457         if (!model->BSIM4v7rgidlGiven)          /* v4.7 New GIDL/GISL */
458             model->BSIM4v7rgidl = 1.0;
459         if (!model->BSIM4v7kgidlGiven)          /* v4.7 New GIDL/GISL */
460             model->BSIM4v7kgidl = 0.0;
461         if (!model->BSIM4v7fgidlGiven)          /* v4.7 New GIDL/GISL */
462             model->BSIM4v7fgidl = 0.0;
463         if (!model->BSIM4v7agislGiven)
464         {
465             if (model->BSIM4v7agidlGiven)
466                 model->BSIM4v7agisl = model->BSIM4v7agidl;
467             else
468                 model->BSIM4v7agisl = 0.0;
469         }
470         if (!model->BSIM4v7bgislGiven)
471         {
472             if (model->BSIM4v7bgidlGiven)
473                 model->BSIM4v7bgisl = model->BSIM4v7bgidl;
474             else
475                 model->BSIM4v7bgisl = 2.3e9; /* V/m */
476         }
477         if (!model->BSIM4v7cgislGiven)
478         {
479             if (model->BSIM4v7cgidlGiven)
480                 model->BSIM4v7cgisl = model->BSIM4v7cgidl;
481             else
482                 model->BSIM4v7cgisl = 0.5; /* V^3 */
483         }
484         if (!model->BSIM4v7egislGiven)
485         {
486             if (model->BSIM4v7egidlGiven)
487                 model->BSIM4v7egisl = model->BSIM4v7egidl;
488             else
489                 model->BSIM4v7egisl = 0.8; /* V */
490         }
491         if (!model->BSIM4v7rgislGiven)          /* v4.7 New GIDL/GISL */
492             model->BSIM4v7rgisl = model->BSIM4v7rgidl;
493         if (!model->BSIM4v7kgislGiven)          /* v4.7 New GIDL/GISL */
494             model->BSIM4v7kgisl = model->BSIM4v7kgidl;
495         if (!model->BSIM4v7fgislGiven)          /* v4.7 New GIDL/GISL */
496             model->BSIM4v7fgisl = model->BSIM4v7fgidl;
497         if (!model->BSIM4v7aigcGiven)
498             model->BSIM4v7aigc = (model->BSIM4v7type == NMOS) ? 1.36e-2 : 9.80e-3;
499         if (!model->BSIM4v7bigcGiven)
500             model->BSIM4v7bigc = (model->BSIM4v7type == NMOS) ? 1.71e-3 : 7.59e-4;
501         if (!model->BSIM4v7cigcGiven)
502             model->BSIM4v7cigc = (model->BSIM4v7type == NMOS) ? 0.075 : 0.03;
503         if (model->BSIM4v7aigsdGiven)
504         {
505             model->BSIM4v7aigs = model->BSIM4v7aigd = model->BSIM4v7aigsd;
506         }
507         else
508         {
509             model->BSIM4v7aigsd = (model->BSIM4v7type == NMOS) ? 1.36e-2 : 9.80e-3;
510             if (!model->BSIM4v7aigsGiven)
511                 model->BSIM4v7aigs = (model->BSIM4v7type == NMOS) ? 1.36e-2 : 9.80e-3;
512             if (!model->BSIM4v7aigdGiven)
513                 model->BSIM4v7aigd = (model->BSIM4v7type == NMOS) ? 1.36e-2 : 9.80e-3;
514         }
515         if (model->BSIM4v7bigsdGiven)
516         {
517             model->BSIM4v7bigs = model->BSIM4v7bigd = model->BSIM4v7bigsd;
518         }
519         else
520         {
521             model->BSIM4v7bigsd = (model->BSIM4v7type == NMOS) ? 1.71e-3 : 7.59e-4;
522             if (!model->BSIM4v7bigsGiven)
523                 model->BSIM4v7bigs = (model->BSIM4v7type == NMOS) ? 1.71e-3 : 7.59e-4;
524             if (!model->BSIM4v7bigdGiven)
525                 model->BSIM4v7bigd = (model->BSIM4v7type == NMOS) ? 1.71e-3 : 7.59e-4;
526         }
527         if (model->BSIM4v7cigsdGiven)
528         {
529             model->BSIM4v7cigs = model->BSIM4v7cigd = model->BSIM4v7cigsd;
530         }
531         else
532         {
533              model->BSIM4v7cigsd = (model->BSIM4v7type == NMOS) ? 0.075 : 0.03;
534            if (!model->BSIM4v7cigsGiven)
535                 model->BSIM4v7cigs = (model->BSIM4v7type == NMOS) ? 0.075 : 0.03;
536             if (!model->BSIM4v7cigdGiven)
537                 model->BSIM4v7cigd = (model->BSIM4v7type == NMOS) ? 0.075 : 0.03;
538         }
539         if (!model->BSIM4v7aigbaccGiven)
540             model->BSIM4v7aigbacc = 1.36e-2;
541         if (!model->BSIM4v7bigbaccGiven)
542             model->BSIM4v7bigbacc = 1.71e-3;
543         if (!model->BSIM4v7cigbaccGiven)
544             model->BSIM4v7cigbacc = 0.075;
545         if (!model->BSIM4v7aigbinvGiven)
546             model->BSIM4v7aigbinv = 1.11e-2;
547         if (!model->BSIM4v7bigbinvGiven)
548             model->BSIM4v7bigbinv = 9.49e-4;
549         if (!model->BSIM4v7cigbinvGiven)
550             model->BSIM4v7cigbinv = 0.006;
551         if (!model->BSIM4v7nigcGiven)
552             model->BSIM4v7nigc = 1.0;
553         if (!model->BSIM4v7nigbinvGiven)
554             model->BSIM4v7nigbinv = 3.0;
555         if (!model->BSIM4v7nigbaccGiven)
556             model->BSIM4v7nigbacc = 1.0;
557         if (!model->BSIM4v7ntoxGiven)
558             model->BSIM4v7ntox = 1.0;
559         if (!model->BSIM4v7eigbinvGiven)
560             model->BSIM4v7eigbinv = 1.1;
561         if (!model->BSIM4v7pigcdGiven)
562             model->BSIM4v7pigcd = 1.0;
563         if (!model->BSIM4v7poxedgeGiven)
564             model->BSIM4v7poxedge = 1.0;
565         if (!model->BSIM4v7xrcrg1Given)
566             model->BSIM4v7xrcrg1 = 12.0;
567         if (!model->BSIM4v7xrcrg2Given)
568             model->BSIM4v7xrcrg2 = 1.0;
569         if (!model->BSIM4v7ijthsfwdGiven)
570             model->BSIM4v7ijthsfwd = 0.1; /* unit A */
571         if (!model->BSIM4v7ijthdfwdGiven)
572             model->BSIM4v7ijthdfwd = model->BSIM4v7ijthsfwd;
573         if (!model->BSIM4v7ijthsrevGiven)
574             model->BSIM4v7ijthsrev = 0.1; /* unit A */
575         if (!model->BSIM4v7ijthdrevGiven)
576             model->BSIM4v7ijthdrev = model->BSIM4v7ijthsrev;
577         if (!model->BSIM4v7tnoiaGiven)
578             model->BSIM4v7tnoia = 1.5;
579         if (!model->BSIM4v7tnoibGiven)
580             model->BSIM4v7tnoib = 3.5;
581         if (!model->BSIM4v7tnoicGiven)
582             model->BSIM4v7tnoic = 0.0;
583         if (!model->BSIM4v7rnoiaGiven)
584             model->BSIM4v7rnoia = 0.577;
585         if (!model->BSIM4v7rnoibGiven)
586             model->BSIM4v7rnoib = 0.5164;
587         if (!model->BSIM4v7rnoicGiven)
588             model->BSIM4v7rnoic = 0.395;
589         if (!model->BSIM4v7ntnoiGiven)
590             model->BSIM4v7ntnoi = 1.0;
591         if (!model->BSIM4v7lambdaGiven)
592             model->BSIM4v7lambda = 0.0;
593         if (!model->BSIM4v7vtlGiven)
594             model->BSIM4v7vtl = 2.0e5;    /* unit m/s */
595         if (!model->BSIM4v7xnGiven)
596             model->BSIM4v7xn = 3.0;
597         if (!model->BSIM4v7lcGiven)
598             model->BSIM4v7lc = 5.0e-9;
599         if (!model->BSIM4v7vfbsdoffGiven)
600             model->BSIM4v7vfbsdoff = 0.0;  /* unit v */
601         if (!model->BSIM4v7tvfbsdoffGiven)
602             model->BSIM4v7tvfbsdoff = 0.0;
603         if (!model->BSIM4v7tvoffGiven)
604             model->BSIM4v7tvoff = 0.0;
605         if (!model->BSIM4v7tnfactorGiven)         /* v4.7 temp dep of leakage current  */
606             model->BSIM4v7tnfactor = 0.0;
607         if (!model->BSIM4v7teta0Given)                /* v4.7 temp dep of leakage current  */
608             model->BSIM4v7teta0 = 0.0;
609         if (!model->BSIM4v7tvoffcvGiven)                /* v4.7 temp dep of leakage current  */
610             model->BSIM4v7tvoffcv = 0.0;
611 
612         if (!model->BSIM4v7lintnoiGiven)
613             model->BSIM4v7lintnoi = 0.0;  /* unit m */
614 
615         if (!model->BSIM4v7xjbvsGiven)
616             model->BSIM4v7xjbvs = 1.0; /* no unit */
617         if (!model->BSIM4v7xjbvdGiven)
618             model->BSIM4v7xjbvd = model->BSIM4v7xjbvs;
619         if (!model->BSIM4v7bvsGiven)
620             model->BSIM4v7bvs = 10.0; /* V */
621         if (!model->BSIM4v7bvdGiven)
622             model->BSIM4v7bvd = model->BSIM4v7bvs;
623 
624         if (!model->BSIM4v7gbminGiven)
625             model->BSIM4v7gbmin = 1.0e-12; /* in mho */
626         if (!model->BSIM4v7rbdbGiven)
627             model->BSIM4v7rbdb = 50.0; /* in ohm */
628         if (!model->BSIM4v7rbpbGiven)
629             model->BSIM4v7rbpb = 50.0;
630         if (!model->BSIM4v7rbsbGiven)
631             model->BSIM4v7rbsb = 50.0;
632         if (!model->BSIM4v7rbpsGiven)
633             model->BSIM4v7rbps = 50.0;
634         if (!model->BSIM4v7rbpdGiven)
635             model->BSIM4v7rbpd = 50.0;
636 
637         if (!model->BSIM4v7rbps0Given)
638             model->BSIM4v7rbps0 = 50.0;
639         if (!model->BSIM4v7rbpslGiven)
640             model->BSIM4v7rbpsl = 0.0;
641         if (!model->BSIM4v7rbpswGiven)
642             model->BSIM4v7rbpsw = 0.0;
643         if (!model->BSIM4v7rbpsnfGiven)
644             model->BSIM4v7rbpsnf = 0.0;
645 
646         if (!model->BSIM4v7rbpd0Given)
647             model->BSIM4v7rbpd0 = 50.0;
648         if (!model->BSIM4v7rbpdlGiven)
649             model->BSIM4v7rbpdl = 0.0;
650         if (!model->BSIM4v7rbpdwGiven)
651             model->BSIM4v7rbpdw = 0.0;
652         if (!model->BSIM4v7rbpdnfGiven)
653             model->BSIM4v7rbpdnf = 0.0;
654 
655         if (!model->BSIM4v7rbpbx0Given)
656             model->BSIM4v7rbpbx0 = 100.0;
657         if (!model->BSIM4v7rbpbxlGiven)
658             model->BSIM4v7rbpbxl = 0.0;
659         if (!model->BSIM4v7rbpbxwGiven)
660             model->BSIM4v7rbpbxw = 0.0;
661         if (!model->BSIM4v7rbpbxnfGiven)
662             model->BSIM4v7rbpbxnf = 0.0;
663         if (!model->BSIM4v7rbpby0Given)
664             model->BSIM4v7rbpby0 = 100.0;
665         if (!model->BSIM4v7rbpbylGiven)
666             model->BSIM4v7rbpbyl = 0.0;
667         if (!model->BSIM4v7rbpbywGiven)
668             model->BSIM4v7rbpbyw = 0.0;
669         if (!model->BSIM4v7rbpbynfGiven)
670             model->BSIM4v7rbpbynf = 0.0;
671 
672 
673         if (!model->BSIM4v7rbsbx0Given)
674             model->BSIM4v7rbsbx0 = 100.0;
675         if (!model->BSIM4v7rbsby0Given)
676             model->BSIM4v7rbsby0 = 100.0;
677         if (!model->BSIM4v7rbdbx0Given)
678             model->BSIM4v7rbdbx0 = 100.0;
679         if (!model->BSIM4v7rbdby0Given)
680             model->BSIM4v7rbdby0 = 100.0;
681 
682 
683         if (!model->BSIM4v7rbsdbxlGiven)
684             model->BSIM4v7rbsdbxl = 0.0;
685         if (!model->BSIM4v7rbsdbxwGiven)
686             model->BSIM4v7rbsdbxw = 0.0;
687         if (!model->BSIM4v7rbsdbxnfGiven)
688             model->BSIM4v7rbsdbxnf = 0.0;
689         if (!model->BSIM4v7rbsdbylGiven)
690             model->BSIM4v7rbsdbyl = 0.0;
691         if (!model->BSIM4v7rbsdbywGiven)
692             model->BSIM4v7rbsdbyw = 0.0;
693         if (!model->BSIM4v7rbsdbynfGiven)
694             model->BSIM4v7rbsdbynf = 0.0;
695 
696         if (!model->BSIM4v7cgslGiven)
697             model->BSIM4v7cgsl = 0.0;
698         if (!model->BSIM4v7cgdlGiven)
699             model->BSIM4v7cgdl = 0.0;
700         if (!model->BSIM4v7ckappasGiven)
701             model->BSIM4v7ckappas = 0.6;
702         if (!model->BSIM4v7ckappadGiven)
703             model->BSIM4v7ckappad = model->BSIM4v7ckappas;
704         if (!model->BSIM4v7clcGiven)
705             model->BSIM4v7clc = 0.1e-6;
706         if (!model->BSIM4v7cleGiven)
707             model->BSIM4v7cle = 0.6;
708         if (!model->BSIM4v7vfbcvGiven)
709             model->BSIM4v7vfbcv = -1.0;
710         if (!model->BSIM4v7acdeGiven)
711             model->BSIM4v7acde = 1.0;
712         if (!model->BSIM4v7moinGiven)
713             model->BSIM4v7moin = 15.0;
714         if (!model->BSIM4v7noffGiven)
715             model->BSIM4v7noff = 1.0;
716         if (!model->BSIM4v7voffcvGiven)
717             model->BSIM4v7voffcv = 0.0;
718         if (!model->BSIM4v7dmcgGiven)
719             model->BSIM4v7dmcg = 0.0;
720         if (!model->BSIM4v7dmciGiven)
721             model->BSIM4v7dmci = model->BSIM4v7dmcg;
722         if (!model->BSIM4v7dmdgGiven)
723             model->BSIM4v7dmdg = 0.0;
724         if (!model->BSIM4v7dmcgtGiven)
725             model->BSIM4v7dmcgt = 0.0;
726         if (!model->BSIM4v7xgwGiven)
727             model->BSIM4v7xgw = 0.0;
728         if (!model->BSIM4v7xglGiven)
729             model->BSIM4v7xgl = 0.0;
730         if (!model->BSIM4v7rshgGiven)
731             model->BSIM4v7rshg = 0.1;
732         if (!model->BSIM4v7ngconGiven)
733             model->BSIM4v7ngcon = 1.0;
734         if (!model->BSIM4v7tcjGiven)
735             model->BSIM4v7tcj = 0.0;
736         if (!model->BSIM4v7tpbGiven)
737             model->BSIM4v7tpb = 0.0;
738         if (!model->BSIM4v7tcjswGiven)
739             model->BSIM4v7tcjsw = 0.0;
740         if (!model->BSIM4v7tpbswGiven)
741             model->BSIM4v7tpbsw = 0.0;
742         if (!model->BSIM4v7tcjswgGiven)
743             model->BSIM4v7tcjswg = 0.0;
744         if (!model->BSIM4v7tpbswgGiven)
745             model->BSIM4v7tpbswg = 0.0;
746 
747         /* Length dependence */
748         if (!model->BSIM4v7lcdscGiven)
749             model->BSIM4v7lcdsc = 0.0;
750         if (!model->BSIM4v7lcdscbGiven)
751             model->BSIM4v7lcdscb = 0.0;
752         if (!model->BSIM4v7lcdscdGiven)
753             model->BSIM4v7lcdscd = 0.0;
754         if (!model->BSIM4v7lcitGiven)
755             model->BSIM4v7lcit = 0.0;
756         if (!model->BSIM4v7lnfactorGiven)
757             model->BSIM4v7lnfactor = 0.0;
758         if (!model->BSIM4v7lxjGiven)
759             model->BSIM4v7lxj = 0.0;
760         if (!model->BSIM4v7lvsatGiven)
761             model->BSIM4v7lvsat = 0.0;
762         if (!model->BSIM4v7latGiven)
763             model->BSIM4v7lat = 0.0;
764         if (!model->BSIM4v7la0Given)
765             model->BSIM4v7la0 = 0.0;
766         if (!model->BSIM4v7lagsGiven)
767             model->BSIM4v7lags = 0.0;
768         if (!model->BSIM4v7la1Given)
769             model->BSIM4v7la1 = 0.0;
770         if (!model->BSIM4v7la2Given)
771             model->BSIM4v7la2 = 0.0;
772         if (!model->BSIM4v7lketaGiven)
773             model->BSIM4v7lketa = 0.0;
774         if (!model->BSIM4v7lnsubGiven)
775             model->BSIM4v7lnsub = 0.0;
776         if (!model->BSIM4v7lndepGiven)
777             model->BSIM4v7lndep = 0.0;
778         if (!model->BSIM4v7lnsdGiven)
779             model->BSIM4v7lnsd = 0.0;
780         if (!model->BSIM4v7lphinGiven)
781             model->BSIM4v7lphin = 0.0;
782         if (!model->BSIM4v7lngateGiven)
783             model->BSIM4v7lngate = 0.0;
784         if (!model->BSIM4v7lvbmGiven)
785             model->BSIM4v7lvbm = 0.0;
786         if (!model->BSIM4v7lxtGiven)
787             model->BSIM4v7lxt = 0.0;
788         if (!model->BSIM4v7lkt1Given)
789             model->BSIM4v7lkt1 = 0.0;
790         if (!model->BSIM4v7lkt1lGiven)
791             model->BSIM4v7lkt1l = 0.0;
792         if (!model->BSIM4v7lkt2Given)
793             model->BSIM4v7lkt2 = 0.0;
794         if (!model->BSIM4v7lk3Given)
795             model->BSIM4v7lk3 = 0.0;
796         if (!model->BSIM4v7lk3bGiven)
797             model->BSIM4v7lk3b = 0.0;
798         if (!model->BSIM4v7lw0Given)
799             model->BSIM4v7lw0 = 0.0;
800         if (!model->BSIM4v7llpe0Given)
801             model->BSIM4v7llpe0 = 0.0;
802         if (!model->BSIM4v7llpebGiven)
803             model->BSIM4v7llpeb = 0.0;
804         if (!model->BSIM4v7ldvtp0Given)
805             model->BSIM4v7ldvtp0 = 0.0;
806         if (!model->BSIM4v7ldvtp1Given)
807             model->BSIM4v7ldvtp1 = 0.0;
808         if (!model->BSIM4v7ldvtp2Given)        /* New DIBL/Rout */
809             model->BSIM4v7ldvtp2 = 0.0;
810         if (!model->BSIM4v7ldvtp3Given)
811             model->BSIM4v7ldvtp3 = 0.0;
812         if (!model->BSIM4v7ldvtp4Given)
813             model->BSIM4v7ldvtp4 = 0.0;
814         if (!model->BSIM4v7ldvtp5Given)
815             model->BSIM4v7ldvtp5 = 0.0;
816         if (!model->BSIM4v7ldvt0Given)
817             model->BSIM4v7ldvt0 = 0.0;
818         if (!model->BSIM4v7ldvt1Given)
819             model->BSIM4v7ldvt1 = 0.0;
820         if (!model->BSIM4v7ldvt2Given)
821             model->BSIM4v7ldvt2 = 0.0;
822         if (!model->BSIM4v7ldvt0wGiven)
823             model->BSIM4v7ldvt0w = 0.0;
824         if (!model->BSIM4v7ldvt1wGiven)
825             model->BSIM4v7ldvt1w = 0.0;
826         if (!model->BSIM4v7ldvt2wGiven)
827             model->BSIM4v7ldvt2w = 0.0;
828         if (!model->BSIM4v7ldroutGiven)
829             model->BSIM4v7ldrout = 0.0;
830         if (!model->BSIM4v7ldsubGiven)
831             model->BSIM4v7ldsub = 0.0;
832         if (!model->BSIM4v7lvth0Given)
833            model->BSIM4v7lvth0 = 0.0;
834         if (!model->BSIM4v7luaGiven)
835             model->BSIM4v7lua = 0.0;
836         if (!model->BSIM4v7lua1Given)
837             model->BSIM4v7lua1 = 0.0;
838         if (!model->BSIM4v7lubGiven)
839             model->BSIM4v7lub = 0.0;
840         if (!model->BSIM4v7lub1Given)
841             model->BSIM4v7lub1 = 0.0;
842         if (!model->BSIM4v7lucGiven)
843             model->BSIM4v7luc = 0.0;
844         if (!model->BSIM4v7luc1Given)
845             model->BSIM4v7luc1 = 0.0;
846         if (!model->BSIM4v7ludGiven)
847             model->BSIM4v7lud = 0.0;
848         if (!model->BSIM4v7lud1Given)
849             model->BSIM4v7lud1 = 0.0;
850         if (!model->BSIM4v7lupGiven)
851             model->BSIM4v7lup = 0.0;
852         if (!model->BSIM4v7llpGiven)
853             model->BSIM4v7llp = 0.0;
854         if (!model->BSIM4v7lu0Given)
855             model->BSIM4v7lu0 = 0.0;
856         if (!model->BSIM4v7luteGiven)
857             model->BSIM4v7lute = 0.0;
858           if (!model->BSIM4v7lucsteGiven)
859             model->BSIM4v7lucste = 0.0;
860         if (!model->BSIM4v7lvoffGiven)
861             model->BSIM4v7lvoff = 0.0;
862         if (!model->BSIM4v7lminvGiven)
863             model->BSIM4v7lminv = 0.0;
864         if (!model->BSIM4v7lminvcvGiven)
865             model->BSIM4v7lminvcv = 0.0;
866         if (!model->BSIM4v7lfproutGiven)
867             model->BSIM4v7lfprout = 0.0;
868         if (!model->BSIM4v7lpditsGiven)
869             model->BSIM4v7lpdits = 0.0;
870         if (!model->BSIM4v7lpditsdGiven)
871             model->BSIM4v7lpditsd = 0.0;
872         if (!model->BSIM4v7ldeltaGiven)
873             model->BSIM4v7ldelta = 0.0;
874         if (!model->BSIM4v7lrdswGiven)
875             model->BSIM4v7lrdsw = 0.0;
876         if (!model->BSIM4v7lrdwGiven)
877             model->BSIM4v7lrdw = 0.0;
878         if (!model->BSIM4v7lrswGiven)
879             model->BSIM4v7lrsw = 0.0;
880         if (!model->BSIM4v7lprwbGiven)
881             model->BSIM4v7lprwb = 0.0;
882         if (!model->BSIM4v7lprwgGiven)
883             model->BSIM4v7lprwg = 0.0;
884         if (!model->BSIM4v7lprtGiven)
885             model->BSIM4v7lprt = 0.0;
886         if (!model->BSIM4v7leta0Given)
887             model->BSIM4v7leta0 = 0.0;
888         if (!model->BSIM4v7letabGiven)
889             model->BSIM4v7letab = -0.0;
890         if (!model->BSIM4v7lpclmGiven)
891             model->BSIM4v7lpclm = 0.0;
892         if (!model->BSIM4v7lpdibl1Given)
893             model->BSIM4v7lpdibl1 = 0.0;
894         if (!model->BSIM4v7lpdibl2Given)
895             model->BSIM4v7lpdibl2 = 0.0;
896         if (!model->BSIM4v7lpdiblbGiven)
897             model->BSIM4v7lpdiblb = 0.0;
898         if (!model->BSIM4v7lpscbe1Given)
899             model->BSIM4v7lpscbe1 = 0.0;
900         if (!model->BSIM4v7lpscbe2Given)
901             model->BSIM4v7lpscbe2 = 0.0;
902         if (!model->BSIM4v7lpvagGiven)
903             model->BSIM4v7lpvag = 0.0;
904         if (!model->BSIM4v7lwrGiven)
905             model->BSIM4v7lwr = 0.0;
906         if (!model->BSIM4v7ldwgGiven)
907             model->BSIM4v7ldwg = 0.0;
908         if (!model->BSIM4v7ldwbGiven)
909             model->BSIM4v7ldwb = 0.0;
910         if (!model->BSIM4v7lb0Given)
911             model->BSIM4v7lb0 = 0.0;
912         if (!model->BSIM4v7lb1Given)
913             model->BSIM4v7lb1 = 0.0;
914         if (!model->BSIM4v7lalpha0Given)
915             model->BSIM4v7lalpha0 = 0.0;
916         if (!model->BSIM4v7lalpha1Given)
917             model->BSIM4v7lalpha1 = 0.0;
918         if (!model->BSIM4v7lbeta0Given)
919             model->BSIM4v7lbeta0 = 0.0;
920         if (!model->BSIM4v7lagidlGiven)
921             model->BSIM4v7lagidl = 0.0;
922         if (!model->BSIM4v7lbgidlGiven)
923             model->BSIM4v7lbgidl = 0.0;
924         if (!model->BSIM4v7lcgidlGiven)
925             model->BSIM4v7lcgidl = 0.0;
926         if (!model->BSIM4v7legidlGiven)
927             model->BSIM4v7legidl = 0.0;
928         if (!model->BSIM4v7lrgidlGiven)        /* v4.7 New GIDL/GISL */
929             model->BSIM4v7lrgidl = 0.0;
930         if (!model->BSIM4v7lkgidlGiven)        /* v4.7 New GIDL/GISL */
931             model->BSIM4v7lkgidl = 0.0;
932         if (!model->BSIM4v7lfgidlGiven)        /* v4.7 New GIDL/GISL */
933             model->BSIM4v7lfgidl = 0.0;
934 
935         if (!model->BSIM4v7lagislGiven)
936         {
937             if (model->BSIM4v7lagidlGiven)
938                 model->BSIM4v7lagisl = model->BSIM4v7lagidl;
939             else
940                 model->BSIM4v7lagisl = 0.0;
941         }
942         if (!model->BSIM4v7lbgislGiven)
943         {
944             if (model->BSIM4v7lbgidlGiven)
945                 model->BSIM4v7lbgisl = model->BSIM4v7lbgidl;
946             else
947                 model->BSIM4v7lbgisl = 0.0;
948         }
949         if (!model->BSIM4v7lcgislGiven)
950         {
951             if (model->BSIM4v7lcgidlGiven)
952                 model->BSIM4v7lcgisl = model->BSIM4v7lcgidl;
953             else
954                 model->BSIM4v7lcgisl = 0.0;
955         }
956         if (!model->BSIM4v7legislGiven)
957         {
958             if (model->BSIM4v7legidlGiven)
959                 model->BSIM4v7legisl = model->BSIM4v7legidl;
960             else
961                 model->BSIM4v7legisl = 0.0;
962         }
963         if (!model->BSIM4v7lrgislGiven)         /* v4.7 New GIDL/GISL */
964         {
965             if (model->BSIM4v7lrgidlGiven)
966                 model->BSIM4v7lrgisl = model->BSIM4v7lrgidl;
967         }
968         if (!model->BSIM4v7lkgislGiven)        /* v4.7 New GIDL/GISL */
969         {
970             if (model->BSIM4v7lkgidlGiven)
971                 model->BSIM4v7lkgisl = model->BSIM4v7lkgidl;
972         }
973         if (!model->BSIM4v7lfgislGiven)        /* v4.7 New GIDL/GISL */
974         {
975             if (model->BSIM4v7lfgidlGiven)
976                 model->BSIM4v7lfgisl = model->BSIM4v7lfgidl;
977         }
978         if (!model->BSIM4v7laigcGiven)
979             model->BSIM4v7laigc = 0.0;
980         if (!model->BSIM4v7lbigcGiven)
981             model->BSIM4v7lbigc = 0.0;
982         if (!model->BSIM4v7lcigcGiven)
983             model->BSIM4v7lcigc = 0.0;
984         if (!model->BSIM4v7aigsdGiven && (model->BSIM4v7aigsGiven || model->BSIM4v7aigdGiven))
985         {
986             if (!model->BSIM4v7laigsGiven)
987                 model->BSIM4v7laigs = 0.0;
988             if (!model->BSIM4v7laigdGiven)
989                 model->BSIM4v7laigd = 0.0;
990         }
991         else
992         {
993            if (!model->BSIM4v7laigsdGiven)
994                model->BSIM4v7laigsd = 0.0;
995            model->BSIM4v7laigs = model->BSIM4v7laigd = model->BSIM4v7laigsd;
996         }
997         if (!model->BSIM4v7bigsdGiven && (model->BSIM4v7bigsGiven || model->BSIM4v7bigdGiven))
998         {
999             if (!model->BSIM4v7lbigsGiven)
1000                 model->BSIM4v7lbigs = 0.0;
1001             if (!model->BSIM4v7lbigdGiven)
1002                 model->BSIM4v7lbigd = 0.0;
1003         }
1004         else
1005         {
1006            if (!model->BSIM4v7lbigsdGiven)
1007                model->BSIM4v7lbigsd = 0.0;
1008            model->BSIM4v7lbigs = model->BSIM4v7lbigd = model->BSIM4v7lbigsd;
1009         }
1010         if (!model->BSIM4v7cigsdGiven && (model->BSIM4v7cigsGiven || model->BSIM4v7cigdGiven))
1011         {
1012             if (!model->BSIM4v7lcigsGiven)
1013                 model->BSIM4v7lcigs = 0.0;
1014             if (!model->BSIM4v7lcigdGiven)
1015                 model->BSIM4v7lcigd = 0.0;
1016         }
1017         else
1018         {
1019            if (!model->BSIM4v7lcigsdGiven)
1020                model->BSIM4v7lcigsd = 0.0;
1021            model->BSIM4v7lcigs = model->BSIM4v7lcigd = model->BSIM4v7lcigsd;
1022         }
1023         if (!model->BSIM4v7laigbaccGiven)
1024             model->BSIM4v7laigbacc = 0.0;
1025         if (!model->BSIM4v7lbigbaccGiven)
1026             model->BSIM4v7lbigbacc = 0.0;
1027         if (!model->BSIM4v7lcigbaccGiven)
1028             model->BSIM4v7lcigbacc = 0.0;
1029         if (!model->BSIM4v7laigbinvGiven)
1030             model->BSIM4v7laigbinv = 0.0;
1031         if (!model->BSIM4v7lbigbinvGiven)
1032             model->BSIM4v7lbigbinv = 0.0;
1033         if (!model->BSIM4v7lcigbinvGiven)
1034             model->BSIM4v7lcigbinv = 0.0;
1035         if (!model->BSIM4v7lnigcGiven)
1036             model->BSIM4v7lnigc = 0.0;
1037         if (!model->BSIM4v7lnigbinvGiven)
1038             model->BSIM4v7lnigbinv = 0.0;
1039         if (!model->BSIM4v7lnigbaccGiven)
1040             model->BSIM4v7lnigbacc = 0.0;
1041         if (!model->BSIM4v7lntoxGiven)
1042             model->BSIM4v7lntox = 0.0;
1043         if (!model->BSIM4v7leigbinvGiven)
1044             model->BSIM4v7leigbinv = 0.0;
1045         if (!model->BSIM4v7lpigcdGiven)
1046             model->BSIM4v7lpigcd = 0.0;
1047         if (!model->BSIM4v7lpoxedgeGiven)
1048             model->BSIM4v7lpoxedge = 0.0;
1049         if (!model->BSIM4v7lxrcrg1Given)
1050             model->BSIM4v7lxrcrg1 = 0.0;
1051         if (!model->BSIM4v7lxrcrg2Given)
1052             model->BSIM4v7lxrcrg2 = 0.0;
1053         if (!model->BSIM4v7leuGiven)
1054             model->BSIM4v7leu = 0.0;
1055                 if (!model->BSIM4v7lucsGiven)
1056             model->BSIM4v7lucs = 0.0;
1057         if (!model->BSIM4v7lvfbGiven)
1058             model->BSIM4v7lvfb = 0.0;
1059         if (!model->BSIM4v7llambdaGiven)
1060             model->BSIM4v7llambda = 0.0;
1061         if (!model->BSIM4v7lvtlGiven)
1062             model->BSIM4v7lvtl = 0.0;
1063         if (!model->BSIM4v7lxnGiven)
1064             model->BSIM4v7lxn = 0.0;
1065         if (!model->BSIM4v7lvfbsdoffGiven)
1066             model->BSIM4v7lvfbsdoff = 0.0;
1067         if (!model->BSIM4v7ltvfbsdoffGiven)
1068             model->BSIM4v7ltvfbsdoff = 0.0;
1069         if (!model->BSIM4v7ltvoffGiven)
1070             model->BSIM4v7ltvoff = 0.0;
1071         if (!model->BSIM4v7ltnfactorGiven)         /* v4.7 temp dep of leakage current  */
1072             model->BSIM4v7ltnfactor = 0.0;
1073         if (!model->BSIM4v7lteta0Given)                /* v4.7 temp dep of leakage current  */
1074             model->BSIM4v7lteta0 = 0.0;
1075         if (!model->BSIM4v7ltvoffcvGiven)                /* v4.7 temp dep of leakage current  */
1076             model->BSIM4v7ltvoffcv = 0.0;
1077 
1078 
1079         if (!model->BSIM4v7lcgslGiven)
1080             model->BSIM4v7lcgsl = 0.0;
1081         if (!model->BSIM4v7lcgdlGiven)
1082             model->BSIM4v7lcgdl = 0.0;
1083         if (!model->BSIM4v7lckappasGiven)
1084             model->BSIM4v7lckappas = 0.0;
1085         if (!model->BSIM4v7lckappadGiven)
1086             model->BSIM4v7lckappad = 0.0;
1087         if (!model->BSIM4v7lclcGiven)
1088             model->BSIM4v7lclc = 0.0;
1089         if (!model->BSIM4v7lcleGiven)
1090             model->BSIM4v7lcle = 0.0;
1091         if (!model->BSIM4v7lcfGiven)
1092             model->BSIM4v7lcf = 0.0;
1093         if (!model->BSIM4v7lvfbcvGiven)
1094             model->BSIM4v7lvfbcv = 0.0;
1095         if (!model->BSIM4v7lacdeGiven)
1096             model->BSIM4v7lacde = 0.0;
1097         if (!model->BSIM4v7lmoinGiven)
1098             model->BSIM4v7lmoin = 0.0;
1099         if (!model->BSIM4v7lnoffGiven)
1100             model->BSIM4v7lnoff = 0.0;
1101         if (!model->BSIM4v7lvoffcvGiven)
1102             model->BSIM4v7lvoffcv = 0.0;
1103 
1104         /* Width dependence */
1105         if (!model->BSIM4v7wcdscGiven)
1106             model->BSIM4v7wcdsc = 0.0;
1107         if (!model->BSIM4v7wcdscbGiven)
1108             model->BSIM4v7wcdscb = 0.0;
1109         if (!model->BSIM4v7wcdscdGiven)
1110             model->BSIM4v7wcdscd = 0.0;
1111         if (!model->BSIM4v7wcitGiven)
1112             model->BSIM4v7wcit = 0.0;
1113         if (!model->BSIM4v7wnfactorGiven)
1114             model->BSIM4v7wnfactor = 0.0;
1115         if (!model->BSIM4v7wxjGiven)
1116             model->BSIM4v7wxj = 0.0;
1117         if (!model->BSIM4v7wvsatGiven)
1118             model->BSIM4v7wvsat = 0.0;
1119         if (!model->BSIM4v7watGiven)
1120             model->BSIM4v7wat = 0.0;
1121         if (!model->BSIM4v7wa0Given)
1122             model->BSIM4v7wa0 = 0.0;
1123         if (!model->BSIM4v7wagsGiven)
1124             model->BSIM4v7wags = 0.0;
1125         if (!model->BSIM4v7wa1Given)
1126             model->BSIM4v7wa1 = 0.0;
1127         if (!model->BSIM4v7wa2Given)
1128             model->BSIM4v7wa2 = 0.0;
1129         if (!model->BSIM4v7wketaGiven)
1130             model->BSIM4v7wketa = 0.0;
1131         if (!model->BSIM4v7wnsubGiven)
1132             model->BSIM4v7wnsub = 0.0;
1133         if (!model->BSIM4v7wndepGiven)
1134             model->BSIM4v7wndep = 0.0;
1135         if (!model->BSIM4v7wnsdGiven)
1136             model->BSIM4v7wnsd = 0.0;
1137         if (!model->BSIM4v7wphinGiven)
1138             model->BSIM4v7wphin = 0.0;
1139         if (!model->BSIM4v7wngateGiven)
1140             model->BSIM4v7wngate = 0.0;
1141         if (!model->BSIM4v7wvbmGiven)
1142             model->BSIM4v7wvbm = 0.0;
1143         if (!model->BSIM4v7wxtGiven)
1144             model->BSIM4v7wxt = 0.0;
1145         if (!model->BSIM4v7wkt1Given)
1146             model->BSIM4v7wkt1 = 0.0;
1147         if (!model->BSIM4v7wkt1lGiven)
1148             model->BSIM4v7wkt1l = 0.0;
1149         if (!model->BSIM4v7wkt2Given)
1150             model->BSIM4v7wkt2 = 0.0;
1151         if (!model->BSIM4v7wk3Given)
1152             model->BSIM4v7wk3 = 0.0;
1153         if (!model->BSIM4v7wk3bGiven)
1154             model->BSIM4v7wk3b = 0.0;
1155         if (!model->BSIM4v7ww0Given)
1156             model->BSIM4v7ww0 = 0.0;
1157         if (!model->BSIM4v7wlpe0Given)
1158             model->BSIM4v7wlpe0 = 0.0;
1159         if (!model->BSIM4v7wlpebGiven)
1160             model->BSIM4v7wlpeb = 0.0;
1161         if (!model->BSIM4v7wdvtp0Given)
1162             model->BSIM4v7wdvtp0 = 0.0;
1163         if (!model->BSIM4v7wdvtp1Given)
1164             model->BSIM4v7wdvtp1 = 0.0;
1165         if (!model->BSIM4v7wdvtp2Given)        /* New DIBL/Rout */
1166             model->BSIM4v7wdvtp2 = 0.0;
1167         if (!model->BSIM4v7wdvtp3Given)
1168             model->BSIM4v7wdvtp3 = 0.0;
1169         if (!model->BSIM4v7wdvtp4Given)
1170             model->BSIM4v7wdvtp4 = 0.0;
1171         if (!model->BSIM4v7wdvtp5Given)
1172             model->BSIM4v7wdvtp5 = 0.0;
1173         if (!model->BSIM4v7wdvt0Given)
1174             model->BSIM4v7wdvt0 = 0.0;
1175         if (!model->BSIM4v7wdvt1Given)
1176             model->BSIM4v7wdvt1 = 0.0;
1177         if (!model->BSIM4v7wdvt2Given)
1178             model->BSIM4v7wdvt2 = 0.0;
1179         if (!model->BSIM4v7wdvt0wGiven)
1180             model->BSIM4v7wdvt0w = 0.0;
1181         if (!model->BSIM4v7wdvt1wGiven)
1182             model->BSIM4v7wdvt1w = 0.0;
1183         if (!model->BSIM4v7wdvt2wGiven)
1184             model->BSIM4v7wdvt2w = 0.0;
1185         if (!model->BSIM4v7wdroutGiven)
1186             model->BSIM4v7wdrout = 0.0;
1187         if (!model->BSIM4v7wdsubGiven)
1188             model->BSIM4v7wdsub = 0.0;
1189         if (!model->BSIM4v7wvth0Given)
1190            model->BSIM4v7wvth0 = 0.0;
1191         if (!model->BSIM4v7wuaGiven)
1192             model->BSIM4v7wua = 0.0;
1193         if (!model->BSIM4v7wua1Given)
1194             model->BSIM4v7wua1 = 0.0;
1195         if (!model->BSIM4v7wubGiven)
1196             model->BSIM4v7wub = 0.0;
1197         if (!model->BSIM4v7wub1Given)
1198             model->BSIM4v7wub1 = 0.0;
1199         if (!model->BSIM4v7wucGiven)
1200             model->BSIM4v7wuc = 0.0;
1201         if (!model->BSIM4v7wuc1Given)
1202             model->BSIM4v7wuc1 = 0.0;
1203         if (!model->BSIM4v7wudGiven)
1204             model->BSIM4v7wud = 0.0;
1205         if (!model->BSIM4v7wud1Given)
1206             model->BSIM4v7wud1 = 0.0;
1207         if (!model->BSIM4v7wupGiven)
1208             model->BSIM4v7wup = 0.0;
1209         if (!model->BSIM4v7wlpGiven)
1210             model->BSIM4v7wlp = 0.0;
1211         if (!model->BSIM4v7wu0Given)
1212             model->BSIM4v7wu0 = 0.0;
1213         if (!model->BSIM4v7wuteGiven)
1214                 model->BSIM4v7wute = 0.0;
1215         if (!model->BSIM4v7wucsteGiven)
1216                 model->BSIM4v7wucste = 0.0;
1217         if (!model->BSIM4v7wvoffGiven)
1218                 model->BSIM4v7wvoff = 0.0;
1219         if (!model->BSIM4v7wminvGiven)
1220             model->BSIM4v7wminv = 0.0;
1221         if (!model->BSIM4v7wminvcvGiven)
1222             model->BSIM4v7wminvcv = 0.0;
1223         if (!model->BSIM4v7wfproutGiven)
1224             model->BSIM4v7wfprout = 0.0;
1225         if (!model->BSIM4v7wpditsGiven)
1226             model->BSIM4v7wpdits = 0.0;
1227         if (!model->BSIM4v7wpditsdGiven)
1228             model->BSIM4v7wpditsd = 0.0;
1229         if (!model->BSIM4v7wdeltaGiven)
1230             model->BSIM4v7wdelta = 0.0;
1231         if (!model->BSIM4v7wrdswGiven)
1232             model->BSIM4v7wrdsw = 0.0;
1233         if (!model->BSIM4v7wrdwGiven)
1234             model->BSIM4v7wrdw = 0.0;
1235         if (!model->BSIM4v7wrswGiven)
1236             model->BSIM4v7wrsw = 0.0;
1237         if (!model->BSIM4v7wprwbGiven)
1238             model->BSIM4v7wprwb = 0.0;
1239         if (!model->BSIM4v7wprwgGiven)
1240             model->BSIM4v7wprwg = 0.0;
1241         if (!model->BSIM4v7wprtGiven)
1242             model->BSIM4v7wprt = 0.0;
1243         if (!model->BSIM4v7weta0Given)
1244             model->BSIM4v7weta0 = 0.0;
1245         if (!model->BSIM4v7wetabGiven)
1246             model->BSIM4v7wetab = 0.0;
1247         if (!model->BSIM4v7wpclmGiven)
1248             model->BSIM4v7wpclm = 0.0;
1249         if (!model->BSIM4v7wpdibl1Given)
1250             model->BSIM4v7wpdibl1 = 0.0;
1251         if (!model->BSIM4v7wpdibl2Given)
1252             model->BSIM4v7wpdibl2 = 0.0;
1253         if (!model->BSIM4v7wpdiblbGiven)
1254             model->BSIM4v7wpdiblb = 0.0;
1255         if (!model->BSIM4v7wpscbe1Given)
1256             model->BSIM4v7wpscbe1 = 0.0;
1257         if (!model->BSIM4v7wpscbe2Given)
1258             model->BSIM4v7wpscbe2 = 0.0;
1259         if (!model->BSIM4v7wpvagGiven)
1260             model->BSIM4v7wpvag = 0.0;
1261         if (!model->BSIM4v7wwrGiven)
1262             model->BSIM4v7wwr = 0.0;
1263         if (!model->BSIM4v7wdwgGiven)
1264             model->BSIM4v7wdwg = 0.0;
1265         if (!model->BSIM4v7wdwbGiven)
1266             model->BSIM4v7wdwb = 0.0;
1267         if (!model->BSIM4v7wb0Given)
1268             model->BSIM4v7wb0 = 0.0;
1269         if (!model->BSIM4v7wb1Given)
1270             model->BSIM4v7wb1 = 0.0;
1271         if (!model->BSIM4v7walpha0Given)
1272             model->BSIM4v7walpha0 = 0.0;
1273         if (!model->BSIM4v7walpha1Given)
1274             model->BSIM4v7walpha1 = 0.0;
1275         if (!model->BSIM4v7wbeta0Given)
1276             model->BSIM4v7wbeta0 = 0.0;
1277         if (!model->BSIM4v7wagidlGiven)
1278             model->BSIM4v7wagidl = 0.0;
1279         if (!model->BSIM4v7wbgidlGiven)
1280             model->BSIM4v7wbgidl = 0.0;
1281         if (!model->BSIM4v7wcgidlGiven)
1282             model->BSIM4v7wcgidl = 0.0;
1283         if (!model->BSIM4v7wegidlGiven)
1284             model->BSIM4v7wegidl = 0.0;
1285         if (!model->BSIM4v7wrgidlGiven)        /* v4.7 New GIDL/GISL */
1286             model->BSIM4v7wrgidl = 0.0;
1287         if (!model->BSIM4v7wkgidlGiven)        /* v4.7 New GIDL/GISL */
1288             model->BSIM4v7wkgidl = 0.0;
1289         if (!model->BSIM4v7wfgidlGiven)        /* v4.7 New GIDL/GISL */
1290             model->BSIM4v7wfgidl = 0.0;
1291 
1292         if (!model->BSIM4v7wagislGiven)
1293         {
1294             if (model->BSIM4v7wagidlGiven)
1295                 model->BSIM4v7wagisl = model->BSIM4v7wagidl;
1296             else
1297                 model->BSIM4v7wagisl = 0.0;
1298         }
1299         if (!model->BSIM4v7wbgislGiven)
1300         {
1301             if (model->BSIM4v7wbgidlGiven)
1302                 model->BSIM4v7wbgisl = model->BSIM4v7wbgidl;
1303             else
1304                 model->BSIM4v7wbgisl = 0.0;
1305         }
1306         if (!model->BSIM4v7wcgislGiven)
1307         {
1308             if (model->BSIM4v7wcgidlGiven)
1309                 model->BSIM4v7wcgisl = model->BSIM4v7wcgidl;
1310             else
1311                 model->BSIM4v7wcgisl = 0.0;
1312         }
1313         if (!model->BSIM4v7wegislGiven)
1314         {
1315             if (model->BSIM4v7wegidlGiven)
1316                 model->BSIM4v7wegisl = model->BSIM4v7wegidl;
1317             else
1318                 model->BSIM4v7wegisl = 0.0;
1319         }
1320         if (!model->BSIM4v7wrgislGiven)         /* v4.7 New GIDL/GISL */
1321         {
1322             if (model->BSIM4v7wrgidlGiven)
1323                 model->BSIM4v7wrgisl = model->BSIM4v7wrgidl;
1324         }
1325         if (!model->BSIM4v7wkgislGiven)        /* v4.7 New GIDL/GISL */
1326         {
1327             if (model->BSIM4v7wkgidlGiven)
1328                 model->BSIM4v7wkgisl = model->BSIM4v7wkgidl;
1329         }
1330         if (!model->BSIM4v7wfgislGiven)        /* v4.7 New GIDL/GISL */
1331         {
1332             if (model->BSIM4v7wfgidlGiven)
1333                 model->BSIM4v7wfgisl = model->BSIM4v7wfgidl;
1334         }
1335         if (!model->BSIM4v7waigcGiven)
1336             model->BSIM4v7waigc = 0.0;
1337         if (!model->BSIM4v7wbigcGiven)
1338             model->BSIM4v7wbigc = 0.0;
1339         if (!model->BSIM4v7wcigcGiven)
1340             model->BSIM4v7wcigc = 0.0;
1341         if (!model->BSIM4v7aigsdGiven && (model->BSIM4v7aigsGiven || model->BSIM4v7aigdGiven))
1342         {
1343             if (!model->BSIM4v7waigsGiven)
1344                 model->BSIM4v7waigs = 0.0;
1345             if (!model->BSIM4v7waigdGiven)
1346                 model->BSIM4v7waigd = 0.0;
1347         }
1348         else
1349         {
1350            if (!model->BSIM4v7waigsdGiven)
1351                model->BSIM4v7waigsd = 0.0;
1352            model->BSIM4v7waigs = model->BSIM4v7waigd = model->BSIM4v7waigsd;
1353         }
1354         if (!model->BSIM4v7bigsdGiven && (model->BSIM4v7bigsGiven || model->BSIM4v7bigdGiven))
1355         {
1356             if (!model->BSIM4v7wbigsGiven)
1357                 model->BSIM4v7wbigs = 0.0;
1358             if (!model->BSIM4v7wbigdGiven)
1359                 model->BSIM4v7wbigd = 0.0;
1360         }
1361         else
1362         {
1363            if (!model->BSIM4v7wbigsdGiven)
1364                model->BSIM4v7wbigsd = 0.0;
1365            model->BSIM4v7wbigs = model->BSIM4v7wbigd = model->BSIM4v7wbigsd;
1366         }
1367         if (!model->BSIM4v7cigsdGiven && (model->BSIM4v7cigsGiven || model->BSIM4v7cigdGiven))
1368         {
1369             if (!model->BSIM4v7wcigsGiven)
1370                 model->BSIM4v7wcigs = 0.0;
1371             if (!model->BSIM4v7wcigdGiven)
1372                 model->BSIM4v7wcigd = 0.0;
1373         }
1374         else
1375         {
1376            if (!model->BSIM4v7wcigsdGiven)
1377                model->BSIM4v7wcigsd = 0.0;
1378            model->BSIM4v7wcigs = model->BSIM4v7wcigd = model->BSIM4v7wcigsd;
1379         }
1380         if (!model->BSIM4v7waigbaccGiven)
1381             model->BSIM4v7waigbacc = 0.0;
1382         if (!model->BSIM4v7wbigbaccGiven)
1383             model->BSIM4v7wbigbacc = 0.0;
1384         if (!model->BSIM4v7wcigbaccGiven)
1385             model->BSIM4v7wcigbacc = 0.0;
1386         if (!model->BSIM4v7waigbinvGiven)
1387             model->BSIM4v7waigbinv = 0.0;
1388         if (!model->BSIM4v7wbigbinvGiven)
1389             model->BSIM4v7wbigbinv = 0.0;
1390         if (!model->BSIM4v7wcigbinvGiven)
1391             model->BSIM4v7wcigbinv = 0.0;
1392         if (!model->BSIM4v7wnigcGiven)
1393             model->BSIM4v7wnigc = 0.0;
1394         if (!model->BSIM4v7wnigbinvGiven)
1395             model->BSIM4v7wnigbinv = 0.0;
1396         if (!model->BSIM4v7wnigbaccGiven)
1397             model->BSIM4v7wnigbacc = 0.0;
1398         if (!model->BSIM4v7wntoxGiven)
1399             model->BSIM4v7wntox = 0.0;
1400         if (!model->BSIM4v7weigbinvGiven)
1401             model->BSIM4v7weigbinv = 0.0;
1402         if (!model->BSIM4v7wpigcdGiven)
1403             model->BSIM4v7wpigcd = 0.0;
1404         if (!model->BSIM4v7wpoxedgeGiven)
1405             model->BSIM4v7wpoxedge = 0.0;
1406         if (!model->BSIM4v7wxrcrg1Given)
1407             model->BSIM4v7wxrcrg1 = 0.0;
1408         if (!model->BSIM4v7wxrcrg2Given)
1409             model->BSIM4v7wxrcrg2 = 0.0;
1410         if (!model->BSIM4v7weuGiven)
1411             model->BSIM4v7weu = 0.0;
1412         if (!model->BSIM4v7wucsGiven)
1413             model->BSIM4v7wucs = 0.0;
1414         if (!model->BSIM4v7wvfbGiven)
1415             model->BSIM4v7wvfb = 0.0;
1416         if (!model->BSIM4v7wlambdaGiven)
1417             model->BSIM4v7wlambda = 0.0;
1418         if (!model->BSIM4v7wvtlGiven)
1419             model->BSIM4v7wvtl = 0.0;
1420         if (!model->BSIM4v7wxnGiven)
1421             model->BSIM4v7wxn = 0.0;
1422         if (!model->BSIM4v7wvfbsdoffGiven)
1423             model->BSIM4v7wvfbsdoff = 0.0;
1424         if (!model->BSIM4v7wtvfbsdoffGiven)
1425             model->BSIM4v7wtvfbsdoff = 0.0;
1426         if (!model->BSIM4v7wtvoffGiven)
1427             model->BSIM4v7wtvoff = 0.0;
1428         if (!model->BSIM4v7wtnfactorGiven)         /* v4.7 temp dep of leakage current  */
1429             model->BSIM4v7wtnfactor = 0.0;
1430         if (!model->BSIM4v7wteta0Given)                /* v4.7 temp dep of leakage current  */
1431             model->BSIM4v7wteta0 = 0.0;
1432         if (!model->BSIM4v7wtvoffcvGiven)                /* v4.7 temp dep of leakage current  */
1433             model->BSIM4v7wtvoffcv = 0.0;
1434 
1435         if (!model->BSIM4v7wcgslGiven)
1436             model->BSIM4v7wcgsl = 0.0;
1437         if (!model->BSIM4v7wcgdlGiven)
1438             model->BSIM4v7wcgdl = 0.0;
1439         if (!model->BSIM4v7wckappasGiven)
1440             model->BSIM4v7wckappas = 0.0;
1441         if (!model->BSIM4v7wckappadGiven)
1442             model->BSIM4v7wckappad = 0.0;
1443         if (!model->BSIM4v7wcfGiven)
1444             model->BSIM4v7wcf = 0.0;
1445         if (!model->BSIM4v7wclcGiven)
1446             model->BSIM4v7wclc = 0.0;
1447         if (!model->BSIM4v7wcleGiven)
1448             model->BSIM4v7wcle = 0.0;
1449         if (!model->BSIM4v7wvfbcvGiven)
1450             model->BSIM4v7wvfbcv = 0.0;
1451         if (!model->BSIM4v7wacdeGiven)
1452             model->BSIM4v7wacde = 0.0;
1453         if (!model->BSIM4v7wmoinGiven)
1454             model->BSIM4v7wmoin = 0.0;
1455         if (!model->BSIM4v7wnoffGiven)
1456             model->BSIM4v7wnoff = 0.0;
1457         if (!model->BSIM4v7wvoffcvGiven)
1458             model->BSIM4v7wvoffcv = 0.0;
1459 
1460         /* Cross-term dependence */
1461         if (!model->BSIM4v7pcdscGiven)
1462             model->BSIM4v7pcdsc = 0.0;
1463         if (!model->BSIM4v7pcdscbGiven)
1464             model->BSIM4v7pcdscb = 0.0;
1465         if (!model->BSIM4v7pcdscdGiven)
1466             model->BSIM4v7pcdscd = 0.0;
1467         if (!model->BSIM4v7pcitGiven)
1468             model->BSIM4v7pcit = 0.0;
1469         if (!model->BSIM4v7pnfactorGiven)
1470             model->BSIM4v7pnfactor = 0.0;
1471         if (!model->BSIM4v7pxjGiven)
1472             model->BSIM4v7pxj = 0.0;
1473         if (!model->BSIM4v7pvsatGiven)
1474             model->BSIM4v7pvsat = 0.0;
1475         if (!model->BSIM4v7patGiven)
1476             model->BSIM4v7pat = 0.0;
1477         if (!model->BSIM4v7pa0Given)
1478             model->BSIM4v7pa0 = 0.0;
1479 
1480         if (!model->BSIM4v7pagsGiven)
1481             model->BSIM4v7pags = 0.0;
1482         if (!model->BSIM4v7pa1Given)
1483             model->BSIM4v7pa1 = 0.0;
1484         if (!model->BSIM4v7pa2Given)
1485             model->BSIM4v7pa2 = 0.0;
1486         if (!model->BSIM4v7pketaGiven)
1487             model->BSIM4v7pketa = 0.0;
1488         if (!model->BSIM4v7pnsubGiven)
1489             model->BSIM4v7pnsub = 0.0;
1490         if (!model->BSIM4v7pndepGiven)
1491             model->BSIM4v7pndep = 0.0;
1492         if (!model->BSIM4v7pnsdGiven)
1493             model->BSIM4v7pnsd = 0.0;
1494         if (!model->BSIM4v7pphinGiven)
1495             model->BSIM4v7pphin = 0.0;
1496         if (!model->BSIM4v7pngateGiven)
1497             model->BSIM4v7pngate = 0.0;
1498         if (!model->BSIM4v7pvbmGiven)
1499             model->BSIM4v7pvbm = 0.0;
1500         if (!model->BSIM4v7pxtGiven)
1501             model->BSIM4v7pxt = 0.0;
1502         if (!model->BSIM4v7pkt1Given)
1503             model->BSIM4v7pkt1 = 0.0;
1504         if (!model->BSIM4v7pkt1lGiven)
1505             model->BSIM4v7pkt1l = 0.0;
1506         if (!model->BSIM4v7pkt2Given)
1507             model->BSIM4v7pkt2 = 0.0;
1508         if (!model->BSIM4v7pk3Given)
1509             model->BSIM4v7pk3 = 0.0;
1510         if (!model->BSIM4v7pk3bGiven)
1511             model->BSIM4v7pk3b = 0.0;
1512         if (!model->BSIM4v7pw0Given)
1513             model->BSIM4v7pw0 = 0.0;
1514         if (!model->BSIM4v7plpe0Given)
1515             model->BSIM4v7plpe0 = 0.0;
1516         if (!model->BSIM4v7plpebGiven)
1517             model->BSIM4v7plpeb = 0.0;
1518         if (!model->BSIM4v7pdvtp0Given)
1519             model->BSIM4v7pdvtp0 = 0.0;
1520         if (!model->BSIM4v7pdvtp1Given)
1521             model->BSIM4v7pdvtp1 = 0.0;
1522         if (!model->BSIM4v7pdvtp2Given)        /* New DIBL/Rout */
1523             model->BSIM4v7pdvtp2 = 0.0;
1524         if (!model->BSIM4v7pdvtp3Given)
1525             model->BSIM4v7pdvtp3 = 0.0;
1526         if (!model->BSIM4v7pdvtp4Given)
1527             model->BSIM4v7pdvtp4 = 0.0;
1528         if (!model->BSIM4v7pdvtp5Given)
1529             model->BSIM4v7pdvtp5 = 0.0;
1530         if (!model->BSIM4v7pdvt0Given)
1531             model->BSIM4v7pdvt0 = 0.0;
1532         if (!model->BSIM4v7pdvt1Given)
1533             model->BSIM4v7pdvt1 = 0.0;
1534         if (!model->BSIM4v7pdvt2Given)
1535             model->BSIM4v7pdvt2 = 0.0;
1536         if (!model->BSIM4v7pdvt0wGiven)
1537             model->BSIM4v7pdvt0w = 0.0;
1538         if (!model->BSIM4v7pdvt1wGiven)
1539             model->BSIM4v7pdvt1w = 0.0;
1540         if (!model->BSIM4v7pdvt2wGiven)
1541             model->BSIM4v7pdvt2w = 0.0;
1542         if (!model->BSIM4v7pdroutGiven)
1543             model->BSIM4v7pdrout = 0.0;
1544         if (!model->BSIM4v7pdsubGiven)
1545             model->BSIM4v7pdsub = 0.0;
1546         if (!model->BSIM4v7pvth0Given)
1547            model->BSIM4v7pvth0 = 0.0;
1548         if (!model->BSIM4v7puaGiven)
1549             model->BSIM4v7pua = 0.0;
1550         if (!model->BSIM4v7pua1Given)
1551             model->BSIM4v7pua1 = 0.0;
1552         if (!model->BSIM4v7pubGiven)
1553             model->BSIM4v7pub = 0.0;
1554         if (!model->BSIM4v7pub1Given)
1555             model->BSIM4v7pub1 = 0.0;
1556         if (!model->BSIM4v7pucGiven)
1557             model->BSIM4v7puc = 0.0;
1558         if (!model->BSIM4v7puc1Given)
1559             model->BSIM4v7puc1 = 0.0;
1560         if (!model->BSIM4v7pudGiven)
1561             model->BSIM4v7pud = 0.0;
1562         if (!model->BSIM4v7pud1Given)
1563             model->BSIM4v7pud1 = 0.0;
1564         if (!model->BSIM4v7pupGiven)
1565             model->BSIM4v7pup = 0.0;
1566         if (!model->BSIM4v7plpGiven)
1567             model->BSIM4v7plp = 0.0;
1568         if (!model->BSIM4v7pu0Given)
1569             model->BSIM4v7pu0 = 0.0;
1570         if (!model->BSIM4v7puteGiven)
1571             model->BSIM4v7pute = 0.0;
1572      if (!model->BSIM4v7pucsteGiven)
1573             model->BSIM4v7pucste = 0.0;
1574         if (!model->BSIM4v7pvoffGiven)
1575             model->BSIM4v7pvoff = 0.0;
1576         if (!model->BSIM4v7pminvGiven)
1577             model->BSIM4v7pminv = 0.0;
1578         if (!model->BSIM4v7pminvcvGiven)
1579             model->BSIM4v7pminvcv = 0.0;
1580         if (!model->BSIM4v7pfproutGiven)
1581             model->BSIM4v7pfprout = 0.0;
1582         if (!model->BSIM4v7ppditsGiven)
1583             model->BSIM4v7ppdits = 0.0;
1584         if (!model->BSIM4v7ppditsdGiven)
1585             model->BSIM4v7ppditsd = 0.0;
1586         if (!model->BSIM4v7pdeltaGiven)
1587             model->BSIM4v7pdelta = 0.0;
1588         if (!model->BSIM4v7prdswGiven)
1589             model->BSIM4v7prdsw = 0.0;
1590         if (!model->BSIM4v7prdwGiven)
1591             model->BSIM4v7prdw = 0.0;
1592         if (!model->BSIM4v7prswGiven)
1593             model->BSIM4v7prsw = 0.0;
1594         if (!model->BSIM4v7pprwbGiven)
1595             model->BSIM4v7pprwb = 0.0;
1596         if (!model->BSIM4v7pprwgGiven)
1597             model->BSIM4v7pprwg = 0.0;
1598         if (!model->BSIM4v7pprtGiven)
1599             model->BSIM4v7pprt = 0.0;
1600         if (!model->BSIM4v7peta0Given)
1601             model->BSIM4v7peta0 = 0.0;
1602         if (!model->BSIM4v7petabGiven)
1603             model->BSIM4v7petab = 0.0;
1604         if (!model->BSIM4v7ppclmGiven)
1605             model->BSIM4v7ppclm = 0.0;
1606         if (!model->BSIM4v7ppdibl1Given)
1607             model->BSIM4v7ppdibl1 = 0.0;
1608         if (!model->BSIM4v7ppdibl2Given)
1609             model->BSIM4v7ppdibl2 = 0.0;
1610         if (!model->BSIM4v7ppdiblbGiven)
1611             model->BSIM4v7ppdiblb = 0.0;
1612         if (!model->BSIM4v7ppscbe1Given)
1613             model->BSIM4v7ppscbe1 = 0.0;
1614         if (!model->BSIM4v7ppscbe2Given)
1615             model->BSIM4v7ppscbe2 = 0.0;
1616         if (!model->BSIM4v7ppvagGiven)
1617             model->BSIM4v7ppvag = 0.0;
1618         if (!model->BSIM4v7pwrGiven)
1619             model->BSIM4v7pwr = 0.0;
1620         if (!model->BSIM4v7pdwgGiven)
1621             model->BSIM4v7pdwg = 0.0;
1622         if (!model->BSIM4v7pdwbGiven)
1623             model->BSIM4v7pdwb = 0.0;
1624         if (!model->BSIM4v7pb0Given)
1625             model->BSIM4v7pb0 = 0.0;
1626         if (!model->BSIM4v7pb1Given)
1627             model->BSIM4v7pb1 = 0.0;
1628         if (!model->BSIM4v7palpha0Given)
1629             model->BSIM4v7palpha0 = 0.0;
1630         if (!model->BSIM4v7palpha1Given)
1631             model->BSIM4v7palpha1 = 0.0;
1632         if (!model->BSIM4v7pbeta0Given)
1633             model->BSIM4v7pbeta0 = 0.0;
1634         if (!model->BSIM4v7pagidlGiven)
1635             model->BSIM4v7pagidl = 0.0;
1636         if (!model->BSIM4v7pbgidlGiven)
1637             model->BSIM4v7pbgidl = 0.0;
1638         if (!model->BSIM4v7pcgidlGiven)
1639             model->BSIM4v7pcgidl = 0.0;
1640         if (!model->BSIM4v7pegidlGiven)
1641             model->BSIM4v7pegidl = 0.0;
1642         if (!model->BSIM4v7prgidlGiven)        /* v4.7 New GIDL/GISL */
1643             model->BSIM4v7prgidl = 0.0;
1644         if (!model->BSIM4v7pkgidlGiven)        /* v4.7 New GIDL/GISL */
1645             model->BSIM4v7pkgidl = 0.0;
1646         if (!model->BSIM4v7pfgidlGiven)        /* v4.7 New GIDL/GISL */
1647             model->BSIM4v7pfgidl = 0.0;
1648 
1649         if (!model->BSIM4v7pagislGiven)
1650         {
1651             if (model->BSIM4v7pagidlGiven)
1652                 model->BSIM4v7pagisl = model->BSIM4v7pagidl;
1653             else
1654                 model->BSIM4v7pagisl = 0.0;
1655         }
1656         if (!model->BSIM4v7pbgislGiven)
1657         {
1658             if (model->BSIM4v7pbgidlGiven)
1659                 model->BSIM4v7pbgisl = model->BSIM4v7pbgidl;
1660             else
1661                 model->BSIM4v7pbgisl = 0.0;
1662         }
1663         if (!model->BSIM4v7pcgislGiven)
1664         {
1665             if (model->BSIM4v7pcgidlGiven)
1666                 model->BSIM4v7pcgisl = model->BSIM4v7pcgidl;
1667             else
1668                 model->BSIM4v7pcgisl = 0.0;
1669         }
1670         if (!model->BSIM4v7pegislGiven)
1671         {
1672             if (model->BSIM4v7pegidlGiven)
1673                 model->BSIM4v7pegisl = model->BSIM4v7pegidl;
1674             else
1675                 model->BSIM4v7pegisl = 0.0;
1676         }
1677         if (!model->BSIM4v7prgislGiven)         /* v4.7 New GIDL/GISL */
1678         {
1679             if (model->BSIM4v7prgidlGiven)
1680                 model->BSIM4v7prgisl = model->BSIM4v7prgidl;
1681         }
1682         if (!model->BSIM4v7pkgislGiven)        /* v4.7 New GIDL/GISL */
1683         {
1684             if (model->BSIM4v7pkgidlGiven)
1685                 model->BSIM4v7pkgisl = model->BSIM4v7pkgidl;
1686         }
1687         if (!model->BSIM4v7pfgislGiven)        /* v4.7 New GIDL/GISL */
1688         {
1689             if (model->BSIM4v7pfgidlGiven)
1690                 model->BSIM4v7pfgisl = model->BSIM4v7pfgidl;
1691         }
1692         if (!model->BSIM4v7paigcGiven)
1693             model->BSIM4v7paigc = 0.0;
1694         if (!model->BSIM4v7pbigcGiven)
1695             model->BSIM4v7pbigc = 0.0;
1696         if (!model->BSIM4v7pcigcGiven)
1697             model->BSIM4v7pcigc = 0.0;
1698         if (!model->BSIM4v7aigsdGiven && (model->BSIM4v7aigsGiven || model->BSIM4v7aigdGiven))
1699         {
1700             if (!model->BSIM4v7paigsGiven)
1701                 model->BSIM4v7paigs = 0.0;
1702             if (!model->BSIM4v7paigdGiven)
1703                 model->BSIM4v7paigd = 0.0;
1704         }
1705         else
1706         {
1707            if (!model->BSIM4v7paigsdGiven)
1708                model->BSIM4v7paigsd = 0.0;
1709            model->BSIM4v7paigs = model->BSIM4v7paigd = model->BSIM4v7paigsd;
1710         }
1711         if (!model->BSIM4v7bigsdGiven && (model->BSIM4v7bigsGiven || model->BSIM4v7bigdGiven))
1712         {
1713             if (!model->BSIM4v7pbigsGiven)
1714                 model->BSIM4v7pbigs = 0.0;
1715             if (!model->BSIM4v7pbigdGiven)
1716                 model->BSIM4v7pbigd = 0.0;
1717         }
1718         else
1719         {
1720            if (!model->BSIM4v7pbigsdGiven)
1721                model->BSIM4v7pbigsd = 0.0;
1722            model->BSIM4v7pbigs = model->BSIM4v7pbigd = model->BSIM4v7pbigsd;
1723         }
1724         if (!model->BSIM4v7cigsdGiven && (model->BSIM4v7cigsGiven || model->BSIM4v7cigdGiven))
1725         {
1726             if (!model->BSIM4v7pcigsGiven)
1727                 model->BSIM4v7pcigs = 0.0;
1728             if (!model->BSIM4v7pcigdGiven)
1729                 model->BSIM4v7pcigd = 0.0;
1730         }
1731         else
1732         {
1733            if (!model->BSIM4v7pcigsdGiven)
1734                model->BSIM4v7pcigsd = 0.0;
1735            model->BSIM4v7pcigs = model->BSIM4v7pcigd = model->BSIM4v7pcigsd;
1736         }
1737         if (!model->BSIM4v7paigbaccGiven)
1738             model->BSIM4v7paigbacc = 0.0;
1739         if (!model->BSIM4v7pbigbaccGiven)
1740             model->BSIM4v7pbigbacc = 0.0;
1741         if (!model->BSIM4v7pcigbaccGiven)
1742             model->BSIM4v7pcigbacc = 0.0;
1743         if (!model->BSIM4v7paigbinvGiven)
1744             model->BSIM4v7paigbinv = 0.0;
1745         if (!model->BSIM4v7pbigbinvGiven)
1746             model->BSIM4v7pbigbinv = 0.0;
1747         if (!model->BSIM4v7pcigbinvGiven)
1748             model->BSIM4v7pcigbinv = 0.0;
1749         if (!model->BSIM4v7pnigcGiven)
1750             model->BSIM4v7pnigc = 0.0;
1751         if (!model->BSIM4v7pnigbinvGiven)
1752             model->BSIM4v7pnigbinv = 0.0;
1753         if (!model->BSIM4v7pnigbaccGiven)
1754             model->BSIM4v7pnigbacc = 0.0;
1755         if (!model->BSIM4v7pntoxGiven)
1756             model->BSIM4v7pntox = 0.0;
1757         if (!model->BSIM4v7peigbinvGiven)
1758             model->BSIM4v7peigbinv = 0.0;
1759         if (!model->BSIM4v7ppigcdGiven)
1760             model->BSIM4v7ppigcd = 0.0;
1761         if (!model->BSIM4v7ppoxedgeGiven)
1762             model->BSIM4v7ppoxedge = 0.0;
1763         if (!model->BSIM4v7pxrcrg1Given)
1764             model->BSIM4v7pxrcrg1 = 0.0;
1765         if (!model->BSIM4v7pxrcrg2Given)
1766             model->BSIM4v7pxrcrg2 = 0.0;
1767         if (!model->BSIM4v7peuGiven)
1768             model->BSIM4v7peu = 0.0;
1769                 if (!model->BSIM4v7pucsGiven)
1770             model->BSIM4v7pucs = 0.0;
1771         if (!model->BSIM4v7pvfbGiven)
1772             model->BSIM4v7pvfb = 0.0;
1773         if (!model->BSIM4v7plambdaGiven)
1774             model->BSIM4v7plambda = 0.0;
1775         if (!model->BSIM4v7pvtlGiven)
1776             model->BSIM4v7pvtl = 0.0;
1777         if (!model->BSIM4v7pxnGiven)
1778             model->BSIM4v7pxn = 0.0;
1779         if (!model->BSIM4v7pvfbsdoffGiven)
1780             model->BSIM4v7pvfbsdoff = 0.0;
1781         if (!model->BSIM4v7ptvfbsdoffGiven)
1782             model->BSIM4v7ptvfbsdoff = 0.0;
1783         if (!model->BSIM4v7ptvoffGiven)
1784             model->BSIM4v7ptvoff = 0.0;
1785         if (!model->BSIM4v7ptnfactorGiven)         /* v4.7 temp dep of leakage current  */
1786             model->BSIM4v7ptnfactor = 0.0;
1787         if (!model->BSIM4v7pteta0Given)                /* v4.7 temp dep of leakage current  */
1788             model->BSIM4v7pteta0 = 0.0;
1789         if (!model->BSIM4v7ptvoffcvGiven)                /* v4.7 temp dep of leakage current  */
1790             model->BSIM4v7ptvoffcv = 0.0;
1791 
1792         if (!model->BSIM4v7pcgslGiven)
1793             model->BSIM4v7pcgsl = 0.0;
1794         if (!model->BSIM4v7pcgdlGiven)
1795             model->BSIM4v7pcgdl = 0.0;
1796         if (!model->BSIM4v7pckappasGiven)
1797             model->BSIM4v7pckappas = 0.0;
1798         if (!model->BSIM4v7pckappadGiven)
1799             model->BSIM4v7pckappad = 0.0;
1800         if (!model->BSIM4v7pcfGiven)
1801             model->BSIM4v7pcf = 0.0;
1802         if (!model->BSIM4v7pclcGiven)
1803             model->BSIM4v7pclc = 0.0;
1804         if (!model->BSIM4v7pcleGiven)
1805             model->BSIM4v7pcle = 0.0;
1806         if (!model->BSIM4v7pvfbcvGiven)
1807             model->BSIM4v7pvfbcv = 0.0;
1808         if (!model->BSIM4v7pacdeGiven)
1809             model->BSIM4v7pacde = 0.0;
1810         if (!model->BSIM4v7pmoinGiven)
1811             model->BSIM4v7pmoin = 0.0;
1812         if (!model->BSIM4v7pnoffGiven)
1813             model->BSIM4v7pnoff = 0.0;
1814         if (!model->BSIM4v7pvoffcvGiven)
1815             model->BSIM4v7pvoffcv = 0.0;
1816 
1817         if (!model->BSIM4v7gamma1Given)
1818             model->BSIM4v7gamma1 = 0.0;
1819         if (!model->BSIM4v7lgamma1Given)
1820             model->BSIM4v7lgamma1 = 0.0;
1821         if (!model->BSIM4v7wgamma1Given)
1822             model->BSIM4v7wgamma1 = 0.0;
1823         if (!model->BSIM4v7pgamma1Given)
1824             model->BSIM4v7pgamma1 = 0.0;
1825         if (!model->BSIM4v7gamma2Given)
1826             model->BSIM4v7gamma2 = 0.0;
1827         if (!model->BSIM4v7lgamma2Given)
1828             model->BSIM4v7lgamma2 = 0.0;
1829         if (!model->BSIM4v7wgamma2Given)
1830             model->BSIM4v7wgamma2 = 0.0;
1831         if (!model->BSIM4v7pgamma2Given)
1832             model->BSIM4v7pgamma2 = 0.0;
1833         if (!model->BSIM4v7vbxGiven)
1834             model->BSIM4v7vbx = 0.0;
1835         if (!model->BSIM4v7lvbxGiven)
1836             model->BSIM4v7lvbx = 0.0;
1837         if (!model->BSIM4v7wvbxGiven)
1838             model->BSIM4v7wvbx = 0.0;
1839         if (!model->BSIM4v7pvbxGiven)
1840             model->BSIM4v7pvbx = 0.0;
1841 
1842         /* unit degree celcius */
1843         if (!model->BSIM4v7tnomGiven)
1844             model->BSIM4v7tnom = ckt->CKTnomTemp;
1845         if (!model->BSIM4v7LintGiven)
1846            model->BSIM4v7Lint = 0.0;
1847         if (!model->BSIM4v7LlGiven)
1848            model->BSIM4v7Ll = 0.0;
1849         if (!model->BSIM4v7LlcGiven)
1850            model->BSIM4v7Llc = model->BSIM4v7Ll;
1851         if (!model->BSIM4v7LlnGiven)
1852            model->BSIM4v7Lln = 1.0;
1853         if (!model->BSIM4v7LwGiven)
1854            model->BSIM4v7Lw = 0.0;
1855         if (!model->BSIM4v7LwcGiven)
1856            model->BSIM4v7Lwc = model->BSIM4v7Lw;
1857         if (!model->BSIM4v7LwnGiven)
1858            model->BSIM4v7Lwn = 1.0;
1859         if (!model->BSIM4v7LwlGiven)
1860            model->BSIM4v7Lwl = 0.0;
1861         if (!model->BSIM4v7LwlcGiven)
1862            model->BSIM4v7Lwlc = model->BSIM4v7Lwl;
1863         if (!model->BSIM4v7LminGiven)
1864            model->BSIM4v7Lmin = 0.0;
1865         if (!model->BSIM4v7LmaxGiven)
1866            model->BSIM4v7Lmax = 1.0;
1867         if (!model->BSIM4v7WintGiven)
1868            model->BSIM4v7Wint = 0.0;
1869         if (!model->BSIM4v7WlGiven)
1870            model->BSIM4v7Wl = 0.0;
1871         if (!model->BSIM4v7WlcGiven)
1872            model->BSIM4v7Wlc = model->BSIM4v7Wl;
1873         if (!model->BSIM4v7WlnGiven)
1874            model->BSIM4v7Wln = 1.0;
1875         if (!model->BSIM4v7WwGiven)
1876            model->BSIM4v7Ww = 0.0;
1877         if (!model->BSIM4v7WwcGiven)
1878            model->BSIM4v7Wwc = model->BSIM4v7Ww;
1879         if (!model->BSIM4v7WwnGiven)
1880            model->BSIM4v7Wwn = 1.0;
1881         if (!model->BSIM4v7WwlGiven)
1882            model->BSIM4v7Wwl = 0.0;
1883         if (!model->BSIM4v7WwlcGiven)
1884            model->BSIM4v7Wwlc = model->BSIM4v7Wwl;
1885         if (!model->BSIM4v7WminGiven)
1886            model->BSIM4v7Wmin = 0.0;
1887         if (!model->BSIM4v7WmaxGiven)
1888            model->BSIM4v7Wmax = 1.0;
1889         if (!model->BSIM4v7dwcGiven)
1890            model->BSIM4v7dwc = model->BSIM4v7Wint;
1891         if (!model->BSIM4v7dlcGiven)
1892            model->BSIM4v7dlc = model->BSIM4v7Lint;
1893         if (!model->BSIM4v7xlGiven)
1894            model->BSIM4v7xl = 0.0;
1895         if (!model->BSIM4v7xwGiven)
1896            model->BSIM4v7xw = 0.0;
1897         if (!model->BSIM4v7dlcigGiven)
1898            model->BSIM4v7dlcig = model->BSIM4v7Lint;
1899         if (!model->BSIM4v7dlcigdGiven)
1900         {
1901            if (model->BSIM4v7dlcigGiven)
1902                model->BSIM4v7dlcigd = model->BSIM4v7dlcig;
1903            else
1904                model->BSIM4v7dlcigd = model->BSIM4v7Lint;
1905         }
1906         if (!model->BSIM4v7dwjGiven)
1907            model->BSIM4v7dwj = model->BSIM4v7dwc;
1908         if (!model->BSIM4v7cfGiven)
1909            model->BSIM4v7cf = 2.0 * model->BSIM4v7epsrox * EPS0 / PI
1910                           * log(1.0 + 0.4e-6 / model->BSIM4v7toxe);
1911 
1912         if (!model->BSIM4v7xpartGiven)
1913             model->BSIM4v7xpart = 0.0;
1914         if (!model->BSIM4v7sheetResistanceGiven)
1915             model->BSIM4v7sheetResistance = 0.0;
1916 
1917         if (!model->BSIM4v7SunitAreaJctCapGiven)
1918             model->BSIM4v7SunitAreaJctCap = 5.0E-4;
1919         if (!model->BSIM4v7DunitAreaJctCapGiven)
1920             model->BSIM4v7DunitAreaJctCap = model->BSIM4v7SunitAreaJctCap;
1921         if (!model->BSIM4v7SunitLengthSidewallJctCapGiven)
1922             model->BSIM4v7SunitLengthSidewallJctCap = 5.0E-10;
1923         if (!model->BSIM4v7DunitLengthSidewallJctCapGiven)
1924             model->BSIM4v7DunitLengthSidewallJctCap = model->BSIM4v7SunitLengthSidewallJctCap;
1925         if (!model->BSIM4v7SunitLengthGateSidewallJctCapGiven)
1926             model->BSIM4v7SunitLengthGateSidewallJctCap = model->BSIM4v7SunitLengthSidewallJctCap ;
1927         if (!model->BSIM4v7DunitLengthGateSidewallJctCapGiven)
1928             model->BSIM4v7DunitLengthGateSidewallJctCap = model->BSIM4v7SunitLengthGateSidewallJctCap;
1929         if (!model->BSIM4v7SjctSatCurDensityGiven)
1930             model->BSIM4v7SjctSatCurDensity = 1.0E-4;
1931         if (!model->BSIM4v7DjctSatCurDensityGiven)
1932             model->BSIM4v7DjctSatCurDensity = model->BSIM4v7SjctSatCurDensity;
1933         if (!model->BSIM4v7SjctSidewallSatCurDensityGiven)
1934             model->BSIM4v7SjctSidewallSatCurDensity = 0.0;
1935         if (!model->BSIM4v7DjctSidewallSatCurDensityGiven)
1936             model->BSIM4v7DjctSidewallSatCurDensity = model->BSIM4v7SjctSidewallSatCurDensity;
1937         if (!model->BSIM4v7SjctGateSidewallSatCurDensityGiven)
1938             model->BSIM4v7SjctGateSidewallSatCurDensity = 0.0;
1939         if (!model->BSIM4v7DjctGateSidewallSatCurDensityGiven)
1940             model->BSIM4v7DjctGateSidewallSatCurDensity = model->BSIM4v7SjctGateSidewallSatCurDensity;
1941         if (!model->BSIM4v7SbulkJctPotentialGiven)
1942             model->BSIM4v7SbulkJctPotential = 1.0;
1943         if (!model->BSIM4v7DbulkJctPotentialGiven)
1944             model->BSIM4v7DbulkJctPotential = model->BSIM4v7SbulkJctPotential;
1945         if (!model->BSIM4v7SsidewallJctPotentialGiven)
1946             model->BSIM4v7SsidewallJctPotential = 1.0;
1947         if (!model->BSIM4v7DsidewallJctPotentialGiven)
1948             model->BSIM4v7DsidewallJctPotential = model->BSIM4v7SsidewallJctPotential;
1949         if (!model->BSIM4v7SGatesidewallJctPotentialGiven)
1950             model->BSIM4v7SGatesidewallJctPotential = model->BSIM4v7SsidewallJctPotential;
1951         if (!model->BSIM4v7DGatesidewallJctPotentialGiven)
1952             model->BSIM4v7DGatesidewallJctPotential = model->BSIM4v7SGatesidewallJctPotential;
1953         if (!model->BSIM4v7SbulkJctBotGradingCoeffGiven)
1954             model->BSIM4v7SbulkJctBotGradingCoeff = 0.5;
1955         if (!model->BSIM4v7DbulkJctBotGradingCoeffGiven)
1956             model->BSIM4v7DbulkJctBotGradingCoeff = model->BSIM4v7SbulkJctBotGradingCoeff;
1957         if (!model->BSIM4v7SbulkJctSideGradingCoeffGiven)
1958             model->BSIM4v7SbulkJctSideGradingCoeff = 0.33;
1959         if (!model->BSIM4v7DbulkJctSideGradingCoeffGiven)
1960             model->BSIM4v7DbulkJctSideGradingCoeff = model->BSIM4v7SbulkJctSideGradingCoeff;
1961         if (!model->BSIM4v7SbulkJctGateSideGradingCoeffGiven)
1962             model->BSIM4v7SbulkJctGateSideGradingCoeff = model->BSIM4v7SbulkJctSideGradingCoeff;
1963         if (!model->BSIM4v7DbulkJctGateSideGradingCoeffGiven)
1964             model->BSIM4v7DbulkJctGateSideGradingCoeff = model->BSIM4v7SbulkJctGateSideGradingCoeff;
1965         if (!model->BSIM4v7SjctEmissionCoeffGiven)
1966             model->BSIM4v7SjctEmissionCoeff = 1.0;
1967         if (!model->BSIM4v7DjctEmissionCoeffGiven)
1968             model->BSIM4v7DjctEmissionCoeff = model->BSIM4v7SjctEmissionCoeff;
1969         if (!model->BSIM4v7SjctTempExponentGiven)
1970             model->BSIM4v7SjctTempExponent = 3.0;
1971         if (!model->BSIM4v7DjctTempExponentGiven)
1972             model->BSIM4v7DjctTempExponent = model->BSIM4v7SjctTempExponent;
1973 
1974         if (!model->BSIM4v7jtssGiven)
1975             model->BSIM4v7jtss = 0.0;
1976         if (!model->BSIM4v7jtsdGiven)
1977             model->BSIM4v7jtsd = model->BSIM4v7jtss;
1978         if (!model->BSIM4v7jtsswsGiven)
1979             model->BSIM4v7jtssws = 0.0;
1980         if (!model->BSIM4v7jtsswdGiven)
1981             model->BSIM4v7jtsswd = model->BSIM4v7jtssws;
1982         if (!model->BSIM4v7jtsswgsGiven)
1983             model->BSIM4v7jtsswgs = 0.0;
1984         if (!model->BSIM4v7jtsswgdGiven)
1985             model->BSIM4v7jtsswgd = model->BSIM4v7jtsswgs;
1986                 if (!model->BSIM4v7jtweffGiven)
1987                     model->BSIM4v7jtweff = 0.0;
1988         if (!model->BSIM4v7njtsGiven)
1989             model->BSIM4v7njts = 20.0;
1990         if (!model->BSIM4v7njtsswGiven)
1991             model->BSIM4v7njtssw = 20.0;
1992         if (!model->BSIM4v7njtsswgGiven)
1993             model->BSIM4v7njtsswg = 20.0;
1994         if (!model->BSIM4v7njtsdGiven)
1995         {
1996             if (model->BSIM4v7njtsGiven)
1997                 model->BSIM4v7njtsd =  model->BSIM4v7njts;
1998             else
1999               model->BSIM4v7njtsd = 20.0;
2000         }
2001         if (!model->BSIM4v7njtsswdGiven)
2002         {
2003             if (model->BSIM4v7njtsswGiven)
2004                 model->BSIM4v7njtsswd =  model->BSIM4v7njtssw;
2005             else
2006               model->BSIM4v7njtsswd = 20.0;
2007         }
2008         if (!model->BSIM4v7njtsswgdGiven)
2009         {
2010             if (model->BSIM4v7njtsswgGiven)
2011                 model->BSIM4v7njtsswgd =  model->BSIM4v7njtsswg;
2012             else
2013               model->BSIM4v7njtsswgd = 20.0;
2014         }
2015         if (!model->BSIM4v7xtssGiven)
2016             model->BSIM4v7xtss = 0.02;
2017         if (!model->BSIM4v7xtsdGiven)
2018             model->BSIM4v7xtsd = model->BSIM4v7xtss;
2019         if (!model->BSIM4v7xtsswsGiven)
2020             model->BSIM4v7xtssws = 0.02;
2021         if (!model->BSIM4v7xtsswdGiven)
2022             model->BSIM4v7xtsswd = model->BSIM4v7xtssws;
2023         if (!model->BSIM4v7xtsswgsGiven)
2024             model->BSIM4v7xtsswgs = 0.02;
2025         if (!model->BSIM4v7xtsswgdGiven)
2026             model->BSIM4v7xtsswgd = model->BSIM4v7xtsswgs;
2027         if (!model->BSIM4v7tnjtsGiven)
2028             model->BSIM4v7tnjts = 0.0;
2029         if (!model->BSIM4v7tnjtsswGiven)
2030             model->BSIM4v7tnjtssw = 0.0;
2031         if (!model->BSIM4v7tnjtsswgGiven)
2032             model->BSIM4v7tnjtsswg = 0.0;
2033         if (!model->BSIM4v7tnjtsdGiven)
2034         {
2035             if (model->BSIM4v7tnjtsGiven)
2036                 model->BSIM4v7tnjtsd =  model->BSIM4v7tnjts;
2037             else
2038               model->BSIM4v7tnjtsd = 0.0;
2039         }
2040         if (!model->BSIM4v7tnjtsswdGiven)
2041         {
2042             if (model->BSIM4v7tnjtsswGiven)
2043                 model->BSIM4v7tnjtsswd =  model->BSIM4v7tnjtssw;
2044             else
2045               model->BSIM4v7tnjtsswd = 0.0;
2046         }
2047         if (!model->BSIM4v7tnjtsswgdGiven)
2048         {
2049             if (model->BSIM4v7tnjtsswgGiven)
2050                 model->BSIM4v7tnjtsswgd =  model->BSIM4v7tnjtsswg;
2051             else
2052               model->BSIM4v7tnjtsswgd = 0.0;
2053         }
2054         if (!model->BSIM4v7vtssGiven)
2055             model->BSIM4v7vtss = 10.0;
2056         if (!model->BSIM4v7vtsdGiven)
2057             model->BSIM4v7vtsd = model->BSIM4v7vtss;
2058         if (!model->BSIM4v7vtsswsGiven)
2059             model->BSIM4v7vtssws = 10.0;
2060         if (!model->BSIM4v7vtsswdGiven)
2061             model->BSIM4v7vtsswd = model->BSIM4v7vtssws;
2062         if (!model->BSIM4v7vtsswgsGiven)
2063             model->BSIM4v7vtsswgs = 10.0;
2064         if (!model->BSIM4v7vtsswgdGiven)
2065             model->BSIM4v7vtsswgd = model->BSIM4v7vtsswgs;
2066 
2067         if (!model->BSIM4v7oxideTrapDensityAGiven)
2068         {   if (model->BSIM4v7type == NMOS)
2069                 model->BSIM4v7oxideTrapDensityA = 6.25e41;
2070             else
2071                 model->BSIM4v7oxideTrapDensityA= 6.188e40;
2072         }
2073         if (!model->BSIM4v7oxideTrapDensityBGiven)
2074         {   if (model->BSIM4v7type == NMOS)
2075                 model->BSIM4v7oxideTrapDensityB = 3.125e26;
2076             else
2077                 model->BSIM4v7oxideTrapDensityB = 1.5e25;
2078         }
2079         if (!model->BSIM4v7oxideTrapDensityCGiven)
2080             model->BSIM4v7oxideTrapDensityC = 8.75e9;
2081         if (!model->BSIM4v7emGiven)
2082             model->BSIM4v7em = 4.1e7; /* V/m */
2083         if (!model->BSIM4v7efGiven)
2084             model->BSIM4v7ef = 1.0;
2085         if (!model->BSIM4v7afGiven)
2086             model->BSIM4v7af = 1.0;
2087         if (!model->BSIM4v7kfGiven)
2088             model->BSIM4v7kf = 0.0;
2089 
2090         if (!model->BSIM4v7vgsMaxGiven)
2091             model->BSIM4v7vgsMax = 1e99;
2092         if (!model->BSIM4v7vgdMaxGiven)
2093             model->BSIM4v7vgdMax = 1e99;
2094         if (!model->BSIM4v7vgbMaxGiven)
2095             model->BSIM4v7vgbMax = 1e99;
2096         if (!model->BSIM4v7vdsMaxGiven)
2097             model->BSIM4v7vdsMax = 1e99;
2098         if (!model->BSIM4v7vbsMaxGiven)
2099             model->BSIM4v7vbsMax = 1e99;
2100         if (!model->BSIM4v7vbdMaxGiven)
2101             model->BSIM4v7vbdMax = 1e99;
2102         if (!model->BSIM4v7vgsrMaxGiven)
2103             model->BSIM4v7vgsrMax = 1e99;
2104         if (!model->BSIM4v7vgdrMaxGiven)
2105             model->BSIM4v7vgdrMax = 1e99;
2106         if (!model->BSIM4v7vgbrMaxGiven)
2107             model->BSIM4v7vgbrMax = 1e99;
2108         if (!model->BSIM4v7vbsrMaxGiven)
2109             model->BSIM4v7vbsrMax = 1e99;
2110         if (!model->BSIM4v7vbdrMaxGiven)
2111             model->BSIM4v7vbdrMax = 1e99;
2112 
2113         /* stress effect */
2114         if (!model->BSIM4v7sarefGiven)
2115             model->BSIM4v7saref = 1e-6; /* m */
2116         if (!model->BSIM4v7sbrefGiven)
2117             model->BSIM4v7sbref = 1e-6;  /* m */
2118         if (!model->BSIM4v7wlodGiven)
2119             model->BSIM4v7wlod = 0;  /* m */
2120         if (!model->BSIM4v7ku0Given)
2121             model->BSIM4v7ku0 = 0; /* 1/m */
2122         if (!model->BSIM4v7kvsatGiven)
2123             model->BSIM4v7kvsat = 0;
2124         if (!model->BSIM4v7kvth0Given) /* m */
2125             model->BSIM4v7kvth0 = 0;
2126         if (!model->BSIM4v7tku0Given)
2127             model->BSIM4v7tku0 = 0;
2128         if (!model->BSIM4v7llodku0Given)
2129             model->BSIM4v7llodku0 = 0;
2130         if (!model->BSIM4v7wlodku0Given)
2131             model->BSIM4v7wlodku0 = 0;
2132         if (!model->BSIM4v7llodvthGiven)
2133             model->BSIM4v7llodvth = 0;
2134         if (!model->BSIM4v7wlodvthGiven)
2135             model->BSIM4v7wlodvth = 0;
2136         if (!model->BSIM4v7lku0Given)
2137             model->BSIM4v7lku0 = 0;
2138         if (!model->BSIM4v7wku0Given)
2139             model->BSIM4v7wku0 = 0;
2140         if (!model->BSIM4v7pku0Given)
2141             model->BSIM4v7pku0 = 0;
2142         if (!model->BSIM4v7lkvth0Given)
2143             model->BSIM4v7lkvth0 = 0;
2144         if (!model->BSIM4v7wkvth0Given)
2145             model->BSIM4v7wkvth0 = 0;
2146         if (!model->BSIM4v7pkvth0Given)
2147             model->BSIM4v7pkvth0 = 0;
2148         if (!model->BSIM4v7stk2Given)
2149             model->BSIM4v7stk2 = 0;
2150         if (!model->BSIM4v7lodk2Given)
2151             model->BSIM4v7lodk2 = 1.0;
2152         if (!model->BSIM4v7steta0Given)
2153             model->BSIM4v7steta0 = 0;
2154         if (!model->BSIM4v7lodeta0Given)
2155             model->BSIM4v7lodeta0 = 1.0;
2156 
2157         /* Well Proximity Effect  */
2158         if (!model->BSIM4v7webGiven)
2159             model->BSIM4v7web = 0.0;
2160         if (!model->BSIM4v7wecGiven)
2161             model->BSIM4v7wec = 0.0;
2162         if (!model->BSIM4v7kvth0weGiven)
2163             model->BSIM4v7kvth0we = 0.0;
2164         if (!model->BSIM4v7k2weGiven)
2165             model->BSIM4v7k2we = 0.0;
2166         if (!model->BSIM4v7ku0weGiven)
2167             model->BSIM4v7ku0we = 0.0;
2168         if (!model->BSIM4v7screfGiven)
2169             model->BSIM4v7scref = 1.0E-6; /* m */
2170         if (!model->BSIM4v7wpemodGiven)
2171             model->BSIM4v7wpemod = 0;
2172         else if ((model->BSIM4v7wpemod != 0) && (model->BSIM4v7wpemod != 1))
2173         {   model->BSIM4v7wpemod = 0;
2174             printf("Warning: wpemod has been set to its default value: 0.\n");
2175         }
2176         if (!model->BSIM4v7lkvth0weGiven)
2177             model->BSIM4v7lkvth0we = 0;
2178         if (!model->BSIM4v7lk2weGiven)
2179             model->BSIM4v7lk2we = 0;
2180         if (!model->BSIM4v7lku0weGiven)
2181             model->BSIM4v7lku0we = 0;
2182         if (!model->BSIM4v7wkvth0weGiven)
2183             model->BSIM4v7wkvth0we = 0;
2184         if (!model->BSIM4v7wk2weGiven)
2185             model->BSIM4v7wk2we = 0;
2186         if (!model->BSIM4v7wku0weGiven)
2187             model->BSIM4v7wku0we = 0;
2188         if (!model->BSIM4v7pkvth0weGiven)
2189             model->BSIM4v7pkvth0we = 0;
2190         if (!model->BSIM4v7pk2weGiven)
2191             model->BSIM4v7pk2we = 0;
2192         if (!model->BSIM4v7pku0weGiven)
2193             model->BSIM4v7pku0we = 0;
2194 
2195         DMCGeff = model->BSIM4v7dmcg - model->BSIM4v7dmcgt;
2196         DMCIeff = model->BSIM4v7dmci;
2197         DMDGeff = model->BSIM4v7dmdg - model->BSIM4v7dmcgt;
2198 
2199         /*
2200          * End processing models and begin to loop
2201          * through all the instances of the model
2202          */
2203 
2204         for (here = BSIM4v7instances(model); here != NULL ;
2205              here=BSIM4v7nextInstance(here))
2206         {
2207             /* allocate a chunk of the state vector */
2208             here->BSIM4v7states = *states;
2209             *states += BSIM4v7numStates;
2210 
2211             /* perform the parameter defaulting */
2212             if (!here->BSIM4v7lGiven)
2213                 here->BSIM4v7l = 5.0e-6;
2214             if (!here->BSIM4v7wGiven)
2215                 here->BSIM4v7w = 5.0e-6;
2216             if (!here->BSIM4v7mGiven)
2217                 here->BSIM4v7m = 1.0;
2218             if (!here->BSIM4v7nfGiven)
2219                 here->BSIM4v7nf = 1.0;
2220             if (!here->BSIM4v7minGiven)
2221                 here->BSIM4v7min = 0; /* integer */
2222             if (!here->BSIM4v7icVDSGiven)
2223                 here->BSIM4v7icVDS = 0.0;
2224             if (!here->BSIM4v7icVGSGiven)
2225                 here->BSIM4v7icVGS = 0.0;
2226             if (!here->BSIM4v7icVBSGiven)
2227                 here->BSIM4v7icVBS = 0.0;
2228             if (!here->BSIM4v7drainAreaGiven)
2229                 here->BSIM4v7drainArea = 0.0;
2230             if (!here->BSIM4v7drainPerimeterGiven)
2231                 here->BSIM4v7drainPerimeter = 0.0;
2232             if (!here->BSIM4v7drainSquaresGiven)
2233                 here->BSIM4v7drainSquares = 1.0;
2234             if (!here->BSIM4v7sourceAreaGiven)
2235                 here->BSIM4v7sourceArea = 0.0;
2236             if (!here->BSIM4v7sourcePerimeterGiven)
2237                 here->BSIM4v7sourcePerimeter = 0.0;
2238             if (!here->BSIM4v7sourceSquaresGiven)
2239                 here->BSIM4v7sourceSquares = 1.0;
2240 
2241             if (!here->BSIM4v7rbdbGiven)
2242                 here->BSIM4v7rbdb = model->BSIM4v7rbdb; /* in ohm */
2243             if (!here->BSIM4v7rbsbGiven)
2244                 here->BSIM4v7rbsb = model->BSIM4v7rbsb;
2245             if (!here->BSIM4v7rbpbGiven)
2246                 here->BSIM4v7rbpb = model->BSIM4v7rbpb;
2247             if (!here->BSIM4v7rbpsGiven)
2248                 here->BSIM4v7rbps = model->BSIM4v7rbps;
2249             if (!here->BSIM4v7rbpdGiven)
2250                 here->BSIM4v7rbpd = model->BSIM4v7rbpd;
2251             if (!here->BSIM4v7delvtoGiven)
2252                 here->BSIM4v7delvto = 0.0;
2253             if (!here->BSIM4v7mulu0Given)
2254                 here->BSIM4v7mulu0 = 1.0;
2255             if (!here->BSIM4v7xgwGiven)
2256                 here->BSIM4v7xgw = model->BSIM4v7xgw;
2257             if (!here->BSIM4v7ngconGiven)
2258                 here->BSIM4v7ngcon = model->BSIM4v7ngcon;
2259 
2260 
2261             /* Process instance model selectors, some
2262              * may override their global counterparts
2263              */
2264             if (!here->BSIM4v7rbodyModGiven)
2265                 here->BSIM4v7rbodyMod = model->BSIM4v7rbodyMod;
2266             else if ((here->BSIM4v7rbodyMod != 0) && (here->BSIM4v7rbodyMod != 1) && (here->BSIM4v7rbodyMod != 2))
2267             {   here->BSIM4v7rbodyMod = model->BSIM4v7rbodyMod;
2268                 printf("Warning: rbodyMod has been set to its global value %d.\n",
2269                 model->BSIM4v7rbodyMod);
2270             }
2271 
2272             if (!here->BSIM4v7rgateModGiven)
2273                 here->BSIM4v7rgateMod = model->BSIM4v7rgateMod;
2274             else if ((here->BSIM4v7rgateMod != 0) && (here->BSIM4v7rgateMod != 1)
2275                 && (here->BSIM4v7rgateMod != 2) && (here->BSIM4v7rgateMod != 3))
2276             {   here->BSIM4v7rgateMod = model->BSIM4v7rgateMod;
2277                 printf("Warning: rgateMod has been set to its global value %d.\n",
2278                 model->BSIM4v7rgateMod);
2279             }
2280 
2281             if (!here->BSIM4v7geoModGiven)
2282                 here->BSIM4v7geoMod = model->BSIM4v7geoMod;
2283 
2284             if (!here->BSIM4v7rgeoModGiven)
2285                 here->BSIM4v7rgeoMod = model->BSIM4v7rgeoMod;
2286             else if ((here->BSIM4v7rgeoMod != 0) && (here->BSIM4v7rgeoMod != 1))
2287             {   here->BSIM4v7rgeoMod = model->BSIM4v7rgeoMod;
2288                 printf("Warning: rgeoMod has been set to its global value %d.\n",
2289                 model->BSIM4v7rgeoMod);
2290             }
2291 
2292             if (!here->BSIM4v7trnqsModGiven)
2293                 here->BSIM4v7trnqsMod = model->BSIM4v7trnqsMod;
2294             else if ((here->BSIM4v7trnqsMod != 0) && (here->BSIM4v7trnqsMod != 1))
2295             {   here->BSIM4v7trnqsMod = model->BSIM4v7trnqsMod;
2296                 printf("Warning: trnqsMod has been set to its global value %d.\n",
2297                 model->BSIM4v7trnqsMod);
2298             }
2299 
2300             if (!here->BSIM4v7acnqsModGiven)
2301                 here->BSIM4v7acnqsMod = model->BSIM4v7acnqsMod;
2302             else if ((here->BSIM4v7acnqsMod != 0) && (here->BSIM4v7acnqsMod != 1))
2303             {   here->BSIM4v7acnqsMod = model->BSIM4v7acnqsMod;
2304                 printf("Warning: acnqsMod has been set to its global value %d.\n",
2305                 model->BSIM4v7acnqsMod);
2306             }
2307 
2308             /* stress effect */
2309             if (!here->BSIM4v7saGiven)
2310                 here->BSIM4v7sa = 0.0;
2311             if (!here->BSIM4v7sbGiven)
2312                 here->BSIM4v7sb = 0.0;
2313             if (!here->BSIM4v7sdGiven)
2314                 here->BSIM4v7sd = 2 * model->BSIM4v7dmcg;
2315             /* Well Proximity Effect  */
2316             if (!here->BSIM4v7scaGiven)
2317                 here->BSIM4v7sca = 0.0;
2318             if (!here->BSIM4v7scbGiven)
2319                 here->BSIM4v7scb = 0.0;
2320             if (!here->BSIM4v7sccGiven)
2321                 here->BSIM4v7scc = 0.0;
2322             if (!here->BSIM4v7scGiven)
2323                 here->BSIM4v7sc = 0.0; /* m */
2324 
2325             /* process drain series resistance */
2326             createNode = 0;
2327             if ( (model->BSIM4v7rdsMod != 0)
2328                             || (model->BSIM4v7tnoiMod == 1 && noiseAnalGiven))
2329             {
2330                createNode = 1;
2331             } else if (model->BSIM4v7sheetResistance > 0)
2332             {
2333                      if (here->BSIM4v7drainSquaresGiven
2334                                        && here->BSIM4v7drainSquares > 0)
2335                      {
2336                           createNode = 1;
2337                      } else if (!here->BSIM4v7drainSquaresGiven
2338                                        && (here->BSIM4v7rgeoMod != 0))
2339                      {
2340                           BSIM4v7RdseffGeo(here->BSIM4v7nf*here->BSIM4v7m, here->BSIM4v7geoMod,
2341                                   here->BSIM4v7rgeoMod, here->BSIM4v7min,
2342                                   here->BSIM4v7w, model->BSIM4v7sheetResistance,
2343                                   DMCGeff, DMCIeff, DMDGeff, 0, &Rtot);
2344                           if(Rtot > 0)
2345                              createNode = 1;
2346                      }
2347             }
2348             if ( createNode != 0 )
2349             {   if ( here->BSIM4v7dNodePrime == 0 )
2350             {   error = CKTmkVolt(ckt,&tmp,here->BSIM4v7name,"drain");
2351                 if(error) return(error);
2352                 here->BSIM4v7dNodePrime = tmp->number;
2353                 if (ckt->CKTcopyNodesets) {
2354                   CKTnode *tmpNode;
2355                   IFuid tmpName;
2356                   if (CKTinst2Node(ckt,here,1,&tmpNode,&tmpName)==OK) {
2357                      if (tmpNode->nsGiven) {
2358                        tmp->nodeset=tmpNode->nodeset;
2359                        tmp->nsGiven=tmpNode->nsGiven;
2360                      }
2361                   }
2362                 }
2363             }
2364             }
2365             else
2366             {   here->BSIM4v7dNodePrime = here->BSIM4v7dNode;
2367             }
2368 
2369             /* process source series resistance */
2370             createNode = 0;
2371             if ( (model->BSIM4v7rdsMod != 0)
2372                             || (model->BSIM4v7tnoiMod == 1 && noiseAnalGiven))
2373             {
2374                createNode = 1;
2375             } else if (model->BSIM4v7sheetResistance > 0)
2376             {
2377                      if (here->BSIM4v7sourceSquaresGiven
2378                                         && here->BSIM4v7sourceSquares > 0)
2379                      {
2380                           createNode = 1;
2381                      } else if (!here->BSIM4v7sourceSquaresGiven
2382                                         && (here->BSIM4v7rgeoMod != 0))
2383                      {
2384                           BSIM4v7RdseffGeo(here->BSIM4v7nf*here->BSIM4v7m, here->BSIM4v7geoMod,
2385                                   here->BSIM4v7rgeoMod, here->BSIM4v7min,
2386                                   here->BSIM4v7w, model->BSIM4v7sheetResistance,
2387                                   DMCGeff, DMCIeff, DMDGeff, 1, &Rtot);
2388                           if(Rtot > 0)
2389                              createNode = 1;
2390                      }
2391             }
2392             if ( createNode != 0 )
2393             {   if ( here->BSIM4v7sNodePrime == 0 )
2394             {   error = CKTmkVolt(ckt,&tmp,here->BSIM4v7name,"source");
2395                 if(error) return(error);
2396                 here->BSIM4v7sNodePrime = tmp->number;
2397                 if (ckt->CKTcopyNodesets) {
2398                   CKTnode *tmpNode;
2399                   IFuid tmpName;
2400                   if (CKTinst2Node(ckt,here,3,&tmpNode,&tmpName)==OK) {
2401                      if (tmpNode->nsGiven) {
2402                        tmp->nodeset=tmpNode->nodeset;
2403                        tmp->nsGiven=tmpNode->nsGiven;
2404                      }
2405                   }
2406                 }
2407             }
2408             }
2409             else
2410                 here->BSIM4v7sNodePrime = here->BSIM4v7sNode;
2411 
2412             if ( here->BSIM4v7rgateMod > 0 )
2413             {   if ( here->BSIM4v7gNodePrime == 0 )
2414             {   error = CKTmkVolt(ckt,&tmp,here->BSIM4v7name,"gate");
2415                 if(error) return(error);
2416                    here->BSIM4v7gNodePrime = tmp->number;
2417                 if (ckt->CKTcopyNodesets) {
2418                   CKTnode *tmpNode;
2419                   IFuid tmpName;
2420                   if (CKTinst2Node(ckt,here,2,&tmpNode,&tmpName)==OK) {
2421                     if (tmpNode->nsGiven) {
2422                       tmp->nodeset=tmpNode->nodeset;
2423                       tmp->nsGiven=tmpNode->nsGiven;
2424                     }
2425                   }
2426                 }
2427             }
2428             }
2429             else
2430                 here->BSIM4v7gNodePrime = here->BSIM4v7gNodeExt;
2431 
2432             if ( here->BSIM4v7rgateMod == 3 )
2433             {   if ( here->BSIM4v7gNodeMid == 0 )
2434             {   error = CKTmkVolt(ckt,&tmp,here->BSIM4v7name,"midgate");
2435                 if(error) return(error);
2436                    here->BSIM4v7gNodeMid = tmp->number;
2437             }
2438             }
2439             else
2440                 here->BSIM4v7gNodeMid = here->BSIM4v7gNodeExt;
2441 
2442 
2443             /* internal body nodes for body resistance model */
2444             if ((here->BSIM4v7rbodyMod ==1) || (here->BSIM4v7rbodyMod ==2))
2445             {   if (here->BSIM4v7dbNode == 0)
2446                 {   error = CKTmkVolt(ckt,&tmp,here->BSIM4v7name,"dbody");
2447                     if(error) return(error);
2448                     here->BSIM4v7dbNode = tmp->number;
2449                 }
2450                 if (here->BSIM4v7bNodePrime == 0)
2451                 {   error = CKTmkVolt(ckt,&tmp,here->BSIM4v7name,"body");
2452                     if(error) return(error);
2453                     here->BSIM4v7bNodePrime = tmp->number;
2454                     if (ckt->CKTcopyNodesets) {
2455                       CKTnode *tmpNode;
2456                       IFuid tmpName;
2457                       if (CKTinst2Node(ckt,here,4,&tmpNode,&tmpName)==OK) {
2458                         if (tmpNode->nsGiven) {
2459                           tmp->nodeset=tmpNode->nodeset;
2460                           tmp->nsGiven=tmpNode->nsGiven;
2461                         }
2462                       }
2463                     }
2464                 }
2465                 if (here->BSIM4v7sbNode == 0)
2466                 {   error = CKTmkVolt(ckt,&tmp,here->BSIM4v7name,"sbody");
2467                     if(error) return(error);
2468                     here->BSIM4v7sbNode = tmp->number;
2469                 }
2470             }
2471             else
2472                 here->BSIM4v7dbNode = here->BSIM4v7bNodePrime = here->BSIM4v7sbNode
2473                                   = here->BSIM4v7bNode;
2474 
2475             /* NQS node */
2476             if ( here->BSIM4v7trnqsMod )
2477             {   if ( here->BSIM4v7qNode == 0 )
2478             {   error = CKTmkVolt(ckt,&tmp,here->BSIM4v7name,"charge");
2479                 if(error) return(error);
2480                 here->BSIM4v7qNode = tmp->number;
2481             }
2482             }
2483             else
2484                 here->BSIM4v7qNode = 0;
2485 
2486 
2487 /* set Sparse Matrix Pointers
2488  * macro to make elements with built-in out-of-memory test */
2489 #define TSTALLOC(ptr,first,second) \
2490 do { if((here->ptr = SMPmakeElt(matrix,here->first,here->second))==(double *)NULL){\
2491     return(E_NOMEM);\
2492 } } while(0)
2493 
2494             TSTALLOC(BSIM4v7DPbpPtr, BSIM4v7dNodePrime, BSIM4v7bNodePrime);
2495             TSTALLOC(BSIM4v7GPbpPtr, BSIM4v7gNodePrime, BSIM4v7bNodePrime);
2496             TSTALLOC(BSIM4v7SPbpPtr, BSIM4v7sNodePrime, BSIM4v7bNodePrime);
2497 
2498             TSTALLOC(BSIM4v7BPdpPtr, BSIM4v7bNodePrime, BSIM4v7dNodePrime);
2499             TSTALLOC(BSIM4v7BPgpPtr, BSIM4v7bNodePrime, BSIM4v7gNodePrime);
2500             TSTALLOC(BSIM4v7BPspPtr, BSIM4v7bNodePrime, BSIM4v7sNodePrime);
2501             TSTALLOC(BSIM4v7BPbpPtr, BSIM4v7bNodePrime, BSIM4v7bNodePrime);
2502 
2503             TSTALLOC(BSIM4v7DdPtr, BSIM4v7dNode, BSIM4v7dNode);
2504             TSTALLOC(BSIM4v7GPgpPtr, BSIM4v7gNodePrime, BSIM4v7gNodePrime);
2505             TSTALLOC(BSIM4v7SsPtr, BSIM4v7sNode, BSIM4v7sNode);
2506             TSTALLOC(BSIM4v7DPdpPtr, BSIM4v7dNodePrime, BSIM4v7dNodePrime);
2507             TSTALLOC(BSIM4v7SPspPtr, BSIM4v7sNodePrime, BSIM4v7sNodePrime);
2508             TSTALLOC(BSIM4v7DdpPtr, BSIM4v7dNode, BSIM4v7dNodePrime);
2509             TSTALLOC(BSIM4v7GPdpPtr, BSIM4v7gNodePrime, BSIM4v7dNodePrime);
2510             TSTALLOC(BSIM4v7GPspPtr, BSIM4v7gNodePrime, BSIM4v7sNodePrime);
2511             TSTALLOC(BSIM4v7SspPtr, BSIM4v7sNode, BSIM4v7sNodePrime);
2512             TSTALLOC(BSIM4v7DPspPtr, BSIM4v7dNodePrime, BSIM4v7sNodePrime);
2513             TSTALLOC(BSIM4v7DPdPtr, BSIM4v7dNodePrime, BSIM4v7dNode);
2514             TSTALLOC(BSIM4v7DPgpPtr, BSIM4v7dNodePrime, BSIM4v7gNodePrime);
2515             TSTALLOC(BSIM4v7SPgpPtr, BSIM4v7sNodePrime, BSIM4v7gNodePrime);
2516             TSTALLOC(BSIM4v7SPsPtr, BSIM4v7sNodePrime, BSIM4v7sNode);
2517             TSTALLOC(BSIM4v7SPdpPtr, BSIM4v7sNodePrime, BSIM4v7dNodePrime);
2518 
2519             TSTALLOC(BSIM4v7QqPtr, BSIM4v7qNode, BSIM4v7qNode);
2520             TSTALLOC(BSIM4v7QbpPtr, BSIM4v7qNode, BSIM4v7bNodePrime) ;
2521             TSTALLOC(BSIM4v7QdpPtr, BSIM4v7qNode, BSIM4v7dNodePrime);
2522             TSTALLOC(BSIM4v7QspPtr, BSIM4v7qNode, BSIM4v7sNodePrime);
2523             TSTALLOC(BSIM4v7QgpPtr, BSIM4v7qNode, BSIM4v7gNodePrime);
2524             TSTALLOC(BSIM4v7DPqPtr, BSIM4v7dNodePrime, BSIM4v7qNode);
2525             TSTALLOC(BSIM4v7SPqPtr, BSIM4v7sNodePrime, BSIM4v7qNode);
2526             TSTALLOC(BSIM4v7GPqPtr, BSIM4v7gNodePrime, BSIM4v7qNode);
2527 
2528             if (here->BSIM4v7rgateMod != 0)
2529             {   TSTALLOC(BSIM4v7GEgePtr, BSIM4v7gNodeExt, BSIM4v7gNodeExt);
2530                 TSTALLOC(BSIM4v7GEgpPtr, BSIM4v7gNodeExt, BSIM4v7gNodePrime);
2531                 TSTALLOC(BSIM4v7GPgePtr, BSIM4v7gNodePrime, BSIM4v7gNodeExt);
2532                 TSTALLOC(BSIM4v7GEdpPtr, BSIM4v7gNodeExt, BSIM4v7dNodePrime);
2533                 TSTALLOC(BSIM4v7GEspPtr, BSIM4v7gNodeExt, BSIM4v7sNodePrime);
2534                 TSTALLOC(BSIM4v7GEbpPtr, BSIM4v7gNodeExt, BSIM4v7bNodePrime);
2535 
2536                 TSTALLOC(BSIM4v7GMdpPtr, BSIM4v7gNodeMid, BSIM4v7dNodePrime);
2537                 TSTALLOC(BSIM4v7GMgpPtr, BSIM4v7gNodeMid, BSIM4v7gNodePrime);
2538                 TSTALLOC(BSIM4v7GMgmPtr, BSIM4v7gNodeMid, BSIM4v7gNodeMid);
2539                 TSTALLOC(BSIM4v7GMgePtr, BSIM4v7gNodeMid, BSIM4v7gNodeExt);
2540                 TSTALLOC(BSIM4v7GMspPtr, BSIM4v7gNodeMid, BSIM4v7sNodePrime);
2541                 TSTALLOC(BSIM4v7GMbpPtr, BSIM4v7gNodeMid, BSIM4v7bNodePrime);
2542                 TSTALLOC(BSIM4v7DPgmPtr, BSIM4v7dNodePrime, BSIM4v7gNodeMid);
2543                 TSTALLOC(BSIM4v7GPgmPtr, BSIM4v7gNodePrime, BSIM4v7gNodeMid);
2544                 TSTALLOC(BSIM4v7GEgmPtr, BSIM4v7gNodeExt, BSIM4v7gNodeMid);
2545                 TSTALLOC(BSIM4v7SPgmPtr, BSIM4v7sNodePrime, BSIM4v7gNodeMid);
2546                 TSTALLOC(BSIM4v7BPgmPtr, BSIM4v7bNodePrime, BSIM4v7gNodeMid);
2547             }
2548 
2549             if ((here->BSIM4v7rbodyMod ==1) || (here->BSIM4v7rbodyMod ==2))
2550             {   TSTALLOC(BSIM4v7DPdbPtr, BSIM4v7dNodePrime, BSIM4v7dbNode);
2551                 TSTALLOC(BSIM4v7SPsbPtr, BSIM4v7sNodePrime, BSIM4v7sbNode);
2552 
2553                 TSTALLOC(BSIM4v7DBdpPtr, BSIM4v7dbNode, BSIM4v7dNodePrime);
2554                 TSTALLOC(BSIM4v7DBdbPtr, BSIM4v7dbNode, BSIM4v7dbNode);
2555                 TSTALLOC(BSIM4v7DBbpPtr, BSIM4v7dbNode, BSIM4v7bNodePrime);
2556                 TSTALLOC(BSIM4v7DBbPtr, BSIM4v7dbNode, BSIM4v7bNode);
2557 
2558                 TSTALLOC(BSIM4v7BPdbPtr, BSIM4v7bNodePrime, BSIM4v7dbNode);
2559                 TSTALLOC(BSIM4v7BPbPtr, BSIM4v7bNodePrime, BSIM4v7bNode);
2560                 TSTALLOC(BSIM4v7BPsbPtr, BSIM4v7bNodePrime, BSIM4v7sbNode);
2561 
2562                 TSTALLOC(BSIM4v7SBspPtr, BSIM4v7sbNode, BSIM4v7sNodePrime);
2563                 TSTALLOC(BSIM4v7SBbpPtr, BSIM4v7sbNode, BSIM4v7bNodePrime);
2564                 TSTALLOC(BSIM4v7SBbPtr, BSIM4v7sbNode, BSIM4v7bNode);
2565                 TSTALLOC(BSIM4v7SBsbPtr, BSIM4v7sbNode, BSIM4v7sbNode);
2566 
2567                 TSTALLOC(BSIM4v7BdbPtr, BSIM4v7bNode, BSIM4v7dbNode);
2568                 TSTALLOC(BSIM4v7BbpPtr, BSIM4v7bNode, BSIM4v7bNodePrime);
2569                 TSTALLOC(BSIM4v7BsbPtr, BSIM4v7bNode, BSIM4v7sbNode);
2570                 TSTALLOC(BSIM4v7BbPtr, BSIM4v7bNode, BSIM4v7bNode);
2571             }
2572 
2573             if (model->BSIM4v7rdsMod)
2574             {   TSTALLOC(BSIM4v7DgpPtr, BSIM4v7dNode, BSIM4v7gNodePrime);
2575                 TSTALLOC(BSIM4v7DspPtr, BSIM4v7dNode, BSIM4v7sNodePrime);
2576                 TSTALLOC(BSIM4v7DbpPtr, BSIM4v7dNode, BSIM4v7bNodePrime);
2577                 TSTALLOC(BSIM4v7SdpPtr, BSIM4v7sNode, BSIM4v7dNodePrime);
2578                 TSTALLOC(BSIM4v7SgpPtr, BSIM4v7sNode, BSIM4v7gNodePrime);
2579                 TSTALLOC(BSIM4v7SbpPtr, BSIM4v7sNode, BSIM4v7bNodePrime);
2580             }
2581         }
2582     }
2583 
2584 #ifdef USE_OMP
2585     InstCount = 0;
2586     model = (BSIM4v7model*)inModel;
2587     /* loop through all the BSIM4v7 device models
2588        to count the number of instances */
2589 
2590     for( ; model != NULL; model = BSIM4v7nextModel(model))
2591     {
2592         /* loop through all the instances of the model */
2593         for (here = BSIM4v7instances(model); here != NULL ;
2594              here=BSIM4v7nextInstance(here))
2595         {
2596             InstCount++;
2597         }
2598         model->BSIM4v7InstCount = 0;
2599         model->BSIM4v7InstanceArray = NULL;
2600     }
2601     InstArray = TMALLOC(BSIM4v7instance*, InstCount);
2602     model = (BSIM4v7model*)inModel;
2603     /* store this in the first model only */
2604     model->BSIM4v7InstCount = InstCount;
2605     model->BSIM4v7InstanceArray = InstArray;
2606     idx = 0;
2607     for( ; model != NULL; model = BSIM4v7nextModel(model))
2608     {
2609         /* loop through all the instances of the model */
2610         for (here = BSIM4v7instances(model); here != NULL ;
2611              here=BSIM4v7nextInstance(here))
2612         {
2613             InstArray[idx] = here;
2614             idx++;
2615         }
2616     }
2617 #endif
2618 
2619     return(OK);
2620 }
2621 
2622 int
BSIM4v7unsetup(GENmodel * inModel,CKTcircuit * ckt)2623 BSIM4v7unsetup(
2624 GENmodel *inModel,
2625 CKTcircuit *ckt)
2626 {
2627 #ifndef HAS_BATCHSIM
2628     BSIM4v7model *model;
2629     BSIM4v7instance *here;
2630 
2631 #ifdef USE_OMP
2632     model = (BSIM4v7model*)inModel;
2633     tfree(model->BSIM4v7InstanceArray);
2634 #endif
2635 
2636     for (model = (BSIM4v7model *)inModel; model != NULL;
2637             model = BSIM4v7nextModel(model))
2638     {
2639         for (here = BSIM4v7instances(model); here != NULL;
2640                 here=BSIM4v7nextInstance(here))
2641         {
2642             if (here->BSIM4v7qNode > 0)
2643                 CKTdltNNum(ckt, here->BSIM4v7qNode);
2644             here->BSIM4v7qNode = 0;
2645 
2646             if (here->BSIM4v7sbNode > 0 &&
2647                 here->BSIM4v7sbNode != here->BSIM4v7bNode)
2648                 CKTdltNNum(ckt, here->BSIM4v7sbNode);
2649             here->BSIM4v7sbNode = 0;
2650 
2651             if (here->BSIM4v7bNodePrime > 0 &&
2652                 here->BSIM4v7bNodePrime != here->BSIM4v7bNode)
2653                 CKTdltNNum(ckt, here->BSIM4v7bNodePrime);
2654             here->BSIM4v7bNodePrime = 0;
2655 
2656             if (here->BSIM4v7dbNode > 0 &&
2657                 here->BSIM4v7dbNode != here->BSIM4v7bNode)
2658                 CKTdltNNum(ckt, here->BSIM4v7dbNode);
2659             here->BSIM4v7dbNode = 0;
2660 
2661             if (here->BSIM4v7gNodeMid > 0 &&
2662                 here->BSIM4v7gNodeMid != here->BSIM4v7gNodeExt)
2663                 CKTdltNNum(ckt, here->BSIM4v7gNodeMid);
2664             here->BSIM4v7gNodeMid = 0;
2665 
2666             if (here->BSIM4v7gNodePrime > 0 &&
2667                 here->BSIM4v7gNodePrime != here->BSIM4v7gNodeExt)
2668                 CKTdltNNum(ckt, here->BSIM4v7gNodePrime);
2669             here->BSIM4v7gNodePrime = 0;
2670 
2671             if (here->BSIM4v7sNodePrime > 0
2672                     && here->BSIM4v7sNodePrime != here->BSIM4v7sNode)
2673                 CKTdltNNum(ckt, here->BSIM4v7sNodePrime);
2674             here->BSIM4v7sNodePrime = 0;
2675 
2676             if (here->BSIM4v7dNodePrime > 0
2677                     && here->BSIM4v7dNodePrime != here->BSIM4v7dNode)
2678                 CKTdltNNum(ckt, here->BSIM4v7dNodePrime);
2679             here->BSIM4v7dNodePrime = 0;
2680 
2681         }
2682     }
2683 #endif
2684     return OK;
2685 }
2686