Fix bug #602 "Warning message trying to linearize a transient analysis vector"
by changing the way "ngspice -a" (autorun option) works. The inserted code now checks whether a simulation has already run by examining $curplot before forcing "run". Also at most one simulation is forced to run.
This commit is contained in:
parent
06131d8107
commit
8cc9d8522f
|
|
@ -1089,8 +1089,12 @@ struct card *inp_readall(FILE *fp, const char *dir_name,
|
||||||
inp_fix_gnd_name(working);
|
inp_fix_gnd_name(working);
|
||||||
inp_chk_for_multi_in_vcvs(working, &rv.line_number);
|
inp_chk_for_multi_in_vcvs(working, &rv.line_number);
|
||||||
|
|
||||||
if (cp_getvar("addcontrol", CP_BOOL, NULL, 0))
|
/* "addcontrol" variable is set if "ngspice -a file" was used. */
|
||||||
|
|
||||||
|
if (cp_getvar("addcontrol", CP_BOOL, NULL, 0)) {
|
||||||
inp_add_control_section(working, &rv.line_number);
|
inp_add_control_section(working, &rv.line_number);
|
||||||
|
cp_remvar("addcontrol"); // Use only for initial netlist
|
||||||
|
}
|
||||||
#ifdef XSPICE
|
#ifdef XSPICE
|
||||||
if (inp_poly_2g6_compat(working)) {
|
if (inp_poly_2g6_compat(working)) {
|
||||||
inp_rem_levels(root);
|
inp_rem_levels(root);
|
||||||
|
|
@ -2170,76 +2174,44 @@ static void inp_chk_for_multi_in_vcvs(struct card *c, int *line_number)
|
||||||
|
|
||||||
|
|
||||||
/* If ngspice is started with option -a, then variable 'autorun'
|
/* If ngspice is started with option -a, then variable 'autorun'
|
||||||
* will be set and the following function scans the deck.
|
* will be set and a control section is inserted to try and ensure
|
||||||
* If 'run' is not found, a .control section will be added:
|
* some analysis is done;
|
||||||
|
*
|
||||||
* .control
|
* .control
|
||||||
* run
|
* strcmp __flag $curplot const
|
||||||
* op ; if .op is found
|
* if $__flag eq 0
|
||||||
|
* run
|
||||||
|
* end
|
||||||
* write rawfile ; if rawfile given
|
* write rawfile ; if rawfile given
|
||||||
* .endc
|
* .endc
|
||||||
|
*
|
||||||
|
* The effect is that "run" is executed if there was no previous
|
||||||
|
* analysis.
|
||||||
*/
|
*/
|
||||||
static void inp_add_control_section(struct card *deck, int *line_number)
|
static void inp_add_control_section(struct card *deck, int *line_number)
|
||||||
{
|
{
|
||||||
struct card *c, *prev_card = NULL;
|
static const char * const cards[] =
|
||||||
bool found_control = FALSE, found_run = FALSE;
|
{".control", "strcmp __flag $curplot const", "if $__flag eq 0",
|
||||||
bool found_end = FALSE;
|
" run", "end", NULL};
|
||||||
char *op_line = NULL, rawfile[1000], *line;
|
const char * const *lp;
|
||||||
|
struct card *c, *prev_card = NULL, *last_end = NULL;
|
||||||
|
char rawfile[1000], *line;
|
||||||
|
|
||||||
for (c = deck; c; c = c->nextcard) {
|
for (c = deck; c; c = c->nextcard) {
|
||||||
|
|
||||||
if (*c->line == '*')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (ciprefix(".op ", c->line)) {
|
|
||||||
*c->line = '*';
|
|
||||||
op_line = c->line + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ciprefix(".end", c->line))
|
if (ciprefix(".end", c->line))
|
||||||
found_end = TRUE;
|
last_end = prev_card;
|
||||||
|
|
||||||
if (found_control && ciprefix("run", c->line))
|
|
||||||
found_run = TRUE;
|
|
||||||
|
|
||||||
if (ciprefix(".control", c->line))
|
|
||||||
found_control = TRUE;
|
|
||||||
|
|
||||||
if (ciprefix(".endc", c->line)) {
|
|
||||||
found_control = FALSE;
|
|
||||||
|
|
||||||
if (!found_run) {
|
|
||||||
prev_card = insert_new_line(
|
|
||||||
prev_card, copy("run"), (*line_number)++, 0);
|
|
||||||
found_run = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cp_getvar("rawfile", CP_STRING, rawfile, sizeof(rawfile))) {
|
|
||||||
line = tprintf("write %s", rawfile);
|
|
||||||
prev_card =
|
|
||||||
insert_new_line(prev_card, line, (*line_number)++, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prev_card = c;
|
prev_card = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if need to add control section
|
if (last_end)
|
||||||
if (!found_run && found_end) {
|
prev_card = last_end;
|
||||||
|
for (lp = cards; *lp; ++lp)
|
||||||
deck = insert_new_line(deck, copy(".control"), (*line_number)++, 0);
|
prev_card = insert_new_line(prev_card, copy(*lp), (*line_number)++, 0);
|
||||||
|
if (cp_getvar("rawfile", CP_STRING, rawfile, sizeof(rawfile))) {
|
||||||
deck = insert_new_line(deck, copy("run"), (*line_number)++, 0);
|
line = tprintf("write %s", rawfile);
|
||||||
|
prev_card = insert_new_line(prev_card, line, (*line_number)++, 0);
|
||||||
if (op_line)
|
|
||||||
deck = insert_new_line(deck, copy(op_line), (*line_number)++, 0);
|
|
||||||
|
|
||||||
if (cp_getvar("rawfile", CP_STRING, rawfile, sizeof(rawfile))) {
|
|
||||||
line = tprintf("write %s", rawfile);
|
|
||||||
deck = insert_new_line(deck, line, (*line_number)++, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
deck = insert_new_line(deck, copy(".endc"), (*line_number)++, 0);
|
|
||||||
}
|
}
|
||||||
|
insert_new_line(prev_card, copy(".endc"), (*line_number)++, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue