diff --git a/ChangeLog b/ChangeLog index 09e488db2..0ec4d0b61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-02-19 Holger Vogt + * spiceif.c: savesnap, loadsnap enabled (still experimental!) + * com_cdump.c, com_cdump.h, commands.c, smpdefs.h, spoutput.c, spsmp.c, + cktpzstr.c, txlload.c: command mdump to dump the matrix to stdout or to a file + 2012-02-11 Dietmar Warning * src/spicelib/devices/asrc/*.c,*.h,Makefile.am * src/frontend/inpcom.c, diff --git a/src/frontend/com_cdump.c b/src/frontend/com_cdump.c index 810714bac..2be33730c 100644 --- a/src/frontend/com_cdump.c +++ b/src/frontend/com_cdump.c @@ -1,4 +1,5 @@ /* Command cdump: dump the control structure to the console output */ +/* Command mdump: dump the matrix of the actual circuit to stdout or a file */ #include "ngspice/ngspice.h" #include @@ -7,7 +8,9 @@ #include "control.h" #include "ngspice/cpextern.h" - +#include "ngspice/fteext.h" +#include "ngspice/smpdefs.h" +#include "ngspice/cktdefs.h" #include "com_cdump.h" static int indent; @@ -143,3 +146,29 @@ com_cdump(wordlist *wl) dodump(c); return; } + +void +com_mdump(wordlist *wl) +{ + CKTcircuit *ckt = NULL; + char *s; + + if (!ft_curckt || !ft_curckt->ci_ckt) { + fprintf(cp_err, "Error: no circuit loaded.\n"); + return; + } + + ckt = ft_curckt->ci_ckt; + + if (ckt->CKTmatrix) + if (wl == NULL) + SMPprint( ckt->CKTmatrix , NULL); + else { + s = cp_unquote(wl->wl_word); + SMPprint( ckt->CKTmatrix , s); + } + else + fprintf(cp_err, "Error: no matrix available.\n"); + + return; +} diff --git a/src/frontend/com_cdump.h b/src/frontend/com_cdump.h index c82d18eef..b87d1e10a 100644 --- a/src/frontend/com_cdump.h +++ b/src/frontend/com_cdump.h @@ -2,6 +2,7 @@ #define _COM_CDUMP_H void com_cdump(wordlist *wl); +void com_mdump(wordlist *wl); #define TABINDENT 2 /* CDHW */ /* The orginal value was 8 */ #endif diff --git a/src/frontend/commands.c b/src/frontend/commands.c index 2f61d28d9..6679154df 100644 --- a/src/frontend/commands.c +++ b/src/frontend/commands.c @@ -549,6 +549,10 @@ struct comm spcp_coms[] = { { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, NULL, ": Dump the current control structures." } , + { "mdump", com_mdump, FALSE, FALSE, + { 0, 0, 0, 0 }, E_DEFHMASK, 0, 1, + NULL, + "outfile: Dump the current matrix." } , { "settype", com_stype, FALSE, FALSE, { 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, NULL, diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 69dc20c5e..f4ffb5095 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -70,6 +70,7 @@ CDHW*/ #include "ngspice/evtproto.h" #include "ngspice/evtudn.h" /* gtri - end - wbk - 5/20/91 - Add stuff for user-defined nodes */ +#include "ngspice/mif.h" #endif /* static declarations */ @@ -1312,6 +1313,14 @@ if_getstat(CKTcircuit *ckt, char *name) { } } +/* Some small updates to make it work, h_vogt, Feb. 2012 + Still very experimental ! + It is now possible to save a state during transient simulation, + reload it later into a new ngspice run and resume simulation. + XSPICE code models probably will not do. + LTRA transmission line will not do. + Many others are not tested. +*/ #ifdef EXPERIMENTAL_CODE #include "ngspice/cktdefs.h" @@ -1499,12 +1508,12 @@ do {\ _foo(ckt->CKTirhs, double,size); _foo(ckt->CKTirhsOld, double,size); _foo(ckt->CKTirhsSpare, double,size); - _foo(ckt->CKTrhsOp, double,size); - _foo(ckt->CKTsenRhs, double,size); - _foo(ckt->CKTseniRhs, double,size); +// _foo(ckt->CKTrhsOp, double,size); +// _foo(ckt->CKTsenRhs, double,size); +// _foo(ckt->CKTseniRhs, double,size); - _foo(ckt->CKTtimePoints,double,-1); - _foo(ckt->CKTdeltaList,double,-1); +// _foo(ckt->CKTtimePoints,double,-1); +// _foo(ckt->CKTdeltaList,double,-1); _foo(ckt->CKTbreaks,double,ckt->CKTbreakSize); @@ -1520,8 +1529,9 @@ do {\ _foo(ft_curckt->ci_curTask->TSKname, char, -1); { /* avoid invalid lvalue assignment errors in the macro _foo() */ - TRANan * lname = (TRANan *)ft_curckt->ci_curTask->jobs; - _foo(lname,TRANan,1); +// TRANan * lname = (TRANan *)ft_curckt->ci_curTask->jobs; +// _foo(lname,TRANan,1); + _foo(ft_curckt->ci_curTask->jobs,JOB,-1); } ft_curckt->ci_curTask->jobs->JOBname = NULL; // ckt->CKTcurJob = (&(ft_curckt->ci_curTask->taskOptions)) -> jobs; @@ -1536,6 +1546,14 @@ do {\ _foo(ckt->CKTstat,STATistics,1); + +#ifdef XSPICE + _foo(ckt->evt,Evt_Ckt_Data_t,1); + _foo(ckt->enh,Enh_Ckt_Data_t,1); + g_mif_info.breakpoint.current = ckt->enh->breakpoint.current; + g_mif_info.breakpoint.last = ckt->enh->breakpoint.last; +#endif + tfree(my_ckt); fclose(file); @@ -1656,12 +1674,12 @@ void com_savesnap(wordlist *wl) _foo(ckt->CKTirhs,double,size); _foo(ckt->CKTirhsOld,double,size); _foo(ckt->CKTirhsSpare,double,size); - _foo(ckt->CKTrhsOp,double,size); - _foo(ckt->CKTsenRhs,double,size); - _foo(ckt->CKTseniRhs,double,size); +// _foo(ckt->CKTrhsOp,double,size); +// _foo(ckt->CKTsenRhs,double,size); +// _foo(ckt->CKTseniRhs,double,size); - _foo(ckt->CKTtimePoints,double,ckt->CKTtimeListSize); - _foo(ckt->CKTdeltaList,double,ckt->CKTtimeListSize); +// _foo(ckt->CKTtimePoints,double,ckt->CKTtimeListSize); +// _foo(ckt->CKTdeltaList,double,ckt->CKTtimeListSize); /* need to save the breakpoints, or something */ @@ -1686,6 +1704,10 @@ void com_savesnap(wordlist *wl) _foo(ckt->CKTstat,STATistics,1); +#ifdef XSPICE + _foo(ckt->evt,Evt_Ckt_Data_t,1); + _foo(ckt->enh,Enh_Ckt_Data_t,1); +#endif fclose(file); diff --git a/src/include/ngspice/smpdefs.h b/src/include/ngspice/smpdefs.h index f95c41897..ecaebf101 100644 --- a/src/include/ngspice/smpdefs.h +++ b/src/include/ngspice/smpdefs.h @@ -30,7 +30,7 @@ int SMPmatSize( SMPmatrix *); int SMPnewMatrix( SMPmatrix ** ); void SMPdestroy( SMPmatrix *); int SMPpreOrder( SMPmatrix *); -void SMPprint( SMPmatrix * , FILE *); +void SMPprint( SMPmatrix * , char *); void SMPgetError( SMPmatrix *, int *, int *); int SMPcProdDiag( SMPmatrix *, SPcomplex *, int *); int SMPcDProd(SMPmatrix *Matrix, SPcomplex *pMantissa, int *pExponent); diff --git a/src/maths/sparse/spoutput.c b/src/maths/sparse/spoutput.c index df2fbb7a3..10bc98c60 100644 --- a/src/maths/sparse/spoutput.c +++ b/src/maths/sparse/spoutput.c @@ -55,7 +55,10 @@ int Printer_Width = PRINTER_WIDTH; - +#include "ngspice/config.h" +#ifdef HAS_WINDOWS +#include "ngspice/wstdio.h" +#endif diff --git a/src/maths/sparse/spsmp.c b/src/maths/sparse/spsmp.c index 70fa32760..8e6b880da 100644 --- a/src/maths/sparse/spsmp.c +++ b/src/maths/sparse/spsmp.c @@ -280,13 +280,14 @@ SMPpreOrder(SMPmatrix *Matrix) /* * SMPprint() */ -/*ARGSUSED*/ -void -SMPprint(SMPmatrix *Matrix, FILE *File) -{ - NG_IGNORE(File); - spPrint( Matrix, 0, 1, 1 ); +void +SMPprint(SMPmatrix *Matrix, char *Filename) +{ + if (Filename) + spFileMatrix(Matrix, Filename, "Circuit Matrix", 0, 1, 1 ); + else + spPrint( Matrix, 0, 1, 1 ); } /* diff --git a/src/spicelib/analysis/cktpzstr.c b/src/spicelib/analysis/cktpzstr.c index fe9b18469..595da3f7c 100644 --- a/src/spicelib/analysis/cktpzstr.c +++ b/src/spicelib/analysis/cktpzstr.c @@ -698,7 +698,7 @@ CKTpzRunTrial(CKTcircuit *ckt, PZtrial **new_trialp, PZtrial **set) #ifdef PZDEBUG DEBUG(3) { printf("Factored:\n"); - SMPprint(ckt->CKTmatrix, stdout); + SMPprint(ckt->CKTmatrix, NULL); } #endif error = SMPcDProd(ckt->CKTmatrix, &new_trial->f_raw, diff --git a/src/spicelib/devices/txl/txlload.c b/src/spicelib/devices/txl/txlload.c index e3e67ac66..28407910a 100644 --- a/src/spicelib/devices/txl/txlload.c +++ b/src/spicelib/devices/txl/txlload.c @@ -48,7 +48,7 @@ TXLload(GENmodel *inModel, CKTcircuit *ckt) /* debug printf("before txlload\n"); - SMPprint(ckt->CKTmatrix, stdout); + SMPprint(ckt->CKTmatrix, NULL); */ h = ckt->CKTdelta; @@ -254,7 +254,7 @@ TXLload(GENmodel *inModel, CKTcircuit *ckt) /* debug printf("after txlload\n"); - SMPprint(ckt->CKTmatrix, stdout); + SMPprint(ckt->CKTmatrix, NULL); */ return(OK);