Unverified Commit ea4107c4 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

add write_echo() method to Input class for logging implicit commands where the...

add write_echo() method to Input class for logging implicit commands where the echo command would send explicit ones
parent 2afc498a
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -377,8 +377,7 @@ void KimInit::kim_init_log_delimiter(std::string const begin_end) const
      mesg =
          "#=== END kim-init ============================================\n\n";

    if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen);
    if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile);
    input->write_echo(mesg.c_str());
  }
}

@@ -425,8 +424,7 @@ void KimInit::do_variables(char *user_units, char *model_units)
    mesg += " to ";
    mesg += to;
    mesg += ":\n";
    if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen);
    if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile);
    input->write_echo(mesg.c_str());
  }

  for (int i = 0; i < nunits; i++) {
@@ -455,14 +453,10 @@ void KimInit::do_variables(char *user_units, char *model_units)
           << " internal "
           << std::setprecision(12) << std::scientific << conversion_factor
           << std::endl;
      if ((screen) && (input->echo_screen)) fputs(mesg.str().c_str(),screen);
      if ((logfile) && (input->echo_log)) fputs(mesg.str().c_str(),logfile);
      input->write_echo(mesg.str().c_str());
    }
  }
  if (comm->me == 0) {
    if ((screen) && (input->echo_screen)) fputs("#\n",screen);
    if ((logfile) && (input->echo_log)) fputs("#\n",logfile);
  }
  if (comm->me == 0) input->write_echo("#\n");
}

/* ---------------------------------------------------------------------- */
+1 −2
Original line number Diff line number Diff line
@@ -106,8 +106,7 @@ void KimInteractions::kim_interactions_log_delimiter(
      mesg =
          "#=== END kim_interactions ====================================\n\n";

    if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen);
    if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile);
    input->write_echo(mesg.c_str());
  }
}

+1 −2
Original line number Diff line number Diff line
@@ -306,7 +306,6 @@ void KimQuery::echo_var_assign(std::string const & name,
  if (comm->me == 0) {
    std::string mesg;
    mesg = name + " = " + value + "\n";
    if ((screen) && (input->echo_screen)) fputs(mesg.c_str(),screen);
    if ((logfile) && (input->echo_log)) fputs(mesg.c_str(),logfile);
    input->write_echo(mesg.c_str());
  }
}
+11 −0
Original line number Diff line number Diff line
@@ -314,6 +314,17 @@ char *Input::one(const char *single)
  return command;
}

/* ----------------------------------------------------------------------
   Send text to active echo file pointers
------------------------------------------------------------------------- */
void Input::write_echo(const char *txt)
{
  if (me == 0) {
    if (echo_screen && screen) fputs(txt,screen);
    if (echo_log && logfile) fputs(txt,logfile);
  }
}

/* ----------------------------------------------------------------------
   parse copy of command line by inserting string terminators
   strip comment = all chars from # on
+2 −3
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ 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
@@ -41,6 +39,7 @@ class Input : protected Pointers {
  void substitute(char *&, char *&, int &, int &, int);
                                 // substitute for variables in a string
  int expand_args(int, char **, int, char **&);  // expand args due to wildcard
  void write_echo(const char *); // send text to active echo file pointers
  
 protected:
  char *command;               // ptr to current command