# mpiAllReduce(uReduce\[\], uG\[\], mpiCommWorld, mpiSUM)

**URL:** <https://community.freefem.org/t/mpiallreduce-ureduce-ug-mpicommworld-mpisum/1027>\
**Category:** General Discussion\
**Created:** [June 11, 2021, 4:49pm UTC](https://community.freefem.org/t/mpiallreduce-ureduce-ug-mpicommworld-mpisum/1027 "2021-06-11T16:49:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 11, 2021, 4:49pm UTC](https://community.freefem.org/t/mpiallreduce-ureduce-ug-mpicommworld-mpisum/1027/1 "2021-06-11T16:49:51Z")

</div>

Dear all,

There is problem in line 3 in the following MPI code:

1. fespace VhG(ThG, P2); _//global mesh ThG_
2. VhG uG=0, uReduce=0;
3. **uReduce = u** _//u is a local variable defined on local mesh Th on one specific MPI processor_
4. mpiAllReduce(uReduce[], uG[], mpiCommWorld, mpiSUM)

The problem is when I do **uReduce = u** in line 3, the values are extrapolated automatically, which is **NOT zero** on **ThG-Th** , so that line 4 generates wrong values in uG using **mpiSUM**.

Is there a better method to centralise/combine results form different MPI processors?

Best,  
Yongxing.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 11, 2021, 5:06pm UTC](https://community.freefem.org/t/mpiallreduce-ureduce-ug-mpicommworld-mpisum/1027/2 "2021-06-11T17:06:41Z")

</div>

Please go through the tutorial before asking all these questions [Pierre Jolivet introduction to parallel FreeFEM part 1 - YouTube](https://www.youtube.com/watch?v=-Aw2O46V2bo) [Pierre Jolivet introduction to parallel FreeFEM part 2 - YouTube](https://www.youtube.com/watch?v=Hx57gxTOnvE)

It is explained thoroughly how to do mesh adaptation, gather a solution, so on and so forth (basically all your questions from the last couple of days…).

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 11, 2021, 5:23pm UTC](https://community.freefem.org/t/mpiallreduce-ureduce-ug-mpicommworld-mpisum/1027/3 "2021-06-11T17:23:37Z")

</div>

Yes, I have not yet successfully implemented my parallel FSI code. Will have a look at the vedio. Thank you.

---

<div class="post-metadata">

**Author:** ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)\
**Post date:** [June 11, 2021, 10:47pm UTC](https://community.freefem.org/t/mpiallreduce-ureduce-ug-mpicommworld-mpisum/1027/4 "2021-06-11T22:47:23Z")

</div>

Great videos, my problem has now been solved. Thank you very much!
