git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14129 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2015-10-21 18:51:09 +00:00
parent 9a878cdd67
commit ef82677cb2
3 changed files with 40 additions and 12 deletions

View File

@ -733,7 +733,7 @@ void Input::clear()
if (narg > 0) error->all(FLERR,"Illegal clear command"); if (narg > 0) error->all(FLERR,"Illegal clear command");
lmp->destroy(); lmp->destroy();
lmp->create(); lmp->create();
lmp->post_create(0,NULL,NULL,NULL); lmp->post_create();
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -89,6 +89,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
suffix = suffix2 = NULL; suffix = suffix2 = NULL;
suffix_enable = 0; suffix_enable = 0;
packargs = NULL;
num_package = 0;
char *rfile = NULL; char *rfile = NULL;
char *dfile = NULL; char *dfile = NULL;
int wdfirst,wdlast; int wdfirst,wdlast;
@ -509,12 +511,25 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
input = new Input(this,narg,arg); input = new Input(this,narg,arg);
// copy package cmdline arguments
if (npack > 0) {
num_package = npack;
packargs = new char**[npack];
for (int i=0; i < npack; ++i) {
int n = plast[i] - pfirst[i];
packargs[i] = new char*[n+1];
for (int j=0; j < n; ++j)
packargs[i][j] = strdup(arg[pfirst[i]+j]);
packargs[i][n] = NULL;
}
memory->destroy(pfirst);
memory->destroy(plast);
}
// allocate top-level classes // allocate top-level classes
create(); create();
post_create(npack,pfirst,plast,arg); post_create();
memory->destroy(pfirst);
memory->destroy(plast);
// if helpflag set, print help and quit with "success" status // if helpflag set, print help and quit with "success" status
@ -556,6 +571,17 @@ LAMMPS::~LAMMPS()
destroy(); destroy();
delete citeme; delete citeme;
if (num_package) {
for (int i = 0; i < num_package; i++) {
for (char **ptr = packargs[i]; *ptr != NULL; ++ptr)
free(*ptr);
delete[] packargs[i];
}
delete[] packargs;
}
num_package = 0;
packargs = NULL;
double totalclock = MPI_Wtime() - initclock; double totalclock = MPI_Wtime() - initclock;
if ((me == 0) && (screen || logfile)) { if ((me == 0) && (screen || logfile)) {
char outtime[128]; char outtime[128];
@ -650,7 +676,7 @@ void LAMMPS::create()
so that package-specific core classes have been instantiated so that package-specific core classes have been instantiated
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void LAMMPS::post_create(int npack, int *pfirst, int *plast, char **arg) void LAMMPS::post_create()
{ {
// default package commands triggered by "-c on" and "-k on" // default package commands triggered by "-c on" and "-k on"
@ -687,15 +713,15 @@ void LAMMPS::post_create(int npack, int *pfirst, int *plast, char **arg)
// invoke any command-line package commands // invoke any command-line package commands
if (npack) { if (num_package) {
char str[128]; char str[256];
for (int i = 0; i < npack; i++) { for (int i = 0; i < num_package; i++) {
strcpy(str,"package"); strcpy(str,"package");
for (int j = pfirst[i]; j < plast[i]; j++) { for (char **ptr = packargs[i]; *ptr != NULL; ++ptr) {
if (strlen(str) + strlen(arg[j]) + 2 > 128) if (strlen(str) + strlen(*ptr) + 2 > 256)
error->all(FLERR,"Too many -pk arguments in command line"); error->all(FLERR,"Too many -pk arguments in command line");
strcat(str," "); strcat(str," ");
strcat(str,arg[j]); strcat(str,*ptr);
} }
input->one(str); input->one(str);
} }

View File

@ -46,6 +46,8 @@ class LAMMPS {
char *suffix,*suffix2; // suffixes to add to input script style names char *suffix,*suffix2; // suffixes to add to input script style names
int suffix_enable; // 1 if suffixes are enabled, 0 if disabled int suffix_enable; // 1 if suffixes are enabled, 0 if disabled
char ***packargs; // arguments for cmdline package commands
int num_package; // number of cmdline package commands
int cite_enable; // 1 if generating log.cite, 0 if disabled int cite_enable; // 1 if generating log.cite, 0 if disabled
class Cuda *cuda; // CUDA accelerator class class Cuda *cuda; // CUDA accelerator class
@ -57,7 +59,7 @@ class LAMMPS {
LAMMPS(int, char **, MPI_Comm); LAMMPS(int, char **, MPI_Comm);
~LAMMPS(); ~LAMMPS();
void create(); void create();
void post_create(int, int *, int *, char **); void post_create();
void init(); void init();
void destroy(); void destroy();