diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 081eb3a3a254a67cc9020d50ea77e74c40796307..3e5181105989fc75798591f101f7838516c15d82 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 e43932ec2a8bf9cfe842c3d2087e320d4420b2cc..4b6e27880f2ca694b94bcb49c373a0555feed974 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 b35d519c8ff65efe108c00bc8e4718ff04627856..287866fe630703d333c0811253640771046bafa3 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 998cf3b95ff36561cac57f7478089a434591b09a..8ba480becd80dbe60b3e9fb8a77298dfbf1407b8 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 47bf41cd40cacd00b7b639bf52b0a11993685ff7..3abb15dd4470c279a4f1eb806d62bb74a42479b8 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;