[lammps-users] Question about lammps as a library

Thanks for the fast answer Axel.
> i assume that you want to have the driver run in parallel
> across groups of processors and each group run a parallel
> lammps execution (if not please explain what you want to do).
>
I want a driver that runs parallel across groups of processors but each
group may consist of a single processors. Because of that I want to call
lammps part serial. The driver runs parallel on N cpus but every CPU run
different lammps with different inputs.

if you want the lammps part to be serial, you can compile the
lammps library against the MPI stub library that is supplied
with the lammps sources. then you can ignore MPI in your driver.

> to get this you have to partition your world communicator
> into groups and then call the lammps library with these.
>
My driver is written in fortran if I initiate MPI in the Fortran part
and create subcommunicators in c++ part would be ok?

that is bad. generally interfacing and calling c++ from
fortran can be very tricky, although not impossible. apart
from that, some MPI libraries support converting fortran
communicators to c/c++ others don't. you would have to
create a groups with just one MPI task in them for each
individual call to the driver code.

cheers,
   axel.

My driver is written in fortran if I initiate MPI in the Fortran part
and create subcommunicators in c++ part would be ok?

that is bad. generally interfacing and calling c++ from
fortran can be very tricky, although not impossible. apart
from that, some MPI libraries support converting fortran
communicators to c/c++ others don't. you would have to
create a groups with just one MPI task in them for each
individual call to the driver code.

There are 2 ways to use LAMMPS as a library. You can
write a C++ wrapper code which instatiates one (or more)
LAMMPS instances as classes. Or you can write
a Fortran or C driver that makes explicit library calls
to LAMMPS, using routines like those in src/library.cpp.
You could add as many routines as you wanted to library.cpp.
In the latter case your driver (Fortran or C) initilializes MPI
and passes a communicator to LAMMPS. The details
depend on the MPI (as Axel says), but often a "communicator"
is simple an integer. The point is that the C/Fortran interface
is very vanilla - it should be callable from any language.

Steve