main.c, suppress progress report when '-o' is used to redirect output

This commit is contained in:
h_vogt 2013-12-30 14:34:07 +01:00 committed by rlar
parent 2355bfc0ff
commit e2f3ea24c0
2 changed files with 37 additions and 25 deletions

View File

@ -57,14 +57,18 @@ static bool name_eq(char *n1, char *n2);
static bool getSpecial(dataDesc *desc, runDesc *run, IFvalue *val);
static void freeRun(runDesc *run);
/*Output data to spice module saj*/
/*Output data to spice module*/
#ifdef TCL_MODULE
#include "ngspice/tclspice.h"
#elif defined SHARED_MODULE
extern int sh_ExecutePerLoop(void);
extern void sh_vecinit(runDesc *run);
#endif
/*saj*/
/*Suppressing progress info in -o option */
#ifndef HAS_WINGUI
extern bool orflag;
#endif
#define DOUBLE_PRECISION 15
@ -465,11 +469,13 @@ OUTpData(runDesc *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
every quarter of a second, to give some feedback without using
too much CPU time */
#ifndef HAS_WINGUI
currclock = clock();
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
fprintf(stderr, " Reference value : % 12.5e\r",
refValue->cValue.real);
lastclock = currclock;
if (!orflag) {
currclock = clock();
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
fprintf(stderr, " Reference value : % 12.5e\r",
refValue->cValue.real);
lastclock = currclock;
}
}
#endif
} else {
@ -478,11 +484,13 @@ OUTpData(runDesc *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
fileAddRealValue(run->fp, run->binary, refValue->rValue);
#ifndef HAS_WINGUI
currclock = clock();
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
fprintf(stderr, " Reference value : % 12.5e\r",
refValue->rValue);
lastclock = currclock;
if (!orflag) {
currclock = clock();
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
fprintf(stderr, " Reference value : % 12.5e\r",
refValue->rValue);
lastclock = currclock;
}
}
#endif
}
@ -559,16 +567,18 @@ OUTpData(runDesc *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
variable just the same */
#ifndef HAS_WINGUI
currclock = clock();
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
if (run->isComplex) {
fprintf(stderr, " Reference value : % 12.5e\r",
refValue ? refValue->cValue.real : NAN);
} else {
fprintf(stderr, " Reference value : % 12.5e\r",
refValue ? refValue->rValue : NAN);
if (!orflag) {
currclock = clock();
if ((currclock-lastclock) > (0.25*CLOCKS_PER_SEC)) {
if (run->isComplex) {
fprintf(stderr, " Reference value : % 12.5e\r",
refValue ? refValue->cValue.real : NAN);
} else {
fprintf(stderr, " Reference value : % 12.5e\r",
refValue ? refValue->rValue : NAN);
}
lastclock = currclock;
}
lastclock = currclock;
}
#endif

View File

@ -100,6 +100,8 @@ char *ft_rawfile = "rawspice.raw";
extern void SetSource( char *Name); /* display the source file name in the source window */
extern int xmain(int argc, char **argv);
FILE *flogp = NULL; /* log file ('-o logfile' command line option) */
#else
bool orflag = FALSE; /* global for -o option */
#endif
FILE *slogp = NULL; /* soa log file ('--soa-log file' command line option) */
@ -803,7 +805,7 @@ main(int argc, char **argv)
bool qflag = FALSE;
FILE * volatile circuit_file;
bool orflag = FALSE;
bool oflag = FALSE;
bool srflag = FALSE;
#ifdef TRACE
@ -942,7 +944,7 @@ main(int argc, char **argv)
/* switch to line buffering for stdout */
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
sprintf (log_file, "%s", optarg);
orflag = TRUE;
oflag = TRUE;
}
break;
@ -989,7 +991,7 @@ main(int argc, char **argv)
} /* --- End of command line option processing (While(1)-loop) --- */
if (orflag) { /* -o option has been set */
if (oflag) { /* -o option has been set */
com_version(NULL);
@ -1013,8 +1015,8 @@ main(int argc, char **argv)
perror (log_file);
sp_shutdown (EXIT_BAD);
}
// oflag = TRUE; /* All further output to -o log file */
#else
orflag = TRUE;
/* Connect stdout and stderr to file log_file and log stdout */
if (!freopen (log_file, "w", stdout)) {
perror (log_file);