From 604c8b30d67e3a781a4da379aa9d19a48f7f7e34 Mon Sep 17 00:00:00 2001
From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa>
Date: Mon, 30 Apr 2007 23:35:33 +0000
Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@547
 f3b2605a-c512-4ea7-a41b-209d697bcdaa

---
 src/input.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 src/input.h   |  2 ++
 2 files changed, 49 insertions(+)

diff --git a/src/input.cpp b/src/input.cpp
index 98c5de8ed0..c9d0721712 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 30971c3b52..1ee2ce28b2 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();
-- 
GitLab