From 9aad956864993fefb69164cbf45aac4a674b5ed2 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Thu, 11 Jun 2009 14:12:07 +0000 Subject: [PATCH] convergence (output.net), add some comments --- ChangeLog | 6 +++ examples/TransImpedanceAmp/output.net | 3 +- src/conf.c | 2 +- src/frontend/cpitf.c | 67 +++++++++++++-------------- src/misc/ivars.c | 35 ++++++++------ 5 files changed, 64 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9641eecb8..006aa3bb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-06-11 Holger Vogt + * conf.c: editor notepad.exe also with MS Visual C++ + * /examples/TransImpedanceAmp/output.net: change integration method + to 'gear' for achieving convergence + * cpitf.c, ivars.c: add some comments + 2009-05-24 Dietmar Warning * tcl-testbench4.tcl: correct path to codemodel * FB14.cir: better breakthrough current in bas70 diff --git a/examples/TransImpedanceAmp/output.net b/examples/TransImpedanceAmp/output.net index b67071194..d223057f0 100644 --- a/examples/TransImpedanceAmp/output.net +++ b/examples/TransImpedanceAmp/output.net @@ -5,7 +5,8 @@ * Documentation at http://www.brorson.com/gEDA/SPICE/ * ********************************************************* * Command stuff -.options gmin=1e-9 noacct +.options gmin=1e-9 noacct +.options method=gear .options abstol=1e-11 * .ac dec 10 10MegHz 10 Ghz * Remainder of file diff --git a/src/conf.c b/src/conf.c index fb54eefa7..d21636156 100644 --- a/src/conf.c +++ b/src/conf.c @@ -18,7 +18,7 @@ char Spice_Build_Date[] = NGSPICEBUILDDATE; char *Spice_Exec_Dir = NGSPICEBINDIR; char *Spice_Lib_Dir = NGSPICEDATADIR; -#ifdef __MINGW32__ +#if defined (__MINGW32__) || defined (_MSC_VER) char *Def_Editor = "notepad.exe"; #else char *Def_Editor = "vi"; diff --git a/src/frontend/cpitf.c b/src/frontend/cpitf.c index 7d35a019a..ff43b182c 100644 --- a/src/frontend/cpitf.c +++ b/src/frontend/cpitf.c @@ -206,47 +206,46 @@ ft_cpinit(void) /* Reset this for the front end. */ cp_hash = '*'; + /* NGSPICEDATADIR has been set to path "$dprefix/share/ngspice" in configure.in, + Spice_Lib_Dir has been set to NGSPICEDATADIR in conf.c, + Lib_Path has been set to Spice_Lib_Dir adding /scripts in ivars() */ if (Lib_Path && *Lib_Path) { - (void) sprintf(buf, "sourcepath = ( %s %s )", DIR_CWD, Lib_Path); + (void) sprintf(buf, "sourcepath = ( %s %s )", DIR_CWD, Lib_Path); wl = cp_doglob(cp_lexer(buf)); - cp_striplist(wl); - com_set(wl); + cp_striplist(wl); + com_set(wl); wl_free(wl); - /* Now source the standard startup file. */ - /* XXX strange */ + + /* Now source the standard startup file. */ - for (copys=s=cp_tildexpand(Lib_Path); copys && *copys; ) {/*DG*/ - while (isspace(*s)) - s++; - for (r = buf; *s && !isspace(*s); r++, s++) - *r = *s; - tfree(copys); /* sjb - it's safe to free this here */ - (void) strcpy(r, DIR_PATHSEP); + /* remove leading spaces */ + for (copys=s=cp_tildexpand(Lib_Path); copys && *copys; ) { + while (isspace(*s)) + s++; + /* copy s into buf until space is seen, r is the actual position */ + for (r = buf; *s && !isspace(*s); r++, s++) + *r = *s; + tfree(copys); /* sjb - it's safe to free this here */ + /* add a path separator to buf at actual position */ + (void) strcpy(r, DIR_PATHSEP); #ifdef TCL_MODULE - (void) strcat(r, "tclspinit"); + /* add "tclspinit" to buf after actual position */ + (void) strcat(r, "tclspinit"); #else - (void) strcat(r, "spinit"); + /* add "spinit" to buf after actual position */ + (void) strcat(r, "spinit"); #endif - if ((fp = fopen(buf, "r"))) { - cp_interactive = FALSE; - inp_spsource(fp, TRUE, buf); - cp_interactive = TRUE; - - /* the following caused me SIGSEGV's since inp_spsource - already closes fp - A. Veliath 12/7/97 - - MW. Its really needed - I changed inp_spsource to - close fp always. */ - - /* (void) fclose(fp); */ - - found = TRUE; - break; - } else if (ft_controldb) - fprintf(cp_err, "Note: can't open \"%s\".\n", buf); - } - if (!found) - fprintf(cp_err, "Note: can't find init file.\n"); + if ((fp = fopen(buf, "r"))) { + cp_interactive = FALSE; + inp_spsource(fp, TRUE, buf); + cp_interactive = TRUE; + found = TRUE; + break; + } else if (ft_controldb) + fprintf(cp_err, "Note: can't open \"%s\".\n", buf); + } + if (!found) + fprintf(cp_err, "Note: can't find init file.\n"); } tcap_init( ); diff --git a/src/misc/ivars.c b/src/misc/ivars.c index 907cd5415..868ff5532 100644 --- a/src/misc/ivars.c +++ b/src/misc/ivars.c @@ -21,7 +21,7 @@ env_overr(char **v, char *e) { char *p; if (v && e && (p = getenv(e))) - *v = p; + *v = p; } static void @@ -39,15 +39,15 @@ mkvar(char **p, char *path_prefix, char *var_dir, char *env_var) asprintf(p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); #else /* ~ HAVE_ASPRINTF */ if (buffer){ - *p = (char *) tmalloc(strlen(buffer)+1); - sprintf(*p,"%s",buffer); - /* asprintf(p, "%s", buffer); */ + *p = (char *) tmalloc(strlen(buffer)+1); + sprintf(*p,"%s",buffer); + /* asprintf(p, "%s", buffer); */ } else{ - *p = (char *) tmalloc(strlen(path_prefix) + - strlen(DIR_PATHSEP) + strlen(var_dir) + 1); - sprintf(*p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); - /* asprintf(p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); */ + *p = (char *) tmalloc(strlen(path_prefix) + + strlen(DIR_PATHSEP) + strlen(var_dir) + 1); + sprintf(*p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); + /* asprintf(p, "%s%s%s", path_prefix, DIR_PATHSEP, var_dir); */ } #endif /* HAVE_ASPRINTF */ } @@ -55,24 +55,33 @@ mkvar(char **p, char *path_prefix, char *var_dir, char *env_var) void ivars(void) { - char *temp=NULL; - + /* $dprefix has been set to /usr/local or C:/Spice (Windows) in configure.in, + NGSPICEBINDIR has been set to $dprefix/bin in configure.in, + Spice_Exec_Dir has been set to NGSPICEBINDIR in conf.c, + may be overridden here by environmental variable SPICE_EXEC_DIR */ env_overr(&Spice_Exec_Dir, "SPICE_EXEC_DIR"); env_overr(&Spice_Lib_Dir, "SPICE_LIB_DIR"); - + /* for printing a news file */ mkvar(&News_File, Spice_Lib_Dir, "news", "SPICE_NEWS"); + /* not used in ngspice */ mkvar(&Default_MFB_Cap, Spice_Lib_Dir, "mfbcap", "SPICE_MFBCAP"); + /* help directory, not used in Windows mode */ mkvar(&Help_Path, Spice_Lib_Dir, "helpdir", "SPICE_HELP_DIR"); + /* where spinit is found */ mkvar(&Lib_Path, Spice_Lib_Dir, "scripts", "SPICE_SCRIPTS"); + /* used to call ngspice with aspice command, not used in Windows mode */ mkvar(&Spice_Path, Spice_Exec_Dir, "ngspice", "SPICE_PATH"); - env_overr(&Spice_Host, "SPICE_HOST"); + env_overr(&Spice_Host, "SPICE_HOST"); /* aspice */ env_overr(&Bug_Addr, "SPICE_BUGADDR"); env_overr(&Def_Editor, "SPICE_EDITOR"); - env_overr(&temp, "SPICE_ASCIIRAWFILE"); + /* Set raw file mode, 0 by default (binary) set in conf.c, + may be overridden by environmental + variable, not sure if acknowledged everywhere in ngspice */ + env_overr(&temp, "SPICE_ASCIIRAWFILE"); if(temp) AsciiRawFile = atoi(temp);