Unverified Commit 6fc5810b authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

with the refactored include handling we can allow include in if/then/else

parent 7547e1da
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -57,8 +57,7 @@ Boolean expression is FALSE, then no commands are executed.
The syntax for Boolean expressions is described below.

Each command (t1, f1, e1, etc) can be any valid LAMMPS input script
command, except an "include"_include.html command, which is not
allowed.  If the command is more than one word, it must enclosed in
command.  If the command is more than one word, it must enclosed in
quotes, so it will be treated as a single argument, as in the examples
above.

+8 −20
Original line number Diff line number Diff line
@@ -82,7 +82,6 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp)
  label_active = 0;
  labelstr = NULL;
  jump_skip = 0;
  ifthenelse_flag = 0;

  if (me == 0) {
    nfile = maxfile = 1;
@@ -962,11 +961,10 @@ void Input::ifthenelse()
      ncommands++;
    }

    ifthenelse_flag = 1;
    for (int i = 0; i < ncommands; i++) one(commands[i]);
    ifthenelse_flag = 0;

    for (int i = 0; i < ncommands; i++) delete [] commands[i];
    for (int i = 0; i < ncommands; i++) {
      one(commands[i]);
      delete [] commands[i];
    }
    delete [] commands;

    return;
@@ -1018,13 +1016,10 @@ void Input::ifthenelse()

    // execute the list of commands

    ifthenelse_flag = 1;
    for (int i = 0; i < ncommands; i++) one(commands[i]);
    ifthenelse_flag = 0;

    // clean up

    for (int i = 0; i < ncommands; i++) delete [] commands[i];
    for (int i = 0; i < ncommands; i++) {
      one(commands[i]);
      delete [] commands[i];
    }
    delete [] commands;

    return;
@@ -1037,13 +1032,6 @@ void Input::include()
{
  if (narg != 1) error->all(FLERR,"Illegal include command");

  // do not allow include inside an if command
  // NOTE: this check will fail if a 2nd if command was inside the if command
  //       and came before the include

  if (ifthenelse_flag)
    error->all(FLERR,"Cannot use include command within an if command");

  if (me == 0) {
    if (nfile == maxfile) {
      maxfile++;
+0 −1
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ class Input : protected Pointers {
  int label_active;            // 0 = no label, 1 = looking for label
  char *labelstr;              // label string being looked for
  int jump_skip;               // 1 if skipping next jump, 0 otherwise
  int ifthenelse_flag;         // 1 if executing commands inside an if-then-else

  FILE **infiles;              // list of open input files