mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
first pass @ removing std::cerr, std::cout, exit, stderr, stdout from R version.
git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@8619 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
7359b9dcb6
commit
7c0b1106aa
@ -35,8 +35,10 @@ error_msg(const std::string & stdstr, int stop)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
std::cerr << msg.str().c_str();
|
||||
std::cout << msg.str().c_str();
|
||||
#endif
|
||||
}
|
||||
if (stop != 0)
|
||||
{
|
||||
@ -53,8 +55,10 @@ warning_msg(const std::string & stdstr)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
std::cerr << stdstr << "\n";
|
||||
std::cout << stdstr << "\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +71,9 @@ output_msg(const std::string & stdstr)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
std::cout << stdstr << "\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +86,9 @@ screen_msg(const std::string & stdstr)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
std::cerr << stdstr << "\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,6 +101,8 @@ echo_msg(const std::string & stdstr)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
std::cout << stdstr << "\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
16
PHRQ_io.cpp
16
PHRQ_io.cpp
@ -177,13 +177,17 @@ error_open(const char *file_name, std::ios_base::openmode mode)
|
||||
{
|
||||
if (!ofstream_open(&error_ostream, file_name, mode))
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
error_ostream = &std::cerr;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
error_ostream = &std::cerr;
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -572,9 +576,12 @@ void PHRQ_io::
|
||||
safe_close(std::ostream **stream_ptr)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
if (*stream_ptr != &std::cerr &&
|
||||
if (
|
||||
#if !defined(R_SO)
|
||||
*stream_ptr != &std::cerr &&
|
||||
*stream_ptr != &std::cout &&
|
||||
*stream_ptr != &std::clog &&
|
||||
#endif
|
||||
*stream_ptr != NULL)
|
||||
{
|
||||
delete *stream_ptr;
|
||||
@ -585,10 +592,13 @@ void PHRQ_io::
|
||||
safe_close(FILE **file_ptr)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
if (*file_ptr != NULL &&
|
||||
if (
|
||||
#if !defined(R_SO)
|
||||
*file_ptr != stderr &&
|
||||
*file_ptr != stdout &&
|
||||
*file_ptr != stdin )
|
||||
*file_ptr != stdin &&
|
||||
#endif
|
||||
*file_ptr != NULL)
|
||||
{
|
||||
fclose(*file_ptr);
|
||||
*file_ptr = NULL;
|
||||
|
||||
@ -207,7 +207,9 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie,
|
||||
try {
|
||||
if (phrq_io == NULL)
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
std::cerr << "No PHRQ_io output handler defined in process_file_names" << "\n";
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Prep for get_line
|
||||
@ -404,7 +406,9 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie,
|
||||
try {
|
||||
if (phrq_io == NULL)
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
std::cerr << "No PHRQ_io output handler defined in process_file_names" << "\n";
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Prep for get_line
|
||||
@ -599,10 +603,12 @@ open_input_stream(char *query, char *default_name, std::ios_base::openmode mode,
|
||||
strcpy(name, default_name);
|
||||
if (!batch )
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
#ifdef ERROR_OSTREAM
|
||||
phrq_io->Set_error_ostream(&std::cerr);
|
||||
#else
|
||||
phrq_io->Set_error_file(stderr);
|
||||
#endif
|
||||
#endif
|
||||
screen_msg(sformatf("%s\n", query));
|
||||
if (default_name[0] != '\0')
|
||||
@ -623,10 +629,12 @@ open_input_stream(char *query, char *default_name, std::ios_base::openmode mode,
|
||||
new_stream = new std::ifstream(name, mode);
|
||||
if (new_stream == NULL || !new_stream->is_open())
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
#ifdef ERROR_OSTREAM
|
||||
phrq_io->Set_error_ostream(&std::cerr);
|
||||
#else
|
||||
phrq_io->Set_error_file(stderr);
|
||||
#endif
|
||||
#endif
|
||||
error_string = sformatf( "\nERROR: Cannot open file, %s.\n", name);
|
||||
screen_msg(error_string);
|
||||
@ -674,10 +682,12 @@ open_output_stream(char *query, char *default_name, std::ios_base::openmode mode
|
||||
strcpy(name, default_name);
|
||||
if (!batch )
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
#ifdef ERROR_OSTREAM
|
||||
phrq_io->Set_error_ostream(&std::cerr);
|
||||
#else
|
||||
phrq_io->Set_error_file(stderr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
screen_msg(sformatf("%s\n", query));
|
||||
@ -699,10 +709,12 @@ open_output_stream(char *query, char *default_name, std::ios_base::openmode mode
|
||||
new_stream = new std::ofstream(name, mode);
|
||||
if (new_stream == NULL || !new_stream->is_open())
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
#ifdef ERROR_OSTREAM
|
||||
phrq_io->Set_error_ostream(&std::cerr);
|
||||
#else
|
||||
phrq_io->Set_error_file(stderr);
|
||||
#endif
|
||||
#endif
|
||||
error_string = sformatf( "\nERROR: Cannot open file, %s.\n", name);
|
||||
screen_msg(error_string);
|
||||
@ -747,10 +759,12 @@ open_output_file(char *query, char *default_name, std::ios_base::openmode mode,
|
||||
strcpy(name, default_name);
|
||||
if (!batch )
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
#ifdef ERROR_OSTREAM
|
||||
phrq_io->Set_error_ostream(&std::cerr);
|
||||
#else
|
||||
phrq_io->Set_error_file(stderr);
|
||||
#endif
|
||||
#endif
|
||||
screen_msg(sformatf("%s\n", query));
|
||||
if (default_name[0] != '\0')
|
||||
@ -771,10 +785,12 @@ open_output_file(char *query, char *default_name, std::ios_base::openmode mode,
|
||||
new_stream = new std::ofstream(name, mode);
|
||||
if (new_stream == NULL || !new_stream->is_open())
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
#ifdef ERROR_OSTREAM
|
||||
phrq_io->Set_error_ostream(&std::cerr);
|
||||
#else
|
||||
phrq_io->Set_error_file(stderr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
error_string = sformatf( "\nERROR: Cannot open file, %s.\n", name);
|
||||
|
||||
@ -651,7 +651,9 @@ CParser::get_option(const std::vector < std::string > &opt_list,
|
||||
std::string::iterator opt_ptr;
|
||||
std::string option;
|
||||
|
||||
#if !defined(R_SO)
|
||||
fprintf(stderr, "Did not think this get_option was called\n");
|
||||
#endif
|
||||
//
|
||||
// Read line
|
||||
//
|
||||
@ -728,7 +730,9 @@ CParser::get_option(const std::vector < std::string > &opt_list,
|
||||
{
|
||||
if (true) // database_file == NULL
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
std::cout << "\t" << m_line_save << "\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1098,7 +1102,9 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
{
|
||||
if (true) // database_file == NULL
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
std::cout << "\t" << m_line_save << "\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
cvode.cpp
15
cvode.cpp
@ -516,12 +516,16 @@ CVodeMalloc(integertype N, RhsFn f, realtype t0, N_Vector y0,
|
||||
booleantype allocOK, ioptExists, roptExists, neg_abstol, ewtsetOK;
|
||||
int maxord;
|
||||
CVodeMem cv_mem;
|
||||
#if !defined(R_SO)
|
||||
FILE *fp;
|
||||
#endif
|
||||
int i, k;
|
||||
|
||||
/* Check for legal input parameters */
|
||||
|
||||
#if !defined(R_SO)
|
||||
fp = (errfp == NULL) ? stdout : errfp;
|
||||
#endif
|
||||
|
||||
if (y0 == NULL)
|
||||
{
|
||||
@ -659,7 +663,9 @@ CVodeMalloc(integertype N, RhsFn f, realtype t0, N_Vector y0,
|
||||
cv_mem->cv_optIn = optIn;
|
||||
cv_mem->cv_iopt = iopt;
|
||||
cv_mem->cv_ropt = ropt;
|
||||
#if !defined(R_SO)
|
||||
cv_mem->cv_errfp = fp;
|
||||
#endif
|
||||
tn = t0;
|
||||
machenv = machEnv;
|
||||
|
||||
@ -789,11 +795,14 @@ CVReInit(void *cvode_mem, RhsFn f, realtype t0, N_Vector y0,
|
||||
booleantype ioptExists, roptExists, neg_abstol, ewtsetOK;
|
||||
int maxord, i, k;
|
||||
CVodeMem cv_mem;
|
||||
#if !defined(R_SO)
|
||||
FILE *fp;
|
||||
|
||||
#endif
|
||||
/* Check for legal input parameters */
|
||||
|
||||
#if !defined(R_SO)
|
||||
fp = (errfp == NULL) ? stdout : errfp;
|
||||
#endif
|
||||
|
||||
if (cvode_mem == NULL)
|
||||
{
|
||||
@ -916,7 +925,9 @@ CVReInit(void *cvode_mem, RhsFn f, realtype t0, N_Vector y0,
|
||||
cv_mem->cv_optIn = optIn;
|
||||
cv_mem->cv_iopt = iopt;
|
||||
cv_mem->cv_ropt = ropt;
|
||||
#if !defined(R_SO)
|
||||
cv_mem->cv_errfp = fp;
|
||||
#endif
|
||||
tn = t0;
|
||||
machenv = machEnv;
|
||||
|
||||
@ -3079,7 +3090,9 @@ CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr, int *kflagPtr,
|
||||
CVMEM warning_msg("CVDoErrorTest");
|
||||
/*exit(8); */
|
||||
CVMEM error_msg("CVDoErrorTest", 1 /* STOP */ );
|
||||
#if !defined(R_SO)
|
||||
exit(4);
|
||||
#endif
|
||||
}
|
||||
nfe++;
|
||||
N_VScale(h, tempv, zn[1]);
|
||||
|
||||
2
cvode.h
2
cvode.h
@ -706,7 +706,9 @@
|
||||
|
||||
/* Error File */
|
||||
|
||||
#if !defined(R_SO)
|
||||
FILE *cv_errfp; /* CVODE error messages are sent to errfp */
|
||||
#endif
|
||||
|
||||
/* Pointer to Machine Environment-Specific Information */
|
||||
|
||||
|
||||
@ -247,7 +247,11 @@ RESTART: // if limiting rates, jump to here
|
||||
}
|
||||
if (count > 2)
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
fprintf(stderr, "Too many limit_rates-.\n");
|
||||
#else
|
||||
error_msg("Too many limit_rates-.\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -256,7 +260,11 @@ RESTART: // if limiting rates, jump to here
|
||||
}
|
||||
if (count > 2)
|
||||
{
|
||||
#if !defined(R_SO)
|
||||
fprintf(stderr, "Too many limit_rates+.\n");
|
||||
#else
|
||||
error_msg("Too many limit_rates+.\n");
|
||||
#endif
|
||||
}
|
||||
return (OK);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user