From 58a11d6bc2eb48412c5fd110bb7c49b5009396e6 Mon Sep 17 00:00:00 2001
From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa>
Date: Wed, 10 Sep 2014 19:39:31 +0000
Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12474
 f3b2605a-c512-4ea7-a41b-209d697bcdaa

---
 src/GPU/fix_gpu.cpp | 10 +++++-----
 src/input.cpp       |  2 +-
 src/lammps.cpp      | 46 ++++++++++++++++++++++++++++++++++++++++++---
 src/lammps.h        |  2 +-
 src/modify.cpp      |  2 +-
 5 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp
index 081eb3a3a2..3e51811059 100644
--- a/src/GPU/fix_gpu.cpp
+++ b/src/GPU/fix_gpu.cpp
@@ -108,17 +108,17 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
       else if (strcmp(arg[iarg]+1,"hybrid") == 0) _gpu_mode = GPU_HYB_NEIGH;
       else error->all(FLERR,"Illegal package gpu command");
       iarg += 2;
+    } else if (strcmp(arg[iarg],"newton") == 0) {
+      if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
+      if (strcmp(arg[iarg]+1,"off") == 0) newtonflag = 0;
+      else if (strcmp(arg[iarg]+1,"on") == 0) newtonflag = 1;
+      else error->all(FLERR,"Illegal package gpu command");
     } else if (strcmp(arg[iarg],"split") == 0) {
       if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
       _particle_split = force->numeric(FLERR,arg[iarg+1]);
       if (_particle_split == 0.0 || _particle_split > 1.0)
         error->all(FLERR,"Illegal package GPU command");
       iarg += 2;
-    } else if (strcmp(arg[iarg],"newton") == 0) {
-      if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
-      if (strcmp(arg[iarg]+1,"off") == 0) newtonflag = 0;
-      else if (strcmp(arg[iarg]+1,"on") == 0) newtonflag = 1;
-      else error->all(FLERR,"Illegal package gpu command");
     } else if (strcmp(arg[iarg],"gpuID") == 0) {
       if (iarg+3 > narg) error->all(FLERR,"Illegal package gpu command");
       first_gpu = force->inumeric(FLERR,arg[iarg+1]);
diff --git a/src/input.cpp b/src/input.cpp
index e43932ec2a..4b6e27880f 100644
--- a/src/input.cpp
+++ b/src/input.cpp
@@ -642,7 +642,7 @@ void Input::clear()
   if (narg > 0) error->all(FLERR,"Illegal clear command");
   lmp->destroy();
   lmp->create();
-  lmp->post_create();
+  lmp->post_create(0,NULL,NULL,NULL);
 }
 
 /* ---------------------------------------------------------------------- */
diff --git a/src/lammps.cpp b/src/lammps.cpp
index b35d519c8f..287866fe63 100644
--- a/src/lammps.cpp
+++ b/src/lammps.cpp
@@ -92,6 +92,10 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
   int wdfirst,wdlast;
   int kkfirst,kklast;
 
