Browse Source

command 'remcir' to remove a circuit updated

h_vogt 15 years ago
parent
commit
f82ec99542
  1. 3
      ChangeLog
  2. 242
      src/frontend/runcoms2.c

3
ChangeLog

@ -1,3 +1,6 @@
2011-11-27 Holger Vogt
* /frontend/runcoms2.c: command 'remcir' to remove a circuit.
2011-11-26 Holger Vogt
* /frontend/plotting/gnuplot.c: appendwrite and complex
variable printing added.

242
src/frontend/runcoms2.c

@ -43,125 +43,124 @@ bool resumption = FALSE;
void
com_resume(wordlist *wl)
{
struct dbcomm *db;
int err;
/*rawfile output saj*/
bool dofile = FALSE;
char buf[BSIZE_SP];
bool ascii = AsciiRawFile;
/*end saj*/
NG_IGNORE(wl);
/*saj fix segment*/
if (!ft_curckt) {
fprintf(cp_err, "Error: there aren't any circuits loaded.\n");
return;
} else if (ft_curckt->ci_ckt == NULL) { /* Set noparse? */
fprintf(cp_err, "Error: circuit not parsed.\n");
return;
}
/*saj*/
if (ft_curckt->ci_inprogress == FALSE) {
fprintf(cp_err, "Note: run starting\n");
com_run(NULL);
return;
}
ft_curckt->ci_inprogress = TRUE;
ft_setflag = TRUE;
reset_trace( );
for ( db = dbs, resumption = FALSE; db; db = db->db_next )
if( db->db_type == DB_IPLOT || db->db_type == DB_IPLOTALL ) {
resumption = TRUE;
}
/*rawfile output saj*/
if (last_used_rawfile)
dofile = TRUE;
if (cp_getvar("filetype", CP_STRING, buf)) {
if (eq(buf, "binary"))
ascii = FALSE;
else if (eq(buf, "ascii"))
ascii = TRUE;
else
fprintf(cp_err,
"Warning: strange file type \"%s\" (using \"ascii\")\n",
buf);
}
if (dofile) {
struct dbcomm *db;
int err;
/*rawfile output saj*/
bool dofile = FALSE;
char buf[BSIZE_SP];
bool ascii = AsciiRawFile;
/*end saj*/
NG_IGNORE(wl);
/*saj fix segment*/
if (!ft_curckt) {
fprintf(cp_err, "Error: there aren't any circuits loaded.\n");
return;
} else if (ft_curckt->ci_ckt == NULL) { /* Set noparse? */
fprintf(cp_err, "Error: circuit not parsed.\n");
return;
}
/*saj*/
if (ft_curckt->ci_inprogress == FALSE) {
fprintf(cp_err, "Note: run starting\n");
com_run(NULL);
return;
}
ft_curckt->ci_inprogress = TRUE;
ft_setflag = TRUE;
reset_trace( );
for ( db = dbs, resumption = FALSE; db; db = db->db_next )
if( db->db_type == DB_IPLOT || db->db_type == DB_IPLOTALL ) {
resumption = TRUE;
}
/*rawfile output saj*/
if (last_used_rawfile)
dofile = TRUE;
if (cp_getvar("filetype", CP_STRING, buf)) {
if (eq(buf, "binary"))
ascii = FALSE;
else if (eq(buf, "ascii"))
ascii = TRUE;
else
fprintf(cp_err,
"Warning: strange file type \"%s\" (using \"ascii\")\n",
buf);
}
if (dofile) {
#ifdef PARALLEL_ARCH
if (ARCHme == 0) {
if (ARCHme == 0) {
#endif /* PARALLEL_ARCH */
if (!last_used_rawfile)
rawfileFp = stdout;
if (!last_used_rawfile)
rawfileFp = stdout;
#if defined(__MINGW32__) || defined(_MSC_VER)
/* ask if binary or ASCII, open file with w or wb hvogt 15.3.2000 */
else if (ascii) {
if((rawfileFp = fopen(last_used_rawfile, "a")) == NULL) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
return;
}
}
else if (!ascii) {
if((rawfileFp = fopen(last_used_rawfile, "ab")) == NULL) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
return;
/* ask if binary or ASCII, open file with w or wb hvogt 15.3.2000 */
else if (ascii) {
if((rawfileFp = fopen(last_used_rawfile, "a")) == NULL) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
return;
}
} else if (!ascii) {
if((rawfileFp = fopen(last_used_rawfile, "ab")) == NULL) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
return;
}
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
#else
else if (!(rawfileFp = fopen(last_used_rawfile, "a"))) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
return;
}
else if (!(rawfileFp = fopen(last_used_rawfile, "a"))) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
return;
}
#endif
#ifdef PARALLEL_ARCH
} else {
rawfileFp = NULL;
}
} else {
rawfileFp = NULL;
}
#endif /* PARALLEL_ARCH */
rawfileBinary = !ascii;
} else {
rawfileFp = NULL;
} /* if dofile */
rawfileBinary = !ascii;
} else {
rawfileFp = NULL;
} /* if dofile */
/*end saj*/
err = if_run(ft_curckt->ci_ckt, "resume", NULL,
ft_curckt->ci_symtab);
/*close rawfile saj*/
if (rawfileFp){
if (ftell(rawfileFp)==0) {
(void) fclose(rawfileFp);
(void) unlink(last_used_rawfile);
} else {
(void) fclose(rawfileFp);
}
}
/*end saj*/
if (err == 1) {
/* The circuit was interrupted somewhere. */
fprintf(cp_err, "simulation interrupted\n");
} else if (err == 2) {
fprintf(cp_err, "simulation aborted\n");
ft_curckt->ci_inprogress = FALSE;
} else
ft_curckt->ci_inprogress = FALSE;
return;
err = if_run(ft_curckt->ci_ckt, "resume", NULL,
ft_curckt->ci_symtab);
/*close rawfile saj*/
if (rawfileFp) {
if (ftell(rawfileFp)==0) {
(void) fclose(rawfileFp);
(void) unlink(last_used_rawfile);
} else {
(void) fclose(rawfileFp);
}
}
/*end saj*/
if (err == 1) {
/* The circuit was interrupted somewhere. */
fprintf(cp_err, "simulation interrupted\n");
} else if (err == 2) {
fprintf(cp_err, "simulation aborted\n");
ft_curckt->ci_inprogress = FALSE;
} else
ft_curckt->ci_inprogress = FALSE;
return;
}
/* Throw out the circuit struct and recreate it from the deck. This command
@ -179,20 +178,22 @@ com_rset(wordlist *wl)
fprintf(cp_err, "Error: there is no circuit loaded.\n");
return;
}
INPkillMods();
INPkillMods();
if_cktfree(ft_curckt->ci_ckt, ft_curckt->ci_symtab);
for (v = ft_curckt->ci_vars; v; v = next) {
next = v->va_next;
tfree(v);
next = v->va_next;
tfree(v);
}
ft_curckt->ci_vars = NULL;
inp_dodeck(ft_curckt->ci_deck, ft_curckt->ci_name, NULL,
TRUE, ft_curckt->ci_options, ft_curckt->ci_filename);
TRUE, ft_curckt->ci_options, ft_curckt->ci_filename);
return;
}
/* Clears ckt and removes current circuit from database */
void
com_remcirc(wordlist *wl)
{
@ -207,17 +208,23 @@ com_remcirc(wordlist *wl)
return;
}
/* The next lines stem from com_rset */
INPkillMods();
INPkillMods();
if_cktfree(ft_curckt->ci_ckt, ft_curckt->ci_symtab);
for (v = ft_curckt->ci_vars; v; v = next) {
next = v->va_next;
tfree(v);
next = v->va_next;
tfree(v);
}
ft_curckt->ci_vars = NULL;
/* delete the deck in ft_curckt */
/* delete the deck and parameter list in ft_curckt */
dd = ft_curckt->ci_deck;
line_free(dd,TRUE);
dd = ft_curckt->ci_param;
line_free(dd,TRUE);
tfree(ft_curckt->FTEstats);
tfree(ft_curckt->ci_defTask);
if (ft_curckt->ci_name)
tfree(ft_curckt->ci_name);
if (ft_curckt->ci_filename)
@ -231,8 +238,7 @@ com_remcirc(wordlist *wl)
tfree(p);
p = NULL;
break;
}
else {
} else {
prev->ci_next = p->ci_next;
tfree(p);
p = NULL;

Loading…
Cancel
Save