Model files that you have written (or downloaded) for use with LATTICEEASY can be easily modified to work with CLUSTEREASY. You can probably most easily see the changes that need to be made by running diff on the model files that come with LATTICEEASY and CLUSTEREASY, but I also describe the changes below. They need to be made in two functions.
In the function potential_energy() you should add a
variable called result and initialize it to zero. In the
loop over the grid you should replace each instance of
potential with result. Immediately after the
loop and before the line where potential is divided by
gridsize, you should insert the line
// Sum potentials from all processors to get the average potential for the array.
MPI_Allreduce(&result, &potential, 1, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
This will cause each processor the calculate its contribution to the potential in the variable result and then combine them all in the variable potential.
Similarly, in the function effective_mass() you should add
a variable called result. Inside the loop over fields (in the case
) you should replace every instance of
fldsqrd[fld] with result. Immediately after
the loop and before the line where you divide result by
gridsize you should insert the line
MPI_Allreduce(&result, &(fldsqrd[fld]), 1, MPI_FLOAT, MPI_SUM, MPI_COMM_WORLD);
Again, if anything in this section is unclear simply look in the model file provided with CLUSTEREASY. You should realize, however, that we've only described the changes that need to be made in the generic parts of the model files. If there are model-specific output functions, or complicated calculations done in the function model_initialize(), these may need to be parallelized as well. A good rule of thumb is that any time you average or sum a quantity over the entire lattice you will need to modify the code to run in parallel. If you are doing any such modification you should read section 7.4 below, and you may also find it helpful to read section 7.2. If you have any questions about parallelizing your functions for CLUSTEREASY feel free to contact G.F. for help.
You should be able to use LATTICEEASY parameter files with no modification.