diff --git a/src/input.cpp b/src/input.cpp index 98c5de8ed068c1ca588fc91e008639d184b5f398..c9d0721712e54e503f6f31517855f4b2fb996866 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -391,6 +391,7 @@ int Input::execute_command() if (!strcmp(command,"clear")) clear(); else if (!strcmp(command,"echo")) echo(); + else if (!strcmp(command,"if")) ifthenelse(); else if (!strcmp(command,"include")) include(); else if (!strcmp(command,"jump")) jump(); else if (!strcmp(command,"label")) label(); @@ -416,6 +417,7 @@ int Input::execute_command() else if (!strcmp(command,"dipole")) dipole(); else if (!strcmp(command,"dump")) dump(); else if (!strcmp(command,"dump_modify")) dump_modify(); + // else if (!strcmp(command,"ellipsoid")) ellipsoid(); else if (!strcmp(command,"fix")) fix(); else if (!strcmp(command,"fix_modify")) fix_modify(); else if (!strcmp(command,"group")) group_command(); @@ -503,6 +505,39 @@ void Input::echo() /* ---------------------------------------------------------------------- */ +void Input::ifthenelse() +{ + if (narg != 5 && narg != 7) error->all("Illegal if command"); + + int flag = 0; + if (strcmp(arg[1],"==") == 0) { + if (atof(arg[0]) == atof(arg[2])) flag = 1; + } else if (strcmp(arg[1],"!=") == 0) { + if (atof(arg[0]) != atof(arg[2])) flag = 1; + } else if (strcmp(arg[1],"<") == 0) { + if (atof(arg[0]) < atof(arg[2])) flag = 1; + } else if (strcmp(arg[1],"<=") == 0) { + if (atof(arg[0]) <= atof(arg[2])) flag = 1; + } else if (strcmp(arg[1],">") == 0) { + if (atof(arg[0]) > atof(arg[2])) flag = 1; + } else if (strcmp(arg[1],">=") == 0) { + if (atof(arg[0]) >= atof(arg[2])) flag = 1; + } else error->all("Illegal if command"); + + if (strcmp(arg[3],"then") != 0) error->all("Illegal if command"); + if (narg == 7 && strcmp(arg[5],"else") != 0) + error->all("Illegal if command"); + + char str[128] = "\0"; + if (flag) strcpy(str,arg[4]); + else if (narg == 7) strcpy(str,arg[6]); + strcat(str,"\n"); + + if (strlen(str) > 1) char *tmp = one(str); +} + +/* ---------------------------------------------------------------------- */ + void Input::include() { if (narg != 1) error->all("Illegal include command"); @@ -789,6 +824,18 @@ void Input::dump_modify() /* ---------------------------------------------------------------------- */ +/* +void Input::ellipsoid() +{ + if (narg != 4) error->all("Illegal ellipsoid command"); + if (domain->box_exist == 0) + error->all("Ellipsoid command before simulation box is defined"); + atom->set_radii3(narg,arg); +} +*/ + +/* ---------------------------------------------------------------------- */ + void Input::fix() { modify->add_fix(narg,arg); diff --git a/src/input.h b/src/input.h index 30971c3b52253c5a770a92adcc8b828a8c38df1a..1ee2ce28b20b88d3d157f980c358f0503c5afc52 100644 --- a/src/input.h +++ b/src/input.h @@ -52,6 +52,7 @@ class Input : protected Pointers { void clear(); // input script commands void echo(); + void ifthenelse(); void include(); void jump(); void label(); @@ -77,6 +78,7 @@ class Input : protected Pointers { void dipole(); void dump(); void dump_modify(); + // void ellipsoid(); void fix(); void fix_modify(); void group_command();