# Coarray usage resources

**URL:** <https://fortran-lang.discourse.group/t/coarray-usage-resources/2570>\
**Category:** Uncategorized\
**Created:** [January 13, 2022, 12:24am UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570 "2022-01-13T00:24:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![nncarlson](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/nncarlson/32/1175_2.png) [@nncarlson](https://fortran-lang.discourse.group/u/nncarlson)\
**Post date:** [January 13, 2022, 12:24am UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/1 "2022-01-13T00:24:30Z")

</div>

Now that I have lots of free time I’m finally starting to dig into coarrays as an alternative to MPI. Quite a few years ago now in the very early days of coarrays, someone – a european, Italian maybe? – had created a series of examples of how to implement various parallel programming approaches using coarrays. Does anyone recall his name or where those examples can be found?

I’d also be interested in any similar resources that approach coarrays from the perspective of an MPI user.

---

<div class="post-metadata">

**Author:** ![fortran4r](https://avatars.discourse-cdn.com/v4/letter/f/9de0a6/32.png) [@fortran4r](https://fortran-lang.discourse.group/u/fortran4r)\
**Post date:** [January 13, 2022, 12:44am UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/2 "2022-01-13T00:44:17Z")

</div>

> **[Kernels/FORTRAN at default · ParRes/Kernels](https://github.com/ParRes/Kernels/tree/default/FORTRAN)**
>
> default/FORTRAN

---

<div class="post-metadata">

**Author:** ![FortranFan](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@FortranFan](https://fortran-lang.discourse.group/u/FortranFan)\
**Post date:** [January 13, 2022, 3:10am UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/3 "2022-01-13T03:10:37Z")

</div>

> [@nncarlson](#):
>
> … I’d also be interested in any similar resources that approach coarrays from the perspective of an MPI user.

Perhaps not as much as from a comparison or size-by-side formulation of SPMD programs using the **coarray** Fortran approach relative to the MPI model but as a semiformal reference into the thoughts of an inventor of the coarray model, a resource worth reviewing closely is [**Parallel Programming with Co-arrays**](https://www.taylorfrancis.com/books/mono/10.1201/9780429437182/parallel-programming-co-arrays-robert-numrich) by Robert Numrich (Taylor & Francis, 2018).

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [January 13, 2022, 3:40am UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/4 "2022-01-13T03:40:40Z")

</div>

Not exactly from the perspective of a MPI user, but here are two resources I’ve found interesting:

- [History of coarrays and SPMD parallelism in Fortran | ACM Journals](https://doi.org/10.1145/3386322)
- [Parallel numerical algorithms based on tensor notation and Co-Array Fortran syntax - ScienceDirect](https://www.sciencedirect.com/science/article/abs/pii/S0167819105000372)

---

<div class="post-metadata">

**Author:** ![nncarlson](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/nncarlson/32/1175_2.png) [@nncarlson](https://fortran-lang.discourse.group/u/nncarlson)\
**Post date:** [January 13, 2022, 3:43am UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/5 "2022-01-13T03:43:17Z")

</div>

After a lot more searching the of the comp.lang.fortran archives I stumbled across his name, Michael Siehl. His examples are in many github repos: [MichaelSiehl (Michael Siehl) · GitHub](https://github.com/MichaelSiehl)

---

<div class="post-metadata">

**Author:** ![cmaapic](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/cmaapic/32/659_2.png) [@cmaapic](https://fortran-lang.discourse.group/u/cmaapic)\
**Post date:** [January 13, 2022, 1:11pm UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/6 "2022-01-13T13:11:20Z")

</div>

He published with ACM Fortran Forum too. Here is one link [https://dl.acm.org/doi/10.1145/2980025.2980026](https://dl.acm.org/doi/10.1145/2980025.2980026)

---

<div class="post-metadata">

**Author:** ![nshaffer](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/nshaffer/32/161_2.png) [@nshaffer](https://fortran-lang.discourse.group/u/nshaffer)\
**Post date:** [January 13, 2022, 2:04pm UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/7 "2022-01-13T14:04:46Z")

</div>

He’s here as @Federchen as well

---

<div class="post-metadata">

**Author:** ![Federchen](https://avatars.discourse-cdn.com/v4/letter/f/ce7236/32.png) [@Federchen](https://fortran-lang.discourse.group/u/Federchen)\
**Post date:** [January 14, 2022, 12:38am UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/8 "2022-01-14T00:38:10Z")

</div>

Thanks for mentioning me and pointing to my Githubs. Nevertheless, much has changed and things are still changing with my coarray programming and I am currently preparing for completely different ways to program with Coarray Fortran: Channels and coroutines.

Simply said, channels allow non-blocking data transfer between coroutines (the blocking is surrounding the coroutines), and groups of coroutines do execute on the same threads (coarray images) at the same time (in constant change): If one group of coroutines must wait with further execution until a data transfer through a channel has completed, another group of coroutines (that uses a different channel for the data transfer between them) can still execute on the same coarray images. Advantages should be a boost of performance (each coarray image does always execute some portion of a task) and a safe and simple parallel programming style (using channels, coarrays and the required synchronizations are hidden).

It is still raw prototyping yet but it works the same with ifort and Gfortran/OpenCoarrays. (Gfortran/OpenCoarrays has some advantages yet). I did not try with the NAG compiler yet.

My current plans for upcoming Github repositories are:

- Implementing coroutines with Coarray Fortran
- A new type of synchronization method to implement channels with Coarray Fortran
- Implementing channels based on coarrays
- Implementing a Fragmented Objects model with Coarray Fortran

> **[MichaelSiehl - Overview](https://github.com/michaelsiehl)**
>
> MichaelSiehl has 29 repositories available. Follow their code on GitHub.

cheers

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [January 19, 2022, 4:05pm UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/9 "2022-01-19T16:05:44Z")

</div>

@nncarlson what resources did you find useful to learn coarrays? I couldn’t find a good comprehensive online tutorial.

I found this paper:

Numrich, Robert W., and John Reid. “Co-Array Fortran for parallel programming.” _ACM Sigplan Fortran Forum_ . Vol. 17. No. 2. New York, NY, USA: ACM, 1998. ftp://hsl.rl.ac.uk/pub/reports/nrRAL98060.pdf

I also found this paper very interesting, for a background:

Numrich, Robert W. “Parallel numerical algorithms based on tensor notation and Co-Array Fortran syntax.” _Parallel Computing_ 31.6 (2005): 588-607. [Redirecting](https://doi.org/10.1016/j.parco.2005.03.003)

Then searching coarray in [Learn Fortran - Fortran Programming Language](https://fortran-lang.org/learn/) reveals these two additional resources:

- [Parallel programming with Fortran 2008 and 2018 coarrays](https://coarrays.sourceforge.io/doc.html)
- [coarray-tutorial/tutorial.md at main · tkoenig1/coarray-tutorial · GitHub](https://github.com/tkoenig1/coarray-tutorial/blob/main/tutorial.md)

Both seem relatively short, but should be enough to get started.

Probably this book mentioned above: [Coarray usage resources - #3 by FortranFan](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/3) might be a good resource, but I don’t currently have it. I believe Milan’s book ([Modern Fortran](https://www.manning.com/books/modern-fortran)) also had a coarray tutorial, but I currently don’t have it either.

---

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [January 19, 2022, 4:43pm UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/10 "2022-01-19T16:43:51Z")

</div>

Two more resources:

- [Summary of](https://www.lrz.de/services/software/parallel/pgas/caf/N1824.pdf) the coarray feature (as covered in the Fortran 2008 standard) by John Reid.
- Andy Vaught’s [coarray compendium](https://www.lrz.de/services/software/parallel/pgas/caf/compendium.pdf)

(links taken from the [Coarray Fortran on LRZ’s HPC systems](https://doku.lrz.de/display/PUBLIC/Coarray+Fortran+on+LRZ%27s+HPC+systems) page of the Leibniz Supercomputing Centre)

---

<div class="post-metadata">

**Author:** ![nncarlson](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/nncarlson/32/1175_2.png) [@nncarlson](https://fortran-lang.discourse.group/u/nncarlson)\
**Post date:** [January 19, 2022, 4:50pm UTC](https://fortran-lang.discourse.group/t/coarray-usage-resources/2570/11 "2022-01-19T16:50:20Z")

</div>

Well I’m only at the initial stages of “learning” coarrays, and the only sources I have so far are the ones suggested by posters in this thread, which I am still working my way through. I was able to look at the Numrich book suggested by @FortranFan online via LANL. It gives a decent basic intro, but probably a majority of the material deals with implementation details of how to parallel decompose a problem, which is independent of coarrays, and only slips in coarrays as the last piece. I’ll add the papers you found to my list. If I find something I find particularly useful I’ll be sure to post about it here.

A tutorial that I think would be very helpful which I didn’t find, is a nuts-and-bolts “Getting started with coarrays”, which is concerned solely with how to compile and run a coarray program, including installation of additional software, if any, beyond the basic compiler. OpenCoarrays has done a nice job for gfortran, but I’m thinking of a comprehensive one-stop tutorial that covers all compilers. Things vary significantly between compilers; I found Intel to be particularly obtuse. Portability is a key thing when I am considering using a new feature, so from the outset I needed to be able to run my learning examples on multiple platforms (Intel, gfortran, and NAG so far).
