Understand lammps code structure

Hi,

I am trying to understand the MPI version of lammps code.

if i understand correctly, the only line that code runs is from the line,

((( lammps->input->file(); )))



  LAMMPS_NS;

 main( argc,  **argv)
{
  MPI_Init(&argc,&argv);

  LAMMPS *lammps =  LAMMPS(argc,argv,MPI_COMM_WORLD);        

  lammps->input->file();
   lammps;

  MPI_Barrier(MPI_COMM_WORLD);
  MPI_Finalize();
}

which means the function “file();” from input class runs the whole code, right?

correct me if i am wrong.

if file(); function runs the whole code, how come integrate, vert::run() and all other main functions activates and produce results???

Thanks in advance.

regards,
baluu

Hi,

I am trying to understand the MPI version of lammps code.

then you should study the LAMMPS paper and the developer guide pdf
from the LAMMPS homepage first.

if i understand correctly, the only line that code runs is from the line,

((( lammps->input->file(); )))

#include <mpi.h>
#include "lammps.h"
#include "input.h"
#include <stdio.h>

using namespace LAMMPS_NS;

int main(int argc, char **argv)
{
  MPI_Init(&argc,&argv);

  LAMMPS *lammps = new LAMMPS(argc,argv,MPI_COMM_WORLD);

  lammps->input->file();
  delete lammps;

  MPI_Barrier(MPI_COMM_WORLD);
  MPI_Finalize();
}

which means the function "file();" from input class runs the whole code,
right?

"runs the whole code" is probably not the right way to describe it.
the file() method of the Input class (instance) processes the provided
input (either from a file or from stdin) in a line by line fashion and
executes it until there is no more input left or LAMMPS terminates for
some other reason.

please note that you also run the LAMMPS constructor (new LAMMPS),
which builds and initializes the basic class hierarchy (the LAMMPS
class is a composite with instances to various sub-classes that take
care of different "duties" inside of LAMMPS).

so "the whole code" are actually three(3!) steps:

- create an instance of the LAMMPS class
- process the input line-by-line until there is nothing left
- tear down the LAMMPS class (and its members).

when you run the standalone LAMMPS executable, you have nothing else
but a very thin wrapper around the LAMMPS library.

correct me if i am wrong.

if file(); function runs the whole code, how come integrate, vert::run() and
all other main functions activates and produce results???

these are all triggered by individual commands. each command in the
input is executed *immediately*. but there are two kinds of commands.
those that create or delete instances of classes (e.g. fix/unfix,
compute/uncompute, pair_style, bond_style) and those that cause
changes to the simulated system or its settings.

axel.