Merge branch 'develop' into collected-small-fixes

This commit is contained in:
Axel Kohlmeyer
2023-11-10 10:57:08 -05:00
28 changed files with 427 additions and 380 deletions

View File

@ -17,12 +17,16 @@ Syntax
* M = insert a single atom or molecule every M steps
* seed = random # seed (positive integer)
* one or more keyword/value pairs may be appended to args
* keyword = *region* or *id* or *global* or *local* or *near* or *gaussian* or *attempt* or *rate* or *vx* or *vy* or *vz* or *target* or *mol* or *molfrac* or *rigid* or *shake* or *orient* or *units*
* keyword = *region* or *var* or *set* or *id* or *global* or *local* or *near* or *gaussian* or *attempt* or *rate* or *vx* or *vy* or *vz* or *target* or *mol* or *molfrac* or *rigid* or *shake* or *orient* or *units*
.. parsed-literal::
*region* value = region-ID
region-ID = ID of region to use as insertion volume
*var* value = name = variable name to evaluate for test of atom creation
*set* values = dim name
dim = *x* or *y* or *z*
name = name of variable to set with x, y, or z atom position
*id* value = *max* or *next*
max = atom ID for new atom(s) is max ID of all current atoms plus one
next = atom ID for new atom(s) increments by one for every deposition
@ -193,17 +197,19 @@ simulation that is "nearby" the chosen x,y position. In this context,
particles is less than the *delta* setting.
Once a trial x,y,z position has been selected, the insertion is only
performed if no current atom in the simulation is within a distance R
of any atom in the new particle, including the effect of periodic
boundary conditions if applicable. R is defined by the *near*
keyword. Note that the default value for R is 0.0, which will allow
atoms to strongly overlap if you are inserting where other atoms are
present. This distance test is performed independently for each atom
in an inserted molecule, based on the randomly rotated configuration
of the molecule. If this test fails, a new random position within the
insertion volume is chosen and another trial is made. Up to Q
attempts are made. If the particle is not successfully inserted,
LAMMPS prints a warning message.
performed if both the *near* and *var* keywords are satisfied (see below).
If either the *near* or the *var* keyword is not satisfied, a new random
position within the insertion volume is chosen and another trial is made.
Up to Q attempts are made. If one or more particle insertions are not
successful, LAMMPS prints a warning message.
The *near* keyword ensures that no current atom in the simulation is within
a distance R of any atom in the new particle, including the effect of
periodic boundary conditions if applicable. Note that the default value
for R is 0.0, which will allow atoms to strongly overlap if you are
inserting where other atoms are present. This distance test is performed
independently for each atom in an inserted molecule, based on the randomly
rotated configuration of the molecule.
.. note::
@ -214,6 +220,24 @@ LAMMPS prints a warning message.
existing particle. LAMMPS will issue a warning if R is smaller than
this value, based on the radii of existing and inserted particles.
The *var* and *set* keywords can be used together to provide a criterion
for accepting or rejecting the addition of an individual atom, based on its
coordinates. The *name* specified for the *var* keyword is the name of an
:doc:`equal-style variable <variable>` that should evaluate to a zero or
non-zero value based on one or two or three variables that will store the
*x*, *y*, or *z* coordinates of an atom (one variable per coordinate). If
used, these other variables must be :doc:`internal-style variables
<variable>` defined in the input script; their initial numeric value can be
anything. They must be internal-style variables, because this command
resets their values directly. The *set* keyword is used to identify the
names of these other variables, one variable for the *x*-coordinate of a
created atom, one for *y*, and one for *z*. When an atom is created, its
:math:`(x,y,z)` coordinates become the values for any *set* variable that
is defined. The *var* variable is then evaluated. If the returned value
is 0.0, the atom is not created. If it is non-zero, the atom is created.
For an example of how to use these keywords, see the
:doc:`create_atoms <create_atoms>`command.
The *rate* option moves the insertion volume in the z direction (3d)
or y direction (2d). This enables particles to be inserted from a
successively higher height over time. Note that this parameter is

View File

@ -379,8 +379,9 @@ class lammps(object):
for i in range(narg):
if type(cmdargs[i]) is str:
cmdargs[i] = cmdargs[i].encode()
cargs = (c_char_p*narg)(*cmdargs)
self.lib.lammps_open.argtypes = [c_int, c_char_p*narg, MPI_Comm, c_void_p]
cargs = (c_char_p*(narg+1))(*cmdargs)
cargs[narg] = None
self.lib.lammps_open.argtypes = [c_int, c_char_p*(narg+1), MPI_Comm, c_void_p]
else:
self.lib.lammps_open.argtypes = [c_int, c_char_p, MPI_Comm, c_void_p]
@ -399,8 +400,9 @@ class lammps(object):
for i in range(narg):
if type(cmdargs[i]) is str:
cmdargs[i] = cmdargs[i].encode()
cargs = (c_char_p*narg)(*cmdargs)
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p*narg, c_void_p]
cargs = (c_char_p*(narg+1))(*cmdargs)
cargs[narg] = None
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p*(narg+1), c_void_p]
self.lmp = c_void_p(self.lib.lammps_open_no_mpi(narg,cargs,None))
else:
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p, c_void_p]

View File

