Fortran 2015 coarray distributed processing quick start

A key reason to use Coarrays is that they are a higher-level construct than OpenMPI, and allow using various libraries including alternatives to OpenMPI. Much simpler Coarray vs. OpenMPI syntax makes debugging easier in general.

At this time (August 2017), Gfortran has the best/widest support for Fortran 2015, particularly the Coarray features so useful in high-performance computing.

How to install Coarray Fortran features

Coarray Fortran as enabled in Fortran 2008 and Fortran 2015 standards is available via:

Intel Fortran Parallel Studio coarray

Note that only parts of Fortran 2008 and Fortran 2015 standards are supported by ifort. In particular the co_sum, co_broadcast and similar from TS18508 are missing even from Intel Parallel Studio 2018.

ifort -coarray

enables the coarray features.

Gfortran coarray

  • Ubuntu ≥ 17.04

      apt install libcoarrays-dev libopenmpi-dev
    
  • Ubuntu ≤ 16.10: linuxbrew

      brew install opencoarrays
    
  • Debian Stretch 9 (as on Raspberry Pi)

      apt install libcoarrays-dev libopenmpi-dev
    
  • Mac OS: homebrew

      brew install opencoarrays
    

Linuxbrew

  1. Install Linuxbrew, pressing Ctrl-D when asked for the password so that it installs to ~/.linuxbrew without Sudo.
  2. install OpenCoarrays

     brew install opencoarrays
    

Replacing missing TS18508 features

It’s frustrating that Intel Parallel Studio 2018 still is missing many TS18508 (Fortran 2015) features like co_sum. This minimal working example has a co_sum() replacement from lines 27-32.

Examples

Fortran Coarray examples starting with coarray_*.f90.

Reference

Leave a Comment