diff --git a/src/frontend/measure.c b/src/frontend/measure.c index c91715a11..b7b6680cc 100644 --- a/src/frontend/measure.c +++ b/src/frontend/measure.c @@ -532,7 +532,7 @@ check_autostop(char* what) { bool flag = FALSE; - if (cp_getvar("autostop", CP_BOOL, NULL, 0)) +// if (cp_getvar("autostop", CP_BOOL, NULL, 0)) flag = do_measure(what, TRUE); return flag; diff --git a/src/spicelib/analysis/dctran.c b/src/spicelib/analysis/dctran.c index 5f7d66c60..d3f6f8c12 100644 --- a/src/spicelib/analysis/dctran.c +++ b/src/spicelib/analysis/dctran.c @@ -94,6 +94,8 @@ DCtran(CKTcircuit *ckt, int numNames; double maxstepsize = 0.0; + bool have_autostop = FALSE, flag_autostop = FALSE; + int ltra_num; CKTnode *node; #ifdef XSPICE @@ -184,6 +186,8 @@ DCtran(CKTcircuit *ckt, save_mode = (ckt->CKTmode&MODEUIC) | MODETRANOP | MODEINITJCT; save_order = ckt->CKTorder; + have_autostop = cp_getvar("autostop", CP_BOOL, NULL, 0); + /* Add breakpoints here which have been requested by the user setting the stop command as 'stop when time = xx'. Get data from the global dbs data base. @@ -466,8 +470,14 @@ DCtran(CKTcircuit *ckt, /* gtri - end - wbk - Update event queues/data for accepted timepoint */ #endif ckt->CKTstat->STAToldIter = ckt->CKTstat->STATnumIter; - if (check_autostop("tran") || - ckt->CKTfinalTime - ckt->CKTtime < ckt->CKTminBreak) { + /* check for the end of the tran simulation, either by< stop time given, + or final time has been reached. */ + if (have_autostop) + /* time consuming autostop check only, when variable 'autostop' has been set + before tran is started.*/ + flag_autostop = check_autostop("tran"); + /* If CKTtime and CKTfinalTime are almost equal, then finish */ + if (flag_autostop || AlmostEqualUlps(ckt->CKTtime, ckt->CKTfinalTime, 100)) { #ifdef STEPDEBUG printf(" done: time is %g, final time is %g, and tol is %g\n", ckt->CKTtime, ckt->CKTfinalTime, ckt->CKTminBreak); @@ -480,6 +490,10 @@ DCtran(CKTcircuit *ckt, ckt->CKTsenInfo->SENmode = save; } #endif + if (flag_autostop) + fprintf(stdout, "\nNote: Autostop after %e s, all measurement conditions are fulfilled\n", ckt->CKTtime); + + /* Final return from tran*/ return(OK); } if(SPfrontEnd->IFpauseTest()) {