@ -34,46 +34,10 @@
#endif
#ifdef LMP_KOKKOS_GPU
// for detecting GPU-aware MPI support:
// the variable int have_gpu_aware
// - is 1 if GPU-aware MPI support is available
// - is 0 if GPU-aware MPI support is unavailable
// - is -1 if GPU-aware MPI support is unknown
#define GPU_AWARE_UNKNOWN static int have_gpu_aware = -1;
// TODO HIP: implement HIP-aware MPI support (UCX) detection
#if defined(KOKKOS_ENABLE_HIP) || defined(KOKKOS_ENABLE_SYCL) || defined(KOKKOS_ENABLE_OPENMPTARGET)
GPU_AWARE_UNKNOWN
#elif defined(KOKKOS_ENABLE_CUDA)
// OpenMPI supports detecting GPU-aware MPI as of version 2.0.0
#if (OPEN_MPI)
#if (OMPI_MAJOR_VERSION >= 2)
#if (OPEN_MPI) && (OMPI_MAJOR_VERSION >= 2)
#include <mpi-ext.h>
#if defined(MPIX_CUDA_AWARE_SUPPORT) && MPIX_CUDA_AWARE_SUPPORT
static int have_gpu_aware = 1;
#elif defined(MPIX_CUDA_AWARE_SUPPORT) && !MPIX_CUDA_AWARE_SUPPORT
static int have_gpu_aware = 0;
#else
GPU_AWARE_UNKNOWN
#endif // defined(MPIX_CUDA_AWARE_SUPPORT)
#else // old OpenMPI
GPU_AWARE_UNKNOWN
#endif // (OMPI_MAJOR_VERSION >=2)
#else // unknown MPI library
GPU_AWARE_UNKNOWN
#endif // OPEN_MPI
#endif // KOKKOS_ENABLE_CUDA
#endif // LMP_ENABLE_DEVICE
#endif
#endif
using namespace LAMMPS_NS;
@ -243,8 +207,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
// default settings for package kokkos command
binsize = 0.0;
#ifdef KOKKOS_ENABLE_CUDA
// TODO HIP: implement HIP-aware MPI testing
#if defined(LMP_KOKKOS_GPU)
gpu_aware_flag = 1;
#else
gpu_aware_flag = 0;
@ -282,70 +245,111 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
#ifdef LMP_KOKKOS_GPU
// check and warn about GPU-aware MPI availability when using multiple MPI tasks
// change default only if we can safely detect that GPU-aware MPI is not available
// change default only if we can detect that GPU-aware MPI is not available
int nmpi = 0;
MPI_Comm_size(world,&nmpi);
if (nmpi > 1) {
#if defined(MPI_VERSION) && (MPI_VERSION > 2)
// Check for IBM Spectrum MPI
// for detecting GPU-aware MPI support:
// the variable int have_gpu_aware
// - is 1 if GPU-aware MPI support is available
// - is 0 if GPU-aware MPI support is unavailable
// - is -1 if GPU-aware MPI support is unknown
int len;
char mpi_version[MPI_MAX_LIBRARY_VERSION_STRING];
MPI_Get_library_version(mpi_version, &len);
if (strstr(&mpi_version[0], "Spectrum") != nullptr) {
gpu_aware_flag = 0;
char* str;
if ((str = getenv("OMPI_MCA_pml_pami_enable_cuda")))
if ((strcmp(str,"1") == 0)) {
have_gpu_aware = 1;
gpu_aware_flag = 1;
}
int have_gpu_aware = -1;
if (!gpu_aware_flag)
if (me == 0)
error->warning(FLERR,"The Spectrum MPI '-gpu' flag is not set. Disabling GPU-aware MPI");
}
// OpenMPI
#if (OPEN_MPI)
#if (OMPI_MAJOR_VERSION >= 2)
#if defined(KOKKOS_ENABLE_CUDA)
#if defined(OMPI_HAVE_MPI_EXT_CUDA) && OMPI_HAVE_MPI_EXT_CUDA
have_gpu_aware = MPIX_Query_cuda_support();
#endif
#endif
#if defined(KOKKOS_ENABLE_HIP)
#if defined(OMPI_HAVE_MPI_EXT_ROCM) && OMPI_HAVE_MPI_EXT_ROCM
have_gpu_aware = MPIX_Query_rocm_support();
#elif (OMPI_MAJOR_VERSION < 5)
have_gpu_aware = 0;
#endif
#endif
#else
have_gpu_aware = 0;
#endif // OMPI_MAJOR_VERSION >= 2
if (gpu_aware_flag == 1 && have_gpu_aware == 0) {
if (me == 0)
error->warning(FLERR,"Turning off GPU-aware MPI since it is not detected, "
"use '-pk kokkos gpu/aware on' to override");
gpu_aware_flag = 0;
} else if (have_gpu_aware == -1) { // maybe we are dealing with MPICH, MVAPICH2 or some derivative?
// MVAPICH2
}
#endif // OPEN_MPI
// IBM Spectrum MPI
#if defined(MPI_VERSION) && (MPI_VERSION > 2)
int len;
char mpi_version[MPI_MAX_LIBRARY_VERSION_STRING];
MPI_Get_library_version(mpi_version, &len);
if (strstr(&mpi_version[0], "Spectrum") != nullptr) {
char* str;
have_gpu_aware = 0;
if ((str = getenv("OMPI_MCA_pml_pami_enable_cuda")))
if ((strcmp(str,"1") == 0))
have_gpu_aware = 1;
if (!have_gpu_aware) {
if (me == 0)
error->warning(FLERR,"The Spectrum MPI '-gpu' flag is not set. Disabling GPU-aware MPI");
gpu_aware_flag = 0;
}
}
#endif
if (have_gpu_aware == -1) {
// MVAPICH2
#if defined(MPICH) && defined(MVAPICH2_VERSION)
char* str;
gpu_aware_flag = 0;
have_gpu_aware = 0;
if ((str = getenv("MV2_USE_CUDA")))
if ((strcmp(str,"1") == 0))
gpu_aware_flag = 1;
have_gpu_aware = 1;
if (!gpu_aware_flag)
if (!have_gpu_aware) {
if (me == 0)
error->warning(FLERR,"MVAPICH2 'MV2_USE_CUDA' environment variable is not set. Disabling GPU-aware MPI");
// pure MPICH or some unsupported MPICH derivative
gpu_aware_flag = 0;
}
// pure MPICH or some MPICH derivative
// check for Cray MPICH which has GPU-aware support
#elif defined(MPICH) && !defined(MVAPICH2_VERSION)
char* str;
gpu_aware_flag = 0;
have_gpu_aware = 0;
if ((str = getenv("MPICH_GPU_SUPPORT_ENABLED")))
if ((strcmp(str,"1") == 0))
gpu_aware_flag = 1;
have_gpu_aware = 1;
if (!gpu_aware_flag && me == 0)
error->warning(FLERR,"Detected MPICH. Disabling GPU-aware MPI");
if (!have_gpu_aware) {
if (me == 0)
error->warning(FLERR,"Detected MPICH. Disabling GPU-aware MPI");
gpu_aware_flag = 0;
}
#else
if (me == 0)
error->warning(FLERR,"Kokkos with GPU-enabled backend assumes GPU-aware MPI is available,"
" but cannot determine if this is the case\n try"
" '-pk kokkos gpu/aware off' if getting segmentation faults");
if (me == 0)
error->warning(FLERR,"Kokkos with GPU-enabled backend assumes GPU-aware MPI is available,"
" but cannot determine if this is the case\n try"
" '-pk kokkos gpu/aware off' if getting segmentation faults");
#endif
} // if (-1 == have_gpu_aware)
}
} // nmpi > 0
#endif // LMP_ENABLE_DEVICE
#endif // LMP_KOKKOS_GPU
#ifdef KILL_KOKKOS_ON_SIGSEGV
signal(SIGSEGV, my_signal_handler);

