Problem when calling back to LAMMPS from Python

Hi,

I am trying to build LAMMPS with Python support and it works for the most part for my tests. Calling LAMMPS from Python works fine (including PyLammps) and Python commands works fine too, but when I try to callback to LAMMPS, errors happen. Here is the situation:

in2.python:

python loop input 4 10 1.0 -4.0 SELF format iffp file funcs.py
python loop invoke

funcs.py:

def loop(N,cut0,thresh,lmpptr):
print “LOOP ARGS”,N,cut0,thresh,lmpptr
from lammps import lammps

log.lammps:

LAMMPS (31 Mar 2017)

OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (…/comm.cpp:90)
using 1 OpenMP thread(s) per MPI task
python loop input 4 10 1.0 -4.0 SELF format iffp file funcs.py
python loop invoke

Output on console:

~/lammps/examples/python$ …/…/src/lmp_wheeler -in in2.python

LAMMPS (31 Mar 2017)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (…/comm.cpp:90)
using 1 OpenMP thread(s) per MPI task
LOOP ARGS 10 1.0 -4.0 <PyCObject object at 0x7f0b4cbd6620>
ERROR on proc 0: Python function evaluation failed (…/python.cpp:253)
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=1
:
system msg for write_line failure : Bad file descriptor

Could anyone help me please? Thanks a lot!

Hi,

I am trying to build LAMMPS with Python support and it works for the most
part for my tests. Calling LAMMPS from Python works fine (including
PyLammps) and Python commands works fine too, but when I try to callback to
LAMMPS, errors happen. Here is the situation:

*in2.python:*

python loop input 4 10 1.0 -4.0 SELF format iffp file funcs.py
python loop invoke

*funcs.py:*

def loop(N,cut0,thresh,lmpptr):
  print "LOOP ARGS",N,cut0,thresh,lmpptr
  from lammps import lammps

*log.lammps:*

LAMMPS (31 Mar 2017)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread.
(../comm.cpp:90)
  using 1 OpenMP thread(s) per MPI task
python loop input 4 10 1.0 -4.0 SELF format iffp file funcs.py
python loop invoke

*Output on console:*

~/lammps/examples/python$ ../../src/lmp_wheeler -in in2.python

LAMMPS (31 Mar 2017)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread.
(../comm.cpp:90)
  using 1 OpenMP thread(s) per MPI task
LOOP ARGS 10 1.0 -4.0 <PyCObject object at 0x7f0b4cbd6620>
ERROR on proc 0: Python function evaluation failed (../python.cpp:253)
application called MPI_Abort(MPI_COMM_WORLD, 1) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=1
:
system msg for write_line failure : Bad file descriptor

Could anyone help me please? Thanks a lot!

​please update LAMMPS to the lastest patch, but at least to version 19 May
2017​.

​axel.​