diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 5ececcdc0..c3a2b731c 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -680,8 +680,6 @@ inp_spsource(FILE *fp, bool comfile, char *filename) wl_free(controls); } - INPkillMods(); /* remove the modtab after the job is done */ - /* Now reset everything. Pop the control stack, and fix up the IO * as it was before the source. */ cp_popcontrol(); diff --git a/src/frontend/runcoms.c b/src/frontend/runcoms.c index 4bcbbd989..da351a2ff 100644 --- a/src/frontend/runcoms.c +++ b/src/frontend/runcoms.c @@ -30,6 +30,7 @@ Modified: 2000 AlansFixes static int dosim(char *what, wordlist *wl); +extern INPmodel *modtab; /* Routines for the commands op, tran, ac, dc, listing, device, state, * resume, stop, trace, run, end. Op, tran, ac, and dc cause the action @@ -103,6 +104,8 @@ com_scirc(wordlist *wl) ft_curckt->ci_nodes = cp_kwswitch(CT_NODENAMES, p->ci_nodes); } ft_curckt = p; + /* get the model table for the current circuit, store it in the global variable modtab */ + modtab = ft_curckt->ci_modtab; } diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index e01e9ac0d..0f87ad06f 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -27,6 +27,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #define RAWBUF_SIZE 32768 extern char rawfileBuf[RAWBUF_SIZE]; extern void line_free_x(struct line * deck, bool recurse); +extern INPmodel *modtab; #define line_free(line, flag) \ do { \ @@ -246,4 +247,6 @@ com_remcirc(wordlist *wl) /* make first entry in ft_circuits the actual circuit (or NULL) */ ft_curckt = ft_circuits; + if (ft_curckt) + modtab = ft_curckt->ci_modtab; } diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 34db0ebca..08c81ad4d 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -72,6 +72,7 @@ CDHW*/ #include "ngspice/mif.h" #endif +extern INPmodel *modtab; static struct variable *parmtovar(IFvalue *pv, IFparm *opt); static IFparm *parmlookup(IFdevice *dev, GENinstance **inptr, char *param, @@ -159,13 +160,13 @@ if_inpdeck(struct line *deck, INPtables **tab) ft_curckt->ci_curTask = ft_curckt->ci_defTask; + /* reset the model table, will be filled in anew in INPpas1() */ + modtab = NULL; INPpas1(ckt, (card *) deck->li_next, *tab); + /* store the new model table in the current circuit */ + ft_curckt->ci_modtab = modtab; INPpas2(ckt, (card *) deck->li_next, *tab, ft_curckt->ci_defTask); - /* INPkillMods(); modtab removed later on the end of inp_spsource - because needed for alter geometry of binned MOS models, - see below if_setparam_model */ - /* INPpas2 has been modified to ignore .NODESET and .IC * cards. These are left till INPpas3 so that we can check for * nodeset/ic of non-existant nodes. */ @@ -876,7 +877,7 @@ if_setparam_model(CKTcircuit *ckt, char **name, char *val) INPgetModBin(ckt, modname, &inpmod, ft_curckt->ci_symtab, val); tfree(modname); if (inpmod == NULL) { - fprintf(cp_err, "Error: no such model %s.\n", val); + fprintf(cp_err, "Error: no model available for %s.\n", val); return; } newMod = inpmod->INPmodfast; diff --git a/src/include/ngspice/ftedefs.h b/src/include/ngspice/ftedefs.h index 7a64c0342..46bd92c96 100644 --- a/src/include/ngspice/ftedefs.h +++ b/src/include/ngspice/ftedefs.h @@ -31,6 +31,7 @@ struct circ { char *ci_name; /* What the circuit can be called. */ CKTcircuit *ci_ckt; /* The CKTcircuit structure. */ INPtables *ci_symtab; /* The INP symbol table. */ + INPmodel *ci_modtab; /* The INP model table. */ struct line *ci_deck; /* The input deck. */ struct line *ci_origdeck;/* The input deck, before subckt expansion. */ struct line *ci_options;/* The .option cards from the deck... */ diff --git a/src/spicelib/parser/inpkmods.c b/src/spicelib/parser/inpkmods.c index ec84f3105..8e356a840 100644 --- a/src/spicelib/parser/inpkmods.c +++ b/src/spicelib/parser/inpkmods.c @@ -8,6 +8,7 @@ Author: 1985 Thomas L. Quarles #include "ngspice/ngspice.h" #include #include "ngspice/inpdefs.h" +#include "ngspice/ftedefs.h" #include "inpxx.h" @@ -26,4 +27,5 @@ void INPkillMods(void) if (prev) FREE(prev); modtab = NULL; + ft_curckt->ci_modtab = NULL; }