# MPI distribution for an ocean model: what's the best way to deal with processes that are completely on land?

**URL:** <https://forum.access-hive.org.au/t/mpi-distribution-for-an-ocean-model-whats-the-best-way-to-deal-with-processes-that-are-completely-on-land/1010>\
**Category:** COSIMA\
**Tags:** cosima, knowledge-base, model\
**Created:** [18 July 2023 15:57 UTC](https://forum.access-hive.org.au/t/mpi-distribution-for-an-ocean-model-whats-the-best-way-to-deal-with-processes-that-are-completely-on-land/1010 "2023-07-18T15:57:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![navidcy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/navidcy/32/101_2.png) [@navidcy](https://forum.access-hive.org.au/u/navidcy)\
**Post date:** [18 July 2023 15:57 UTC](https://forum.access-hive.org.au/t/mpi-distribution-for-an-ocean-model-whats-the-best-way-to-deal-with-processes-that-are-completely-on-land/1010/1 "2023-07-18T15:57:31Z")

</div>

@ssilvest is working on further optimizing the distributed Oceananigans. We came across the following connundrum. When we distribute the model across several MPI processes there are a few processes are have _only_ land on them (see eg the schematic below for a 48x16 ranks configuration).

 ![Screenshot 2023-07-18 at 9.21.33 AM](https://us1.discourse-cdn.com/flex020/uploads/access1/original/1X/89830791296d7e6b205a5fe3d75f1a87622f0252.jpeg)

So the processes that correspond to regions that are completely over land do not contribute anything. While we don’t compute any tendencies for the points on land, still, we _do_ load the corresponding MPI processes that ends up allocating a GPU (or CPU) for those regions. And that GPU/CPU ends up doing no work at all!

If there was a way to avoid starting an MPI process on those regions it would help. But it seems like a complicated logistically since then we’d have to skip some MPI processes and renumber the ranks and the way communication is done…

Question: How do we handle this in ACCESS-OM2 – if we are handling it at all? Or we just ignore it and just launch MPI processes on land?

cc @glwagner @Aidan @dougiesquire

---

<div class="post-metadata">

**Author:** ![micael](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/micael/32/93_2.png) [@micael](https://forum.access-hive.org.au/u/micael)\
**Post date:** [18 July 2023 22:34 UTC](https://forum.access-hive.org.au/t/mpi-distribution-for-an-ocean-model-whats-the-best-way-to-deal-with-processes-that-are-completely-on-land/1010/2 "2023-07-18T22:34:12Z")

</div>

> [@navidcy](#):
>
> If there was a way to avoid starting an MPI process on those regions it would help. But it seems like a complicated logistically since then we’d have to skip some MPI processes and renumber the ranks and the way communication is done…

I’m afraid there’s no “simple” trick here. The solution is indeed to renumber ranks and change the way how you do communications. AFAIK, this is how it’s done in both MOM5 and MOM6.

But even that solution is not optimal, as you will still large load-imbalances because of the domains that intersect the coastline. To solve that, you need to allow for domain of arbitrary shapes. This increases the code complexity another notch, but based on my experience I would say it’s worth it. I don’t know if there are codes in fluid-dynamics that do this, but I’ve develop a finite-differences code that does precisely that, and its parallel scalability is extremely good.

---

<div class="post-metadata">

**Author:** ![angus-g](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/angus-g/32/89_2.png) [@angus-g](https://forum.access-hive.org.au/u/angus-g)\
**Post date:** [19 July 2023 00:31 UTC](https://forum.access-hive.org.au/t/mpi-distribution-for-an-ocean-model-whats-the-best-way-to-deal-with-processes-that-are-completely-on-land/1010/3 "2023-07-19T00:31:57Z")

</div>

The FMS-based models, i.e. ACCESS-OM2 and MOM6, rely on the land mask preprocessing to solve the problem of not starting a process which would lie completely on the land. There’s a lot of (probably significantly overcomplicated) logic within FMS itself to then handle the domain connectivity.

> [@micael](#):
>
> To solve that, you need to allow for domain of arbitrary shapes. This increases the code complexity another notch, but based on my experience I would say it’s worth it. I don’t know if there are codes in fluid-dynamics that do this…

There are indeed unstructured mesh models, like FVCOM and MPAS-Ocean. I also think that would have been a potentially nicer way to go about things, especially with the wealth of libraries for handling domain decomposition on unstructured meshes, etc. I do wonder how it would impact the ease and efficiency of analysis however…

---

<div class="post-metadata">

**Author:** ![micael](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/micael/32/93_2.png) [@micael](https://forum.access-hive.org.au/u/micael)\
**Post date:** [19 July 2023 01:00 UTC](https://forum.access-hive.org.au/t/mpi-distribution-for-an-ocean-model-whats-the-best-way-to-deal-with-processes-that-are-completely-on-land/1010/4 "2023-07-19T01:00:25Z")

</div>

> [@angus-g](#):
>
> There are indeed unstructured mesh models, like FVCOM and MPAS-Ocean. I also think that would have been a potentially nicer way to go about things, especially with the wealth of libraries for handling domain decomposition on unstructured meshes, etc. I do wonder how it would impact the ease and efficiency of analysis however…

Interesting. What about codes using structured grids?

---

<div class="post-metadata">

**Author:** ![angus-g](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/angus-g/32/89_2.png) [@angus-g](https://forum.access-hive.org.au/u/angus-g)\
**Post date:** [19 July 2023 01:12 UTC](https://forum.access-hive.org.au/t/mpi-distribution-for-an-ocean-model-whats-the-best-way-to-deal-with-processes-that-are-completely-on-land/1010/5 "2023-07-19T01:12:31Z")

</div>

Do you mean structured grids, but arbitrary shape domains? I’m not aware of anything, although that isn’t to say it doesn’t exist!

---

<div class="post-metadata">

**Author:** ![aekiss](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/aekiss/32/46_2.png) [@aekiss](https://forum.access-hive.org.au/u/aekiss)\
**Post date:** [19 July 2023 05:26 UTC](https://forum.access-hive.org.au/t/mpi-distribution-for-an-ocean-model-whats-the-best-way-to-deal-with-processes-that-are-completely-on-land/1010/6 "2023-07-19T05:26:15Z")

</div>

CICE has the ability to subdivide the computational domain horizontally into tiles (termed “blocks”), and then parallelise by allocating several blocks to each CPU. This can improve load balancing if a similar number of ice-containing and ice-free blocks are allocated to each CPU. Land-only blocks aren’t allocated to a CPU at all. See [Craig et al., (2015)](https://doi.org/10.1177/1094342014548771).

---

<div class="post-metadata">

**Author:** ![navidcy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/navidcy/32/101_2.png) [@navidcy](https://forum.access-hive.org.au/u/navidcy)\
**Post date:** [30 July 2023 13:43 UTC](https://forum.access-hive.org.au/t/mpi-distribution-for-an-ocean-model-whats-the-best-way-to-deal-with-processes-that-are-completely-on-land/1010/7 "2023-07-30T13:43:03Z")

</div>

Thank you all for these. Very useful. 🙏
