Research Article

Using Coarrays to Parallelize Legacy Fortran Applications: Strategy and Case Study

Listing 4

Parallel loop by splitting bands.
! Loop over the bands
do k = my_first_band, my_last_band
 ! Global number
 ! of last particle in (k − 1) band
l = k ** 2 + (k − 1) ** 2 − 1
 ! Loop over the particles in band
do m = 1, k
    ! First octant
   l = l + 1
    ! Do some computations
    ! Second octant
   l = l + 1
    ! Do some computations
    ! Third octant
   l = l + 1
    ! Do some computations
    ! Fourth octant
   l = l + 1
    ! Do some computations
end do
end do