# Analytical perturbation with MPI

**URL:** <https://discourse.channelflow.ch/t/analytical-perturbation-with-mpi/174>\
**Category:** Usage\
**Created:** [June 23, 2022, 2:08pm UTC](https://discourse.channelflow.ch/t/analytical-perturbation-with-mpi/174 "2022-06-23T14:08:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://discourse.channelflow.ch/u/Michael)\
**Post date:** [June 23, 2022, 2:08pm UTC](https://discourse.channelflow.ch/t/analytical-perturbation-with-mpi/174/1 "2022-06-23T14:08:11Z")

</div>

Hello,

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);  
u1.makePhysical();  
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; }  
u1.makeSpectral();

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,  
Michael

---

<div class="post-metadata">

**Author:** ![Michael](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Michael](https://discourse.channelflow.ch/u/Michael)\
**Post date:** [June 27, 2022, 5:53pm UTC](https://discourse.channelflow.ch/t/analytical-perturbation-with-mpi/174/2 "2022-06-27T17:53:36Z")

</div>

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
