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

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