Analytical perturbation with MPI


I’m trying to run the code with an analytical initial condition using the following:

FlowField u1=FlowField(Nx, Ny, Nz, 3, Lx, Lz, a, b);
for (int ny=0; ny<Ny; ++ny)
for (int nz=0; nz<Nz; ++nz)
for (int nx=0; nx<Nx; ++nx) {
u1(nx,ny,nz,0) = 0.01*(1.0 - square(u1.y(ny)));
u1(nx,ny,nz,1) = 0;
u1(nx,ny,nz,2) = 0; }

This works perfectly when running serial [./test] but fails with mpi [mpirun -np 2 ./test]
Could you please suggest a path to overcome the problem?

Thanks a lot in advance,

in case someone experiences a similar problem, i split it into 2 programs
the first runs serial and writes an initial condition to file
the second loads the initial condition and runs with mpi