From c6d0f807b569bdf6ab6e9ed0665ca81d80f1d3d5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 23 Jun 2019 14:13:24 -0400 Subject: [PATCH] output messages that would otherwise only show up in logs only when logs are enable for screen or logfile --- src/KIM/kim_init.cpp | 16 ++++++++-------- src/KIM/kim_interactions.cpp | 4 ++-- src/input.h | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/KIM/kim_init.cpp b/src/KIM/kim_init.cpp index 1ca55d7adc..ce1b944792 100644 --- a/src/KIM/kim_init.cpp +++ b/src/KIM/kim_init.cpp @@ -363,8 +363,8 @@ void KimInit::kim_init_log_delimiter(std::string const begin_end) const mesg = "#=== END kim-init ============================================\n\n"; - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); + if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); + if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); } } @@ -411,8 +411,8 @@ void KimInit::do_variables(char *user_units, char *model_units) mesg += " to "; mesg += to; mesg += ":\n"; - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); + if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); + if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); } for (int i = 0; i < nunits; i++) { @@ -441,12 +441,12 @@ void KimInit::do_variables(char *user_units, char *model_units) << " internal " << std::setprecision(12) << std::scientific << conversion_factor << std::endl; - if (screen) fputs(mesg.str().c_str(),screen); - if (logfile) fputs(mesg.str().c_str(),logfile); + if ((screen) && (input->echo_screen)) fputs(mesg.str().c_str(),screen); + if ((logfile) && (input->echo_log)) fputs(mesg.str().c_str(),logfile); } } if (comm->me == 0) { - if (screen) fputs("#\n",screen); - if (logfile) fputs("#\n",logfile); + if ((screen) && (input->echo_screen)) fputs("#\n",screen); + if ((logfile) && (input->echo_log)) fputs("#\n",logfile); } } diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 491d406ae6..4771272ff8 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -109,8 +109,8 @@ void KimInteractions::kim_interactions_log_delimiter( mesg = "#=== END kim_interactions ====================================\n\n"; - if (screen) fputs(mesg.c_str(),screen); - if (logfile) fputs(mesg.c_str(),logfile); + if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen); + if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile); } } diff --git a/src/input.h b/src/input.h index 47ad7779f1..ebd015619c 100644 --- a/src/input.h +++ b/src/input.h @@ -25,6 +25,8 @@ class Input : protected Pointers { friend class Info; friend class Error; friend class Deprecated; + friend class KimInit; + friend class KimInteractions; public: int narg; // # of command args @@ -42,14 +44,14 @@ class Input : protected Pointers { protected: char *command; // ptr to current command + int echo_screen; // 0 = no, 1 = yes + int echo_log; // 0 = no, 1 = yes private: int me; // proc ID int maxarg; // max # of args in arg char *line,*copy,*work; // input line & copy and work string int maxline,maxcopy,maxwork; // max lengths of char strings - int echo_screen; // 0 = no, 1 = yes - int echo_log; // 0 = no, 1 = yes int nfile,maxfile; // current # and max # of open input files int label_active; // 0 = no label, 1 = looking for label char *labelstr; // label string being looked for