Error in coupling LAMMPS and Quantum Espresso

Dear sir,
I installed and built LAMMPS 29SEP2021 version using make mpi in src folder, and performed the following steps:

  1. make lib-qmmm args="-m gfortran"
  2. make yes-molecule yes-kspace yes-rigid yes-qmmm
    make mpi
    make mode=lib mpi
    3.In QE (version 6.8) directory:
    ./configure
    make pw couple
  3. make -f Makefile.gfortran all

While Installing qmmm package, in this 4th step, I am getting the following error message:

mpicxx -c -DOMPI_SKIP_MPICXX=1 -O2 -Wall -g -fPIC -I…/…/src -I/home/sp097/QE_testing/Silicon/LAMMPS_QE/q-e-qe-6.8/COUPLE/include pwqmmm.c -o pwqmmm.o
pwqmmm.c: In function ‘int main(int, char**)’:
pwqmmm.c:262:9: error: ‘lammps_open’ was not declared in this scope; did you mean ‘lammps_free’?
262 | lammps_open(5, lmpargs, intra_comm, &lmp);
| ^~~~~~~~~~~
| lammps_free
pwqmmm.c:335:9: error: ‘lammps_open’ was not declared in this scope; did you mean ‘lammps_free’?
335 | lammps_open(5, lmpargs, intra_comm, &lmp);
| ^~~~~~~~~~~
| lammps_free
make: *** [Makefile.gfortran:61: pwqmmm.o] Error 1

Please guide me to complete the action.
Thank you

You have two options to resolve this compilation issue:

  1. Edit lib/qmmm/Makefile.gfortran and add -DLAMMPS_LIB_MPI to the MPICXXFLAGS variable definition
  2. Download and apply the bugfixes patch file from: https://github.com/lammps/lammps/releases/download/stable_29Sep2021/bugfixes_for_stable_29Sep2021.patch.gz

Option 1. is simpler, option 2. addresses all currently known bugs and compilation issues with the 29 Sep 2021 stable release.

Sir,
Thank you for replying.
I followed your step 1, and added -DLAMMPS_LIB_MPI as shown below

MPICXXFLAGS=-DLAMMPS_LIB_MPI -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -O2 -g -fPIC
-I…/…/src -I$(QETOPDIR)/COUPLE/include

I got the following message:

make: *** No rule to make target ‘/home/sp097/QE_testing/Silicon/LAMMPS_QE/q-e-qe-6.8/iotk/src/libiotk.a’, needed by ‘pwqmmm.x’. Stop.

Thus pwqmmm.x is not created. How can I proceed further.
Thank you in advance

This means that there were changes in quantum espresso since the version that was last tested with this interface. You would either have to use a compatible version of QE or ask the QM/MM developers on the QE mailing list for help with updating the the makefile(s). I don’t work on QE anymore so I don’t know.

Thank you sir for reply.
However i tried coupling now using cmake. Versions: Lammps - 31Aug2021 and QE version - 6.6
The following steps were followed and errors encountered.

  1. Goto Lammps-31-Aug-2021 folder:

used commands:
mkdir build-qmmm
cd build-qmmm
cmake -C …/cmake/presets/basic.cmake -D PKG_QMMM=yes
-D BUILD_LIB=yes -DBUILD_SHARED_LIBS=yes …/cmake
make
make install

  1. goto QE folder
    commands used:

./configure
make pw couple

  1. goto lammps/lib/qmmm folder
    (a) edited Makefile.gfortran-cmake anc changed the QETOPDIR path to QE-6.6 folder
    (b) commands used for export of LD_LIBRARY_PATH and PKG_CONFIG_PATH: (i) PKG_CONFIG_PATH={PKG_CONFIG_PATH-/usr/lib64/pkgconfig}:{HOME}/QE_testing/Silicon/LAMMPS_QE/lammps-31Aug2021/build-qmmm
    (ii)
    LD_LIBRARY_PATH={LD_LIBRARY_PATH-/usr/lib64}:{HOME}/QE_testing/Silicon/LAMMPS_QE/lammps-31Aug2021/build-qmmm
    (iii)
    export LD_LIBRARY_PATH PKG_CONFIG_PATH

Final step to generate pwqmmm executable:
commands used:
(a) checked export with command pkgconf liblammps --libs
(b) make -f Makefile.gfortran-cmake pwqmmm.x
error encountered:

pwqmmm.c:262:9: error: ‘lammps_open’ was not declared in this scope; did you mean ‘lammps_free’?
262 | lammps_open(5, lmpargs, intra_comm, &lmp);
| ^~~~~~~~~~~
| lammps_free
pwqmmm.c:335:9: error: ‘lammps_open’ was not declared in this scope; did you mean ‘lammps_free’?
335 | lammps_open(5, lmpargs, intra_comm, &lmp);
| ^~~~~~~~~~~
| lammps_free
make: *** [Makefile.gfortran-cmake:69: pwqmmm.o] Error 1

As per your suggestion, I added DLAMMPS_LIB_MPI to the MPICXXFLAGS variable definition
and tried again with command

make -f Makefile.gfortran-cmake pwqmmm.x

Now the error encountered is:

90:311: more undefined references to `__uspp_param_MOD_upf’ follow
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [Makefile.gfortran-cmake:62: pwqmmm.x] Error 1

Please suggest, what can I further do or edit to complete this final step

(Even if I followed with make instead of cmake, same error at the final step is encountered)

Thank you in advance.

I would not compile LAMMPS with shared libraries. The undefined reference error is due to quantum espresso. You probably need to change link libraries or locations. You need to consult with the QM/MM folks on the QE side about that.