Fortran-C couple:simple program


I would like to use the fortran-c coupling example in /examples/COUPLE/simple directory. As given in the README and previous forum comments on this issue, the following commands were executed:

mpif90 -I/home/kamal/lammps3/16Aug13/src -c simple.f90

mpiCC -I/home/kamal/lammps3/16Aug13/src -c libfwrapper.c

mpif90 -L/home/kamal/lammps3/16Aug13/src simple.o libfwrapper.o -llammps_ufhpc -lstdc++ -lm -lmpi_cxx -o simpleF

But, it gave me following error:

simple.o: In function MAIN__': simple.f90:(.text+0x265): undefined reference to lammps_open_’
simple.f90:(.text+0x357): undefined reference to lammps_command_' simple.f90:(.text+0x36e): undefined reference to lammps_get_natoms_’
simple.f90:(.text+0x42d): undefined reference to lammps_gather_atoms_' simple.f90:(.text+0x47c): undefined reference to lammps_scatter_atoms_’
simple.f90:(.text+0x4e2): undefined reference to lammps_command_' simple.f90:(.text+0x4f1): undefined reference to lammps_close_’
simple.f90:(.text+0x571): undefined reference to `lammps_command_’

Could anyone help me to solve this problem?

Best Regards
Kamal Choudhary

Looks like you forgot to build lammps as a library.

Looks like you forgot to build lammps as a library.

i'd rather say it is the fortran wrapper that has not been compiled
correctly. in the list of commands that were executed, there is the
command to compile, but not the command to copy the source of that

that being said, this (fortran 77 style) wrapper has not been updated
for the current version of the lammps library interface and thus would
not link correctly with the simple.f90 example, even if it *was*
compiled properly. the functions to access and modify per atom data
are different now.

thus at the moment, it is recommended to use karl hammond's (fortran
2003 style) interface, which has more features, is more flexible and
more modern (which sounds a bit strange in the context of fortran).


Thanks for the response Carlos and Axel. In fact I found Karl Hammond’s code working.

Best Regards
Kamal Choudhary