add -skiprun command line flag that sets a timeout so that run and minimizations loops are skipped

This commit is contained in:
Axel Kohlmeyer
2021-09-03 11:21:42 -04:00
parent bca9157405
commit f768b701ee
4 changed files with 126 additions and 94 deletions

View File

@ -126,6 +126,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
cslib = nullptr;
cscomm = 0;
skipflag = 0;
screen = nullptr;
logfile = nullptr;
infile = nullptr;
@ -391,6 +393,11 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
screenflag = iarg + 1;
iarg += 2;
} else if (strcmp(arg[iarg],"-skiprun") == 0 ||
strcmp(arg[iarg],"-sr") == 0) {
skipflag = 1;
++iarg;
} else if (strcmp(arg[iarg],"-suffix") == 0 ||
strcmp(arg[iarg],"-sf") == 0) {
if (iarg+2 > narg)
@ -462,9 +469,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
else {
universe->uscreen = fopen(arg[screenflag],"w");
if (universe->uscreen == nullptr)
error->universe_one(FLERR,fmt::format("Cannot open universe screen "
"file {}: {}",arg[screenflag],
utils::getsyserror()));
error->universe_one(FLERR,fmt::format("Cannot open universe screen file {}: {}",
arg[screenflag],utils::getsyserror()));
}
if (logflag == 0) {
if (helpflag == 0) {
@ -478,9 +484,8 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
else {
universe->ulogfile = fopen(arg[logflag],"w");
if (universe->ulogfile == nullptr)
error->universe_one(FLERR,fmt::format("Cannot open universe log "
"file {}: {}",arg[logflag],
utils::getsyserror()));
error->universe_one(FLERR,fmt::format("Cannot open universe log file {}: {}",
arg[logflag],utils::getsyserror()));
}
}
@ -505,8 +510,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
else if (strcmp(arg[inflag], "none") == 0) infile = stdin;
else infile = fopen(arg[inflag],"r");
if (infile == nullptr)
error->one(FLERR,"Cannot open input script {}: {}",
arg[inflag], utils::getsyserror());
error->one(FLERR,"Cannot open input script {}: {}",arg[inflag], utils::getsyserror());
}
if ((universe->me == 0) && !helpflag)
@ -530,16 +534,14 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
str = fmt::format("screen.{}",universe->iworld);
screen = fopen(str.c_str(),"w");
if (screen == nullptr)
error->one(FLERR,"Cannot open screen file {}: {}",
str,utils::getsyserror());
error->one(FLERR,"Cannot open screen file {}: {}",str,utils::getsyserror());
} else if (strcmp(arg[screenflag],"none") == 0) {
screen = nullptr;
} else {
str = fmt::format("{}.{}",arg[screenflag],universe->iworld);
screen = fopen(str.c_str(),"w");
if (screen == nullptr)
error->one(FLERR,"Cannot open screen file {}: {}",
arg[screenflag],utils::getsyserror());
error->one(FLERR,"Cannot open screen file {}: {}",arg[screenflag],utils::getsyserror());
}
} else if (strcmp(arg[partscreenflag],"none") == 0) {
screen = nullptr;
@ -547,8 +549,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
str = fmt::format("{}.{}",arg[partscreenflag],universe->iworld);
screen = fopen(str.c_str(),"w");
if (screen == nullptr)
error->one(FLERR,"Cannot open screen file {}: {}",
str,utils::getsyserror());
error->one(FLERR,"Cannot open screen file {}: {}",str,utils::getsyserror());
}
if (partlogflag == 0) {
@ -556,16 +557,14 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
str = fmt::format("log.lammps.{}",universe->iworld);
logfile = fopen(str.c_str(),"w");
if (logfile == nullptr)
error->one(FLERR,"Cannot open logfile {}: {}",
str, utils::getsyserror());
error->one(FLERR,"Cannot open logfile {}: {}",str, utils::getsyserror());
} else if (strcmp(arg[logflag],"none") == 0) {
logfile = nullptr;
} else {
str = fmt::format("{}.{}",arg[logflag],universe->iworld);
logfile = fopen(str.c_str(),"w");
if (logfile == nullptr)
error->one(FLERR,"Cannot open logfile {}: {}",
str, utils::getsyserror());
error->one(FLERR,"Cannot open logfile {}: {}",str, utils::getsyserror());
}
} else if (strcmp(arg[partlogflag],"none") == 0) {
logfile = nullptr;
@ -573,15 +572,13 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
str = fmt::format("{}.{}",arg[partlogflag],universe->iworld);
logfile = fopen(str.c_str(),"w");
if (logfile == nullptr)
error->one(FLERR,"Cannot open logfile {}: {}",
str, utils::getsyserror());
error->one(FLERR,"Cannot open logfile {}: {}",str, utils::getsyserror());
}
if (strcmp(arg[inflag], "none") != 0) {
infile = fopen(arg[inflag],"r");
if (infile == nullptr)
error->one(FLERR,"Cannot open input script {}: {}",
arg[inflag], utils::getsyserror());
error->one(FLERR,"Cannot open input script {}: {}",arg[inflag], utils::getsyserror());
}
}
@ -615,12 +612,10 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
int mpisize;
MPI_Type_size(MPI_LMP_TAGINT,&mpisize);
if (mpisize != sizeof(tagint))
error->all(FLERR,"MPI_LMP_TAGINT and tagint in "
"lmptype.h are not compatible");
error->all(FLERR,"MPI_LMP_TAGINT and tagint in lmptype.h are not compatible");
MPI_Type_size(MPI_LMP_BIGINT,&mpisize);
if (mpisize != sizeof(bigint))
error->all(FLERR,"MPI_LMP_BIGINT and bigint in "
"lmptype.h are not compatible");
error->all(FLERR,"MPI_LMP_BIGINT and bigint in lmptype.h are not compatible");
#ifdef LAMMPS_SMALLBIG
if (sizeof(smallint) != 4 || sizeof(imageint) != 4 ||
@ -837,6 +832,8 @@ void LAMMPS::create()
void LAMMPS::post_create()
{
if (skipflag) input->one("timer timeout 0 every 1");
// default package command triggered by "-k on"
if (kokkos && kokkos->kokkos_exists) input->one("package kokkos");

View File

@ -22,52 +22,52 @@ namespace LAMMPS_NS {
class LAMMPS {
public:
// ptrs to fundamental LAMMPS classes
class Memory *memory; // memory allocation functions
class Error *error; // error handling
class Universe *universe; // universe of processors
class Input *input; // input script processing
// ptrs to top-level LAMMPS-specific classes
class Atom *atom; // atom-based quantities
class Update *update; // integrators/minimizers
class Neighbor *neighbor; // neighbor lists
class Comm *comm; // inter-processor communication
class Domain *domain; // simulation box
class Force *force; // inter-particle forces
class Modify *modify; // fixes and computes
class Group *group; // groups of atoms
class Output *output; // thermo/dump/restart
class Timer *timer; // CPU timing info
class Memory *memory; // memory allocation functions
class Error *error; // error handling
class Universe *universe; // universe of processors
class Input *input; // input script processing
// ptrs to top-level LAMMPS-specific classes
class Atom *atom; // atom-based quantities
class Update *update; // integrators/minimizers
class Neighbor *neighbor; // neighbor lists
class Comm *comm; // inter-processor communication
class Domain *domain; // simulation box
class Force *force; // inter-particle forces
class Modify *modify; // fixes and computes
class Group *group; // groups of atoms
class Output *output; // thermo/dump/restart
class Timer *timer; // CPU timing info
//
class KokkosLMP *kokkos; // KOKKOS accelerator class
class AtomKokkos *atomKK; // KOKKOS version of Atom class
class MemoryKokkos *memoryKK; // KOKKOS version of Memory class
class Python *python; // Python interface
class CiteMe *citeme; // handle citation info
const char *version; // LAMMPS version string = date
int num_ver; // numeric version id derived from *version*
// that is constructed so that will be greater
// for newer versions in numeric or string
// value comparisons
MPI_Comm world; // MPI communicator
FILE *infile; // infile
FILE *screen; // screen output
FILE *logfile; // logfile
double initclock; // wall clock at instantiation
//
MPI_Comm world; // MPI communicator
FILE *infile; // infile
FILE *screen; // screen output
FILE *logfile; // logfile
//
double initclock; // wall clock at instantiation
int skiprunflag; // 1 inserts timer command to skip run and minimize loops
char *suffix, *suffix2, *suffixp; // suffixes to add to input script style names
int suffix_enable; // 1 if suffixes are enabled, 0 if disabled
char *exename; // pointer to argv[0]
//
char ***packargs; // arguments for cmdline package commands
int num_package; // number of cmdline package commands
int clientserver; // 0 = neither, 1 = client, 2 = server
void *cslib; // client/server messaging via CSlib
MPI_Comm cscomm; // MPI comm for client+server in mpi/one mode
class KokkosLMP *kokkos; // KOKKOS accelerator class
class AtomKokkos *atomKK; // KOKKOS version of Atom class
class MemoryKokkos *memoryKK; // KOKKOS version of Memory class
class Python *python; // Python interface
class CiteMe *citeme; // handle citation info
//
int clientserver; // 0 = neither, 1 = client, 2 = server
void *cslib; // client/server messaging via CSlib
MPI_Comm cscomm; // MPI comm for client+server in mpi/one mode
const char *match_style(const char *style, const char *name);
static const char *installed_packages[];