diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index c799816fd3..306efb8ea2 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -144,6 +144,7 @@ void PPPM::init() cutoff = *p_cutoff; // if kspace is TIP4P, extract TIP4P params from pair style + // bond/angle are not yet init(), so insure equilibrium request is valid qdist = 0.0; @@ -165,6 +166,12 @@ void PPPM::init() if (force->angle == NULL || force->bond == NULL) error->all("Bond and angle potentials must be defined for TIP4P"); + if (typeA < 1 || typeA > atom->nangletypes || + force->angle->setflag[typeA] == 0) + error->all("Bad TIP4P angle type for PPPM/TIP4P"); + if (typeB < 1 || typeA > atom->nbondtypes || + force->bond->setflag[typeB] == 0) + error->all("Bad TIP4P bond type for PPPM/TIP4P"); double theta = force->angle->equilibrium_angle(typeA); double blen = force->bond->equilibrium_distance(typeB); alpha = qdist / (2.0 * cos(0.5*theta) * blen); diff --git a/src/error.h b/src/error.h index b578d4ba50..e1fbd19367 100644 --- a/src/error.h +++ b/src/error.h @@ -28,6 +28,7 @@ class Error : protected Pointers { void all(const char *); void one(const char *); void warning(const char *, int = 1); + void message(char *, int = 1); }; } diff --git a/src/input.cpp b/src/input.cpp index 07704a4501..18973af399 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -16,6 +16,8 @@ #include "stdlib.h" #include "string.h" #include "ctype.h" +#include "unistd.h" +#include "sys/stat.h" #include "input.h" #include "style_command.h" #include "universe.h" @@ -81,10 +83,13 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp) int iarg = 0; while (iarg < argc) { - if (strcmp(argv[iarg],"-var") == 0) { - variable->set(argv[iarg+1],argv[iarg+2]); - iarg += 3; - } else if (strcmp(argv[iarg],"-echo") == 0) { + if (strcmp(argv[iarg],"-var") == 0 || strcmp(argv[iarg],"-v") == 0) { + int jarg = iarg+2; + while (jarg < argc && argv[jarg][0] != '-') jarg++; + variable->set(argv[iarg+1],jarg-iarg-2,&argv[iarg+2]); + iarg = jarg; + } else if (strcmp(argv[iarg],"-echo") == 0 || + strcmp(argv[iarg],"-e") == 0) { narg = 1; char **tmp = arg; // trick echo() into using argv instead of arg arg = &argv[iarg+1]; @@ -409,6 +414,7 @@ int Input::execute_command() else if (!strcmp(command,"log")) log(); else if (!strcmp(command,"next")) next_command(); else if (!strcmp(command,"print")) print(); + else if (!strcmp(command,"shell")) shell(); else if (!strcmp(command,"variable")) variable_command(); else if (!strcmp(command,"angle_coeff")) angle_coeff(); @@ -752,6 +758,43 @@ void Input::print() /* ---------------------------------------------------------------------- */ +void Input::shell() +{ + if (narg < 1) error->all("Illegal shell command"); + + if (strcmp(arg[0],"cd") == 0) { + if (narg != 2) error->all("Illegal shell command"); + chdir(arg[1]); + + } else if (strcmp(arg[0],"mkdir") == 0) { + if (narg < 2) error->all("Illegal shell command"); +#if !defined(WINDOWS) && !defined(__MINGW32_VERSION) + if (me == 0) + for (int i = 1; i < narg; i++) + mkdir(arg[i], S_IRWXU | S_IRGRP | S_IXGRP); +#endif + + } else if (strcmp(arg[0],"mv") == 0) { + if (narg != 3) error->all("Illegal shell command"); + if (me == 0) rename(arg[1],arg[2]); + + } else if (strcmp(arg[0],"rm") == 0) { + if (narg < 2) error->all("Illegal shell command"); + if (me == 0) + for (int i = 1; i < narg; i++) + unlink(arg[i]); + + } else if (strcmp(arg[0],"rmdir") == 0) { + if (narg < 2) error->all("Illegal shell command"); + if (me == 0) + for (int i = 1; i < narg; i++) + rmdir(arg[i]); + + } else error->all("Illegal shell command"); +} + +/* ---------------------------------------------------------------------- */ + void Input::variable_command() { variable->set(narg,arg); diff --git a/src/input.h b/src/input.h index 17c96e2128..7d2946d3e9 100644 --- a/src/input.h +++ b/src/input.h @@ -58,6 +58,7 @@ class Input : protected Pointers { void log(); void next_command(); void print(); + void shell(); void variable_command(); void angle_coeff(); // LAMMPS commands diff --git a/src/lammps.cpp b/src/lammps.cpp index 97b07922a3..6b1d2f704d 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -57,7 +57,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) int iarg = 1; while (iarg < narg) { - if (strcmp(arg[iarg],"-partition") == 0) { + if (strcmp(arg[iarg],"-partition") == 0 || + strcmp(arg[iarg],"-p") == 0) { universe->existflag = 1; if (iarg+2 > narg) error->universe_all("Invalid command-line argument"); @@ -66,26 +67,32 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) universe->add_world(arg[iarg]); iarg++; } - } else if (strcmp(arg[iarg],"-in") == 0) { + } else if (strcmp(arg[iarg],"-in") == 0 || + strcmp(arg[iarg],"-i") == 0) { if (iarg+2 > narg) error->universe_all("Invalid command-line argument"); inflag = iarg + 1; iarg += 2; - } else if (strcmp(arg[iarg],"-screen") == 0) { + } else if (strcmp(arg[iarg],"-screen") == 0 || + strcmp(arg[iarg],"-s") == 0) { if (iarg+2 > narg) error->universe_all("Invalid command-line argument"); screenflag = iarg + 1; iarg += 2; - } else if (strcmp(arg[iarg],"-log") == 0) { + } else if (strcmp(arg[iarg],"-log") == 0 || + strcmp(arg[iarg],"-l") == 0) { if (iarg+2 > narg) error->universe_all("Invalid command-line argument"); logflag = iarg + 1; iarg += 2; - } else if (strcmp(arg[iarg],"-var") == 0) { + } else if (strcmp(arg[iarg],"-var") == 0 || + strcmp(arg[iarg],"-v") == 0) { if (iarg+3 > narg) error->universe_all("Invalid command-line argument"); - iarg += 3; - } else if (strcmp(arg[iarg],"-echo") == 0) { + iarg += 2; + while (iarg < narg && arg[iarg][0] != '-') iarg++; + } else if (strcmp(arg[iarg],"-echo") == 0 || + strcmp(arg[iarg],"-e") == 0) { if (iarg+2 > narg) error->universe_all("Invalid command-line argument"); iarg += 2; diff --git a/src/shell.cpp b/src/shell.cpp deleted file mode 100644 index 8483772a46..0000000000 --- a/src/shell.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#include "mpi.h" -#include "string.h" -#include "unistd.h" -#include "sys/stat.h" -#include "shell.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -Shell::Shell(LAMMPS *lmp) : Pointers(lmp) -{ - MPI_Comm_rank(world,&me); -} - -/* ---------------------------------------------------------------------- */ - -void Shell::command(int narg, char **arg) -{ - if (narg < 1) error->all("Illegal shell command"); - - if (strcmp(arg[0],"cd") == 0) { - if (narg != 2) error->all("Illegal shell command"); - chdir(arg[1]); - - } else if (strcmp(arg[0],"mkdir") == 0) { - if (narg < 2) error->all("Illegal shell command"); -#if !defined(WINDOWS) && !defined(__MINGW32_VERSION) - if (me == 0) - for (int i = 1; i < narg; i++) - mkdir(arg[i], S_IRWXU | S_IRGRP | S_IXGRP); -#endif - - } else if (strcmp(arg[0],"mv") == 0) { - if (narg != 3) error->all("Illegal shell command"); - if (me == 0) rename(arg[1],arg[2]); - - } else if (strcmp(arg[0],"rm") == 0) { - if (narg < 2) error->all("Illegal shell command"); - if (me == 0) - for (int i = 1; i < narg; i++) - unlink(arg[i]); - - } else if (strcmp(arg[0],"rmdir") == 0) { - if (narg < 2) error->all("Illegal shell command"); - if (me == 0) - for (int i = 1; i < narg; i++) - rmdir(arg[i]); - - } else error->all("Illegal shell command"); -} diff --git a/src/shell.h b/src/shell.h deleted file mode 100644 index 723369d188..0000000000 --- a/src/shell.h +++ /dev/null @@ -1,39 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef COMMAND_CLASS - -CommandStyle(shell,Shell) - -#else - -#ifndef LMP_SHELL_H -#define LMP_SHELL_H - -#include "pointers.h" - -namespace LAMMPS_NS { - -class Shell : protected Pointers { - public: - Shell(class LAMMPS *); - void command(int, char **); - - private: - int me; -}; - -} - -#endif -#endif diff --git a/src/variable.cpp b/src/variable.cpp index 29dbc69f0e..ecf2d971ae 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -322,17 +322,17 @@ void Variable::set(int narg, char **arg) } /* ---------------------------------------------------------------------- - single-value INDEX variable created by command-line argument + INDEX variable created by command-line argument make it INDEX rather than STRING so cannot be re-defined in input script ------------------------------------------------------------------------- */ -void Variable::set(char *name, char *value) +void Variable::set(char *name, int narg, char **arg) { - char **newarg = new char*[3]; + char **newarg = new char*[2+narg]; newarg[0] = name; newarg[1] = (char *) "index"; - newarg[2] = value; - set(3,newarg); + for (int i = 0; i < narg; i++) newarg[2+i] = arg[i]; + set(2+narg,newarg); delete [] newarg; } diff --git a/src/variable.h b/src/variable.h index 96dde3c51e..08552dff81 100644 --- a/src/variable.h +++ b/src/variable.h @@ -23,7 +23,7 @@ class Variable : protected Pointers { Variable(class LAMMPS *); ~Variable(); void set(int, char **); - void set(char *, char *); + void set(char *, int, char **); int next(int, char **); int find(char *); int equalstyle(int);