2000-04-27 22:03:57 +02:00
|
|
|
/**********
|
|
|
|
|
Copyright 1990 Regents of the University of California. All rights reserved.
|
|
|
|
|
Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|
|
|
|
**********/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* Print out in more detail what a floating point error was.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/ngspice.h"
|
|
|
|
|
#include "ngspice/cpdefs.h"
|
|
|
|
|
#include "ngspice/ftedefs.h"
|
2000-04-27 22:03:57 +02:00
|
|
|
#include <signal.h>
|
|
|
|
|
#include "error.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* global error message buffer */
|
|
|
|
|
char ErrorMessage[1024];
|
|
|
|
|
|
|
|
|
|
|
2010-01-30 14:21:27 +01:00
|
|
|
#ifdef HAS_WINDOWS
|
|
|
|
|
void winmessage(char* new_msg);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
controlled_exit(int status)
|
|
|
|
|
{
|
2011-08-10 18:39:46 +02:00
|
|
|
if (status != 0)
|
2010-01-30 14:21:27 +01:00
|
|
|
#ifdef HAS_WINDOWS
|
2011-08-10 18:39:46 +02:00
|
|
|
winmessage("Fatal error in NGSPICE");
|
2010-01-30 14:21:27 +01:00
|
|
|
#else
|
2011-08-10 18:39:46 +02:00
|
|
|
{
|
|
|
|
|
if (!ft_pipemode) {
|
|
|
|
|
fprintf(stderr, " Fatal error in NGSPICE - Press Return to exit\n");
|
|
|
|
|
getc(stdin);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fprintf(stderr, " Fatal error in NGSPICE - Exit\n");
|
|
|
|
|
}
|
2010-01-30 14:21:27 +01:00
|
|
|
#endif
|
|
|
|
|
exit(status);
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
fperror(char *mess, int code)
|
|
|
|
|
{
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(code);
|
2000-04-27 22:03:57 +02:00
|
|
|
fprintf(cp_err, "%s: floating point exception.\n", mess);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Print a spice error message. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ft_sperror(int code, char *mess)
|
|
|
|
|
{
|
|
|
|
|
fprintf(cp_err, "%s: %s\n", mess, if_errstring(code));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
fatal(void)
|
|
|
|
|
{
|
|
|
|
|
cp_ccon(FALSE);
|
|
|
|
|
#ifdef FTEDEBUG
|
|
|
|
|
#ifdef SIGQUIT
|
|
|
|
|
(void) signal(SIGQUIT, SIG_DFL);
|
|
|
|
|
(void) kill(getpid(), SIGQUIT);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
exit(EXIT_BAD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* These error messages are from internal consistency checks. */
|
|
|
|
|
void
|
|
|
|
|
internalerror(char *message)
|
|
|
|
|
{
|
|
|
|
|
|
2011-08-10 18:39:46 +02:00
|
|
|
fprintf(stderr, "ERROR: (internal) %s\n", message);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* These errors are from external routines like fopen. */
|
|
|
|
|
void
|
|
|
|
|
externalerror(char *message)
|
|
|
|
|
{
|
|
|
|
|
|
2011-08-10 18:39:46 +02:00
|
|
|
fprintf(stderr, "ERROR: (external) %s\n", message);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
}
|