Coupling Lammps to Fortran

Hi

I am trying to couple the LAMMPS to fortran code. I tried to build LAMMPS as a library (see example/COUPLE/README):

make mode=lib machine

or
make mode=shlib machine

but I receive the following error:

Makefile:201: recipe for target ‘machine’ failed
make: *** [machine] Error 1

I would appreciate if anyone could help me.

Best,
Alireza

Hi
solved

Thanks

Hi
I am not sure this is a lammps question or not but I receive this error when I am trying to couple lammps with fortran.

at first I cpied the libfwrapper.c and simple.f90 wrappers to the src directory of lammps folder then I try:

cd lammps/src/
mpicc -I/home/sjplimp/lammps/src -c libfwrapper.c
mpifort -c simple.f90

mpifort -L/home/sjplimp/lammps/src simple.o libfwrapper.o \

-llammps -lfftw -o simpleF

/usr/bin/ld: cannot find -llammps
/usr/bin/ld: cannot find -lfftw

collect2: error: ld returned 1 exit status

I would appreciate it if anyone could help me.

This is mostly not a LAMMPS question, but a question about understanding how compilers and compiling and linking works. It also demonstrates the problem of using cut-n-paste from documentation or README examples without reading up on what the individual commands and flags do. There is lots of information about this on the internet and in text books about programming/compiling. E.g. I have a lecture published on my homepage that - among other things - briefly explains several compiler flags and linking to libraries. https://sites.google.com/site/akohlmey/lectures/compile-link-make.pdf?attredirects=0&d=1

Please note that the LAMMPS fortran interface code is not being automatically checked and updated when changes to the LAMMPS library interface are made (which in turn is not exposing all of LAMMPS and only lightly tested). While there are several cases of LAMMPS being interfaced to libraries and codes in Fortran, that by themselves provide a C language interface, there seems to be very limited use of calling LAMMPS as a library from Fortran. So you are likely in for some serious debugging, testing, and updating that interface code by yourself, which means, that you need to teach yourself (much?) more about programming and in particular how to interface between multiple programming languages (if need be, there is a lecture about some multi-language programming basics on my home page as well. whether it is helpful depends a lot on your available programming skills and ability to teach yourself).

as points of reference: according to the source code management history, the code in the “fortran” folder has not been touched in over 7 years and thus can be considered abandoned, the code in the fortran2 folder is unchanged since over 3 years ago, and the fortran_dftb folder is an extension/update of fortran2 and has been added over 2 years ago.

Axel.