forked from lijiext/lammps
simplify and use utils functions
This commit is contained in:
parent
b5830b672a
commit
5b6b6b8767
|
@ -204,11 +204,8 @@ void ComputeCNPAtom::compute_peratom()
|
|||
|
||||
int nerrorall;
|
||||
MPI_Allreduce(&nerror,&nerrorall,1,MPI_INT,MPI_SUM,world);
|
||||
if (nerrorall && comm->me == 0) {
|
||||
char str[128];
|
||||
sprintf(str,"Too many neighbors in CNP for %d atoms",nerrorall);
|
||||
error->warning(FLERR,str);
|
||||
}
|
||||
if (nerrorall && comm->me == 0)
|
||||
error->warning(FLERR,"Too many neighbors in CNP for {} atoms",nerrorall);
|
||||
|
||||
// compute CNP value for each atom in group
|
||||
// only performed if # of nearest neighbors = 12 or 14 (fcc,hcp)
|
||||
|
@ -311,11 +308,8 @@ void ComputeCNPAtom::compute_peratom()
|
|||
|
||||
// warning message
|
||||
MPI_Allreduce(&nerror,&nerrorall,1,MPI_INT,MPI_SUM,world);
|
||||
if (nerrorall && comm->me == 0) {
|
||||
char str[128];
|
||||
sprintf(str,"Too many common neighbors in CNP %d times",nerrorall);
|
||||
error->warning(FLERR,str);
|
||||
}
|
||||
if (nerrorall && comm->me == 0)
|
||||
error->warning(FLERR,"Too many common neighbors in CNP {} times",nerrorall);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
|
@ -145,11 +145,9 @@ FixAveCorrelateLong::FixAveCorrelateLong(LAMMPS * lmp, int narg, char **arg):
|
|||
error->all(FLERR,"Illegal fix ave/correlate/long command");
|
||||
if (me == 0) {
|
||||
fp = fopen(arg[iarg+1],"w");
|
||||
if (fp == nullptr) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open fix ave/correlate/long file %s",arg[iarg+1]);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
if (fp == nullptr)
|
||||
error->one(FLERR,"Cannot open fix ave/correlate/long file {}: {}",
|
||||
arg[iarg+1],utils::getsyserror());
|
||||
}
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"overwrite") == 0) {
|
||||
|
|
|
@ -243,11 +243,8 @@ void FixElectronStopping::read_table(const char *file)
|
|||
char line[MAXLINE];
|
||||
|
||||
FILE *fp = utils::open_potential(file,lmp,nullptr);
|
||||
if (fp == nullptr) {
|
||||
char str[128];
|
||||
snprintf(str, 128, "Cannot open stopping range table %s", file);
|
||||
error->one(FLERR, str);
|
||||
}
|
||||
if (fp == nullptr)
|
||||
error->one(FLERR,"Cannot open stopping range table {}: {}", file, utils::getsyserror());
|
||||
|
||||
const int ncol = atom->ntypes + 1;
|
||||
|
||||
|
|
|
@ -19,18 +19,18 @@
|
|||
|
||||
#include "fix_gle.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "error.h"
|
||||
#include "force.h"
|
||||
#include "memory.h"
|
||||
#include "random_mars.h"
|
||||
#include "respa.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "update.h"
|
||||
#include "respa.h"
|
||||
#include "comm.h"
|
||||
#include "random_mars.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
|
@ -225,13 +225,9 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) :
|
|||
char *fname = arg[7];
|
||||
if (comm->me == 0) {
|
||||
fgle = utils::open_potential(fname,lmp,nullptr);
|
||||
if (fgle == nullptr) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open A-matrix file %s",fname);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
if (screen) fprintf(screen,"Reading A-matrix from %s\n", fname);
|
||||
if (logfile) fprintf(logfile,"Reading A-matrix from %s\n", fname);
|
||||
if (fgle == nullptr)
|
||||
error->one(FLERR,"Cannot open A-matrix file {}: {}",fname, utils::getsyserror());
|
||||
utils::logmesg(lmp,"Reading A-matrix from {}\n", fname);
|
||||
}
|
||||
|
||||
// read each line of the file, skipping blank lines or leading '#'
|
||||
|
@ -295,15 +291,9 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) :
|
|||
} else {
|
||||
if (comm->me == 0) {
|
||||
fgle = utils::open_potential(fname,lmp,nullptr);
|
||||
if (fgle == nullptr) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open C-matrix file %s",fname);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
if (screen)
|
||||
fprintf(screen,"Reading C-matrix from %s\n", fname);
|
||||
if (logfile)
|
||||
fprintf(logfile,"Reading C-matrix from %s\n", fname);
|
||||
if (fgle == nullptr)
|
||||
error->one(FLERR,"Cannot open C-matrix file {}: {}",fname, utils::getsyserror());
|
||||
utils::logmesg(lmp,"Reading C-matrix from {}\n", fname);
|
||||
}
|
||||
|
||||
// read each line of the file, skipping blank lines or leading '#'
|
||||
|
|
|
@ -75,8 +75,7 @@ nfileevery(0), fp(nullptr), xf(nullptr), xold(nullptr)
|
|||
if (me == 0) {
|
||||
fp = fopen(arg[6],"w");
|
||||
if (fp == nullptr)
|
||||
error->one(FLERR,"Cannot open fix tmd file {}: {}",
|
||||
arg[6], utils::getsyserror());
|
||||
error->one(FLERR,"Cannot open fix tmd file {}: {}", arg[6], utils::getsyserror());
|
||||
fprintf(fp,"%s %s\n","# Step rho_target rho_old gamma_back",
|
||||
"gamma_forward lambda work_lambda work_analytical");
|
||||
}
|
||||
|
@ -381,7 +380,7 @@ int FixTMD::unpack_exchange(int nlocal, double *buf)
|
|||
void FixTMD::readfile(char *file)
|
||||
{
|
||||
if (me == 0) {
|
||||
if (screen) fprintf(screen,"Reading TMD target file %s ...\n",file);
|
||||
utils::logmesg(lmp,"Reading TMD target file {} ...\n",file);
|
||||
open(file);
|
||||
}
|
||||
|
||||
|
@ -541,8 +540,7 @@ void FixTMD::open(char *file)
|
|||
}
|
||||
|
||||
if (fp == nullptr)
|
||||
error->one(FLERR,"Cannot open file {}: {}",
|
||||
file, utils::getsyserror());
|
||||
error->one(FLERR,"Cannot open file {}: {}",file, utils::getsyserror());
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
|
|
@ -20,22 +20,21 @@
|
|||
|
||||
#include "fix_ttm_mod.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "citeme.h"
|
||||
#include "comm.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "force.h"
|
||||
#include "math_const.h"
|
||||
#include "memory.h"
|
||||
#include "random_mars.h"
|
||||
#include "respa.h"
|
||||
#include "tokenizer.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include "atom.h"
|
||||
#include "force.h"
|
||||
#include "update.h"
|
||||
#include "domain.h"
|
||||
#include "respa.h"
|
||||
#include "comm.h"
|
||||
#include "random_mars.h"
|
||||
#include "memory.h"
|
||||
#include "error.h"
|
||||
#include "citeme.h"
|
||||
#include "math_const.h"
|
||||
|
||||
|
||||
#include "tokenizer.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace FixConst;
|
||||
|
@ -104,11 +103,8 @@ FixTTMMod::FixTTMMod(LAMMPS *lmp, int narg, char **arg) :
|
|||
if (narg != 11) error->all(FLERR,"Illegal fix ttm/mod command");
|
||||
if (comm->me == 0) {
|
||||
fp = fopen(arg[10],"w");
|
||||
if (fp == nullptr) {
|
||||
char str[128];
|
||||
snprintf(str,128,"Cannot open fix ttm/mod file %s",arg[10]);
|
||||
error->one(FLERR,str);
|
||||
}
|
||||
if (fp == nullptr)
|
||||
error->one(FLERR,"Cannot open fix ttm/mod file {}: {}",arg[10],utils::getsyserror());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue