Merge pull request #3102 from akohlmey/mpi-stubs-simplify

Porting unit tests to run natively on Windows
This commit is contained in:
Axel Kohlmeyer
2022-01-31 21:37:48 -05:00
committed by GitHub
68 changed files with 675 additions and 353 deletions

View File

@ -319,7 +319,7 @@ void FixDeformKokkos::end_of_step()
// if (mask[i] & groupbit)
// domain->x2lamda(x[i],x[i]);
if (nrigid)
if (rfix.size() > 0)
error->all(FLERR,"Cannot (yet) use rigid bodies with fix deform and Kokkos");
//for (i = 0; i < nrigid; i++)
// modify->fix[rfix[i]]->deform(0);

View File

@ -505,8 +505,10 @@ void PairEAMCD::read_h_coeff(char *filename)
utils::getsyserror());
char *buf = new char[MAXLINE+1];
utils::sfread(FLERR, buf, 1, MAXLINE, fptr, filename, error);
buf[MAXLINE] = '\0'; // must 0-terminate buffer for string processing
auto rv = fread(buf,1,MAXLINE,fptr);
if (rv == 0) error->one(FLERR,"Failure to read h(x) coeffs: {}", utils::getsyserror());
buf[rv] = '\0'; // must 0-terminate buffer for string processing
Tokenizer lines(buf, "\n");
delete[] buf;

View File

@ -356,10 +356,10 @@ gitversion:
branch='(unknown)' ; \
describe='(unknown)' ; \
fi ; \
echo "const bool LAMMPS_NS::LAMMPS::has_git_info = $${git};" >> ${TMPNAME}.lmpgitversion ; \
echo "const char LAMMPS_NS::LAMMPS::git_commit[] = \"$${commit}\";" >> ${TMPNAME}.lmpgitversion ; \
echo "const char LAMMPS_NS::LAMMPS::git_branch[] = \"$${branch}\";" >> ${TMPNAME}.lmpgitversion ; \
echo "const char LAMMPS_NS::LAMMPS::git_descriptor[] = \"$${describe}\";" >> ${TMPNAME}.lmpgitversion
echo "bool LAMMPS_NS::LAMMPS::has_git_info() { return $${git}; }" >> ${TMPNAME}.lmpgitversion ; \
echo "const char *LAMMPS_NS::LAMMPS::git_commit() { return \"$${commit}\"; }" >> ${TMPNAME}.lmpgitversion ; \
echo "const char *LAMMPS_NS::LAMMPS::git_branch() { return \"$${branch}\"; }" >> ${TMPNAME}.lmpgitversion ; \
echo "const char *LAMMPS_NS::LAMMPS::git_descriptor() { return \"$${describe}\"; }" >> ${TMPNAME}.lmpgitversion
@echo '#endif' >> ${TMPNAME}.lmpgitversion
@if [ -f lmpgitversion.h ]; \
then test "`diff --brief ${TMPNAME}.lmpgitversion lmpgitversion.h`" != "" && \

View File

