Research Article

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

Listing 3

Parallel loop by splitting particles.
! Loop over the particles
do l = my_first_particle, my_last_particle, 4
k = nint(sqrt(real(l) * 0.5))
m = (l − (1 + 2 * k * (k − 1) − 4))/4
    ! First octant
    ! Do some computations
    ! Second octant
    ! Do some computations
    ! Third octant
    ! Do some computations
    ! Fourth octant
    ! Do some computations
end do