View File

@ -202,8 +202,10 @@ void PairPACEExtrapolation::compute(int eflag, int vflag)
// jnum(0) = 50
// jlist(neigh ind of 0-atom) = [1,2,10,7,99,25, .. 50 element in total]
try {
if (flag_compute_extrapolation_grade)
if (flag_compute_extrapolation_grade) {
aceimpl->ace->compute_projections = true;
aceimpl->ace->compute_atom(i, x, type, jnum, jlist);
}
else
aceimpl->rec_ace->compute_atom(i, x, type, jnum, jlist);
} catch (std::exception &e) {

View File

@ -123,11 +123,9 @@ void AngleWrite::command(int narg, char **arg)
if (comm->me == 0) {
// set up new LAMMPS instance with dummy system to evaluate angle potential
const char *args[] = {"AngleWrite", "-nocite", "-echo", "none",
"-log", "none", "-screen", "none"};
char **argv = (char **) args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS *writer = new LAMMPS(argc, argv, singlecomm);
LAMMPS::argv args = {"AngleWrite", "-nocite", "-echo", "none",
"-log", "none", "-screen", "none"};
LAMMPS *writer = new LAMMPS(args, singlecomm);
// create dummy system replicating angle style settings
writer->input->one(fmt::format("units {}", update->unit_style));

View File

@ -124,12 +124,8 @@ void DihedralWrite::command(int narg, char **arg)
if (comm->me == 0) {
// set up new LAMMPS instance with dummy system to evaluate dihedral potential
// const char *args[] = {"DihedralWrite", "-nocite", "-echo", "none",
// "-log", "none", "-screen", "none"};
const char *args[] = {"DihedralWrite", "-nocite", "-echo", "screen", "-log", "none"};
char **argv = (char **) args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS *writer = new LAMMPS(argc, argv, singlecomm);
LAMMPS::argv args = {"DihedralWrite", "-nocite", "-echo", "screen", "-log", "none"};
LAMMPS *writer = new LAMMPS(args, singlecomm);
// create dummy system replicating dihedral style settings
writer->input->one(fmt::format("units {}", update->unit_style));

View File

@ -20,6 +20,7 @@
#include "domain.h"
#include "error.h"
#include "fix.h"
#include "input.h"
#include "lattice.h"
#include "math_const.h"
#include "math_extra.h"
@ -29,6 +30,7 @@
#include "random_park.h"
#include "region.h"
#include "update.h"
#include "variable.h"
#include <cmath>
#include <cstring>
@ -209,6 +211,10 @@ FixDeposit::~FixDeposit()
delete [] idrigid;
delete [] idshake;
delete [] idregion;
delete [] vstr;
delete [] xstr;
delete [] ystr;
delete [] zstr;
memory->destroy(coords);
memory->destroy(imageflags);
}
@ -226,6 +232,8 @@ int FixDeposit::setmask()
void FixDeposit::init()
{
warnflag = 1;
// set index and check validity of region
iregion = domain->get_region_by_id(idregion);
@ -361,6 +369,8 @@ void FixDeposit::pre_exchange()
} while (iregion->match(coord[0],coord[1],coord[2]) == 0);
} else error->all(FLERR,"Unknown particle distribution in fix deposit");
if (varflag && vartest(coord[0],coord[1],coord[2]) == 0) continue;
// adjust vertical coord by offset
if (dimension == 2) coord[1] += offset;
@ -583,8 +593,10 @@ void FixDeposit::pre_exchange()
// warn if not successful b/c too many attempts
if (!success && comm->me == 0)
error->warning(FLERR,"Particle deposition was unsuccessful");
if (warnflag && !success && comm->me == 0) {
error->warning(FLERR,"One or more particle depositions were unsuccessful");
warnflag = 0;
}
// reset global natoms,nbonds,etc
// increment maxtag_all and maxmol_all if necessary
@ -661,6 +673,8 @@ void FixDeposit::options(int narg, char **arg)
iregion = nullptr;
idregion = nullptr;
varflag = 0;
vstr = xstr = ystr = zstr = nullptr;
mode = ATOM;
molfrac = nullptr;
rigidflag = 0;
@ -680,6 +694,7 @@ void FixDeposit::options(int narg, char **arg)
scaleflag = 1;
targetflag = 0;
orientflag = 0;
warnflag = 1;
rx = 0.0;
ry = 0.0;
rz = 0.0;
@ -693,6 +708,27 @@ void FixDeposit::options(int narg, char **arg)
idregion = utils::strdup(arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg], "var") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix deposit var", error);
delete[] vstr;
vstr = utils::strdup(arg[iarg + 1]);
varflag = 1;
iarg += 2;
} else if (strcmp(arg[iarg], "set") == 0) {
if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, "fix deposit set", error);
if (strcmp(arg[iarg + 1], "x") == 0) {
delete[] xstr;
xstr = utils::strdup(arg[iarg + 2]);
} else if (strcmp(arg[iarg + 1], "y") == 0) {
delete[] ystr;
ystr = utils::strdup(arg[iarg + 2]);
} else if (strcmp(arg[iarg + 1], "z") == 0) {
delete[] zstr;
zstr = utils::strdup(arg[iarg + 2]);
} else
error->all(FLERR, "Unknown fix deposit set option {}", arg[iarg + 2]);
iarg += 3;
} else if (strcmp(arg[iarg],"mol") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix deposit command");
int imol = atom->find_molecule(arg[iarg+1]);
@ -815,6 +851,39 @@ void FixDeposit::options(int narg, char **arg)
iarg += 4;
} else error->all(FLERR,"Illegal fix deposit command");
}
// error check and further setup for variable test
if (!vstr && (xstr || ystr || zstr))
error->all(FLERR, "Incomplete use of variables in fix deposit command");
if (vstr && (!xstr && !ystr && !zstr))
error->all(FLERR, "Incomplete use of variables in fix deposit command");
if (varflag) {
vvar = input->variable->find(vstr);
if (vvar < 0) error->all(FLERR, "Variable {} for fix deposit does not exist", vstr);
if (!input->variable->equalstyle(vvar))
error->all(FLERR, "Variable for fix deposit is invalid style");
if (xstr) {
xvar = input->variable->find(xstr);
if (xvar < 0) error->all(FLERR, "Variable {} for fix deposit does not exist", xstr);
if (!input->variable->internalstyle(xvar))
error->all(FLERR, "Variable for fix deposit is invalid style");
}
if (ystr) {
yvar = input->variable->find(ystr);
if (yvar < 0) error->all(FLERR, "Variable {} for fix deposit does not exist", ystr);
if (!input->variable->internalstyle(yvar))
error->all(FLERR, "Variable for fix deposit is invalid style");
}
if (zstr) {
zvar = input->variable->find(zstr);
if (zvar < 0) error->all(FLERR, "Variable {} for fix deposit does not exist", zstr);
if (!input->variable->internalstyle(zvar))
error->all(FLERR, "Variable for fix deposit is invalid style");
}
}
}
/* ----------------------------------------------------------------------
@ -908,3 +977,20 @@ void *FixDeposit::extract(const char *str, int &itype)
return nullptr;
}
/* ----------------------------------------------------------------------
test a generated atom position against variable evaluation
first set x,y,z values in internal variables
------------------------------------------------------------------------- */
int FixDeposit::vartest(double x, double y, double z)
{
if (xstr) input->variable->internal_set(xvar, x);
if (ystr) input->variable->internal_set(yvar, y);
if (zstr) input->variable->internal_set(zvar, z);
double value = input->variable->compute_equal(vvar);
if (value == 0.0) return 0;
return 1;
}