+  int npack = 0;
+  int *pfirst = NULL;
+  int *plast = NULL;
+
   int iarg = 1;
   while (iarg < narg) {
     if (strcmp(arg[iarg],"-partition") == 0 ||
@@ -165,6 +169,22 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
       kkfirst = iarg;
       while (iarg < narg && arg[iarg][0] != '-') iarg++;
       kklast = iarg;
+    } else if (strcmp(arg[iarg],"-package") == 0 ||
+               strcmp(arg[iarg],"-pk") == 0) {
+      if (iarg+2 > narg)
+        error->universe_all(FLERR,"Invalid command-line argument");
+      memory->grow(pfirst,npack+1,"lammps:pfirst");
+      memory->grow(plast,npack+1,"lammps:plast");
+      // delimit args for package command invocation
+      // any package arg with leading "-" will be followed by numeric digit
+      iarg++;
+      pfirst[npack] = iarg;
+      while (iarg < narg) {
+        if (arg[iarg][0] != '-') iarg++;
+        else if (isdigit(arg[iarg][1])) iarg++;
+        else break;
+      }
+      plast[npack++] = iarg;
     } else if (strcmp(arg[iarg],"-suffix") == 0 ||
                strcmp(arg[iarg],"-sf") == 0) {
       if (iarg+2 > narg)
@@ -480,7 +500,9 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
   // allocate top-level classes
 
   create();
-  post_create();
+  post_create(npack,pfirst,plast,arg);
+  memory->destroy(pfirst);
+  memory->destroy(plast);
 
   // if helpflag set, print help and quit
 
@@ -603,7 +625,7 @@ void LAMMPS::create()
      so that package-specific core classes have been instantiated
 ------------------------------------------------------------------------- */
 
-void LAMMPS::post_create()
+void LAMMPS::post_create(int npack, int *pfirst, int *plast, char **arg)
 {
   // default package commands triggered by "-c on" and "-k on"
 
@@ -644,6 +666,22 @@ void LAMMPS::post_create()
   if (suffix2) {
     if (strcmp(suffix,"omp") == 0) input->one("package omp 0");
   }
+
+  // invoke any command-line package commands
+
+  if (npack) {
+    char str[128];
+    for (int i = 0; i < npack; i++) {
+      strcpy(str,"package");
+      for (int j = pfirst[i]; j < plast[i]; j++) {
+        if (strlen(str) + strlen(arg[j]) + 2 > 128)
+          error->all(FLERR,"Too many -pk arguments in command line");
+        strcat(str," ");
+        strcpy(str,arg[j]);
+      }
+      input->one(str);
+    }
+  }
 }
 
 /* ----------------------------------------------------------------------
@@ -705,14 +743,16 @@ void LAMMPS::help()
           "\nCommand line options:\n\n"
           "-cuda on/off                : turn CUDA mode on or off (-c)\n"
           "-echo none/screen/log/both  : echoing of input script (-e)\n"
-          "-in filename                : read input from file, not stdin (-i)\n"
           "-help                       : print this help message (-h)\n"
+          "-in filename                : read input from file, not stdin (-i)\n"
           "-kokkos on/off ...          : turn KOKKOS mode on or off (-k)\n"
           "-log none/filename          : where to send log output (-l)\n"
           "-nocite                     : disable writing log.cite file (-nc)\n"
+          "-package style ...          : invoke package command (-pk)\n"
           "-partition size1 size2 ...  : assign partition sizes (-p)\n"
           "-plog basename              : basename for partition logs (-pl)\n"
           "-pscreen basename           : basename for partition screens (-ps)\n"
+          "-restart rfile dfile ...    : convert restart to data file (-r)\n" 
           "-reorder topology-specs     : processor reordering (-r)\n"
           "-screen none/filename       : where to send screen output (-sc)\n"
           "-suffix cuda/gpu/opt/omp    : style suffix to apply (-sf)\n"
diff --git a/src/lammps.h b/src/lammps.h
index 998cf3b95f..8ba480becd 100644
--- a/src/lammps.h
+++ b/src/lammps.h
@@ -54,7 +54,7 @@ class LAMMPS {
   LAMMPS(int, char **, MPI_Comm);
   ~LAMMPS();
   void create();
-  void post_create();
+  void post_create(int, int *, int *, char **);
   void init();
   void destroy();
 
diff --git a/src/modify.cpp b/src/modify.cpp
index 47bf41cd40..3abb15dd44 100644
--- a/src/modify.cpp
+++ b/src/modify.cpp
@@ -661,7 +661,7 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)
   // MUST change NEXCEPT above when add new fix to this list
 
   const char *exceptions[NEXCEPT] = 
-    {"GPU","OMP","Intel","property/atom","cmap"};
+    {"GPU","OMP","INTEL","property/atom","cmap"};
 
   if (domain->box_exist == 0) {
     int m;
-- 
GitLab