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**
|
||||
|
||||
Specify a file to use as an input script. This is an optional switch
|
||||
when running LAMMPS in one-partition mode. If it is not specified,
|
||||
LAMMPS reads its script from standard input, typically from a script
|
||||
via I/O redirection; e.g. lmp_linux < in.run. I/O redirection should
|
||||
also work in parallel, but if it does not (in the unlikely case that
|
||||
an MPI implementation does not support it), then use the -in flag.
|
||||
Specify a file to use as an input script. This is an optional but
|
||||
recommended switch when running LAMMPS in one-partition mode. If it
|
||||
is not specified, LAMMPS reads its script from standard input, typically
|
||||
from a script via I/O redirection; e.g. lmp_linux < in.run.
|
||||
With many MPI implementations I/O redirection also works in parallel,
|
||||
but using the -in flag will always work.
|
||||
|
||||
Note that this is a required switch when running LAMMPS in
|
||||
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**
|
||||
|
||||
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
|
||||
specified in the -screen command-line option. This option is useful
|
||||
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 (me == 0) {
|
||||
|
||||
m = 0;
|
||||
while (1) {
|
||||
|
||||
if (infile == nullptr) {
|
||||
n = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (maxline-m < 2) reallocate(line,maxline,0);
|
||||
|
||||
// end of file reached, so break
|
||||
|
||||
@ -456,6 +456,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
|
||||
|
||||
if (universe->me == 0) {
|
||||
if (inflag == 0) infile = stdin;
|
||||
else if (strcmp(arg[inflag], "none") == 0) infile = stdin;
|
||||
else infile = fopen(arg[inflag],"r");
|
||||
if (infile == nullptr)
|
||||
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()));
|
||||
}
|
||||
|
||||
infile = fopen(arg[inflag],"r");
|
||||
if (infile == nullptr)
|
||||
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||
arg[inflag], utils::getsyserror()));
|
||||
if (strcmp(arg[inflag], "none") != 0) {
|
||||
infile = fopen(arg[inflag],"r");
|
||||
if (infile == nullptr)
|
||||
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||
arg[inflag], utils::getsyserror()));
|
||||
}
|
||||
}
|
||||
|
||||
// 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"
|
||||
"-echo none/screen/log/both : echoing of input script (-e)\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"
|
||||
"-log none/filename : where to send log output (-l)\n"
|
||||
"-mpicolor color : which exe in a multi-exe mpirun cmd (-m)\n"
|
||||
|
||||
@ -156,11 +156,9 @@ TEST(MPI, multi_partition)
|
||||
lammps_mpi_init();
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &me);
|
||||
fp = fopen("in.mp_dummy", "w");
|
||||
fclose(fp);
|
||||
|
||||
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;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
void *lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
|
||||
@ -184,7 +182,6 @@ TEST(MPI, multi_partition)
|
||||
}
|
||||
|
||||
lammps_close(lmp);
|
||||
unlink("in.mp_dummy");
|
||||
};
|
||||
|
||||
class MPITest : public ::testing::Test {
|
||||
|
||||
Reference in New Issue
Block a user