@ -329,9 +329,11 @@ void PythonImpl::invoke_function(int ifunc, char *result)
if (pfuncs[ifunc].noutput) {
int otype = pfuncs[ifunc].otype;
if (otype == INT) {
sprintf(result, "%ld", PY_INT_AS_LONG(pValue));
auto value = fmt::format("{}", PY_INT_AS_LONG(pValue));
strncpy(result, value.c_str(), Variable::VALUELENGTH - 1);
} else if (otype == DOUBLE) {
sprintf(result, "%.15g", PyFloat_AsDouble(pValue));
auto value = fmt::format("{:.15g}", PyFloat_AsDouble(pValue));
strncpy(result, value.c_str(), Variable::VALUELENGTH - 1);
} else if (otype == STRING) {
const char *pystr = PY_STRING_AS_STRING(pValue);
if (pfuncs[ifunc].longstr)

View File

@ -1052,7 +1052,7 @@ void Atom::deallocate_topology()
void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
int type_offset, int shiftflag, double *shift)
{
int m,xptr,iptr;
int xptr,iptr;
imageint imagedata;
double xdata[3],lamda[3];
double *coord;
@ -1197,7 +1197,7 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
void Atom::data_vels(int n, char *buf, tagint id_offset)
{
int j,m;
int m;
char *next;
next = strchr(buf,'\n');
@ -1576,7 +1576,7 @@ void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset,
void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus, tagint id_offset)
{
int j,m;
int m;
char *next;
next = strchr(buf,'\n');

View File

@ -226,13 +226,13 @@ int ComputePairLocal::compute_pairs(int flag)
factor_lj = special_lj[sbmask(j)];
factor_coul = special_coul[sbmask(j)];
j &= NEIGHMASK;
jtag = tag[j];
if (!(mask[j] & groupbit)) continue;
// itag = jtag is possible for long cutoffs that include images of self
if (newton_pair == 0 && j >= nlocal) {
jtag = tag[j];
if (itag > jtag) {
if ((itag+jtag) % 2 == 0) continue;
} else if (itag < jtag) {

View File

@ -1009,13 +1009,13 @@ void Dump::balance()
// send for this proc
if (iproc_prev != me) {
MPI_Send(&buf[procstart*size_one],procnsend*size_one,MPI_DOUBLE,procsend,0,world);
MPI_Send(&buf[procstart*size_one],procnsend*size_one,MPI_DOUBLE,procsend,0,world);
} else {
// sending to self, copy buffers
int offset_me = proc_offsets[me] - proc_new_offsets[me];
memcpy(&buf_balance[(offset_me + procstart)*size_one],&buf[procstart*size_one],procnsend*size_one*sizeof(double));
int offset_me = proc_offsets[me] - proc_new_offsets[me];
memcpy(&buf_balance[(offset_me + procstart)*size_one],&buf[procstart*size_one],sizeof(double)*procnsend*size_one);
}
procstart = i;

View File

@ -167,16 +167,13 @@ int DumpCFG::convert_string(int n, double *mybuf)
offset += sprintf(&sbuf[offset],"%s \n",typenames[(int) mybuf[m]]);
} else if (j >= 2) {
if (vtype[j] == Dump::INT)
offset +=
sprintf(&sbuf[offset],vformat[j],static_cast<int> (mybuf[m]));
offset += sprintf(&sbuf[offset],vformat[j],static_cast<int> (mybuf[m]));
else if (vtype[j] == Dump::DOUBLE)
offset += sprintf(&sbuf[offset],vformat[j],mybuf[m]);
else if (vtype[j] == Dump::STRING)
offset +=
sprintf(&sbuf[offset],vformat[j],typenames[(int) mybuf[m]]);
offset += sprintf(&sbuf[offset],vformat[j],typenames[(int) mybuf[m]]);
else if (vtype[j] == Dump::BIGINT)
offset +=
sprintf(&sbuf[offset],vformat[j],static_cast<bigint> (mybuf[m]));
offset += sprintf(&sbuf[offset],vformat[j],static_cast<bigint> (mybuf[m]));
}
m++;
}

View File

@ -45,7 +45,7 @@ enum{ONE_FROM_ONE,ONE_FROM_TWO,TWO_FROM_ONE};
/* ---------------------------------------------------------------------- */
FixDeform::FixDeform(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg),
rfix(nullptr), irregular(nullptr), set(nullptr)
irregular(nullptr), set(nullptr)
{
if (narg < 4) error->all(FLERR,"Illegal fix deform command");
@ -127,8 +127,8 @@ rfix(nullptr), irregular(nullptr), set(nullptr)
error->all(FLERR,"Illegal fix deform command");
if (strstr(arg[iarg+3],"v_") != arg[iarg+3])
error->all(FLERR,"Illegal fix deform command");
delete [] set[index].hstr;
delete [] set[index].hratestr;
delete[] set[index].hstr;
delete[] set[index].hratestr;
set[index].hstr = utils::strdup(&arg[iarg+2][2]);
set[index].hratestr = utils::strdup(&arg[iarg+3][2]);
iarg += 4;
@ -185,8 +185,8 @@ rfix(nullptr), irregular(nullptr), set(nullptr)
error->all(FLERR,"Illegal fix deform command");
if (strstr(arg[iarg+3],"v_") != arg[iarg+3])
error->all(FLERR,"Illegal fix deform command");
delete [] set[index].hstr;
delete [] set[index].hratestr;
delete[] set[index].hstr;
delete[] set[index].hratestr;
set[index].hstr = utils::strdup(&arg[iarg+2][2]);
set[index].hratestr = utils::strdup(&arg[iarg+3][2]);
iarg += 4;
@ -344,7 +344,6 @@ rfix(nullptr), irregular(nullptr), set(nullptr)
force_reneighbor = 1;
next_reneighbor = -1;
nrigid = 0;
flip = 0;
if (force_reneighbor) irregular = new Irregular(lmp);
@ -359,12 +358,11 @@ FixDeform::~FixDeform()
{
if (set) {
for (int i = 0; i < 6; i++) {
delete [] set[i].hstr;
delete [] set[i].hratestr;
delete[] set[i].hstr;
delete[] set[i].hratestr;
}
}
delete [] set;
delete [] rfix;
delete[] set;
delete irregular;
@ -396,9 +394,8 @@ void FixDeform::init()
// domain, fix nvt/sllod, compute temp/deform only work on single h_rate
int count = 0;
for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"deform") == 0) count++;
if (count > 1) error->all(FLERR,"More than one fix deform");
if (modify->get_fix_by_style("deform").size() > 1)
error->all(FLERR,"More than one fix deform");
// Kspace setting
@ -609,20 +606,12 @@ void FixDeform::init()
}
// detect if any rigid fixes exist so rigid bodies can be rescaled
// rfix[] = indices to each fix rigid
// rfix[] = vector with pointers to each fix rigid
delete [] rfix;
nrigid = 0;
rfix = nullptr;
rfix.clear();
for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->rigid_flag) nrigid++;
if (nrigid) {
rfix = new int[nrigid];
nrigid = 0;
for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->rigid_flag) rfix[nrigid++] = i;
}
for (auto ifix : modify->get_fix_list())
if (ifix->rigid_flag) rfix.push_back(ifix);
}
/* ----------------------------------------------------------------------
@ -894,9 +883,8 @@ void FixDeform::end_of_step()
if (mask[i] & groupbit)
domain->x2lamda(x[i],x[i]);
if (nrigid)
for (i = 0; i < nrigid; i++)
modify->fix[rfix[i]]->deform(0);
for (auto ifix : rfix)
ifix->deform(0);
}
// reset global and local box to new size/shape
@ -934,9 +922,8 @@ void FixDeform::end_of_step()
if (mask[i] & groupbit)
domain->lamda2x(x[i],x[i]);
if (nrigid)
for (i = 0; i < nrigid; i++)
modify->fix[rfix[i]]->deform(1);
for (auto ifix : rfix)
ifix->deform(1);
}
// redo KSpace coeffs since box has changed

View File

@ -45,8 +45,7 @@ class FixDeform : public Fix {
double *h_rate, *h_ratelo;
int varflag; // 1 if VARIABLE option is used, 0 if not
int kspace_flag; // 1 if KSpace invoked, 0 if not
int nrigid; // number of rigid fixes
int *rfix; // indices of rigid fixes
std::vector<Fix *> rfix; // pointers to rigid fixes
class Irregular *irregular; // for migrating atoms after box flips
double TWOPI;

View File

@ -278,9 +278,9 @@ void Info::command(int narg, char **arg)
fmt::print(out,"\nLAMMPS version: {} / {}\n",
lmp->version, lmp->num_ver);
if (lmp->has_git_info)
if (lmp->has_git_info())
fmt::print(out,"Git info: {} / {} / {}\n",
lmp->git_branch, lmp->git_descriptor,lmp->git_commit);
lmp->git_branch(), lmp->git_descriptor(),lmp->git_commit());
fmt::print(out,"\nOS information: {}\n\n",platform::os_info());

View File

@ -978,10 +978,15 @@ void Input::include()
if (nfile == maxfile)
error->one(FLERR,"Too many nested levels of input scripts");
infile = fopen(arg[0],"r");
// expand variables
int n = strlen(arg[0]) + 1;
if (n > maxline) reallocate(line,maxline,n);
strcpy(line,arg[0]);
substitute(line,work,maxline,maxwork,0);
infile = fopen(line,"r");
if (infile == nullptr)
error->one(FLERR,"Cannot open input script {}: {}",
arg[0], utils::getsyserror());
error->one(FLERR,"Cannot open input script {}: {}", line, utils::getsyserror());
infiles[nfile++] = infile;
}

View File

@ -1149,9 +1149,9 @@ void _noopt LAMMPS::help()
// general help message about command line and flags
if (has_git_info) {
if (has_git_info()) {
fprintf(fp,"\nLarge-scale Atomic/Molecular Massively Parallel Simulator - "
LAMMPS_VERSION UPDATE_STRING "\nGit info (%s / %s)\n\n",git_branch, git_descriptor);
LAMMPS_VERSION UPDATE_STRING "\nGit info (%s / %s)\n\n",git_branch(), git_descriptor());
} else {
fprintf(fp,"\nLarge-scale Atomic/Molecular Massively Parallel Simulator - "
LAMMPS_VERSION UPDATE_STRING "\n\n");

View File

@ -73,10 +73,10 @@ class LAMMPS {
static const char *installed_packages[];
static bool is_installed_pkg(const char *pkg);
static const bool has_git_info;
static const char git_commit[];
static const char git_branch[];
static const char git_descriptor[];
static bool has_git_info();
static const char *git_commit();
static const char *git_branch();
static const char *git_descriptor();
LAMMPS(int, char **, MPI_Comm);
~LAMMPS();

View File

@ -1028,7 +1028,7 @@ std::vector<std::string> utils::split_words(const std::string &text)
------------------------------------------------------------------------- */
std::vector<std::string> utils::split_lines(const std::string &text)
{
return Tokenizer(text, "\n").as_vector();
return Tokenizer(text, "\r\n").as_vector();
}
/* ----------------------------------------------------------------------

View File

@ -68,6 +68,7 @@ void WriteDump::command(int narg, char **arg)
#undef DUMP_CLASS
} else error->all(FLERR,utils::check_packages_for_style("dump",arg[1],lmp));
delete[] dumpargs;
if (modindex < narg) dump->modify_params(narg-modindex-1,&arg[modindex+1]);
@ -89,5 +90,4 @@ void WriteDump::command(int narg, char **arg)
// delete the Dump instance and local storage
delete dump;
delete [] dumpargs;
}