Merge pull request #4440 from akohlmey/collected-small-changes

Collected small changes and fixes
This commit is contained in:
Axel Kohlmeyer
2025-01-28 16:28:11 -05:00
committed by GitHub
32 changed files with 387 additions and 272 deletions

View File

@ -32,9 +32,9 @@ endif()
# Note: must also adjust check for supported API versions in
# fix_plumed.cpp when version changes from v2.n.x to v2.n+1.y
set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.9.2/plumed-src-2.9.2.tgz"
set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.9.3/plumed-src-2.9.3.tgz"
CACHE STRING "URL for PLUMED tarball")
set(PLUMED_MD5 "04862602a372c1013bdfee2d6d03bace" CACHE STRING "MD5 checksum of PLUMED tarball")
set(PLUMED_MD5 "ee1249805fe94bccee17d10610d3f6f1" CACHE STRING "MD5 checksum of PLUMED tarball")
mark_as_advanced(PLUMED_URL)
mark_as_advanced(PLUMED_MD5)

View File

@ -196,13 +196,18 @@ LAMMPS.
.. tab:: CMake build
By default CMake will use the compiler it finds according to
By default CMake will use the compiler it finds according to its
internal preferences, and it will add optimization flags
appropriate to that compiler and any :doc:`accelerator packages
<Speed_packages>` you have included in the build. CMake will
check if the detected or selected compiler is compatible with the
C++ support requirements of LAMMPS and stop with an error, if this
is not the case.
is not the case. A C++11 compatible compiler is currently
required, but a transition to require C++17 is in progess and
planned to be completed in Summer 2025. Currently, setting
``-DLAMMPS_CXX11=yes`` is required when configuring with CMake while
using a C++11 compatible compiler that does not support C++17,
otherwise setting ``-DCMAKE_CXX_STANDARD=17`` is preferred.
You can tell CMake to look for a specific compiler with setting
CMake variables (listed below) during configuration. For a few
@ -223,6 +228,8 @@ LAMMPS.
-D CMAKE_C_COMPILER=name # name of C compiler
-D CMAKE_Fortran_COMPILER=name # name of Fortran compiler
-D CMAKE_CXX_STANDARD=17 # put compiler in C++17 mode
-D LAMMPS_CXX11=yes # enforce compilation in C++11 mode
-D CMAKE_CXX_FLAGS=string # flags to use with C++ compiler
-D CMAKE_C_FLAGS=string # flags to use with C compiler
-D CMAKE_Fortran_FLAGS=string # flags to use with Fortran compiler
@ -321,15 +328,23 @@ LAMMPS.
you would have to install a newer compiler that supports C++11;
either as a binary package or through compiling from source.
If you build LAMMPS with any :doc:`Speed_packages` included,
there may be specific compiler or linker flags that are either
required or recommended to enable required features and to
achieve optimal performance. You need to include these in the
``CCFLAGS`` and ``LINKFLAGS`` settings above. For details, see the
documentation for the individual packages listed on the
:doc:`Speed_packages` page. Or examine these files in the
``src/MAKE/OPTIONS`` directory. They correspond to each of the 5
accelerator packages and their hardware variants:
While a C++11 compatible compiler is currently sufficient to compile
LAMMPS, a transition to require C++17 is in progess and planned to
be completed in Summer 2025. Currently, setting ``-DLAMMPS_CXX11``
in the ``LMP_INC =`` line in the machine makefile is required when
using a C++11 compatible compiler that does not support C++17.
Otherwise, to enable C++17 support (if not enabled by default) using
a compiler flag like ``-std=c++17`` in CCFLAGS may needed.
If you build LAMMPS with any :doc:`Speed_packages` included,
there may be specific compiler or linker flags that are either
required or recommended to enable required features and to
achieve optimal performance. You need to include these in the
``CCFLAGS`` and ``LINKFLAGS`` settings above. For details, see the
documentation for the individual packages listed on the
:doc:`Speed_packages` page. Or examine these files in the
``src/MAKE/OPTIONS`` directory. They correspond to each of the 5
accelerator packages and their hardware variants:
.. code-block:: bash

View File

@ -314,6 +314,11 @@ C++20 language standard as ``std::format()``, so changes to adopt it are
future-proof, for as long as they are not using any extensions that are
not (yet) included into C++.
The long-term plan is to switch to using ``std::format()`` instead of
``fmt::format()`` when the minimum C++ standard required for LAMMPS will
be set to C++20. See the :ref:`basic build instructions <compile>` for
more details.
Formatted strings are frequently created by calling the
``fmt::format()`` function, which will return a string as a
``std::string`` class instance. In contrast to the ``%`` placeholder in

View File

@ -209,7 +209,7 @@ nve, nvt, npt.
At the end of the timestep, fixes that contain an ``end_of_step()``
method are invoked. These typically perform a diagnostic calculation,
e.g. the ave/time and ave/spatial fixes. The final operation of the
e.g. the ave/time and ave/chunk fixes. The final operation of the
timestep is to perform any requested output, via the ``write()`` method
of the Output class. There are 3 kinds of LAMMPS output: thermodynamic
output to the screen and log file, snapshots of atom data to a dump

View File

@ -45,6 +45,8 @@ class. See compute.h for details.
+-----------------------+------------------------------------------------------------------+
| pair_tally_callback | callback function for *tally*\ -style computes (optional). |
+-----------------------+------------------------------------------------------------------+
| modify_param | called when a compute_modify request is executed (optional) |
+-----------------------+------------------------------------------------------------------+
| memory_usage | tally memory usage (optional) |
+-----------------------+------------------------------------------------------------------+

View File