View File

@ -40,7 +40,8 @@ class FixDeposit : public Fix {
private:
int ninsert, ntype, nfreq, seed;
int globalflag, localflag, maxattempt, rateflag, scaleflag, targetflag;
int mode, rigidflag, shakeflag, idnext, distflag, orientflag;
int mode, rigidflag, shakeflag, idnext, distflag, orientflag, warnflag;
int varflag, vvar, xvar, yvar, zvar;
double lo, hi, deltasq, nearsq, rate, sigma;
double vxlo, vxhi, vylo, vyhi, vzlo, vzhi;
double xlo, xhi, ylo, yhi, zlo, zhi, xmid, ymid, zmid;
@ -48,6 +49,8 @@ class FixDeposit : public Fix {
class Region *iregion;
char *idregion;
char *idrigid, *idshake;
char *vstr, *xstr, *ystr, *zstr;
char *xstr_copy, *ystr_copy, *zstr_copy;
class Molecule **onemols;
int nmol, natom_max;
@ -64,6 +67,7 @@ class FixDeposit : public Fix {
void find_maxid();
void options(int, char **);
int vartest(double, double, double); // evaluate a variable with new atom position
};
} // namespace LAMMPS_NS

View File

@ -109,6 +109,15 @@ using namespace LAMMPS_NS;
* The specifics of setting up and running a simulation are handled by the
* individual component class instances. */
/** Create a LAMMPS simulation instance
*
* \param args list of arguments
* \param communicator MPI communicator used by this LAMMPS instance
*/
LAMMPS::LAMMPS(argv & args, MPI_Comm communicator) :
LAMMPS(args.size(), argv_pointers(args).data(), communicator) {
}
/** Create a LAMMPS simulation instance
*
* The LAMMPS constructor starts up a simulation by allocating all
@ -212,7 +221,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
suffix = suffix2 = nullptr;
suffix_enable = 0;
pair_only_flag = 0;
if (arg) exename = arg[0];
if (arg) exename = utils::strdup(arg[0]);
else exename = nullptr;
packargs = nullptr;
num_package = 0;
@ -802,6 +811,7 @@ LAMMPS::~LAMMPS() noexcept(false)
delete memory;
delete pkg_lists;
delete[] exename;
}
/* ----------------------------------------------------------------------
@ -1468,3 +1478,17 @@ void LAMMPS::print_config(FILE *fp)
}
fputs("\n\n",fp);
}
/** Create vector of argv string pointers including terminating nullptr element
*
* \param args list of arguments
*/
std::vector<char*> LAMMPS::argv_pointers(argv & args){
std::vector<char*> r;
r.reserve(args.size()+1);
for(auto & a : args) {
r.push_back((char*)a.data());
}
r.push_back(nullptr);
return r;
}

View File

@ -16,6 +16,8 @@
#include <cstdio>
#include <mpi.h>
#include <string>
#include <vector>
namespace LAMMPS_NS {
@ -84,6 +86,10 @@ class LAMMPS {
static const char *git_branch();
static const char *git_descriptor();
using argv = std::vector<std::string>;
static std::vector<char*> argv_pointers(argv & args);
LAMMPS(argv & args, MPI_Comm);
LAMMPS(int, char **, MPI_Comm);
~LAMMPS() noexcept(false);
void create();

View File

@ -26,10 +26,11 @@ protected:
void SetUp() override
{
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite",
"-var", "x", "2", "-var", "zpos", "1.5"};
"-var", "x", "2", "-var", "zpos", "1.5",
nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
lmp = lammps_open_no_mpi(argc, argv, nullptr);

View File

@ -29,10 +29,11 @@ protected:
{
const char *args[] = {"LAMMPS_test", "-log", "none",
"-echo", "screen", "-nocite",
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER)};
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER),
nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
lmp = lammps_open_no_mpi(argc, argv, nullptr);

View File

@ -64,9 +64,9 @@ static void callback(void *handle, step_t timestep, int nlocal, tag_t *, double
TEST(lammps_external, callback)
{
const char *args[] = {"liblammps", "-log", "none", "-nocite"};
const char *args[] = {"liblammps", "-log", "none", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
void *handle = lammps_open_no_mpi(argc, argv, nullptr);
@ -131,9 +131,9 @@ TEST(lammps_external, callback)
TEST(lammps_external, array)
{
const char *args[] = {"liblammps", "-log", "none", "-nocite"};
const char *args[] = {"liblammps", "-log", "none", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
void *handle = lammps_open_no_mpi(argc, argv, nullptr);

View File

@ -34,9 +34,9 @@ TEST(MPI, global_box)
int boxflag;
::testing::internal::CaptureStdout();
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite"};
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
void *lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
lammps_command(lmp, "units lj");
lammps_command(lmp, "atom_style atomic");
@ -77,9 +77,9 @@ TEST(MPI, sub_box)
int boxflag;
::testing::internal::CaptureStdout();
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite"};
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
void *lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
lammps_command(lmp, "units lj");
lammps_command(lmp, "atom_style atomic");
@ -143,9 +143,9 @@ TEST(MPI, split_comm)
MPI_Comm_split(MPI_COMM_WORLD, color, key, &newcomm);
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite"};
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
void *lmp = lammps_open(argc, argv, newcomm, nullptr);
lammps_command(lmp, "units lj");
lammps_command(lmp, "atom_style atomic");
@ -173,9 +173,9 @@ TEST(MPI, multi_partition)
MPI_Comm_rank(MPI_COMM_WORLD, &me);
const char *args[] = {"LAMMPS_test", "-log", "none", "-partition", "4x1",
"-echo", "screen", "-nocite", "-in", "none"};
"-echo", "screen", "-nocite", "-in", "none", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
void *lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
lammps_command(lmp, "units lj");
@ -205,9 +205,9 @@ protected:
void SetUp() override
{
const char *args[] = {testbinary, "-log", "none", "-echo", "screen", "-nocite"};
const char *args[] = {testbinary, "-log", "none", "-echo", "screen", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
if (!verbose) ::testing::internal::CaptureStdout();
lmp = lammps_open(argc, argv, MPI_COMM_WORLD, nullptr);
InitSystem();

View File

@ -39,9 +39,9 @@ TEST(lammps_open, null_args)
TEST(lammps_open, with_args)
{
const char *args[] = {"liblammps", "-log", "none", "-nocite"};
const char *args[] = {"liblammps", "-log", "none", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
// MPI is already initialized
MPI_Comm mycomm;
@ -78,9 +78,9 @@ TEST(lammps_open, with_args)
TEST(lammps_open, with_kokkos)
{
if (!LAMMPS_NS::LAMMPS::is_installed_pkg("KOKKOS")) GTEST_SKIP();
const char *args[] = {"liblammps", "-k", "on", "t", "2", "-sf", "kk", "-log", "none"};
const char *args[] = {"liblammps", "-k", "on", "t", "2", "-sf", "kk", "-log", "none", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
void *alt_ptr;
@ -108,9 +108,9 @@ TEST(lammps_open, with_kokkos)
TEST(lammps_open_no_mpi, no_screen)
{
const char *args[] = {"liblammps", "-log", "none", "-screen", "none", "-nocite"};
const char *args[] = {"liblammps", "-log", "none", "-screen", "none", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
void *alt_ptr;
@ -139,9 +139,9 @@ TEST(lammps_open_no_mpi, with_omp)
{
if (!LAMMPS_NS::LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
const char *args[] = {"liblammps", "-pk", "omp", "2", "neigh", "no",
"-sf", "omp", "-log", "none", "-nocite"};
"-sf", "omp", "-log", "none", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
void *alt_ptr;
@ -201,9 +201,9 @@ TEST(lammps_open_fortran, no_args)
TEST(lammps_open_no_mpi, lammps_error)
{
const char *args[] = {"liblammps", "-log", "none", "-nocite"};
const char *args[] = {"liblammps", "-log", "none", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
void *alt_ptr;

View File

@ -33,10 +33,11 @@ protected:
{
const char *args[] = {"LAMMPS_test", "-log", "none",
"-echo", "screen", "-nocite",
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER)};
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER),
nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
lmp = lammps_open_no_mpi(argc, argv, nullptr);
@ -551,10 +552,10 @@ protected:
void SetUp() override
{
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite"};
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite", nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
lmp = lammps_open_no_mpi(argc, argv, nullptr);
@ -632,10 +633,10 @@ TEST(SystemSettings, kokkos)
// clang-format off
const char *args[] = {"SystemSettings", "-log", "none", "-echo", "screen", "-nocite",
"-k", "on", "t", "4", "-sf", "kk"};
"-k", "on", "t", "4", "-sf", "kk", nullptr};
// clang-format on
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
void *lmp = lammps_open_no_mpi(argc, argv, nullptr);

View File

@ -32,10 +32,11 @@ protected:
{
const char *args[] = {"LAMMPS_test", "-log", "none",
"-echo", "screen", "-nocite",
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER)};
"-var", "input_dir", STRINGIFY(TEST_INPUT_FOLDER),
nullptr};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
int argc = (sizeof(args) / sizeof(char *)) - 1;
::testing::internal::CaptureStdout();
lmp = lammps_open_no_mpi(argc, argv, nullptr);

View File

@ -33,11 +33,9 @@ protected:
void SetUp() override
{
const char *args[] = {testbinary, "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {testbinary, "-log", "none", "-echo", "screen", "-nocite"};
if (!verbose) ::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
InitSystem();
if (!verbose) ::testing::internal::GetCapturedStdout();
}

View File

@ -8,6 +8,7 @@
#include <mpi.h>
#include <string>
#include "../testing/utils.h"
#include "gtest/gtest.h"
const char *demo_input[] = {"region box block 0 $x 0 2 0 2", "create_box 1 box",
@ -21,9 +22,9 @@ protected:
LAMMPS *lmp;
Input_commands()
{
const char *args[] = {"LAMMPS_test"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
const char * args[] = {"LAMMPS_test", nullptr};
char ** argv = (char**)args;
int argc = 1;
int flag;
MPI_Initialized(&flag);
@ -33,13 +34,11 @@ protected:
void SetUp() override
{
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite",
"-var", "zpos", "1.5", "-var", "x", "2"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite",
"-var", "zpos", "1.5", "-var", "x", "2"};
::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.substr(0, 8).c_str(), "LAMMPS (");
}

View File

@ -21,9 +21,9 @@ protected:
LAMMPS *lmp;
LAMMPS_plain() : lmp(nullptr)
{
const char *args[] = {"LAMMPS_test"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
const char * args[] = {"LAMMPS_test", nullptr};
char ** argv = (char**)args;
int argc = 1;
int flag;
MPI_Initialized(&flag);
@ -34,12 +34,10 @@ protected:
void SetUp() override
{
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "both", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-echo", "both", "-nocite"};
::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_THAT(output, StartsWith("LAMMPS ("));
}
@ -159,9 +157,9 @@ protected:
LAMMPS *lmp;
LAMMPS_omp() : lmp(nullptr)
{
const char *args[] = {"LAMMPS_test"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
const char * args[] = {"LAMMPS_test", nullptr};
char ** argv = (char**)args;
int argc = 1;
int flag;
MPI_Initialized(&flag);
@ -172,15 +170,13 @@ protected:
void SetUp() override
{
const char *args[] = {"LAMMPS_test", "-log", "none", "-screen", "none", "-echo", "screen",
"-pk", "omp", "2", "neigh", "yes", "-sf", "omp"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-screen", "none", "-echo", "screen",
"-pk", "omp", "2", "neigh", "yes", "-sf", "omp"};
// only run this test fixture with omp suffix if OPENMP package is installed
if (LAMMPS::is_installed_pkg("OPENMP"))
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
else
GTEST_SKIP();
}
@ -242,9 +238,9 @@ protected:
LAMMPS *lmp;
LAMMPS_kokkos() : lmp(nullptr)
{
const char *args[] = {"LAMMPS_test"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
const char * args[] = {"LAMMPS_test", nullptr};
char ** argv = (char**)args;
int argc = 1;
int flag;
MPI_Initialized(&flag);
@ -255,15 +251,13 @@ protected:
void SetUp() override
{
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "none", "-screen", "none",
"-k", "on", "t", "1", "-sf", "kk"};
LAMMPS::argv args = {"LAMMPS_test", "-log", "none", "-echo", "none", "-screen", "none",
"-k", "on", "t", "1", "-sf", "kk"};
if (Info::has_accelerator_feature("KOKKOS", "api", "openmp")) args[10] = "2";
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
if (LAMMPS::is_installed_pkg("KOKKOS")) {
::testing::internal::CaptureStdout();
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
::testing::internal::GetCapturedStdout();
} else
GTEST_SKIP();
@ -333,12 +327,10 @@ TEST(LAMMPS_init, OpenMP)
fputs("\n", fp);
fclose(fp);
const char *args[] = {"LAMMPS_init", "-in", "in.lammps_empty", "-log", "none", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"LAMMPS_init", "-in", "in.lammps_empty", "-log", "none", "-nocite"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
LAMMPS *lmp = new LAMMPS(args, MPI_COMM_WORLD);
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_THAT(output, ContainsRegex(".*using 2 OpenMP thread.*per MPI task.*"));
@ -366,12 +358,10 @@ TEST(LAMMPS_init, NoOpenMP)
fclose(fp);
platform::unsetenv("OMP_NUM_THREADS");
const char *args[] = {"LAMMPS_init", "-in", "in.lammps_class_noomp", "-log", "none", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"LAMMPS_init", "-in", "in.lammps_class_noomp", "-log", "none", "-nocite"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
LAMMPS *lmp = new LAMMPS(args, MPI_COMM_WORLD);
std::string output = ::testing::internal::GetCapturedStdout();
EXPECT_THAT(output, ContainsRegex(
".*OMP_NUM_THREADS environment is not set.*Defaulting to 1 thread.*"));

View File

@ -59,11 +59,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
delete lmp;
}
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
LAMMPS *init_lammps(LAMMPS::argv & args, const TestConfig &cfg, const bool newton = true)
{
LAMMPS *lmp;
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
// check if prerequisite styles are available
Info *info = new Info(lmp);
@ -211,11 +211,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
void generate_yaml_file(const char *outfile, const TestConfig &config)
{
// initialize system geometry
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS *lmp = init_lammps(argc, argv, config);
LAMMPS *lmp = init_lammps(args, config);
if (!lmp) {
std::cerr << "One or more prerequisite styles are not available "
"in this LAMMPS configuration:\n";
@ -303,13 +301,10 @@ TEST(AngleStyle, plain)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -358,7 +353,7 @@ TEST(AngleStyle, plain)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
// skip over these tests if newton bond is forced to be on
@ -422,14 +417,11 @@ TEST(AngleStyle, omp)
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -482,7 +474,7 @@ TEST(AngleStyle, omp)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
// skip over these tests if newton bond is forced to be on
@ -525,14 +517,11 @@ TEST(AngleStyle, single)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
// create a LAMMPS instance with standard settings to detect the number of atom types
if (!verbose) ::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config);
LAMMPS *lmp = init_lammps(args, test_config);
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!lmp) {
@ -672,13 +661,10 @@ TEST(AngleStyle, extract)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite"};
if (!verbose) ::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!lmp) {

View File

@ -59,11 +59,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
delete lmp;
}
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
LAMMPS *init_lammps(LAMMPS::argv & args, const TestConfig &cfg, const bool newton = true)
{
LAMMPS *lmp;
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
// check if prerequisite styles are available
Info *info = new Info(lmp);
@ -211,11 +211,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
void generate_yaml_file(const char *outfile, const TestConfig &config)
{
// initialize system geometry
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS *lmp = init_lammps(argc, argv, config);
LAMMPS *lmp = init_lammps(args, config);
if (!lmp) {
std::cerr << "One or more prerequisite styles are not available "
"in this LAMMPS configuration:\n";
@ -303,13 +301,10 @@ TEST(BondStyle, plain)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -358,7 +353,7 @@ TEST(BondStyle, plain)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
// skip over these tests if newton bond is forced to be on
@ -424,14 +419,11 @@ TEST(BondStyle, omp)
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -484,7 +476,7 @@ TEST(BondStyle, omp)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
// skip over these tests if newton bond is forced to be on
@ -527,14 +519,11 @@ TEST(BondStyle, single)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
// create a LAMMPS instance with standard settings to detect the number of atom types
if (!verbose) ::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config);
LAMMPS *lmp = init_lammps(args, test_config);
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!lmp) {
@ -785,13 +774,10 @@ TEST(BondStyle, extract)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"BondStyle", "-log", "none", "-echo", "screen", "-nocite"};
if (!verbose) ::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!lmp) {

View File

@ -59,11 +59,9 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
delete lmp;
}
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
LAMMPS *init_lammps(LAMMPS::argv & args, const TestConfig &cfg, const bool newton = true)
{
LAMMPS *lmp;
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
LAMMPS *lmp = new LAMMPS(args, MPI_COMM_WORLD);
// check if prerequisite styles are available
Info *info = new Info(lmp);
@ -220,11 +218,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
void generate_yaml_file(const char *outfile, const TestConfig &config)
{
// initialize system geometry
const char *args[] = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite"};
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS *lmp = init_lammps(argc, argv, config);
LAMMPS *lmp = init_lammps(args, config);
if (!lmp) {
std::cerr << "One or more prerequisite styles are not available "
"in this LAMMPS configuration:\n";
@ -306,13 +302,10 @@ TEST(DihedralStyle, plain)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -361,7 +354,7 @@ TEST(DihedralStyle, plain)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
// skip over these tests if newton bond is forced to be on
@ -427,14 +420,11 @@ TEST(DihedralStyle, omp)
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"DihedralStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -488,7 +478,7 @@ TEST(DihedralStyle, omp)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
// skip over these tests if newton bond is forced to be on

View File

@ -61,11 +61,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
delete lmp;
}
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool use_respa = false)
LAMMPS *init_lammps(LAMMPS::argv & args, const TestConfig &cfg, const bool use_respa = false)
{
LAMMPS *lmp;
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
// check if prerequisite styles are available
Info *info = new Info(lmp);
@ -169,11 +169,8 @@ void restart_lammps(LAMMPS *lmp, const TestConfig &cfg, bool use_rmass, bool use
void generate_yaml_file(const char *outfile, const TestConfig &config)
{
// initialize system geometry
const char *args[] = {"FixIntegrate", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS *lmp = init_lammps(argc, argv, config);
LAMMPS::argv args = {"FixIntegrate", "-log", "none", "-echo", "screen", "-nocite"};
LAMMPS *lmp = init_lammps(args, config);
if (!lmp) {
std::cerr << "One or more prerequisite styles are not available "
"in this LAMMPS configuration:\n";
@ -252,13 +249,10 @@ TEST(FixTimestep, plain)
if (test_config.skip_tests.count("static")) GTEST_SKIP();
#endif
const char *args[] = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config);
LAMMPS *lmp = init_lammps(args, test_config);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -420,7 +414,7 @@ TEST(FixTimestep, plain)
if (!verbose) ::testing::internal::GetCapturedStdout();
::testing::internal::CaptureStdout();
lmp = init_lammps(argc, argv, test_config, true);
lmp = init_lammps(args, test_config, true);
output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -554,14 +548,12 @@ TEST(FixTimestep, omp)
if (test_config.skip_tests.count("static")) GTEST_SKIP();
#endif
const char *args[] = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
LAMMPS::argv args = {"FixTimestep", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config);
LAMMPS *lmp = init_lammps(args, test_config);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -723,7 +715,7 @@ TEST(FixTimestep, omp)
if (!verbose) ::testing::internal::GetCapturedStdout();
::testing::internal::CaptureStdout();
lmp = init_lammps(argc, argv, test_config, true);
lmp = init_lammps(args, test_config, true);
output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;

View File

@ -59,11 +59,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
delete lmp;
}
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
LAMMPS *init_lammps(LAMMPS::argv & args, const TestConfig &cfg, const bool newton = true)
{
LAMMPS *lmp;
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
// check if prerequisite styles are available
Info *info = new Info(lmp);
@ -211,11 +211,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
void generate_yaml_file(const char *outfile, const TestConfig &config)
{
// initialize system geometry
const char *args[] = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS *lmp = init_lammps(argc, argv, config);
LAMMPS *lmp = init_lammps(args, config);
if (!lmp) {
std::cerr << "One or more prerequisite styles are not available "
"in this LAMMPS configuration:\n";
@ -297,13 +295,10 @@ TEST(ImproperStyle, plain)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -352,7 +347,7 @@ TEST(ImproperStyle, plain)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
// skip over these tests if newton bond is forced to be on
@ -418,14 +413,11 @@ TEST(ImproperStyle, omp)
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -479,7 +471,7 @@ TEST(ImproperStyle, omp)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
// skip over these tests if newton bond is forced to be on

View File

@ -61,11 +61,11 @@ void cleanup_lammps(LAMMPS *lmp, const TestConfig &cfg)
delete lmp;
}
LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool newton = true)
LAMMPS *init_lammps(LAMMPS::argv & args, const TestConfig &cfg, const bool newton = true)
{
LAMMPS *lmp;
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(args, MPI_COMM_WORLD);
// check if prerequisite styles are available
Info *info = new Info(lmp);
@ -225,11 +225,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg)
void generate_yaml_file(const char *outfile, const TestConfig &config)
{
// initialize system geometry
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS *lmp = init_lammps(argc, argv, config);
LAMMPS *lmp = init_lammps(args, config);
if (!lmp) {
std::cerr << "One or more prerequisite styles are not available "
"in this LAMMPS configuration:\n";
@ -323,13 +321,10 @@ TEST(PairStyle, plain)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -388,7 +383,7 @@ TEST(PairStyle, plain)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
// skip over these tests if newton pair is forced to be on
@ -469,7 +464,7 @@ TEST(PairStyle, plain)
if (pair->respa_enable) {
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
lmp->input->one("run_style respa 2 1 inner 1 4.8 5.5 outer 2");
run_lammps(lmp);
if (!verbose) ::testing::internal::GetCapturedStdout();
@ -501,17 +496,14 @@ TEST(PairStyle, omp)
if (!LAMMPS::is_installed_pkg("OPENMP")) GTEST_SKIP();
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "omp", "4", "-sf", "omp"};
// cannot run dpd styles with more than 1 thread due to using multiple pRNGs
if (utils::strmatch(test_config.pair_style, "^dpd")) args[8] = "1";
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -570,7 +562,7 @@ TEST(PairStyle, omp)
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
pair = lmp->force->pair;
@ -626,8 +618,8 @@ TEST(PairStyle, kokkos_omp)
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
if (!Info::has_accelerator_feature("KOKKOS", "api", "openmp")) GTEST_SKIP();
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
"-k", "on", "t", "4", "-sf", "kk"};
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
"-k", "on", "t", "4", "-sf", "kk"};
// cannot run dpd styles in plain or hybrid with more than 1 thread due to using multiple pRNGs
if (utils::strmatch(test_config.pair_style, "^dpd") ||
@ -642,11 +634,8 @@ TEST(PairStyle, kokkos_omp)
utils::strmatch(test_config.pair_style, " pace"))
args[9] = "1";
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -704,7 +693,7 @@ TEST(PairStyle, kokkos_omp)
if (lmp->force->newton_pair == 0) {
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp, test_config);
lmp = init_lammps(argc, argv, test_config, false);
lmp = init_lammps(args, test_config, false);
if (!verbose) ::testing::internal::GetCapturedStdout();
pair = lmp->force->pair;
@ -767,22 +756,19 @@ TEST(PairStyle, gpu)
(!Info::has_fft_single_support()))
GTEST_SKIP();
const char *args_neigh[] = {"PairStyle", "-log", "none", "-echo",
"screen", "-nocite", "-sf", "gpu"};
const char *args_noneigh[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf",
"gpu", "-pk", "gpu", "0", "neigh", "no"};
char **argv = (char **)args_neigh;
int argc = sizeof(args_neigh) / sizeof(char *);
LAMMPS::argv args_neigh = {"PairStyle", "-log", "none", "-echo",
"screen", "-nocite", "-sf", "gpu"};
LAMMPS::argv args_noneigh = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf",
"gpu", "-pk", "gpu", "0", "neigh", "no"};
LAMMPS::argv args = args_neigh;
// cannot use GPU neighbor list with hybrid pair style (yet)
if (test_config.pair_style.substr(0, 6) == "hybrid") {
argv = (char **)args_noneigh;
argc = sizeof(args_noneigh) / sizeof(char *);
args = args_noneigh;
}
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, false);
LAMMPS *lmp = init_lammps(args, test_config, false);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -854,18 +840,15 @@ TEST(PairStyle, intel)
if (!LAMMPS::is_installed_pkg("INTEL")) GTEST_SKIP();
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "intel", "0", "mode", "double", "omp",
"4", "lrt", "no", "-sf", "intel"};
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite",
"-pk", "intel", "0", "mode", "double", "omp",
"4", "lrt", "no", "-sf", "intel"};
// cannot use more than 1 thread for dpd styles due to pRNG
if (utils::strmatch(test_config.pair_style, "^dpd")) args[12] = "1";
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -942,13 +925,10 @@ TEST(PairStyle, opt)
if (!LAMMPS::is_installed_pkg("OPT")) GTEST_SKIP();
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf", "opt"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite", "-sf", "opt"};
::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config);
LAMMPS *lmp = init_lammps(args, test_config);
std::string output = ::testing::internal::GetCapturedStdout();
if (verbose) std::cout << output;
@ -1025,17 +1005,14 @@ TEST(PairStyle, single)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
// need to add this dependency
test_config.prerequisites.emplace_back("atom", "full");
// create a LAMMPS instance with standard settings to detect the number of atom types
if (!verbose) ::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config);
LAMMPS *lmp = init_lammps(args, test_config);
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!lmp) {
@ -1276,13 +1253,10 @@ TEST(PairStyle, extract)
{
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
const char *args[] = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(char *);
LAMMPS::argv args = {"PairStyle", "-log", "none", "-echo", "screen", "-nocite"};
if (!verbose) ::testing::internal::CaptureStdout();
LAMMPS *lmp = init_lammps(argc, argv, test_config, true);
LAMMPS *lmp = init_lammps(args, test_config, true);
if (!verbose) ::testing::internal::GetCapturedStdout();
if (!lmp) {

View File

@ -71,10 +71,10 @@ protected:
// clang-format off
const char *args[] =
{ "LAMMPS_Fortran_test", "-l", "none", "-echo", "screen", "-nocite",
"-var", "input_dir", input_dir, "-var", "zpos", "1.5", "-var", "x", "2" };
"-var", "input_dir", input_dir, "-var", "zpos", "1.5", "-var", "x", "2", nullptr };
// clang-format on
char **argv = (char **)args;
int argc = sizeof(args) / sizeof(const char *);
int argc = (sizeof(args) / sizeof(const char *)) - 1;
::testing::internal::CaptureStdout();
lmp = (LAMMPS_NS::LAMMPS *)f_lammps_with_c_args(argc, argv);

View File

@ -106,31 +106,21 @@ public:
}
protected:
std::string testbinary = "LAMMPSTest";
std::vector<std::string> args = {"-log", "none", "-echo", "screen", "-nocite"};
std::string testbinary = "LAMMPSTest";
LAMMPS::argv args = {"-log", "none", "-echo", "screen", "-nocite"};
LAMMPS *lmp;
Info *info;
void SetUp() override
{
int argc = args.size() + 1;
char **argv = new char *[argc];
argv[0] = LAMMPS_NS::utils::strdup(testbinary);
for (int i = 1; i < argc; i++) {
argv[i] = LAMMPS_NS::utils::strdup(args[i - 1]);
}
LAMMPS::argv full_args = {testbinary};
full_args.insert(full_args.end(), args.begin(), args.end());
HIDE_OUTPUT([&] {
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
lmp = new LAMMPS(full_args, MPI_COMM_WORLD);
info = new Info(lmp);
});
InitSystem();
for (int i = 0; i < argc; i++) {
delete[] argv[i];
argv[i] = nullptr;
}
delete[] argv;
}
virtual void InitSystem() {}