alecjohnson/iPic3D — pull request #1 by rinke (2013-12-13 18:05:04+00:00)
Title: Spawn fields solver with MPI_Comm_spawn 

The following might help to make understanding easier of what I did:

Attached is a handwritten note which depicts where and what is transferred.
This might be a good starting point.

![fields_moments_transfer](https://f.cloud.github.com/assets/5738855/1744648/b69765e2-6420-11e3-881b-42d586418c07.png)

I general, I tried to avoid code duplication by having fields and particles solver partly use the same code.
To me, the resulting changes or not too intrusive, but you will see yourself.

The basic functionality is in the following routines in class EMfields3D:

* syncInit -- Creates MPI datatypes for fields and moments transfer (done only once and re-used)
* syncFields -- synchronizes fields
* syncMoments -- synchronizes moments
* syncFinalize -- Frees MPI datatypes created in syncInit on simulation completion

Additionally, there are helper routines printFields and printMoments which print checksums for comparing
data between fields and particles solver. Currently, they are not in use.

For implementation I touched the following routines:

* c_Solver::Init
* c_Solver::Finalize
* EMfields3D::calculateE
* EMfields3D::calculateHatFunctions

Since calculation of rhoh is done on both sides in different places, I put the corresponding code in EMfields3D::calcRhoHat().

Wrt the main source files for fields and particles solver, the particles solver remains in iPic3D.cpp whereas the
fields solver is in a new file called iPic3D_fields.cpp. The corresponding binaries are now created with make based on the modified cmake configuration which is included.

FYI: Wrt file I/O, I introduced a preprocessor symbol called FILE_IO, see debug.h. This way we can switch file I/O
on and off. Might be useful for benchmarking. If on, all I/O is done by the particles solver only.

Please consider this code as a starting point only.
Debug compilation flags are turned on in cmake_template.cmake.Xeon
Nevertheless, it implements the ideas about which data to transfer and what infrastructure is needed.