@ -30,6 +30,8 @@ Examples
Description
"""""""""""
.. versionadded:: TBD
Define a computation that calculates a Gaussian representation of the ionic
structure. This representation is used for the efficient evaluation
of quantities related to the structure factor in a grid-based workflow,

View File

@ -412,11 +412,9 @@ slab correction has also been extended to point dipole interactions
.. note::
If you wish to apply an electric field in the Z-direction, in
conjunction with the *slab* keyword, you should do it by adding
explicit charged particles to the +/- Z surfaces. If you do it via
the :doc:`fix efield <fix_efield>` command, it will not give the correct
dielectric constant due to the Yeh/Berkowitz :ref:`(Yeh) <Yeh>` correction
not being compatible with how :doc:`fix efield <fix_efield>` works.
conjunction with the *slab* keyword, you can do it either by
adding explicit oppositely charged particles to the +/- Z surfaces,
or by using the :doc:`fix efield <fix_efield>` command.
----------

View File

@ -21,6 +21,7 @@
#include <mpi.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -63,7 +64,7 @@ int main(int narg, char **arg)
nprocs_lammps = atoi(arg[1]);
if (nprocs_lammps > nprocs) {
if (me == 0)
printf("ERROR: LAMMPS cannot use more procs than available\n");
printf("ERROR: LAMMPS cannot use more procs than available: %d\n", nprocs);
MPI_Abort(MPI_COMM_WORLD,1);
}
@ -76,7 +77,7 @@ int main(int narg, char **arg)
if (me == 0) {
fp = fopen(arg[2],"r");
if (fp == NULL) {
printf("ERROR: Could not open LAMMPS input script\n");
printf("ERROR: Could not open LAMMPS input script %s: %s\n", arg[2], strerror(errno));
MPI_Abort(MPI_COMM_WORLD,1);
}
}
@ -87,9 +88,10 @@ int main(int narg, char **arg)
all LAMMPS procs call lammps_command() on the line */
if (lammps == 1) {
errno = 0;
plugin = liblammpsplugin_load(arg[3]);
if (plugin == NULL) {
if (me == 0) printf("ERROR: Could not load shared LAMMPS library\n");
if (me == 0) printf("ERROR: Could not load shared LAMMPS library file %s: %s\n", arg[3], strerror(errno));
MPI_Abort(MPI_COMM_WORLD,1);
}
/* must match the plugin ABI version */

View File

@ -19,7 +19,7 @@ parser = ArgumentParser(prog='Install.py',
# Note: must also adjust check for supported API versions in
# fix_plumed.cpp when version changes from v2.n.x to v2.n+1.y
version = "2.9.2"
version = "2.9.3"
mode = "static"
# help message
@ -52,6 +52,7 @@ checksums = { \
'2.9.0' : '661eabeebee05cf84bbf9dc23d7d5f46', \
'2.9.1' : 'c3b2d31479c1e9ce211719d40e9efbd7', \
'2.9.2' : '04862602a372c1013bdfee2d6d03bace', \
'2.9.3' : 'ee1249805fe94bccee17d10610d3f6f1', \
}
# parse and process arguments

View File

@ -1694,7 +1694,6 @@ class lammps(object):
with ExceptionCheck(self):
return self.lib.lammps_eval(self.lmp, newexpr)
return None
# -------------------------------------------------------------------------

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -29,10 +28,9 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeTempDrude::ComputeTempDrude(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
ComputeTempDrude::ComputeTempDrude(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
{
if (narg != 3) error->all(FLERR,"Illegal compute temp command");
if (narg != 3) error->all(FLERR, "Incorrect number of arguments for compute temp/drude");
vector_flag = 1;
scalar_flag = 1;
@ -42,7 +40,7 @@ ComputeTempDrude::ComputeTempDrude(LAMMPS *lmp, int narg, char **arg) :
extlist = new int[6];
extlist[0] = extlist[1] = 0;
extlist[2] = extlist[3] = extlist[4] = extlist[5] = 1;
tempflag = 0; // because does not compute a single temperature (scalar and vector)
tempflag = 0; // because does not compute a single temperature (scalar and vector)
vector = new double[size_vector];
fix_drude = nullptr;
@ -65,11 +63,13 @@ void ComputeTempDrude::init()
{
// Fix drude already checks that there is only one fix drude instance
auto &fixes = modify->get_fix_by_style("^drude$");
if (fixes.size() == 0) error->all(FLERR, "compute temp/drude requires fix drude");
if (fixes.size() == 0)
error->all(FLERR, Error::NOLASTLINE, "compute temp/drude requires fix drude");
fix_drude = dynamic_cast<FixDrude *>(fixes[0]);
if (!comm->ghost_velocity)
error->all(FLERR,"compute temp/drude requires ghost velocities. Use comm_modify vel yes");
error->all(FLERR, Error::NOLASTLINE,
"compute temp/drude requires ghost velocities. Use comm_modify vel yes");
}
/* ---------------------------------------------------------------------- */
@ -93,15 +93,15 @@ void ComputeTempDrude::dof_compute()
bigint dof_core_loc = 0, dof_drude_loc = 0;
for (int i = 0; i < nlocal; i++) {
if (atom->mask[i] & groupbit) {
if (drudetype[type[i]] == DRUDE_TYPE) // Non-polarizable atom
dof_drude_loc++;
if (drudetype[type[i]] == DRUDE_TYPE) // Non-polarizable atom
dof_drude_loc++;
else
dof_core_loc++;
dof_core_loc++;
}
}
dof_core_loc *= dim;
dof_drude_loc *= dim;
MPI_Allreduce(&dof_core_loc, &dof_core, 1, MPI_LMP_BIGINT, MPI_SUM, world);
MPI_Allreduce(&dof_core_loc, &dof_core, 1, MPI_LMP_BIGINT, MPI_SUM, world);
MPI_Allreduce(&dof_drude_loc, &dof_drude, 1, MPI_LMP_BIGINT, MPI_SUM, world);
dof_core -= fix_dof;
vector[2] = dof_core;
@ -112,19 +112,19 @@ void ComputeTempDrude::dof_compute()
int ComputeTempDrude::modify_param(int narg, char **arg)
{
if (strcmp(arg[0],"temp") == 0) {
if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
delete [] id_temp;
if (strcmp(arg[0], "temp") == 0) {
if (narg < 2) utils::missing_cmd_args(FLERR, "compute_modify temp", error);
delete[] id_temp;
id_temp = utils::strdup(arg[1]);
temperature = modify->get_compute_by_id(id_temp);
if (!temperature)
error->all(FLERR,"Could not find fix_modify temperature compute {}", id_temp);
error->all(FLERR, "Could not find fix_modify temperature compute {}", id_temp);
if (temperature->tempflag == 0)
error->all(FLERR, "Fix_modify temperature compute {} does not compute temperature", id_temp);
if (temperature->igroup != igroup && comm->me == 0)
error->warning(FLERR,"Group for fix_modify temp != fix group");
error->warning(FLERR, "Group for fix_modify temp != fix group");
return 2;
}
return 0;
@ -134,83 +134,95 @@ int ComputeTempDrude::modify_param(int narg, char **arg)
void ComputeTempDrude::compute_vector()
{
invoked_vector = update->ntimestep;
invoked_vector = update->ntimestep;
int nlocal = atom->nlocal;
int *mask = atom->mask;
int *type = atom->type;
double *rmass = atom->rmass, *mass = atom->mass;
double **v = atom->v;
tagint *drudeid = fix_drude->drudeid;
int *drudetype = fix_drude->drudetype;
int dim = domain->dimension;
double mvv2e = force->mvv2e, kb = force->boltz;
int nlocal = atom->nlocal;
int *mask = atom->mask;
int *type = atom->type;
double *rmass = atom->rmass, *mass = atom->mass;
double **v = atom->v;
tagint *drudeid = fix_drude->drudeid;
int *drudetype = fix_drude->drudetype;
int dim = domain->dimension;
double mvv2e = force->mvv2e, kb = force->boltz;
double mcore, mdrude;
double ecore, edrude;
double *vcore, *vdrude;
double kineng_core_loc = 0., kineng_drude_loc = 0.;
for (int i=0; i<nlocal; i++) {
if (groupbit & mask[i] && drudetype[type[i]] != DRUDE_TYPE) {
if (drudetype[type[i]] == NOPOL_TYPE) {
ecore = 0.;
vcore = v[i];
if (temperature) temperature->remove_bias(i, vcore);
for (int k=0; k<dim; k++) ecore += vcore[k]*vcore[k];
if (temperature) temperature->restore_bias(i, vcore);
if (rmass) mcore = rmass[i];
else mcore = mass[type[i]];
kineng_core_loc += mcore * ecore;
} else { // CORE_TYPE
int j = atom->map(drudeid[i]);
if (rmass) {
mcore = rmass[i];
mdrude = rmass[j];
} else {
mcore = mass[type[i]];
mdrude = mass[type[j]];
}
double mtot_inv = 1. / (mcore + mdrude);
ecore = 0.;
edrude = 0.;
vcore = v[i];
vdrude = v[j];
if (temperature) {
temperature->remove_bias(i, vcore);
temperature->remove_bias(j, vdrude);
}
for (int k=0; k<dim; k++) {
double v1 = mdrude * vdrude[k] + mcore * vcore[k];
ecore += v1 * v1;
double v2 = vdrude[k] - vcore[k];
edrude += v2 * v2;
}
if (temperature) {
temperature->restore_bias(i, vcore);
temperature->restore_bias(j, vdrude);
}
kineng_core_loc += mtot_inv * ecore;
kineng_drude_loc += mtot_inv * mcore * mdrude * edrude;
}
double mcore, mdrude;
double ecore, edrude;
double *vcore, *vdrude;
double kineng_core_loc = 0.0, kineng_drude_loc = 0.0;
for (int i = 0; i < nlocal; i++) {
vdrude = nullptr;
vcore = nullptr;
if (groupbit & mask[i] && drudetype[type[i]] != DRUDE_TYPE) {
if (drudetype[type[i]] == NOPOL_TYPE) {
ecore = 0.0;
vcore = v[i];
if (temperature) temperature->remove_bias(i, vcore);
for (int k = 0; k < dim; k++) ecore += vcore[k] * vcore[k];
if (temperature) temperature->restore_bias(i, vcore);
if (rmass)
mcore = rmass[i];
else
mcore = mass[type[i]];
kineng_core_loc += mcore * ecore;
} else { // CORE_TYPE
int j = atom->map(drudeid[i]);
if (j < 0) {
if (drudeid[i] == 0) {
error->one(FLERR, "Drude atom for core atom ID {} is not defined", atom->tag[i]);
} else {
error->one(FLERR, "Drude atom ID {} for core atom ID {} is out of range", drudeid[i],
atom->tag[i]);
}
}
if (rmass) {
mcore = rmass[i];
mdrude = rmass[j];
} else {
mcore = mass[type[i]];
mdrude = mass[type[j]];
}
double mtot_inv = 1.0 / (mcore + mdrude);
ecore = 0.0;
edrude = 0.0;
vcore = v[i];
vdrude = v[j];
if (temperature) {
temperature->remove_bias(i, vcore);
temperature->remove_bias(j, vdrude);
}
for (int k = 0; k < dim; k++) {
double v1 = mdrude * vdrude[k] + mcore * vcore[k];
ecore += v1 * v1;
double v2 = vdrude[k] - vcore[k];
edrude += v2 * v2;
}
if (temperature) {
temperature->restore_bias(i, vcore);
temperature->restore_bias(j, vdrude);
}
kineng_core_loc += mtot_inv * ecore;
kineng_drude_loc += mtot_inv * mcore * mdrude * edrude;
}
}
}
if (dynamic) dof_compute();
kineng_core_loc *= 0.5 * mvv2e;
kineng_drude_loc *= 0.5 * mvv2e;
MPI_Allreduce(&kineng_core_loc,&kineng_core,1,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(&kineng_drude_loc,&kineng_drude,1,MPI_DOUBLE,MPI_SUM,world);
temp_core = 2.0 * kineng_core / (dof_core * kb);
temp_drude = 2.0 * kineng_drude / (dof_drude * kb);
vector[0] = temp_core;
vector[1] = temp_drude;
vector[4] = kineng_core;
vector[5] = kineng_drude;
if (dynamic) dof_compute();
kineng_core_loc *= 0.5 * mvv2e;
kineng_drude_loc *= 0.5 * mvv2e;
MPI_Allreduce(&kineng_core_loc, &kineng_core, 1, MPI_DOUBLE, MPI_SUM, world);
MPI_Allreduce(&kineng_drude_loc, &kineng_drude, 1, MPI_DOUBLE, MPI_SUM, world);
temp_core = 2.0 * kineng_core / (dof_core * kb);
temp_drude = 2.0 * kineng_drude / (dof_drude * kb);
vector[0] = temp_core;
vector[1] = temp_drude;
vector[4] = kineng_core;
vector[5] = kineng_drude;
}
double ComputeTempDrude::compute_scalar() {
compute_vector();
scalar = vector[0];
return scalar;
double ComputeTempDrude::compute_scalar()
{
compute_vector();
scalar = vector[0];
return scalar;
}

View File

@ -32,7 +32,7 @@ class ComputeTempDrude : public Compute {
void setup() override;
void compute_vector() override;
double compute_scalar() override;
int modify_param(int, char **);
int modify_param(int, char **) override;
private:
class FixDrude *fix_drude;

View File

@ -33,7 +33,9 @@ using namespace FixConst;
FixDrude::FixDrude(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)
{
if (narg != 3 + atom->ntypes) error->all(FLERR,"Illegal fix drude command");
if (narg != 3 + atom->ntypes)
error->all(FLERR,"Incorrect number of arguments ({} instead of {}) for fix drude command",
narg, 3 + atom->ntypes);
comm_border = 1; // drudeid
special_alter_flag = 1;
@ -49,7 +51,7 @@ FixDrude::FixDrude(LAMMPS *lmp, int narg, char **arg) :
else if (arg[i][0] == 'd' || arg[i][0] == 'D' || arg[i][0] == '2')
drudetype[i-2] = DRUDE_TYPE;
else
error->all(FLERR, "Illegal fix drude command");
error->all(FLERR, i, "Unknown drude type {} for atom type {}", arg[i], i-2);
}
drudeid = nullptr;
@ -82,7 +84,8 @@ FixDrude::~FixDrude()
void FixDrude::init()
{
if (modify->get_fix_by_style("^drude$").size() > 1) error->all(FLERR,"More than one fix drude");
if (modify->get_fix_by_style("^drude$").size() > 1)
error->all(FLERR, Error::NOLASTLINE, "More than one fix drude");
if (!rebuildflag) rebuild_special();
}
@ -106,8 +109,7 @@ void FixDrude::build_drudeid() {
std::vector<tagint> core_drude_vec;
partner_set = new std::set<tagint>[nlocal]; // Temporary sets of bond partner tags
if (atom->molecular == Atom::MOLECULAR)
{
if (atom->molecular == Atom::MOLECULAR) {
// Build list of my atoms' bond partners
for (int i=0; i<nlocal; i++) {
if (drudetype[type[i]] == NOPOL_TYPE) continue;
@ -117,9 +119,7 @@ void FixDrude::build_drudeid() {
core_drude_vec.push_back(atom->bond_atom[i][k]);
}
}
}
else
{
} else {
// Template case
class Molecule **atommols;
atommols = atom->avec->onemols;
@ -157,10 +157,17 @@ void FixDrude::build_drudeid() {
// At this point each of my Drudes knows its core.
// Send my list of Drudes to other procs and myself
// so that each core finds its Drude.
comm->ring(drude_vec.size(), sizeof(tagint),
(char *) drude_vec.data(),
comm->ring(drude_vec.size(), sizeof(tagint), (char *) drude_vec.data(),
3, ring_search_drudeid, nullptr, (void *)this, 1);
delete [] partner_set;
delete[] partner_set;
// Check if all cores have a drude particle attached
for (int i=0; i<nlocal; i++) {
if (drudetype[type[i]] == CORE_TYPE) {
if (drudeid[i] == 0)
error->one(FLERR, Error::NOLASTLINE, "Core atom ID {} has no drude atom", atom->tag[i]);
}
}
}
/* ----------------------------------------------------------------------
@ -347,7 +354,8 @@ void FixDrude::rebuild_special() {
utils::logmesg(lmp, "New max number of 1-2 to 1-4 neighbors: {} (+{})\n", nspecmax, nspecmax - nspecmax_old);
if (atom->maxspecial < nspecmax)
error->all(FLERR, "Not enough space in special: extra/special/per/atom should be at least {}", nspecmax - nspecmax_old);
error->all(FLERR, Error::NOLASTLINE, "Not enough space for special neighbors list: "
"use extra/special/per/atom with at least a value of {}", nspecmax - nspecmax_old);
// Build list of cores' special lists to communicate to ghost drude particles
for (int i=0; i<nlocal; i++) {
@ -512,7 +520,8 @@ void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr) {
void FixDrude::set_arrays(int i) {
if (drudetype[atom->type[i]] != NOPOL_TYPE) {
if (atom->nspecial[i] == nullptr)
error->all(FLERR, "Polarizable atoms cannot be inserted with special lists info from the molecule template");
error->all(FLERR, Error::NOLASTLINE, "Polarizable atoms cannot be inserted "
"with special lists info from the molecule template");
drudeid[i] = atom->special[i][0]; // Drude partner should be at first place in the special list
} else {
drudeid[i] = 0;

View File

@ -225,7 +225,8 @@ void FixACKS2ReaxFFKokkos<DeviceType>::pre_force(int /*vflag*/)
allocate_array();
if (!allocated_flag || last_allocate < neighbor->lastcall) {
if (!allocated_flag || last_allocate < neighbor->lastcall
|| nlocal_last_allocate != nlocal) {
// get max number of neighbor
@ -281,6 +282,7 @@ void FixACKS2ReaxFFKokkos<DeviceType>::pre_force(int /*vflag*/)
prev_last_rows_rank = last_rows_rank;
last_allocate = update->ntimestep;
nlocal_last_allocate = nlocal;
}
// compute_H
@ -430,8 +432,6 @@ void FixACKS2ReaxFFKokkos<DeviceType>::num_neigh_item(int ii, bigint &totneigh)
template<class DeviceType>
void FixACKS2ReaxFFKokkos<DeviceType>::allocate_matrix()
{
nmax = atom->nmax;
// determine the total space for the H matrix
m_cap_big = 0;
@ -456,15 +456,15 @@ void FixACKS2ReaxFFKokkos<DeviceType>::allocate_matrix()
// H matrix
d_firstnbr = typename AT::t_bigint_1d("acks2/kk:firstnbr",nmax);
d_numnbrs = typename AT::t_int_1d("acks2/kk:numnbrs",nmax);
d_firstnbr = typename AT::t_bigint_1d("acks2/kk:firstnbr",nlocal);
d_numnbrs = typename AT::t_int_1d("acks2/kk:numnbrs",nlocal);
d_jlist = typename AT::t_int_1d("acks2/kk:jlist",m_cap_big);
d_val = typename AT::t_ffloat_1d("acks2/kk:val",m_cap_big);
// X matrix
d_firstnbr_X = typename AT::t_bigint_1d("acks2/kk:firstnbr_X",nmax);
d_numnbrs_X = typename AT::t_int_1d("acks2/kk:numnbrs_X",nmax);
d_firstnbr_X = typename AT::t_bigint_1d("acks2/kk:firstnbr_X",nlocal);
d_numnbrs_X = typename AT::t_int_1d("acks2/kk:numnbrs_X",nlocal);
d_jlist_X = typename AT::t_int_1d("acks2/kk:jlist_X",m_cap_big);
d_val_X = typename AT::t_ffloat_1d("acks2/kk:val_X",m_cap_big);
}

View File

@ -243,7 +243,7 @@ class FixACKS2ReaxFFKokkos : public FixACKS2ReaxFF, public KokkosBase {
void calculate_Q() override;
int neighflag;
int nlocal,nall,nmax,newton_pair;
int nlocal,nlocal_last_allocate,nall,nmax,newton_pair;
int count, isuccess;
double alpha, beta, omega, cutsq;

View File

@ -215,9 +215,11 @@ void FixQEqReaxFFKokkos<DeviceType>::pre_force(int /*vflag*/)
// get max number of neighbor
if (!allocated_flag || last_allocate < neighbor->lastcall) {
if (!allocated_flag || last_allocate < neighbor->lastcall
|| nlocal_last_allocate != nlocal) {
allocate_matrix();
last_allocate = update->ntimestep;
nlocal_last_allocate = nlocal;
}
// compute_H
@ -313,8 +315,6 @@ void FixQEqReaxFFKokkos<DeviceType>::num_neigh_item(int ii, bigint &totneigh) co
template<class DeviceType>
void FixQEqReaxFFKokkos<DeviceType>::allocate_matrix()
{
nmax = atom->nmax;
// determine the total space for the H matrix
m_cap_big = 0;
@ -332,8 +332,8 @@ void FixQEqReaxFFKokkos<DeviceType>::allocate_matrix()
d_jlist = typename AT::t_int_1d();
d_val = typename AT::t_ffloat_1d();
d_firstnbr = typename AT::t_bigint_1d("qeq/kk:firstnbr",nmax);
d_numnbrs = typename AT::t_int_1d("qeq/kk:numnbrs",nmax);
d_firstnbr = typename AT::t_bigint_1d("qeq/kk:firstnbr",nlocal);
d_numnbrs = typename AT::t_int_1d("qeq/kk:numnbrs",nlocal);
d_jlist = typename AT::t_int_1d("qeq/kk:jlist",m_cap_big);
d_val = typename AT::t_ffloat_1d("qeq/kk:val",m_cap_big);
}

View File

@ -273,7 +273,7 @@ class FixQEqReaxFFKokkos : public FixQEqReaxFF, public KokkosBase {
void calculate_q();
int neighflag, pack_flag;
int nlocal,nall,nmax,newton_pair;
int nlocal,nlocal_last_allocate,nall,nmax,newton_pair;
int count, isuccess;
F_FLOAT alpha[2];
F_FLOAT beta[2];

View File

@ -1654,7 +1654,7 @@ void FixIMD::handle_output_v3() {
if (imdsinfo->coords) {
commdata *recvcoord = nullptr;
memory->destroy(coord_data);
coord_data = memory->smalloc(nme*size_one, "imd:coord_data");
coord_data = memory->smalloc((bigint)nme * size_one, "imd:coord_data");
buf = static_cast<struct commdata *>(coord_data);
int idx = 0;
if (imdsinfo->unwrap) {
@ -1720,7 +1720,7 @@ void FixIMD::handle_output_v3() {
if (imdsinfo->velocities) {
commdata *recvvel = nullptr;
memory->destroy(vel_data);
vel_data = memory->smalloc(nme*size_one, "imd:vel_data");
vel_data = memory->smalloc((bigint)nme * size_one, "imd:vel_data");
buf = static_cast<struct commdata *>(vel_data);
int idx = 0;
for (int i = 0; i < nlocal; ++i) {
@ -1755,7 +1755,7 @@ void FixIMD::handle_output_v3() {
if (imdsinfo->forces) {
commdata *recvforce = nullptr;
memory->destroy(force_data);
force_data = memory->smalloc(nme*size_one, "imd:force_data");
force_data = memory->smalloc((bigint)nme * size_one, "imd:force_data");
buf = static_cast<struct commdata *>(force_data);
int idx = 0;
for (int i = 0; i < nlocal; ++i) {

View File

@ -137,19 +137,20 @@ void Compute::modify_params(int narg, char **arg)
int iarg = 0;
while (iarg < narg) {
// added more specific keywords in Mar17
// at some point, remove generic extra and dynamic
if (strcmp(arg[iarg],"extra") == 0 ||
strcmp(arg[iarg],"extra/dof") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal compute_modify command");
if (strcmp(arg[iarg],"extra/dof") == 0) {
if (iarg+2 > narg) utils::missing_cmd_args(FLERR,"compute_modify extra/dof", error);
extra_dof = utils::numeric(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"dynamic") == 0 ||
strcmp(arg[iarg],"dynamic/dof") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal compute_modify command");
} else if (strcmp(arg[iarg],"dynamic/dof") == 0) {
if (iarg+2 > narg) utils::missing_cmd_args(FLERR,"compute_modify dynamic/dof", error);
dynamic_user = utils::logical(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else error->all(FLERR,"Illegal compute_modify command");
} else {
int n = modify_param(narg-iarg, &arg[iarg]);
if (n== 0)
error->all(FLERR, iarg + 1, "Compute {} {} does not support compute_modify {} command",
id, style, arg[iarg]);
}
}
}

View File

@ -113,6 +113,7 @@ class Compute : protected Pointers {
Compute(class LAMMPS *, int, char **);
~Compute() override;
void modify_params(int, char **);
virtual int modify_param(int, char **) { return 0; }
virtual void reset_extra_dof();
void init_flags();

View File

@ -16,6 +16,7 @@
#include "angle.h"
#include "atom.h"
#include "atom_masks.h"
#include "bond.h"
#include "dihedral.h"
#include "domain.h"
@ -132,6 +133,11 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
vector = new double[size_vector];
nvirial = 0;
vptr = nullptr;
// KOKKOS
datamask_read = EMPTY_MASK;
datamask_modify = EMPTY_MASK;
}
/* ---------------------------------------------------------------------- */

View File

@ -124,7 +124,6 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
atomflag = YES;
gridflag = NO;
lineflag = triflag = bodyflag = fixflag = NO;
id_grid_compute = id_grid_fix = nullptr;
if (atom->nbondtypes == 0) bondflag = NO;
else {
@ -188,10 +187,13 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
igrid,idata,index,lmp);
if (iflag < 0) error->all(FLERR,"Invalid grid reference in dump image command");
delete[] id_grid_compute;
delete[] id_grid_fix;
if (iflag == ArgInfo::COMPUTE) id_grid_compute = utils::strdup(id);
else if (iflag == ArgInfo::FIX) id_grid_fix = utils::strdup(id);
if (iflag == ArgInfo::COMPUTE) {
delete[] id_grid_compute;
id_grid_compute = utils::strdup(id);
} else if (iflag == ArgInfo::FIX) {
delete[] id_grid_fix;
id_grid_fix = utils::strdup(id);
}
delete[] id;
grid_igrid = igrid;
grid_idata = idata;
@ -465,15 +467,8 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
// local data
grid_compute = nullptr;
grid_fix = nullptr;
maxbufcopy = 0;
chooseghost = nullptr;
bufcopy = nullptr;
maxgrid = 0;
gbuf = nullptr;
}
/* ---------------------------------------------------------------------- */

View File

@ -85,6 +85,7 @@ void Error::universe_one(const std::string &file, int line, const std::string &s
std::string mesg = fmt::format("ERROR on proc {}: {} ({}:{})\n",
universe->me,str,truncpath(file),line);
if (universe->uscreen) fputs(mesg.c_str(),universe->uscreen);
utils::flush_buffers(lmp);
// allow commands if an exception was caught in a run
// update may be a null pointer when catching command-line errors
@ -118,13 +119,19 @@ void Error::all(const std::string &file, int line, int failed, const std::string
{
MPI_Barrier(world);
// must get rank from communicator since "comm" instance may not yet exist
int me = 0;
MPI_Comm_rank(world, &me);
std::string lastcmd = "(unknown)";
std::string mesg = "ERROR: " + str + fmt::format(" ({}:{})\n", truncpath(file), line);
// add text about the input following the error message
if (failed > NOLASTLINE) mesg += utils::point_to_error(input, failed);
if (comm->me == 0) utils::logmesg(lmp,mesg);
if (me == 0) utils::logmesg(lmp,mesg);
utils::flush_buffers(lmp);
// allow commands if an exception was caught in a run
// update may be a null pointer when catching command-line errors
@ -148,8 +155,12 @@ void Error::one(const std::string &file, int line, int failed, const std::string
{
std::string lastcmd = "(unknown)";
std::string mesg = fmt::format("ERROR on proc {}: {} ({}:{})\n", comm->me, str,
truncpath(file), line);
// must get rank from communicator since "comm" instance may not yet exist
int me = 0;
MPI_Comm_rank(world, &me);
std::string mesg = fmt::format("ERROR on proc {}: {} ({}:{})\n", me, str, truncpath(file), line);
if (failed > NOPOINTER) mesg += utils::point_to_error(input, failed);
utils::logmesg(lmp,mesg);
@ -157,6 +168,7 @@ void Error::one(const std::string &file, int line, int failed, const std::string
if (universe->uscreen)
fputs(mesg.c_str(),universe->uscreen);
utils::flush_buffers(lmp);
// allow commands if an exception was caught in a run
// update may be a null pointer when catching command-line errors
@ -255,6 +267,7 @@ void Error::_message(const std::string &file, int line, fmt::string_view format,
void Error::done(int status)
{
utils::flush_buffers(lmp);
MPI_Barrier(world);
if (output) delete output;

View File

@ -42,7 +42,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), nvalues(0), fp(nullptr), stats_list(nullptr), bin(nullptr),
bin_total(nullptr), bin_all(nullptr), bin_list(nullptr), coord(nullptr), vector(nullptr)
{
auto mycmd = fmt::format("fix {}", style);
const auto mycmd = fmt::format("fix {}", style);
if (narg < 10) utils::missing_cmd_args(FLERR, mycmd, error);
nevery = utils::inumeric(FLERR, arg[3], false, lmp);
@ -67,8 +67,9 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
// then read options so know mode = SCALAR/VECTOR before re-reading values
nvalues = 0;
int iarg = 9;
// the first 9 arguments have fixed positions
const int ioffset = 9;
int iarg = ioffset;
while (iarg < narg) {
if (strcmp(arg[iarg],"x") == 0 ||
strcmp(arg[iarg],"y") == 0 ||
@ -87,7 +88,9 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
} else break;
}
if (nvalues == 0) error->all(FLERR,"No values in {} command", mycmd);
if (nvalues == 0)
error->all(FLERR, ioffset,
"No values in from computes, fixes, or variables used in {} command", mycmd);
options(iarg,narg,arg);
@ -96,9 +99,10 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
int expand = 0;
char **earg;
nvalues = utils::expand_args(FLERR, nvalues, &arg[9], mode, earg, lmp);
int *amap = nullptr;
nvalues = utils::expand_args(FLERR, nvalues, &arg[ioffset], mode, earg, lmp, &amap);
if (earg != &arg[9]) expand = 1;
if (earg != &arg[ioffset]) expand = 1;
arg = earg;
// parse values
@ -113,42 +117,62 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
if (strcmp(arg[i],"x") == 0) {
val.which = ArgInfo::X;
val.argindex = 0;
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
} else if (strcmp(arg[i],"y") == 0) {
val.which = ArgInfo::X;
val.argindex = 1;
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
} else if (strcmp(arg[i],"z") == 0) {
val.which = ArgInfo::X;
val.argindex = 2;
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
} else if (strcmp(arg[i],"vx") == 0) {
val.which = ArgInfo::V;
val.argindex = 0;
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
} else if (strcmp(arg[i],"vy") == 0) {
val.which = ArgInfo::V;
val.argindex = 1;
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
} else if (strcmp(arg[i],"vz") == 0) {
val.which = ArgInfo::V;
val.argindex = 2;
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
} else if (strcmp(arg[i],"fx") == 0) {
val.which = ArgInfo::F;
val.argindex = 0;
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
} else if (strcmp(arg[i],"fy") == 0) {
val.which = ArgInfo::F;
val.argindex = 1;
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
} else if (strcmp(arg[i],"fz") == 0) {
val.which = ArgInfo::F;
val.argindex = 2;
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
} else {
ArgInfo argi(arg[i]);
if (argi.get_type() == ArgInfo::NONE) break;
if ((argi.get_type() == ArgInfo::UNKNOWN) || (argi.get_dim() > 1))
error->all(FLERR,"Invalid {} argument: {}", mycmd, arg[i]);
error->all(FLERR, amap[i] + ioffset, "Invalid {} argument: {}", mycmd, arg[i]);
val.which = argi.get_type();
val.argindex = argi.get_index1();
if (expand) val.iarg = amap[i] + ioffset;
else val.iarg = i + ioffset;
val.id = argi.get_name();
}
values.push_back(val);
@ -156,24 +180,17 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
if (nvalues != (int)values.size())
error->all(FLERR, "Could not parse value data consistently for {}", mycmd);
// if wildcard expansion occurred, free earg memory from expand_args()
if (expand) {
for (int i = 0; i < nvalues; i++) delete[] earg[i];
memory->sfree(earg);
}
// check input args for kind consistency
// inputs must all be all either global, per-atom, or local
if (nevery <= 0)
error->all(FLERR,"Illegal {} nevery value: {}", mycmd, nevery);
error->all(FLERR, 3, "Illegal {} nevery value: {}", mycmd, nevery);
if (nrepeat <= 0)
error->all(FLERR,"Illegal {} nrepeat value: {}", mycmd, nrepeat);
error->all(FLERR, 4, "Illegal {} nrepeat value: {}", mycmd, nrepeat);
if (nfreq <= 0)
error->all(FLERR,"Illegal {} nfreq value: {}", mycmd, nfreq);
error->all(FLERR, 5, "Illegal {} nfreq value: {}", mycmd, nfreq);
if (nfreq % nevery || nrepeat*nevery > nfreq)
error->all(FLERR,"Inconsistent {} nevery/nrepeat/nfreq values", mycmd);
error->all(FLERR, "Inconsistent {} nevery/nrepeat/nfreq values", mycmd);
if (ave != RUNNING && overwrite)
error->all(FLERR,"{} overwrite keyword requires ave running setting", mycmd);
@ -186,7 +203,8 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
} else if (val.which == ArgInfo::COMPUTE) {
val.val.c = modify->get_compute_by_id(val.id);
if (!val.val.c) error->all(FLERR,"Compute ID {} for {} does not exist", val.id, mycmd);
if (!val.val.c)
error->all(FLERR, val.iarg, "Compute ID {} for {} does not exist", val.id, mycmd);
// computes can produce multiple kinds of output
if (val.val.c->scalar_flag || val.val.c->vector_flag || val.val.c->array_flag)
kindglobal = 1;
@ -195,7 +213,8 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
} else if (val.which == ArgInfo::FIX) {
val.val.f = modify->get_fix_by_id(val.id);
if (!val.val.f) error->all(FLERR,"Fix ID {} for {} does not exist", val.id, mycmd);
if (!val.val.f)
error->all(FLERR, val.iarg, "Fix ID {} for {} does not exist", val.id, mycmd);
// fixes can produce multiple kinds of output
if (val.val.f->scalar_flag || val.val.f->vector_flag || val.val.f->array_flag)
kindglobal = 1;
@ -205,32 +224,40 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
} else if (val.which == ArgInfo::VARIABLE) {
val.val.v = input->variable->find(val.id.c_str());
if (val.val.v < 0)
error->all(FLERR,"Variable name {} for {} does not exist", val.id, mycmd);
error->all(FLERR, val.iarg, "Variable name {} for {} does not exist", val.id, mycmd);
// variables only produce one kind of output
if (input->variable->equalstyle(val.val.v) || input->variable->vectorstyle(val.val.v))
kindglobal = 1;
else if (input->variable->atomstyle(val.val.v)) kindperatom = 1;
else error->all(FLERR,"{} variable {} is incompatible style", mycmd, val.id);
else error->all(FLERR, val.iarg, "{} variable {} is incompatible style", mycmd, val.id);
}
if (kind == DEFAULT) {
if (kindglobal + kindperatom + kindlocal > 1)
error->all(FLERR,"{} input kind is ambiguous", mycmd);
error->all(FLERR, val.iarg, "{} input kind is ambiguous", mycmd);
if (kindglobal) kind = GLOBAL;
if (kindperatom) kind = PERATOM;
if (kindlocal) kind = LOCAL;
} else if (kind == GLOBAL) {
if (!kindglobal)
error->all(FLERR,"{} input kind is not global", mycmd);
error->all(FLERR, val.iarg, "{} input kind is not global", mycmd);
} else if (kind == PERATOM) {
if (!kindperatom)
error->all(FLERR,"{} input kind is not peratom", mycmd);
error->all(FLERR, val.iarg, "{} input kind is not peratom", mycmd);
} else if (kind == LOCAL) {
if (!kindlocal)
error->all(FLERR,"{} input kind is not local", mycmd);
error->all(FLERR, val.iarg, "{} input kind is not local", mycmd);
}
}
// if wildcard expansion occurred, free earg memory from expand_args()
if (expand) {
for (int i = 0; i < nvalues; i++) delete[] earg[i];
memory->sfree(earg);
memory->sfree(amap);
}
// more error checks
// for fix inputs, check that fix frequency is acceptable
@ -242,98 +269,98 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
for (auto &val : values) {
if (val.which == ArgInfo::COMPUTE && kind == GLOBAL && mode == SCALAR) {
if (val.argindex == 0 && val.val.c->scalar_flag == 0)
error->all(FLERR, "{} compute {} does not calculate a global scalar", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate a global scalar", mycmd, val.id);
if (val.argindex && val.val.c->vector_flag == 0)
error->all(FLERR, "{} compute {} does not calculate a global vector", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate a global vector", mycmd, val.id);
if (val.argindex && val.argindex > val.val.c->size_vector)
error->all(FLERR, "{} compute {} vector is accessed out-of-range", mycmd, val.id);
error->all(FLERR,val.iarg, "{} compute {} vector is accessed out-of-range", mycmd, val.id);
} else if (val.which == ArgInfo::COMPUTE && kind == GLOBAL && mode == VECTOR) {
if (val.argindex == 0 && val.val.c->vector_flag == 0)
error->all(FLERR, "{} compute {} does not calculate a global vector", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate a global vector", mycmd, val.id);
if (val.argindex && val.val.c->array_flag == 0)
error->all(FLERR, "{} compute {} does not calculate a global array", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate a global array", mycmd, val.id);
if (val.argindex && val.argindex > val.val.c->size_array_cols)
error->all(FLERR, "{} compute {} array is accessed out-of-range", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} array is accessed out-of-range", mycmd, val.id);
} else if (val.which == ArgInfo::COMPUTE && kind == PERATOM) {
if (val.val.c->peratom_flag == 0)
error->all(FLERR, "{} compute {} does not calculate per-atom values", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate per-atom values", mycmd, val.id);
if (val.argindex == 0 && val.val.c->size_peratom_cols != 0)
error->all(FLERR, "{} compute {} does not calculate a per-atom vector", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate a per-atom vector", mycmd, val.id);
if (val.argindex && val.val.c->size_peratom_cols == 0)
error->all(FLERR, "{} compute {} does not calculate a per-atom array", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate a per-atom array", mycmd, val.id);
if (val.argindex && val.argindex > val.val.c->size_peratom_cols)
error->all(FLERR, "{} compute {} array is accessed out-of-range", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} array is accessed out-of-range", mycmd, val.id);
} else if (val.which == ArgInfo::COMPUTE && kind == LOCAL) {
if (val.val.c->local_flag == 0)
error->all(FLERR, "{} compute {} does not calculate local values", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate local values", mycmd, val.id);
if (val.argindex == 0 && val.val.c->size_local_cols != 0)
error->all(FLERR, "{} compute {} does not calculate a local vector", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate a local vector", mycmd, val.id);
if (val.argindex && val.val.c->size_local_cols == 0)
error->all(FLERR, "{} compute {} does not calculate a local array", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} does not calculate a local array", mycmd, val.id);
if (val.argindex && val.argindex > val.val.c->size_local_cols)
error->all(FLERR, "{} compute {} array is accessed out-of-range", mycmd, val.id);
error->all(FLERR, val.iarg, "{} compute {} array is accessed out-of-range", mycmd, val.id);
} else if (val.which == ArgInfo::FIX && kind == GLOBAL && mode == SCALAR) {
if (val.argindex == 0 && val.val.f->scalar_flag == 0)
error->all(FLERR, "{} fix {} does not calculate a global scalar", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} does not calculate a global scalar", mycmd, val.id);
if (val.argindex && val.val.f->vector_flag == 0)
error->all(FLERR, "{} fix {} does not calculate a global vector", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} does not calculate a global vector", mycmd, val.id);
if (val.argindex && val.argindex > val.val.f->size_vector)
error->all(FLERR, "{} fix {} vector is accessed out-of-range", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} vector is accessed out-of-range", mycmd, val.id);
if (nevery % val.val.f->global_freq)
error->all(FLERR, "Fix {} for {} not computed at compatible time", val.id, mycmd);
error->all(FLERR, val.iarg, "Fix {} for {} not computed at compatible time", val.id, mycmd);
} else if (val.which == ArgInfo::FIX && kind == GLOBAL && mode == VECTOR) {
if (val.argindex == 0 && val.val.f->vector_flag == 0)
error->all(FLERR, "{} fix {} does not calculate a global vector", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} does not calculate a global vector", mycmd, val.id);
if (val.argindex && val.val.f->array_flag == 0)
error->all(FLERR, "{} fix {} does not calculate a global array", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} does not calculate a global array", mycmd, val.id);
if (val.argindex && val.argindex > val.val.f->size_array_cols)
error->all(FLERR, "{} fix {} array is accessed out-of-range", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} array is accessed out-of-range", mycmd, val.id);
if (nevery % val.val.f->global_freq)
error->all(FLERR, "Fix {} for {} not computed at compatible time", val.id, mycmd);
error->all(FLERR, val.iarg, "Fix {} for {} not computed at compatible time", val.id, mycmd);
} else if (val.which == ArgInfo::FIX && kind == PERATOM) {
if (val.val.f->peratom_flag == 0)
error->all(FLERR, "{} fix {} does not calculate per-atom values", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} does not calculate per-atom values", mycmd, val.id);
if (val.argindex == 0 && val.val.f->size_peratom_cols != 0)
error->all(FLERR," {} fix {} does not calculate a per-atom vector", mycmd, val.id);
error->all(FLERR, val.iarg, " {} fix {} does not calculate a per-atom vector", mycmd, val.id);
if (val.argindex && val.val.f->size_peratom_cols == 0)
error->all(FLERR, "{} fix {} does not ""calculate a per-atom array", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} does not ""calculate a per-atom array", mycmd, val.id);
if (val.argindex && val.argindex > val.val.f->size_peratom_cols)
error->all(FLERR, "{} fix {} array is accessed out-of-range", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} array is accessed out-of-range", mycmd, val.id);
if (nevery % val.val.f->global_freq)
error->all(FLERR, "Fix {} for {} not computed at compatible time", val.id, mycmd);
error->all(FLERR, val.iarg, "Fix {} for {} not computed at compatible time", val.id, mycmd);
} else if (val.which == ArgInfo::FIX && kind == LOCAL) {
if (val.val.f->local_flag == 0)
error->all(FLERR, "{} fix {} does not calculate local values", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} does not calculate local values", mycmd, val.id);
if (val.argindex == 0 && val.val.f->size_local_cols != 0)
error->all(FLERR, "{} fix {} does not calculate a local vector", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} does not calculate a local vector", mycmd, val.id);
if (val.argindex && val.val.f->size_local_cols == 0)
error->all(FLERR, "{} fix does not calculate a local array", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix does not calculate a local array", mycmd, val.id);
if (val.argindex && val.argindex > val.val.f->size_local_cols)
error->all(FLERR, "{} fix {} array is accessed out-of-range", mycmd, val.id);
error->all(FLERR, val.iarg, "{} fix {} array is accessed out-of-range", mycmd, val.id);
if (nevery % val.val.f->global_freq)
error->all(FLERR, "Fix {} for {} not computed at compatible time", val.id, mycmd);
error->all(FLERR, val.iarg, "Fix {} for {} not computed at compatible time", val.id, mycmd);
} else if (val.which == ArgInfo::VARIABLE && kind == GLOBAL && mode == SCALAR) {
if (val.argindex == 0 && input->variable->equalstyle(val.val.v) == 0)
error->all(FLERR,"{} variable {} is not equal-style variable", mycmd, val.id);
error->all(FLERR, val.iarg, "{} variable {} is not equal-style variable", mycmd, val.id);
if (val.argindex && input->variable->vectorstyle(val.val.v) == 0)
error->all(FLERR,"{} variable {} is not vector-style variable" , mycmd, val.id);
error->all(FLERR, val.iarg, "{} variable {} is not vector-style variable" , mycmd, val.id);
} else if (val.which == ArgInfo::VARIABLE && kind == GLOBAL && mode == VECTOR) {
if (val.argindex == 0 && input->variable->vectorstyle(val.val.v) == 0)
error->all(FLERR,"{} variable {} is not vector-style variable", mycmd, val.id);
error->all(FLERR, val.iarg, "{} variable {} is not vector-style variable", mycmd, val.id);
if (val.argindex) error->all(FLERR,"{} variable {} cannot be indexed", mycmd, val.id);
} else if (val.which == ArgInfo::VARIABLE && kind == PERATOM) {
if (val.argindex == 0 && input->variable->atomstyle(val.val.v) == 0)
error->all(FLERR,"{} variable {} is not atom-style variable", mycmd, val.id);
error->all(FLERR, val.iarg, "{} variable {} is not atom-style variable", mycmd, val.id);
if (val.argindex) error->all(FLERR,"{} variable {} cannot be indexed", mycmd, val.id);
}
}
@ -350,7 +377,7 @@ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) :
if (title3) fprintf(fp,"%s\n",title3);
else fprintf(fp,"# Bin Coord Count Count/Total\n");
if (ferror(fp)) error->one(FLERR,"Error writing file header: {}", utils::getsyserror());
if (ferror(fp)) error->one(FLERR, "Error writing file header: {}", utils::getsyserror());
filepos = platform::ftell(fp);
}
@ -450,13 +477,17 @@ void FixAveHisto::init()
for (auto &val : values) {
if (val.which == ArgInfo::COMPUTE) {
val.val.c = modify->get_compute_by_id(val.id);
if (!val.val.c) error->all(FLERR,"Compute ID {} for {} does not exist", val.id, mycmd);
if (!val.val.c)
error->all(FLERR, Error::NOLASTLINE, "Compute ID {} for {} does not exist", val.id, mycmd);
} else if (val.which == ArgInfo::FIX) {
val.val.f = modify->get_fix_by_id(val.id);
if (!val.val.f) error->all(FLERR,"Fix ID {} for {} does not exist", val.id, mycmd);
if (!val.val.f)
error->all(FLERR, Error::NOLASTLINE, "Fix ID {} for {} does not exist", val.id, mycmd);
} else if (val.which == ArgInfo::VARIABLE) {
val.val.v = input->variable->find(val.id.c_str());
if (val.val.v < 0) error->all(FLERR,"Variable name {} for {} does not exist", val.id, mycmd);
if (val.val.v < 0)
error->all(FLERR, Error::NOLASTLINE,
"Variable name {} for {} does not exist", val.id, mycmd);
}
}
@ -728,13 +759,13 @@ void FixAveHisto::end_of_step()
fprintf(fp,"%d %g %g %g\n",i+1,coord[i],0.0,0.0);
if (ferror(fp))
error->one(FLERR,"Error writing out histogram data");
error->one(FLERR, Error::NOLASTLINE, "Error writing out histogram data");
fflush(fp);
if (overwrite) {
bigint fileend = platform::ftell(fp);
if ((fileend > 0) && (platform::ftruncate(fp,fileend)))
error->warning(FLERR,"Error while tuncating output: {}",utils::getsyserror());
error->warning(FLERR, "Error while tuncating output: {}",utils::getsyserror());
}
}
}
@ -839,56 +870,57 @@ void FixAveHisto::options(int iarg, int narg, char **arg)
title3 = nullptr;
// optional args
auto mycmd = fmt::format("fix {}", style);
auto mycmd = fmt::format("fix {} ", style);
while (iarg < narg) {
if ((strcmp(arg[iarg],"file") == 0) || (strcmp(arg[iarg],"append") == 0)) {
if (iarg+2 > narg)
utils::missing_cmd_args(FLERR, std::string("fix ave/histo ")+arg[iarg], error);
utils::missing_cmd_args(FLERR, mycmd + arg[iarg], error);
if (comm->me == 0) {
if (strcmp(arg[iarg],"file") == 0) fp = fopen(arg[iarg+1],"w");
else fp = fopen(arg[iarg+1],"a");
if (fp == nullptr)
error->one(FLERR, "Cannot open fix ave/histo file {}: {}",
error->one(FLERR, iarg+1, "Cannot open fix ave/histo file {}: {}",
arg[iarg+1], utils::getsyserror());
}
iarg += 2;
} else if (strcmp(arg[iarg],"kind") == 0) {
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + " kind", error);
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + "kind", error);
if (strcmp(arg[iarg+1],"global") == 0) kind = GLOBAL;
else if (strcmp(arg[iarg+1],"peratom") == 0) kind = PERATOM;
else if (strcmp(arg[iarg+1],"local") == 0) kind = LOCAL;
else error->all(FLERR,"Unknown fix ave/histo kind option: {}", arg[iarg+1]);
else error->all(FLERR, iarg+1, "Unknown fix ave/histo kind option: {}", arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"ave") == 0) {
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + " ave", error);
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + "ave", error);
if (strcmp(arg[iarg+1],"one") == 0) ave = ONE;
else if (strcmp(arg[iarg+1],"running") == 0) ave = RUNNING;
else if (strcmp(arg[iarg+1],"window") == 0) ave = WINDOW;
else error->all(FLERR,"Unknown fix ave/histo ave option: {}", arg[iarg+1]);
else error->all(FLERR, iarg + 1, "Unknown fix ave/histo ave option: {}", arg[iarg+1]);
if (ave == WINDOW) {
if (iarg+3 > narg) utils::missing_cmd_args(FLERR, mycmd + " ave window", error);
if (iarg+3 > narg) utils::missing_cmd_args(FLERR, mycmd + "ave window", error);
nwindow = utils::inumeric(FLERR,arg[iarg+2],false,lmp);
if (nwindow <= 0) error->all(FLERR,"Illegal fix ave/histo ave window size: {}", nwindow);
if (nwindow <= 0)
error->all(FLERR, iarg + 2, "Illegal fix ave/histo ave window size: {}", nwindow);
}
iarg += 2;
if (ave == WINDOW) iarg++;
} else if (strcmp(arg[iarg],"start") == 0) {
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + " start", error);
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + "start", error);
startstep = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
iarg += 2;
} else if (strcmp(arg[iarg],"mode") == 0) {
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + " mode", error);
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + "mode", error);
if (strcmp(arg[iarg+1],"scalar") == 0) mode = SCALAR;
else if (strcmp(arg[iarg+1],"vector") == 0) mode = VECTOR;
else error->all(FLERR,"Unknown fix ave/histo mode option: {}", arg[iarg+1]);
else error->all(FLERR, iarg + 1, "Unknown fix ave/histo mode option: {}", arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"beyond") == 0) {
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + " beyond", error);
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, mycmd + "beyond", error);
if (strcmp(arg[iarg+1],"ignore") == 0) beyond = IGNORE;
else if (strcmp(arg[iarg+1],"end") == 0) beyond = END;
else if (strcmp(arg[iarg+1],"extra") == 0) beyond = EXTRA;
else error->all(FLERR,"Unknown fix ave/histo beyond option: {}", arg[iarg+1]);
else error->all(FLERR, iarg + 1, "Unknown fix ave/histo beyond option: {}", arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"overwrite") == 0) {
overwrite = 1;
@ -908,7 +940,7 @@ void FixAveHisto::options(int iarg, int narg, char **arg)
delete[] title3;
title3 = utils::strdup(arg[iarg+1]);
iarg += 2;
} else error->all(FLERR,"Unknown {} option: {}", mycmd, arg[iarg]);
} else error->all(FLERR, iarg, "Unknown {}option: {}", mycmd, arg[iarg]);
}
}

View File

@ -39,6 +39,7 @@ class FixAveHisto : public Fix {
struct value_t {
int which; // type of data: COMPUTE, FIX, VARIABLE
int argindex; // 1-based index if data is vector, else 0
int iarg; // argument index in original argument list
std::string id; // compute/fix/variable ID
union {
class Compute *c;

View File

@ -83,7 +83,7 @@ FixAveTime::FixAveTime(LAMMPS *lmp, int narg, char **arg) :
int expand = 0;
char **earg;
int *amap = nullptr;
nvalues = utils::expand_args(FLERR,nvalues,&arg[ioffset],mode,earg,lmp,&amap);
nvalues = utils::expand_args(FLERR, nvalues, &arg[ioffset], mode, earg, lmp, &amap);
key2col.clear();
if (earg != &arg[ioffset]) expand = 1;

View File

@ -562,7 +562,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->all(FLERR,"Cannot open input script {}: {}", arg[inflag], utils::getsyserror());
if (!helpflag)
utils::logmesg(this,"LAMMPS ({}{})\n", version, update_string);

View File

@ -436,7 +436,6 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq,
// update scale values from variables where needed
const int nvars = scalevars.size();
int atomscaleflag = 0;
if (nvars > 0) {
auto vals = new double[nvars];
auto vars = new int[nvars];
@ -453,7 +452,6 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq,
} else if (input->variable->atomstyle(m)) {
vals[k] = 0.0;
vars[k] = m;
atomscaleflag = 1;
} else
error->all(FLERR, "Variable '{}' has incompatible style", scalevars[k]);
}
@ -517,7 +515,6 @@ void PairHybridScaled::born_matrix(int i, int j, int itype, int jtype, double rs
// update scale values from variables where needed
const int nvars = scalevars.size();
int atomscaleflag = 0;
if (nvars > 0) {
auto vals = new double[nvars];
auto vars = new int[nvars];
@ -534,7 +531,6 @@ void PairHybridScaled::born_matrix(int i, int j, int itype, int jtype, double rs
} else if (input->variable->atomstyle(m)) {
vals[k] = 0.0;
vars[k] = m;
atomscaleflag = 1;
} else
error->all(FLERR, "Variable '{}' has incompatible style", scalevars[k]);
}

View File

@ -43,6 +43,15 @@ namespace utils {
/*! Compare two string while ignoring whitespace
*
\verbatim embed:rst
.. versionadded:: TBD
This function compares two strings while skipping over any kind of whitespace
(blank, tab, newline, carriage return, etc.).
\endverbatim
*
* \param text1 the first text to be compared
* \param text2 the second text to be compared
* \return true if the non-whitespace part of the two strings matches, false if not */
@ -51,6 +60,14 @@ namespace utils {
/*! Compress whitespace in a string
*
\verbatim embed:rst
.. versionadded:: TBD
This function compresses whitespace in a string to just a single blank.
\endverbatim
*
* \param text the text to be compressed
* \return string with whitespace compressed to single blanks */
@ -77,11 +94,22 @@ namespace utils {
/*! Create string with last command and optionally pointing to arg with error
*
* This function is a helper function for error messages. It creates
\verbatim embed:rst
.. versionadded:: TBD
This function is a helper function for error messages. It creates extra output
in error messages. It will produce either two or three lines: the original last
input line *before* variable substitutions, the corresponding pre-processed command
(only when different) and one or more '^' characters pointing to the faulty argument
as indicated by the *failed* argument. Any whitespace in the lines with the command
output are compressed to a single blank by calling :cpp:func:`strcompress()`
\endverbatim
*
* \param input pointer to the Input class instance (for access to last command args)
* \param faile index of the faulty argument (-1 to point to the command itself)
* \return string with two lines: the pre-processed command and a '^' pointing to the faulty argument */
* \param failed index of the faulty argument (-1 to point to the command itself)
* \return string with two or three lines to follow error messages */
std::string point_to_error(Input *input, int failed);
/*! Internal function handling the argument list for logmesg(). */
@ -111,22 +139,18 @@ namespace utils {
void logmesg(LAMMPS *lmp, const std::string &mesg);
/*! Return text redirecting the user to a specific paragraph in the manual
*
* The LAMMPS manual contains detailed explanations for errors and
* warnings where a simple error message may not be sufficient. These can
* be reached through URLs with a numeric code. This function creates the
* corresponding text to be included into the error message that redirects
* the user to that URL.
*
* \param errorcode number pointing to a paragraph in the manual */
/*! Internal function handling the argument list for print(). */
void fmtargs_print(FILE *fp, fmt::string_view format, fmt::format_args args);
/*! Write formatted message to file
*
\verbatim embed:rst
.. versionadded:: TBD
\endverbatim
*
* This function implements a version of fprintf() that uses {fmt} formatting
*
* \param fp stdio FILE pointer

View File

@ -835,7 +835,8 @@ int Variable::next(int narg, char **arg)
if (fp == nullptr) goto uloop_again;
buf[0] = buf[1] = '\0';
fread(buf,1,64,fp);
auto tmp = fread(buf,1,64,fp);
(void) tmp; // can be safely ignored, suppress compiler warning in a portable way
fclose(fp);
if (strlen(buf) > 0) {

View File

@ -102,7 +102,7 @@ def check_folder(directory, config, fix=False, verbose=False):
return success
def main():
parser = argparse.ArgumentParser(description='Utility for detecting and fixing whitespace issues in LAMMPS')
parser = argparse.ArgumentParser(description='Utility for detecting and removing error message comment in LAMMPS headers')
parser.add_argument('-c', '--config', metavar='CONFIG_FILE', help='location of a optional configuration file')
parser.add_argument('-f', '--fix', action='store_true', help='automatically fix URLs')
parser.add_argument('-v', '--verbose', action='store_true', help='verbose output')

View File

@ -158,7 +158,7 @@ def check_folder(directory, config, fix=False, verbose=False):
return success
def main():
parser = argparse.ArgumentParser(description='Utility for detecting and fixing whitespace issues in LAMMPS')
parser = argparse.ArgumentParser(description='Utility for detecting and correct the LAMMPS homepage URL and developer email in LAMMPS source files')
parser.add_argument('-c', '--config', metavar='CONFIG_FILE', help='location of a optional configuration file')
parser.add_argument('-f', '--fix', action='store_true', help='automatically fix URLs')
parser.add_argument('-v', '--verbose', action='store_true', help='verbose output')