1# -*- Makefile -*- for coupling LAMMPS to PWscf for QM/MM molecular dynamics
2
3# this file will be copied to Makefile.lammps
4EXTRAMAKE = Makefile.lammps.empty
5
6# top level directory of Quantum ESPRESSO 5.4.1 or later
7QETOPDIR=$(HOME)/compile/espresso
8
9# import compiler settings from Quantum ESPRESSO
10sinclude $(QETOPDIR)/make.sys
11
12# FLAGS for c++ OpenMPI 1.8.8 or later when QE was compiled with GNU Fortran 4.x
13MPICXX=mpicxx
14MPICXXFLAGS= -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -O2 -g -fPIC\
15	-I../../src -I$(QETOPDIR)/COUPLE/include
16MPILIBS=-fopenmp -lgfortran -ldl -ljpeg -lpng -lz -lmpi_mpifh -lmpi
17
18# location of required libraries
19# part 1: hi-level libraries for building pw.x
20PWOBJS = \
21$(QETOPDIR)/COUPLE/src/libqecouple.a \
22$(QETOPDIR)/PW/src/libpw.a \
23$(QETOPDIR)/Modules/libqemod.a
24# part 2: lo-level libraries for all of Q-E
25LIBOBJS = \
26$(QETOPDIR)/FFTXlib/libqefft.a \
27$(QETOPDIR)/LAXlib/libqela.a   \
28$(QETOPDIR)/clib/clib.a   \
29$(QETOPDIR)/iotk/src/libiotk.a
30
31# part 3: add-on libraries and main library for LAMMPS
32sinclude ../../src/Makefile.package
33LAMMPSCFG = mpi
34LAMMPSLIB = ../../src/liblammps_$(LAMMPSCFG).a
35
36# part 4: local QM/MM library and progams
37SRC=pwqmmm.c libqmmm.c
38OBJ=$(SRC:%.c=%.o)
39
40
41default: libqmmm.a
42
43all : tldeps libqmmm.a pwqmmm.x
44
45pwqmmm.x : pwqmmm.o $(OBJ) $(PWOBJS) $(LIBOBJS) $(LAMMPSLIB)
46	$(MPICXX) $(LDFLAGS) -o $@ $^ $(PKG_PATH) $(PKG_LIB) $(MPILIBS) $(LIBS)
47
48libqmmm.a: libqmmm.o
49	$(AR) $(ARFLAGS) $@ $^
50	@cp $(EXTRAMAKE) Makefile.lammps
51
52%.o: %.c
53	$(MPICXX) -c $(LAMMPSFLAGS) $(MPICXXFLAGS) $< -o $@
54
55tldeps:
56	( cd $(QETOPDIR) ; $(MAKE) $(MFLAGS) couple || exit 1)
57	$(MAKE) -C ../../src $(MFLAGS) $(LAMMPSCFG)
58	$(MAKE) -C ../../src $(MFLAGS) mode=lib $(LAMMPSCFG)
59
60clean :
61	-rm -f *.x *.o *.a *~ *.F90 *.d *.mod *.i *.L
62
63# explicit dependencies
64
65pwqmmm.o: pwqmmm.c libqmmm.h
66libqmmm.o: libqmmm.c libqmmm.h
67