add support for '-in none' for multi-partition runs from the library interface
This commit is contained in:
@ -62,15 +62,18 @@ used.
|
|||||||
|
|
||||||
**-in file**
|
**-in file**
|
||||||
|
|
||||||
Specify a file to use as an input script. This is an optional switch
|
Specify a file to use as an input script. This is an optional but
|
||||||
when running LAMMPS in one-partition mode. If it is not specified,
|
recommended switch when running LAMMPS in one-partition mode. If it
|
||||||
LAMMPS reads its script from standard input, typically from a script
|
is not specified, LAMMPS reads its script from standard input, typically
|
||||||
via I/O redirection; e.g. lmp_linux < in.run. I/O redirection should
|
from a script via I/O redirection; e.g. lmp_linux < in.run.
|
||||||
also work in parallel, but if it does not (in the unlikely case that
|
With many MPI implementations I/O redirection also works in parallel,
|
||||||
an MPI implementation does not support it), then use the -in flag.
|
but using the -in flag will always work.
|
||||||
|
|
||||||
Note that this is a required switch when running LAMMPS in
|
Note that this is a required switch when running LAMMPS in
|
||||||
multi-partition mode, since multiple processors cannot all read from
|
multi-partition mode, since multiple processors cannot all read from
|
||||||
stdin.
|
stdin concurrently. The file name may be "none" for starting
|
||||||
|
multi-partition calculations without reading an initial input file
|
||||||
|
from the library interface.
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
@ -296,7 +299,7 @@ command-line option.
|
|||||||
**-pscreen file**
|
**-pscreen file**
|
||||||
|
|
||||||
Specify the base name for the partition screen file, so partition N
|
Specify the base name for the partition screen file, so partition N
|
||||||
writes screen information to file.N. If file is none, then no
|
writes screen information to file.N. If file is "none", then no
|
||||||
partition screen files are created. This overrides the filename
|
partition screen files are created. This overrides the filename
|
||||||
specified in the -screen command-line option. This option is useful
|
specified in the -screen command-line option. This option is useful
|
||||||
when working with large numbers of partitions, allowing the partition
|
when working with large numbers of partitions, allowing the partition
|
||||||
|
|||||||
@ -189,8 +189,15 @@ void Input::file()
|
|||||||
// if line ends in continuation char '&', concatenate next line
|
// if line ends in continuation char '&', concatenate next line
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
|
|
||||||
m = 0;
|
m = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
|
if (infile == nullptr) {
|
||||||
|
n = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (maxline-m < 2) reallocate(line,maxline,0);
|
if (maxline-m < 2) reallocate(line,maxline,0);
|
||||||
|
|
||||||
// end of file reached, so break
|
// end of file reached, so break
|
||||||
|
|||||||
@ -456,6 +456,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
|
|||||||
|
|
||||||
if (universe->me == 0) {
|
if (universe->me == 0) {
|
||||||
if (inflag == 0) infile = stdin;
|
if (inflag == 0) infile = stdin;
|
||||||
|
else if (strcmp(arg[inflag], "none") == 0) infile = stdin;
|
||||||
else infile = fopen(arg[inflag],"r");
|
else infile = fopen(arg[inflag],"r");
|
||||||
if (infile == nullptr)
|
if (infile == nullptr)
|
||||||
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||||
@ -530,10 +531,12 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
|
|||||||
str, utils::getsyserror()));
|
str, utils::getsyserror()));
|
||||||
}
|
}
|
||||||
|
|
||||||
infile = fopen(arg[inflag],"r");
|
if (strcmp(arg[inflag], "none") != 0) {
|
||||||
if (infile == nullptr)
|
infile = fopen(arg[inflag],"r");
|
||||||
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
if (infile == nullptr)
|
||||||
arg[inflag], utils::getsyserror()));
|
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||||
|
arg[inflag], utils::getsyserror()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// screen and logfile messages for universe and world
|
// screen and logfile messages for universe and world
|
||||||
@ -1103,7 +1106,7 @@ void _noopt LAMMPS::help()
|
|||||||
"List of command line options supported by this LAMMPS executable:\n\n"
|
"List of command line options supported by this LAMMPS executable:\n\n"
|
||||||
"-echo none/screen/log/both : echoing of input script (-e)\n"
|
"-echo none/screen/log/both : echoing of input script (-e)\n"
|
||||||
"-help : print this help message (-h)\n"
|
"-help : print this help message (-h)\n"
|
||||||
"-in filename : read input from file, not stdin (-i)\n"
|
"-in none/filename : read input from file or stdin (default) (-i)\n"
|
||||||
"-kokkos on/off ... : turn KOKKOS mode on or off (-k)\n"
|
"-kokkos on/off ... : turn KOKKOS mode on or off (-k)\n"
|
||||||
"-log none/filename : where to send log output (-l)\n"
|
"-log none/filename : where to send log output (-l)\n"
|
||||||
"-mpicolor color : which exe in a multi-exe mpirun cmd (-m)\n"
|
"-mpicolor color : which exe in a multi-exe mpirun cmd (-m)\n"
|
||||||
|
|||||||
@ -156,11 +156,9 @@ TEST(MPI, multi_partition)
|
|||||||
lammps_mpi_init();
|
lammps_mpi_init();
|
||||||
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
||||||
MPI_Comm_rank(MPI_COMM_WORLD, &me);
|
MPI_Comm_rank(MPI_COMM_WORLD, &me);
|
||||||
fp = fopen("in.mp_dummy", "w");
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-partition", "2x2",
|
const char *args[] = {"LAMMPS_test", "-log", "none", "-partition", "2x2",
|
||||||
"-echo", "screen", "-nocite", "-in", "in.mp_dummy"};
|
"-echo", "screen", "-nocite", "-in", "none"};
|
||||||
char **argv = (char **)args;
|
char **argv = (char **)args;
|
||||||
int argc = sizeof(args) / sizeof(char *);
|
int argc = sizeof(args) / sizeof(char *);
|
||||||
void *lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
|
void *lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
|
||||||
@ -184,7 +182,6 @@ TEST(MPI, multi_partition)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lammps_close(lmp);
|
lammps_close(lmp);
|
||||||
unlink("in.mp_dummy");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MPITest : public ::testing::Test {
|
class MPITest : public ::testing::Test {
|
||||||
|
|||||||
Reference in New Issue
Block a user