An error occurred in MPI_Allreduce - fix momentum

I compiled lammps (git May 24) using OpenMPI (1.10.2).

I am running a hybrid potential (EAM + CHARMM).
When I tried to run a script which contain the fix momentum, I got the following error:

*** An error occurred in MPI_Allreduce
*** reported by process [2711420929,15]
*** on communicator MPI_COMM_WORLD
*** MPI_ERR_TRUNCATE: message truncated
*** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
*** and potentially your MPI job)

The error is not present when I comment the fix momentum line, and the job can run normally.

Using a lammps version from Mar 31 (compiled with OpenMPI 1.8) this error is not present and the calculation can run normally.

Thanks,

Gustavo

I compiled lammps (git May 24) using OpenMPI (1.10.2).

I am running a hybrid potential (EAM + CHARMM).
When I tried to run a script which contain the fix momentum, I got the
following error:

*** An error occurred in MPI_Allreduce
*** reported by process [2711420929,15]
*** on communicator MPI_COMM_WORLD
*** MPI_ERR_TRUNCATE: message truncated
*** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
*** and potentially your MPI job)

The error is not present when I comment the fix momentum line, and the job
can run normally.

​that doesn't mean anything. it may be a communication from some other
style​ (compute or fix) that has gone astray that is causing this and fix
momentum just catches it because of the global communication. we've had
similar cases before.

Using a lammps version from Mar 31 (compiled with OpenMPI 1.8) this error
is not present and the calculation can run normally.

can you produce a minimal input deck (i.e. input with a small number of
atoms and the minimum​​ number of commands) that reproduces this?
then it may be possible to look into this. but reviewing the changes to fix
momentum between march and now, there is nothing obvious that would affect
fix momentum in the way you mention.

axel.

Dear Axel and Gustavo,

I was having the same issue and I think that I have traced it. The “dynamic” flag is not initialized in the FixMomentum constructor. Initializing the flag to zero fixes the problem for me (May 14,2016 version, OMPI 1.6.5).

The script below will reproduce the original error intermittently, since it depends on how the individual processes set their flags to zero or not zero:

units lj
atom_style atomic
lattice fcc 0.8442
region box block 0 5 0 5 0 5
create_box 1 box
create_atoms 1 box
mass 1 1.0
velocity all create 1 87287
pair_style lj/cut 1.122462
pair_coeff 1 1 1.0 1.0
pair_modify shift yes
fix 1 all nve
fix 2 all momentum 4 linear 1 1 1
thermo 1000
thermo_modify flush yes
run 40

Thanks,
-David

Dear Axel and Gustavo,

I was having the same issue and I think that I have traced it. The "dynamic"
flag is not initialized in the FixMomentum constructor. Initializing the
flag to zero fixes the problem for me (May 14,2016 version, OMPI 1.6.5).

thanks david.

yes, this makes sense. it is also better to move the check for a
dynamic group into the Fix::init() method rather than have it in the
constructor.
so the full patch relative to upstream would be:
diff --git a/src/fix_momentum.cpp b/src/fix_momentum.cpp
index aa0f5fd..88a50d8 100644
--- a/src/fix_momentum.cpp
+++ b/src/fix_momentum.cpp
@@ -36,7 +36,7 @@ FixMomentum::FixMomentum(LAMMPS *lmp, int narg, char **arg) :
   nevery = force->inumeric(FLERR,arg[3]);
   if (nevery <= 0) error->all(FLERR,"Illegal fix momentum command");

- linear = angular = rescale = 0;
+ dynamic = linear = angular = rescale = 0;

   int iarg = 4;
   while (iarg < narg) {
@@ -65,12 +65,6 @@ FixMomentum::FixMomentum(LAMMPS *lmp, int narg, char **arg) :
       error->all(FLERR,"Illegal fix momentum command");

   dynamic_group_allow = 1;
- if (group->dynamic[igroup]) {
- dynamic = 1;
- } else {
- if (group->count(igroup) == 0)
- error->all(FLERR,"Fix momentum group has no atoms");
- }
}

/* ---------------------------------------------------------------------- */
@@ -86,6 +80,12 @@ int FixMomentum::setmask()

void FixMomentum::init()
{
+ if (group->dynamic[igroup]) {
+ dynamic = 1;
+ } else {
+ if (group->count(igroup) == 0)
+ error->all(FLERR,"Fix momentum group has no atoms");
+ }
   masstotal = group->mass(igroup);
}

axel.