From 064bd39a2f7f70682da186c863a9369ef8036bf5 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 13 Jun 2020 18:26:21 +0200 Subject: [PATCH] Unify batch mode and control mode raw file output: Voltage is always named as v(nodename) --- src/frontend/outitf.c | 6 ++++-- src/frontend/rawfile.c | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index 3416ce3af..0304a1a42 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -845,8 +845,10 @@ OUTattributes(runDesc *plotPtr, IFuid varName, int param, IFvalue *value) } -/* The file writing routines. */ - +/* The file writing routines. + Write a raw file in batch mode (-b and -r flags). + Writing a raw file in interactive or control mode is handled + by raw_write() in rawfile.c */ static void fileInit(runDesc *run) { diff --git a/src/frontend/rawfile.c b/src/frontend/rawfile.c index 8767b0064..348011cf7 100644 --- a/src/frontend/rawfile.c +++ b/src/frontend/rawfile.c @@ -33,8 +33,9 @@ int raw_prec = -1; /* How many sigfigs to use, default 15 (max). */ #endif -/* Write a raw file. We write everything in the plot pointed to. */ - +/* Write a raw file with the 'write' command. We write everything in the plot pointed to. + Writing a raw file in batch mode is handled by fileInit_pass1() and fileInit_pass2() + in outitf.c */ void raw_write(char *name, struct plot *pl, bool app, bool binary) { FILE *fp; @@ -153,17 +154,26 @@ void raw_write(char *name, struct plot *pl, bool app, bool binary) fprintf(fp, "Variables:\n"); for (i = 0, v = pl->pl_dvecs; v; v = v->v_next) { + /* write i(name) instaed of name#branch */ if (v->v_type == SV_CURRENT) { branch = NULL; + /* get name only*/ if ((branch = strstr(v->v_name, "#branch")) != NULL) { *branch = '\0'; } fprintf(fp, "\t%d\ti(%s)\t%s", i++, v->v_name, ft_typenames(v->v_type)); + /* restore name#branch */ if (branch != NULL) *branch = '#'; } + /* write v(name)*/ else if (v->v_type == SV_VOLTAGE) { - fprintf(fp, "\t%d\t%s\t%s", i++, v->v_name, ft_typenames(v->v_type)); + /* If the node name is a number, the vector is already called v(name) */ + if (ciprefix("v(", v->v_name)) + fprintf(fp, "\t%d\t%s\t%s", i++, v->v_name, ft_typenames(v->v_type)); + else + fprintf(fp, "\t%d\tv(%s)\t%s", i++, v->v_name, ft_typenames(v->v_type)); } + /* write 'name' only for all other vector types */ else { fprintf(fp, "\t%d\t%s\t%s", i++, v->v_name, ft_typenames(v->v_type)); }