forked from lijiext/lammps
Merge branch 'master' into more-fmtlib-and-string
# Conflicts: # src/write_restart.cpp
This commit is contained in:
commit
f547d66104
|
@ -275,7 +275,7 @@ void KimInit::determine_model_type_and_units(char * model_name,
|
||||||
std::string mesg("Incompatible units for KIM Simulator Model, "
|
std::string mesg("Incompatible units for KIM Simulator Model, "
|
||||||
"required units = ");
|
"required units = ");
|
||||||
mesg += *model_units;
|
mesg += *model_units;
|
||||||
error->all(FLERR,mesg.c_str());
|
error->all(FLERR,mesg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,8 +328,7 @@ void KimInit::do_init(char *model_name, char *user_units, char *model_units, KIM
|
||||||
mesg += "\n";
|
mesg += "\n";
|
||||||
mesg += "#\n";
|
mesg += "#\n";
|
||||||
|
|
||||||
if (screen) fputs(mesg.c_str(),screen);
|
utils::logmesg(lmp,mesg);
|
||||||
if (logfile) fputs(mesg.c_str(),logfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fix_store->setptr("simulator_model", (void *) simulatorModel);
|
fix_store->setptr("simulator_model", (void *) simulatorModel);
|
||||||
|
@ -346,7 +345,7 @@ void KimInit::do_init(char *model_name, char *user_units, char *model_units, KIM
|
||||||
|
|
||||||
std::string cmd("units ");
|
std::string cmd("units ");
|
||||||
cmd += model_units;
|
cmd += model_units;
|
||||||
input->one(cmd.c_str());
|
input->one(cmd);
|
||||||
|
|
||||||
if (model_type == SM) {
|
if (model_type == SM) {
|
||||||
int sim_fields, sim_lines;
|
int sim_fields, sim_lines;
|
||||||
|
@ -519,7 +518,7 @@ void KimInit::do_variables(char *user_units, char *model_units)
|
||||||
"unit = " + units[i] + "; "
|
"unit = " + units[i] + "; "
|
||||||
"from = " + from + "; "
|
"from = " + from + "; "
|
||||||
"to = " + to + ".";
|
"to = " + to + ".";
|
||||||
error->all(FLERR,err.c_str());
|
error->all(FLERR,err);
|
||||||
}
|
}
|
||||||
variable->internal_set(v_unit,conversion_factor);
|
variable->internal_set(v_unit,conversion_factor);
|
||||||
if (comm->me == 0) {
|
if (comm->me == 0) {
|
||||||
|
|
|
@ -192,7 +192,7 @@ void KimInteractions::do_setup(int narg, char **arg)
|
||||||
std::string msg("Species '");
|
std::string msg("Species '");
|
||||||
msg += strword;
|
msg += strword;
|
||||||
msg += "' is not supported by this KIM Simulator Model";
|
msg += "' is not supported by this KIM Simulator Model";
|
||||||
error->all(FLERR,msg.c_str());
|
error->all(FLERR,msg);
|
||||||
}
|
}
|
||||||
strword = strtok(NULL," \t");
|
strword = strtok(NULL," \t");
|
||||||
}
|
}
|
||||||
|
@ -276,8 +276,8 @@ void KimInteractions::do_setup(int narg, char **arg)
|
||||||
cmd2 += " ";
|
cmd2 += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
input->one(cmd1.c_str());
|
input->one(cmd1);
|
||||||
input->one(cmd2.c_str());
|
input->one(cmd2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// End output to log file
|
// End output to log file
|
||||||
|
|
|
@ -163,7 +163,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
if (!kim_param_get && !kim_param_set) {
|
if (!kim_param_get && !kim_param_set) {
|
||||||
std::string msg("Incorrect arguments in kim_param command.\n");
|
std::string msg("Incorrect arguments in kim_param command.\n");
|
||||||
msg += "'kim_param get/set' is mandatory.";
|
msg += "'kim_param get/set' is mandatory.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we called a kim_init command
|
// Check if we called a kim_init command
|
||||||
|
@ -225,7 +225,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
msg += "To set the new parameter values, pair style must be assigned.\n";
|
msg += "To set the new parameter values, pair style must be assigned.\n";
|
||||||
msg += "Must use 'kim_interactions' or";
|
msg += "Must use 'kim_interactions' or";
|
||||||
msg += "'pair_style kim ' before 'kim_param set'";
|
msg += "'pair_style kim ' before 'kim_param set'";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
} else {
|
} else {
|
||||||
KIM_LengthUnit lengthUnit;
|
KIM_LengthUnit lengthUnit;
|
||||||
KIM_EnergyUnit energyUnit;
|
KIM_EnergyUnit energyUnit;
|
||||||
|
@ -296,7 +296,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
msg += "This Model does not have the requested '";
|
msg += "This Model does not have the requested '";
|
||||||
msg += paramname;
|
msg += paramname;
|
||||||
msg += "' parameter.";
|
msg += "' parameter.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the index_range for the requested parameter
|
// Get the index_range for the requested parameter
|
||||||
|
@ -313,7 +313,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
msg += "Expected integer parameter(s) instead of '";
|
msg += "Expected integer parameter(s) instead of '";
|
||||||
msg += argtostr;
|
msg += argtostr;
|
||||||
msg += "' in index_range.";
|
msg += "' in index_range.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::size_type npos = argtostr.find(':');
|
std::string::size_type npos = argtostr.find(':');
|
||||||
|
@ -330,7 +330,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
msg += "' parameter with extent of '";
|
msg += "' parameter with extent of '";
|
||||||
msg += SNUM(extent);
|
msg += SNUM(extent);
|
||||||
msg += "' .";
|
msg += "' .";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::stringstream str(argtostr);
|
std::stringstream str(argtostr);
|
||||||
|
@ -342,7 +342,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
msg += "' with the extent of '";
|
msg += "' with the extent of '";
|
||||||
msg += SNUM(extent);
|
msg += SNUM(extent);
|
||||||
msg += "' .";
|
msg += "' .";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
nubound = nlbound;
|
nubound = nlbound;
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
std::string msg("Wrong number of arguments in ");
|
std::string msg("Wrong number of arguments in ");
|
||||||
msg += "kim_param get command.\n";
|
msg += "kim_param get command.\n";
|
||||||
msg += "Index range after parameter name is mandatory.";
|
msg += "Index range after parameter name is mandatory.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int const nvars = nubound - nlbound + 1;
|
int const nvars = nubound - nlbound + 1;
|
||||||
|
@ -363,7 +363,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
std::string msg("Wrong number of arguments in ");
|
std::string msg("Wrong number of arguments in ");
|
||||||
msg += "kim_param get command.\n";
|
msg += "kim_param get command.\n";
|
||||||
msg += "The LAMMPS variable name is mandatory.";
|
msg += "The LAMMPS variable name is mandatory.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// indicator flag for list request
|
// indicator flag for list request
|
||||||
|
@ -400,7 +400,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
msg += "' variable names or '";
|
msg += "' variable names or '";
|
||||||
msg += varname;
|
msg += varname;
|
||||||
msg += " split' is mandatory.";
|
msg += " split' is mandatory.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::string msg("Wrong number of arguments in ");
|
std::string msg("Wrong number of arguments in ");
|
||||||
|
@ -410,7 +410,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
msg += "' variable names or '";
|
msg += "' variable names or '";
|
||||||
msg += varname;
|
msg += varname;
|
||||||
msg += " split/list' is mandatory.";
|
msg += " split/list' is mandatory.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
varsname = new char *[1];
|
varsname = new char *[1];
|
||||||
|
@ -524,7 +524,7 @@ void KimParam::command(int narg, char **arg)
|
||||||
set_cmd += " ";
|
set_cmd += " ";
|
||||||
set_cmd += arg[i];
|
set_cmd += arg[i];
|
||||||
}
|
}
|
||||||
input->one(set_cmd.c_str());
|
input->one(set_cmd);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
error->all(FLERR, "This model has No mutable parameters.");
|
error->all(FLERR, "This model has No mutable parameters.");
|
||||||
|
|
|
@ -100,13 +100,13 @@ void kimProperty::command(int narg, char **arg)
|
||||||
std::string msg("Error incorrect arguments in kim_property command.\n");
|
std::string msg("Error incorrect arguments in kim_property command.\n");
|
||||||
msg += "`kim_property create/destroy/modify/remove/dump` ";
|
msg += "`kim_property create/destroy/modify/remove/dump` ";
|
||||||
msg += "is mandatory.";
|
msg += "is mandatory.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comm->me == 0) {
|
if (comm->me == 0) {
|
||||||
std::string msg;
|
std::string msg;
|
||||||
msg = "#=== kim-property ===========================================\n";
|
msg = "#=== kim-property ===========================================\n";
|
||||||
input->write_echo(msg.c_str());
|
input->write_echo(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the kim_str ptr to the data associated with a kim_property_str
|
// Get the kim_str ptr to the data associated with a kim_property_str
|
||||||
|
|
|
@ -429,7 +429,7 @@ void PairKIM::coeff(int narg, char **arg)
|
||||||
} else {
|
} else {
|
||||||
std::string msg("create_kim_particle_codes: symbol not found: ");
|
std::string msg("create_kim_particle_codes: symbol not found: ");
|
||||||
msg += lmps_unique_elements[i];
|
msg += lmps_unique_elements[i];
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set the new values for PM parameters
|
// Set the new values for PM parameters
|
||||||
|
@ -441,7 +441,7 @@ void PairKIM::coeff(int narg, char **arg)
|
||||||
if (!numberOfParameters) {
|
if (!numberOfParameters) {
|
||||||
std::string msg("Incorrect args for pair coefficients \n");
|
std::string msg("Incorrect args for pair coefficients \n");
|
||||||
msg += "This model has No mutable parameters.";
|
msg += "This model has No mutable parameters.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int kimerror;
|
int kimerror;
|
||||||
|
@ -477,7 +477,7 @@ void PairKIM::coeff(int narg, char **arg)
|
||||||
msg += "This Model does not have the requested '";
|
msg += "This Model does not have the requested '";
|
||||||
msg += paramname;
|
msg += paramname;
|
||||||
msg += "' parameter.";
|
msg += "' parameter.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the index_range for the requested parameter
|
// Get the index_range for the requested parameter
|
||||||
|
@ -493,7 +493,7 @@ void PairKIM::coeff(int narg, char **arg)
|
||||||
msg += "Expected integer parameter(s) instead of '";
|
msg += "Expected integer parameter(s) instead of '";
|
||||||
msg += argtostr;
|
msg += argtostr;
|
||||||
msg += "' in index_range.";
|
msg += "' in index_range.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::size_type npos = argtostr.find(':');
|
std::string::size_type npos = argtostr.find(':');
|
||||||
|
@ -510,7 +510,7 @@ void PairKIM::coeff(int narg, char **arg)
|
||||||
msg += "' parameter with extent of '";
|
msg += "' parameter with extent of '";
|
||||||
msg += SNUM(extent);
|
msg += SNUM(extent);
|
||||||
msg += "' .";
|
msg += "' .";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::stringstream str(argtostr);
|
std::stringstream str(argtostr);
|
||||||
|
@ -522,7 +522,7 @@ void PairKIM::coeff(int narg, char **arg)
|
||||||
msg += "' parameter with extent of '";
|
msg += "' parameter with extent of '";
|
||||||
msg += SNUM(extent);
|
msg += SNUM(extent);
|
||||||
msg += "' .";
|
msg += "' .";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
nubound = nlbound;
|
nubound = nlbound;
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ void PairKIM::coeff(int narg, char **arg)
|
||||||
std::string msg =
|
std::string msg =
|
||||||
"Wrong number of arguments for pair coefficients.\n";
|
"Wrong number of arguments for pair coefficients.\n";
|
||||||
msg += "Index range after parameter name is mandatory.";
|
msg += "Index range after parameter name is mandatory.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parameter values
|
// Parameter values
|
||||||
|
@ -561,7 +561,7 @@ void PairKIM::coeff(int narg, char **arg)
|
||||||
msg += "' values are requested for '";
|
msg += "' values are requested for '";
|
||||||
msg += paramname;
|
msg += paramname;
|
||||||
msg += "' parameter.";
|
msg += "' parameter.";
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,7 +1122,7 @@ void PairKIM::set_kim_model_has_flags()
|
||||||
KIM_SUPPORT_STATUS_required)) {
|
KIM_SUPPORT_STATUS_required)) {
|
||||||
std::string msg("KIM Model requires unsupported compute argument: ");
|
std::string msg("KIM Model requires unsupported compute argument: ");
|
||||||
msg += KIM_ComputeArgumentName_ToString(computeArgumentName);
|
msg += KIM_ComputeArgumentName_ToString(computeArgumentName);
|
||||||
error->all(FLERR, msg.c_str());
|
error->all(FLERR, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) :
|
||||||
else {
|
else {
|
||||||
std::string errmsg = "Illegal command " + std::string(word)
|
std::string errmsg = "Illegal command " + std::string(word)
|
||||||
+ " expected \"sparse\" or \"dense\"\n";
|
+ " expected \"sparse\" or \"dense\"\n";
|
||||||
error->all(FLERR, errmsg.c_str());
|
error->all(FLERR, errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comm->me == 0 and Verbosity > 1){
|
if (comm->me == 0 and Verbosity > 1){
|
||||||
|
@ -134,7 +134,7 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) :
|
||||||
else
|
else
|
||||||
msg += std::string("dense");
|
msg += std::string("dense");
|
||||||
|
|
||||||
error->message(FLERR, msg.c_str());
|
error->message(FLERR, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ FixRX::FixRX(LAMMPS *lmp, int narg, char **arg) :
|
||||||
odeIntegrationFlag = ODE_LAMMPS_RKF45;
|
odeIntegrationFlag = ODE_LAMMPS_RKF45;
|
||||||
else {
|
else {
|
||||||
std::string errmsg = "Illegal ODE integration type: " + std::string(word);
|
std::string errmsg = "Illegal ODE integration type: " + std::string(word);
|
||||||
error->all(FLERR, errmsg.c_str());
|
error->all(FLERR, errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
#include "math_const.h"
|
#include "math_const.h"
|
||||||
#include "math_extra.h"
|
#include "math_extra.h"
|
||||||
|
@ -759,11 +760,9 @@ void PairMesoCNT::read_file()
|
||||||
// open file
|
// open file
|
||||||
|
|
||||||
fp = force->open_potential(file);
|
fp = force->open_potential(file);
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
std::string str("Cannot open mesocnt file: ");
|
error->one(FLERR,fmt::format("Cannot open mesocnt file: {}",file));
|
||||||
str += file;
|
|
||||||
error->one(FLERR,str.c_str());
|
|
||||||
}
|
|
||||||
utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
|
utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
|
||||||
|
|
||||||
// potential parameters
|
// potential parameters
|
||||||
|
@ -771,18 +770,15 @@ void PairMesoCNT::read_file()
|
||||||
utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
|
utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
|
||||||
num = sscanf(line,"%d %d %d %d",
|
num = sscanf(line,"%d %d %d %d",
|
||||||
&uinf_points,&gamma_points,&phi_points,&usemi_points);
|
&uinf_points,&gamma_points,&phi_points,&usemi_points);
|
||||||
if (num != 4) {
|
if (num != 4)
|
||||||
std::string str("Could not correctly parse line 2 in mesocnt file: ");
|
error->one(FLERR,fmt::format("Could not correctly parse line 2 in "
|
||||||
str += file;
|
"mesocnt file: {}",file));
|
||||||
error->one(FLERR,str.c_str());
|
|
||||||
}
|
|
||||||
utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
|
utils::sfgets(FLERR,line,MAXLINE,fp,file,error);
|
||||||
num = sscanf(line,"%lg %lg %lg %lg",&r_ang,&sig_ang,&delta1,&delta2);
|
num = sscanf(line,"%lg %lg %lg %lg",&r_ang,&sig_ang,&delta1,&delta2);
|
||||||
if (num != 4) {
|
if (num != 4)
|
||||||
std::string str("Could not correctly parse line 3 in mesocnt file: ");
|
error->one(FLERR,fmt::format("Could not correctly parse line 3 in "
|
||||||
str += file;
|
"mesocnt file: {}",file));
|
||||||
error->one(FLERR,str.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MPI_Bcast(&uinf_points,1,MPI_INT,0,world);
|
MPI_Bcast(&uinf_points,1,MPI_INT,0,world);
|
||||||
|
@ -850,11 +846,9 @@ void PairMesoCNT::read_data(FILE *fp, double *data,
|
||||||
double x,xtemp,dxtemp;
|
double x,xtemp,dxtemp;
|
||||||
|
|
||||||
for (int i = 0; i < ninput; i++) {
|
for (int i = 0; i < ninput; i++) {
|
||||||
if (NULL == fgets(line,MAXLINE,fp)) {
|
if (NULL == fgets(line,MAXLINE,fp))
|
||||||
std::string str("Premature end of file in pair table ");
|
error->one(FLERR,fmt::format("Premature end of file in pair table: {}",file));
|
||||||
str += file;
|
|
||||||
error->one(FLERR,str.c_str());
|
|
||||||
}
|
|
||||||
if (i > 0) xtemp = x;
|
if (i > 0) xtemp = x;
|
||||||
if (2 != sscanf(line,"%lg %lg",&x,&data[i])) cerror++;
|
if (2 != sscanf(line,"%lg %lg",&x,&data[i])) cerror++;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
@ -869,24 +863,18 @@ void PairMesoCNT::read_data(FILE *fp, double *data,
|
||||||
// warn if data was read incompletely, e.g. columns were missing
|
// warn if data was read incompletely, e.g. columns were missing
|
||||||
|
|
||||||
if (cerror) {
|
if (cerror) {
|
||||||
char str[128];
|
std::string mesg = fmt::format("{} of {} lines were incomplete or could "
|
||||||
sprintf(str,"%d of %d lines were incomplete\n"
|
"or could not be parsed completely in "
|
||||||
" or could not be parsed completely\n"
|
" pair table: {}",cerror,ninput,file);
|
||||||
" in pair table ",cerror,ninput);
|
error->warning(FLERR,mesg);
|
||||||
std::string errstr = str;
|
|
||||||
errstr += file;
|
|
||||||
error->warning(FLERR,errstr.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// warn if spacing between data points is not constant
|
// warn if spacing between data points is not constant
|
||||||
|
|
||||||
if (serror) {
|
if (serror) {
|
||||||
char str[128];
|
std::string mesg = fmt::format("{} spacings in first column were different "
|
||||||
sprintf(str,"%d spacings in first column were different\n"
|
" from first spacing in pair table: {}",serror,file);
|
||||||
" from first spacing in pair table ",serror);
|
error->warning(FLERR,mesg);
|
||||||
std::string errstr = str;
|
|
||||||
errstr += file;
|
|
||||||
error->warning(FLERR,errstr.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,11 +899,9 @@ void PairMesoCNT::read_data(FILE *fp, double **data,
|
||||||
for (int i = 0; i < ninput; i++) {
|
for (int i = 0; i < ninput; i++) {
|
||||||
if (i > 0) xtemp = x;
|
if (i > 0) xtemp = x;
|
||||||
for (int j = 0; j < ninput; j++) {
|
for (int j = 0; j < ninput; j++) {
|
||||||
if (NULL == fgets(line,MAXLINE,fp)) {
|
if (NULL == fgets(line,MAXLINE,fp))
|
||||||
std::string str("Premature end of file in pair table ");
|
error->one(FLERR,fmt::format("Premature end of file in pair table: {}",file));
|
||||||
str += file;
|
|
||||||
error->one(FLERR,str.c_str());
|
|
||||||
}
|
|
||||||
if (j > 0) ytemp = y;
|
if (j > 0) ytemp = y;
|
||||||
if (3 != sscanf(line,"%lg %lg %lg",&x,&y,&data[i][j])) cerror++;
|
if (3 != sscanf(line,"%lg %lg %lg",&x,&y,&data[i][j])) cerror++;
|
||||||
if (i == 0 && j == 0) ystart = y;
|
if (i == 0 && j == 0) ystart = y;
|
||||||
|
@ -936,34 +922,21 @@ void PairMesoCNT::read_data(FILE *fp, double **data,
|
||||||
|
|
||||||
// warn if data was read incompletely, e.g. columns were missing
|
// warn if data was read incompletely, e.g. columns were missing
|
||||||
|
|
||||||
if (cerror) {
|
if (cerror)
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("{} of {} lines were incomplete or could "
|
||||||
sprintf(str,"%d of %d lines were incomplete\n"
|
"not be parsed completely in pair table: {}",
|
||||||
" or could not be parsed completely\n"
|
cerror,ninput*ninput,file));
|
||||||
" in pair table ",cerror,ninput*ninput);
|
|
||||||
std::string errstr = str;
|
|
||||||
errstr += file;
|
|
||||||
error->warning(FLERR,errstr.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// warn if spacing between data points is not constant
|
// warn if spacing between data points is not constant
|
||||||
|
|
||||||
if (sxerror) {
|
if (sxerror)
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("{} spacings in first column were different "
|
||||||
sprintf(str,"%d spacings in first column were different\n"
|
" from first spacing in pair table: {}",
|
||||||
" from first spacing in pair table ",sxerror);
|
sxerror,file));
|
||||||
std::string errstr = str;
|
if (syerror)
|
||||||
errstr += file;
|
error->warning(FLERR,fmt::format("{} spacings in second column were different "
|
||||||
error->warning(FLERR,errstr.c_str());
|
" from first spacing in pair table: {}",
|
||||||
}
|
syerror,file));
|
||||||
if (syerror) {
|
|
||||||
char str[128];
|
|
||||||
sprintf(str,"%d spacings in second column were different\n"
|
|
||||||
" from first spacing in pair table ",syerror);
|
|
||||||
std::string errstr = str;
|
|
||||||
errstr += file;
|
|
||||||
error->warning(FLERR,errstr.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
|
@ -758,7 +758,7 @@ AtomVec *Atom::new_avec(const std::string &style, int trysuffix, int &sflag)
|
||||||
return avec_creator(lmp);
|
return avec_creator(lmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
error->all(FLERR,utils::check_packages_for_style("atom",style,lmp).c_str());
|
error->all(FLERR,utils::check_packages_for_style("atom",style,lmp));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -475,7 +475,9 @@ void Balance::options(int iarg, int narg, char **arg)
|
||||||
|
|
||||||
if (outflag && comm->me == 0) {
|
if (outflag && comm->me == 0) {
|
||||||
fp = fopen(arg[outarg],"w");
|
fp = fopen(arg[outarg],"w");
|
||||||
if (fp == NULL) error->one(FLERR,"Cannot open (fix) balance output file");
|
if (fp == NULL)
|
||||||
|
error->one(FLERR,fmt::format("Cannot open (fix) balance output file {}: {}",
|
||||||
|
arg[outarg], utils::getsyserror()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "atom_masks.h"
|
#include "atom_masks.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -254,7 +256,9 @@ void Bond::write_file(int narg, char **arg)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(arg[4],"a");
|
fp = fopen(arg[4],"a");
|
||||||
if (fp == NULL) error->one(FLERR,"Cannot open bond_write file");
|
if (fp == NULL)
|
||||||
|
error->one(FLERR,fmt::format("Cannot open bond_write file {}: {}",
|
||||||
|
arg[4], utils::getsyserror()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize potentials before evaluating bond potential
|
// initialize potentials before evaluating bond potential
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -388,12 +390,10 @@ void ChangeBox::command(int narg, char **arg)
|
||||||
bigint natoms;
|
bigint natoms;
|
||||||
bigint nblocal = atom->nlocal;
|
bigint nblocal = atom->nlocal;
|
||||||
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
if (natoms != atom->natoms && comm->me == 0) {
|
if (natoms != atom->natoms && comm->me == 0)
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Lost atoms via change_box: "
|
||||||
sprintf(str,"Lost atoms via change_box: original " BIGINT_FORMAT
|
"original {} current {}",
|
||||||
" current " BIGINT_FORMAT,atom->natoms,natoms);
|
atom->natoms,natoms));
|
||||||
error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
20
src/comm.cpp
20
src/comm.cpp
|
@ -679,23 +679,19 @@ double Comm::get_comm_cutoff()
|
||||||
if (!force->pair && (cutghostuser == 0.0)) {
|
if (!force->pair && (cutghostuser == 0.0)) {
|
||||||
maxcommcutoff = MAX(maxcommcutoff,maxbondcutoff);
|
maxcommcutoff = MAX(maxcommcutoff,maxbondcutoff);
|
||||||
} else {
|
} else {
|
||||||
if ((me == 0) && (maxbondcutoff > maxcommcutoff)) {
|
if ((me == 0) && (maxbondcutoff > maxcommcutoff))
|
||||||
char mesg[256];
|
error->warning(FLERR,fmt::format("Communication cutoff {} is shorter "
|
||||||
snprintf(mesg,256,"Communication cutoff %g is shorter than a bond "
|
"than a bond length based estimate of "
|
||||||
"length based estimate of %g. This may lead to errors.",
|
"{}. This may lead to errors.",
|
||||||
maxcommcutoff,maxbondcutoff);
|
maxcommcutoff,maxbondcutoff));
|
||||||
error->warning(FLERR,mesg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// print warning if neighborlist cutoff overrides user cutoff
|
// print warning if neighborlist cutoff overrides user cutoff
|
||||||
|
|
||||||
if ((me == 0) && (update->setupflag == 1)) {
|
if ((me == 0) && (update->setupflag == 1)) {
|
||||||
if ((cutghostuser > 0.0) && (maxcommcutoff > cutghostuser)) {
|
if ((cutghostuser > 0.0) && (maxcommcutoff > cutghostuser))
|
||||||
char mesg[128];
|
error->warning(FLERR,fmt::format("Communication cutoff adjusted to {}",
|
||||||
snprintf(mesg,128,"Communication cutoff adjusted to %g",maxcommcutoff);
|
maxcommcutoff));
|
||||||
error->warning(FLERR,mesg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return maxcommcutoff;
|
return maxcommcutoff;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "math_extra.h"
|
#include "math_extra.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
|
@ -353,12 +354,10 @@ void DisplaceAtoms::command(int narg, char **arg)
|
||||||
bigint natoms;
|
bigint natoms;
|
||||||
bigint nblocal = atom->nlocal;
|
bigint nblocal = atom->nlocal;
|
||||||
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
|
||||||
if (natoms != atom->natoms && comm->me == 0) {
|
if (natoms != atom->natoms && comm->me == 0)
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Lost atoms via displace_atoms: "
|
||||||
sprintf(str,"Lost atoms via displace_atoms: original " BIGINT_FORMAT
|
"original {} current {}",
|
||||||
" current " BIGINT_FORMAT,atom->natoms,natoms);
|
atom->natoms,natoms));
|
||||||
error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
|
@ -158,7 +158,7 @@ void Domain::init()
|
||||||
std::string mesg = "Must not have multiple fixes change box parameter ";
|
std::string mesg = "Must not have multiple fixes change box parameter ";
|
||||||
|
|
||||||
#define CHECK_BOX_FIX_ERROR(par) \
|
#define CHECK_BOX_FIX_ERROR(par) \
|
||||||
if (box_change_ ## par > 1) error->all(FLERR,(mesg + #par).c_str())
|
if (box_change_ ## par > 1) error->all(FLERR,(mesg + #par))
|
||||||
|
|
||||||
CHECK_BOX_FIX_ERROR(x);
|
CHECK_BOX_FIX_ERROR(x);
|
||||||
CHECK_BOX_FIX_ERROR(y);
|
CHECK_BOX_FIX_ERROR(y);
|
||||||
|
@ -1787,7 +1787,7 @@ void Domain::add_region(int narg, char **arg)
|
||||||
if (region_map->find(arg[1]) != region_map->end()) {
|
if (region_map->find(arg[1]) != region_map->end()) {
|
||||||
RegionCreator region_creator = (*region_map)[arg[1]];
|
RegionCreator region_creator = (*region_map)[arg[1]];
|
||||||
regions[nregion] = region_creator(lmp, narg, arg);
|
regions[nregion] = region_creator(lmp, narg, arg);
|
||||||
} else error->all(FLERR,utils::check_packages_for_style("region",arg[1],lmp).c_str());
|
} else error->all(FLERR,utils::check_packages_for_style("region",arg[1],lmp));
|
||||||
|
|
||||||
// initialize any region variables via init()
|
// initialize any region variables via init()
|
||||||
// in case region is used between runs, e.g. to print a variable
|
// in case region is used between runs, e.g. to print a variable
|
||||||
|
|
110
src/error.cpp
110
src/error.cpp
|
@ -15,10 +15,13 @@
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
#include "universe.h"
|
#include "universe.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "accelerator_kokkos.h"
|
#include "accelerator_kokkos.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
#if defined(LAMMPS_EXCEPTIONS)
|
#if defined(LAMMPS_EXCEPTIONS)
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
@ -28,23 +31,19 @@ using namespace LAMMPS_NS;
|
||||||
|
|
||||||
// helper function to truncate a string to a segment starting with "src/";
|
// helper function to truncate a string to a segment starting with "src/";
|
||||||
|
|
||||||
static const char *truncpath(const char *path)
|
static std::string truncpath(const std::string &path)
|
||||||
{
|
{
|
||||||
if (path) {
|
std::size_t found = path.find("src/");
|
||||||
int len = strlen(path);
|
if (found != std::string::npos)
|
||||||
for (int i = len-4; i > 0; --i) {
|
return path.substr(found);
|
||||||
if (strncmp("src/",path+i,4) == 0)
|
else return path;
|
||||||
return path+i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
Error::Error(LAMMPS *lmp) : Pointers(lmp) {
|
Error::Error(LAMMPS *lmp) : Pointers(lmp) {
|
||||||
#ifdef LAMMPS_EXCEPTIONS
|
#ifdef LAMMPS_EXCEPTIONS
|
||||||
last_error_message = NULL;
|
last_error_message.clear();
|
||||||
last_error_type = ERROR_NONE;
|
last_error_type = ERROR_NONE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -55,15 +54,14 @@ Error::Error(LAMMPS *lmp) : Pointers(lmp) {
|
||||||
no abort, so insure all procs in universe call, else will hang
|
no abort, so insure all procs in universe call, else will hang
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Error::universe_all(const char *file, int line, const char *str)
|
void Error::universe_all(const std::string &file, int line, const std::string &str)
|
||||||
{
|
{
|
||||||
MPI_Barrier(universe->uworld);
|
MPI_Barrier(universe->uworld);
|
||||||
|
std::string mesg = fmt::format("ERROR: {} ({}:{})\n",
|
||||||
|
str,truncpath(file),line);
|
||||||
if (universe->me == 0) {
|
if (universe->me == 0) {
|
||||||
if (universe->uscreen) fprintf(universe->uscreen,
|
if (universe->uscreen) fputs(mesg.c_str(),universe->uscreen);
|
||||||
"ERROR: %s (%s:%d)\n",str,truncpath(file),line);
|
if (universe->ulogfile) fputs(mesg.c_str(),universe->ulogfile);
|
||||||
if (universe->ulogfile) fprintf(universe->ulogfile,
|
|
||||||
"ERROR: %s (%s:%d)\n",str,truncpath(file),line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output) delete output;
|
if (output) delete output;
|
||||||
|
@ -80,9 +78,7 @@ void Error::universe_all(const char *file, int line, const char *str)
|
||||||
|
|
||||||
if (update) update->whichflag = 0;
|
if (update) update->whichflag = 0;
|
||||||
|
|
||||||
char msg[100];
|
throw LAMMPSException(mesg);
|
||||||
snprintf(msg, 100, "ERROR: %s (%s:%d)\n", str, truncpath(file), line);
|
|
||||||
throw LAMMPSException(msg);
|
|
||||||
#else
|
#else
|
||||||
if (lmp->kokkos) Kokkos::finalize();
|
if (lmp->kokkos) Kokkos::finalize();
|
||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
|
@ -95,11 +91,11 @@ void Error::universe_all(const char *file, int line, const char *str)
|
||||||
forces abort of entire universe if any proc in universe calls
|
forces abort of entire universe if any proc in universe calls
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Error::universe_one(const char *file, int line, const char *str)
|
void Error::universe_one(const std::string &file, int line, const std::string &str)
|
||||||
{
|
{
|
||||||
if (universe->uscreen)
|
std::string mesg = fmt::format("ERROR on proc {}: {} ({}:{})\n",
|
||||||
fprintf(universe->uscreen,"ERROR on proc %d: %s (%s:%d)\n",
|
|
||||||
universe->me,str,truncpath(file),line);
|
universe->me,str,truncpath(file),line);
|
||||||
|
if (universe->uscreen) fputs(mesg.c_str(),universe->uscreen);
|
||||||
|
|
||||||
#ifdef LAMMPS_EXCEPTIONS
|
#ifdef LAMMPS_EXCEPTIONS
|
||||||
|
|
||||||
|
@ -108,9 +104,7 @@ void Error::universe_one(const char *file, int line, const char *str)
|
||||||
|
|
||||||
if (update) update->whichflag = 0;
|
if (update) update->whichflag = 0;
|
||||||
|
|
||||||
char msg[100];
|
throw LAMMPSAbortException(mesg, universe->uworld);
|
||||||
snprintf(msg, 100, "ERROR: %s (%s:%d)\n", str, truncpath(file), line);
|
|
||||||
throw LAMMPSAbortException(msg, universe->uworld);
|
|
||||||
#else
|
#else
|
||||||
MPI_Abort(universe->uworld,1);
|
MPI_Abort(universe->uworld,1);
|
||||||
#endif
|
#endif
|
||||||
|
@ -121,10 +115,10 @@ void Error::universe_one(const char *file, int line, const char *str)
|
||||||
prints a warning message to the screen
|
prints a warning message to the screen
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Error::universe_warn(const char *file, int line, const char *str)
|
void Error::universe_warn(const std::string &file, int line, const std::string &str)
|
||||||
{
|
{
|
||||||
if (universe->uscreen)
|
if (universe->uscreen)
|
||||||
fprintf(universe->uscreen,"WARNING on proc %d: %s (%s:%d)\n",
|
fmt::print(universe->uscreen,"WARNING on proc {}: {} ({}:{})\n",
|
||||||
universe->me,str,truncpath(file),line);
|
universe->me,str,truncpath(file),line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,23 +129,19 @@ void Error::universe_warn(const char *file, int line, const char *str)
|
||||||
force MPI_Abort if running in multi-partition mode
|
force MPI_Abort if running in multi-partition mode
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Error::all(const char *file, int line, const char *str)
|
void Error::all(const std::string &file, int line, const std::string &str)
|
||||||
{
|
{
|
||||||
MPI_Barrier(world);
|
MPI_Barrier(world);
|
||||||
|
|
||||||
int me;
|
int me;
|
||||||
const char *lastcmd = (const char*)"(unknown)";
|
std::string lastcmd = "(unknown)";
|
||||||
|
|
||||||
MPI_Comm_rank(world,&me);
|
MPI_Comm_rank(world,&me);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
if (input && input->line) lastcmd = input->line;
|
if (input && input->line) lastcmd = input->line;
|
||||||
if (screen) fprintf(screen,"ERROR: %s (%s:%d)\n"
|
utils::logmesg(lmp,fmt::format("ERROR: {} ({}:{})\nLast command: {}\n",
|
||||||
"Last command: %s\n",
|
str,truncpath(file),line,lastcmd));
|
||||||
str,truncpath(file),line,lastcmd);
|
|
||||||
if (logfile) fprintf(logfile,"ERROR: %s (%s:%d)\n"
|
|
||||||
"Last command: %s\n",
|
|
||||||
str,truncpath(file),line,lastcmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LAMMPS_EXCEPTIONS
|
#ifdef LAMMPS_EXCEPTIONS
|
||||||
|
@ -161,8 +151,8 @@ void Error::all(const char *file, int line, const char *str)
|
||||||
|
|
||||||
if (update) update->whichflag = 0;
|
if (update) update->whichflag = 0;
|
||||||
|
|
||||||
char msg[100];
|
std::string msg = fmt::format("ERROR: {} ({}:{})\n",
|
||||||
snprintf(msg, 100, "ERROR: %s (%s:%d)\n", str, truncpath(file), line);
|
str, truncpath(file), line);
|
||||||
|
|
||||||
if (universe->nworlds > 1) {
|
if (universe->nworlds > 1) {
|
||||||
throw LAMMPSAbortException(msg, universe->uworld);
|
throw LAMMPSAbortException(msg, universe->uworld);
|
||||||
|
@ -188,24 +178,20 @@ void Error::all(const char *file, int line, const char *str)
|
||||||
forces abort of entire world (and universe) if any proc in world calls
|
forces abort of entire world (and universe) if any proc in world calls
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Error::one(const char *file, int line, const char *str)
|
void Error::one(const std::string &file, int line, const std::string &str)
|
||||||
{
|
{
|
||||||
int me;
|
int me;
|
||||||
const char *lastcmd = (const char*)"(unknown)";
|
std::string lastcmd = "(unknown)";
|
||||||
MPI_Comm_rank(world,&me);
|
MPI_Comm_rank(world,&me);
|
||||||
|
|
||||||
if (input && input->line) lastcmd = input->line;
|
if (input && input->line) lastcmd = input->line;
|
||||||
if (screen) fprintf(screen,"ERROR on proc %d: %s (%s:%d)\n"
|
std::string mesg = fmt::format("ERROR on proc {}: {} ({}:{})\n",
|
||||||
"Last command: %s\n",
|
|
||||||
me,str,truncpath(file),line,lastcmd);
|
|
||||||
if (logfile) fprintf(logfile,"ERROR on proc %d: %s (%s:%d)\n"
|
|
||||||
"Last command: %s\n",
|
|
||||||
me,str,truncpath(file),line,lastcmd);
|
me,str,truncpath(file),line,lastcmd);
|
||||||
|
utils::logmesg(lmp,mesg);
|
||||||
|
|
||||||
if (universe->nworlds > 1)
|
if (universe->nworlds > 1)
|
||||||
if (universe->uscreen)
|
if (universe->uscreen)
|
||||||
fprintf(universe->uscreen,"ERROR on proc %d: %s (%s:%d)\n",
|
fputs(mesg.c_str(),universe->uscreen);
|
||||||
universe->me,str,truncpath(file),line);
|
|
||||||
|
|
||||||
#ifdef LAMMPS_EXCEPTIONS
|
#ifdef LAMMPS_EXCEPTIONS
|
||||||
|
|
||||||
|
@ -214,9 +200,7 @@ void Error::one(const char *file, int line, const char *str)
|
||||||
|
|
||||||
if (update) update->whichflag = 0;
|
if (update) update->whichflag = 0;
|
||||||
|
|
||||||
char msg[100];
|
throw LAMMPSAbortException(mesg, world);
|
||||||
snprintf(msg, 100, "ERROR on proc %d: %s (%s:%d)\n", me, str, truncpath(file), line);
|
|
||||||
throw LAMMPSAbortException(msg, world);
|
|
||||||
#else
|
#else
|
||||||
if (screen) fflush(screen);
|
if (screen) fflush(screen);
|
||||||
if (logfile) fflush(logfile);
|
if (logfile) fflush(logfile);
|
||||||
|
@ -229,11 +213,12 @@ void Error::one(const char *file, int line, const char *str)
|
||||||
only write to screen if non-NULL on this proc since could be file
|
only write to screen if non-NULL on this proc since could be file
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Error::warning(const char *file, int line, const char *str, int logflag)
|
void Error::warning(const std::string &file, int line, const std::string &str, int logflag)
|
||||||
{
|
{
|
||||||
if (screen) fprintf(screen,"WARNING: %s (%s:%d)\n",str,truncpath(file),line);
|
std::string mesg = fmt::format("WARNING: {} ({}:{})\n",
|
||||||
if (logflag && logfile) fprintf(logfile,"WARNING: %s (%s:%d)\n",
|
|
||||||
str,truncpath(file),line);
|
str,truncpath(file),line);
|
||||||
|
if (screen) fputs(mesg.c_str(),screen);
|
||||||
|
if (logflag && logfile) fputs(mesg.c_str(),logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
@ -241,10 +226,12 @@ void Error::warning(const char *file, int line, const char *str, int logflag)
|
||||||
write message to screen and logfile (if logflag is set)
|
write message to screen and logfile (if logflag is set)
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Error::message(const char *file, int line, const char *str, int logflag)
|
void Error::message(const std::string &file, int line, const std::string &str, int logflag)
|
||||||
{
|
{
|
||||||
if (screen) fprintf(screen,"%s (%s:%d)\n",str,truncpath(file),line);
|
std::string mesg = fmt::format("{} ({}:{})\n",str,truncpath(file),line);
|
||||||
if (logflag && logfile) fprintf(logfile,"%s (%s:%d)\n",str,truncpath(file),line);
|
|
||||||
|
if (screen) fputs(mesg.c_str(),screen);
|
||||||
|
if (logflag && logfile) fputs(mesg.c_str(),logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
@ -273,7 +260,7 @@ void Error::done(int status)
|
||||||
compiled with -DLAMMPS_EXCEPTIONS)
|
compiled with -DLAMMPS_EXCEPTIONS)
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
char * Error::get_last_error() const
|
std::string Error::get_last_error() const
|
||||||
{
|
{
|
||||||
return last_error_message;
|
return last_error_message;
|
||||||
}
|
}
|
||||||
|
@ -293,16 +280,9 @@ ErrorType Error::get_last_error_type() const
|
||||||
(only used if compiled with -DLAMMPS_EXCEPTIONS)
|
(only used if compiled with -DLAMMPS_EXCEPTIONS)
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Error::set_last_error(const char * msg, ErrorType type)
|
void Error::set_last_error(const std::string &msg, ErrorType type)
|
||||||
{
|
{
|
||||||
delete [] last_error_message;
|
last_error_message = msg;
|
||||||
|
|
||||||
if(msg) {
|
|
||||||
last_error_message = new char[strlen(msg)+1];
|
|
||||||
strcpy(last_error_message, msg);
|
|
||||||
} else {
|
|
||||||
last_error_message = NULL;
|
|
||||||
}
|
|
||||||
last_error_type = type;
|
last_error_type = type;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
21
src/error.h
21
src/error.h
|
@ -15,6 +15,7 @@
|
||||||
#define LMP_ERROR_H
|
#define LMP_ERROR_H
|
||||||
|
|
||||||
#include "pointers.h"
|
#include "pointers.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#ifdef LAMMPS_EXCEPTIONS
|
#ifdef LAMMPS_EXCEPTIONS
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
|
@ -26,23 +27,23 @@ class Error : protected Pointers {
|
||||||
public:
|
public:
|
||||||
Error(class LAMMPS *);
|
Error(class LAMMPS *);
|
||||||
|
|
||||||
void universe_all(const char *, int, const char *);
|
void universe_all(const std::string &, int, const std::string &);
|
||||||
void universe_one(const char *, int, const char *);
|
void universe_one(const std::string &, int, const std::string &);
|
||||||
void universe_warn(const char *, int, const char *);
|
void universe_warn(const std::string &, int, const std::string &);
|
||||||
|
|
||||||
void all(const char *, int, const char *);
|
void all(const std::string &, int, const std::string &);
|
||||||
void one(const char *, int, const char *);
|
void one(const std::string &, int, const std::string &);
|
||||||
void warning(const char *, int, const char *, int = 1);
|
void warning(const std::string &, int, const std::string &, int = 1);
|
||||||
void message(const char *, int, const char *, int = 1);
|
void message(const std::string &, int, const std::string &, int = 1);
|
||||||
void done(int = 0); // 1 would be fully backwards compatible
|
void done(int = 0); // 1 would be fully backwards compatible
|
||||||
|
|
||||||
#ifdef LAMMPS_EXCEPTIONS
|
#ifdef LAMMPS_EXCEPTIONS
|
||||||
char * get_last_error() const;
|
std::string get_last_error() const;
|
||||||
ErrorType get_last_error_type() const;
|
ErrorType get_last_error_type() const;
|
||||||
void set_last_error(const char * msg, ErrorType type = ERROR_NORMAL);
|
void set_last_error(const std::string &msg, ErrorType type = ERROR_NORMAL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char * last_error_message;
|
std::string last_error_message;
|
||||||
ErrorType last_error_type;
|
ErrorType last_error_type;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,7 +25,7 @@ class LAMMPSException : public std::exception
|
||||||
public:
|
public:
|
||||||
std::string message;
|
std::string message;
|
||||||
|
|
||||||
LAMMPSException(std::string msg) : message(msg) {
|
LAMMPSException(const std::string &msg) : message(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
~LAMMPSException() throw() {
|
~LAMMPSException() throw() {
|
||||||
|
@ -40,7 +40,7 @@ class LAMMPSAbortException : public LAMMPSException {
|
||||||
public:
|
public:
|
||||||
MPI_Comm universe;
|
MPI_Comm universe;
|
||||||
|
|
||||||
LAMMPSAbortException(std::string msg, MPI_Comm universe) :
|
LAMMPSAbortException(const std::string &msg, MPI_Comm universe) :
|
||||||
LAMMPSException(msg),
|
LAMMPSException(msg),
|
||||||
universe(universe)
|
universe(universe)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -223,11 +225,9 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/chunk command");
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(arg[iarg+1],"w");
|
fp = fopen(arg[iarg+1],"w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open fix ave/chunk file {}: {}",
|
||||||
snprintf(str,128,"Cannot open fix ave/chunk file %s",arg[iarg+1]);
|
arg[iarg+1], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"overwrite") == 0) {
|
} else if (strcmp(arg[iarg],"overwrite") == 0) {
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -148,11 +150,9 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS * lmp, int narg, char **arg):
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate command");
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(arg[iarg+1],"w");
|
fp = fopen(arg[iarg+1],"w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open fix ave/correlate file {}:"" {}",
|
||||||
snprintf(str,128,"Cannot open fix ave/correlate file %s",arg[iarg+1]);
|
arg[iarg+1], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"overwrite") == 0) {
|
} else if (strcmp(arg[iarg],"overwrite") == 0) {
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -963,11 +965,9 @@ void FixAveHisto::options(int iarg, int narg, char **arg)
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/histo command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/histo command");
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(arg[iarg+1],"w");
|
fp = fopen(arg[iarg+1],"w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open fix ave/histo file {}: {}",
|
||||||
snprintf(str,128,"Cannot open fix ave/histo file %s",arg[iarg+1]);
|
arg[iarg+1], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"kind") == 0) {
|
} else if (strcmp(arg[iarg],"kind") == 0) {
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -1043,11 +1045,9 @@ void FixAveTime::options(int iarg, int narg, char **arg)
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command");
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(arg[iarg+1],"w");
|
fp = fopen(arg[iarg+1],"w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open fix ave/time file {}: {}",
|
||||||
snprintf(str,128,"Cannot open fix ave/time file %s",arg[iarg+1]);
|
arg[iarg+1], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"ave") == 0) {
|
} else if (strcmp(arg[iarg],"ave") == 0) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "respa.h"
|
#include "respa.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -76,11 +77,9 @@ void FixEnforce2D::init()
|
||||||
if (modify->fix[i]->enforce2d_flag) {
|
if (modify->fix[i]->enforce2d_flag) {
|
||||||
if (myindex < 0)
|
if (myindex < 0)
|
||||||
flist[nfixlist++] = modify->fix[i];
|
flist[nfixlist++] = modify->fix[i];
|
||||||
else {
|
else
|
||||||
char msg[256];
|
error->all(FLERR,fmt::format("Fix enforce2d must be defined after fix {}",
|
||||||
snprintf(msg,256,"Fix enforce2d must be defined after fix %s",modify->fix[i]->style);
|
modify->fix[i]->style));
|
||||||
error->all(FLERR,msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (modify->fix[i] == this) myindex = i;
|
if (modify->fix[i] == this) myindex = i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -65,11 +67,9 @@ FixPrint::FixPrint(LAMMPS *lmp, int narg, char **arg) :
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
if (strcmp(arg[iarg],"file") == 0) fp = fopen(arg[iarg+1],"w");
|
if (strcmp(arg[iarg],"file") == 0) fp = fopen(arg[iarg+1],"w");
|
||||||
else fp = fopen(arg[iarg+1],"a");
|
else fp = fopen(arg[iarg+1],"a");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open fix print file {}: {}",
|
||||||
snprintf(str,128,"Cannot open fix print file %s",arg[iarg+1]);
|
arg[iarg+1], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"screen") == 0) {
|
} else if (strcmp(arg[iarg],"screen") == 0) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -221,11 +222,8 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf,
|
||||||
int nwords = utils::count_words(buf);
|
int nwords = utils::count_words(buf);
|
||||||
*next = '\n';
|
*next = '\n';
|
||||||
|
|
||||||
if (nwords != nvalue+1) {
|
if (nwords != nvalue+1)
|
||||||
char str[128];
|
error->all(FLERR,fmt::format("Incorrect {} format in data file",keyword));
|
||||||
snprintf(str,128,"Incorrect %s format in data file",keyword);
|
|
||||||
error->all(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
char **values = new char*[nwords];
|
char **values = new char*[nwords];
|
||||||
|
|
||||||
|
@ -239,28 +237,21 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf,
|
||||||
next = strchr(buf,'\n');
|
next = strchr(buf,'\n');
|
||||||
|
|
||||||
values[0] = strtok(buf," \t\n\r\f");
|
values[0] = strtok(buf," \t\n\r\f");
|
||||||
if (values[0] == NULL) {
|
if (values[0] == NULL)
|
||||||
char str[128];
|
error->all(FLERR,fmt::format("Too few lines in {} section of data file",keyword));
|
||||||
snprintf(str,128,"Too few lines in %s section of data file",keyword);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
int format_ok = 1;
|
int format_ok = 1;
|
||||||
for (j = 1; j < nwords; j++) {
|
for (j = 1; j < nwords; j++) {
|
||||||
values[j] = strtok(NULL," \t\n\r\f");
|
values[j] = strtok(NULL," \t\n\r\f");
|
||||||
if (values[j] == NULL) format_ok = 0;
|
if (values[j] == NULL) format_ok = 0;
|
||||||
}
|
}
|
||||||
if (!format_ok) {
|
if (!format_ok)
|
||||||
char str[128];
|
error->all(FLERR,fmt::format("Incorrect {} format in data file",keyword));
|
||||||
snprintf(str,128,"Incorrect %s format in data file",keyword);
|
|
||||||
error->all(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
itag = ATOTAGINT(values[0]) + id_offset;
|
itag = ATOTAGINT(values[0]) + id_offset;
|
||||||
if (itag <= 0 || itag > map_tag_max) {
|
if (itag <= 0 || itag > map_tag_max)
|
||||||
char str[128];
|
error->all(FLERR,fmt::format("Invalid atom ID {} in {} section of "
|
||||||
snprintf(str,128,"Invalid atom ID in %s section of data file",keyword);
|
"data file",itag, keyword));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
// assign words in line to per-atom vectors
|
// assign words in line to per-atom vectors
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "math_const.h"
|
#include "math_const.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -82,8 +83,8 @@ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) :
|
||||||
if (strcmp(arg[iarg],"bond") == 0) {
|
if (strcmp(arg[iarg],"bond") == 0) {
|
||||||
if (iarg+6 > narg) error->all(FLERR,"Illegal fix restrain command");
|
if (iarg+6 > narg) error->all(FLERR,"Illegal fix restrain command");
|
||||||
rstyle[nrestrain] = BOND;
|
rstyle[nrestrain] = BOND;
|
||||||
ids[nrestrain][0] = force->inumeric(FLERR,arg[iarg+1]);
|
ids[nrestrain][0] = force->tnumeric(FLERR,arg[iarg+1]);
|
||||||
ids[nrestrain][1] = force->inumeric(FLERR,arg[iarg+2]);
|
ids[nrestrain][1] = force->tnumeric(FLERR,arg[iarg+2]);
|
||||||
kstart[nrestrain] = force->numeric(FLERR,arg[iarg+3]);
|
kstart[nrestrain] = force->numeric(FLERR,arg[iarg+3]);
|
||||||
kstop[nrestrain] = force->numeric(FLERR,arg[iarg+4]);
|
kstop[nrestrain] = force->numeric(FLERR,arg[iarg+4]);
|
||||||
deqstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]);
|
deqstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]);
|
||||||
|
@ -97,8 +98,8 @@ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) :
|
||||||
} else if (strcmp(arg[iarg],"lbound") == 0) {
|
} else if (strcmp(arg[iarg],"lbound") == 0) {
|
||||||
if (iarg+6 > narg) error->all(FLERR,"Illegal fix restrain command");
|
if (iarg+6 > narg) error->all(FLERR,"Illegal fix restrain command");
|
||||||
rstyle[nrestrain] = LBOUND;
|
rstyle[nrestrain] = LBOUND;
|
||||||
ids[nrestrain][0] = force->inumeric(FLERR,arg[iarg+1]);
|
ids[nrestrain][0] = force->tnumeric(FLERR,arg[iarg+1]);
|
||||||
ids[nrestrain][1] = force->inumeric(FLERR,arg[iarg+2]);
|
ids[nrestrain][1] = force->tnumeric(FLERR,arg[iarg+2]);
|
||||||
kstart[nrestrain] = force->numeric(FLERR,arg[iarg+3]);
|
kstart[nrestrain] = force->numeric(FLERR,arg[iarg+3]);
|
||||||
kstop[nrestrain] = force->numeric(FLERR,arg[iarg+4]);
|
kstop[nrestrain] = force->numeric(FLERR,arg[iarg+4]);
|
||||||
deqstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]);
|
deqstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]);
|
||||||
|
@ -112,9 +113,9 @@ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) :
|
||||||
} else if (strcmp(arg[iarg],"angle") == 0) {
|
} else if (strcmp(arg[iarg],"angle") == 0) {
|
||||||
if (iarg+7 > narg) error->all(FLERR,"Illegal fix restrain command");
|
if (iarg+7 > narg) error->all(FLERR,"Illegal fix restrain command");
|
||||||
rstyle[nrestrain] = ANGLE;
|
rstyle[nrestrain] = ANGLE;
|
||||||
ids[nrestrain][0] = force->inumeric(FLERR,arg[iarg+1]);
|
ids[nrestrain][0] = force->tnumeric(FLERR,arg[iarg+1]);
|
||||||
ids[nrestrain][1] = force->inumeric(FLERR,arg[iarg+2]);
|
ids[nrestrain][1] = force->tnumeric(FLERR,arg[iarg+2]);
|
||||||
ids[nrestrain][2] = force->inumeric(FLERR,arg[iarg+3]);
|
ids[nrestrain][2] = force->tnumeric(FLERR,arg[iarg+3]);
|
||||||
kstart[nrestrain] = force->numeric(FLERR,arg[iarg+4]);
|
kstart[nrestrain] = force->numeric(FLERR,arg[iarg+4]);
|
||||||
kstop[nrestrain] = force->numeric(FLERR,arg[iarg+5]);
|
kstop[nrestrain] = force->numeric(FLERR,arg[iarg+5]);
|
||||||
target[nrestrain] = force->numeric(FLERR,arg[iarg+6]);
|
target[nrestrain] = force->numeric(FLERR,arg[iarg+6]);
|
||||||
|
@ -124,10 +125,10 @@ FixRestrain::FixRestrain(LAMMPS *lmp, int narg, char **arg) :
|
||||||
if (iarg+8 > narg) error->all(FLERR,"Illegal fix restrain command");
|
if (iarg+8 > narg) error->all(FLERR,"Illegal fix restrain command");
|
||||||
rstyle[nrestrain] = DIHEDRAL;
|
rstyle[nrestrain] = DIHEDRAL;
|
||||||
mult[nrestrain] = 1;
|
mult[nrestrain] = 1;
|
||||||
ids[nrestrain][0] = force->inumeric(FLERR,arg[iarg+1]);
|
ids[nrestrain][0] = force->tnumeric(FLERR,arg[iarg+1]);
|
||||||
ids[nrestrain][1] = force->inumeric(FLERR,arg[iarg+2]);
|
ids[nrestrain][1] = force->tnumeric(FLERR,arg[iarg+2]);
|
||||||
ids[nrestrain][2] = force->inumeric(FLERR,arg[iarg+3]);
|
ids[nrestrain][2] = force->tnumeric(FLERR,arg[iarg+3]);
|
||||||
ids[nrestrain][3] = force->inumeric(FLERR,arg[iarg+4]);
|
ids[nrestrain][3] = force->tnumeric(FLERR,arg[iarg+4]);
|
||||||
kstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]);
|
kstart[nrestrain] = force->numeric(FLERR,arg[iarg+5]);
|
||||||
kstop[nrestrain] = force->numeric(FLERR,arg[iarg+6]);
|
kstop[nrestrain] = force->numeric(FLERR,arg[iarg+6]);
|
||||||
target[nrestrain] = force->numeric(FLERR,arg[iarg+7]);
|
target[nrestrain] = force->numeric(FLERR,arg[iarg+7]);
|
||||||
|
@ -271,24 +272,16 @@ void FixRestrain::restrain_bond(int m)
|
||||||
|
|
||||||
if (newton_bond) {
|
if (newton_bond) {
|
||||||
if (i2 == -1 || i2 >= nlocal) return;
|
if (i2 == -1 || i2 >= nlocal) return;
|
||||||
if (i1 == -1) {
|
if (i1 == -1)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Restrain atoms {} {} missing on "
|
||||||
sprintf(str,
|
"proc {} at step {}", ids[m][0],ids[m][1],
|
||||||
"Restrain atoms %d %d missing on proc %d at step " BIGINT_FORMAT,
|
comm->me,update->ntimestep));
|
||||||
ids[m][0],ids[m][1],
|
|
||||||
comm->me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal)) return;
|
if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal)) return;
|
||||||
if (i1 == -1 || i2 == -1) {
|
if (i1 == -1 || i2 == -1)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Restrain atoms {} {} missing on "
|
||||||
sprintf(str,
|
"proc {} at step {}", ids[m][0],ids[m][1],
|
||||||
"Restrain atoms %d %d missing on proc %d at step " BIGINT_FORMAT,
|
comm->me,update->ntimestep));
|
||||||
ids[m][0],ids[m][1],
|
|
||||||
comm->me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delx = x[i1][0] - x[i2][0];
|
delx = x[i1][0] - x[i2][0];
|
||||||
|
@ -352,24 +345,16 @@ void FixRestrain::restrain_lbound(int m)
|
||||||
|
|
||||||
if (newton_bond) {
|
if (newton_bond) {
|
||||||
if (i2 == -1 || i2 >= nlocal) return;
|
if (i2 == -1 || i2 >= nlocal) return;
|
||||||
if (i1 == -1) {
|
if (i1 == -1)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Restrain atoms {} {} missing on "
|
||||||
sprintf(str,
|
"proc {} at step {}",ids[m][0],ids[m][1],
|
||||||
"Restrain atoms %d %d missing on proc %d at step " BIGINT_FORMAT,
|
comm->me,update->ntimestep));
|
||||||
ids[m][0],ids[m][1],
|
|
||||||
comm->me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal)) return;
|
if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal)) return;
|
||||||
if (i1 == -1 || i2 == -1) {
|
if (i1 == -1 || i2 == -1)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Restrain atoms {} {} missing on "
|
||||||
sprintf(str,
|
"proc {} at step {}",ids[m][0],ids[m][1],
|
||||||
"Restrain atoms %d %d missing on proc %d at step " BIGINT_FORMAT,
|
comm->me,update->ntimestep));
|
||||||
ids[m][0],ids[m][1],
|
|
||||||
comm->me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delx = x[i1][0] - x[i2][0];
|
delx = x[i1][0] - x[i2][0];
|
||||||
|
@ -442,27 +427,17 @@ void FixRestrain::restrain_angle(int m)
|
||||||
|
|
||||||
if (newton_bond) {
|
if (newton_bond) {
|
||||||
if (i2 == -1 || i2 >= nlocal) return;
|
if (i2 == -1 || i2 >= nlocal) return;
|
||||||
if (i1 == -1 || i3 == -1) {
|
if (i1 == -1 || i3 == -1)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Restrain atoms {} {} {} missing on "
|
||||||
sprintf(str,
|
"proc {} at step {}",ids[m][0],ids[m][1],
|
||||||
"Restrain atoms %d %d %d missing on proc %d at step "
|
ids[m][2],comm->me,update->ntimestep));
|
||||||
BIGINT_FORMAT,
|
|
||||||
ids[m][0],ids[m][1],ids[m][2],
|
|
||||||
comm->me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal) &&
|
if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal) &&
|
||||||
(i3 == -1 || i3 >= nlocal)) return;
|
(i3 == -1 || i3 >= nlocal)) return;
|
||||||
if (i1 == -1 || i2 == -1 || i3 == -1) {
|
if (i1 == -1 || i2 == -1 || i3 == -1)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Restrain atoms {} {} {} missing on "
|
||||||
sprintf(str,
|
"proc {} at step {}",ids[m][0],ids[m][1],
|
||||||
"Restrain atoms %d %d %d missing on proc %d at step "
|
ids[m][2],comm->me,update->ntimestep));
|
||||||
BIGINT_FORMAT,
|
|
||||||
ids[m][0],ids[m][1],ids[m][2],
|
|
||||||
comm->me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1st bond
|
// 1st bond
|
||||||
|
@ -572,27 +547,19 @@ void FixRestrain::restrain_dihedral(int m)
|
||||||
|
|
||||||
if (newton_bond) {
|
if (newton_bond) {
|
||||||
if (i2 == -1 || i2 >= nlocal) return;
|
if (i2 == -1 || i2 >= nlocal) return;
|
||||||
if (i1 == -1 || i3 == -1 || i4 == -1) {
|
if (i1 == -1 || i3 == -1 || i4 == -1)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Restrain atoms {} {} {} {} missing on "
|
||||||
sprintf(str,
|
"proc {} at step {}",ids[m][0],ids[m][1],
|
||||||
"Restrain atoms %d %d %d %d missing on proc %d at step "
|
ids[m][2],ids[m][3],comm->me,
|
||||||
BIGINT_FORMAT,
|
update->ntimestep));
|
||||||
ids[m][0],ids[m][1],ids[m][2],ids[m][3],
|
|
||||||
comm->me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal) &&
|
if ((i1 == -1 || i1 >= nlocal) && (i2 == -1 || i2 >= nlocal) &&
|
||||||
(i3 == -1 || i3 >= nlocal) && (i4 == -1 || i3 >= nlocal)) return;
|
(i3 == -1 || i3 >= nlocal) && (i4 == -1 || i3 >= nlocal)) return;
|
||||||
if (i1 == -1 || i2 == -1 || i3 == -1 || i4 == -1) {
|
if (i1 == -1 || i2 == -1 || i3 == -1 || i4 == -1)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Restrain atoms {} {} {} {} missing on "
|
||||||
sprintf(str,
|
"proc {} at step {}",ids[m][0],ids[m][1],
|
||||||
"Restrain atoms %d %d %d %d missing on proc %d at step "
|
ids[m][2],ids[m][3],comm->me,
|
||||||
BIGINT_FORMAT,
|
update->ntimestep));
|
||||||
ids[m][0],ids[m][1],ids[m][2],ids[m][3],
|
|
||||||
comm->me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1st bond
|
// 1st bond
|
||||||
|
@ -648,21 +615,18 @@ void FixRestrain::restrain_dihedral(int m)
|
||||||
int me;
|
int me;
|
||||||
MPI_Comm_rank(world,&me);
|
MPI_Comm_rank(world,&me);
|
||||||
if (screen) {
|
if (screen) {
|
||||||
char str[128];
|
std::string str = fmt::format("Restrain problem: {} {} {} {} {} {}",
|
||||||
sprintf(str,"Restrain problem: %d " BIGINT_FORMAT " "
|
me,update->ntimestep,atom->tag[i1],
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " "
|
atom->tag[i2],atom->tag[i3],atom->tag[i4]);
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT,
|
|
||||||
me,update->ntimestep,
|
|
||||||
atom->tag[i1],atom->tag[i2],atom->tag[i3],atom->tag[i4]);
|
|
||||||
error->warning(FLERR,str);
|
error->warning(FLERR,str);
|
||||||
fprintf(screen," 1st atom: %d %g %g %g\n",
|
fmt::print(screen," 1st atom: {} {} {} {}\n"
|
||||||
me,x[i1][0],x[i1][1],x[i1][2]);
|
" 2nd atom: {} {} {} {}\n"
|
||||||
fprintf(screen," 2nd atom: %d %g %g %g\n",
|
" 3rd atom: {} {} {} {}\n"
|
||||||
me,x[i2][0],x[i2][1],x[i2][2]);
|
" 4th atom: {} {} {} {}\n",
|
||||||
fprintf(screen," 3rd atom: %d %g %g %g\n",
|
comm->me,x[i1][0],x[i1][1],x[i1][2],
|
||||||
me,x[i3][0],x[i3][1],x[i3][2]);
|
comm->me,x[i2][0],x[i2][1],x[i2][2],
|
||||||
fprintf(screen," 4th atom: %d %g %g %g\n",
|
comm->me,x[i3][0],x[i3][1],x[i3][2],
|
||||||
me,x[i4][0],x[i4][1],x[i4][2]);
|
comm->me,x[i4][0],x[i4][1],x[i4][2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class FixRestrain : public Fix {
|
||||||
int nrestrain,maxrestrain;
|
int nrestrain,maxrestrain;
|
||||||
int *rstyle;
|
int *rstyle;
|
||||||
int *mult;
|
int *mult;
|
||||||
int **ids;
|
tagint **ids;
|
||||||
double *kstart,*kstop,*deqstart,*deqstop,*target;
|
double *kstart,*kstop,*deqstart,*deqstop,*target;
|
||||||
double *cos_target,*sin_target;
|
double *cos_target,*sin_target;
|
||||||
double energy,energy_all;
|
double energy,energy_all;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -73,11 +74,9 @@ nfileevery(0), fp(NULL), xf(NULL), xold(NULL)
|
||||||
if (narg != 7) error->all(FLERR,"Illegal fix tmd command");
|
if (narg != 7) error->all(FLERR,"Illegal fix tmd command");
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(arg[6],"w");
|
fp = fopen(arg[6],"w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open fix tmd file {}: {}",
|
||||||
snprintf(str,128,"Cannot open fix tmd file %s",arg[6]);
|
arg[6], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
fprintf(fp,"%s %s\n","# Step rho_target rho_old gamma_back",
|
fprintf(fp,"%s %s\n","# Step rho_target rho_old gamma_back",
|
||||||
"gamma_forward lambda work_lambda work_analytical");
|
"gamma_forward lambda work_lambda work_analytical");
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,12 +185,9 @@ void Force::init()
|
||||||
|
|
||||||
// check if pair style must be specified after restart
|
// check if pair style must be specified after restart
|
||||||
if (pair_restart) {
|
if (pair_restart) {
|
||||||
if (!pair) {
|
if (!pair)
|
||||||
char msg[128];
|
error->all(FLERR,fmt::format("Must re-specify non-restarted pair style "
|
||||||
snprintf(msg,128,"Must re-specify non-restarted pair style (%s) "
|
"({}) after read_restart", pair_restart));
|
||||||
"after read_restart", pair_restart);
|
|
||||||
error->all(FLERR,msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kspace) kspace->init(); // kspace must come before pair
|
if (kspace) kspace->init(); // kspace must come before pair
|
||||||
|
@ -282,7 +279,7 @@ Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag)
|
||||||
return pair_creator(lmp);
|
return pair_creator(lmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
error->all(FLERR,utils::check_packages_for_style("pair",style,lmp).c_str());
|
error->all(FLERR,utils::check_packages_for_style("pair",style,lmp));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -393,7 +390,7 @@ Bond *Force::new_bond(const std::string &style, int trysuffix, int &sflag)
|
||||||
return bond_creator(lmp);
|
return bond_creator(lmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
error->all(FLERR,utils::check_packages_for_style("bond",style,lmp).c_str());
|
error->all(FLERR,utils::check_packages_for_style("bond",style,lmp));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -470,7 +467,7 @@ Angle *Force::new_angle(const std::string &style, int trysuffix, int &sflag)
|
||||||
return angle_creator(lmp);
|
return angle_creator(lmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
error->all(FLERR,utils::check_packages_for_style("angle",style,lmp).c_str());
|
error->all(FLERR,utils::check_packages_for_style("angle",style,lmp));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -547,7 +544,7 @@ Dihedral *Force::new_dihedral(const std::string &style, int trysuffix, int &sfla
|
||||||
return dihedral_creator(lmp);
|
return dihedral_creator(lmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
error->all(FLERR,utils::check_packages_for_style("dihedral",style,lmp).c_str());
|
error->all(FLERR,utils::check_packages_for_style("dihedral",style,lmp));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -624,7 +621,7 @@ Improper *Force::new_improper(const std::string &style, int trysuffix, int &sfla
|
||||||
return improper_creator(lmp);
|
return improper_creator(lmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
error->all(FLERR,utils::check_packages_for_style("improper",style,lmp).c_str());
|
error->all(FLERR,utils::check_packages_for_style("improper",style,lmp));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -705,7 +702,7 @@ KSpace *Force::new_kspace(const std::string &style, int trysuffix, int &sflag)
|
||||||
return kspace_creator(lmp);
|
return kspace_creator(lmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
error->all(FLERR,utils::check_packages_for_style("kspace",style,lmp).c_str());
|
error->all(FLERR,utils::check_packages_for_style("kspace",style,lmp));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -929,9 +926,8 @@ double Force::numeric(const char *file, int line, char *str)
|
||||||
if (isdigit(str[i])) continue;
|
if (isdigit(str[i])) continue;
|
||||||
if (str[i] == '-' || str[i] == '+' || str[i] == '.') continue;
|
if (str[i] == '-' || str[i] == '+' || str[i] == '.') continue;
|
||||||
if (str[i] == 'e' || str[i] == 'E') continue;
|
if (str[i] == 'e' || str[i] == 'E') continue;
|
||||||
std::string msg = fmt::format("Expected floating point parameter "
|
error->all(file,line,fmt::format("Expected floating point parameter "
|
||||||
"instead of '{}' in input script or data file",str);
|
"instead of '{}' in input script or data file",str));
|
||||||
error->all(file,line,msg.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return atof(str);
|
return atof(str);
|
||||||
|
@ -954,9 +950,8 @@ int Force::inumeric(const char *file, int line, char *str)
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
||||||
std::string msg = fmt::format("Expected integer parameter instead "
|
error->all(file,line,fmt::format("Expected integer parameter instead "
|
||||||
"of '{}' in input script or data file",str);
|
"of '{}' in input script or data file",str));
|
||||||
error->all(file,line,msg.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return atoi(str);
|
return atoi(str);
|
||||||
|
@ -979,9 +974,8 @@ bigint Force::bnumeric(const char *file, int line, char *str)
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
||||||
std::string msg = fmt::format("Expected integer parameter instead "
|
error->all(file,line,fmt::format("Expected integer parameter instead "
|
||||||
"of '{}' in input script or data file",str);
|
"of '{}' in input script or data file",str));
|
||||||
error->all(file,line,msg.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ATOBIGINT(str);
|
return ATOBIGINT(str);
|
||||||
|
@ -1004,9 +998,8 @@ tagint Force::tnumeric(const char *file, int line, char *str)
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
if (isdigit(str[i]) || str[i] == '-' || str[i] == '+') continue;
|
||||||
std::string msg = fmt::format("Expected integer parameter instead "
|
error->all(file,line,fmt::format("Expected integer parameter instead "
|
||||||
"of '{}' in input script or data file",str);
|
"of '{}' in input script or data file",str));
|
||||||
error->all(file,line,msg.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ATOTAGINT(str);
|
return ATOTAGINT(str);
|
||||||
|
|
|
@ -251,11 +251,10 @@ void Input::file(const char *filename)
|
||||||
error->one(FLERR,"Too many nested levels of input scripts");
|
error->one(FLERR,"Too many nested levels of input scripts");
|
||||||
|
|
||||||
infile = fopen(filename,"r");
|
infile = fopen(filename,"r");
|
||||||
if (infile == NULL) {
|
if (infile == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||||
snprintf(str,128,"Cannot open input script %s",filename);
|
filename, utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
infiles[nfile++] = infile;
|
infiles[nfile++] = infile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +301,7 @@ char *Input::one(const std::string &single)
|
||||||
// execute the command and return its name
|
// execute the command and return its name
|
||||||
|
|
||||||
if (execute_command())
|
if (execute_command())
|
||||||
error->all(FLERR,fmt::format("Unknown command: {}",line).c_str());
|
error->all(FLERR,fmt::format("Unknown command: {}",line));
|
||||||
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
@ -545,11 +544,10 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag)
|
||||||
value = variable->retrieve(var);
|
value = variable->retrieve(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == NULL) {
|
if (value == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Substitution for illegal "
|
||||||
snprintf(str,128,"Substitution for illegal variable %s",var);
|
"variable {}",var));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
// check if storage in str2 needs to be expanded
|
// check if storage in str2 needs to be expanded
|
||||||
// re-initialize ptr and ptr2 to the point beyond the variable.
|
// re-initialize ptr and ptr2 to the point beyond the variable.
|
||||||
|
|
||||||
|
@ -1038,11 +1036,10 @@ void Input::include()
|
||||||
error->one(FLERR,"Too many nested levels of input scripts");
|
error->one(FLERR,"Too many nested levels of input scripts");
|
||||||
|
|
||||||
infile = fopen(arg[0],"r");
|
infile = fopen(arg[0],"r");
|
||||||
if (infile == NULL) {
|
if (infile == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||||
snprintf(str,128,"Cannot open input script %s",arg[0]);
|
arg[0], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
infiles[nfile++] = infile;
|
infiles[nfile++] = infile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1073,11 +1070,10 @@ void Input::jump()
|
||||||
else {
|
else {
|
||||||
if (infile && infile != stdin) fclose(infile);
|
if (infile && infile != stdin) fclose(infile);
|
||||||
infile = fopen(arg[0],"r");
|
infile = fopen(arg[0],"r");
|
||||||
if (infile == NULL) {
|
if (infile == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||||
snprintf(str,128,"Cannot open input script %s",arg[0]);
|
arg[0], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
infiles[nfile-1] = infile;
|
infiles[nfile-1] = infile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1118,11 +1114,10 @@ void Input::log()
|
||||||
if (appendflag) logfile = fopen(arg[0],"a");
|
if (appendflag) logfile = fopen(arg[0],"a");
|
||||||
else logfile = fopen(arg[0],"w");
|
else logfile = fopen(arg[0],"w");
|
||||||
|
|
||||||
if (logfile == NULL) {
|
if (logfile == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open logfile {}: {}",
|
||||||
snprintf(str,128,"Cannot open logfile %s",arg[0]);
|
arg[0], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (universe->nworlds == 1) universe->ulogfile = logfile;
|
if (universe->nworlds == 1) universe->ulogfile = logfile;
|
||||||
}
|
}
|
||||||
|
@ -1197,11 +1192,9 @@ void Input::print()
|
||||||
if (fp != NULL) fclose(fp);
|
if (fp != NULL) fclose(fp);
|
||||||
if (strcmp(arg[iarg],"file") == 0) fp = fopen(arg[iarg+1],"w");
|
if (strcmp(arg[iarg],"file") == 0) fp = fopen(arg[iarg+1],"w");
|
||||||
else fp = fopen(arg[iarg+1],"a");
|
else fp = fopen(arg[iarg+1],"a");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open print file {}: {}",
|
||||||
snprintf(str,128,"Cannot open print file %s",arg[iarg+1]);
|
arg[iarg+1], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"screen") == 0) {
|
} else if (strcmp(arg[iarg],"screen") == 0) {
|
||||||
|
@ -1810,18 +1803,15 @@ void Input::pair_style()
|
||||||
{
|
{
|
||||||
if (narg < 1) error->all(FLERR,"Illegal pair_style command");
|
if (narg < 1) error->all(FLERR,"Illegal pair_style command");
|
||||||
if (force->pair) {
|
if (force->pair) {
|
||||||
|
std::string style = arg[0];
|
||||||
int match = 0;
|
int match = 0;
|
||||||
if (strcmp(arg[0],force->pair_style) == 0) match = 1;
|
if (style == force->pair_style) match = 1;
|
||||||
if (!match && lmp->suffix_enable) {
|
if (!match && lmp->suffix_enable) {
|
||||||
char estyle[256];
|
if (lmp->suffix)
|
||||||
if (lmp->suffix) {
|
if (style + "/" + lmp->suffix == force->pair_style) match = 1;
|
||||||
snprintf(estyle,256,"%s/%s",arg[0],lmp->suffix);
|
|
||||||
if (strcmp(estyle,force->pair_style) == 0) match = 1;
|
if (lmp->suffix2)
|
||||||
}
|
if (style + "/" + lmp->suffix2 == force->pair_style) match = 1;
|
||||||
if (lmp->suffix2) {
|
|
||||||
snprintf(estyle,256,"%s/%s",arg[0],lmp->suffix2);
|
|
||||||
if (strcmp(estyle,force->pair_style) == 0) match = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (match) {
|
if (match) {
|
||||||
force->pair->settings(narg-1,&arg[1]);
|
force->pair->settings(narg-1,&arg[1]);
|
||||||
|
|
|
@ -400,20 +400,25 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
|
||||||
else {
|
else {
|
||||||
universe->uscreen = fopen(arg[screenflag],"w");
|
universe->uscreen = fopen(arg[screenflag],"w");
|
||||||
if (universe->uscreen == NULL)
|
if (universe->uscreen == NULL)
|
||||||
error->universe_one(FLERR,"Cannot open universe screen file");
|
error->universe_one(FLERR,fmt::format("Cannot open universe screen "
|
||||||
|
"file {}: {}",arg[screenflag],
|
||||||
|
utils::getsyserror()));
|
||||||
}
|
}
|
||||||
if (logflag == 0) {
|
if (logflag == 0) {
|
||||||
if (helpflag == 0) {
|
if (helpflag == 0) {
|
||||||
universe->ulogfile = fopen("log.lammps","w");
|
universe->ulogfile = fopen("log.lammps","w");
|
||||||
if (universe->ulogfile == NULL)
|
if (universe->ulogfile == NULL)
|
||||||
error->universe_warn(FLERR,"Cannot open log.lammps for writing");
|
error->universe_warn(FLERR,"Cannot open log.lammps for writing: "
|
||||||
|
+ utils::getsyserror());
|
||||||
}
|
}
|
||||||
} else if (strcmp(arg[logflag],"none") == 0)
|
} else if (strcmp(arg[logflag],"none") == 0)
|
||||||
universe->ulogfile = NULL;
|
universe->ulogfile = NULL;
|
||||||
else {
|
else {
|
||||||
universe->ulogfile = fopen(arg[logflag],"w");
|
universe->ulogfile = fopen(arg[logflag],"w");
|
||||||
if (universe->ulogfile == NULL)
|
if (universe->ulogfile == NULL)
|
||||||
error->universe_one(FLERR,"Cannot open universe log file");
|
error->universe_one(FLERR,fmt::format("Cannot open universe log "
|
||||||
|
"file {}: {}",arg[logflag],
|
||||||
|
utils::getsyserror()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,11 +441,9 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
|
||||||
if (universe->me == 0) {
|
if (universe->me == 0) {
|
||||||
if (inflag == 0) infile = stdin;
|
if (inflag == 0) infile = stdin;
|
||||||
else infile = fopen(arg[inflag],"r");
|
else infile = fopen(arg[inflag],"r");
|
||||||
if (infile == NULL) {
|
if (infile == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||||
snprintf(str,128,"Cannot open input script %s",arg[inflag]);
|
arg[inflag], utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((universe->me == 0) && !helpflag)
|
if ((universe->me == 0) && !helpflag)
|
||||||
|
@ -463,47 +466,58 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
|
||||||
if (screenflag == 0) {
|
if (screenflag == 0) {
|
||||||
str = fmt::format("screen.{}",universe->iworld);
|
str = fmt::format("screen.{}",universe->iworld);
|
||||||
screen = fopen(str.c_str(),"w");
|
screen = fopen(str.c_str(),"w");
|
||||||
if (screen == NULL) error->one(FLERR,"Cannot open screen file");
|
if (screen == NULL)
|
||||||
|
error->one(FLERR,fmt::format("Cannot open screen file {}: {}",
|
||||||
|
str,utils::getsyserror()));
|
||||||
} else if (strcmp(arg[screenflag],"none") == 0) {
|
} else if (strcmp(arg[screenflag],"none") == 0) {
|
||||||
screen = NULL;
|
screen = NULL;
|
||||||
} else {
|
} else {
|
||||||
str = fmt::format("{}.{}",arg[screenflag],universe->iworld);
|
str = fmt::format("{}.{}",arg[screenflag],universe->iworld);
|
||||||
screen = fopen(str.c_str(),"w");
|
screen = fopen(str.c_str(),"w");
|
||||||
if (screen == NULL) error->one(FLERR,"Cannot open screen file");
|
if (screen == NULL)
|
||||||
|
error->one(FLERR,fmt::format("Cannot open screen file {}: {}",
|
||||||
|
arg[screenflag],utils::getsyserror()));
|
||||||
}
|
}
|
||||||
} else if (strcmp(arg[partscreenflag],"none") == 0) {
|
} else if (strcmp(arg[partscreenflag],"none") == 0) {
|
||||||
screen = NULL;
|
screen = NULL;
|
||||||
} else {
|
} else {
|
||||||
str = fmt::format("{}.{}",arg[partscreenflag],universe->iworld);
|
str = fmt::format("{}.{}",arg[partscreenflag],universe->iworld);
|
||||||
screen = fopen(str.c_str(),"w");
|
screen = fopen(str.c_str(),"w");
|
||||||
if (screen == NULL) error->one(FLERR,"Cannot open screen file");
|
if (screen == NULL)
|
||||||
|
error->one(FLERR,fmt::format("Cannot open screen file {}: {}",
|
||||||
|
str,utils::getsyserror()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (partlogflag == 0) {
|
if (partlogflag == 0) {
|
||||||
if (logflag == 0) {
|
if (logflag == 0) {
|
||||||
str = fmt::format("log.lammps.{}",universe->iworld);
|
str = fmt::format("log.lammps.{}",universe->iworld);
|
||||||
logfile = fopen(str.c_str(),"w");
|
logfile = fopen(str.c_str(),"w");
|
||||||
if (logfile == NULL) error->one(FLERR,"Cannot open logfile");
|
if (logfile == NULL)
|
||||||
|
error->one(FLERR,fmt::format("Cannot open logfile {}: {}",
|
||||||
|
str, utils::getsyserror()));
|
||||||
} else if (strcmp(arg[logflag],"none") == 0) {
|
} else if (strcmp(arg[logflag],"none") == 0) {
|
||||||
logfile = NULL;
|
logfile = NULL;
|
||||||
} else {
|
} else {
|
||||||
str = fmt::format("{}.{}",arg[logflag],universe->iworld);
|
str = fmt::format("{}.{}",arg[logflag],universe->iworld);
|
||||||
logfile = fopen(str.c_str(),"w");
|
logfile = fopen(str.c_str(),"w");
|
||||||
if (logfile == NULL) error->one(FLERR,"Cannot open logfile");
|
if (logfile == NULL)
|
||||||
|
error->one(FLERR,fmt::format("Cannot open logfile {}: {}",
|
||||||
|
str, utils::getsyserror()));
|
||||||
}
|
}
|
||||||
} else if (strcmp(arg[partlogflag],"none") == 0) {
|
} else if (strcmp(arg[partlogflag],"none") == 0) {
|
||||||
logfile = NULL;
|
logfile = NULL;
|
||||||
} else {
|
} else {
|
||||||
str = fmt::format("{}.{}",arg[partlogflag],universe->iworld);
|
str = fmt::format("{}.{}",arg[partlogflag],universe->iworld);
|
||||||
logfile = fopen(str.c_str(),"w");
|
logfile = fopen(str.c_str(),"w");
|
||||||
if (logfile == NULL) error->one(FLERR,"Cannot open logfile");
|
if (logfile == NULL)
|
||||||
|
error->one(FLERR,fmt::format("Cannot open logfile {}: {}",
|
||||||
|
str, utils::getsyserror()));
|
||||||
}
|
}
|
||||||
|
|
||||||
infile = fopen(arg[inflag],"r");
|
infile = fopen(arg[inflag],"r");
|
||||||
if (infile == NULL) {
|
if (infile == NULL)
|
||||||
str = fmt::format("Cannot open input script {}",arg[inflag]);
|
error->one(FLERR,fmt::format("Cannot open input script {}: {}",
|
||||||
error->one(FLERR,str.c_str());
|
arg[inflag], utils::getsyserror()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// screen and logfile messages for universe and world
|
// screen and logfile messages for universe and world
|
||||||
|
@ -614,13 +628,13 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) :
|
||||||
if (restart2data || restart2dump) {
|
if (restart2data || restart2dump) {
|
||||||
std::string cmd = fmt::format("read_restart {}",restartfile);
|
std::string cmd = fmt::format("read_restart {}",restartfile);
|
||||||
if (restartremap) cmd += " remap\n";
|
if (restartremap) cmd += " remap\n";
|
||||||
input->one(cmd.c_str());
|
input->one(cmd);
|
||||||
if (restart2data) cmd = "write_data ";
|
if (restart2data) cmd = "write_data ";
|
||||||
else cmd = "write_dump";
|
else cmd = "write_dump";
|
||||||
for (iarg = wfirst; iarg < wlast; iarg++)
|
for (iarg = wfirst; iarg < wlast; iarg++)
|
||||||
cmd += fmt::format(" {}", arg[iarg]);
|
cmd += fmt::format(" {}", arg[iarg]);
|
||||||
if (restart2data) cmd += " noinit";
|
if (restart2data) cmd += " noinit";
|
||||||
input->one(cmd.c_str());
|
input->one(cmd);
|
||||||
error->done(0);
|
error->done(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
#include "neigh_list.h"
|
#include "neigh_list.h"
|
||||||
#include "neigh_request.h"
|
#include "neigh_request.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
#if defined(LAMMPS_EXCEPTIONS)
|
#if defined(LAMMPS_EXCEPTIONS)
|
||||||
#include "exceptions.h"
|
#include "exceptions.h"
|
||||||
|
@ -78,12 +79,12 @@ using namespace LAMMPS_NS;
|
||||||
MPI_Comm_size(ae.universe, &nprocs ); \
|
MPI_Comm_size(ae.universe, &nprocs ); \
|
||||||
\
|
\
|
||||||
if (nprocs > 1) { \
|
if (nprocs > 1) { \
|
||||||
error->set_last_error(ae.message.c_str(), ERROR_ABORT); \
|
error->set_last_error(ae.message, ERROR_ABORT); \
|
||||||
} else { \
|
} else { \
|
||||||
error->set_last_error(ae.message.c_str(), ERROR_NORMAL); \
|
error->set_last_error(ae.message, ERROR_NORMAL); \
|
||||||
} \
|
} \
|
||||||
} catch(LAMMPSException & e) { \
|
} catch(LAMMPSException & e) { \
|
||||||
error->set_last_error(e.message.c_str(), ERROR_NORMAL); \
|
error->set_last_error(e.message, ERROR_NORMAL); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define BEGIN_CAPTURE
|
#define BEGIN_CAPTURE
|
||||||
|
@ -1582,14 +1583,11 @@ void lammps_create_atoms(void *ptr, int n, tagint *id, int *type,
|
||||||
|
|
||||||
// warn if new natoms is not correct
|
// warn if new natoms is not correct
|
||||||
|
|
||||||
if (lmp->atom->natoms != natoms_prev + n) {
|
if ((lmp->atom->natoms != natoms_prev + n) && (lmp->comm->me == 0))
|
||||||
char str[128];
|
lmp->error->warning(FLERR,fmt::format("Library warning in "
|
||||||
snprintf(str, 128, "Library warning in lammps_create_atoms, "
|
"lammps_create_atoms: "
|
||||||
"invalid total atoms " BIGINT_FORMAT " " BIGINT_FORMAT,
|
"invalid total atoms {} vs. {}",
|
||||||
lmp->atom->natoms,natoms_prev+n);
|
lmp->atom->natoms,natoms_prev+n));
|
||||||
if (lmp->comm->me == 0)
|
|
||||||
lmp->error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
END_CAPTURE
|
END_CAPTURE
|
||||||
}
|
}
|
||||||
|
@ -1607,19 +1605,13 @@ void lammps_set_fix_external_callback(void *ptr, char *id, FixExternalFnPtr call
|
||||||
BEGIN_CAPTURE
|
BEGIN_CAPTURE
|
||||||
{
|
{
|
||||||
int ifix = lmp->modify->find_fix(id);
|
int ifix = lmp->modify->find_fix(id);
|
||||||
if (ifix < 0) {
|
if (ifix < 0)
|
||||||
char str[128];
|
lmp->error->all(FLERR,fmt::format("Can not find fix with ID '{}'!", id));
|
||||||
snprintf(str, 128, "Can not find fix with ID '%s'!", id);
|
|
||||||
lmp->error->all(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
Fix *fix = lmp->modify->fix[ifix];
|
Fix *fix = lmp->modify->fix[ifix];
|
||||||
|
|
||||||
if (strcmp("external",fix->style) != 0){
|
if (strcmp("external",fix->style) != 0)
|
||||||
char str[128];
|
lmp->error->all(FLERR,fmt::format("Fix '{}' is not of style external!", id));
|
||||||
snprintf(str, 128, "Fix '%s' is not of style external!", id);
|
|
||||||
lmp->error->all(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
FixExternal * fext = (FixExternal*) fix;
|
FixExternal * fext = (FixExternal*) fix;
|
||||||
fext->set_callback(callback, caller);
|
fext->set_callback(callback, caller);
|
||||||
|
@ -1716,7 +1708,7 @@ int lammps_config_has_exceptions() {
|
||||||
int lammps_has_error(void *ptr) {
|
int lammps_has_error(void *ptr) {
|
||||||
LAMMPS *lmp = (LAMMPS *)ptr;
|
LAMMPS *lmp = (LAMMPS *)ptr;
|
||||||
Error *error = lmp->error;
|
Error *error = lmp->error;
|
||||||
return error->get_last_error() ? 1 : 0;
|
return (error->get_last_error() != "") ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
@ -1730,9 +1722,9 @@ int lammps_get_last_error_message(void *ptr, char * buffer, int buffer_size) {
|
||||||
LAMMPS *lmp = (LAMMPS *)ptr;
|
LAMMPS *lmp = (LAMMPS *)ptr;
|
||||||
Error *error = lmp->error;
|
Error *error = lmp->error;
|
||||||
|
|
||||||
if(error->get_last_error()) {
|
if(error->get_last_error() != "") {
|
||||||
int error_type = error->get_last_error_type();
|
int error_type = error->get_last_error_type();
|
||||||
strncpy(buffer, error->get_last_error(), buffer_size-1);
|
strncpy(buffer, error->get_last_error().c_str(), buffer_size-1);
|
||||||
error->set_last_error(NULL, ERROR_NONE);
|
error->set_last_error(NULL, ERROR_NONE);
|
||||||
return error_type;
|
return error_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
#if defined(LMP_USER_INTEL) && defined(__INTEL_COMPILER)
|
#if defined(LMP_USER_INTEL) && defined(__INTEL_COMPILER)
|
||||||
#ifndef LMP_INTEL_NO_TBB
|
#ifndef LMP_INTEL_NO_TBB
|
||||||
|
@ -56,12 +57,9 @@ void *Memory::smalloc(bigint nbytes, const char *name)
|
||||||
#else
|
#else
|
||||||
void *ptr = malloc(nbytes);
|
void *ptr = malloc(nbytes);
|
||||||
#endif
|
#endif
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Failed to allocate {} bytes for array {}",
|
||||||
sprintf(str,"Failed to allocate " BIGINT_FORMAT " bytes for array %s",
|
nbytes,name));
|
||||||
nbytes,name);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,12 +90,9 @@ void *Memory::srealloc(void *ptr, bigint nbytes, const char *name)
|
||||||
#else
|
#else
|
||||||
ptr = realloc(ptr,nbytes);
|
ptr = realloc(ptr,nbytes);
|
||||||
#endif
|
#endif
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Failed to reallocate {} bytes for array {}",
|
||||||
sprintf(str,"Failed to reallocate " BIGINT_FORMAT " bytes for array %s",
|
nbytes,name));
|
||||||
nbytes,name);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +116,6 @@ void Memory::sfree(void *ptr)
|
||||||
|
|
||||||
void Memory::fail(const char *name)
|
void Memory::fail(const char *name)
|
||||||
{
|
{
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot create/grow a vector/array of "
|
||||||
snprintf(str,128,
|
"pointers for {}",name));
|
||||||
"Cannot create/grow a vector/array of pointers for %s",name);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
|
@ -245,21 +246,15 @@ void Modify::init()
|
||||||
// error if any fix or compute is using a dynamic group when not allowed
|
// error if any fix or compute is using a dynamic group when not allowed
|
||||||
|
|
||||||
for (i = 0; i < nfix; i++)
|
for (i = 0; i < nfix; i++)
|
||||||
if (!fix[i]->dynamic_group_allow && group->dynamic[fix[i]->igroup]) {
|
if (!fix[i]->dynamic_group_allow && group->dynamic[fix[i]->igroup])
|
||||||
char str[128];
|
error->all(FLERR,fmt::format("Fix {} does not allow use with a "
|
||||||
snprintf(str,128,
|
"dynamic group",fix[i]->id));
|
||||||
"Fix %s does not allow use of dynamic group",fix[i]->id);
|
|
||||||
error->all(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ncompute; i++)
|
for (i = 0; i < ncompute; i++)
|
||||||
if (!compute[i]->dynamic_group_allow &&
|
if (!compute[i]->dynamic_group_allow &&
|
||||||
group->dynamic[compute[i]->igroup]) {
|
group->dynamic[compute[i]->igroup])
|
||||||
char str[128];
|
error->all(FLERR,fmt::format("Compute {} does not allow use with a "
|
||||||
snprintf(str,128,"Compute %s does not allow use of dynamic group",
|
"dynamic group",compute[i]->id));
|
||||||
fix[i]->id);
|
|
||||||
error->all(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
// warn if any particle is time integrated more than once
|
// warn if any particle is time integrated more than once
|
||||||
|
|
||||||
|
@ -904,7 +899,7 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fix[ifix] == NULL)
|
if (fix[ifix] == NULL)
|
||||||
error->all(FLERR,utils::check_packages_for_style("fix",arg[2],lmp).c_str());
|
error->all(FLERR,utils::check_packages_for_style("fix",arg[2],lmp));
|
||||||
|
|
||||||
// check if Fix is in restart_global list
|
// check if Fix is in restart_global list
|
||||||
// if yes, pass state info to the Fix so it can reset itself
|
// if yes, pass state info to the Fix so it can reset itself
|
||||||
|
@ -1243,7 +1238,7 @@ void Modify::add_compute(int narg, char **arg, int trysuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compute[ncompute] == NULL)
|
if (compute[ncompute] == NULL)
|
||||||
error->all(FLERR,utils::check_packages_for_style("compute",arg[2],lmp).c_str());
|
error->all(FLERR,utils::check_packages_for_style("compute",arg[2],lmp));
|
||||||
|
|
||||||
ncompute++;
|
ncompute++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -1721,11 +1722,9 @@ void Molecule::deallocate()
|
||||||
void Molecule::open(char *file)
|
void Molecule::open(char *file)
|
||||||
{
|
{
|
||||||
fp = fopen(file,"r");
|
fp = fopen(file,"r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open molecule file {}: {}",
|
||||||
snprintf(str,128,"Cannot open molecule file %s",file);
|
file, utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "thermo.h"
|
#include "thermo.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -58,15 +59,11 @@ void NTopoAngleAll::build()
|
||||||
atom3 = atom->map(angle_atom3[i][m]);
|
atom3 = atom->map(angle_atom3[i][m]);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1) {
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Angle atoms {} {} {} missing on "
|
||||||
sprintf(str,"Angle atoms "
|
"proc {} at step {}",angle_atom1[i][m],
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT
|
angle_atom2[i][m],angle_atom3[i][m],
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
me,update->ntimestep));
|
||||||
angle_atom1[i][m],angle_atom2[i][m],angle_atom3[i][m],
|
|
||||||
me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -90,10 +87,7 @@ void NTopoAngleAll::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Angle atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Angle atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "thermo.h"
|
#include "thermo.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -59,15 +60,11 @@ void NTopoAnglePartial::build()
|
||||||
atom3 = atom->map(angle_atom3[i][m]);
|
atom3 = atom->map(angle_atom3[i][m]);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1) {
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Angle atoms {} {} {} missing on "
|
||||||
sprintf(str,"Angle atoms "
|
"proc {} at step {}",angle_atom1[i][m],
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT
|
angle_atom2[i][m],angle_atom3[i][m],
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
me,update->ntimestep));
|
||||||
angle_atom1[i][m],angle_atom2[i][m],angle_atom3[i][m],
|
|
||||||
me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -91,10 +88,7 @@ void NTopoAnglePartial::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Angle atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Angle atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "molecule.h"
|
#include "molecule.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -76,16 +77,13 @@ void NTopoAngleTemplate::build()
|
||||||
atom3 = atom->map(angle_atom3[iatom][m]+tagprev);
|
atom3 = atom->map(angle_atom3[iatom][m]+tagprev);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1) {
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Angle atoms {} {} {} missing on "
|
||||||
sprintf(str,"Angle atoms "
|
"proc {} at step {}",
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT
|
angle_atom1[iatom][m]+tagprev,
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
angle_atom2[iatom][m]+tagprev,
|
||||||
angle_atom1[iatom][m]+tagprev,angle_atom2[iatom][m]+tagprev,
|
|
||||||
angle_atom3[iatom][m]+tagprev,
|
angle_atom3[iatom][m]+tagprev,
|
||||||
me,update->ntimestep);
|
me,update->ntimestep));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -110,10 +108,7 @@ void NTopoAngleTemplate::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Angle atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Angle atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "thermo.h"
|
#include "thermo.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -55,13 +56,10 @@ void NTopoBondAll::build()
|
||||||
atom1 = atom->map(bond_atom[i][m]);
|
atom1 = atom->map(bond_atom[i][m]);
|
||||||
if (atom1 == -1) {
|
if (atom1 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Bond atoms {} {} missing on "
|
||||||
sprintf(str,"Bond atoms " TAGINT_FORMAT " " TAGINT_FORMAT
|
"proc {} at step {}",tag[i],
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
bond_atom[i][m],me,update->ntimestep));
|
||||||
tag[i],bond_atom[i][m],me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -82,10 +80,7 @@ void NTopoBondAll::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Bond atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Bond atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "thermo.h"
|
#include "thermo.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -56,13 +57,10 @@ void NTopoBondPartial::build()
|
||||||
atom1 = atom->map(bond_atom[i][m]);
|
atom1 = atom->map(bond_atom[i][m]);
|
||||||
if (atom1 == -1) {
|
if (atom1 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Bond atoms {} {} missing on "
|
||||||
sprintf(str,"Bond atoms " TAGINT_FORMAT " " TAGINT_FORMAT
|
"proc {} at step {}",tag[i],
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
bond_atom[i][m],me,update->ntimestep));
|
||||||
tag[i],bond_atom[i][m],me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -83,10 +81,7 @@ void NTopoBondPartial::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Bond atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Bond atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "molecule.h"
|
#include "molecule.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -72,13 +73,11 @@ void NTopoBondTemplate::build()
|
||||||
atom1 = atom->map(bond_atom[iatom][m]+tagprev);
|
atom1 = atom->map(bond_atom[iatom][m]+tagprev);
|
||||||
if (atom1 == -1) {
|
if (atom1 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Bond atoms {} {} missing on "
|
||||||
sprintf(str,"Bond atoms " TAGINT_FORMAT " " TAGINT_FORMAT
|
"proc {} at step {}",tag[i],
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
bond_atom[iatom][m]+tagprev,
|
||||||
tag[i],bond_atom[iatom][m]+tagprev,me,update->ntimestep);
|
me,update->ntimestep));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -100,10 +99,7 @@ void NTopoBondTemplate::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Bond atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Bond atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "thermo.h"
|
#include "thermo.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -60,17 +61,12 @@ void NTopoDihedralAll::build()
|
||||||
atom4 = atom->map(dihedral_atom4[i][m]);
|
atom4 = atom->map(dihedral_atom4[i][m]);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Dihedral atoms {} {} {} {} missing on "
|
||||||
sprintf(str,"Dihedral atoms "
|
"proc {} at step {}",
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " "
|
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT
|
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
|
||||||
dihedral_atom1[i][m],dihedral_atom2[i][m],
|
dihedral_atom1[i][m],dihedral_atom2[i][m],
|
||||||
dihedral_atom3[i][m],dihedral_atom4[i][m],
|
dihedral_atom3[i][m],dihedral_atom4[i][m],
|
||||||
me,update->ntimestep);
|
me,update->ntimestep));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -97,10 +93,7 @@ void NTopoDihedralAll::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Dihedral atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Dihedral atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "thermo.h"
|
#include "thermo.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -62,17 +63,12 @@ void NTopoDihedralPartial::build()
|
||||||
atom4 = atom->map(dihedral_atom4[i][m]);
|
atom4 = atom->map(dihedral_atom4[i][m]);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Dihedral atoms {} {} {} {} missing on "
|
||||||
sprintf(str,"Dihedral atoms "
|
"proc {} at step {}",
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " "
|
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT
|
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
|
||||||
dihedral_atom1[i][m],dihedral_atom2[i][m],
|
dihedral_atom1[i][m],dihedral_atom2[i][m],
|
||||||
dihedral_atom3[i][m],dihedral_atom4[i][m],
|
dihedral_atom3[i][m],dihedral_atom4[i][m],
|
||||||
me,update->ntimestep);
|
me,update->ntimestep));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -99,10 +95,7 @@ void NTopoDihedralPartial::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Dihedral atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Dihedral atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "molecule.h"
|
#include "molecule.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -78,19 +79,14 @@ void NTopoDihedralTemplate::build()
|
||||||
atom4 = atom->map(dihedral_atom4[iatom][m]+tagprev);
|
atom4 = atom->map(dihedral_atom4[iatom][m]+tagprev);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Dihedral atoms {} {} {} {} missing on "
|
||||||
sprintf(str,"Dihedral atoms "
|
"proc {} at step {}",
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " "
|
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT
|
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
|
||||||
dihedral_atom1[iatom][m]+tagprev,
|
dihedral_atom1[iatom][m]+tagprev,
|
||||||
dihedral_atom2[iatom][m]+tagprev,
|
dihedral_atom2[iatom][m]+tagprev,
|
||||||
dihedral_atom3[iatom][m]+tagprev,
|
dihedral_atom3[iatom][m]+tagprev,
|
||||||
dihedral_atom4[iatom][m]+tagprev,
|
dihedral_atom4[iatom][m]+tagprev,
|
||||||
me,update->ntimestep);
|
me,update->ntimestep));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -118,10 +114,7 @@ void NTopoDihedralTemplate::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Dihedral atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Dihedral atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "thermo.h"
|
#include "thermo.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -60,17 +61,12 @@ void NTopoImproperAll::build()
|
||||||
atom4 = atom->map(improper_atom4[i][m]);
|
atom4 = atom->map(improper_atom4[i][m]);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Improper atoms {} {} {} {} missing on "
|
||||||
sprintf(str,"Improper atoms "
|
"proc {} at step {}",
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " "
|
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT
|
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
|
||||||
improper_atom1[i][m],improper_atom2[i][m],
|
improper_atom1[i][m],improper_atom2[i][m],
|
||||||
improper_atom3[i][m],improper_atom4[i][m],
|
improper_atom3[i][m],improper_atom4[i][m],
|
||||||
me,update->ntimestep);
|
me,update->ntimestep));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -97,10 +93,7 @@ void NTopoImproperAll::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Improper atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Improper atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "thermo.h"
|
#include "thermo.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -62,17 +63,14 @@ void NTopoImproperPartial::build()
|
||||||
atom4 = atom->map(improper_atom4[i][m]);
|
atom4 = atom->map(improper_atom4[i][m]);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Improper atoms {} {} {} {}"
|
||||||
sprintf(str,"Improper atoms "
|
" missing on proc {} at step {}",
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " "
|
improper_atom1[i][m],
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT
|
improper_atom2[i][m],
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
improper_atom3[i][m],
|
||||||
improper_atom1[i][m],improper_atom2[i][m],
|
improper_atom4[i][m],
|
||||||
improper_atom3[i][m],improper_atom4[i][m],
|
me,update->ntimestep));
|
||||||
me,update->ntimestep);
|
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "molecule.h"
|
#include "molecule.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -78,19 +79,14 @@ void NTopoImproperTemplate::build()
|
||||||
atom4 = atom->map(improper_atom4[iatom][m]+tagprev);
|
atom4 = atom->map(improper_atom4[iatom][m]+tagprev);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1) {
|
||||||
nmissing++;
|
nmissing++;
|
||||||
if (lostbond == Thermo::ERROR) {
|
if (lostbond == Thermo::ERROR)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Improper atoms {} {} {} {}"
|
||||||
sprintf(str,"Improper atoms "
|
" missing on proc {} at step {}",
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " "
|
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT
|
|
||||||
" missing on proc %d at step " BIGINT_FORMAT,
|
|
||||||
improper_atom1[iatom][m]+tagprev,
|
improper_atom1[iatom][m]+tagprev,
|
||||||
improper_atom2[iatom][m]+tagprev,
|
improper_atom2[iatom][m]+tagprev,
|
||||||
improper_atom3[iatom][m]+tagprev,
|
improper_atom3[iatom][m]+tagprev,
|
||||||
improper_atom4[iatom][m]+tagprev,
|
improper_atom4[iatom][m]+tagprev,
|
||||||
me,update->ntimestep);
|
me,update->ntimestep));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
atom1 = domain->closest_image(i,atom1);
|
atom1 = domain->closest_image(i,atom1);
|
||||||
|
@ -118,10 +114,7 @@ void NTopoImproperTemplate::build()
|
||||||
|
|
||||||
int all;
|
int all;
|
||||||
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
|
||||||
if (all) {
|
if (all && (me == 0))
|
||||||
char str[128];
|
error->warning(FLERR,fmt::format("Improper atoms missing at step {}",
|
||||||
sprintf(str,
|
update->ntimestep));
|
||||||
"Improper atoms missing at step " BIGINT_FORMAT,update->ntimestep);
|
|
||||||
if (me == 0) error->warning(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -585,7 +585,7 @@ void Output::add_dump(int narg, char **arg)
|
||||||
if (dump_map->find(arg[2]) != dump_map->end()) {
|
if (dump_map->find(arg[2]) != dump_map->end()) {
|
||||||
DumpCreator dump_creator = (*dump_map)[arg[2]];
|
DumpCreator dump_creator = (*dump_map)[arg[2]];
|
||||||
dump[ndump] = dump_creator(lmp, narg, arg);
|
dump[ndump] = dump_creator(lmp, narg, arg);
|
||||||
} else error->all(FLERR,utils::check_packages_for_style("dump",arg[2],lmp).c_str());
|
} else error->all(FLERR,utils::check_packages_for_style("dump",arg[2],lmp));
|
||||||
|
|
||||||
every_dump[ndump] = force->inumeric(FLERR,arg[3]);
|
every_dump[ndump] = force->inumeric(FLERR,arg[3]);
|
||||||
if (every_dump[ndump] <= 0) error->all(FLERR,"Illegal dump command");
|
if (every_dump[ndump] <= 0) error->all(FLERR,"Illegal dump command");
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "math_const.h"
|
#include "math_const.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
|
@ -1639,7 +1641,9 @@ void Pair::write_file(int narg, char **arg)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(arg[6],"a");
|
fp = fopen(arg[6],"a");
|
||||||
if (fp == NULL) error->one(FLERR,"Cannot open pair_write file");
|
if (fp == NULL)
|
||||||
|
error->one(FLERR,fmt::format("Cannot open pair_write file {}: {}",
|
||||||
|
arg[6], utils::getsyserror()));
|
||||||
fprintf(fp,"# Pair potential %s for atom types %d %d: i,r,energy,force\n",
|
fprintf(fp,"# Pair potential %s for atom types %d %d: i,r,energy,force\n",
|
||||||
force->pair_style,itype,jtype);
|
force->pair_style,itype,jtype);
|
||||||
if (style == RLINEAR)
|
if (style == RLINEAR)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
|
@ -249,11 +250,9 @@ void PairCoulStreitz::read_file(char *file)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if (comm->me == 0) {
|
if (comm->me == 0) {
|
||||||
fp = fopen(file,"r");
|
fp = fopen(file,"r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open coul/streitz potential "
|
||||||
snprintf(str,128,"Cannot open coul/streitz potential file %s",file);
|
"file {}",file));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read each line out of file, skipping blank lines or leading '#'
|
// read each line out of file, skipping blank lines or leading '#'
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "potential_file_reader.h"
|
#include "potential_file_reader.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "tokenizer.h"
|
#include "tokenizer.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
@ -36,11 +37,9 @@ PotentialFileReader::PotentialFileReader(LAMMPS *lmp,
|
||||||
|
|
||||||
fp = force->open_potential(filename.c_str());
|
fp = force->open_potential(filename.c_str());
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open {} potential file {}: {}",
|
||||||
snprintf(str, 128, "cannot open %s potential file %s", potential_name.c_str(), filename.c_str());
|
potential_name, filename, utils::getsyserror()));
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PotentialFileReader::~PotentialFileReader() {
|
PotentialFileReader::~PotentialFileReader() {
|
||||||
|
@ -49,12 +48,9 @@ PotentialFileReader::~PotentialFileReader() {
|
||||||
|
|
||||||
void PotentialFileReader::skip_line() {
|
void PotentialFileReader::skip_line() {
|
||||||
char *ptr = fgets(line, MAXLINE, fp);
|
char *ptr = fgets(line, MAXLINE, fp);
|
||||||
if (ptr == nullptr) {
|
if (ptr == nullptr)
|
||||||
// EOF
|
error->one(FLERR,fmt::format("Missing line in {} potential file!",
|
||||||
char str[128];
|
potential_name));
|
||||||
snprintf(str, 128, "Missing line in %s potential file!", potential_name.c_str());
|
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *PotentialFileReader::next_line(int nparams) {
|
char *PotentialFileReader::next_line(int nparams) {
|
||||||
|
@ -83,16 +79,13 @@ char *PotentialFileReader::next_line(int nparams) {
|
||||||
|
|
||||||
if (ptr == nullptr) {
|
if (ptr == nullptr) {
|
||||||
// EOF
|
// EOF
|
||||||
if (nwords > 0 && nwords < nparams) {
|
if (nwords > 0 && nwords < nparams)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Incorrect format in {} potential "
|
||||||
snprintf(str, 128, "Incorrect format in %s potential file! %d/%d parameters", potential_name.c_str(), nwords, nparams);
|
"file! {}/{} parameters",
|
||||||
error->one(FLERR, str);
|
potential_name, nwords, nparams));
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// strip comment
|
// strip comment
|
||||||
if ((ptr = strchr(line, '#'))) *ptr = '\0';
|
if ((ptr = strchr(line, '#'))) *ptr = '\0';
|
||||||
|
|
||||||
|
@ -114,11 +107,9 @@ void PotentialFileReader::next_dvector(int n, double * list) {
|
||||||
|
|
||||||
if (ptr == nullptr) {
|
if (ptr == nullptr) {
|
||||||
// EOF
|
// EOF
|
||||||
if (i < n) {
|
if (i < n)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Incorrect format in {} potential file! "
|
||||||
snprintf(str, 128, "Incorrect format in %s potential file! %d/%d values", potential_name.c_str(), i, n);
|
"{}/{} values", potential_name, i, n));
|
||||||
error->one(FLERR, str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueTokenizer values(line);
|
ValueTokenizer values(line);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "read_data.h"
|
#include "read_data.h"
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "atom_vec.h"
|
#include "atom_vec.h"
|
||||||
|
@ -710,11 +711,8 @@ void ReadData::command(int narg, char **arg)
|
||||||
if (firstpass) impropercoeffs(1);
|
if (firstpass) impropercoeffs(1);
|
||||||
else skip_lines(nimpropertypes);
|
else skip_lines(nimpropertypes);
|
||||||
|
|
||||||
} else {
|
} else error->all(FLERR,fmt::format("Unknown identifier in data file: {}",
|
||||||
char str[128];
|
keyword));
|
||||||
snprintf(str,128,"Unknown identifier in data file: %s",keyword);
|
|
||||||
error->all(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_keyword(0);
|
parse_keyword(0);
|
||||||
}
|
}
|
||||||
|
@ -1940,25 +1938,21 @@ void ReadData::open(char *file)
|
||||||
if (!compressed) fp = fopen(file,"r");
|
if (!compressed) fp = fopen(file,"r");
|
||||||
else {
|
else {
|
||||||
#ifdef LAMMPS_GZIP
|
#ifdef LAMMPS_GZIP
|
||||||
char gunzip[128];
|
std::string gunzip = fmt::format("gzip -c -d {}",file);
|
||||||
snprintf(gunzip,128,"gzip -c -d %s",file);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fp = _popen(gunzip,"rb");
|
fp = _popen(gunzip.c_str(),"rb");
|
||||||
#else
|
#else
|
||||||
fp = popen(gunzip,"r");
|
fp = popen(gunzip.c_str(),"r");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
error->one(FLERR,"Cannot open gzipped file");
|
error->one(FLERR,"Cannot open gzipped file: " + utils::getsyserror());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open file {}: {}",
|
||||||
snprintf(str,128,"Cannot open file %s",file);
|
file, utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
|
@ -252,7 +252,7 @@ void ReadDump::setup_reader(int narg, char **arg)
|
||||||
|
|
||||||
// unrecognized style
|
// unrecognized style
|
||||||
|
|
||||||
else error->all(FLERR,utils::check_packages_for_style("reader",readerstyle,lmp).c_str());
|
else error->all(FLERR,utils::check_packages_for_style("reader",readerstyle,lmp));
|
||||||
|
|
||||||
if (utils::strmatch(readerstyle,"^adios")) {
|
if (utils::strmatch(readerstyle,"^adios")) {
|
||||||
// everyone is a reader with adios
|
// everyone is a reader with adios
|
||||||
|
|
|
@ -113,11 +113,9 @@ void ReadRestart::command(int narg, char **arg)
|
||||||
*ptr = '%';
|
*ptr = '%';
|
||||||
} else hfile = file;
|
} else hfile = file;
|
||||||
fp = fopen(hfile,"rb");
|
fp = fopen(hfile,"rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open restart file {}: {}",
|
||||||
snprintf(str,128,"Cannot open restart file %s",hfile);
|
hfile, utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
if (multiproc) delete [] hfile;
|
if (multiproc) delete [] hfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,12 +280,9 @@ void ReadRestart::command(int narg, char **arg)
|
||||||
sprintf(procfile,"%s%d%s",file,iproc,ptr+1);
|
sprintf(procfile,"%s%d%s",file,iproc,ptr+1);
|
||||||
*ptr = '%';
|
*ptr = '%';
|
||||||
fp = fopen(procfile,"rb");
|
fp = fopen(procfile,"rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open restart file {}: {}",
|
||||||
snprintf(str,128,"Cannot open restart file %s",procfile);
|
procfile, utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
utils::sfread(FLERR,&flag,sizeof(int),1,fp,NULL,error);
|
utils::sfread(FLERR,&flag,sizeof(int),1,fp,NULL,error);
|
||||||
if (flag != PROCSPERFILE)
|
if (flag != PROCSPERFILE)
|
||||||
error->one(FLERR,"Invalid flag in peratom section of restart file");
|
error->one(FLERR,"Invalid flag in peratom section of restart file");
|
||||||
|
@ -354,11 +349,9 @@ void ReadRestart::command(int narg, char **arg)
|
||||||
sprintf(procfile,"%s%d%s",file,icluster,ptr+1);
|
sprintf(procfile,"%s%d%s",file,icluster,ptr+1);
|
||||||
*ptr = '%';
|
*ptr = '%';
|
||||||
fp = fopen(procfile,"rb");
|
fp = fopen(procfile,"rb");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open restart file {}: {}",
|
||||||
snprintf(str,128,"Cannot open restart file %s",procfile);
|
procfile, utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
delete [] procfile;
|
delete [] procfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,12 +711,10 @@ void ReadRestart::header()
|
||||||
|
|
||||||
} else if (flag == NPROCS) {
|
} else if (flag == NPROCS) {
|
||||||
nprocs_file = read_int();
|
nprocs_file = read_int();
|
||||||
if (nprocs_file != comm->nprocs && me == 0) {
|
if (nprocs_file != comm->nprocs && me == 0)
|
||||||
char msg[128];
|
error->warning(FLERR,fmt::format("Restart file used different # of "
|
||||||
snprintf(msg,128,"Restart file used different # of processors: %d vs. %d",
|
"processors: {} vs. {}",nprocs_file,
|
||||||
nprocs_file,comm->nprocs);
|
comm->nprocs));
|
||||||
error->warning(FLERR,msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// don't set procgrid, warn if different
|
// don't set procgrid, warn if different
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -41,25 +43,21 @@ void Reader::open_file(const char *file)
|
||||||
if (!compressed) fp = fopen(file,"r");
|
if (!compressed) fp = fopen(file,"r");
|
||||||
else {
|
else {
|
||||||
#ifdef LAMMPS_GZIP
|
#ifdef LAMMPS_GZIP
|
||||||
char gunzip[1024];
|
std::string gunzip = fmt::format("gzip -c -d {}",file);
|
||||||
snprintf(gunzip,1024,"gzip -c -d %s",file);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fp = _popen(gunzip,"rb");
|
fp = _popen(gunzip.c_str(),"rb");
|
||||||
#else
|
#else
|
||||||
fp = popen(gunzip,"r");
|
fp = popen(gunzip.c_str(),"r");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
error->one(FLERR,"Cannot open gzipped file");
|
error->one(FLERR,"Cannot open gzipped file: " + utils::getsyserror());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open file {}: {}",
|
||||||
snprintf(str,128,"Cannot open file %s",file);
|
file, utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -96,7 +98,10 @@ void Universe::reorder(char *style, char *arg)
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
FILE *fp = fopen(arg,"r");
|
FILE *fp = fopen(arg,"r");
|
||||||
if (fp == NULL) error->universe_one(FLERR,"Cannot open -reorder file");
|
if (fp == NULL)
|
||||||
|
error->universe_one(FLERR,fmt::format("Cannot open -reorder "
|
||||||
|
"file {}: {}",arg,
|
||||||
|
utils::getsyserror()));
|
||||||
|
|
||||||
// skip header = blank and comment lines
|
// skip header = blank and comment lines
|
||||||
|
|
||||||
|
@ -117,7 +122,8 @@ void Universe::reorder(char *style, char *arg)
|
||||||
rv = sscanf(line,"%d %d",&me_orig,&me_new);
|
rv = sscanf(line,"%d %d",&me_orig,&me_new);
|
||||||
if (me_orig < 0 || me_orig >= nprocs ||
|
if (me_orig < 0 || me_orig >= nprocs ||
|
||||||
me_new < 0 || me_new >= nprocs || rv != 2)
|
me_new < 0 || me_new >= nprocs || rv != 2)
|
||||||
error->one(FLERR,"Invalid entry in -reorder file");
|
error->one(FLERR,fmt::format("Invalid entry '{} {}' in -reorder "
|
||||||
|
"file", me_orig, me_new));
|
||||||
uni2orig[me_new] = me_orig;
|
uni2orig[me_new] = me_orig;
|
||||||
|
|
||||||
for (int i = 1; i < nprocs; i++) {
|
for (int i = 1; i < nprocs; i++) {
|
||||||
|
@ -126,7 +132,8 @@ void Universe::reorder(char *style, char *arg)
|
||||||
rv = sscanf(line,"%d %d",&me_orig,&me_new);
|
rv = sscanf(line,"%d %d",&me_orig,&me_new);
|
||||||
if (me_orig < 0 || me_orig >= nprocs ||
|
if (me_orig < 0 || me_orig >= nprocs ||
|
||||||
me_new < 0 || me_new >= nprocs || rv != 2)
|
me_new < 0 || me_new >= nprocs || rv != 2)
|
||||||
error->one(FLERR,"Invalid entry in -reorder file");
|
error->one(FLERR,fmt::format("Invalid entry '{} {}' in -reorder "
|
||||||
|
"file", me_orig, me_new));
|
||||||
uni2orig[me_new] = me_orig;
|
uni2orig[me_new] = me_orig;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -201,11 +208,9 @@ void Universe::add_world(char *str)
|
||||||
|
|
||||||
if (n < 1 || nper < 1) valid = false;
|
if (n < 1 || nper < 1) valid = false;
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid)
|
||||||
char msg[128];
|
error->universe_all(FLERR,fmt::format("Invalid partition string '{}'",
|
||||||
snprintf(msg,128,"Invalid partition string '%s'",str);
|
str));
|
||||||
error->universe_all(FLERR,msg);
|
|
||||||
}
|
|
||||||
} else nper = nprocs;
|
} else nper = nprocs;
|
||||||
|
|
||||||
memory->grow(procs_per_world,nworlds+n,"universe:procs_per_world");
|
memory->grow(procs_per_world,nworlds+n,"universe:procs_per_world");
|
||||||
|
@ -268,8 +273,7 @@ char *date2num(const char *version)
|
||||||
year = atoi(version);
|
year = atoi(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ver = new char[64];
|
char *ver = new char[12];
|
||||||
sprintf(ver,"%04d%02d%02d", year % 10000, month, day % 100);
|
snprintf(ver,12,"%04d%02d%02d", year % 10000, month, day % 100);
|
||||||
|
|
||||||
return ver;
|
return ver;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cerrno>
|
||||||
#include "lammps.h"
|
#include "lammps.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "tokenizer.h"
|
#include "tokenizer.h"
|
||||||
|
@ -99,6 +100,14 @@ void utils::logmesg(LAMMPS *lmp, const std::string &mesg)
|
||||||
if (lmp->logfile) fputs(mesg.c_str(), lmp->logfile);
|
if (lmp->logfile) fputs(mesg.c_str(), lmp->logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* define this here, so we won't have to include the headers
|
||||||
|
everywhere and utils.h will more likely be included anyway. */
|
||||||
|
|
||||||
|
std::string utils::getsyserror()
|
||||||
|
{
|
||||||
|
return std::string(strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief try to detect pathname from FILE pointer. Currently only supported on Linux, otherwise will report "(unknown)".
|
/** \brief try to detect pathname from FILE pointer. Currently only supported on Linux, otherwise will report "(unknown)".
|
||||||
*
|
*
|
||||||
* \param buf storage buffer for pathname. output will be truncated if not large enough
|
* \param buf storage buffer for pathname. output will be truncated if not large enough
|
||||||
|
|
|
@ -43,6 +43,14 @@ namespace LAMMPS_NS {
|
||||||
*/
|
*/
|
||||||
void logmesg(LAMMPS *lmp, const std::string &mesg);
|
void logmesg(LAMMPS *lmp, const std::string &mesg);
|
||||||
|
|
||||||
|
/** \brief return a string representing the current system error status
|
||||||
|
*
|
||||||
|
* This is a wrapper around calling strerror(errno).
|
||||||
|
*
|
||||||
|
* \return error string
|
||||||
|
*/
|
||||||
|
std::string getsyserror();
|
||||||
|
|
||||||
/** \brief safe wrapper around fgets() which aborts on errors
|
/** \brief safe wrapper around fgets() which aborts on errors
|
||||||
* or EOF and prints a suitable error message to help debugging
|
* or EOF and prints a suitable error message to help debugging
|
||||||
*
|
*
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
|
@ -268,7 +269,8 @@ void Variable::set(int narg, char **arg)
|
||||||
if (universe->me == 0) {
|
if (universe->me == 0) {
|
||||||
FILE *fp = fopen("tmp.lammps.variable","w");
|
FILE *fp = fopen("tmp.lammps.variable","w");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
error->one(FLERR,"Cannot open temporary file for world counter.");
|
error->one(FLERR,"Cannot open temporary file for world counter: "
|
||||||
|
+ utils::getsyserror());
|
||||||
fprintf(fp,"%d\n",universe->nworlds);
|
fprintf(fp,"%d\n",universe->nworlds);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
|
@ -531,12 +533,10 @@ void Variable::set(int narg, char **arg)
|
||||||
strcpy(names[nvar],arg[0]);
|
strcpy(names[nvar],arg[0]);
|
||||||
|
|
||||||
for (int i = 0; i < n-1; i++)
|
for (int i = 0; i < n-1; i++)
|
||||||
if (!isalnum(names[nvar][i]) && names[nvar][i] != '_') {
|
if (!isalnum(names[nvar][i]) && names[nvar][i] != '_')
|
||||||
char errmsg[128];
|
error->all(FLERR,fmt::format("Variable name '{}' must have only "
|
||||||
snprintf(errmsg,128,"Variable name '%s' must have only alphanumeric "
|
"alphanumeric characters or underscores",
|
||||||
"characters or underscore",names[nvar]);
|
names[nvar]));
|
||||||
error->all(FLERR,errmsg);
|
|
||||||
}
|
|
||||||
nvar++;
|
nvar++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,11 +589,9 @@ int Variable::next(int narg, char **arg)
|
||||||
|
|
||||||
for (int iarg = 0; iarg < narg; iarg++) {
|
for (int iarg = 0; iarg < narg; iarg++) {
|
||||||
ivar = find(arg[iarg]);
|
ivar = find(arg[iarg]);
|
||||||
if (ivar < 0) {
|
if (ivar < 0)
|
||||||
char errmsg[128];
|
error->all(FLERR,fmt::format("Invalid variable '{}' in next command",
|
||||||
snprintf(errmsg,128,"Invalid variable '%s' in next command",arg[iarg]);
|
arg[iarg]));
|
||||||
error->all(FLERR,errmsg);
|
|
||||||
}
|
|
||||||
if (style[ivar] == ULOOP && style[find(arg[0])] == UNIVERSE) continue;
|
if (style[ivar] == ULOOP && style[find(arg[0])] == UNIVERSE) continue;
|
||||||
else if (style[ivar] == UNIVERSE && style[find(arg[0])] == ULOOP) continue;
|
else if (style[ivar] == UNIVERSE && style[find(arg[0])] == ULOOP) continue;
|
||||||
else if (style[ivar] != style[find(arg[0])])
|
else if (style[ivar] != style[find(arg[0])])
|
||||||
|
@ -918,11 +916,9 @@ char *Variable::retrieve(char *name)
|
||||||
str = data[ivar][1];
|
str = data[ivar][1];
|
||||||
} else if (style[ivar] == PYTHON) {
|
} else if (style[ivar] == PYTHON) {
|
||||||
int ifunc = python->variable_match(data[ivar][0],name,0);
|
int ifunc = python->variable_match(data[ivar][0],name,0);
|
||||||
if (ifunc < 0) {
|
if (ifunc < 0)
|
||||||
char errmsg[128];
|
error->all(FLERR,fmt::format("Python variable '{}' does not match "
|
||||||
snprintf(errmsg,128,"Python variable '%s' does not match Python function",name);
|
"Python function", name));
|
||||||
error->all(FLERR,errmsg);
|
|
||||||
}
|
|
||||||
python->invoke_function(ifunc,data[ivar][1]);
|
python->invoke_function(ifunc,data[ivar][1]);
|
||||||
str = data[ivar][1];
|
str = data[ivar][1];
|
||||||
// if Python func returns a string longer than VALUELENGTH
|
// if Python func returns a string longer than VALUELENGTH
|
||||||
|
@ -1336,7 +1332,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
|
||||||
std::string mesg = "Invalid compute ID '";
|
std::string mesg = "Invalid compute ID '";
|
||||||
mesg += (word+2);
|
mesg += (word+2);
|
||||||
mesg += "' in variable formula";
|
mesg += "' in variable formula";
|
||||||
print_var_error(FLERR,mesg.c_str(),ivar);
|
print_var_error(FLERR,mesg,ivar);
|
||||||
}
|
}
|
||||||
Compute *compute = modify->compute[icompute];
|
Compute *compute = modify->compute[icompute];
|
||||||
|
|
||||||
|
@ -1637,12 +1633,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
|
||||||
if (word[0] == 'F') lowercase = 0;
|
if (word[0] == 'F') lowercase = 0;
|
||||||
|
|
||||||
int ifix = modify->find_fix(word+2);
|
int ifix = modify->find_fix(word+2);
|
||||||
if (ifix < 0) {
|
if (ifix < 0)
|
||||||
std::string mesg = "Invalid fix ID '";
|
print_var_error(FLERR,fmt::format("Invalid fix ID '{}' in variable"
|
||||||
mesg += (word+2);
|
" formula",word+2),ivar);
|
||||||
mesg += "' in variable formula";
|
|
||||||
print_var_error(FLERR,mesg.c_str(),ivar);
|
|
||||||
}
|
|
||||||
Fix *fix = modify->fix[ifix];
|
Fix *fix = modify->fix[ifix];
|
||||||
|
|
||||||
// parse zero or one or two trailing brackets
|
// parse zero or one or two trailing brackets
|
||||||
|
@ -2073,12 +2066,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
|
||||||
argstack,nargstack,ivar));
|
argstack,nargstack,ivar));
|
||||||
else if (special_function(word,contents,tree,treestack,ntreestack,
|
else if (special_function(word,contents,tree,treestack,ntreestack,
|
||||||
argstack,nargstack,ivar));
|
argstack,nargstack,ivar));
|
||||||
else {
|
else print_var_error(FLERR,fmt::format("Invalid math/group/special "
|
||||||
char msg[128];
|
"function '{}()'in variable "
|
||||||
snprintf(msg,128,"Invalid math/group/special function '%s()'"
|
"formula", word),ivar);
|
||||||
"in variable formula", word);
|
|
||||||
print_var_error(FLERR,msg,ivar);
|
|
||||||
}
|
|
||||||
delete [] contents;
|
delete [] contents;
|
||||||
|
|
||||||
// ----------------
|
// ----------------
|
||||||
|
@ -2133,11 +2123,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
|
||||||
"simulation box is defined",ivar);
|
"simulation box is defined",ivar);
|
||||||
|
|
||||||
int flag = output->thermo->evaluate_keyword(word,&value1);
|
int flag = output->thermo->evaluate_keyword(word,&value1);
|
||||||
if (flag) {
|
if (flag)
|
||||||
char msg[128];
|
print_var_error(FLERR,fmt::format("Invalid thermo keyword '{}' in "
|
||||||
snprintf(msg,128,"Invalid thermo keyword '%s' in variable formula",word);
|
"variable formula",word),ivar);
|
||||||
print_var_error(FLERR,msg,ivar);
|
|
||||||
}
|
|
||||||
if (tree) {
|
if (tree) {
|
||||||
Tree *newtree = new Tree();
|
Tree *newtree = new Tree();
|
||||||
newtree->type = VALUE;
|
newtree->type = VALUE;
|
||||||
|
@ -3831,7 +3819,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree,
|
||||||
std::string mesg = "Group ID '";
|
std::string mesg = "Group ID '";
|
||||||
mesg += args[0];
|
mesg += args[0];
|
||||||
mesg += "' in variable formula does not exist";
|
mesg += "' in variable formula does not exist";
|
||||||
print_var_error(FLERR,mesg.c_str(),ivar);
|
print_var_error(FLERR,mesg,ivar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// match word to group function
|
// match word to group function
|
||||||
|
@ -4044,7 +4032,7 @@ int Variable::region_function(char *id, int ivar)
|
||||||
std::string mesg = "Region ID '";
|
std::string mesg = "Region ID '";
|
||||||
mesg += id;
|
mesg += id;
|
||||||
mesg += "' in variable formula does not exist";
|
mesg += "' in variable formula does not exist";
|
||||||
print_var_error(FLERR,mesg.c_str(),ivar);
|
print_var_error(FLERR,mesg,ivar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// init region in case sub-regions have been deleted
|
// init region in case sub-regions have been deleted
|
||||||
|
@ -4126,7 +4114,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
|
||||||
std::string mesg = "Invalid compute ID '";
|
std::string mesg = "Invalid compute ID '";
|
||||||
mesg += (args[0]+2);
|
mesg += (args[0]+2);
|
||||||
mesg += "' in variable formula";
|
mesg += "' in variable formula";
|
||||||
print_var_error(FLERR,mesg.c_str(),ivar);
|
print_var_error(FLERR,mesg,ivar);
|
||||||
}
|
}
|
||||||
compute = modify->compute[icompute];
|
compute = modify->compute[icompute];
|
||||||
if (index == 0 && compute->vector_flag) {
|
if (index == 0 && compute->vector_flag) {
|
||||||
|
@ -4171,7 +4159,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
|
||||||
std::string mesg = "Invalid fix ID '";
|
std::string mesg = "Invalid fix ID '";
|
||||||
mesg += (args[0]+2);
|
mesg += (args[0]+2);
|
||||||
mesg += "' in variable formula";
|
mesg += "' in variable formula";
|
||||||
print_var_error(FLERR,mesg.c_str(),ivar);
|
print_var_error(FLERR,mesg,ivar);
|
||||||
}
|
}
|
||||||
fix = modify->fix[ifix];
|
fix = modify->fix[ifix];
|
||||||
if (index == 0 && fix->vector_flag) {
|
if (index == 0 && fix->vector_flag) {
|
||||||
|
@ -4179,7 +4167,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
|
||||||
std::string mesg = "Fix with ID '";
|
std::string mesg = "Fix with ID '";
|
||||||
mesg += (args[0]+2);
|
mesg += (args[0]+2);
|
||||||
mesg += "' in variable formula not computed at compatible time";
|
mesg += "' in variable formula not computed at compatible time";
|
||||||
print_var_error(FLERR,mesg.c_str(),ivar);
|
print_var_error(FLERR,mesg,ivar);
|
||||||
}
|
}
|
||||||
nvec = fix->size_vector;
|
nvec = fix->size_vector;
|
||||||
nstride = 1;
|
nstride = 1;
|
||||||
|
@ -4391,7 +4379,7 @@ int Variable::special_function(char *word, char *contents, Tree **tree,
|
||||||
std::string mesg = "Variable ID '";
|
std::string mesg = "Variable ID '";
|
||||||
mesg += args[0];
|
mesg += args[0];
|
||||||
mesg += "' in variable formula does not exist";
|
mesg += "' in variable formula does not exist";
|
||||||
print_var_error(FLERR,mesg.c_str(),ivar);
|
print_var_error(FLERR,mesg,ivar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SCALARFILE has single current value, read next one
|
// SCALARFILE has single current value, read next one
|
||||||
|
@ -4772,13 +4760,11 @@ char *Variable::find_next_comma(char *str)
|
||||||
helper routine for printing variable name with error message
|
helper routine for printing variable name with error message
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void Variable::print_var_error(const char *srcfile, int lineno,
|
void Variable::print_var_error(const std::string &srcfile, const int lineno,
|
||||||
const char *errmsg, int ivar, int global)
|
const std::string &errmsg, int ivar, int global)
|
||||||
{
|
{
|
||||||
if ((ivar >= 0) && (ivar < nvar)) {
|
if ((ivar >= 0) && (ivar < nvar)) {
|
||||||
char msg[128];
|
std::string msg = fmt::format("Variable {}: ",names[ivar]) + errmsg;
|
||||||
|
|
||||||
snprintf(msg,128,"Variable %s: %s",names[ivar],errmsg);
|
|
||||||
if (global)
|
if (global)
|
||||||
error->all(srcfile,lineno,msg);
|
error->all(srcfile,lineno,msg);
|
||||||
else
|
else
|
||||||
|
@ -5072,11 +5058,9 @@ VarReader::VarReader(LAMMPS *lmp, char *name, char *file, int flag) :
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(file,"r");
|
fp = fopen(file,"r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open file variable file {}: {}",
|
||||||
snprintf(str,128,"Cannot open file variable file %s",file);
|
file, utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if atomfile-style variable, must store per-atom values read from file
|
// if atomfile-style variable, must store per-atom values read from file
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#define LMP_VARIABLE_H
|
#define LMP_VARIABLE_H
|
||||||
|
|
||||||
#include "pointers.h"
|
#include "pointers.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
|
@ -123,7 +124,8 @@ class Variable : protected Pointers {
|
||||||
double constant(char *);
|
double constant(char *);
|
||||||
int parse_args(char *, char **);
|
int parse_args(char *, char **);
|
||||||
char *find_next_comma(char *);
|
char *find_next_comma(char *);
|
||||||
void print_var_error(const char *, int, const char *, int, int global=1);
|
void print_var_error(const std::string &, int, const std::string &,
|
||||||
|
int, int global=1);
|
||||||
void print_tree(Tree *, int);
|
void print_tree(Tree *, int);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
@ -56,10 +57,9 @@ void WriteCoeff::command(int narg, char **arg)
|
||||||
char str[256], coeff[256];
|
char str[256], coeff[256];
|
||||||
FILE *one = fopen(file,"wb+");
|
FILE *one = fopen(file,"wb+");
|
||||||
|
|
||||||
if (one == NULL) {
|
if (one == NULL)
|
||||||
snprintf(str,256,"Cannot open coeff file %s",file);
|
error->one(FLERR,fmt::format("Cannot open coeff file {}: {}",
|
||||||
error->one(FLERR,str);
|
file, utils::getsyserror()));
|
||||||
}
|
|
||||||
|
|
||||||
if (force->pair && force->pair->writedata) {
|
if (force->pair && force->pair->writedata) {
|
||||||
fprintf(one,"# pair_style %s\npair_coeff\n",force->pair_style);
|
fprintf(one,"# pair_style %s\npair_coeff\n",force->pair_style);
|
||||||
|
@ -91,10 +91,10 @@ void WriteCoeff::command(int narg, char **arg)
|
||||||
rewind(one);
|
rewind(one);
|
||||||
|
|
||||||
FILE *two = fopen(file+4,"w");
|
FILE *two = fopen(file+4,"w");
|
||||||
if (two == NULL) {
|
if (two == NULL)
|
||||||
snprintf(str,256,"Cannot open coeff file %s",file+4);
|
error->one(FLERR,fmt::format("Cannot open coeff file {}: {}",
|
||||||
error->one(FLERR,str);
|
file+4, utils::getsyserror()));
|
||||||
}
|
|
||||||
fprintf(two,"# LAMMPS coeff file via write_coeff, version %s\n",
|
fprintf(two,"# LAMMPS coeff file via write_coeff, version %s\n",
|
||||||
universe->version);
|
universe->version);
|
||||||
|
|
||||||
|
|
|
@ -188,11 +188,9 @@ void WriteData::write(const char *file)
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
fp = fopen(file,"w");
|
fp = fopen(file,"w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
char str[128];
|
error->one(FLERR,fmt::format("Cannot open data file {}: {}",
|
||||||
snprintf(str,128,"Cannot open data file %s",file);
|
file, utils::getsyserror()));
|
||||||
error->one(FLERR,str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// proc 0 writes header, ntype-length arrays, force fields
|
// proc 0 writes header, ntype-length arrays, force fields
|
||||||
|
|
|
@ -63,7 +63,7 @@ void WriteDump::command(int narg, char **arg)
|
||||||
#include "style_dump.h"
|
#include "style_dump.h"
|
||||||
#undef DUMP_CLASS
|
#undef DUMP_CLASS
|
||||||
|
|
||||||
else error->all(FLERR,utils::check_packages_for_style("dump",arg[1],lmp).c_str());
|
else error->all(FLERR,utils::check_packages_for_style("dump",arg[1],lmp));
|
||||||
|
|
||||||
if (modindex < narg) dump->modify_params(narg-modindex-1,&arg[modindex+1]);
|
if (modindex < narg) dump->modify_params(narg-modindex-1,&arg[modindex+1]);
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,8 @@ void WriteRestart::write(std::string file)
|
||||||
|
|
||||||
fp = fopen(base.c_str(),"wb");
|
fp = fopen(base.c_str(),"wb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
error->one(FLERR,fmt::format("Cannot open restart file {}",base).c_str());
|
error->one(FLERR, fmt::format("Cannot open restart file {}: {}",
|
||||||
|
base, utils::getsyserror()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// proc 0 writes magic string, endian flag, numeric version
|
// proc 0 writes magic string, endian flag, numeric version
|
||||||
|
@ -299,7 +300,8 @@ void WriteRestart::write(std::string file)
|
||||||
if (filewriter) {
|
if (filewriter) {
|
||||||
fp = fopen(multiname.c_str(),"wb");
|
fp = fopen(multiname.c_str(),"wb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
error->one(FLERR,fmt::format("Cannot open restart file {}",multiname).c_str());
|
error->one(FLERR, fmt::format("Cannot open restart file {}: {}",
|
||||||
|
multiname, utils::getsyserror()));
|
||||||
write_int(PROCSPERFILE,nclusterprocs);
|
write_int(PROCSPERFILE,nclusterprocs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue