Browse Source

Unify batch mode and control mode raw file output:

Voltage is always named as v(nodename)
pre-master-46
Holger Vogt 6 years ago
parent
commit
064bd39a2f
  1. 6
      src/frontend/outitf.c
  2. 16
      src/frontend/rawfile.c

6
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 static void
fileInit(runDesc *run) fileInit(runDesc *run)
{ {

16
src/frontend/rawfile.c

@ -33,8 +33,9 @@ int raw_prec = -1; /* How many sigfigs to use, default 15 (max). */
#endif #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) void raw_write(char *name, struct plot *pl, bool app, bool binary)
{ {
FILE *fp; FILE *fp;
@ -153,17 +154,26 @@ void raw_write(char *name, struct plot *pl, bool app, bool binary)
fprintf(fp, "Variables:\n"); fprintf(fp, "Variables:\n");
for (i = 0, v = pl->pl_dvecs; v; v = v->v_next) { 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) { if (v->v_type == SV_CURRENT) {
branch = NULL; branch = NULL;
/* get name only*/
if ((branch = strstr(v->v_name, "#branch")) != NULL) { if ((branch = strstr(v->v_name, "#branch")) != NULL) {
*branch = '\0'; *branch = '\0';
} }
fprintf(fp, "\t%d\ti(%s)\t%s", i++, v->v_name, ft_typenames(v->v_type)); fprintf(fp, "\t%d\ti(%s)\t%s", i++, v->v_name, ft_typenames(v->v_type));
/* restore name#branch */
if (branch != NULL) *branch = '#'; if (branch != NULL) *branch = '#';
} }
/* write v(name)*/
else if (v->v_type == SV_VOLTAGE) { 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 { else {
fprintf(fp, "\t%d\t%s\t%s", i++, v->v_name, ft_typenames(v->v_type)); fprintf(fp, "\t%d\t%s\t%s", i++, v->v_name, ft_typenames(v->v_type));
} }

Loading…
Cancel
Save